code wiki / (root) / nx_nishi_usb_desktop.nx

nx_nishi_usb_desktop.nx

buildroot/runtime/nx_nishi_usb_desktop.nx

16004 B268 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tooltopic nishi
docsdependenciesstructsconstsfunctions

about

nx_nishi_usb_desktop.nx -- x86 ladder R9-DESKTOP: boot the PERSISTED USB image -> SEE the desktop. Operator north star for this arc: "emu and SEE it in a window". The prior rungs proved a persisted bootable image (nx_nishi_usb_image) and that the disk-loaded kernel crosses into LONG mode (nx_nishi_usb_longmode). This rung connects that boot chain to the VISIBLE desktop: it boots the persisted on-disk image to long mode and -- ONLY because the disk-loaded kernel actually reached long mode -- the kernel's framebuffer driver (nx_fb) initializes a linear framebuffer and draws the desktop, rendering the REAL boot state (the UART banner it printed + "LONG MODE") into the window. Export = knowledge/status/nishi_os_desktop.bmp = one picture of "flash this image -> power on -> long mode -> desktop". KAT: (T1) booted off the persisted image (INT 13h: 0x8000 0->0xBE); (T2) the disk-loaded kernel reached LONG mode (mode==2); (T3) UART banner == 'NishiOS'; (T4) the desktop wallpaper was drawn; (T5) the desktop window was drawn; (T6) the BMP was exported. NEG/liar-kill (T7): a sibling image whose MBR loads ZERO sectors never reaches long mode, so the desktop-draw (gated on mode==2) never fires -- the desktop exists ONLY because the real disk-loaded kernel booted to long mode. HONEST SEAM (no overclaim, identical to nx_nishios_boot_gui): the emu EXECUTES the loader + the real->protected->long CR0/EFER transition as real x86; the desktop is then drawn by nx_fb -- the kernel's framebuffer driver in NishiLang (the SAME sovereign language the kernel compiles from). Running the desktop draw-loop itself as x86-on-the-emu + a real VESA/GOP framebuffer on hardware are the deeper rungs. The unified boot-disk emu is the same one proven in nx_nishi_usb_longmode. NEVER-BRICK (Rule 26): writes FILE artifacts (.img/.bmp/.html); models INT 13h *reads* only; no /dev. expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_fb.nx nx_font8x8.nx nx_nishi_usb_desktop.nx

imports: nx_fb.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 ud_puts build_image ud_movrax sys_openat_wr ud_read sys_read boot_image emu_x86_boot_disk ud_mode ud_num font8x8_table sys_mmap fg fb_nishi_font fb_gly fb_rect fb_setpx fb_text fb_char fb_rect ↻ fb_window fb_rect ↻ fb_text ↻ draw_str fb_rect ↻ fb_cursor sys_mmap ↻ fb_setpx ↻ fb_bmp_save sys_mmap ↻ fb_p32 fb_p16 sys_openat_wr ↻ sys_write sys_close ud_contains

structs

none

consts

26const IMG_MAGIC_200000: i64 = 200000
27const IMG_MAGIC_32767: i64 = 32767
28const IMG_MAGIC_65536: i64 = 65536
106const IMG_SZ: i64 = 1024

functions

30func ud_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
31func ud_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main
32func ud_beq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
33func ud_contains(hay: *u8, hn: i64, ndl: *u8, nn: i64) -> i64
called by 1: main
39func ud_mode(cr0: i64, efer: i64) -> i64 { let pe: i64=cr0&1; let pg: i64=(cr0>>31)&1; let lme: i64=(efer>>8)&1; if pe==0 { return 0 } if pg==1 { if lme==1 { return 2 } } return 1 }
called by 1: emu_x86_boot_disk
43func emu_x86_boot_disk(mem: *u8, disk: *u8, entry: i64, console: *u8, clen: *i64, st: *i64) -> i64
called by 1: boot_image calls 1: ud_mode
108func ud_movrax(img: *u8, base: i64, o: i64, b0: i64, b1: i64, b2: i64, b3: i64) -> i64
called by 1: build_image
115func build_image(img: *u8) -> i64
called by 1: main calls 1: ud_movrax
155func boot_image(img: *u8, console: *u8, clen: *i64, st: *i64, loaded: *i64) -> i64
called by 1: main calls 1: emu_x86_boot_disk
168func ud_read(path: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
178func draw_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: fb_rect
192func main() -> i64