code wiki / (root) / nx_nishios_kbd.nx

nx_nishios_kbd.nx

buildroot/runtime/nx_nishios_kbd.nx

9098 B140 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tooltopic nishios
docsdependenciesstructsconstsfunctions

about

nx_nishios_kbd.nx -- NishiOS GUI rung-5: LIVE KEYBOARD INPUT + a real shell line editor. Turns the terminal from a `cat` into something you TYPE into. Models the PS/2 keyboard path a kernel actually walks: read scancodes from the controller (port 0x60), translate set-1 make codes -> ASCII via a keymap, handle BACKSPACE line-editing, echo, and on ENTER dispatch a shell builtin. The demo types 'v','e','e',<backspace>,'r',<enter> -> the line editor yields "ver" (the stray 'e' erased), the shell runs it -> "NishiOS 0.1 sovereign", and the terminal renders prompt+command+output. KAT: the line editor produced "ver" (backspace worked), the shell dispatched the right output, both the command line and the output render, and the BMP exports. HONEST SEAM: the scancode SOURCE is scripted (no live PS/2 controller modeled on the emu -- that IRQ1 wiring is the hardware rung); the driver LOGIC (port read, set-1 keymap, line edit, echo, dispatch) is real. No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_fb.nx nx_itoa_lib.nx nx_font8x8.nx nx_nishios_kbd.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 kb_puts build_keymap run_cmd kb_streq kb_slen kb_scopy kb_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 ↻ kb_streq ↻ kt_count

structs

none

consts

15const K_MAGIC_192054: i64 = 192054

functions

17func kb_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
22func kb_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
23func kb_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: kb_streq
24func kb_streq(a: *u8, alen: i64, b: *u8) -> i64 { let bl: i64=kb_slen(b); if alen!=bl { return 0 } var i: i64=0; while i<alen { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
called by 2: run_cmdmain calls 1: kb_slen
25func kb_scopy(dst: *u8, doff: i64, src: *u8) -> i64 { var i: i64=0; while src[i]!=(0 as u8) { dst[doff+i]=src[i]; i=i+1 } return doff+i }
called by 1: run_cmd
28func kt_char(fb: *u8, W: i64, H: i64, table: *u8, x: i64, y: i64, ch: i64, r: i64, g: i64, b: i64) -> i64
called by 1: kt_str calls 1: fb_setpx
36func kt_str(fb: *u8, W: i64, H: i64, table: *u8, x: i64, y: i64, s: *u8, r: i64, g: i64, b: i64) -> i64
called by 1: main calls 1: kt_char
41func kt_count(fb: *u8, W: i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64
called by 1: main
48func build_keymap(km: *u8) -> i64
called by 1: main
59func run_cmd(line: *u8, linelen: i64, out: *u8) -> i64
called by 1: main calls 2: kb_streqkb_scopy
70func main() -> i64