nx_emu_x86_stage2_test.nx
buildroot/runtime/nx_emu_x86_stage2_test.nx
about
nx_emu_x86_stage2_test.nx -- x86 ladder R9 rung-4: a REAL MULTI-STAGE LOADER, executed end-to-end.
A 512-byte boot sector cannot BE an OS -- it must LOAD one. This builds a 2-sector disk (sector 0 =
stage-1 MBR, sector 1 = stage-2), and the emu now models BIOS INT 13h (AH=0x02 read-sectors). The
real boot flow runs on the sovereign machine: stage-1 issues INT 13h to read sector 1 into memory at
0x8000, then E9-jumps to it; stage-2 prints "STAGE2 OK" over INT 10h and halts. This is the
multi-stage loader the real-OS ladder needs -- proven by EXECUTION, not structure.
KAT: stage-2 was actually copied off disk by INT 13h (0x8000 was empty, now holds stage-2), the
console shows stage-2's output, and the cpu halted cleanly.
HONEST SCOPE: stage-2 here is a tiny printer. The rungs above: stage-2 -> protected/long mode ->
load the real kernel -> GDT/IDT/paging/MM/scheduler/syscalls -> userspace. No hw writes (Rule 26).
expect_exit: 0 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
| 14 | func s2_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 15 | func s2_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;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{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 16 | func s2_beq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } called by 1: main |
| 20 | func emu_x86_real16_disk(mem: *u8, disk: *u8, entry: i64, console: *u8, clen: *i64) -> i64 called by 1: main |
| 64 | func main() -> i64 |