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