Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/x86efi/ident/id.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / x86efi / ident / id.om` 272 lines ยท 4194 bytes Raw Blame History 1 target x86efi 2 note efi 14 identity: the CPUID brand string, SystemTable FirmwareVendor (UCS-2 to ASCII, ? outside 3 note 32..126), SMBIOS type 1 Manufacturer/Product/Version (never Serial or UUID), then one hex line 4 note per refusal or edge result. FirmwareRevision goes after the ==B block (it depends on the OVMF build). 5 global ms uchar 256 6 global ml ulong 1 7 global cb uchar 16 8 global br uchar 48 9 global vb uchar 256 10 global sb uchar 8192 11 global pb uchar 8 12 13 fn pc c ulong to void 14 put ms get ml 0 uchar c 15 put ml 0 add get ml 0 1 16 end 17 18 fn nl to void 19 pc 10 20 r = efi 13 0 ms 0 get ml 0 21 put ml 0 0 22 end 23 24 fn ps c ulong to void 25 if and ge c 32 le c 126 26 pc c 27 else 28 pc 63 29 end 30 end 31 32 fn hx v ulong n ulong to void 33 i = ulong 0 34 while lt i n bound 16 35 d = and shr v mul sub sub n 1 i 4 15 36 if lt d 10 37 pc add 48 d 38 else 39 pc add 87 d 40 end 41 i = add i 1 42 end 43 end 44 45 fn rd4 k ulong to ulong 46 v = ulong 0 47 for i ulong 4 48 v = or v shl ulong get cb add k i mul i 8 49 end 50 ret v 51 end 52 53 note CPUID leaf l into cb; returns efi 14's result 54 fn cpu l ulong to ulong 55 ret efi 14 shl l 16 cb 0 16 56 end 57 58 note true when brand byte i is padding (32 or 0); and/or evaluate both sides, so the trim loops test 59 note their index bound in the while and the byte inside the body: br[48] is never read 60 fn bblank i ulong to bool 61 v = ulong get br i 62 ret or eq v 32 eq v 0 63 end 64 65 fn brand to void 66 r = cpu `2147483648` 67 if or ne r 16 lt rd4 0 `2147483652` 68 pc 45 69 ret 70 end 71 for j ulong 3 72 r = cpu add `2147483650` j 73 for k ulong 16 74 put br add mul j 16 k get cb k 75 end 76 end 77 s = ulong 0 78 while lt s 48 bound 48 79 if not bblank s 80 break 81 end 82 s = add s 1 83 end 84 e = ulong 48 85 while gt e s bound 48 86 if not bblank sub e 1 87 break 88 end 89 e = sub e 1 90 end 91 if eq e s 92 pc 45 93 end 94 i = s 95 while lt i e bound 48 96 ps ulong get br i 97 i = add i 1 98 end 99 end 100 101 fn vendor to void 102 r = efi 14 1 vb 0 256 103 if or ge r `9223372036854775808` eq r 0 104 pc 45 105 ret 106 end 107 for k ulong div r 2 108 ps or ulong get vb mul k 2 shl ulong get vb add mul k 2 1 8 109 end 110 end 111 112 note SMBIOS string number n of the structure at p (formatted length at p+1), or - when n is 0, when 113 note the string set ends first (a string may not start with 0: that 0 ends the set), or when the 114 note string's NUL lies at or past t. Every read is below t, so the walk never leaves the structure. 115 fn sstr p ulong n ulong t ulong to void 116 if eq n 0 117 pc 45 118 ret 119 end 120 q = add p ulong get sb add p 1 121 c = ulong 1 122 while lt q t bound 8192 123 if eq ulong get sb q 0 124 pc 45 125 ret 126 end 127 if eq c n 128 e = q 129 while lt e t bound 8192 130 if eq ulong get sb e 0 131 break 132 end 133 e = add e 1 134 end 135 if ge e t 136 pc 45 137 ret 138 end 139 while lt q e bound 8192 140 ps ulong get sb q 141 q = add q 1 142 end 143 ret 144 end 145 while lt q t bound 8192 146 if eq ulong get sb q 0 147 break 148 end 149 q = add q 1 150 end 151 q = add q 1 152 c = add c 1 153 end 154 pc 45 155 end 156 157 note string number in field i of the structure at p (byte p+4+i), or 0 when that byte is at or past t 158 fn fld p ulong i ulong t ulong to ulong 159 k = add add p 4 i 160 if ge k t 161 ret 0 162 end 163 ret ulong get sb k 164 end 165 166 note true when sb[q] and sb[q+1] are both 0 (the end of a structure's string set) 167 fn dnul q ulong to bool 168 ret and eq ulong get sb q 0 eq ulong get sb add q 1 0 169 end 170 171 fn smbios to void 172 t = efi 14 3 sb 0 8192 173 if or ge t `9223372036854775808` lt t 4 174 pc 45 175 ret 176 end 177 p = ulong 0 178 while lt add p 4 t bound 8192 179 ty = ulong get sb p 180 ln = ulong get sb add p 1 181 if eq ty 1 182 if lt ln 8 183 pc 45 184 ret 185 end 186 sstr p fld p 0 t t 187 pc 47 188 sstr p fld p 1 t t 189 pc 47 190 sstr p fld p 2 t t 191 ret 192 end 193 if or eq ty 127 lt ln 4 194 pc 45 195 ret 196 end 197 q = add p ln 198 while lt add q 1 t bound 8192 199 if dnul q 200 break 201 end 202 q = add q 1 203 end 204 p = add q 2 205 end 206 pc 45 207 end 208 209 fn line v ulong to void 210 hx v 16 211 nl 212 end 213 214 fn main to ulong 215 pc 61 216 pc 61 217 pc 66 218 nl 219 pc 98 220 pc 114 221 pc 61 222 brand 223 nl 224 pc 102 225 pc 119 226 pc 61 227 vendor 228 nl 229 pc 115 230 pc 109 231 pc 61 232 smbios 233 nl 234 note sub 3 at position 4: 8 bytes equal to the table's bytes 4..11 235 r = efi 14 or ulong 3 shl ulong 4 16 pb 0 8 236 ok = eq r 8 237 for k ulong 8 238 if ne get pb k get sb add k 4 239 ok = false 240 end 241 end 242 if ok 243 pc 112 244 pc 111 245 pc 115 246 pc 32 247 pc 111 248 pc 107 249 else 250 pc 63 251 end 252 nl 253 line efi 14 3 pb 0 0 254 line efi 14 or ulong 3 shl ulong `1048575` 16 pb 0 8 255 line efi 14 0 cb 0 16 256 line efi 14 0 cb 0 15 257 line efi 14 shl ulong 1 48 cb 0 16 258 line efi 14 4 cb 0 16 259 line efi 14 65537 cb 0 16 260 line efi 14 256 cb 0 16 261 pc 61 262 pc 61 263 pc 69 264 nl 265 pc 61 266 pc 61 267 pc 82 268 pc 32 269 hx efi 14 2 cb 0 0 8 270 nl 271 ret 0 272 end