Check-in [037a21425e]

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

Overview
Comment:Add SystemCallException and nicer SystemCallError; Initialize UI via format.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 037a21425ef796cd3cf404de9d7faf4f27d9d057
User & Date: stephanie.gawroriski 2020-01-12 14:48:32
Context
2020-01-13
08:02
Backup developer notes. check-in: c4b2c5b2d3 user: squirreljme tags: trunk
2020-01-12
14:48
Add SystemCallException and nicer SystemCallError; Initialize UI via format. check-in: 037a21425e user: stephanie.gawroriski tags: trunk
2020-01-09
19:17
Remove CLIP_RECT, TRANSLATE, GET_TRANSLATE_X, and GET_TRANSLATE_Y from serialized graphics to simplify them; Add capabilities support for the framebuffer; Reduce argument count in drawRegion() so it fits within the system call limits; Add system calls for accelerated graphics support; Shorten FRAMEBUFFER_ to FB_ in RatufaCoat; Shorten FramebufferProperty to Framebuffer since it contains all of the Framebuffer stuff. check-in: 9fbed3bd18 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallError.java.

64
65
66
67
68
69
70















71
72
73
74
75
76
77
78
79
80
81
82
83


84



























	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}















	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
}





































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












|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}
	
	/**
	 * Checks if an error was set, if it was an exception is thrown.
	 *
	 * @param __si The system call to check.
	 * @throws SystemCallException If there was an error.
	 * @since 2020/01/12
	 */
	public static final void checkError(short __si)
		throws SystemCallException
	{
		int code = SystemCallError.getError(__si);
		if (code != NO_ERROR)
			throw new SystemCallException(__si, code);
	}
	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
	
	/**
	 * Converts the error to a string.
	 *
	 * @param __err The input error.
	 * @return The resulting string.
	 * @since 2020/01/12
	 */
	public static final String toString(int __err)
	{
		switch (__err)
		{
			case NO_ERROR:					return "NoError";
			case UNSUPPORTED_SYSTEM_CALL:	return "UnsupportedSystemCall";
			case PIPE_DESCRIPTOR_INVALID:	return "PDInvalid";
			case PIPE_DESCRIPTOR_BAD_WRITE:	return "PDBadWrite";
			case VALUE_OUT_OF_RANGE:		return "ValueOutOfRange";
			case NO_FRAMEBUFFER:			return "NoFramebuffer";
			case PERMISSION_DENIED:			return "PermissionDenied";
			case INTERRUPTED:				return "Interrupted";
			case UNKNOWN:					return "Unknown";
			case END_OF_FILE:				return "EndOfFile";
			case IPC_ERROR:					return "IPCError";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

Added runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallException.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
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
// -*- 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;

/**
 * Exception that may be thrown by {@link SystemCallError.checkError(int)}.
 *
 * @since 2020/01/12
 */
public class SystemCallException
	extends RuntimeException
{
	/** The system call ID. */
	public final int callid;
	
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec)
	{
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m)
	{
		super(__m);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m, Throwable __t)
	{
		super(__m, __t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, Throwable __t)
	{
		super(__t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/12
	 */
	@Override
	public String getMessage()
	{
		return "[SID=" + this.callid + ", ERR=" +
			SystemCallError.toString(this.code) + "]: " + super.getMessage();
	}
}

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/gfx/PixelFormat.java.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
...
259
260
261
262
263
264
265
266
267
268
269
270
271


272




































// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;


import javax.microedition.lcdui.Graphics;

/**
 * This represents the pixel format that is used.
 *
 * @since 2018/03/24
 */
................................................................................
			case 4:		return BYTE_RGB332;
			case 5:		return SHORT_INDEXED16;
			case 6:		return SHORT_ARGB4444;
			case 7:		return SHORT_RGB565;
			case 8:		return INTEGER_ARGB8888;
			case 9:		return INTEGER_RGB888;
			
				// {@squirreljme.error EB0k Unknown pixel buffer format.}
			default:
				throw new IllegalArgumentException("EB0k " + __id);
		}
	}
}














































>







 







|




|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.gfx;

import cc.squirreljme.jvm.Framebuffer;
import javax.microedition.lcdui.Graphics;

/**
 * This represents the pixel format that is used.
 *
 * @since 2018/03/24
 */
................................................................................
			case 4:		return BYTE_RGB332;
			case 5:		return SHORT_INDEXED16;
			case 6:		return SHORT_ARGB4444;
			case 7:		return SHORT_RGB565;
			case 8:		return INTEGER_ARGB8888;
			case 9:		return INTEGER_RGB888;
			
				// {@squirreljme.error EB0k Unknown pixel buffer format. (ID)}
			default:
				throw new IllegalArgumentException("EB0k " + __id);
		}
	}
	
	/**
	 * Returns the pixel format used for the native framebuffer.
	 *
	 * @param __id The format ID.
	 * @return The associated pixel format.
	 * @throws IllegalArgumentException If the ID is not valid.
	 * @since 2020/01/12
	 */
	public static final PixelFormat ofFramebuffer(int __id)
		throws IllegalArgumentException
	{
		switch (__id)
		{
			case Framebuffer.FORMAT_INTEGER_RGB888:
				return INTEGER_RGB888;
			
			case Framebuffer.FORMAT_BYTE_INDEXED:
				return BYTE_INDEXED8;
			
			case Framebuffer.FORMAT_SHORT_RGB565:
				return SHORT_RGB565;
			
			case Framebuffer.FORMAT_PACKED_ONE:
				return BYTE_INDEXED1;
				
			case Framebuffer.FORMAT_PACKED_TWO:
				return BYTE_INDEXED2;
				
			case Framebuffer.FORMAT_PACKED_FOUR:
				return BYTE_INDEXED4;
			
				// {@squirreljme.error EB3a Unknown frame buffer pixel buffer
				// format. (ID}}
			default:
				throw new IllegalArgumentException("EB3a " + __id);
		}
	}
}

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/NativeUIBackend.java.

