Check-in [62ae333b39]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add some more base system calls and otherwise.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-springcoat-bringup
Files: files | file ages | folders
SHA1: 62ae333b39b02a3caf615366f6e559d7deb5088e
User & Date: stephanie.gawroriski 2020-05-11 02:34:15
Context
2020-05-12
12:38
Implement CHECK_FOR_COMPATIBILITY system call. check-in: 59b3122181 user: stephanie.gawroriski tags: wip-springcoat-bringup
2020-05-11
02:34
Add some more base system calls and otherwise. check-in: 62ae333b39 user: stephanie.gawroriski tags: wip-springcoat-bringup
2020-05-10
20:19
Add clarification to API_LEVEL. check-in: 95a65f9e94 user: stephanie.gawroriski tags: wip-springcoat-bringup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to .idea/dictionaries/xer.xml.

60
61
62
63
64
65
66

67
68
69
70
71
72
73
      <w>lowercased</w>
      <w>meep</w>
      <w>microedition</w>
      <w>midlet</w>
      <w>midp</w>
      <w>moob</w>
      <w>multiphasicapps</w>

      <w>namep</w>
      <w>narg</w>
      <w>nextp</w>
      <w>nomanifest</w>
      <w>ourself</w>
      <w>parm</w>
      <w>phasic</w>







>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
      <w>lowercased</w>
      <w>meep</w>
      <w>microedition</w>
      <w>midlet</w>
      <w>midp</w>
      <w>moob</w>
      <w>multiphasicapps</w>
      <w>mutf</w>
      <w>namep</w>
      <w>narg</w>
      <w>nextp</w>
      <w>nomanifest</w>
      <w>ourself</w>
      <w>parm</w>
      <w>phasic</w>

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/Constants.java.

102
103
104
105
106
107
108
109



110

	/** The thread ID for out-of-bound IPC events. */
	int OOB_IPC_THREAD =
		0xFFFFFFFF;
	
	/** This is the API level that is used for "new" SquirrelJME versions. */
	int API_LEVEL_2020_05_10 =
		4_0_20131;
}












|
>
>
>
|
>
102
103
104
105
106
107
108
109
110
111
112
113
114
	/** The thread ID for out-of-bound IPC events. */
	int OOB_IPC_THREAD =
		0xFFFFFFFF;
	
	/** This is the API level that is used for "new" SquirrelJME versions. */
	int API_LEVEL_2020_05_10 =
		4_0_20131;
	
	/** The current API level. */
	int API_LEVEL_CURRENT =
		4_0_20131;
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/HardwareThread.java.

74
75
76
77
78
79
80





























81
82
83
84
85
86
			HardwareThreadControl.CONTROL_THREAD_SET_TASKID,
			threadId, useTaskId);
		
		// {@squirreljme.error ZZ47 Could not set initial task ID of new
		// thread.}
		if (SystemCall.hasError(SystemCallIndex.HW_THREAD))
			throw new IllegalThreadStateException("ZZ47");





























		
		// Hardware threads are very low level, so there is not much to
		// initialize here
		return hw;
	}
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
			HardwareThreadControl.CONTROL_THREAD_SET_TASKID,
			threadId, useTaskId);
		
		// {@squirreljme.error ZZ47 Could not set initial task ID of new
		// thread.}
		if (SystemCall.hasError(SystemCallIndex.HW_THREAD))
			throw new IllegalThreadStateException("ZZ47");
		
		// If this is a main task we are going to have to initialize a context
		// to store thread information and such inside of it (such as classes
		// or other things)
		if (__main)
		{
			// Initialize a new context
			Assembly.sysCallV(SystemCallIndex.HW_THREAD,
				HardwareThreadControl.CONTROL_INITIALIZE_CONTEXT, useTaskId);
			
			// {@squirreljme.error ZZ48 Could not initialize a context for
			// the main thread.}
			if (SystemCall.hasError(SystemCallIndex.HW_THREAD))
				throw new IllegalThreadStateException("ZZ48");
		}
		
		// Otherwise we want to use the context that is part of the main task
		else
		{
			// Use pre-existing context, which will be the main thread/task
			Assembly.sysCallV(SystemCallIndex.HW_THREAD,
				HardwareThreadControl.CONTROL_SET_CONTEXT,
				threadId, useTaskId);
				
			// {@squirreljme.error ZZ49 Could not set the new hardware thread
			// context to be that of the main thread.}
			if (SystemCall.hasError(SystemCallIndex.HW_THREAD))
				throw new IllegalThreadStateException("ZZ49");
		}
		
		// Hardware threads are very low level, so there is not much to
		// initialize here
		return hw;
	}
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/HardwareThreadControl.java.

8
9
10
11
12
13
14


15
16
17
18
19
20
21
..
33
34
35
36
37
38
39
40

































41
42
43

44
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

/**
 * System call controls for hardware threads.
 *


 * @since 2020/05/01
 */
public interface HardwareThreadControl
{
	/**
	 * Creates a new hardware thread, the task ID of the thread will be the
	 * same as that of the creator of the hardware thread.
................................................................................
	 *
	 * @squirreljme.syscallparam 1 The hardware thread ID.
	 * @squirreljme.syscallparam 2 The task ID to use.
	 * @since 2020/05/01
	 */
	byte CONTROL_THREAD_SET_TASKID =
		2;
	

































	/** The number of hardware controls. */
	byte NUM_CONTROLS =
		3;

}







>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<
>

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

78
79
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

/**
 * System call controls for hardware threads.
 *
 * This is used with {@link SystemCallIndex#HW_THREAD}.
 *
 * @since 2020/05/01
 */
public interface HardwareThreadControl
{
	/**
	 * Creates a new hardware thread, the task ID of the thread will be the
	 * same as that of the creator of the hardware thread.
................................................................................
	 *
	 * @squirreljme.syscallparam 1 The hardware thread ID.
	 * @squirreljme.syscallparam 2 The task ID to use.
	 * @since 2020/05/01
	 */
	byte CONTROL_THREAD_SET_TASKID =
		2;
	
	/**
	 * Initializes a new context for the given thread, the created context will
	 * always have the same ID as the main thread and is used to refer to it.
	 *
	 * @squirreljme.syscallparam 1 The thread ID.
	 * @since 2020/05/10
	 */
	byte CONTROL_INITIALIZE_CONTEXT =
		3;
	
