Files
arti 0075e57c0d m7.2: add object/debug end-to-end gates
- oracle.sh: link the M5 native objects with GSPLNK and tms-link, require
  identical allocated bytes/public symbols through the independent reader,
  then run the tms-link image in MAME and decode _native_value with dis34.
- cinit.sh: a C TI .cinit record table (packed u16 count/u32 destination/
  data words) linked by tms-link, the termtris copy loop in MAME, cinit at
  the .cinit origin, the destination resolved to a bit address, and
  bytes/placement equal to GSPLNK.
- longname.sh: a 44-character public function defined in one TU and called
  from another, linked by tms-link, full name in the map, runs in MAME.
- debug.sh: tms-clang -g -> TI-COFF -> tms-link --keep-debug, .debug_*
  wrapped in a minimal ELF32 container and validated with llvm-dwarfdump
  (debug.c, line rows, low PC 0x314000, high_pc byte size, string names),
  plus the stripped image loading in MAME.
- tms-clang: pass -g through to clang; the bit-pointer passes preserve !dbg.
- tms-link: accept GSPA's .text/.data/.bss/.cinit order as well as llc's
  .text/.data/.cinit/.bss order (the real startup cinit.asm shape).
2026-11-14 22:21:03 +00:00

52 lines
2.0 KiB
C

/* M7.2 `.cinit` gate table: the TI init-record format in C.
*
* The TI format is a sequence of records:
*
* packed struct {
* unsigned short count; // data word count
* unsigned long destination; // TMS34010 *bit* address
* unsigned short data[count];
* };
*
* terminated by a zero count. `cinit-entry.asm` defines the public `cinit`
* symbol at the start of its own empty `.cinit` section (the termtris
* `cinit.asm` shape) and walks this table exactly like the termtris `_start`:
* `movi cinit,a9; move *a9+,count; move *a9+,dst,1; copy count words`.
*
* The destination is a pointer-typed union member rather than a plain
* `unsigned long` initialised with `(unsigned long)&cinit_target`. Both are
* the same packed 32-bit field at byte offset 2, but the object writer emits a
* relocation only for a pointer constant; casting the address to an integer
* produces an LLVM `ptrtoint` constant expression that the `.data`/.cinit
* emitter deliberately rejects as unsupported. The pointer value *is* the
* TMS34010 bit address in this ABI, so the linked field is the resolved bit
* address the entry loop needs. The record header is packed, so the 32-bit
* destination sits at bit offset 16 and the linker resolves it as an ordinary
* R-RELLONG field (the CPU copy loop is bit-addressed).
*/
unsigned short cinit_target[4];
struct __attribute__((packed)) cinit_record {
unsigned short count;
union {
unsigned long destination;
unsigned short *address;
} target;
unsigned short data[3];
unsigned short end;
};
/* The table lives in `.cinit`; the entry object contributes the `cinit`
* symbol at offset 0 of the concatenated section. */
__attribute__((section(".cinit")))
const struct cinit_record cinit_table = {
3, { .address = cinit_target }, { 0x1111, 0x2222, 0x3333 }, 0
};
/* Called by the entry after the copy loop; returns the sum of the copied
* words (0x1111 + 0x2222 + 0x3333 = 0x6666). */
int cinit_probe(void) {
return cinit_target[0] + cinit_target[1] + cinit_target[2];
}