code wiki / _hdl_build / nx_spore_emit_iso.nx
nx_spore_emit_iso.nx
buildroot/runtime/_hdl_build/nx_spore_emit_iso.nx
about
nx_spore_emit_iso.nx -- nx_spore_emit rung 1: a SOVEREIGN El Torito bootable ISO (BIOS/KVM) for cloud testing (Vultr).
The iso/README (nx_spore) REFUSES xorriso/mkisofs/genisoimage -- so we emit ISO 9660 + El Torito ourselves.
This produces knowledge/status/nishi_vultr.iso: a minimal but spec-faithful bootable CD image that Vultr
(and any BIOS/KVM/SeaBIOS host) boots via "Custom ISO". Layout (2048-byte ISO sectors):
0..15 system area (zero)
16 Primary Volume Descriptor (type 1, "CD001")
17 Boot Record VD (El Torito, "EL TORITO SPECIFICATION") -> boot catalog @ sector 19
18 Volume Descriptor Set Terminator (type 255)
19 El Torito Boot Catalog: validation entry (checksum + 55 AA) + default entry (no-emul, load @0x7C00)
20 boot image = our proven real-mode boot sector (prints a banner via BIOS INT10h, then HLT)
21 (empty root directory extent)
The default entry is NO-EMULATION: BIOS loads sector-count*512 bytes from the boot image to 0x7C00 and runs
our real-mode code -- the exact code our sovereign BIOS-INT emu already executes (C8/nx_nishi_bootimg).
HONEST SCOPE (no overclaim): structure is VERIFIED here by parse-back (PVD/boot-record/terminator/catalog
checksum/default-entry/boot-image-signature) -- the BYTES are El-Torito-correct. The ACTUAL boot on real
SeaBIOS is NOT verified locally (no qemu installed); Vultr's KVM boot (a disposable VM = never-brick) is the
real validation. Full browsable ISO 9660 (path tables / files) + UEFI + hybrid-MBR = nx_spore_emit refinements.
KAT 6/6 (parse-back of the persisted bytes). composes nx_syscalls only.
NEVER-BRICK (Rule 26): writes a FILE; models nothing on hardware. 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
| 23 | const LBA_MAGIC_2048: i64 = 2048 |
| 25 | const SEC: i64 = 2048 |
| 26 | const NSEC: i64 = 24 // total ISO sectors (49152 bytes) |
| 27 | const LBA_PVD: i64 = 16 |
| 28 | const LBA_BOOTREC: i64 = 17 |
| 29 | const LBA_TERM: i64 = 18 |
| 30 | const LBA_CATALOG: i64 = 19 |
| 31 | const LBA_BOOTIMG: i64 = 20 |
| 32 | const LBA_ROOTDIR: i64 = 21 |
| 33 | const BOOT_VSECS: i64 = 4 // virtual 512-byte sectors the BIOS loads from the boot image (4*512=2048) |
functions
| 35 | func ui_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 36 | func ui_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 } |
| 37 | func w16le(d: *u8, o: i64, v: i64) -> i64 { d[o]=(v&0xFF) as u8; d[o+1]=((v>>8)&0xFF) as u8; return 0 } called by 1: main |
| 38 | func w16be(d: *u8, o: i64, v: i64) -> i64 { d[o]=((v>>8)&0xFF) as u8; d[o+1]=(v&0xFF) as u8; return 0 } called by 1: main |
| 39 | func w32le(d: *u8, o: i64, v: i64) -> i64 { d[o]=(v&0xFF) as u8; d[o+1]=((v>>8)&0xFF) as u8; d[o+2]=((v>>16)&0xFF) as u8; d[o+3]=((v>>24)&0xFF) as u8; return 0 } called by 1: main |
| 40 | func w32be(d: *u8, o: i64, v: i64) -> i64 { d[o]=((v>>24)&0xFF) as u8; d[o+1]=((v>>16)&0xFF) as u8; d[o+2]=((v>>8)&0xFF) as u8; d[o+3]=(v&0xFF) as u8; return 0 } called by 1: main |
| 41 | func r32le(d: *u8, o: i64) -> i64 { return (d[o] as i64) | ((d[o+1] as i64)<<8) | ((d[o+2] as i64)<<16) | ((d[o+3] as i64)<<24) } called by 1: main |
| 43 | func strpad(d: *u8, o: i64, s: *u8, n: i64, pad: i64) -> i64 { var i: i64=0; while i<n { if s[i]!=(0 as u8) { d[o+i]=s[i] } else { d[o+i]=pad as u8 } i=i+1 } return 0 } called by 1: main |
| 44 | func streq(d: *u8, o: i64, s: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if d[o+i]!=s[i] { return 0 } i=i+1 } return 1 } called by 1: main |
| 47 | func author_boot(d: *u8, b: i64) -> i64 called by 1: main |
| 70 | func main() -> i64 |