code wiki / _hdl_build / _gpu_bm_doorbell_gate.nx

_gpu_bm_doorbell_gate.nx

buildroot/runtime/_hdl_build/_gpu_bm_doorbell_gate.nx

9520 B128 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic gpu
docsdependenciesstructsconstsfunctions

about

_gpu_bm_doorbell_gate.nx -- BARE-METAL SOVEREIGN-GPU rung BM-GPU-5: the FULL doorbell->execute path. Composes BM-GPU-4 (GPFIFO channel + entry) + BM-GPU-1 (pushbuffer execution): the driver writes pushbuffers + GPFIFO entries, advances GP_PUT, and RINGS THE DOORBELL; the modeled host FIFO then walks the ring GP_GET..GP_PUT, decodes each entry, fetches+executes each pushbuffer, and the semaphores land in GPU memory. THIS IS THE EXACT SOVEREIGN SUBMIT->EXECUTE LOOP WSL'S HOST-TRANSLATION BLOCKED -- closed end-to-end in a spec-faithful model. NISHI-ECOSYSTEM-ONLY: our channel + our ring + our pushbuffer + our FIFO model. HONEST SCOPE: full path LOGIC vs spec; real doorbell MMIO + real channel in VRAM = BM-GPU-6 on native Linux. GREEN iff: before the doorbell both semaphores read 0; after the doorbell BOTH land their distinct payloads and GP_GET advances to GP_PUT (FIFO consumed the ring); AND tampers (no doorbell => nothing executes; corrupt pushbuffer => its semaphore doesn't land) hold. Marker -> knowledge/status/gpu_baremetal.log (BMDOORBELLGATE). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx _gpu_bm_doorbell_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main p sys_write sys_mmap emit_pb wr32 wr32 ↻ gp_encode0 gp_encode1 rd32 x p ↻ sys_mmap ↻ sys_write ↻ n sys_mmap ↻ sys_write ↻ fifo_doorbell rd32 ↻ gpfifo_run rd32 ↻ wr32 ↻ gp_decode_va gp_decode_len sys_openat_append fp sys_write ↻ fx sys_mmap ↻ fp ↻ sys_write ↻ sys_close sys_exit

structs

none

consts

none

functions

15func p(s: *u8) -> i64 { var nn: i64=0; while s[nn]!=(0 as u8){nn=nn+1} sys_write(1,s,nn); return 0 }
called by 2: xmain calls 1: sys_write
16func fp(fd: i64, s: *u8) -> i64 { var nn: i64=0; while s[nn]!=(0 as u8){nn=nn+1} sys_write(fd,s,nn); return 0 }
called by 2: fxmain calls 1: sys_write
17func n(v: i64) -> i64 { let bb: *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;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{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
18func x(v: i64) -> i64 { p("0x" as *u8); let bb:*u8=sys_mmap(20); var k:i64=0; var m:i64=v; if m==0{bb[0]=48;k=1}; while m>0{ let d:i64=m&15; if d<10{bb[k]=(48+d) as u8}else{bb[k]=(87+d) as u8}; m=(m>>4); k=k+1 } var i:i64=0; let o:*u8=sys_mmap(20); while i<k{o[i]=bb[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
called by 1: main calls 3: psys_mmapsys_write
19func fx(fd: i64, v: i64) -> i64 { let bb:*u8=sys_mmap(20); var k:i64=0; var m:i64=v; if m==0{bb[0]=48;k=1}; while m>0{ let d:i64=m&15; if d<10{bb[k]=(48+d) as u8}else{bb[k]=(87+d) as u8}; m=(m>>4); k=k+1 } let o:*u8=sys_mmap(20); var i:i64=0; while i<k{o[i]=bb[k-1-i];i=i+1} fp(fd,"0x" as *u8); sys_write(fd,o,k); return 0 }
called by 1: main calls 3: sys_mmapfpsys_write
20func rd32(b: *u8, o: i64) -> i64 { return (b[o] as i64)|((b[o+1] as i64)<<8)|((b[o+2] as i64)<<16)|((b[o+3] as i64)<<24) }
21func wr32(b: *u8, o: i64, v: i64) -> i64 { b[o]=(v&0xff) as u8; b[o+1]=((v>>8)&0xff) as u8; b[o+2]=((v>>16)&0xff) as u8; b[o+3]=((v>>24)&0xff) as u8; return 0 }
24func gpfifo_run(mem: *u8, pb_off: i64, pb_dwords: i64) -> i64
called by 1: fifo_doorbell calls 2: rd32wr32
45func gp_decode_va(e0: i64, e1: i64) -> i64 { return (e0 & 0xFFFFFFFC) | ((e1 & 0xFF) << 32) }
called by 1: fifo_doorbell
46func gp_decode_len(e1: i64) -> i64 { return (e1 >> 10) & 0x1FFFFF }
called by 1: fifo_doorbell
47func gp_encode0(va: i64) -> i64 { return va & 0xFFFFFFFC }
called by 1: main
48func gp_encode1(va: i64, length: i64) -> i64 { return ((va >> 32) & 0xFF) | ((length & 0x1FFFFF) << 10) }
called by 1: main
51func emit_pb(mem: *u8, pb_off: i64, sem_addr: i64, payload: i64, corrupt: i64) -> i64
called by 1: main calls 1: wr32
61func fifo_doorbell(gmem: *u8, ch: *i64) -> i64
73func main() -> i64