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 / mmio_trace.om

325 lines · 4883 bytes Raw Blame History
1note tests/mmio_trace.om: every register access gspboot and gspnotify make against the simulated SEC2 + GSP
2note (gsp/sim.om, mode 0) in a fixed list of scenarios, one per line. Port of aien-dev/aienux PR #441
3note native/kernel/tests/gsp_boot_trace.c: same scenarios, same printf bytes (%d, %u, %#x with 0 as `0`,
4note %06x, %08x), so tests/mmio_diff.sh can cmp the two outputs. Host only; never touches a device.
5note Build: cat gsp/mmio.om gsp/sim.om tests/mmio_trace.om | omc
6const ARGSPA ulong 4886716416
7const APPVER ulong 390049
8text tnames "happy busy3 busy-forever sec2-never mask-never hwcfg2-zero2 args-never lockdown-never fmc-error riscv-dead emem-stuck bad-header odd-7 full-1024 too-long budget0 "
9text th1 "== "
10text th2 " rc="
11text th3 " stage="
12text th4 " polls="
13text th5 " dwords="
14text th6 " ememc="
15text th7 " sec2="
16text th8 " hwcfg2="
17text th9 " gsp="
18text th10 " cpuctl="
19text th11 " nlog="
20text th12 " violations="
21text th13 " phase="
22global tob uchar 262144
23global tpos ulong 1
24global tdig uchar 24
25fn tflush to void
26n = get tpos 0
27if gt n 0
28r = write 1 tob 0 n
29if ne r long n
30exit 1
31end
32end
33put tpos 0 0
34end
35fn tch c uchar to void
36p = get tpos 0
37put tob p c
38put tpos 0 add p 1
39if ge add p 1 262000
40tflush
41end
42end
43fn ttext k ulong to void
44if eq k 1
45for i ulong len th1
46tch get th1 i
47end
48end
49if eq k 2
50for i ulong len th2
51tch get th2 i
52end
53end
54if eq k 3
55for i ulong len th3
56tch get th3 i
57end
58end
59if eq k 4
60for i ulong len th4
61tch get th4 i
62end
63end
64if eq k 5
65for i ulong len th5
66tch get th5 i
67end
68end
69if eq k 6
70for i ulong len th6
71tch get th6 i
72end
73end
74if eq k 7
75for i ulong len th7
76tch get th7 i
77end
78end
79if eq k 8
80for i ulong len th8
81tch get th8 i
82end
83end
84if eq k 9
85for i ulong len th9
86tch get th9 i
87end
88end
89if eq k 10
90for i ulong len th10
91tch get th10 i
92end
93end
94if eq k 11
95for i ulong len th11
96tch get th11 i
97end
98end
99if eq k 12
100for i ulong len th12
101tch get th12 i
102end
103end
104if eq k 13
105for i ulong len th13
106tch get th13 i
107end
108end
109end
110note the k-th space-separated name of tnames
111fn tname k ulong to void
112w = ulong 0
113for i ulong len tnames
114c = get tnames i
115if eq c 32
116w = add w 1
117else
118if eq w k
119tch c
120end
121end
122end
123end
124note %u
125fn tdec v ulong to void
126n = ulong 0
127x = v
128while true bound 24
129put tdig n uchar add rem x 10 48
130n = add n 1
131x = div x 10
132if eq x 0
133break
134end
135end
136for i ulong n
137tch get tdig sub sub n 1 i
138end
139end
140note %d
141fn tsdec v long to void
142if lt v 0
143tch 45
144tdec ulong neg v
145ret
146end
147tdec ulong v
148end
149note lowercase hex, at least w digits, zero-padded (%0Nx)
150fn thex v ulong w ulong to void
151n = ulong 0
152x = v
153while true bound 24
154d = uchar rem x 16
155if lt d 10
156put tdig n add d 48
157else
158put tdig n add d 87
159end
160n = add n 1
161x = div x 16
162if eq x 0
163break
164end
165end
166while lt n w bound 24
167put tdig n 48
168n = add n 1
169end
170for i ulong n
171tch get tdig sub sub n 1 i
172end
173end
174note %#x: 0 alone, otherwise 0x and the digits
175fn talt v ulong to void
176if eq v 0
177tch 48
178ret
179end
180tch 48
181tch 120
182thex v 1
183end
184fn tbase to void
185put scfg 0 0
186put scfg 1 3
187put scfg 2 4
188put scfg 3 2
189put scfg 4 5
190put scfg 5 0
191put scfg 6 0
192put scfg 7 0
193put scfg 8 ARGSPA
194put scfg 9 0
195end
196fn tput32 o ulong v ulong to void
197put gpkt o uchar and v 255
198put gpkt add o 1 uchar and shr v 8 255
199put gpkt add o 2 uchar and shr v 16 255
200put gpkt add o 3 uchar and shr v 24 255
201end
202fn thead k ulong rc long to void
203ttext 1
204tname k
205ttext 2
206tsdec rc
207ttext 3
208tsdec get gstage 0
209ttext 4
210tdec get gout 0
211tch 44
212tdec get gout 1
213tch 44
214tdec get gout 2
215tch 44
216tdec get gout 3
217ttext 5
218tdec get gout 4
219ttext 6
220talt get gout 5
221ttext 7
222talt get gout 6
223tch 44
224talt get gout 7
225ttext 8
226talt get gout 8
227ttext 9
228talt get gout 9
229tch 44
230talt get gout 10
231ttext 10
232talt get gout 11
233ttext 11
234tdec get ss SNLOG
235ttext 12
236tdec get ss SVIOL
237ttext 13
238tdec get ss SPHASE
239tch 10
240end
241note one scenario: the caller has set scfg; k names it
242fn tscen k ulong ln ulong budget ulong hdrok bool to void
243for i ulong 1024
244put gpkt i uchar and add mul i 13 5 255
245end
246if hdrok
247tput32 0 1
248tput32 4 336649854
249tput32 8 56360961
250end
251put gin 0 ln
252put gin 1 ARGSPA
253put gin 2 APPVER
254for j ulong 4
255put gin add 3 j budget
256end
257put gspmode 0 0
258siminit
259rc = gspboot
260if eq rc 0
261gspnotify
262end
263thead k rc
264n = get ss SNLOG
265for e ulong n
266if lt e LOGMAX
267if eq get slogw e 1
268tch 87
269else
270tch 82
271end
272tch 32
273thex get slogo e 6
274tch 32
275thex get slogv e 8
276tch 10
277end
278end
279end
280fn main to int
281tbase
282tscen 0 868 100 true
283tbase
284put scfg 0 3
285tscen 1 868 100 true
286tbase
287put scfg 0 NOEND
288tscen 2 868 5 true
289tbase
290put scfg 1 NOEND
291tscen 3 868 5 true
292tbase
293put scfg 2 NOEND
294tscen 4 868 5 true
295tbase
296put scfg 9 2
297tscen 5 868 100 true
298tbase
299put scfg 3 NOEND
300tscen 6 868 6 true
301tbase
302put scfg 4 NOEND
303tscen 7 868 6 true
304tbase
305put scfg 5 35
306tscen 8 868 100 true
307tbase
308put scfg 6 1
309tscen 9 868 100 true
310tbase
311put scfg 7 1
312tscen 10 868 100 true
313tbase
314tscen 11 868 3 false
315tbase
316tscen 12 7 3 true
317tbase
318tscen 13 1024 3 true
319tbase
320tscen 14 1025 3 true
321tbase
322tscen 15 868 0 true
323tflush
324ret 0
325end