Check-in [b48990fcdb]

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

Overview
Comment:Remove all the extra arguments to the bootstrap and just have a RAM, ROM, and Config memory areas.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b48990fcdbbf5e721ce4e1d5aa0c1a6d0a385e19
User & Date: stephanie.gawroriski 2019-06-14 14:25:01
Context
2019-06-14
14:36
Add WritableMemoryOutputStream. check-in: eda2bb56cb user: stephanie.gawroriski tags: trunk
14:25
Remove all the extra arguments to the bootstrap and just have a RAM, ROM, and Config memory areas. check-in: b48990fcdb user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: d6dd3b8ed8 user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ratufacoat/sjmerc.c.

1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838

1839
1840
1841
1842
1843
1844
1845
	cpu->r[SJME_POOL_REGISTER] = SJME_POINTER_TO_JINT(
		SJME_POINTER_OFFSET(ram, sjme_memjreadp(jvm, 4, &rp)));
	cpu->r[SJME_STATIC_FIELD_REGISTER] = SJME_POINTER_TO_JINT(
		SJME_POINTER_OFFSET(ram, sjme_memjreadp(jvm, 4, &rp)));
	cpu->pc = SJME_POINTER_OFFSET(bootjar, sjme_memjreadp(jvm, 4, &rp));
	
	/* Bootstrap entry arguments. */
	/* (int __rambase, int __ramsize, int __bootsize, byte[][] __classpath, */
	/* byte[][] __sysprops, byte[] __mainclass, byte[][] __mainargs, */
	/* boolean __ismidlet, int __gd, int __rombase) */
	cpu->r[SJME_ARGBASE_REGISTER + 0] = SJME_POINTER_TO_JINT(ram);
	cpu->r[SJME_ARGBASE_REGISTER + 1] = ramsize;
	cpu->r[SJME_ARGBASE_REGISTER + 2] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 3] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 4] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 5] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 6] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 7] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 8] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 9] = SJME_POINTER_TO_JINT(rom);

	
	/* Address where the BootRAM is read from. */
	rp = SJME_POINTER_OFFSET(bootjar, bootoff);
	
	/* Copy initial base memory bytes, which is pure big endian. */
	byteram = (sjme_jbyte*)ram;
	n = sjme_memjreadp(jvm, 4, &rp);







|
|
<


|
|


<
<
<
<
>







1819
1820
1821
1822
1823
1824
1825
1826
1827

1828
1829
1830
1831
1832
1833




1834
1835
1836
1837
1838
1839
1840
1841
	cpu->r[SJME_POOL_REGISTER] = SJME_POINTER_TO_JINT(
		SJME_POINTER_OFFSET(ram, sjme_memjreadp(jvm, 4, &rp)));
	cpu->r[SJME_STATIC_FIELD_REGISTER] = SJME_POINTER_TO_JINT(
		SJME_POINTER_OFFSET(ram, sjme_memjreadp(jvm, 4, &rp)));
	cpu->pc = SJME_POINTER_OFFSET(bootjar, sjme_memjreadp(jvm, 4, &rp));
	
	/* Bootstrap entry arguments. */
	/* (int __rambase, int __ramsize, int __rombase, int __romsize, */
	/* int __confbase, int __confsize) */

	cpu->r[SJME_ARGBASE_REGISTER + 0] = SJME_POINTER_TO_JINT(ram);
	cpu->r[SJME_ARGBASE_REGISTER + 1] = ramsize;
	cpu->r[SJME_ARGBASE_REGISTER + 2] = SJME_POINTER_TO_JINT(rom);
	cpu->r[SJME_ARGBASE_REGISTER + 3] = jvm->romsize;
	cpu->r[SJME_ARGBASE_REGISTER + 4] = 0;
	cpu->r[SJME_ARGBASE_REGISTER + 5] = 0;




	
	
	/* Address where the BootRAM is read from. */
	rp = SJME_POINTER_OFFSET(bootjar, bootoff);
	
	/* Copy initial base memory bytes, which is pure big endian. */
	byteram = (sjme_jbyte*)ram;
	n = sjme_memjreadp(jvm, 4, &rp);

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

53
54
55
56
57
58
59



60
61
62
63
64
65
66
...
101
102
103
104
105
106
107



108
109
110
111
112
113
114
...
124
125
126
127
128
129
130



131
132
133
134
135
136
137
	 * @since 2019/05/26
	 */
	public static final int allocate(int __sz)
	{
		// The number of desired bytes
		int want = CHUNK_LENGTH + (__sz <= 4 ? 4 : ((__sz + 3) & (~3)));
		



		// Go through the memory chunks to locate a free chunk
		int seeker = Allocator._rambase;
		while (seeker != 0)
		{
			// Read chunk properties
			int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
................................................................................
				}
				
				// Clear out memory since Java expects the data to be
				// initialized to zero always
				for (int i = CHUNK_LENGTH; i < want; i += 4)
					Assembly.memWriteInt(seeker, i, 0);
				



				// Use this chunk
				return rv;
			}
			
			// Go to the next chunk
			seeker = cnx;
		}
