import "io" import "os1" manifest { ptn_bits = selector 10 : 22, pn_bits = selector 11 : 11, offset_bits = selector 11 : 0 } manifest { iv_none = 0, iv_memory = 1, iv_pagefault = 2, iv_unimpop = 3, iv_halt = 4, iv_divzero = 5, iv_unwrop = 6, iv_timer = 7, iv_privop = 8, iv_keybd = 9, iv_badcall = 10, iv_pagepriv = 11, iv_debug = 12, iv_intrfault = 13 } let ihandle_pf(intcode, address, info, pc) be { let ptn = ptn_bits from address, pn = pn_bits from address, off = offset_bits from address; let pt_physaddr = pgdir_va ! ptn >> 11; out("Page Fault for %08x: PT:%d, PN:%d, OFF:%d\n", address, ptn, pn, off); out("PC was %08x = %d\n", pc, pc); out("relevant page table is phys page %d\n", pt_physaddr); ptspec_va ! spec_p1e := (pt_physaddr << 11) bitor 1; p1_va ! pn := (13 << 11) bitor 1; ireturn } let start() be { let addr = 0x80003210, n; assembly { getsr r1, $flags cbit $ip setsr r1, $flags } intvec_va ! iv_pagefault := ihandle_pf; outs("number? "); n := inno(); outs("storing..."); ! addr := n; outs("...stored\n"); out("%d\n", ! addr) }