5
6
7
8
9
10
11




12
13
14
15
16
17
18
..
60
61
62
63
64
65
66
67
68


69
70
71
72
73
74
75
76
77
78
79
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;





import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.AcceleratedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import javax.microedition.lcdui.Canvas;
................................................................................
	 * @param __nid The native display ID this uses.
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Get data buffers and properties
		int[] params = NativeDisplayAccess.framebufferParameters(__nid);


		
		// Set parameters
		this.pixelformat = PixelFormat.of(
			params[NativeDisplayAccess.PARAMETER_PIXELFORMAT]);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override







>
>
>
>







 







|
|
>
>

|
|
<







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Framebuffer;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.AcceleratedGraphics;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import cc.squirreljme.runtime.lcdui.gfx.PixelFormat;
import javax.microedition.lcdui.Canvas;
................................................................................
	 * @param __nid The native display ID this uses.
	 * @since 2019/05/16
	 */
	public NativeUIBackend(int __nid)
	{
		this.nid = __nid;
		
		// Throw an exception if this has failed
		int pft = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
			Framebuffer.CONTROL_FORMAT);
		SystemCallError.checkError(SystemCallIndex.FRAMEBUFFER);
		
		// Set pixel format
		this.pixelformat = PixelFormat.ofFramebuffer(pft);

	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/16
	 */
	@Override

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/vfb/VirtualFramebuffer.java.

174
175
176
177
178
179
180

181
182
183
184

185
186
187
188
189
190
191
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __pid The property ID.
	 * @param __args The call arguments.
	 * @return The result of the property.

	 * @since 2019/12/28
	 */
	public final long framebufferControl(int __pid, int __a, int __b, int __c,
		int __d, int __e, int __g, int __h)

	{
		// Depends on the property
		switch (__pid)
		{
				// Raw address (since it is simulated, this is not set)
			case Framebuffer.CONTROL_ADDRESS:
				return 0;
................................................................................
			case Framebuffer.CONTROL_ACCEL_FUNC_QUERY:
				throw new todo.TODO();
			
				// Perform acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_INVOKE:
				throw new todo.TODO();
				
				// Unknown
			default:
				return 0;
		}
	}
}








>




>







 







|

|