	/**
	 * Sets the context for a given thread to be the same as the one that was
	 * already initialized.
	 *
	 * @squirreljme.syscallparam 1 The thread to set the context of.
	 * @squirreljme.syscallparam 2 The context of another thread to use.
	 * @since 2020/05/10
	 */
	byte CONTROL_SET_CONTEXT =
		4;
	
	/**
	 * Pushes the specified ROM reference to the classpath of the given
	 * context.
	 *
	 * @squirreljme.syscallparam 1 The main thread context to push to.
	 * @squirreljme.syscallparam 2 The ROM reference (high bytes).
	 * @squirreljme.syscallparam 2 The ROM reference (low bytes).
	 * @since 2020/05/10
	 */
	byte CONTROL_PUSH_CLASSPATH =
		5;
	
	/** The number of hardware controls. */
	byte NUM_CONTROLS =

		6;
}

Added modules/cldc-compact/src/main/java/cc/squirreljme/jvm/RomAccessControl.java.















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm;

/**
 * Controls that are used to access the ROM and Soft ROM (if available).
 *
 * This is used by {@link SystemCallIndex#ROM_ACCESS}.
 *
 * It is not defined what a ROM reference identifier will be, except that
 * {@code 0} indicates no ROM value. The values must conform to a 64-bit
 * integer, since it is possible that for simplicity a memory address could
 * be used.
 *
 * @since 2020/05/10
 */
public interface RomAccessControl
{
	/**
	 * Search for a JAR ROM with a modified UTF string.
	 *
	 * @squirreljme.syscallparam 1 Pointer (high bytes) to a modified UTF
	 * string.
	 * @squirreljme.syscallparam 2 Pointer (low bytes).
	 * @squirreljme.syscallreturn A 64-bit ROM Reference, or {@code 0} if not
	 * found.
	 * @since 2020/05/10
	 */
	byte CONTROL_SEARCH_BY_JAR_MUTF =
		1;
	
	/**
	 * Search for a JAR ROM with a UTF-8 encoded byte array.
	 *
	 * @squirreljme.syscallparam 1 Pointer (high bytes) to a UTF-8 encoded
	 * byte array.
	 * @squirreljme.syscallparam 2 Pointer (low bytes).
	 * @squirreljme.syscallreturn A 64-bit ROM Reference, or {@code 0} if not
	 * found.
	 * @since 2020/05/10
	 */
	byte CONTROL_SEARCH_BY_JAR_BYTES =
		2;
	
