Check-in [5770b6db48]

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

Overview
Comment:Add base code to push classpaths from the ROM to processes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-springcoat-bringup
Files: files | file ages | folders
SHA1: 5770b6db485cd38e2c2f3988b6a500be14a3c87c
User & Date: stephanie.gawroriski 2020-05-12 19:52:09
Context
2020-05-13
00:01
Have ConfigEntry and ConfigReader just be iteration over that, ConfigEntry has all the parsing stuff. check-in: 5133c45caf user: stephanie.gawroriski tags: wip-springcoat-bringup
2020-05-12
19:52
Add base code to push classpaths from the ROM to processes. check-in: 5770b6db48 user: stephanie.gawroriski tags: wip-springcoat-bringup
15:54
Commit the context storage in SpringCoat. check-in: b9a5337de4 user: stephanie.gawroriski tags: wip-springcoat-bringup
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

47
48
49
50
51
52
53
54

55
	 * @since 2020/05/10
	 */
	byte CONTROL_SEARCH_BY_JAR_BYTES =
		2;
	
	/** The number of controls. */
	byte NUM_CONTROLS =
		3;

}







<
>

47
48
49
50
51
52
53

54
55
	 * @since 2020/05/10
	 */
	byte CONTROL_SEARCH_BY_JAR_BYTES =
		2;
	
	/** The number of controls. */
	byte NUM_CONTROLS =

		4;
}

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

6
7
8
9
10
11
12

13
14
15
16
17
18
19
...
136
137
138
139
140
141
142
143



































































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

package cc.squirreljme.jvm;

import cc.squirreljme.runtime.cldc.debug.Debugging;


/**
 * This class contains helpers for all of the system calls to more reliably
 * have a type-safe and easier to use interface to them.
 *
 * @see SystemCallIndex
 * @since 2020/03/27
................................................................................
			// Use this created info
			return Assembly.pointerToClassInfo(rvP);
		}
		
		// Loading of classes is our responsibility
		throw Debugging.todo();
	}
}










































































>







 







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

package cc.squirreljme.jvm;

import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.io.UnsupportedEncodingException;

/**
 * This class contains helpers for all of the system calls to more reliably
 * have a type-safe and easier to use interface to them.
 *
 * @see SystemCallIndex
 * @since 2020/03/27
................................................................................
			// Use this created info
			return Assembly.pointerToClassInfo(rvP);
		}
		
		// Loading of classes is our responsibility
		throw Debugging.todo();
	}
	
	/**
	 * Searches the ROM for the given JAR.
	 *
	 * @param __name The name of the ROM to search for.
	 * @return The ROM reference or {@code null} if no ROM was found.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/12
	 */
	public static RomReference searchJar(String __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// The system call expects only UTF-8, so we need to decode it as that
		try
		{
			return SystemCall.searchJar(__name.getBytes("utf-8"));
		}
		catch (UnsupportedEncodingException e)
		{
			// {@squirreljme.error ZZ4A Could not decode JAR name.}
			throw new RuntimeException("ZZ4A", e);
		}
	}
	
	/**
	 * Searches the ROM for the given JAR.
	 *
	 * @param __name The name of the ROM to search for.
	 * @return The ROM reference or {@code null} if no ROM was found.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/12
	 */
	public static RomReference searchJar(byte... __name)
		throws NullPointerException
	{
		if (__name == null)
			throw new NullPointerException("NARG");
		
		// If this system call is not supported, then just stop here
		if (SystemCall.isSupported(SystemCallIndex.ROM_ACCESS))
			return null;
		
		// Lookup search
		long nameP = Assembly.objectToPointer(__name);
		long id = Assembly.sysCallVL(SystemCallIndex.ROM_ACCESS,
			RomAccessControl.CONTROL_SEARCH_BY_JAR_BYTES,
			Assembly.longUnpackHigh(nameP), Assembly.longUnpackLow(nameP));
		
		// {@squirreljme.error ZZ4B Could not check for ROM access.
		if (SystemCall.hasError(SystemCallIndex.ROM_ACCESS))
		{
			if (!SystemCall.isError(SystemCallIndex.ROM_ACCESS,
				SystemCallError.UNSUPPORTED_SYSTEM_CALL))
				throw new RuntimeException("ZZ4B " +
					SystemCall.getError(SystemCallIndex.ROM_ACCESS));
			else
				return null;
		}
		
		// Make this type safe rather than having to use integers
		if (id == 0)
			return null;
		return new RomReference(id);
	}
}

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

