Files

77 lines
2.7 KiB
C

/*
* hwmark.c -- M7.3 real-hardware marker client, built at the proven VT1200
* hardware origins:
*
* .text 018C0000h
* .data 018D0000h
* .bss 018D8000h
*
* This is the COFF image that dwt/loader/hostload.py pokes and that
* dwt/loader/loader.asm places through create_process. The marker cells are
* the ones hostload.py's MARKER_CELLS names (all TMS34010 *bit* addresses):
*
* 018E0000 _start address at run time (must equal the loader entry)
* 018E0020 d_magic read from .data (must be DEADBEEF)
* 018E0040 d_two read from .data (must be 12345678)
* 018E0060 b_zero read from .bss (must be 0)
* 018E0080 b_counter, a live counter (must advance)
*
* The M7.3 brief prefers a C-only entry when the compiler can express it, so
* `start` is an ordinary C function and the COFF entry point is `_start`.
* create_process() supplies the process stack (the firmware allocates it; the
* xhello trace records a valid entry A14). The MAME run proves the generated
* prologue did not fault and the markers/counter are correct, not that A14/SP
* point at the create_process stack; the real-unit run (VT1200_HOST) is the
* hardware confirmation. The `.data` pointer
* initializer below is supported as an ordinary pointer relocation, so no
* `ptrtoint` constant initializer and no assembly entry are needed.
*
* The loader zeroes .bss after the harness has pre-filled it with A5A5, so a
* zero at 018E0060 is the loader's work, not fresh RAM. The delay loop is
* marker.asm's 2000h `dsjs` delay: the child stays scheduled but does not burn
* the cooperative scheduler with an unbroken hot loop.
*/
#define MARK(n) (*(volatile unsigned int *)(0x018E0000u + (n) * 0x20u))
/* Initialised .data: the loader must copy these bytes from the COFF. */
unsigned int d_magic = 0xDEADBEEFu;
unsigned int d_two = 0x12345678u;
/* Uninitialised .bss: the loader must zero these. */
unsigned int b_zero;
unsigned int b_counter;
void start(void);
/*
* The entry address as a relocated pointer, not a ptrtoint constant. The
* loader's result block reports the same `_start` bit address as the COFF
* entry point, so the runtime start cell proves placement, not a guess.
*/
void (*const start_address)(void) = start;
/* A volatile .bss sink keeps the delay loop from being folded away. */
static volatile unsigned int delay_sink;
void start(void) {
unsigned int count = 0;
MARK(0) = (unsigned int)start_address;
MARK(1) = d_magic;
MARK(2) = d_two;
MARK(3) = b_zero;
for (;;) {
unsigned int spin;
count++;
b_counter = count;
MARK(4) = count;
for (spin = 0; spin < 0x2000u; spin++) {
delay_sink = spin;
}
}
}