code wiki / _hdl_build / _trap_syscall_gate.nx
_trap_syscall_gate.nx
buildroot/runtime/_hdl_build/_trap_syscall_gate.nx
about
_trap_syscall_gate.nx -- the K-R1 gate (kernel-up ladder rung 1). Drives the full
author->trap->syscall chain with NO mocks: runs the REAL nx_trap_syscall_emit (the
team AUTHORS the rv64 trap+syscall image + the TABLE-COMPUTED golden transcript from
the spec), then RUNS the image on the SOVEREIGN rv64 emulator (rv64im_min_sim -- the
PRIMARY, gating lane: Nishi owns the runtime) and asserts the captured serial
transcript CONTAINS the emitter's golden (banner + each syscall's emit byte, in order)
AND the sovereign emu reports a clean SiFive-finisher halt (BOOTSOV verdict=GREEN).
Then it runs the SAME image on qemu-system-riscv64 -machine virt (the declared
hardware-alignment lane, NOT the runtime -- the diff-lane signal) and asserts the
lanes AGREE on the transcript. Finally a TAMPER test: corrupt one syscall's a7 in the
image -> that handler never fires -> the transcript loses a byte -> the gate must go
RED (proves the gate bites, not a rubber stamp). Evidence -> knowledge/status/
trap_syscall.log (TRAPGATE row; the queue row's ||MARK= reads it). Sovereign
orchestration (fork/dup3/execve/wait4). license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 17 | func g_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 18 | func g_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 19 | func g_fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 22 | func g_run_emit(spec: *u8) -> i64 |
| 43 | func g_run_qemu(binpath: *u8, outpath: *u8) -> i64 |
| 68 | func g_run_sov(binpath: *u8, outpath: *u8) -> i64 |
| 89 | func g_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 100 | func g_buf_has(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 |
| 113 | func g_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: g_file_has |
| 116 | func g_file_has(path: *u8, pat: *u8) -> i64 |
| 122 | func main() -> i64 |