code wiki / _hdl_build / nx_spore_boot.nx

nx_spore_boot.nx

buildroot/runtime/_hdl_build/nx_spore_boot.nx

11479 B161 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind tooltopic spore
docsdependenciesstructsconstsfunctions

about

nx_spore_boot.nx -- GATE: the BOOTABLE SPORE. NishiOS rung 4 capstone -- "match Puppy = a live image from POST". Composes the three capabilities built this rung into a full cold boot to userland: * the LIVE IMAGE = an NSFS-v2 filesystem image (a file = the medium; nx_vfsblock_lib) carrying /sbin/init.nxe * MOUNT ROOT = vb_mount validates the superblock + REPLAYS the journal (crash-safe boot; nx_vfsblock_lib) * LOAD + RUN INIT = read the .nxe by path from the mounted FS, VERIFY (SHA-256 + capability + never-brick), then EXECUTE it (nx_nxe_lib: mmap RWX + cast fn-ptr + call = real machine code at userland) The RESET stage is REAL executed x86_64: from cold reset the boot-stage runs as machine code (mmap RWX + call), the C9-class "boot runs as real executed code" seam -- not a function called in sequence. T1 COLD BOOT TO USERLAND: reset-code runs -> load medium -> mount(replay) -> load+verify+exec /sbin/init.nxe -> marker. T2 PERSISTENCE / POWER-CYCLE: reboot from the same medium -> same userland result (a live image boots repeatedly). T3 CRASH-DURING-INSTALL: journaled install of /sbin/init2.nxe crashes after commit -> reboot replays -> init2 BOOTS. T4 NEVER-BRICK SAFE-HALT: a tampered /sbin/init.nxe on the medium -> loader REFUSES -> boot halts, init NEVER runs. T5 MISSING INIT: no /sbin/init.nxe -> boot halts cleanly (-3), no crash. HONEST: emulator/file-model -- RWX-exec stands in for the CPU fetch, the medium is a file; real-hardware POST (BIOS/UEFI on physical silicon) remains the guarded never-brick operator step. expect_exit: 0 Sovereign: nx_cc->nxasm via nx_vfsblock_lib + nx_nxe_lib + nx_sha256. NEVER-BRICK: RAM + an image file, 0 firmware.

dependencies 2 imports · 0 importers

nx_vfsblock_lib.nx nx_nxe_lib.nx nx_spore_boot.nx

imports: nx_vfsblock_lib.nxnx_nxe_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main g_puts vb_format vb_wr vb_ino vb_nm_set vbj_mkdir_tx vb_ino ↻ vb_rd vb_lookup vb_ino ↻ vb_rd ↻ vb_nm_eq vb_alloc_inode vb_rd ↻ vb_ino ↻ sys_mmap vb_wr ↻ vbj_begin vbj_hdr vb_rd ↻ vb_wr ↻ vbj_add vbj_hdr ↻ vb_rd ↻ vb_wr ↻ vbj_rec vbj_commit vbj_hdr ↻ vbj_sumrecs vbj_hdr ↻ vb_rd ↻ vb_sum vbj_rec ↻ vb_wr ↻ vbj_apply vbj_hdr ↻ vb_rd ↻ vbj_rec ↻ vbj_checkpoint

structs

none

consts

19const K_MAGIC_4096: i64 = 4096
20const K_MAGIC_45063: i64 = 45063

functions

22func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: ckmain
23func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 1: main
24func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
called by 1: main calls 1: g_puts
25func wlog(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 }
called by 1: main
28func emit_init(dst: *u8) -> i64
called by 1: build_init_nxe
36func emit_boot(dst: *u8) -> i64
called by 1: main
44func build_init_nxe(out: *u8) -> i64
called by 1: main calls 3: emit_initnxe_writenxe_size
53func spore_boot(a: *u8, imgpath: *u8, arg: i64, resbox: *i64, ranbox: *i64) -> i64
66func stage_file(a: *u8, scr: *u8, parent: i64, name: *u8, data: *u8, len: i64) -> i64
81func main() -> i64