	/** The number of controls. */
	byte NUM_CONTROLS =
		3;
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallIndex.java.

21
22
23
24
25
26
27

28
29
30
31
32
33
34
..
37
38
39
40
41
42
43

44
45
46
47
48
49
50
..
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
..
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
191
192
193
194

195
196
197
198
199
200
201
202
203
204
205
206
207

208
209
210
211
212
213
214
...
217
218
219
220
221
222
223

224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240
241
242
243
244

245
246
247
248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
297

298
299
300
301
302
303
304
305
306
307

308
309
310
311
312
313
314
315
316
317
318

319
320
321
322
323
324

325


326
327
328

329
330
331
332
333
334

335
336
337
338
339
340

341
342
343
344
345
346
347
...
348
349
350
351
352
353
354

355
356
357
358
359
360
361
362
363
364
365
366

367
368
369
370
371
372
373
374
375
376
377

378
379
380
381
382
383
384
385
386

387
388
389
390
391
392
393
394
395
396
397

398
399
400
401
402
403
404
405
406
407
408
409
410

411
412
413
414
415
416
417
418


419
420
421
422
423
424
425
426
427
428
429
430
431

432
433
434
435
436
437
438

439
440
441
442
443
444
445
446
447
448
449
450
451

452
453
454
455
456
457
458
...
477
478
479
480
481
482
483























484
485
486
487
488
489
490
491
492
493
{
	/**
	 * Checks if the system call is supported.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn Zero if not supported, otherwise a non-zero
	 * value.

	 */
	byte QUERY_INDEX =
		0;
	
	/**
	 * Gets the last error code.
	 *
................................................................................
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn The last error code, will be zero if the last
	 * command succeeded.

	 */
	byte ERROR_GET =
		1;
	
	/**
	 * Sets the last error code.
	 *
................................................................................
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallparam 2 The value to set error register to.
	 * @squirreljme.syscallreturn The value which was previously in the
	 * register.

	 */
	byte ERROR_SET =
		2;
	
	/**
	 * Current wall clock milliseconds.
	 *
	 * @squirreljme.syscallreturn The current milliseconds time.

	 */
	byte TIME_MILLI_WALL =
		3;
	
	/**
	 * Returns the cross-IPC exception class which has been stored.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallreturn The exception which has been stored.

	 */
	byte EXCEPTION_LOAD =
		4;
	
	/**
	 * Current monotonic clock nanoseconds (low).
	 *
	 * @squirreljme.syscallreturn The monotonic nanoseconds time.

	 */
	byte TIME_NANO_MONO =
		5;
	
	/**
	 * Stores the cross-IPC exception class for system call errors.
	 *
................................................................................
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallparam 1 The exception to store.
	 * @squirreljme.syscallreturn The old value that was stored in the
	 * register.

	 */
	byte EXCEPTION_STORE =
		6;
	
	/**
	 * VM Information: Free memory in bytes.
	 *
	 * @squirreljme.syscallreturn The free memory amount in bytes.

	 */
	byte VMI_MEM_FREE =
		7;
	
	/**
	 * VM Information: Used memory in bytes.
	 *
	 * @squirreljme.syscallreturn The used memory amount in bytes.

	 */
	byte VMI_MEM_USED =
		8;
	
	/**
	 * VM Information: Max memory in bytes.
	 *
	 * @squirreljme.syscallreturn The max memory amount in bytes.

	 */
	byte VMI_MEM_MAX =
		9;
	
	/**
	 * Suggests that the garbage collector should run, note that this may be
	 * a deferred operation and might not be immediate.
	 *
	 * @squirreljme.syscallreturn Generally zero although any other value could
	 * be returned.

	 */
	byte GARBAGE_COLLECT =
		10;
	
	/**
	 * Exits the VM with the given exit code.
	 *
	 * @squirreljme.syscallparam 1 The exit code to exit the process with.
	 * @squirreljme.syscallreturn This generally does not return, if it does
	 * then the error code will likely specify why this failed.

	 */
	byte EXIT =
		11;
	
	/**
	 * The API Level of the VM, this value should not change much and signifies
	 * the binary compatibility of SquirrelJME. Breaking changes that will
	 * completely invalidate a ROM should result in this value being changed.
	 *
	 * @squirreljme.syscallreturn The API level of the virtual machine, for
	 * older VMs this will be one of the {@link ApiLevel} values, for all
	 * new and current VMs this will be {@link Constants#API_LEVEL_2020_05_10}.

	 */
	byte API_LEVEL =
		12;
	
	/**
	 * The pipe descriptor for stdin.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard input.

	 */
	byte PD_OF_STDIN =
		13;
	
	/**
	 * The pipe descriptor for stdout.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard output.

	 */
	byte PD_OF_STDOUT =
		14;
	
	/**
	 * The pipe descriptor for stderr.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard error.

	 */
	byte PD_OF_STDERR =
		15;
	
	/**
	 * Pipe descriptor: Write single byte.
	 *
	 * @squirreljme.syscallparam 1 The pipe descriptor.
	 * @squirreljme.syscallparam 2 The value of the byte to write, only the
	 * lowest 8-bits is used.
	 * @squirreljme.syscallreturn The number of bytes written to the output,
	 * if this returns a value lower than zero then it indicates an error.

	 */
	byte PD_WRITE_BYTE =
		16;
	
	/**
	 * Bulk sets the memory inside of a region, this follows the same pattern
	 * as C's {@code memset()} operation.
	 *
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set.
	 * @squirreljme.syscallreturn The number of bytes actually written, if this
	 * is zero then it is likely the system call is not supported.

	 */
	byte MEM_SET =
		17;
	
	/**
	 * Bulk sets the memory inside of a region writing full integer values at
	 * a time which is generally faster, this follows the same pattern as C's
................................................................................
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set, the lower 2-bits
	 * ({@code 0x3}) will be masked off so the length is always a multiple of
	 * four.
	 * @squirreljme.syscallreturn The number of bytes actually written,
	 * if this is zero then it is likely the system call is not supported.

	 */
	byte MEM_SET_INT =
		18;
	
	/**
	 * Get the height of the call stack.
	 *
	 * @squirreljme.syscallreturn The height of the call stack.

	 */
	byte CALL_STACK_HEIGHT =
		19;
	
	/**
	 * Gets the specified call stack item.
	 *
	 * @squirreljme.syscallparam 1 The number of frames from the top of the
	 * call stack to get the items for, zero will be the top-most item.
	 * @squirreljme.syscallparam 2 The item to obtain as specified in
	 * {@link CallStackItem}.
	 * @squirreljme.syscallreturn The value of the item, if it is undefined or
	 * not supported then zero will be returned.

	 */
	byte CALL_STACK_ITEM =
		20;
	
	/**
	 * Returns the string of the given pointer.
	 *
	 * @squirreljme.syscallparam 1 The pointer to the modified UTF encoded
	 * string.
	 * @squirreljme.syscallreturn An instance of {@link String}.

	 */
	byte LOAD_STRING =
		21;
	
	/**
	 * Fatal ToDo hit.
	 *
	 * @squirreljme.syscallparam 1 The code to use for the To Do.
	 * @squirreljme.syscallreturn This should not return unless it is not
	 * supported.

	 */
	byte FATAL_TODO =
		22;
	
	/**
	 * This is used to indicate that the supervisor booted correctly and that
	 * execution control is normal.
	 *
	 * @squirreljme.syscallreturn Generally zero as no value is intended to be
	 * returned.

	 */
	byte SUPERVISOR_BOOT_OKAY =
		23;
	
	/**
	 * Get, set, or change a property of the framebuffer, the properties which
	 * are defined are specified in {@link Framebuffer}.
	 *
	 * @squirreljme.syscallparam 1 The frame buffer property to select.
	 * @squirreljme.syscallparam ... Undefined, this depends on the property
	 * selected.
	 * @squirreljme.syscallreturn Whatever value the frame buffer property will
	 * return.

	 */
	byte FRAMEBUFFER =
		24;
	
	/**
	 * Returns the native byte order of the system the virtual machine is
	 * running on.
	 *
	 * @squirreljme.syscallreturn Non-zero if little endian, otherwise zero
	 * will be big endian.

	 */
	byte BYTE_ORDER_LITTLE =
		25;
	
	/**
	 * Returns the pointer to the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn A pointer to the data or zero if there is no
	 * option JAR defined in the requested slot.

	 */
	byte OPTION_JAR_DATA =
		26;
	
	/**
	 * Returns the size of the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn The size of the specified option JAR or zero
	 * if there is no
	 * option JAR defined in the requested slot.

	 */
	byte OPTION_JAR_SIZE =
		27;
	
	/**
	 * Loads the specified class for the current thread context.

	 *


	 * @squirreljme.syscallparam 1 The Modified UTF specifying the class name.
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.

	 */
	byte LOAD_CLASS_UTF =
		28;
	
	/**
	 * Loads the specified class for the current thread context.

	 *
	 * @squirreljme.syscallparam 1 Pointer (high bytes) to a UTF-8 encoded
	 * byte array.
	 * @squirreljme.syscallparam 2 Pointer (low bytes).
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.

	 */
	byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
................................................................................
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to set.
	 * @squirreljme.syscallparam 2 The new value of the property.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.

	 */
	byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to get.
	 * @squirreljme.syscallreturn The value of that property, error should be
	 * checked to ensure that it did not fail.

	 */
	byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
	 *
	 * Only the supervisor is allowed to set this.
	 *
	 * @squirreljme.syscallparam 1 The task ID to set.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.

	 */
	@Deprecated
	byte FRAME_TASK_ID_SET =
		32;
	
	/**
	 * Gets the value of a thread register.
	 *
	 * @squirreljme.syscallreturn The value of the task ID.

	 */
	byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @squirreljme.syscallparam 1 The type of {@link DeviceFeedbackType} to
	 * perform.
	 * @squirreljme.syscallparam 2 The duration of the feedback.
	 * @squirreljme.syscallreturn Non-zero on success.

	 */
	byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * If the time to wait is zero, then it will indicate that the current
	 * thread is yielding its execution cycles.
	 *
	 * @squirreljme.syscallparam 1 The number of milliseconds to sleep for.
	 * @squirreljme.syscallparam 2 The number of nanoseconds to sleep for.
	 * @squirreljme.syscallreturn Returns zero unless sleep was interrupted.

	 */
	byte SLEEP =
		35;
	
	/**
	 * If the framebuffer is shared with the console, this tells the console
	 * printer to not send messages to the screen as it will corrupt the
	 * display on the screen.


	 */
	byte SQUELCH_FB_CONSOLE =
		36;
	
	/**
	 * Perform IPC call.
	 *
	 * @squirreljme.syscallparam 1 The task to call, {@code 0} is the
	 * supervisor.
	 * @squirreljme.syscallparam 2 The IPC identifier which specifies which
	 * service this was associated with.
	 * @squirreljme.syscallparam ... Any arguments to the call.
	 * @squirreljme.syscallreturn The value returned from the remote call.

	 */
	byte IPC_CALL =
		37;
	
	/**
	 * Returns flags used to change how debugging is used within SquirreLJME.
	 *

	 * @since 2020/03/15
	 */
	byte DEBUG_FLAGS =
		38;
	
	/**
	 * This is the hardware thread interface and this allows the code within
	 * the virtual machine to manage these.
	 *
	 * Access to this system call should only be permitted by the supervisor
	 * task.
	 *
	 * @squirreljme.syscallparam 1 The hardware thread to manage

	 * @squirreljme.syscallparam ... Any arguments to the call.
	 * @see HardwareThread
	 * @since 2020/04/28
	 */
	byte HW_THREAD =
		39;
	
................................................................................
	 * @squirreljme.syscallreturn The type of the key, which will be one of
	 * {@link ConfigRomType}.
	 * @since 2020/05/03
	 */
	byte CONFIG_GET_TYPE =
		41;
	























	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	byte NUM_SYSCALLS =
		42;
}








>







 







>







 







>








>












>








>







 







>








>








>








>










>










>












>








>








>








>












>













>







 







>








>













>










>










>










>













>










>










>











>





|
>

>
>
|


>

|



|
>






>







 







>












>











>









>











>













>








>
>













>







>












|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
{
	/**
	 * Checks if the system call is supported.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn Zero if not supported, otherwise a non-zero
	 * value.
	 * @since 2019/05/26
	 */
	byte QUERY_INDEX =
		0;
	
	/**
	 * Gets the last error code.
	 *
................................................................................
	 *
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallreturn The last error code, will be zero if the last
	 * command succeeded.
	 * @since 2019/05/26
	 */
	byte ERROR_GET =
		1;
	
	/**
	 * Sets the last error code.
	 *
................................................................................
	 * If the system call index is not valid then it is assumed to be
	 * {@link #QUERY_INDEX}.
	 *
	 * @squirreljme.syscallparam 1 The system call index to query.
	 * @squirreljme.syscallparam 2 The value to set error register to.
	 * @squirreljme.syscallreturn The value which was previously in the
	 * register.
	 * @since 2019/05/26
	 */
	byte ERROR_SET =
		2;
	
	/**
	 * Current wall clock milliseconds.
	 *
	 * @squirreljme.syscallreturn The current milliseconds time.
	 * @since 2019/05/26
	 */
	byte TIME_MILLI_WALL =
		3;
	
	/**
	 * Returns the cross-IPC exception class which has been stored.
	 *
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallreturn The exception which has been stored.
	 * @since 2019/05/26
	 */
	byte EXCEPTION_LOAD =
		4;
	
	/**
	 * Current monotonic clock nanoseconds (low).
	 *
	 * @squirreljme.syscallreturn The monotonic nanoseconds time.
	 * @since 2019/05/26
	 */
	byte TIME_NANO_MONO =
		5;
	
	/**
	 * Stores the cross-IPC exception class for system call errors.
	 *
................................................................................
	 * This system call should have the same effect regardless of whether it
	 * is a supervisor thread or user thread, it does not get forwarded
	 * to the task system call handler.
	 *
	 * @squirreljme.syscallparam 1 The exception to store.
	 * @squirreljme.syscallreturn The old value that was stored in the
	 * register.
	 * @since 2019/05/26
	 */
	byte EXCEPTION_STORE =
		6;
	
	/**
	 * VM Information: Free memory in bytes.
	 *
	 * @squirreljme.syscallreturn The free memory amount in bytes.
	 * @since 2019/05/26
	 */
	byte VMI_MEM_FREE =
		7;
	
	/**
	 * VM Information: Used memory in bytes.
	 *
	 * @squirreljme.syscallreturn The used memory amount in bytes.
	 * @since 2019/05/26
	 */
	byte VMI_MEM_USED =
		8;
	
	/**
	 * VM Information: Max memory in bytes.
	 *
	 * @squirreljme.syscallreturn The max memory amount in bytes.
	 * @since 2019/05/26
	 */
	byte VMI_MEM_MAX =
		9;
	
	/**
	 * Suggests that the garbage collector should run, note that this may be
	 * a deferred operation and might not be immediate.
	 *
	 * @squirreljme.syscallreturn Generally zero although any other value could
	 * be returned.
	 * @since 2019/05/26
	 */
	byte GARBAGE_COLLECT =
		10;
	
	/**
	 * Exits the VM with the given exit code.
	 *
	 * @squirreljme.syscallparam 1 The exit code to exit the process with.
	 * @squirreljme.syscallreturn This generally does not return, if it does
	 * then the error code will likely specify why this failed.
	 * @since 2019/05/26
	 */
	byte EXIT =
		11;
	
	/**
	 * The API Level of the VM, this value should not change much and signifies
	 * the binary compatibility of SquirrelJME. Breaking changes that will
	 * completely invalidate a ROM should result in this value being changed.
	 *
	 * @squirreljme.syscallreturn The API level of the virtual machine, for
	 * older VMs this will be one of the {@link ApiLevel} values, for all
	 * new and current VMs this will be {@link Constants#API_LEVEL_2020_05_10}.
	 * @since 2019/05/26
	 */
	byte API_LEVEL =
		12;
	
	/**
	 * The pipe descriptor for stdin.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard input.
	 * @since 2019/05/27
	 */
	byte PD_OF_STDIN =
		13;
	
	/**
	 * The pipe descriptor for stdout.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard output.
	 * @since 2019/05/27
	 */
	byte PD_OF_STDOUT =
		14;
	
	/**
	 * The pipe descriptor for stderr.
	 *
	 * @squirreljme.syscallreturn The pipe descriptor for standard error.
	 * @since 2019/05/27
	 */
	byte PD_OF_STDERR =
		15;
	
	/**
	 * Pipe descriptor: Write single byte.
	 *
	 * @squirreljme.syscallparam 1 The pipe descriptor.
	 * @squirreljme.syscallparam 2 The value of the byte to write, only the
	 * lowest 8-bits is used.
	 * @squirreljme.syscallreturn The number of bytes written to the output,
	 * if this returns a value lower than zero then it indicates an error.
	 * @since 2019/05/27
	 */
	byte PD_WRITE_BYTE =
		16;
	
	/**
	 * Bulk sets the memory inside of a region, this follows the same pattern
	 * as C's {@code memset()} operation.
	 *
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set.
	 * @squirreljme.syscallreturn The number of bytes actually written, if this
	 * is zero then it is likely the system call is not supported.
	 * @since 2019/05/27
	 */
	byte MEM_SET =
		17;
	
	/**
	 * Bulk sets the memory inside of a region writing full integer values at
	 * a time which is generally faster, this follows the same pattern as C's
................................................................................
	 * @squirreljme.syscallparam 1 The address to set.
	 * @squirreljme.syscallparam 2 The value to set the region with.
	 * @squirreljme.syscallparam 3 The number of bytes to set, the lower 2-bits
	 * ({@code 0x3}) will be masked off so the length is always a multiple of
	 * four.
	 * @squirreljme.syscallreturn The number of bytes actually written,
	 * if this is zero then it is likely the system call is not supported.
	 * @since 2019/06/15
	 */
	byte MEM_SET_INT =
		18;
	
	/**
	 * Get the height of the call stack.
	 *
	 * @squirreljme.syscallreturn The height of the call stack.
	 * @since 2019/06/15
	 */
	byte CALL_STACK_HEIGHT =
		19;
	
	/**
	 * Gets the specified call stack item.
	 *
	 * @squirreljme.syscallparam 1 The number of frames from the top of the
	 * call stack to get the items for, zero will be the top-most item.
	 * @squirreljme.syscallparam 2 The item to obtain as specified in
	 * {@link CallStackItem}.
	 * @squirreljme.syscallreturn The value of the item, if it is undefined or
	 * not supported then zero will be returned.
	 * @since 2019/06/16
	 */
	byte CALL_STACK_ITEM =
		20;
	
	/**
	 * Returns the string of the given pointer.
	 *
	 * @squirreljme.syscallparam 1 The pointer to the modified UTF encoded
	 * string.
	 * @squirreljme.syscallreturn An instance of {@link String}.
	 * @since 2019/06/16
	 */
	byte LOAD_STRING =
		21;
	
	/**
	 * Fatal ToDo hit.
	 *
	 * @squirreljme.syscallparam 1 The code to use for the To Do.
	 * @squirreljme.syscallreturn This should not return unless it is not
	 * supported.
	 * @since 2019/06/16
	 */
	byte FATAL_TODO =
		22;
	
	/**
	 * This is used to indicate that the supervisor booted correctly and that
	 * execution control is normal.
	 *
	 * @squirreljme.syscallreturn Generally zero as no value is intended to be
	 * returned.
	 * @since 2019/06/16
	 */
	byte SUPERVISOR_BOOT_OKAY =
		23;
	
	/**
	 * Get, set, or change a property of the framebuffer, the properties which
	 * are defined are specified in {@link Framebuffer}.
	 *
	 * @squirreljme.syscallparam 1 The frame buffer property to select.
	 * @squirreljme.syscallparam ... Undefined, this depends on the property
	 * selected.
	 * @squirreljme.syscallreturn Whatever value the frame buffer property will
	 * return.
	 * @since 2019/06/20
	 */
	byte FRAMEBUFFER =
		24;
	
	/**
	 * Returns the native byte order of the system the virtual machine is
	 * running on.
	 *
	 * @squirreljme.syscallreturn Non-zero if little endian, otherwise zero
	 * will be big endian.
	 * @since 2019/06/20
	 */
	byte BYTE_ORDER_LITTLE =
		25;
	
	/**
	 * Returns the pointer to the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn A pointer to the data or zero if there is no
	 * option JAR defined in the requested slot.
	 * @since 2019/06/21
	 */
	byte OPTION_JAR_DATA =
		26;
	
	/**
	 * Returns the size of the option JAR data.
	 *
	 * @squirreljme.syscallparam 1 The option JAR slot to request.
	 * @squirreljme.syscallreturn The size of the specified option JAR or zero
	 * if there is no
	 * option JAR defined in the requested slot.
	 * @since 2019/06/29
	 */
	byte OPTION_JAR_SIZE =
		27;
	
	/**
	 * Loads the specified class for the current thread context with a modified
	 * UTF lookup.
	 *
	 * @squirreljme.syscallparam 1 Pointer (high bytes) to a modified UTF
	 * string.
	 * @squirreljme.syscallparam 2 Pointer (low bytes).
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.
	 * @since 2019/10/01
	 */
	byte LOAD_CLASS_MUTF =
		28;
	
	/**
	 * Loads the specified class for the current thread context with a UTF-8
	 * encoded byte array lookup.
	 *
	 * @squirreljme.syscallparam 1 Pointer (high bytes) to a UTF-8 encoded
	 * byte array.
	 * @squirreljme.syscallparam 2 Pointer (low bytes).
	 * @squirreljme.syscallreturn The pointer to the loaded class info, will be
	 * zero on failure.
	 * @since 2019/10/01
	 */
	byte LOAD_CLASS_BYTES =
		29;
	
	/**
	 * Sets the value of a supervisor property.
	 *
................................................................................
	 * Supervisor properties are local to a thread.
	 *
	 * Only the supervisor is allowed to set these properties.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to set.
	 * @squirreljme.syscallparam 2 The new value of the property.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.
	 * @since 2019/10/04
	 */
	byte SUPERVISOR_PROPERTY_SET =
		30;
	
	/**
	 * Gets the value of a supervisor property.
	 *
	 * Supervisor properties are local to a thread.
	 *
	 * @squirreljme.syscallparam 1 The supervisor property to get.
	 * @squirreljme.syscallreturn The value of that property, error should be
	 * checked to ensure that it did not fail.
	 * @since 2019/10/04
	 */
	byte SUPERVISOR_PROPERTY_GET =
		31;
	
	/**
	 * Sets the task ID of the current thread frame.
	 *
	 * Only the supervisor is allowed to set this.
	 *
	 * @squirreljme.syscallparam 1 The task ID to set.
	 * @squirreljme.syscallreturn A non-zero value if this was successful.
	 * @since 2019/10/04
	 */
	@Deprecated
	byte FRAME_TASK_ID_SET =
		32;
	
	/**
	 * Gets the value of a thread register.
	 *
	 * @squirreljme.syscallreturn The value of the task ID.
	 * @since 2019/10/04
	 */
	byte FRAME_TASK_ID_GET =
		33;
	
	/**
	 * Perform a feedback operation.
	 *
	 * @squirreljme.syscallparam 1 The type of {@link DeviceFeedbackType} to
	 * perform.
	 * @squirreljme.syscallparam 2 The duration of the feedback.
	 * @squirreljme.syscallreturn Non-zero on success.
	 * @since 2019/10/06
	 */
	byte DEVICE_FEEDBACK =
		34;
	
	/**
	 * Sleep for the given number of nanoseconds.
	 *
	 * If the time to wait is zero, then it will indicate that the current
	 * thread is yielding its execution cycles.
	 *
	 * @squirreljme.syscallparam 1 The number of milliseconds to sleep for.
	 * @squirreljme.syscallparam 2 The number of nanoseconds to sleep for.
	 * @squirreljme.syscallreturn Returns zero unless sleep was interrupted.
	 * @since 2019/10/06
	 */
	byte SLEEP =
		35;
	
	/**
	 * If the framebuffer is shared with the console, this tells the console
	 * printer to not send messages to the screen as it will corrupt the
	 * display on the screen.
	 *
	 * @since 2019/12/14
	 */
	byte SQUELCH_FB_CONSOLE =
		36;
	
	/**
	 * Perform IPC call.
	 *
	 * @squirreljme.syscallparam 1 The task to call, {@code 0} is the
	 * supervisor.
	 * @squirreljme.syscallparam 2 The IPC identifier which specifies which
	 * service this was associated with.
	 * @squirreljme.syscallparam ... Any arguments to the call.
	 * @squirreljme.syscallreturn The value returned from the remote call.
	 * @since 2019/12/28
	 */
	byte IPC_CALL =
		37;
	
	/**
	 * Returns flags used to change how debugging is used within SquirreLJME.
	 *
	 * @squirreljme.syscallreturn The debug flags, see {@link Constants}.
	 * @since 2020/03/15
	 */
	byte DEBUG_FLAGS =
		38;
	
	/**
	 * This is the hardware thread interface and this allows the code within
	 * the virtual machine to manage these.
	 *
	 * Access to this system call should only be permitted by the supervisor
	 * task.
	 *
	 * @squirreljme.syscallparam 1 The hardware control to execute, this will
	 * be one of {@link HardwareThreadControl}.
	 * @squirreljme.syscallparam ... Any arguments to the call.
	 * @see HardwareThread
	 * @since 2020/04/28
	 */
	byte HW_THREAD =
		39;
	
................................................................................
	 * @squirreljme.syscallreturn The type of the key, which will be one of
	 * {@link ConfigRomType}.
	 * @since 2020/05/03
	 */
	byte CONFIG_GET_TYPE =
		41;
	
	/**
	 * Access to the ROM using various controls.
	 *
	 * @squirreljme.syscallparam 1 The control key, which will be one of
	 * {@link RomAccessControl}.
	 * @squirreljme.syscallparam ... Any extra parameters.
	 * @since 2020/05/10
	 */
	byte ROM_ACCESS =
		42;
	
	/**
	 * Checks for the execution compatibility for SquirrelJME, so that if an
	 * older ROM is running on too new of an execution system where it is not
	 * supported then the ROM will fail to work.
	 *
	 * @squirreljme.syscallparam 1 The API level of the ROM, this will be
	 * the value of {@link Constants#API_LEVEL_CURRENT}.
	 * @since 2020/05/10
	 */
	byte CHECK_EXEC_COMPATIBILITY =
		43;
	
	/**
	 * The number of system calls that are defined in this run-time.
	 *
	 * One must NEVER utilize this value in a system call as it will have
	 * unintended consequences of requesting future API values.
	 */
	byte NUM_SYSCALLS =
		44;
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/boot/SystemBoot.java.

36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51

52
53
54




55
56
57
58
59
60
61
62

















63
64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
109
110
111
112
113
114
115

116
117
118
119
120
121
122
...
136
137
138
139
140
141
142
























143
144
145
146
147
148
149
...
150
151
152
153
154
155
156


157
158
159
160
161
162









163
164
165
166
167
168
169
170
171
172
173
174
	@SuppressWarnings("StaticVariableUsedBeforeInitialization")
	public static ConfigReader config()
	{
		return SystemBoot._config;
	}
	
	/**
	 * Prints a bunch of characters to the output.

	 *
	 * @param __pd The pipe to write to.
	 * @param __a Character A.
	 * @param __b Character B.
	 * @param __c Character C.
	 * @param __d Character D.
	 * @since 2020/05/10
	 */

	private static void __ancientPrint(int __pd, char __a, char __b, char __c,
		char __d)
	{




		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__a >= 0x7F ? '?' : __a));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__b >= 0x7F ? '?' : __b));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__c >= 0x7F ? '?' : __c));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__d >= 0x7F ? '?' : __d));

















	}
	
	/**
	 * This is used when the version of SquirrelJME is too ancient.
	 *
	 * This method assumes that no memory system has been initialized.
	 *
	 * @since 2020/05/10
	 */

	private static void __ancientSquirrelJME()
	{
		// We need to get stderr's output so we can print a message saying
		// that this version is too old and is broken
		int stdErr = Assembly.sysCallPV(SystemCallIndex.PD_OF_STDERR);
		
		// This may seem complicated to print, however when this code runs
		// the allocator cannot actually initialize because the given addresses
		// are not valid...
		// "This version of SquirrelJME requires a newer execution engine..."
		SystemBoot.__ancientPrint(stdErr, 'T', 'h', 'i', 's');
		SystemBoot.__ancientPrint(stdErr, ' ', 'v', 'e', 'r');
		SystemBoot.__ancientPrint(stdErr, 's', 'i', 'o', 'n');
		SystemBoot.__ancientPrint(stdErr, ' ', 'o', 'f', ' ');
		SystemBoot.__ancientPrint(stdErr, 'S', 'q', 'u', 'i');
		SystemBoot.__ancientPrint(stdErr, 'r', 'r', 'e', 'l');
		SystemBoot.__ancientPrint(stdErr, 'J', 'M', 'E', ' ');
		SystemBoot.__ancientPrint(stdErr, 'r', 'e', 'q', 'u');
		SystemBoot.__ancientPrint(stdErr, 'i', 'r', 'e', 's');
		SystemBoot.__ancientPrint(stdErr, ' ', 'a', ' ', 'n');
		SystemBoot.__ancientPrint(stdErr, 'e', 'w', 'e', 'r');
		SystemBoot.__ancientPrint(stdErr, ' ', 'e', 'x', 'e');
		SystemBoot.__ancientPrint(stdErr, 'c', 'u', 't', 'i');
		SystemBoot.__ancientPrint(stdErr, 'o', 'n', ' ', 'e');
		SystemBoot.__ancientPrint(stdErr, 'n', 'g', 'i', 'n');
		SystemBoot.__ancientPrint(stdErr, 'e', '.', '.', '.');
		
		// End line sequence, just assume Windows endings here
		SystemBoot.__ancientPrint(stdErr, '\r', '\n',
			'\r', '\n');
		
		// Try to stop the VM somehow
		Assembly.breakpoint();
		Assembly.sysCallPV(SystemCallIndex.EXIT, -13);
	}
	
