code wiki / _hdl_build / nx_paging.nx
nx_paging.nx
buildroot/runtime/_hdl_build/nx_paging.nx
about
nx_paging.nx -- SOVEREIGN VIRTUAL-MEMORY MODEL (deepens MEMORY-MGMT beyond the nx_alloc heap). Page table
(vpn->pfn), address translation, PAGE FAULTS, a physical-frame allocator, DEMAND paging + LRU eviction, and
per-page protection bits. This is the VM POLICY/data-structure.
★ NEVER-BRICK (cardinal 26): this is a MODEL only -- it does NOT touch the real hardware MMU (no CR3/TLB/ring0,
no firmware/page-table writes). By construction it cannot brick anything. The real-MMU binding is a separate,
guarded hardware-axis capability.
T1 map + translate (hit). T2 unmapped page -> FAULT. T3 demand page-in. T4 eviction (LRU; evicted page faults).
T5 teeth: write to a read-only page is DENIED (protection).
expect_exit: 0 Sovereign: nx_syscalls.
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_g_puts_lib.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
| 21 | const PS: i64 = 4096 // page size |
| 22 | const NV: i64 = 16 // virtual pages |
| 23 | const NF: i64 = 4 // physical frames (small -> exercises eviction) |
functions
| 18 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 19 | func 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 } |
| 25 | func vm_translate(ptab: *i64, vaddr: i64) -> i64 { let vpn: i64=vaddr/PS; if ptab[vpn]>=0 { return ptab[vpn]*PS + (vaddr%PS) } return 0-1 } called by 1: main |
| 27 | func vm_access(ptab: *i64, frown: *i64, lastu: *i64, vpn: i64, clk: i64) -> i64 called by 1: main |
| 37 | func vm_can_write(prot: *i64, vpn: i64) -> i64 { return (prot[vpn]>>1)&1 } // prot bit1 = write called by 1: main |
| 39 | func main() -> i64 |