nx_nishios_irq.nx
buildroot/runtime/nx_nishios_irq.nx
about
nx_nishios_irq.nx -- NishiOS GUI rung-8: LIVE PS/2 IRQ1 (real interrupt-driven keyboard).
Closes the "input is scripted" seam. The emu now models hardware INTERRUPT DELIVERY: between
instructions, if IF (interrupt flag) is set and the keyboard controller has a pending scancode, the
CPU TAKES the interrupt -- pushes the return address, vectors through the IDT entry idt[0x21] to the
handler, which reads the scancode via INB port 0x60, stores it, and IRETs. The handler runs ONLY
because an interrupt was delivered, not because anyone called it. Kernel: install idt[0x21], STI,
then wait until N keys handled. We inject the scancodes for "nishi" as IRQs.
KAT: all 5 keys arrive via the interrupt path (handler fired 5x, scancodes match); a NEGATIVE CONTROL
with interrupts masked (no STI) collects ZERO -> proves delivery is genuinely IF-gated (real interrupt,
not a disguised direct call); the scancodes translate to "nishi"; rendered to a terminal BMP.
HONEST SEAM: scancodes are injected by the harness (a real PS/2 controller chip on hardware is R10);
the IDT vectoring + IF-gating + INB + IRET are real. No hw writes (Rule 26). expect_exit: 0 tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_fb.nxnx_itoa_lib.nxnx_font8x8.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
| 16 | const K_MAGIC_3000000: i64 = 3000000 |
| 17 | const K_MAGIC_4096: i64 = 4096 |
| 18 | const K_MAGIC_8192: i64 = 8192 |
| 19 | const K_MAGIC_4104: i64 = 4104 |
| 20 | const K_MAGIC_4112: i64 = 4112 |
| 21 | const K_MAGIC_16384: i64 = 16384 |
functions
| 23 | func iq_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 1: main |
| 28 | func iq_num(v: i64) -> i64 { nxi_out(v); return 0 } |
| 29 | func iq_b(c: *u8, o: i64, b: i64) -> i64 { c[o]=(b & 0xff) as u8; return o+1 } called by 1: main |
| 30 | func iq_i32(c: *u8, o: i64, v: i64) -> i64 { c[o]=(v&0xff) as u8; c[o+1]=((v>>8)&0xff) as u8; c[o+2]=((v>>16)&0xff) as u8; c[o+3]=((v>>24)&0xff) as u8; return o+4 } called by 1: main |
| 31 | func iq_ld64(mem: *u8, a: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v=v|((mem[a+i] as i64)<<(i*8)); i=i+1 } return v } |
| 32 | func iq_st64(mem: *u8, a: i64, v: i64) -> i64 { var i: i64=0; while i<8 { mem[a+i]=((v>>(i*8))&0xff) as u8; i=i+1 } return 0 } called by 1: emu_irq |
| 33 | func iq_i32r(code: *u8, off: i64) -> i64 { var v: i64=(code[off] as i64)|((code[off+1] as i64)<<8)|((code[off+2] as i64)<<16)|((code[off+3] as i64)<<24); if (v & 0x80000000)!=0 { v=v-(1<<32) } return v } called by 1: emu_irq |
| 37 | func emu_irq(code: *u8, len: i64, mem: *u8, scq: *u8, sctot: i64, sti_en: i64) -> i64 |
| 72 | func kt_char(fb: *u8, W: i64, H: i64, table: *u8, x: i64, y: i64, ch: i64, r: i64, g: i64, b: i64) -> i64 { if ch<0x20 { return 0 } if ch>0x7E { return 0 } let gi: i64=(ch-0x20)*8; var row: i64=0; while row<8 { let bits: i64=table[gi+row] as i64; var col: i64=0; while col<8 { if ((bits>>col)&1)==1 { fb_setpx(fb,W,H, x+col, y+row, r,g,b) } col=col+1 } row=row+1 } return 0 } |
| 73 | func kt_str(fb: *u8, W: i64, H: i64, table: *u8, x: i64, y: i64, s: *u8, r: i64, g: i64, b: i64) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { kt_char(fb,W,H,table, x+i*8, y, s[i] as i64, r,g,b); i=i+1 } return 0 } |
| 75 | func main() -> i64 |