sbl bringup: stublets, slots, maze, ffu-ref, b10 chain, docs
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import struct
|
||||
|
||||
M = '/root/qemu-src/qemu-8.2.2/hw/arm/saimaa.c'
|
||||
src = open(M).read()
|
||||
|
||||
start = src.find(' /* Boot scaffolding for SBL1 BringUp')
|
||||
assert start > 0, 'scaffold start not found'
|
||||
end_marker = 'printf("saimaa: SBL1 %s loaded'
|
||||
end = src.find(end_marker, start)
|
||||
assert end > 0, 'scaffold end not found'
|
||||
line_start = src.rfind('\n', 0, end) + 1
|
||||
|
||||
blob = open('/tmp/stubs3.bin', 'rb').read()
|
||||
print('stub blob len', len(blob))
|
||||
c_array = ', '.join('0x%02x' % b for b in blob)
|
||||
|
||||
S10_A = '0x08062001'
|
||||
S2 = '0x08062013'
|
||||
S10_B = '0x08062021'
|
||||
S6_A = '0x08062033'
|
||||
|
||||
new_block = ''' /* Boot scaffolding for SBL1 BringUp (WIP stub-driven PBL):
|
||||
* pop-compensation stublets at 0x08062000 pin sp and route onward,
|
||||
* so repeated pops always hit valid slots. */
|
||||
{
|
||||
static const unsigned char stub_blob[] = { %s };
|
||||
uint32_t magic = 0x00000000; /* IMEM poll spins WHILE equal */
|
||||
uint32_t S = 0x08062100, STUB = 0x08062120;
|
||||
uint32_t w;
|
||||
uint16_t h0 = 0x2000, h1 = 0x4770; /* movs r0,#0; bx lr */
|
||||
size_t k;
|
||||
uint32_t v;
|
||||
for (k = 0; k < sizeof(stub_blob); k += 4) {
|
||||
uint32_t word;
|
||||
__builtin_memcpy(&word, &stub_blob[k], 4);
|
||||
cpu_physical_memory_write(0x08062000 + k, &word, 4);
|
||||
}
|
||||
/* pointer maze in owned RAM for SBL1 struct chains */
|
||||
w = S + 8;
|
||||
cpu_physical_memory_write(S, &w, 4);
|
||||
cpu_physical_memory_write(S + 8, &STUB, 4);
|
||||
cpu_physical_memory_write(STUB, &h0, 2);
|
||||
cpu_physical_memory_write(STUB + 2, &h1, 2);
|
||||
cpu_physical_memory_write(0x087c29d18, &S, 4);
|
||||
cpu_physical_memory_write(0x08050b28, &S, 4);
|
||||
cpu_physical_memory_write(0x08070000, &S, 4);
|
||||
/* pop-site slots -> stublets (sp values from cpu traces) */
|
||||
v = %s; /* S1 pop10 */
|
||||
cpu_physical_memory_write(0x085FFF14, &v, 4);
|
||||
v = %s; /* S2 pop2 */
|
||||
cpu_physical_memory_write(0x085FFF1C, &v, 4);
|
||||
v = %s; /* S3 pop10 */
|
||||
cpu_physical_memory_write(0x085FFF44, &v, 4);
|
||||
cpu_physical_memory_write(0x085FFF7C, &v, 4);
|
||||
v = %s; /* S4 pop6 (stublet chains S5) */
|
||||
cpu_physical_memory_write(0x085FFF34, &v, 4);
|
||||
cpu_physical_memory_write(0x08600944, &magic, 4);
|
||||
printf("saimaa: stub-scaffold live\\n");
|
||||
}
|
||||
{
|
||||
''' % (c_array, S10_A, S2, S10_B, S6_A)
|
||||
|
||||
src = src[:start] + new_block + src[line_start:]
|
||||
open(M, 'w').write(src)
|
||||
print('CANONICAL SCAFFOLD v2 OK')
|
||||
Reference in New Issue
Block a user