................................................................................
	 * Performs the actual boot process.
	 *
	 * @param __ramAddr The RAM Address.
	 * @param __ramLen The length of RAM.
	 * @param __config The configuration data.
	 * @since 2020/05/10
	 */

	static void __boot(long __ramAddr, int __ramLen, ConfigReader __config)
	{
		// Store configuration for later
		SystemBoot._config = __config;
		
		// Spawn our primary process and initialize it
		VirtualProcess primary = VirtualProcess.spawn();
................................................................................
			{
				// Ignore ...
			}
		
		// Now exit with the code
		SystemCall.exit(exitCode);
	}
























	
	/**
	 * System boot entry point.
	 *
	 * @param __ramAddr The RAM address.
	 * @param __ramLen The size of RAM.
	 * @param __configAddr The configuration address.
................................................................................
	 * @param __configLen The configuration length.
	 * @since 2020/03/26
	 */
	@SuppressWarnings({"unused"})
	static void __sysBoot(long __ramAddr, int __ramLen,
		long __configAddr, int __configLen)
	{


		if (Assembly.sysCallPV(SystemCallIndex.API_LEVEL) <
			Constants.API_LEVEL_2020_05_10)
		{
			SystemBoot.__ancientSquirrelJME();
			return;
		}









		
		// Initialize the links in RAM
		Allocator.__initRamLinks(__ramAddr, __ramLen);
		
		// Setup the configuration reader to obtain our entry point info
		ConfigReader config = new ConfigReader(
			new ReadableAssemblyMemory(__configAddr, __configLen));
		
		// Forward to standard boot process
		SystemBoot.__boot(__ramAddr, __ramLen, config);
	}
}