523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
	 * {@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 =







|







523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
	 * {@link ConfigRomType}.
	 * @since 2020/05/03
	 */
	byte CONFIG_GET_TYPE =
		41;
	
	/**
	 * Access to the ROM using various controls, via {@link RomAccessControl}.
	 *
	 * @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 =

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

38
39
40
41
42
43
44

















45
46
47
48
49
50
51
..
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
	{
		if (__main == null)
			throw new NullPointerException("NARG");
		
		this.main = __main;
		this.taskId = __main.taskId;
	}

















	
	/**
	 * Starts this process.
	 *
	 * @since 2020/04/28
	 */
	public final void start()
................................................................................
		Assembly.breakpoint();
		throw Debugging.todo();
	}
	
	/**
	 * Spawns a process.
	 *

	 * @return The resulting process that was spawned.

	 * @since 2020/04/28
	 */
	public static VirtualProcess spawn()

	{



		// Create hardware thread for the main thread, the hardware thread ID
		// will become the task ID
		HardwareThread main = HardwareThread.createThread(
			true, 0);
		VirtualProcess rv = new VirtualProcess(main);




		
		if (true)
		{
			Assembly.breakpoint();
			throw Debugging.todo();
		}
		
		return rv;
	}
}







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







 







>

>


|
>

>
>
>





>
>
>
>










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
..
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
	{
		if (__main == null)
			throw new NullPointerException("NARG");
		
		this.main = __main;
		this.taskId = __main.taskId;
	}
	
	/**
	 * Pushes the specified ROM to the class path so that the process is able
	 * to use all of the classes and resources within it.
	 *
	 * @param __rom The ROM to push to the classpath.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/05/12
	 */
	public void pushClasspath(RomReference __rom)
		throws NullPointerException
	{
		if (__rom == null)
			throw new NullPointerException("NARG");
		
		throw Debugging.todo();
	}
	
	/**
	 * Starts this process.
	 *
	 * @since 2020/04/28
	 */
	public final void start()
................................................................................
		Assembly.breakpoint();
		throw Debugging.todo();
	}
	
	/**
	 * Spawns a process.
	 *
	 * @param __cp The classpath to use for the process.
	 * @return The resulting process that was spawned.
	 * @throws NullPointerException On null arguments.
	 * @since 2020/04/28
	 */
	public static VirtualProcess spawn(String[] __cp)
		throws NullPointerException
	{
		if (__cp == null)
			throw new NullPointerException("NARG");
		
		// Create hardware thread for the main thread, the hardware thread ID
		// will become the task ID
		HardwareThread main = HardwareThread.createThread(
			true, 0);
		VirtualProcess rv = new VirtualProcess(main);
		
		// Push all of the ROM classpath into this process
		for (int i = 0, n = __cp.length; i < n; i++)
			rv.pushClasspath(SystemCall.searchJar(__cp[i]));
		
		if (true)
		{
			Assembly.breakpoint();
			throw Debugging.todo();
		}
		
		return rv;
	}
}

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

6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
..
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
..
79
80
81
82
83
84
85

86
87
88

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

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.JVMFunction;
import cc.squirreljme.jvm.memory.ReadableBasicMemory;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.util.Iterator;


/**
 * This is a helper class used to read the configuration.
 *
 * @see ConfigWriter
 * @since 2019/06/22
 */
................................................................................
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
	}




















	
	/**
	 * {@inheritDoc}
	 * @since 2020/04/03
	 */
	@Override
	public Iterator<ConfigEntry> iterator()
	{
		throw Debugging.todo();
	}
	
	/**
	 * Returns the raw value of the configuration key.
	 *
	 * @param __key The key to use.
	 * @return The raw value.

	 * @since 2020/05/03
	 */
	public long rawValue(int __key)

	{
		Assembly.breakpoint();
		throw Debugging.todo();
	}
	
	/**
	 * Returns the number of configuration items.
................................................................................
	}
	
	/**
	 * Returns the type that the key is.
	 *
	 * @param __key The key to use.
	 * @return The {@link ConfigRomType}.

	 * @since 2020/05/03
	 */
	public int type(int __key)

	{
		Assembly.breakpoint();
		throw Debugging.todo();
	}
}








