omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / uvm / fmt.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note uvm/fmt.om: Blackwell VER3 page-table words and the page pool. |
| 3 | note Library unit, no main. Prefix uv / UV. Concatenate uvm/fmt.om uvm/pt.om uvm/fault.om |
| 4 | note then tests/uvm_trace.om. Do not concatenate with chan/: that port owns mm / MM. |
| 5 | note |
| 6 | note Field positions are the open-gpu-kernel-modules 580.173.02 VER3 layout |
| 7 | note (dev_mmu.h NV_MMU_VER3_*, dev_fault.h NV_PFAULT_FAULT_TYPE_*, clc369.h |
| 8 | note NVC369_BUF_ENTRY_*). aienux feat/gb10-gpu-mmu-sim was read as a behavior |
| 9 | note reference only; this is a new Omega unit, not a transcription. |
| 10 | note |
| 11 | note Levels (lo, hi), index 5 is PT_BIG and index 6 is PT_SMALL, both off PD0: |
| 12 | note 0 (56,56) 1 (47,55) 2 (38,46) 3 (29,37) 4 PD0 (21,28) 5 (16,20) 6 (12,20) |
| 13 | note PDE address 51:12, aperture 2:1, PCF 5:3. Dual PDE big address 51:8 in word 0, |
| 14 | note small address 51:12 in word 1. PTE valid 0:0, aperture 2:1, PCF 7:3, address 51:12. |
| 15 | note Pool is 16 pages of 4096 bytes. A page physical address is UVPOOL plus its offset. |
| 16 | note WolframLanguageEvaluator: 2^31 -> 2147483648, 16*4096 -> 65536, |
| 17 | note BitAnd[2^52-1, BitNot[2^12-1]] -> 4503599627366400, |
| 18 | note BitAnd[2^52-1, BitNot[2^8-1]] -> 4503599627370240, |
| 19 | note 2^32 -> 4294967296, 2^28 -> 268435456, 2^57 -> 144115188075855872, |
| 20 | note 2^52 -> 4503599627370496, 2^28/2^12 -> 65536. |
| 21 | const UVPOOL ulong 2147483648 |
| 22 | const UVBYTES ulong 65536 |
| 23 | const UVBASE ulong 4294967296 |
| 24 | const UVWIN ulong 268435456 |
| 25 | const UVVA57 ulong 144115188075855872 |
| 26 | const UVPA52 ulong 4503599627370496 |
| 27 | const UV4K ulong 4096 |
| 28 | const UV64K ulong 65536 |
| 29 | const UV2M ulong 2097152 |
| 30 | const UVPDMSK ulong 4503599627366400 |
| 31 | const UVBIGMSK ulong 4503599627370240 |
| 32 | const UVPDEPCF ulong 2 |
| 33 | const UVAPSYS ulong 2 |
| 34 | const UVOK ulong 0 |
| 35 | const UVEINVAL ulong 1 |
| 36 | const UVEALIGN ulong 2 |
| 37 | const UVEBUSY ulong 3 |
| 38 | const UVENOM ulong 4 |
| 39 | const UVENOENT ulong 5 |
| 40 | const UVERANGE ulong 6 |
| 41 | const UVEPERM ulong 7 |
| 42 | const UVIGN ulong 8 |
| 43 | const UVREPLAY ulong 9 |
| 44 | const UVCANCEL ulong 10 |
| 45 | const UVFATAL ulong 11 |
| 46 | const UVCONT ulong 20 |
| 47 | const UVFREE ulong 21 |
| 48 | const UVMAPPED ulong 22 |
| 49 | const UVCONF ulong 23 |
| 50 | const UVMISS ulong 24 |
| 51 | global uvmem uchar 65536 |
| 52 | global uvused uchar 16 |
| 53 | global uvout ulong 1 |
| 54 | global uvtbl ulong 1 |
| 55 | global uvleaf ulong 1 |
| 56 | global uvmiss ulong 1 |
| 57 | global uvw0 ulong 1 |
| 58 | global uvw1 ulong 1 |
| 59 | global uvkey ulong 8 |
| 60 | global uvrva ulong 32 |
| 61 | global uvrsz ulong 32 |
| 62 | global uvrpg ulong 32 |
| 63 | global uvrpa ulong 32 |
| 64 | global uvrro ulong 32 |
| 65 | global uvrn ulong 1 |
| 66 | global uvdpa ulong 1 |
| 67 | global uvdap ulong 1 |
| 68 | global uvdpcf ulong 1 |
| 69 | global uvdv ulong 1 |
| 70 | fn uvld64 off ulong to ulong |
| 71 | acc = ulong 0 |
| 72 | for i ulong 8 |
| 73 | acc = or acc shl ulong get uvmem add off i mul i 8 |
| 74 | end |
| 75 | ret acc |
| 76 | end |
| 77 | fn uvst64 off ulong v ulong to void |
| 78 | for i ulong 8 |
| 79 | put uvmem add off i uchar and shr v mul i 8 255 |
| 80 | end |
| 81 | end |
| 82 | fn uvlvlo lv ulong to ulong |
| 83 | if eq lv 0 |
| 84 | ret 56 |
| 85 | end |
| 86 | if eq lv 1 |
| 87 | ret 47 |
| 88 | end |
| 89 | if eq lv 2 |
| 90 | ret 38 |
| 91 | end |
| 92 | if eq lv 3 |
| 93 | ret 29 |
| 94 | end |
| 95 | if eq lv 4 |
| 96 | ret 21 |
| 97 | end |
| 98 | if eq lv 5 |
| 99 | ret 16 |
| 100 | end |
| 101 | ret 12 |
| 102 | end |
| 103 | fn uvlvhi lv ulong to ulong |
| 104 | if eq lv 0 |
| 105 | ret 56 |
| 106 | end |
| 107 | if eq lv 1 |
| 108 | ret 55 |
| 109 | end |
| 110 | if eq lv 2 |
| 111 | ret 46 |
| 112 | end |
| 113 | if eq lv 3 |
| 114 | ret 37 |
| 115 | end |
| 116 | if eq lv 4 |
| 117 | ret 28 |
| 118 | end |
| 119 | ret 20 |
| 120 | end |
| 121 | fn uvlvidx lv ulong va ulong to ulong |
| 122 | lo = uvlvlo lv |
| 123 | hi = uvlvhi lv |
| 124 | bits = add sub hi lo 1 |
| 125 | ret and shr va lo sub shl ulong 1 bits 1 |
| 126 | end |
| 127 | fn uvpde pa ulong ap ulong to ulong |
| 128 | ret or or and pa UVPDMSK shl UVPDEPCF 3 shl and ap 3 1 |
| 129 | end |
| 130 | fn uvpte pa ulong ap ulong pcf ulong to ulong |
| 131 | v = or ulong 1 shl and ap 3 1 |
| 132 | v = or v shl and pcf 31 3 |
| 133 | ret or v and pa UVPDMSK |
| 134 | end |
| 135 | fn uvbadpa pa ulong to bool |
| 136 | if lt pa UVPOOL |
| 137 | ret true |
| 138 | end |
| 139 | if ge pa add UVPOOL UVBYTES |
| 140 | ret true |
| 141 | end |
| 142 | if ne and pa 4095 0 |
| 143 | ret true |
| 144 | end |
| 145 | ret false |
| 146 | end |
| 147 | fn uvptnew to ulong |
| 148 | for i ulong 16 |
| 149 | if eq get uvused i 0 |
| 150 | put uvused i 1 |
| 151 | base = mul i 4096 |
| 152 | for j ulong 512 |
| 153 | uvst64 add base mul j 8 0 |
| 154 | end |
| 155 | put uvout 0 base |
| 156 | ret UVOK |
| 157 | end |
| 158 | end |
| 159 | ret UVENOM |
| 160 | end |
| 161 | fn uvnfree to ulong |
| 162 | n = ulong 0 |
| 163 | for i ulong 16 |
| 164 | if eq get uvused i 0 |
| 165 | n = add n 1 |
| 166 | end |
| 167 | end |
| 168 | ret n |
| 169 | end |
| 170 | fn uvsum to ulong |
| 171 | s = ulong 0 |
| 172 | for i ulong 65536 |
| 173 | s = add s ulong get uvmem i |
| 174 | end |
| 175 | ret s |
| 176 | end |