code wiki / (root) / nx_nishios_irq.nx

nx_nishios_irq.nx

buildroot/runtime/nx_nishios_irq.nx

13729 B171 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tooltopic nishios
docsdependenciesstructsconstsfunctions

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

nx_fb.nx nx_itoa_lib.nx nx_font8x8.nx nx_nishios_irq.nx

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

main iq_puts iq_b iq_i32 emu_irq iq_st64 iq_ld64 iq_i32r iq_ld64 ↻ iq_num nxi_out nxi_fd sys_mmap ccz_cat_num sys_write sys_munmap font8x8_table sys_mmap ↻ fg fb_rect fb_setpx kt_str kt_char fb_setpx ↻ fb_bmp_save sys_mmap ↻ fb_p32 fb_p16 sys_openat_wr sys_write ↻ sys_close sys_openat_wr ↻

structs

none

consts

16const K_MAGIC_3000000: i64 = 3000000
17const K_MAGIC_4096: i64 = 4096
18const K_MAGIC_8192: i64 = 8192
19const K_MAGIC_4104: i64 = 4104
20const K_MAGIC_4112: i64 = 4112
21const K_MAGIC_16384: i64 = 16384

functions

23func 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
28func iq_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
29func iq_b(c: *u8, o: i64, b: i64) -> i64 { c[o]=(b & 0xff) as u8; return o+1 }
called by 1: main
30func 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
31func 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 }
called by 2: emu_irqmain
32func 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
33func 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
37func emu_irq(code: *u8, len: i64, mem: *u8, scq: *u8, sctot: i64, sti_en: i64) -> i64
called by 1: main calls 3: iq_st64iq_ld64iq_i32r
72func 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 }
called by 1: kt_str calls 1: fb_setpx
73func 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 }
called by 1: main calls 1: kt_char
75func main() -> i64