interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / driver / uvm / fmt.om

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