174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
	
	/**
	 * Executes the framebuffer control system call.
	 *
	 * @param __pid The property ID.
	 * @param __args The call arguments.
	 * @return The result of the property.
	 * @throws IllegalArgumentException If the property was not known.
	 * @since 2019/12/28
	 */
	public final long framebufferControl(int __pid, int __a, int __b, int __c,
		int __d, int __e, int __g, int __h)
		throws IllegalArgumentException
	{
		// Depends on the property
		switch (__pid)
		{
				// Raw address (since it is simulated, this is not set)
			case Framebuffer.CONTROL_ADDRESS:
				return 0;
................................................................................
			case Framebuffer.CONTROL_ACCEL_FUNC_QUERY:
				throw new todo.TODO();
			
				// Perform acceleration function.
			case Framebuffer.CONTROL_ACCEL_FUNC_INVOKE:
				throw new todo.TODO();
				
				// {@squirreljme.error EB3b Unknown control property.}
			default:
				throw new IllegalArgumentException("EB3b");
		}
	}
}

Changes to runt/klib/supervisor/cc/squirreljme/jvm/SystemCallError.java.

64
65
66
67
68
69
70















71
72
73
74
75
76
77
78
79
80
81
82
83


84



























	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}















	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
}





































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












|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
	 * Not used.
	 *
	 * @since 2019/05/23
	 */
	private SystemCallError()
	{
	}
	
	/**
	 * Checks if an error was set, if it was an exception is thrown.
	 *
	 * @param __si The system call to check.
	 * @throws SystemCallException If there was an error.
	 * @since 2020/01/12
	 */
	public static final void checkError(short __si)
		throws SystemCallException
	{
		int code = SystemCallError.getError(__si);
		if (code != NO_ERROR)
			throw new SystemCallException(__si, code);
	}
	
	/**
	 * Returns the error state.
	 *
	 * @param __si The system call index.
	 * @return The error, 0 will be on success.
	 * @since 2019/05/23
	 */
	public static final int getError(short __si)
	{
		return Assembly.sysCallV(SystemCallIndex.ERROR_GET, __si);
	}
	
	/**
	 * Converts the error to a string.
	 *
	 * @param __err The input error.
	 * @return The resulting string.
	 * @since 2020/01/12
	 */
	public static final String toString(int __err)
	{
		switch (__err)
		{
			case NO_ERROR:					return "NoError";
			case UNSUPPORTED_SYSTEM_CALL:	return "UnsupportedSystemCall";
			case PIPE_DESCRIPTOR_INVALID:	return "PDInvalid";
			case PIPE_DESCRIPTOR_BAD_WRITE:	return "PDBadWrite";
			case VALUE_OUT_OF_RANGE:		return "ValueOutOfRange";
			case NO_FRAMEBUFFER:			return "NoFramebuffer";
			case PERMISSION_DENIED:			return "PermissionDenied";
			case INTERRUPTED:				return "Interrupted";
			case UNKNOWN:					return "Unknown";
			case END_OF_FILE:				return "EndOfFile";
			case IPC_ERROR:					return "IPCError";
			
				// Some Other ID?
			default:
				return "ERROR" + __err;
		}
	}
}

Added runt/klib/supervisor/cc/squirreljme/jvm/SystemCallException.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
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
// -*- 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;

/**
 * Exception that may be thrown by {@link SystemCallError.checkError(int)}.
 *
 * @since 2020/01/12
 */
public class SystemCallException
	extends RuntimeException
{
	/** The system call ID. */
	public final int callid;
	
	/** The error code. */
	public final int code;
	
	/**
	 * Initializes the exception with no message or cause.
	 *
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec)
	{
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and no cause.
	 *
	 * @param __m The message.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m)
	{
		super(__m);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given message and cause.
	 *
	 * @param __m The message.
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, String __m, Throwable __t)
	{
		super(__m, __t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * Initializes the exception with the given cause and no message.
	 *
	 * @param __t The cause.
	 * @since 2019/10/21
	 */
	public SystemCallException(int __sid, int __ec, Throwable __t)
	{
		super(__t);
		
		this.callid = __sid;
		this.code = __ec;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/01/12
	 */
	@Override
	public String getMessage()
	{
		return "[SID=" + this.callid + ", ERR=" + this.code + "]: " +
			super.getMessage();
	}
}