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

278 lines · 5303 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note gpu/driver/tests/bootfs_trace.om: Host-only self-test suite for gsp/bootfs.om (OM-1).
3note Build: cat gpu/driver/gsp/bootfs.om gpu/driver/tests/bootfs_trace.om | seed/out/omc > bootfs_trace
4note Never opens a device, maps MMIO, or reads external firmware blobs. Synthetic fixtures only.
5
6text BTPASS "BOOTFS TEST PASS 9/9\n"
7
8note ---- Fixture writers into bfbuf ----
9fn btput32 o ulong v ulong to void
10for i ulong 4
11put bfbuf add o i uchar and shr v mul i 8 255
12end
13end
14
15fn btput64 o ulong v ulong to void
16for i ulong 8
17put bfbuf add o i uchar and shr v mul i 8 255
18end
19end
20
21fn btclear to void
22for i ulong BFDSZ
23put bfbuf i 0
24end
25end
26
27note Build valid 580.173.02-shaped synthetic 01_file_directory.bin:
28note 4,096 B zero guard page (0..4096)
29note 1,832 B BootFS directory (4096..5928): magic + 12 records / 23 mappings
30note 11 records x 152 B (2 maps each) + 1 record x 144 B (1 map) = 1816 B + 16 B hdr = 1832 B
31note 22 maps x 3,200,000 B + 1 map x 4,118,528 B = 74,518,528 B tiling [450560..74969088)
32note 2,264 B zero tail (5928..8192)
33fn btbuild580 to void
34btclear
35btput64 BFGUARD BFMAGIC
36btput32 add BFGUARD 8 BFDLEN
37btput32 add BFGUARD 12 BFEXPREC
38cur = add BFGUARD BFHDRSZ
39fwo = BFDEND
40for r ulong 11
41btput32 cur 152
42btput32 add cur 4 2
43btput32 add cur 8 8
44btput32 add cur 12 r
45btput64 add cur 16 fwo
46btput64 add cur 24 3200000
47btput64 add cur 32 add 16777216 mul r 65536
48fwo = add fwo 3200000
49btput64 add cur 40 fwo
50btput64 add cur 48 3200000
51btput64 add cur 56 add 67108864 mul r 65536
52fwo = add fwo 3200000
53cur = add cur 152
54end
55btput32 cur 144
56btput32 add cur 4 1
57btput32 add cur 8 8
58btput32 add cur 12 11
59btput64 add cur 16 fwo
60btput64 add cur 24 4118528
61btput64 add cur 32 71303168
62end
63
64note ---- Test 1: valid 580.173.02 directory & zero-gap tiling ----
65fn bttest1 to bool
66btbuild580
67rc = bfparse580 BFDSZ
68if ne rc 23
69ret false
70end
71if ne bfdirlen BFDLEN
72ret false
73end
74if ne bfrecn BFEXPREC
75ret false
76end
77if ne bfmapn BFEXPMAP
78ret false
79end
80if ne bfcovered BFREMLEN
81ret false
82end
83if ne bfmapoff 0 BFDEND
84ret false
85end
86if ne bfmaplen 0 3200000
87ret false
88end
89if ne bfmapoff 22 70850560
90ret false
91end
92if ne bfmaplen 22 4118528
93ret false
94end
95if ne bfmaprec 22 11
96ret false
97end
98ret true
99end
100
101note ---- Test 2: unsorted mapping order still validates exact tiling ----
102fn bttest2 to bool
103btbuild580
104note Swap mapping 0 (at 4112+16=4128) and mapping 22 (at 5784+16=5800)
105btput64 4128 70850560
106btput64 4136 4118528
107btput64 5800 BFDEND
108btput64 5808 3200000
109rc = bfparse580 BFDSZ
110if ne rc 23
111ret false
112end
113if ne bfcovered BFREMLEN
114ret false
115end
116ret true
117end
118
119note ---- Test 3: negative control - bad magic at 0x6d000 ----
120fn bttest3 to bool
121btbuild580
122btput64 BFGUARD xor BFMAGIC 1
123rc = bfparse BFDSZ BFFWIMG
124if ne rc -3
125ret false
126end
127ret true
128end
129
130note ---- Test 4: negative control - non-zero guard page (0x6c000..0x6d000) ----
131fn bttest4 to bool
132btbuild580
133put bfbuf 0 1
134rc = bfparse BFDSZ BFFWIMG
135if ne rc -2
136ret false
137end
138btbuild580
139put bfbuf 4095 255
140rc = bfparse BFDSZ BFFWIMG
141if ne rc -2
142ret false
143end
144ret true
145end
146
147note ---- Test 5: negative control - non-zero tail (0x6d728..0x6e000) ----
148fn bttest5 to bool
149btbuild580
150put bfbuf 5928 1
151rc = bfparse BFDSZ BFFWIMG
152if ne rc -6
153ret false
154end
155btbuild580
156put bfbuf 8191 1
157rc = bfparse BFDSZ BFFWIMG
158if ne rc -6
159ret false
160end
161ret true
162end
163
164note ---- Test 6: negative control - truncated buffer & truncated directory ----
165fn bttest6 to bool
166btbuild580
167rc = bfparse 8191 BFFWIMG
168if ne rc -1
169ret false
170end
171btbuild580
172btput32 add BFGUARD 8 sub BFDLEN 8
173rc = bfparse BFDSZ BFFWIMG
174if ne rc -7
175ret false
176end
177ret true
178end
179
180note ---- Test 7: negative control - overlapping mappings refused ----
181fn bttest7 to bool
182btbuild580
183note Extend mapping 0 length by 4096 B so it overlaps mapping 1
184btput64 4136 3204096
185rc = bfparse BFDSZ BFFWIMG
186if ne rc -9
187ret false
188end
189ret true
190end
191
192note ---- Test 8: negative control - leading, interior, and trailing gaps refused ----
193fn bttest8 to bool
194note Leading gap: shift mapping 0 start up by 4096 B
195btbuild580
196btput64 4128 add BFDEND 4096
197btput64 4136 sub ulong 3200000 4096
198rc = bfparse BFDSZ BFFWIMG
199if ne rc -10
200ret false
201end
202note Interior gap: shrink mapping 0 length by 4096 B
203btbuild580
204btput64 4136 sub ulong 3200000 4096
205rc = bfparse BFDSZ BFFWIMG
206if ne rc -10
207ret false
208end
209note Trailing gap: shrink last mapping (at 5800) length by 4096 B
210btbuild580
211btput64 5808 sub ulong 4118528 4096
212rc = bfparse BFDSZ BFFWIMG
213if ne rc -10
214ret false
215end
216ret true
217end
218
219note ---- Test 9: negative control - out-of-bounds and zero-length mappings refused ----
220fn bttest9 to bool
221note Below 0x6e000
222btbuild580
223btput64 4128 sub BFDEND 4096
224rc = bfparse BFDSZ BFFWIMG
225if ne rc -8
226ret false
227end
228note Zero length
229btbuild580
230btput64 4136 0
231rc = bfparse BFDSZ BFFWIMG
232if ne rc -8
233ret false
234end
235note Past end of .fwimage
236btbuild580
237btput64 5808 add ulong 4118528 4096
238rc = bfparse BFDSZ BFFWIMG
239if ne rc -8
240ret false
241end
242ret true
243end
244
245fn main to int
246if not bttest1
247ret 1
248end
249if not bttest2
250ret 2
251end
252if not bttest3
253ret 3
254end
255if not bttest4
256ret 4
257end
258if not bttest5
259ret 5
260end
261if not bttest6
262ret 6
263end
264if not bttest7
265ret 7
266end
267if not bttest8
268ret 8
269end
270if not bttest9
271ret 9
272end
273w = write 1 BTPASS 0 len BTPASS
274if ne w long len BTPASS
275ret 20
276end
277ret 0
278end