aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / gpu / contract / gb10_chan.devc
| 1 | # gb10_chan.devc -- one GB10 compute channel (GPFIFO ring, USERD, instance block, doorbell) |
| 2 | # as a device contract (ADR 0021 devc 1, class gpu-chan; L332 rung 1). |
| 3 | # |
| 4 | # This file is the channel driver. crates/aienos-devc (branch feat/devc-gpu) compiles it into |
| 5 | # gen/gch_contract.c the same API as ../gpu_chan.h (ck_gpu_chan_*), swapped in with |
| 6 | # `make CK_GPU_CHAN_IMPL=contract test-gpu-sim` |
| 7 | # gen/gb10_chan.md the documentation page |
| 8 | # The hand-written ../gpu_chan.c (L193) stays as the reference twin; both must pass |
| 9 | # test_gpu_sim (225 checks) and produce the same register and memory trace. |
| 10 | # |
| 11 | # Grammar (class gpu-chan): one statement per line, "#" to end of line is a comment, |
| 12 | # strings in double quotes, numbers decimal or 0x hex. Steps inside create/submit/ |
| 13 | # teardown come from a closed list; the checker refuses unsafe orders (see gen/gb10_chan.md). |
| 14 | |
| 15 | devc 1 |
| 16 | device gb10-gpu-channel |
| 17 | prefix ck_gpu |
| 18 | class gpu-chan |
| 19 | transport pci-bar |
| 20 | ring-kind gpfifo |
| 21 | |
| 22 | # ---- evidence: the driver-source lines this contract is written from ---- |
| 23 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/sdk/nvidia/inc/class/clc96f.h:95" "#define NVC96F_GP_ENTRY0_GET 31:2" |
| 24 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/sdk/nvidia/inc/class/clc96f.h:98" "#define NVC96F_GP_ENTRY1_GET_HI 7:0" |
| 25 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/sdk/nvidia/inc/class/clc96f.h:102" "#define NVC96F_GP_ENTRY1_LENGTH 30:10" |
| 26 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/sdk/nvidia/inc/class/clc96f.h:31" "NvU32 GPPut; /* GP FIFO put offset 008c-008f*/" |
| 27 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/inc/swref/published/blackwell/gb100/dev_vm.h:620" "#define NV_VIRTUAL_FUNCTION_DOORBELL 0x30090 /* -W-4R */" |
| 28 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/inc/swref/published/blackwell/gb100/dev_vm.h:622" "#define NV_VIRTUAL_FUNCTION_DOORBELL_VECTOR 11:0 /* -WXUF */" |
| 29 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/inc/swref/published/blackwell/gb100/dev_vm.h:624" "#define NV_VIRTUAL_FUNCTION_DOORBELL_RUNLIST_ID 22:16 /* -WXUF */" |
| 30 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/inc/swref/published/blackwell/gb10b/dev_ram.h:27" "#define NV_RAMRL_ENTRY_CHAN_USERD_PTR_LO (31+0*32):(8+0*32) /* RWXUF */" |
| 31 | manual "NVIDIA open-gpu-kernel-modules 580.173.02" "src/common/inc/swref/published/blackwell/gb10b/dev_ram.h:28" "#define NV_RAMRL_ENTRY_CHAN_USERD_PTR_HI_HW (19+1*32):(0+1*32) /* RWXUF */" |
| 32 | # No chip has run this contract. GB10 silicon behaviour is UNVERIFIED (L193 UNKNOWN list 1-9). |
| 33 | proven gpu-sim aienos-host 2026-10-21 test_gpu_sim pending |
| 34 | |
| 35 | # ---- constants (C: CK_GPU_<NAME> in the generated file) ---- |
| 36 | const CHID_MAX 0xFFF |
| 37 | const RUNLIST_INVALID 0x7F |
| 38 | const ENTRIES_MIN 2 |
| 39 | const ENTRIES_MAX 65536 |
| 40 | const GP_LEN_MAX 0x1FFFFF |
| 41 | const GP_VA_BITS 40 |
| 42 | const USERD_BYTES 512 |
| 43 | const USERD_GPPUT 0x8C |
| 44 | const INST_BYTES 4096 |
| 45 | const RAMIN_PDB_WORD 128 |
| 46 | const TARGET_SYS_COH 2 |
| 47 | |
| 48 | # ---- register window and registers: window NAME bar N base B size S ---- |
| 49 | window vf bar 0 base 0xB80000 size 0x40000 |
| 50 | reg vf DOORBELL 0x30090 4 wo |
| 51 | |
| 52 | # ---- packed formats: format NAME BITS then fields NAME HI:LO [place] ---- |
| 53 | # `place` = the value already sits at its bit position (an address); otherwise it is shifted in. |
| 54 | format TOKEN 32 RUNLIST_ID 22:16 VECTOR 11:0 |
| 55 | format GP_ENTRY 64 GET 39:2 place LEVEL 41:41 LENGTH 62:42 |
| 56 | format RL_USERD 64 PTR_LO 31:8 place PTR_HI 51:32 place |
| 57 | format RAMIN_PDB 64 TARGET 1:0 BIG_PAGE_64K 11:11 ADDR 63:12 place |
| 58 | |
| 59 | # ---- buffers the channel owns: buffer NAME size (CONST | entries xN) cache flags ---- |
| 60 | # The CPU writes the ring and USERD while the GPU reads them: uncached (spark-hardware-manual 4.2). |
| 61 | buffer GPFIFO entries x8 uncached gpu-ro |
| 62 | buffer USERD USERD_BYTES uncached host-polled |
| 63 | buffer INST INST_BYTES uncached none |
| 64 | |
| 65 | # ---- the three operations ---- |
| 66 | create |
| 67 | refuse chid > CHID_MAX else EINVAL |
| 68 | refuse runlist_id >= RUNLIST_INVALID else EINVAL |
| 69 | refuse-entries pow2 ENTRIES_MIN ENTRIES_MAX else EINVAL |
| 70 | alloc GPFIFO USERD INST else ENOMEM |
| 71 | zero GPFIFO USERD INST |
| 72 | store-pdb INST RAMIN_PDB_WORD RAMIN_PDB TARGET=TARGET_SYS_COH BIG_PAGE_64K=1 |
| 73 | token TOKEN RUNLIST_ID=runlist_id VECTOR=chid |
| 74 | runlist-userd RL_USERD USERD else ENOMEM |
| 75 | fence |
| 76 | bind else EBIND |
| 77 | end |
| 78 | |
| 79 | submit |
| 80 | require-open else ESTATE |
| 81 | require-buffer else EINVAL |
| 82 | require-span GP_LEN_MAX else EINVAL |
| 83 | require-va GP_VA_BITS else EINVAL |
| 84 | require-room else EFULL |
| 85 | ring-write GP_ENTRY GET=va LENGTH=nwords LEVEL=1 # LEVEL 1 = SUBROUTINE, as physics sets it (chip-proven there; L216) |
| 86 | fence |
| 87 | publish USERD USERD_GPPUT |
| 88 | fence |
| 89 | doorbell DOORBELL TOKEN |
| 90 | end |
| 91 | |
| 92 | teardown |
| 93 | require-open else ESTATE |
| 94 | disable |
| 95 | poll-idle |
| 96 | release INST USERD GPFIFO |
| 97 | end |