b38: S21 table-walker router

This commit is contained in:
lumia-emu
2026-09-14 00:34:52 +00:00
parent d3e2efe7ba
commit 8aef555346
5 changed files with 169 additions and 6 deletions
+22 -4
View File
@@ -104,15 +104,15 @@ static void saimaa_tmr_init(Object *obj)
/* Stubs region handle for set_readonly after scaffold implant. */
static MemoryRegion *saimaa_stubs_mr;
/* DDRLOW stub trap [0x08006B80,0x08006D60): serves the scaffolded bytes
* (S/maze/S6/banner/S7/S9/S10/S16/S17/S18/S20 stubs) on read/fetch,
/* DDRLOW stub trap [0x08006B80,0x08006D80): serves the scaffolded bytes
* (S/maze/S6/banner/S7/S9/S10/S16/S17/S18/S20/S21 stubs) on read/fetch,
* ignores SBL heap-clobber writes. Uni parity: deferred-restore guard
* in sbl_uni.py (wider: [0x080068C0,0x08006D60), also covers PBL stub).
* in sbl_uni.py (wider: [0x080068C0,0x08006D80), also covers PBL stub).
* Snapshot is taken AFTER ELF load + all stub writes (readback).
* PBL stub [0x080068C0,0x080068F4) and the ELF-text gap below stay plain
* RAM: PBL runs once (if at all), gap holds real hot SBL code. */
#define SAIMAA_DSTUB_BASE 0x08006B80
#define SAIMAA_DSTUB_SIZE 0x000001E0
#define SAIMAA_DSTUB_SIZE 0x00000200
static uint8_t saimaa_dstub_mem[SAIMAA_DSTUB_SIZE];
static uint64_t saimaa_dstub_read(void *opaque, hwaddr off, unsigned size)
@@ -698,6 +698,24 @@ static void saimaa_machine_init(MachineState *machine)
cpu_physical_memory_write(0x08006D22 + k, &word, 4);
}
}
/* S21 stublet at 0x08006D5A (32B, b38): table-walker router.
* [sp+0x24] valid-code? => original pop.w (legit return);
* else b.w S19 (sbl_main post-logger restart). */
{
static const uint8_t s21[] = {
0x09, 0x9b, 0x13, 0xf0, 0x01, 0x0f, 0x09, 0xd0,
0x1a, 0x0e, 0x08, 0x2a, 0x01, 0xd1, 0xbd, 0xe8,
0xf0, 0x9f, 0x1a, 0x0f, 0x08, 0x2a, 0x01, 0xd1,
0xbd, 0xe8, 0xf0, 0x9f, 0xff, 0xf7, 0xd9, 0xbf,
};
size_t k;
for (k = 0; k < sizeof(s21); k += 4) {
uint32_t word = 0;
size_t n = sizeof(s21) - k < 4 ? sizeof(s21) - k : 4;
__builtin_memcpy(&word, &s21[k], n);
cpu_physical_memory_write(0x08006D5A + k, &word, 4);
}
}
/* S20 stublet at 0x08006D38 (34B, b37): clock-dispatcher
* router. [sp+0x2C] valid-code? => original pop.w (legit);
* else r0=sl + b.w dispatcher re-run (idempotent math). */