|
>

<
<
<
<
<


>
|
<

>
>
>
>
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>


<
|






|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


|







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>






>
>
>
>
>
>
>
>
>












36
37
38
39
40
41
42
43
44
45





46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	@SuppressWarnings("StaticVariableUsedBeforeInitialization")
	public static ConfigReader config()
	{
		return SystemBoot._config;
	}
	
	/**
	 * This is executed if the execution engine is too new and would not be
	 * capable of running this ROM.
	 *





	 * @since 2020/05/10
	 */
	@SuppressWarnings("FeatureEnvy")
	private static void __advancedSquirrelJME()

	{
		// Get standard error since we cannot use other classes here
		int stdErr = Assembly.sysCallPV(SystemCallIndex.PD_OF_STDERR);
		
		// Need to be able to print without allocating any memory...
		// "This execution engine requires a newer ROM file to execute it..."
		SystemBoot.__lowPrint(stdErr, 'T', 'h', 'i', 's');
		SystemBoot.__lowPrint(stdErr, ' ', 'e', 'x', 'e');
		SystemBoot.__lowPrint(stdErr, 'c', 'u', 't', 'i');
		SystemBoot.__lowPrint(stdErr, 'o', 'n', ' ', 'e');
		SystemBoot.__lowPrint(stdErr, 'n', 'g', 'i', 'n');
		SystemBoot.__lowPrint(stdErr, 'e', ' ', 'r', 'e');
		SystemBoot.__lowPrint(stdErr, 'q', 'u', 'i', 'r');
		SystemBoot.__lowPrint(stdErr, 'e', 's', ' ', 'a');
		SystemBoot.__lowPrint(stdErr, ' ', 'n', 'e', 'w');
		SystemBoot.__lowPrint(stdErr, 'e', 'r', ' ', 'R');
		SystemBoot.__lowPrint(stdErr, 'O', 'M', ' ', 'f');
		SystemBoot.__lowPrint(stdErr, 'i', 'l', 'e', ' ');
		SystemBoot.__lowPrint(stdErr, 't', 'o', ' ', 'e');
		SystemBoot.__lowPrint(stdErr, 'x', 'e', 'c', 'u');
		SystemBoot.__lowPrint(stdErr, 't', 'e', ' ', 'i');
		SystemBoot.__lowPrint(stdErr, 't', '.', '.', '.');
		
		// End line sequence, just assume Windows endings here
		SystemBoot.__lowPrint(stdErr, '\r', '\n',
			'\r', '\n');
		
		// Try to stop the VM somehow
		Assembly.breakpoint();
		Assembly.sysCallPV(SystemCallIndex.EXIT, -14);
	}
	
	/**
	 * This is used when the version of SquirrelJME is too ancient.
	 *
	 * This method assumes that no memory system has been initialized.
	 *
	 * @since 2020/05/10
	 */
	@SuppressWarnings("FeatureEnvy")
	private static void __ancientSquirrelJME()
	{

		// Get standard error since we cannot use other classes here
		int stdErr = Assembly.sysCallPV(SystemCallIndex.PD_OF_STDERR);
		
		// This may seem complicated to print, however when this code runs
		// the allocator cannot actually initialize because the given addresses
		// are not valid...
		// "This version of SquirrelJME requires a newer execution engine..."
		SystemBoot.__lowPrint(stdErr, 'T', 'h', 'i', 's');
		SystemBoot.__lowPrint(stdErr, ' ', 'v', 'e', 'r');
		SystemBoot.__lowPrint(stdErr, 's', 'i', 'o', 'n');
		SystemBoot.__lowPrint(stdErr, ' ', 'o', 'f', ' ');
		SystemBoot.__lowPrint(stdErr, 'S', 'q', 'u', 'i');
		SystemBoot.__lowPrint(stdErr, 'r', 'r', 'e', 'l');
		SystemBoot.__lowPrint(stdErr, 'J', 'M', 'E', ' ');
		SystemBoot.__lowPrint(stdErr, 'r', 'e', 'q', 'u');
		SystemBoot.__lowPrint(stdErr, 'i', 'r', 'e', 's');
		SystemBoot.__lowPrint(stdErr, ' ', 'a', ' ', 'n');
		SystemBoot.__lowPrint(stdErr, 'e', 'w', 'e', 'r');
		SystemBoot.__lowPrint(stdErr, ' ', 'e', 'x', 'e');
		SystemBoot.__lowPrint(stdErr, 'c', 'u', 't', 'i');
		SystemBoot.__lowPrint(stdErr, 'o', 'n', ' ', 'e');
		SystemBoot.__lowPrint(stdErr, 'n', 'g', 'i', 'n');
		SystemBoot.__lowPrint(stdErr, 'e', '.', '.', '.');
		
		// End line sequence, just assume Windows endings here
		SystemBoot.__lowPrint(stdErr, '\r', '\n',
			'\r', '\n');
		
		// Try to stop the VM somehow
		Assembly.breakpoint();
		Assembly.sysCallPV(SystemCallIndex.EXIT, -13);
	}
	