................................................................................
	 * @since 2019/05/27
	 */
	static final void free(int __p)
	{
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		



		// Determine the seeker position for this chunk
		int seeker = __p - CHUNK_LENGTH;
		
		// Read chunk properties
		int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
			cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
		







>
>
>







 







>
>
>







 







>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	 * @since 2019/05/26
	 */
	public static final int allocate(int __sz)
	{
		// The number of desired bytes
		int want = CHUNK_LENGTH + (__sz <= 4 ? 4 : ((__sz + 3) & (~3)));
		
		// Debug
		todo.DEBUG.code('A', 'l', __sz);
		
		// Go through the memory chunks to locate a free chunk
		int seeker = Allocator._rambase;
		while (seeker != 0)
		{
			// Read chunk properties
			int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
				cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
................................................................................
				}
				
				// Clear out memory since Java expects the data to be
				// initialized to zero always
				for (int i = CHUNK_LENGTH; i < want; i += 4)
					Assembly.memWriteInt(seeker, i, 0);
				
				// Debug
				todo.DEBUG.code('A', 'p', rv);
				
				// Use this chunk
				return rv;
			}
			
			// Go to the next chunk
			seeker = cnx;
		}
................................................................................
	 * @since 2019/05/27
	 */
	static final void free(int __p)
	{
		if (__p == 0 || __p == Constants.BAD_MAGIC)
			throw new VirtualMachineError();
		
		// Debug
		todo.DEBUG.code('A', 'f', __p);
		
		// Determine the seeker position for this chunk
		int seeker = __p - CHUNK_LENGTH;
		
		// Read chunk properties
		int csz = Assembly.memReadInt(seeker, CHUNK_SIZE_OFFSET),
			cnx = Assembly.memReadInt(seeker, CHUNK_NEXT_OFFSET);
		

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

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
	}
	
	/**
	 * Entry point for the bootstrap.
	 *
	 * @param __rambase The base RAM address.
	 * @param __ramsize The size of RAM.
	 * @param __bootsize Boot memory size.
	 * @param __classpath The class path.
	 * @param __sysprops System properties.
	 * @param __mainclass Main class.
	 * @param __mainargs Main arguments.
	 * @param __ismidlet Is this a MIDlet?
	 * @param __gd The current guest depth.
	 * @param __rombase Base address of the ROM (for offset calculation).
	 * @since 2019/05/25
	 */
	static final void __start(int __rambase, int __ramsize, int __bootsize,
		byte[][] __classpath, byte[][] __sysprops, byte[] __mainclass,
		byte[][] __mainargs, boolean __ismidlet, int __gd, int __rombase)

	{
		// Initialize the RAM links to setup dirty bits and initialize the
		// last block of memory with anything that remains. This makes it so
		// the RAM is actually useable.
		Allocator.__initRamLinks(__rambase, __ramsize);
		
		// Test







|
|
|
|
<
<
<
<


|
<
<
>







26
27
28
29
30
31
32
33
34
35
36




37
38
39


40
41
42
43
44
45
46
47
	}
	
	/**
	 * Entry point for the bootstrap.
	 *
	 * @param __rambase The base RAM address.
	 * @param __ramsize The size of RAM.
	 * @param __rombase Base address of the ROM (for offset calculation).
	 * @param __romsize The size of ROM.
	 * @param __confbase The configuration memory base.
	 * @param __confsize The configuration memory size.




	 * @since 2019/05/25
	 */
	static final void __start(int __rambase, int __ramsize,


		int __rombase, int __romsize, int __confbase, int __confsize)
	{
		// Initialize the RAM links to setup dirty bits and initialize the
		// last block of memory with anything that remains. This makes it so
		// the RAM is actually useable.
		Allocator.__initRamLinks(__rambase, __ramsize);
		
		// Test

Changes to runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SummerCoatFactory.java.

50
51
52
53
54
55
56




57
58
59
60
61
62
63
..
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
...
123
124
125
126
127
128
129



130
131
132
133
134
135
136
...
141
142
143
144
145
146
147



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
	/** The base address for suites. */
	public static final int SUITE_BASE_ADDR =
		0x40000000;
	
	/** Base address for configuration data. */
	public static final int CONFIG_BASE_ADDR =
		0x30000000;




	
	/** The starting address for RAM. */
	public static final int RAM_START_ADDRESS =
		1048576;
	
	/**
	 * Initializes the factory.
................................................................................
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Virtual memory which provides access to many parts of memory
		VirtualMemory vmem = new VirtualMemory();
		
		// The ROM always starts here
		int rombase = SUITE_BASE_ADDR;

		
		// Try to load a specific ROM file instead of the dynamically
		// generate one?
		String romfile = __sprops.get("cc.squirreljme.romfile");
		if (romfile == null)
			try
			{
................................................................................
					baos.write(buf, 0, rc);
				}
				
				// Initialize memory with the ROM data
				ReadableMemory sm = new ByteArrayMemory(rombase,
					baos.toByteArray());
				vmem.mapRegion(sm);



			}
			
			// {@squirreljme.error AE05 Could not load SummerCoat ROM. (File)}
			catch (IOException e)
			{
				throw new RuntimeException("AE05 " + romfile, e);
			}
................................................................................
		{
			// Create and map dynamic suite region
			SuitesMemory sm = new SuitesMemory(rombase, __sm);
			vmem.mapRegion(sm);
			
			// Initialize suite memory explicitly since we need it!
			sm.__init();



		}
		
		// Initialize RAM
		int ramsize = DefaultConfiguration.DEFAULT_RAM_SIZE,
			ramstart = RAM_START_ADDRESS;
		vmem.mapRegion(new RawMemory(ramstart, ramsize));
		
		// Initialize configuration memory
		WritableMemory cmem = new RawMemory(CONFIG_BASE_ADDR, 8192);
		vmem.mapRegion(cmem);
		
		// Read the boot JAR offset of this packfile
		int bootjaroff = rombase + vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJAROFFSET),
			bootjarsize = vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJARSIZE);
................................................................................
		{
			throw new VMException("AE01", e);
		}
		
		// Setup virtual execution CPU
		NativeCPU cpu = new NativeCPU(vmem);
		NativeCPU.Frame iframe = cpu.enterFrame(bootjaroff + bjh.bootstart,
			ramstart, ramsize, lram, xxclasspth, xxsysprops, xxmainclss,
			xxmainargs, (__ismid ? 1 : 0), __gd, rombase);
		
		// Seed initial frame registers
		iframe._registers[NativeCode.POOL_REGISTER] =
			ramstart + bjh.bootpool;
		iframe._registers[NativeCode.STATIC_FIELD_REGISTER] =
			ramstart + bjh.bootsfieldbase;
		







>
>
>
>







 







|
>







 







>
>
>







 







>
>
>








|







 







|
<







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
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
...
295
296
297
298
299
300
301
302

303
304
305
306
307
308
309
	/** The base address for suites. */
	public static final int SUITE_BASE_ADDR =
		0x40000000;
	
	/** Base address for configuration data. */
	public static final int CONFIG_BASE_ADDR =
		0x30000000;
	
	/** Size of the configuration area. */
	public static final int CONFIG_SIZE =
		65536;
	
	/** The starting address for RAM. */
	public static final int RAM_START_ADDRESS =
		1048576;
	
	/**
	 * Initializes the factory.
................................................................................
		String[] __args)
		throws IllegalArgumentException, NullPointerException, VMException
	{
		// Virtual memory which provides access to many parts of memory
		VirtualMemory vmem = new VirtualMemory();
		
		// The ROM always starts here
		int rombase = SUITE_BASE_ADDR,
			romsize = 0;
		
		// Try to load a specific ROM file instead of the dynamically
		// generate one?
		String romfile = __sprops.get("cc.squirreljme.romfile");
		if (romfile == null)
			try
			{
................................................................................
					baos.write(buf, 0, rc);
				}
				
				// Initialize memory with the ROM data
				ReadableMemory sm = new ByteArrayMemory(rombase,
					baos.toByteArray());
				vmem.mapRegion(sm);
				
				// Record size of RAM
				romsize = baos.size();
			}
			
			// {@squirreljme.error AE05 Could not load SummerCoat ROM. (File)}
			catch (IOException e)
			{
				throw new RuntimeException("AE05 " + romfile, e);
			}
................................................................................
		{
			// Create and map dynamic suite region
			SuitesMemory sm = new SuitesMemory(rombase, __sm);
			vmem.mapRegion(sm);
			
			// Initialize suite memory explicitly since we need it!
			sm.__init();
			
			// Rom size is derived from the chunk size
			romsize = sm.size;
		}
		
		// Initialize RAM
		int ramsize = DefaultConfiguration.DEFAULT_RAM_SIZE,
			ramstart = RAM_START_ADDRESS;
		vmem.mapRegion(new RawMemory(ramstart, ramsize));
		
		// Initialize configuration memory
		WritableMemory cmem = new RawMemory(CONFIG_BASE_ADDR, CONFIG_SIZE);
		vmem.mapRegion(cmem);
		
		// Read the boot JAR offset of this packfile
		int bootjaroff = rombase + vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJAROFFSET),
			bootjarsize = vmem.memReadInt(rombase +
				MinimizedPackHeader.OFFSET_OF_BOOTJARSIZE);
................................................................................
		{
			throw new VMException("AE01", e);
		}
		
		// Setup virtual execution CPU
		NativeCPU cpu = new NativeCPU(vmem);
		NativeCPU.Frame iframe = cpu.enterFrame(bootjaroff + bjh.bootstart,
			ramstart, ramsize, rombase, CONFIG_BASE_ADDR, CONFIG_SIZE);

		
		// Seed initial frame registers
		iframe._registers[NativeCode.POOL_REGISTER] =
			ramstart + bjh.bootpool;
		iframe._registers[NativeCode.STATIC_FIELD_REGISTER] =
			ramstart + bjh.bootsfieldbase;