b37: S20 clock-dispatcher router

This commit is contained in:
lumia-emu
2026-09-14 00:24:47 +00:00
parent 8ce95238e0
commit 4fcb316c99
5 changed files with 165 additions and 7 deletions
+24 -5
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,0x08006D30): serves the scaffolded bytes
* (S/maze/S6/banner/S7/S9/S10/S16/S17 stubs) on read/fetch, ignores SBL
* heap-clobber writes. Uni parity: deferred-restore guard in sbl_uni.py
* (wider: [0x080068C0,0x08006D30), also covers PBL stub).
/* DDRLOW stub trap [0x08006B80,0x08006D60): serves the scaffolded bytes
* (S/maze/S6/banner/S7/S9/S10/S16/S17/S18/S20 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).
* 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 0x000001B0
#define SAIMAA_DSTUB_SIZE 0x000001E0
static uint8_t saimaa_dstub_mem[SAIMAA_DSTUB_SIZE];
static uint64_t saimaa_dstub_read(void *opaque, hwaddr off, unsigned size)
@@ -707,6 +707,25 @@ static void saimaa_machine_init(MachineState *machine)
cpu_physical_memory_write(0x08006D22 + 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). */
{
static const uint8_t s20[] = {
0x0b, 0x9b, 0x13, 0xf0, 0x01, 0x0f, 0x09, 0xd0,
0x1a, 0x0e, 0x08, 0x2a, 0x01, 0xd1, 0xbd, 0xe8,
0xfe, 0x8f, 0x1a, 0x0f, 0x08, 0x2a, 0x01, 0xd1,
0xbd, 0xe8, 0xfe, 0x8f, 0x50, 0x46, 0x07, 0xf0,
0x13, 0xbf,
};
size_t k;
for (k = 0; k < sizeof(s20); k += 4) {
uint32_t word = 0;
size_t n = sizeof(s20) - k < 4 ? sizeof(s20) - k : 4;
__builtin_memcpy(&word, &s20[k], n);
cpu_physical_memory_write(0x08006D38 + k, &word, 4);
}
}
/* S17 safe-logger (50B @0x08006CF0, b26): print r1-string
* via UARTDM-TF iff r1 in rodata [0x804B800,0x8058000);
* pop-return (no leak). Replaces S8 silence with logs. */