................................................................................
	 * Performs the actual boot process.
	 *
	 * @param __ramAddr The RAM Address.
	 * @param __ramLen The length of RAM.
	 * @param __config The configuration data.
	 * @since 2020/05/10
	 */
	@SuppressWarnings({"FeatureEnvy", "unused"})
	static void __boot(long __ramAddr, int __ramLen, ConfigReader __config)
	{
		// Store configuration for later
		SystemBoot._config = __config;
		
		// Spawn our primary process and initialize it
		VirtualProcess primary = VirtualProcess.spawn();
................................................................................
			{
				// Ignore ...
			}
		
		// Now exit with the code
		SystemCall.exit(exitCode);
	}
	
	/**
	 * Prints a bunch of characters to the output.
	 *
	 * @param __pd The pipe to write to.
	 * @param __a Character A.
	 * @param __b Character B.
	 * @param __c Character C.
	 * @param __d Character D.
	 * @since 2020/05/10
	 */
	@SuppressWarnings("FeatureEnvy")
	private static void __lowPrint(int __pd, char __a, char __b, char __c,
		char __d)
	{
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__a >= 0x7F ? '?' : __a));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__b >= 0x7F ? '?' : __b));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__c >= 0x7F ? '?' : __c));
		Assembly.sysCallP(SystemCallIndex.PD_WRITE_BYTE, __pd,
			(__d >= 0x7F ? '?' : __d));
	}
	
	/**
	 * System boot entry point.
	 *
	 * @param __ramAddr The RAM address.
	 * @param __ramLen The size of RAM.
	 * @param __configAddr The configuration address.
................................................................................
	 * @param __configLen The configuration length.
	 * @since 2020/03/26
	 */
	@SuppressWarnings({"unused"})
	static void __sysBoot(long __ramAddr, int __ramLen,
		long __configAddr, int __configLen)
	{
		// Detect if this is a SquirrelJME that is too old and will not be
		// capable of running this ROM at all.
		if (Assembly.sysCallPV(SystemCallIndex.API_LEVEL) <
			Constants.API_LEVEL_2020_05_10)
		{
			SystemBoot.__ancientSquirrelJME();
			return;
		}
		
		// Additionally check if the execution engine is too new and it will
		// not be compatible with this ROM
		if (Assembly.sysCallPV(SystemCallIndex.CHECK_EXEC_COMPATIBILITY,
			Constants.API_LEVEL_CURRENT) == 0)
		{
			SystemBoot.__advancedSquirrelJME();
			return;
		}
		
		// Initialize the links in RAM
		Allocator.__initRamLinks(__ramAddr, __ramLen);
		
		// Setup the configuration reader to obtain our entry point info
		ConfigReader config = new ConfigReader(
			new ReadableAssemblyMemory(__configAddr, __configLen));
		
		// Forward to standard boot process
		SystemBoot.__boot(__ramAddr, __ramLen, config);
	}
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/lang/ApiLevel.java.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24