|
|



>







 







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






|









>


|
>







 







>


|
>






6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
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
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.ConfigRomType;
import cc.squirreljme.jvm.memory.ReadableBasicMemory;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * This is a helper class used to read the configuration.
 *
 * @see ConfigWriter
 * @since 2019/06/22
 */
................................................................................
		throws NullPointerException
	{
		if (__mem == null)
			throw new NullPointerException("NARG");
		
		this.memory = __mem;
	}
	
	/**
	 * Gets the string array from a key.
	 *
	 * @param __key The {@link ConfigRomKey} to obtain.
	 * @return The string array.
	 * @throws IllegalArgumentException If the key does not refer to a value
	 * that is compatible with a string array.
	 * @throws NoSuchElementException If no such key exists.
	 * @since 2020/05/12
	 */
	public final String[] getStrings(int __key)
		throws IllegalArgumentException, NoSuchElementException
	{
		// {@squirreljme.error ZZ4B Key is not UTF list type. (The key)}
		if (this.type(__key) != ConfigRomType.UTF_LIST)
			throw new IllegalArgumentException("ZZ4B " + __key);
		
		throw Debugging.todo();
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2020/04/03
	 */
	@Override
	public final Iterator<ConfigEntry> iterator()
	{
		throw Debugging.todo();
	}
	
	/**
	 * Returns the raw value of the configuration key.
	 *
	 * @param __key The key to use.
	 * @return The raw value.
	 * @throws NoSuchElementException If no such key exists.
	 * @since 2020/05/03
	 */
	public final long rawValue(int __key)
		throws NoSuchElementException
	{
		Assembly.breakpoint();
		throw Debugging.todo();
	}
	
	/**
	 * Returns the number of configuration items.
................................................................................
	}
	
	/**
	 * Returns the type that the key is.
	 *
	 * @param __key The key to use.
	 * @return The {@link ConfigRomType}.
	 * @throws NoSuchElementException If no such key exists.
	 * @since 2020/05/03
	 */
	public final int type(int __key)
		throws NoSuchElementException
	{
		Assembly.breakpoint();
		throw Debugging.todo();
	}
}

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

6
7
8
9
10
11
12

13
14
15
16
17
18
19
...
133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;

import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCall;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.VirtualProcess;
import cc.squirreljme.jvm.memory.ReadableAssemblyMemory;

/**
................................................................................
	@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();

		
		// Start the process
		primary.start();
		
		// Wait for the process to finish execution
		int exitCode;
		for (;;)







>







 







|
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.jvm.boot;

import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.ConfigRomKey;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCall;
import cc.squirreljme.jvm.SystemCallIndex;
import cc.squirreljme.jvm.VirtualProcess;
import cc.squirreljme.jvm.memory.ReadableAssemblyMemory;

/**
................................................................................
	@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(__config.getStrings(
			ConfigRomKey.CLASS_PATH));
		
		// Start the process
		primary.start();
		
		// Wait for the process to finish execution
		int exitCode;
		for (;;)

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/Debugging.java.

68
69
70
71
72
73
74












75
76
77
78
79
80
81
	 * @since 2020/03/22
	 */
	@SuppressWarnings("deprecation")
	public static Error oops(Object... __args)
	{
		return OOPS.OOPS(__args);
	}












	
	/**
	 * Emits a To-Do error.
	 *
	 * @param __args Arguments to the error.
	 * @return The generated error.
	 * @since 2020/03/21







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







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
	 * @since 2020/03/22
	 */
	@SuppressWarnings("deprecation")
	public static Error oops(Object... __args)
	{
		return OOPS.OOPS(__args);
	}
	
	/**
	 * Emits a To-Do error.
	 *
	 * @return The generated error.
	 * @since 2020/03/21
	 */
	@SuppressWarnings("deprecation")
	public static Error todo()
	{
		return TODO.TODO((Object[])null);
	}
	
	/**
	 * Emits a To-Do error.
	 *
	 * @param __args Arguments to the error.
	 * @return The generated error.
	 * @since 2020/03/21