PC port: Phase 2 — real threads, dual-mapped DRAM, fast3d integration

- Replace setjmp/longjmp green threads with real pthreads (8MB stacks);
  PortQueue side table (mutex+condvar) for OSMesgQueue; dedicated tick
  thread posts VI retrace + services timers (D24).
- Dual-mapped N64 DRAM: one 8MB store at V1 0x70000000 (s32-safe, all game
  RAM symbols) and V2 0x80000000 (KSEG0 mirror for offset|0x80000000
  rebuilds). Windows: CreateFileMappingW + MapViewOfFileEx; POSIX: memfd
  + MAP_FIXED. dram_syms.s pins cfb_16/_bssSegmentEnd/tlb block (D25).
- Address-width shims: PHYS_TO_K0 identity, OS_K0_TO_PHYSICAL = offset from
  V1 base, OS_PHYSICAL_TO_K0 identity; fast3d seg_addr() remaps small
  offsets into V2 (D26).
- ASLR off (-Wl,--disable-dynamicbase): absolute symbols referenced through
  pointer-typed externs (.refptr + BASE reloc) must not rebase; startup
  sanity check on image base 0x140000000 (D27).
- osPiStartDma posts its completion message on every path (fixes
  romReceiveMesg deadlock) (D29).
- SEH-free crash handler: raw fault log first, validated manual EBP-chain
  walk second (-fno-omit-frame-pointer), TerminateProcess; crashDumpThreads
  via Toolhelp32 for heartbeat hang dumps (D30).
- PD fast3d integrated (port/fast3d/), replaces gfxstub.c; real src/sched.c
  compiled; mainproc runs as a real pthread, host thread pumps SDL events.
- Docs: findings D24-D31 + Phase 2 status (section F/G).

Current state: boots through bossInitMainthreadData to langInit(), then
SIGSEGVs on the first file load — stack frame clobbered by a table of
truncated s32 pointers (D31, open). Next: attribute the write with
'set scheduler-locking on' + hardware watchpoint.
This commit is contained in:
James Dansereau committed 2026-08-21 14:42:19 -04:00
1 parent 2aad171344
commit 13ca03a6db
42 files changed
+12660 -537

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/*
* PC port shim for <stdlib.h>.
*
* The N64 decomp ships include/stdlib.h (a libc stub: lldiv_t/ldiv_t typedefs
* + a couple of prototypes). C game code gets it, exactly as on the console.
*
* In C++ TUs (fast3d) it must NOT be used: MinGW's own headers pull in the
* host <stdlib.h> through their include chains (sec_api/stdlib_s.h does
* `#include <stdlib.h>`, which resolves to the N64 header via -I), and the
* lldiv_t/ldiv_t typedefs then conflict with the host's. The shim routes C++
* TUs to the host header by absolute path (generated hoststdlib.h, same
* trick as port/shim/string.h — see docs/PCPortResearch.md §11 D12).
*
* Inert in the N64 build (port/shim is not on its include path).
*/
#if defined(__cplusplus)
#include "hoststdlib.h"
#else
#include "include/stdlib.h"
#endif