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 / evidence / x86efi / ident-bounds-20261104 / id-fbcf0882.om

226 lines · 3397 bytes Raw Blame History
1target x86efi
2note efi 14 identity: the CPUID brand string, SystemTable FirmwareVendor (UCS-2 to ASCII, ? outside
3note 32..126), SMBIOS type 1 Manufacturer/Product/Version (never Serial or UUID), then one hex line
4note per refusal or edge result. FirmwareRevision goes after the ==B block (it depends on the OVMF build).
5global ms uchar 256
6global ml ulong 1
7global cb uchar 16
8global br uchar 48
9global vb uchar 256
10global sb uchar 8192
11global pb uchar 8
12
13fn pc c ulong to void
14put ms get ml 0 uchar c
15put ml 0 add get ml 0 1
16end
17
18fn nl to void
19pc 10
20r = efi 13 0 ms 0 get ml 0
21put ml 0 0
22end
23
24fn ps c ulong to void
25if and ge c 32 le c 126
26pc c
27else
28pc 63
29end
30end
31
32fn hx v ulong n ulong to void
33i = ulong 0
34while lt i n
35d = and shr v mul sub sub n 1 i 4 15
36if lt d 10
37pc add 48 d
38else
39pc add 87 d
40end
41i = add i 1
42end
43end
44
45fn rd4 k ulong to ulong
46v = ulong 0
47for i ulong 4
48v = or v shl ulong get cb add k i mul i 8
49end
50ret v
51end
52
53note CPUID leaf l into cb; returns efi 14's result
54fn cpu l ulong to ulong
55ret efi 14 shl l 16 cb 0 16
56end
57
58fn brand to void
59r = cpu 2147483648
60if or ne r 16 lt rd4 0 2147483652
61pc 45
62ret
63end
64for j ulong 3
65r = cpu add 2147483650 j
66for k ulong 16
67put br add mul j 16 k get cb k
68end
69end
70s = ulong 0
71while and lt s 48 or eq ulong get br s 32 eq ulong get br s 0
72s = add s 1
73end
74e = ulong 48
75while and gt e s or eq ulong get br sub e 1 32 eq ulong get br sub e 1 0
76e = sub e 1
77end
78if eq e s
79pc 45
80end
81i = s
82while lt i e
83ps ulong get br i
84i = add i 1
85end
86end
87
88fn vendor to void
89r = efi 14 1 vb 0 256
90if or ge r 9223372036854775808 eq r 0
91pc 45
92ret
93end
94for k ulong div r 2
95ps or ulong get vb mul k 2 shl ulong get vb add mul k 2 1 8
96end
97end
98
99note SMBIOS string number n of the structure at p (formatted length at p+1), or - when absent
100fn sstr p ulong n ulong t ulong to void
101if eq n 0
102pc 45
103ret
104end
105q = add p ulong get sb add p 1
106c = ulong 1
107while and lt q t lt c n
108if eq ulong get sb q 0
109c = add c 1
110end
111q = add q 1
112end
113if or ge q t eq ulong get sb q 0
114pc 45
115ret
116end
117while and lt q t ne ulong get sb q 0
118ps ulong get sb q
119q = add q 1
120end
121end
122
123note true when sb[q] and sb[q+1] are both 0 (the end of a structure's string set)
124fn dnul q ulong to bool
125ret and eq ulong get sb q 0 eq ulong get sb add q 1 0
126end
127
128fn smbios to void
129t = efi 14 3 sb 0 8192
130if or ge t 9223372036854775808 lt t 4
131pc 45
132ret
133end
134p = ulong 0
135while lt add p 4 t
136ty = ulong get sb p
137ln = ulong get sb add p 1
138if eq ty 1
139if lt ln 8
140pc 45
141ret
142end
143sstr p ulong get sb add p 4 t
144pc 47
145sstr p ulong get sb add p 5 t
146pc 47
147sstr p ulong get sb add p 6 t
148ret
149end
150if or eq ty 127 lt ln 4
151pc 45
152ret
153end
154q = add p ln
155while and lt add q 1 t not dnul q
156q = add q 1
157end
158p = add q 2
159end
160pc 45
161end
162
163fn line v ulong to void
164hx v 16
165nl
166end
167
168fn main to ulong
169pc 61
170pc 61
171pc 66
172nl
173pc 98
174pc 114
175pc 61
176brand
177nl
178pc 102
179pc 119
180pc 61
181vendor
182nl
183pc 115
184pc 109
185pc 61
186smbios
187nl
188note sub 3 at position 4: 8 bytes equal to the table's bytes 4..11
189r = efi 14 or ulong 3 shl ulong 4 16 pb 0 8
190ok = eq r 8
191for k ulong 8
192if ne get pb k get sb add k 4
193ok = false
194end
195end
196if ok
197pc 112
198pc 111
199pc 115
200pc 32
201pc 111
202pc 107
203else
204pc 63
205end
206nl
207line efi 14 3 pb 0 0
208line efi 14 or ulong 3 shl ulong 1048575 16 pb 0 8
209line efi 14 0 cb 0 16
210line efi 14 0 cb 0 15
211line efi 14 shl ulong 1 48 cb 0 16
212line efi 14 4 cb 0 16
213line efi 14 65537 cb 0 16
214line efi 14 256 cb 0 16
215pc 61
216pc 61
217pc 69
218nl
219pc 61
220pc 61
221pc 82
222pc 32
223hx efi 14 2 cb 0 0 8
224nl
225ret 0
226end