25
26
27
28
29
30
31
32
33
34
35
36
37
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.jvm.Assembly;

import cc.squirreljme.jvm.SystemCallIndex;

/**
 * Provides access to the current API level.
 *
 * This is used for backwards compatibility.
 *
 * Levels are in the form of {@code 0M_mm_R_yyDDD} (Major version, minor
 * version, release version, year (20yy), day of year). This means they are
 * limited to the form of {@code [0-9].[0-99].[0-9] (Day [0-999] of 20[0-99])}.
 *



 * @since 2018/12/05
 */
@Deprecated
public final class ApiLevel
{
	/** The current API level. */
	@Deprecated
	public static final int CURRENT_LEVEL =
		Assembly.sysCallV(SystemCallIndex.API_LEVEL);
	
	/** Undefined. */
	@Deprecated
	public static final int UNDEFINED =







>











>
>
>





|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.lang;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallIndex;

/**
 * Provides access to the current API level.
 *
 * This is used for backwards compatibility.
 *
 * Levels are in the form of {@code 0M_mm_R_yyDDD} (Major version, minor
 * version, release version, year (20yy), day of year). This means they are
 * limited to the form of {@code [0-9].[0-99].[0-9] (Day [0-999] of 20[0-99])}.
 *
 * The hard-coded current API level for the ROM is located at
 * {@link Constants#API_LEVEL_CURRENT}.
 *
 * @since 2018/12/05
 */
@Deprecated
public final class ApiLevel
{
	/** The current API level as defined by the VM. */
	@Deprecated
	public static final int CURRENT_LEVEL =
		Assembly.sysCallV(SystemCallIndex.API_LEVEL);
	
	/** Undefined. */
	@Deprecated
	public static final int UNDEFINED =