omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / fwprep.om
| 1 | note fwprep.om: the GB10 firmware inputs for the bring-up chain, from files only (OM-1 seeded omc). |
| 2 | note Usage: fwprep FWFILE OGKMSRC OUTDIR [gb20b] |
| 3 | note FWFILE gsp_ga10x.bin (580.173.02), inspected as ck_gsp_fw_inspect inspect does |
| 4 | note OGKMSRC open-gpu-kernel-modules-580.173.02 tree; its two profile-specific bindata files are read as |
| 5 | note ck_gsp_bindata_extract extract does (src/nvidia/generated/g_bindata_kgspGetBinArchive*) |
| 6 | note OUTDIR must be new for gb20b (commit marker fw.gb20b.manifest). The default directory |
| 7 | note gets fmc.img fmc.hash fmc.pubkey fmc.sig bl.img, then fw.manifest (written to |
| 8 | note fw.manifest.tmp and renamed; fw.manifest is unlinked first, so a refused or failed run |
| 9 | note never leaves a manifest behind; consumers read the outputs only through it) |
| 10 | note stdout: the inspect report, the FMC extract report, the boot extract report (the C tools' exact |
| 11 | note bytes, without --out), then "fwprep ..." lines. Exit 0 ok, 1 usage or FWFILE open/read error |
| 12 | note (stderr), 2 refused, 3 output write failure. |
| 13 | note Build: cat gsp/sha2.om gsp/inflate.om gsp/fw.om gsp/bindata.om fwprep.om | build/omc > fwprep |
| 14 | note Prefix fwp. Host only: reads files, writes OUTDIR; no device. |
| 15 | global fwpok ulong 1 |
| 16 | global fwp20 ulong 1 |
| 17 | global fwparg uchar 32 |
| 18 | text FWPGB20 "gb20b" |
| 19 | note sha256 of the installed 580.173.02 firmware and the exact GB20B vendor archives, |
| 20 | note in FMC then boot order, from open-gpu-kernel-modules 20e4e6e19cc26ba47b5cbe23130a396be100c427. |
| 21 | text FWPGSP "32cb7cf3e77f97e92f6e92135939ccb3ba382748144569c0dfccf3338d43d963" |
| 22 | text FWPARCH "035179cfd878d6bed7308842b0d95612fbb0390149ebee7532b23f375727d8b671e3c512eaa78c60518f6c907826df36bed8e9cbbe8ea8257ca0b1c45d131dec" |
| 23 | text FWPERR20 "fwprep REFUSED GB20B input digest" |
| 24 | global fwpsgb ulong 80 |
| 25 | global fwpsgl ulong 80 |
| 26 | global fwpst uchar 128 |
| 27 | global fwpsrc uchar 4096 |
| 28 | global fwpsrcn ulong 1 |
| 29 | global fwpout uchar 4096 |
| 30 | global fwpoutn ulong 1 |
| 31 | global fwpp uchar 4096 |
| 32 | global fwppn ulong 1 |
| 33 | global fwprn uchar 8200 |
| 34 | global fwpoo ulong 5 |
| 35 | global fwpon ulong 5 |
| 36 | global fwpoh uchar 320 |
| 37 | global fwpdo ulong 1 |
| 38 | global fwpsz ulong 2 |
| 39 | global fwpsh uchar 128 |
| 40 | note FWPTXT segments: 1 "fwprep ", 2 usage, 3..5 bindata paths, 6..7 functions, 8..13 labels, |
| 41 | note 14..20 output names, 21.. messages, 33.. manifest pieces, 43..63 the 21 RM_RISCV_UCODE_DESC |
| 42 | note words in struct order (C riscv_desc), 64.. more pieces |
| 43 | text FWPTXT "|fwprep |usage: fwprep FWFILE OGKMSRC OUTDIR [gb20b]|/src/nvidia/generated/|g_bindata_kgspGetBinArchiveGspRmFmcGfwProdSigned_GB10B.c|g_bindata_kgspGetBinArchiveGspRmBoot_GB10B.c|kgspGetBinArchiveGspRmFmcGfwProdSigned_GB10B|kgspGetBinArchiveGspRmBoot_GB10B|UCODE_IMAGE|UCODE_HASH|UCODE_PKEY|UCODE_SIG|UCODE_IMAGE_PROD|UCODE_DESC_PROD|fmc.img|fmc.hash|fmc.pubkey|fmc.sig|bl.img|fw.manifest|fw.manifest.tmp|REFUSED unexpected function | in |REFUSED missing label |wrote | bytes=| sha256=|RESULT OK|FAILED |makedir |write |rename |: |fwmanifest 1|fwversion |build_id |fw_file bytes=|fwimage offset=| size=|fwsignature .fwsignature_gb10y offset=|fmc_src |boot_src |bl_desc UCODE_DESC_PROD| version=| bootloader_off=| bootloader_size=| bl_param_off=| bl_param_size=| elf_off=| elf_size=| app_version=| manifest_off=| manifest_size=| mdata_off=| mdata_size=| mcode_off=| mcode_size=| monitor_enabled=| swbrom_code_off=| swbrom_code_size=| swbrom_data_off=| swbrom_data_size=| fb_reserved=| signed_as_code=|out |end|open |short read|REFUSED firmware|REFUSED bindata |g_bindata_kgspGetBinArchiveGspRmFmcGfwProdSigned_GB20B.c|g_bindata_kgspGetBinArchiveGspRmBoot_GB20B.c|kgspGetBinArchiveGspRmFmcGfwProdSigned_GB20B|kgspGetBinArchiveGspRmBoot_GB20B|fwsignature .fwsignature_gb20y offset=|fw.gb20b.manifest|fw.gb20b.manifest.tmp|" |
| 44 | fn fwpsetup to void |
| 45 | if eq get fwpok 0 1 |
| 46 | ret |
| 47 | end |
| 48 | put fwpok 0 1 |
| 49 | seg = ulong 0 |
| 50 | for i ulong len FWPTXT |
| 51 | c = get FWPTXT i |
| 52 | if eq c 124 |
| 53 | seg = add seg 1 |
| 54 | put fwpsgb seg add i 1 |
| 55 | put fwpsgl seg 0 |
| 56 | else |
| 57 | put fwpsgl seg add get fwpsgl seg 1 |
| 58 | end |
| 59 | end |
| 60 | end |
| 61 | fn fwpos k ulong to void |
| 62 | b = get fwpsgb k |
| 63 | for i ulong get fwpsgl k |
| 64 | fwoc get FWPTXT add b i |
| 65 | end |
| 66 | end |
| 67 | fn fwppath to void |
| 68 | for i ulong get fwppn 0 |
| 69 | fwoc get fwpp i |
| 70 | end |
| 71 | end |
| 72 | note fwpp = OUTDIR "/" segment k |
| 73 | fn fwpmk k ulong to void |
| 74 | n = get fwpoutn 0 |
| 75 | for i ulong n |
| 76 | put fwpp i get fwpout i |
| 77 | end |
| 78 | put fwpp n 47 |
| 79 | n = add n 1 |
| 80 | b = get fwpsgb k |
| 81 | for i ulong get fwpsgl k |
| 82 | put fwpp n get FWPTXT add b i |
| 83 | n = add n 1 |
| 84 | end |
| 85 | put fwppn 0 n |
| 86 | end |
| 87 | note bdpath = OGKMSRC "/src/nvidia/generated/" segment k |
| 88 | fn fwpbdp k ulong to void |
| 89 | n = get fwpsrcn 0 |
| 90 | for i ulong n |
| 91 | put bdpath i get fwpsrc i |
| 92 | end |
| 93 | for s ulong 2 |
| 94 | g = ulong 3 |
| 95 | if eq s 1 |
| 96 | g = k |
| 97 | end |
| 98 | b = get fwpsgb g |
| 99 | for i ulong get fwpsgl g |
| 100 | put bdpath n get FWPTXT add b i |
| 101 | n = add n 1 |
| 102 | end |
| 103 | end |
| 104 | put bdpathn 0 n |
| 105 | end |
| 106 | note one line to stderr: segment k, then the path in fwpath (when wp 1), then ": " strerror e (e > 0) |
| 107 | fn fwperr k ulong wp ulong e ulong to void |
| 108 | z = fwoflush |
| 109 | put fwofd 0 2 |
| 110 | fwpos k |
| 111 | if eq wp 1 |
| 112 | fwopath |
| 113 | end |
| 114 | if gt e 0 |
| 115 | fwpos 32 |
| 116 | fwoerrno e |
| 117 | end |
| 118 | fwoc 10 |
| 119 | z = fwoflush |
| 120 | put fwofd 0 1 |
| 121 | end |
| 122 | note Select the production archives, commit marker, manifest signature and ELF family together. |
| 123 | note The same slots drive matching and reporting. The default table remains GB10B. |
| 124 | fn fwpprof to ulong |
| 125 | n = argread 4 fwparg 0 32 |
| 126 | if ne n long len FWPGB20 |
| 127 | ret 1 |
| 128 | end |
| 129 | for i ulong len FWPGB20 |
| 130 | if ne get fwparg i get FWPGB20 i |
| 131 | ret 1 |
| 132 | end |
| 133 | end |
| 134 | for i ulong 4 |
| 135 | put fwpsgb add 4 i get fwpsgb add 70 i |
| 136 | put fwpsgl add 4 i get fwpsgl add 70 i |
| 137 | end |
| 138 | for i ulong 2 |
| 139 | put fwpsgb add 19 i get fwpsgb add 75 i |
| 140 | put fwpsgl add 19 i get fwpsgl add 75 i |
| 141 | end |
| 142 | put fwpsgb 39 get fwpsgb 74 |
| 143 | put fwpsgl 39 get fwpsgl 74 |
| 144 | put fwsgb 50 get fwsgb 71 |
| 145 | put fwsgl 50 get fwsgl 71 |
| 146 | put fwsgb 52 get fwsgb 72 |
| 147 | put fwsgl 52 get fwsgl 72 |
| 148 | put fwp20 0 1 |
| 149 | ret 0 |
| 150 | end |
| 151 | note arguments into fwpath (FWFILE), fwpsrc, fwpout: 0, or 1 on a usage error |
| 152 | fn fwpargs to ulong |
| 153 | if eq argcnt 5 |
| 154 | if ne fwpprof 0 |
| 155 | ret 1 |
| 156 | end |
| 157 | else |
| 158 | if ne argcnt 4 |
| 159 | ret 1 |
| 160 | end |
| 161 | end |
| 162 | a = argread 1 fwpath 0 4096 |
| 163 | if lt a 1 |
| 164 | ret 1 |
| 165 | end |
| 166 | put fwpathn 0 ulong a |
| 167 | b = argread 2 fwpsrc 0 4000 |
| 168 | if lt b 1 |
| 169 | ret 1 |
| 170 | end |
| 171 | put fwpsrcn 0 ulong b |
| 172 | c = argread 3 fwpout 0 4000 |
| 173 | if lt c 1 |
| 174 | ret 1 |
| 175 | end |
| 176 | put fwpoutn 0 ulong c |
| 177 | ret 0 |
| 178 | end |
| 179 | note C cmd_inspect on FWFILE: 0 OK, 2 refused, 1 open or read error (C stderr wording) |
| 180 | fn fwpfw to ulong |
| 181 | fd = fopen fwpath 0 get fwpathn 0 524288 0 |
| 182 | if lt fd 0 |
| 183 | fwperr 66 1 ulong neg fd |
| 184 | ret 1 |
| 185 | end |
| 186 | s = fstat int fd fwpst 0 128 |
| 187 | if lt s 0 |
| 188 | c = fclose int fd |
| 189 | fwperr 66 1 ulong neg s |
| 190 | ret 1 |
| 191 | end |
| 192 | sz = ulong 0 |
| 193 | for i ulong 8 |
| 194 | sz = or sz shl ulong get fwpst add 48 i mul i 8 |
| 195 | end |
| 196 | md = ulong 0 |
| 197 | for i ulong 4 |
| 198 | md = or md shl ulong get fwpst add 16 i mul i 8 |
| 199 | end |
| 200 | note S_IFMT 0170000 = 61440, S_IFDIR 0040000 = 16384: a directory is "Is a directory" (21) |
| 201 | if eq and md 61440 16384 |
| 202 | c = fclose int fd |
| 203 | fwperr 66 1 21 |
| 204 | ret 1 |
| 205 | end |
| 206 | e = fwinsp int fd sz |
| 207 | c = fclose int fd |
| 208 | if eq e 1 |
| 209 | fwperr 67 0 0 |
| 210 | ret 1 |
| 211 | end |
| 212 | ret e |
| 213 | end |
| 214 | note does the label of block i equal FWPTXT segment k? |
| 215 | fn fwpleq i ulong k ulong to ulong |
| 216 | b = get fwpsgb k |
| 217 | l = get fwpsgl k |
| 218 | if ne get bdlbl i l |
| 219 | ret 0 |
| 220 | end |
| 221 | a = mul i 64 |
| 222 | m = ulong 1 |
| 223 | for j ulong l |
| 224 | if ne get bdlb add a j get FWPTXT add b j |
| 225 | m = 0 |
| 226 | end |
| 227 | end |
| 228 | ret m |
| 229 | end |
| 230 | note block whose label equals FWPTXT segment k, or BDNONE |
| 231 | fn fwpfind k ulong to ulong |
| 232 | for i ulong get bdn 0 |
| 233 | if eq fwpleq i k 1 |
| 234 | ret i |
| 235 | end |
| 236 | end |
| 237 | ret BDNONE |
| 238 | end |
| 239 | note "fwprep REFUSED missing label L in FILE" |
| 240 | fn fwpmiss k ulong f ulong to ulong |
| 241 | fwpos 1 |
| 242 | fwpos 23 |
| 243 | fwpos k |
| 244 | fwpos 22 |
| 245 | fwpos f |
| 246 | fwoc 10 |
| 247 | ret 2 |
| 248 | end |
| 249 | note record block for label segment k as output slot o; 2 (refused) when it is missing |
| 250 | fn fwpslot k ulong f ulong o ulong to ulong |
| 251 | i = fwpfind k |
| 252 | if eq i BDNONE |
| 253 | ret fwpmiss k f |
| 254 | end |
| 255 | put fwpoo o get bdpo i |
| 256 | put fwpon o get bdpn i |
| 257 | ret 0 |
| 258 | end |
| 259 | note extract bindata file f (segment 4 FMC or 5 boot) whose function must be segment fn |
| 260 | fn fwpbd f ulong fs ulong w ulong to ulong |
| 261 | fwpbdp f |
| 262 | e = bdfile |
| 263 | put fwpsz w get bdfsz 0 |
| 264 | for i ulong 64 |
| 265 | put fwpsh add mul w 64 i get bdfsh i |
| 266 | end |
| 267 | if ne e 0 |
| 268 | fwpos 1 |
| 269 | fwpos 69 |
| 270 | fwpos f |
| 271 | fwoc 10 |
| 272 | ret 2 |
| 273 | end |
| 274 | b = get fwpsgb fs |
| 275 | l = get fwpsgl fs |
| 276 | m = ulong 1 |
| 277 | if ne get bdfnl 0 l |
| 278 | m = 0 |
| 279 | else |
| 280 | for j ulong l |
| 281 | if ne get bdfn j get FWPTXT add b j |
| 282 | m = 0 |
| 283 | end |
| 284 | end |
| 285 | end |
| 286 | if eq m 0 |
| 287 | fwpos 1 |
| 288 | fwpos 21 |
| 289 | bdofn 0 |
| 290 | fwpos 22 |
| 291 | fwpos f |
| 292 | fwoc 10 |
| 293 | ret 2 |
| 294 | end |
| 295 | ret 0 |
| 296 | end |
| 297 | fn fwpfmc to ulong |
| 298 | e = fwpbd 4 6 0 |
| 299 | if ne e 0 |
| 300 | ret e |
| 301 | end |
| 302 | e = fwpslot 8 4 0 |
| 303 | if ne e 0 |
| 304 | ret e |
| 305 | end |
| 306 | e = fwpslot 9 4 1 |
| 307 | if ne e 0 |
| 308 | ret e |
| 309 | end |
| 310 | e = fwpslot 10 4 2 |
| 311 | if ne e 0 |
| 312 | ret e |
| 313 | end |
| 314 | ret fwpslot 11 4 3 |
| 315 | end |
| 316 | fn fwpboot to ulong |
| 317 | e = fwpbd 5 7 1 |
| 318 | if ne e 0 |
| 319 | ret e |
| 320 | end |
| 321 | e = fwpslot 12 5 4 |
| 322 | if ne e 0 |
| 323 | ret e |
| 324 | end |
| 325 | i = fwpfind 13 |
| 326 | if eq i BDNONE |
| 327 | ret fwpmiss 13 5 |
| 328 | end |
| 329 | put fwpdo 0 get bdpo i |
| 330 | ret 0 |
| 331 | end |
| 332 | note "fwprep FAILED <what> <path in fwpp>: <strerror e>" on stdout |
| 333 | fn fwpfail k ulong e ulong to ulong |
| 334 | fwpos 1 |
| 335 | fwpos 28 |
| 336 | fwpos k |
| 337 | fwppath |
| 338 | fwpos 32 |
| 339 | fwoerrno e |
| 340 | fwoc 10 |
| 341 | ret 3 |
| 342 | end |
| 343 | note write bdpl[o..o+n) to OUTDIR/segment k: 0 or a positive errno (5 for a zero-byte write) |
| 344 | fn fwpwf k ulong o ulong n ulong to ulong |
| 345 | fwpmk k |
| 346 | fd = fopen fwpp 0 get fwppn 0 524865 420 |
| 347 | if lt fd 0 |
| 348 | ret ulong neg fd |
| 349 | end |
| 350 | q = ulong 0 |
| 351 | while lt q n bound 999999 |
| 352 | r = write int fd bdpl add o q sub n q |
| 353 | if lt r 1 |
| 354 | c = fclose int fd |
| 355 | if lt r 0 |
| 356 | ret ulong neg r |
| 357 | end |
| 358 | ret 5 |
| 359 | end |
| 360 | q = add q ulong r |
| 361 | end |
| 362 | c = fclose int fd |
| 363 | if lt c 0 |
| 364 | ret ulong neg c |
| 365 | end |
| 366 | ret 0 |
| 367 | end |
| 368 | note write output slot o as segment k and print its line; 0 or 3 |
| 369 | fn fwpput o ulong k ulong to ulong |
| 370 | e = fwpwf k get fwpoo o get fwpon o |
| 371 | if ne e 0 |
| 372 | ret fwpfail 30 e |
| 373 | end |
| 374 | bdsh256 get fwpoo o get fwpon o |
| 375 | shhex 32 |
| 376 | for i ulong 64 |
| 377 | put fwpoh add mul o 64 i get shhx i |
| 378 | end |
| 379 | fwpos 1 |
| 380 | fwpos 24 |
| 381 | fwpos k |
| 382 | fwpos 25 |
| 383 | fwodec get fwpon o |
| 384 | fwpos 26 |
| 385 | fwohx 32 |
| 386 | fwoc 10 |
| 387 | ret 0 |
| 388 | end |
| 389 | fn fwpohx o ulong to void |
| 390 | for i ulong 64 |
| 391 | fwoc get fwpoh add mul o 64 i |
| 392 | end |
| 393 | end |
| 394 | note little-endian u32 word w of the boot UCODE_DESC_PROD plain bytes |
| 395 | fn fwpw32 w ulong to ulong |
| 396 | p = add get fwpdo 0 mul w 4 |
| 397 | v = ulong 0 |
| 398 | for k ulong 4 |
| 399 | v = or v shl ulong get bdpl add p k mul k 8 |
| 400 | end |
| 401 | ret v |
| 402 | end |
| 403 | note manifest lines 1..6: the firmware and the two bindata inputs |
| 404 | fn fwpman1 to void |
| 405 | fwpos 33 |
| 406 | fwoc 10 |
| 407 | fwpos 34 |
| 408 | for i ulong get fwvern 0 |
| 409 | fwoc get fwver i |
| 410 | end |
| 411 | fwoc 10 |
| 412 | fwpos 35 |
| 413 | for i ulong get fwbidn 0 |
| 414 | fwoc get fwbidh i |
| 415 | end |
| 416 | fwoc 10 |
| 417 | fwpos 36 |
| 418 | fwodec get fwlen 0 |
| 419 | fwpos 26 |
| 420 | for i ulong 64 |
| 421 | fwoc get fwhxf i |
| 422 | end |
| 423 | fwoc 10 |
| 424 | fwpos 37 |
| 425 | fwodec get fwsof get fwimx 0 |
| 426 | fwpos 38 |
| 427 | fwodec get fwssz get fwimx 0 |
| 428 | fwpos 26 |
| 429 | for i ulong 64 |
| 430 | fwoc get fwhxi i |
| 431 | end |
| 432 | fwoc 10 |
| 433 | fwpos 39 |
| 434 | fwodec get fwsof get fwsx 0 |
| 435 | fwpos 38 |
| 436 | fwodec get fwssz get fwsx 0 |
| 437 | fwpos 26 |
| 438 | for i ulong 64 |
| 439 | fwoc get fwhxs i |
| 440 | end |
| 441 | fwoc 10 |
| 442 | for w ulong 2 |
| 443 | fwpos add 40 w |
| 444 | fwpos add 4 w |
| 445 | fwpos 25 |
| 446 | fwodec get fwpsz w |
| 447 | fwpos 26 |
| 448 | for i ulong 64 |
| 449 | fwoc get fwpsh add mul w 64 i |
| 450 | end |
| 451 | fwoc 10 |
| 452 | end |
| 453 | end |
| 454 | note manifest: the descriptor words, the outputs, "end" |
| 455 | fn fwpman2 to void |
| 456 | fwpos 42 |
| 457 | for w ulong 21 |
| 458 | fwpos add 43 w |
| 459 | fwodec fwpw32 w |
| 460 | end |
| 461 | fwoc 10 |
| 462 | for o ulong 5 |
| 463 | fwpos 64 |
| 464 | fwpos add 14 o |
| 465 | fwpos 25 |
| 466 | fwodec get fwpon o |
| 467 | fwpos 26 |
| 468 | fwpohx o |
| 469 | fwoc 10 |
| 470 | end |
| 471 | fwpos 65 |
| 472 | fwoc 10 |
| 473 | end |
| 474 | note write fw.manifest.tmp through the fw.om writer, then rename it to fw.manifest; 0 or 3 |
| 475 | fn fwpman to ulong |
| 476 | z = fwoflush |
| 477 | oe = get fwoerr 0 |
| 478 | fwpmk 20 |
| 479 | fd = fopen fwpp 0 get fwppn 0 524865 420 |
| 480 | if lt fd 0 |
| 481 | ret fwpfail 30 ulong neg fd |
| 482 | end |
| 483 | put fwofd 0 int fd |
| 484 | put fwoerr 0 0 |
| 485 | fwpman1 |
| 486 | fwpman2 |
| 487 | z = fwoflush |
| 488 | we = get fwoerr 0 |
| 489 | put fwofd 0 1 |
| 490 | put fwoerr 0 oe |
| 491 | c = fclose int fd |
| 492 | if eq we 1 |
| 493 | ret fwpfail 30 5 |
| 494 | end |
| 495 | if lt c 0 |
| 496 | ret fwpfail 30 ulong neg c |
| 497 | end |
| 498 | ret fwpren |
| 499 | end |
| 500 | note rename fw.manifest.tmp to fw.manifest (renameat2 packed list: u16 count, then u16 len + bytes) |
| 501 | fn fwpren to ulong |
| 502 | put fwprn 0 2 |
| 503 | put fwprn 1 0 |
| 504 | n = ulong 2 |
| 505 | for s ulong 2 |
| 506 | fwpmk sub 20 s |
| 507 | l = get fwppn 0 |
| 508 | put fwprn n uchar rem l 256 |
| 509 | put fwprn add n 1 uchar div l 256 |
| 510 | n = add n 2 |
| 511 | for i ulong l |
| 512 | put fwprn add n i get fwpp i |
| 513 | end |
| 514 | n = add n l |
| 515 | end |
| 516 | r = renames fwprn 0 n 0 |
| 517 | if lt r 0 |
| 518 | ret fwpfail 31 ulong neg r |
| 519 | end |
| 520 | fwpos 1 |
| 521 | fwpos 24 |
| 522 | fwpos 19 |
| 523 | fwoc 10 |
| 524 | ret 0 |
| 525 | end |
| 526 | note make OUTDIR (an existing one is fine) and write every output, the manifest last |
| 527 | fn fwpwrite to ulong |
| 528 | r = makedir fwpout 0 get fwpoutn 0 493 |
| 529 | if lt r 0 |
| 530 | if or ne r -17 eq get fwp20 0 1 |
| 531 | for i ulong get fwpoutn 0 |
| 532 | put fwpp i get fwpout i |
| 533 | end |
| 534 | put fwppn 0 get fwpoutn 0 |
| 535 | ret fwpfail 29 ulong neg r |
| 536 | end |
| 537 | end |
| 538 | for o ulong 5 |
| 539 | e = fwpput o add 14 o |
| 540 | if ne e 0 |
| 541 | ret e |
| 542 | end |
| 543 | end |
| 544 | ret fwpman |
| 545 | end |
| 546 | note Bind the selected section and archive payloads to the complete pinned inputs before output. |
| 547 | fn fwppins to ulong |
| 548 | for i ulong 64 |
| 549 | if ne get fwhxf i get FWPGSP i |
| 550 | ret 0 |
| 551 | end |
| 552 | end |
| 553 | for i ulong 128 |
| 554 | if ne get fwpsh i get FWPARCH i |
| 555 | ret 0 |
| 556 | end |
| 557 | end |
| 558 | ret 1 |
| 559 | end |
| 560 | fn fwprun to ulong |
| 561 | e = fwpfw |
| 562 | if eq e 2 |
| 563 | fwpos 1 |
| 564 | fwpos 68 |
| 565 | fwoc 10 |
| 566 | end |
| 567 | if ne e 0 |
| 568 | ret e |
| 569 | end |
| 570 | e = fwpfmc |
| 571 | if ne e 0 |
| 572 | ret e |
| 573 | end |
| 574 | e = fwpboot |
| 575 | if ne e 0 |
| 576 | ret e |
| 577 | end |
| 578 | if eq get fwp20 0 1 |
| 579 | if eq fwppins 0 |
| 580 | for i ulong len FWPERR20 |
| 581 | fwoc get FWPERR20 i |
| 582 | end |
| 583 | fwoc 10 |
| 584 | ret 2 |
| 585 | end |
| 586 | end |
| 587 | e = fwpwrite |
| 588 | if ne e 0 |
| 589 | ret e |
| 590 | end |
| 591 | fwpos 1 |
| 592 | fwpos 27 |
| 593 | fwoc 10 |
| 594 | ret 0 |
| 595 | end |
| 596 | fn main to int |
| 597 | fwsetup |
| 598 | bdsetup |
| 599 | fwpsetup |
| 600 | if ne fwpargs 0 |
| 601 | fwperr 2 0 0 |
| 602 | ret 1 |
| 603 | end |
| 604 | if eq get fwp20 0 0 |
| 605 | fwpmk 19 |
| 606 | u = unlink fwpp 0 get fwppn 0 |
| 607 | end |
| 608 | e = fwprun |
| 609 | z = fwoflush |
| 610 | if and eq e 0 eq get fwoerr 0 1 |
| 611 | ret 3 |
| 612 | end |
| 613 | ret int e |
| 614 | end |