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 / tests / uvm_trace.om

307 lines · 5252 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note tests/uvm_trace.om: host trace for the uvm page-table builder.
3note Build: cat uvm/fmt.om uvm/pt.om uvm/fault.om tests/uvm_trace.om | omc > prog.
4note Addresses below are WolframLanguageEvaluator results, not hand sums:
5note 2^32 -> 4294967296, 2^32+2^21 -> 4297064448, 2^32+2^22 -> 4299161600,
6note 2^32+2^23 -> 4303355904, 2^31+2^20 -> 2148532224, 2^31+2^20+2^16 -> 2148597760,
7note 2^31+2^21 -> 2149580800. The checker recomputes every expected word.
8const VA4 ulong 4294967296
9const VA4B ulong 4297064448
10const VA64 ulong 4299161600
11const VA2 ulong 4303355904
12const PA4 ulong 2148532224
13const PA64 ulong 2148597760
14const PA2 ulong 2149580800
15const PG4 ulong 4096
16const PG64 ulong 65536
17const PG2 ulong 2097152
18text utl "INIT|ALLOC|BIND|MAP|UNMAP|SUM|DUMP|ENDDUMP|WALK|ENC|PKT|DEC|SERVE|PROT|FIT|DONE|rc=|va=|sz=|pg=|pa=|ap=|pcf=|v=|ts=|typ=|rep=|acc=|en=|val=|cli=|act=|ro=|"
19global utb uchar 256
20global utp ulong 1
21global utdig uchar 24
22fn utch c uchar to void
23p = get utp 0
24put utb p c
25put utp 0 add p 1
26end
27fn utflush to void
28utch 10
29n = get utp 0
30r = write 1 utb 0 n
31if ne r long n
32exit 1
33end
34put utp 0 0
35end
36fn utfrag k ulong to void
37w = ulong 0
38for i ulong len utl
39c = get utl i
40if eq c 124
41w = add w 1
42else
43if eq w k
44utch c
45end
46end
47end
48end
49fn utdec v ulong to void
50n = ulong 0
51x = v
52while true bound 24
53put utdig n uchar add rem x 10 48
54n = add n 1
55x = div x 10
56if eq x 0
57break
58end
59end
60for i ulong n
61utch get utdig sub sub n 1 i
62end
63end
64fn uthex v ulong w ulong to void
65n = ulong 0
66x = v
67while true bound 24
68d = uchar rem x 16
69if lt d 10
70put utdig n add d 48
71else
72put utdig n add d 87
73end
74n = add n 1
75x = div x 16
76if eq x 0
77break
78end
79end
80while lt n w bound 24
81put utdig n 48
82n = add n 1
83end
84for i ulong n
85utch get utdig sub sub n 1 i
86end
87end
88fn utkv k ulong v ulong to void
89utch 32
90utfrag k
91utdec v
92end
93fn utend rc ulong to void
94utkv 16 rc
95utflush
96end
97fn utsum to void
98utfrag 5
99utch 32
100utdec uvsum
101utflush
102end
103fn utdump to void
104utsum
105utfrag 6
106utflush
107for i ulong 8192
108v = uvld64 mul i 8
109if ne v 0
110utch 87
111utch 32
112utdec i
113utch 32
114uthex v 16
115utflush
116end
117end
118utfrag 7
119utflush
120end
121fn utwalk va ulong pg ulong to void
122r = uvread va pg
123utfrag 8
124utkv 17 va
125utkv 19 pg
126utkv 16 r
127utkv 20 get uvdpa 0
128utkv 21 get uvdap 0
129utkv 22 get uvdpcf 0
130utkv 23 get uvdv 0
131utflush
132end
133fn utpkt to void
134utfrag 10
135for i ulong 32
136uthex ulong get uvpkt i 2
137end
138utflush
139end
140fn utdecf to void
141utfrag 11
142utkv 17 get uvfva 0
143utkv 24 get uvfts 0
144utkv 25 get uvftyp 0
145utkv 26 get uvfrep 0
146utkv 27 get uvfacc 0
147utkv 28 get uvfen 0
148utkv 29 get uvfval 0
149utkv 30 get uvfcli 0
150utflush
151end
152fn utfault va ulong ts ulong typ ulong rep ulong acc ulong cli ulong to void
153utfrag 9
154utkv 17 va
155utkv 24 ts
156utkv 25 typ
157utkv 26 rep
158utkv 27 acc
159utkv 28 get uvfen 0
160utkv 29 get uvfval 0
161utkv 30 cli
162utflush
163uvpktenc va ts typ rep acc cli
164utpkt
165uvpktdec
166utdecf
167r = uvserve
168utfrag 12
169utkv 31 r
170utkv 16 r
171utflush
172utdump
173end
174fn scinit to void
175r = uvinit
176utfrag 0
177utend r
178utdump
179end
180fn scalloc va ulong sz ulong pg ulong to void
181r = uvallocat va sz pg
182utfrag 1
183utkv 17 va
184utkv 18 sz
185utkv 19 pg
186utend r
187end
188fn scbind va ulong pa ulong to void
189r = uvbind va pa
190utfrag 2
191utkv 17 va
192utkv 20 pa
193utend r
194end
195fn scmap va ulong pa ulong sz ulong pg ulong ap ulong to void
196r = uvmap va pa sz pg ap 0
197utfrag 3
198utkv 17 va
199utkv 20 pa
200utkv 18 sz
201utkv 19 pg
202utkv 21 ap
203utkv 22 0
204utend r
205utdump
206end
207fn scmapc va ulong pa ulong sz ulong pg ulong pcf ulong to void
208r = uvmap va pa sz pg 2 pcf
209utfrag 3
210utkv 17 va
211utkv 20 pa
212utkv 18 sz
213utkv 19 pg
214utkv 21 2
215utkv 22 pcf
216utend r
217utdump
218end
219fn scunmap va ulong sz ulong pg ulong to void
220r = uvunmap va sz pg
221utfrag 4
222utkv 17 va
223utkv 18 sz
224utkv 19 pg
225utend r
226utdump
227end
228fn scfit sz ulong pg ulong to void
229r = uvalloc sz pg
230utfrag 14
231utkv 18 sz
232utkv 19 pg
233utkv 17 get uvout 0
234utend r
235end
236fn scprot va ulong ro ulong to void
237r = uvprot va ro
238utfrag 13
239utkv 17 va
240utkv 32 ro
241utend r
242end
243fn main to int
244scinit
245scalloc VA4 8192 PG4
246scbind VA4 PA4
247scmap VA4 PA4 8192 PG4 2
248utwalk VA4 PG4
249utwalk add VA4 PG4 PG4
250scmap VA4 PA4 PG4 PG4 2
251scmap add VA4 1 PA4 PG4 PG4 2
252scmap VA4B UVPOOL PG4 PG4 2
253scmap VA4 PA4 0 PG4 2
254scmap VA4 PA4 36864 PG4 2
255scalloc VA4B PG4 PG4
256scbind VA4B add PA4 8192
257scmap VA4B add PA4 8192 PG4 PG4 2
258utwalk VA4B PG4
259scalloc VA64 PG64 PG64
260scbind VA64 PA64
261scmap VA64 PA64 PG64 PG64 2
262utwalk VA64 PG64
263scalloc VA2 PG2 PG2
264scbind VA2 PA2
265scmap VA2 PA2 PG2 PG2 2
266utwalk VA2 PG2
267scmap add VA4 536870912 add PA2 PG2 PG4 PG4 2
268utwalk add VA4 536870912 PG4
269scunmap VA4 8192 PG4
270utwalk VA4 PG4
271scmap VA4 PA64 PG64 PG64 2
272scfit PG4 PG4
273put uvfen 0 1
274put uvfval 0 1
275utfault VA4 7 1 1 0 0
276utwalk VA4 PG4
277utfault add VA4 PG4 8 1 1 1 0
278utwalk add VA4 PG4 PG4
279utfault VA4 9 1 1 0 0
280put uvfval 0 0
281utfault VA4 10 1 1 0 0
282put uvfen 0 0
283put uvfval 0 1
284utfault VA4 11 1 1 0 0
285put uvfen 0 1
286utfault VA4 12 1 0 0 0
287utfault VA4 13 3 1 0 0
288utfault add VA2 PG2 14 1 1 0 0
289scalloc add VA2 PG2 PG4 PG4
290utfault add VA2 PG2 15 1 1 0 0
291scprot VA64 1
292scunmap VA64 PG64 PG64
293utfault VA64 16 1 1 1 0
294utwalk VA64 PG64
295utfault VA64 17 1 1 0 0
296utwalk VA64 PG64
297scunmap VA4 8192 PG4
298scunmap VA4 PG4 PG4
299scunmap add VA4 1 PG4 PG4
300scalloc VA4 PG4 PG4
301scalloc 4096 PG4 PG4
302scbind VA4 1
303scprot 1 1
304utfrag 15
305utend 0
306ret 0
307end