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-helix/blob/main/native/eio.om # omega-helix This project has not described itself yet. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-helix / native / eio.om` 1042 lines ยท 19574 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note omegallm eio.om (aien-train#52): the UEFI platform unit for `target x86efi`. It replaces lio.om 3 note and defines the same functions (oargc, oargr, oflush, ocwopen, ocwput, ocwend, ofsz, ogradw, 4 note ocsinit, ocsg, ocsp, odread, owflush, owopen, owclose, ooffrd, oprd, obmsave, main) with efi words only: efi 1 key, efi 2 stall, efi 10 millisecond clock, 5 note efi 12 file (one open file; ARG bits 0..7 sub, 8..15 volume, 16..63 position; result bit 63 set 6 note on error), efi 13 console text, efi 14 machine identity (CPUID, SystemTable FirmwareVendor and 7 note FirmwareRevision, SMBIOS structure table). Every file is on the volume the image was loaded 8 note from (k = 255). After the banner main prints the identity line `ID cpu=... fw=... fwrev=... 9 note smbios=.../.../...` (CONTRACT section 9); it never prints the SMBIOS serial number or UUID. 10 note The command lines come from \OLLM\JOB.TXT (CONTRACT section 9): one command per line without the 11 note program name, tokens split on space or tab, a token in double quotes may hold spaces, empty lines 12 note and lines starting with # are skipped. Each job's line is echoed as `> line`, its output follows 13 note (with a line feed added when it does not end in one), then `J ms` (wall milliseconds, 0 when the 14 note firmware has no clock). Output goes to the console 15 note (bytes outside 9, 10, 13, 32..126 shown as ?) and, byte-exact, to \OLLM\OUT.TXT, which main 16 note recreates at start; each flush appends. After the last job main prints `OLLM DONE jobs ms` and 17 note waits up to 300 s for a key. A refusal (exit N) ends the application at once with status N, as 18 note on Linux; OUT.TXT then ends with the failing job's output so far. 19 note One job is not a cli command: `ask CK SEED N TEMPMILLI [MERGES]` (oask) is a typed conversation with 20 note the model at the machine's own keyboard and screen. It prints `You: `, reads a line of keys (efi 1; 21 note 32..126 only, Backspace removes one, at most 900), and runs `sample CK SEED+turn N TEMPMILLI LINE 22 note [MERGES]` for it, again and again. An empty line, Esc, or ten minutes without a key ends the job. The 23 note typed line and the answer go to OUT.TXT like every other output. It needs a keyboard, so no 24 note recorded job file uses it. 25 note Differences from lio.om: a checkpoint is written in place (no PATH.tmp + rename: the UEFI file 26 note protocol has no rename), and a path longer than 255 bytes is an I/O refusal (exit 70). 27 const OEV ulong 65280 28 const OERR ulong `9223372036854775808` 29 const OJCAP ulong 65536 30 global ojob uchar 65536 31 global ojn ulong 1 32 global otb ulong 64 33 global otl ulong 64 34 global otc ulong 1 35 global opn uchar 16 36 global ocon uchar 4096 37 global oop ulong 1 38 global owq0 uchar 256 39 global owq1 uchar 256 40 global owql ulong 2 41 global owps ulong 2 42 global oclk uchar 8 43 global okey uchar 8 44 global olc ulong 1 45 global oidc uchar 16 46 global oidb uchar 48 47 global oidv uchar 512 48 global oids uchar 65536 49 global ommap_sz_g ulong 1 50 51 fn oeerr r ulong to bool 52 ret ge r OERR 53 end 54 55 note efi 12 ARG for sub-op s at byte position p on the boot volume 56 fn oefa s ulong p ulong to ulong 57 ret or or s OEV shl p 16 58 end 59 60 note close the open file; a failed close is an I/O refusal 61 fn oeclose to void 62 c = efi 12 oefa 4 0 opn 0 0 63 if oeerr c 64 exit 70 65 end 66 end 67 68 note opn = \OLLM\JOB.TXT (w = 0) or \OLLM\OUT.TXT (w = 1), 13 bytes 69 fn opath w ulong to void 70 put opn 0 92 71 put opn 1 79 72 put opn 2 76 73 put opn 3 76 74 put opn 4 77 75 put opn 5 92 76 if eq w 0 77 put opn 6 74 78 put opn 7 79 79 put opn 8 66 80 else 81 put opn 6 79 82 put opn 7 85 83 put opn 8 84 84 end 85 put opn 9 46 86 put opn 10 84 87 put opn 11 88 88 put opn 12 84 89 end 90 91 note the bytes of a little-endian u64 packing, low byte first, zero bytes skipped 92 fn oputw v ulong to void 93 for k ulong 8 94 c = and shr v mul k 8 255 95 if ne c 0 96 oputc c 97 end 98 end 99 end 100 101 note onsnow: the firmware clock in nanoseconds (kvcmp's step timing in cli.om), ms resolution 102 fn onsnow to ulong 103 ret mul oms `1000000` 104 end 105 106 note firmware milliseconds (efi 10), 0 when unavailable 107 fn oms to ulong 108 st = efi 10 0 oclk 0 8 109 if ne st 0 110 ret 0 111 end 112 v = ulong 0 113 for i ulong 8 114 v = or v shl ulong get oclk i mul i 8 115 end 116 ret v 117 end 118 119 note wait up to 300 s (3000 polls 100 ms apart) for a key 120 fn owait to void 121 for i ulong 3000 122 st = efi 1 0 okey 0 4 123 if eq st 0 124 break 125 end 126 s2 = efi 2 100000 okey 0 0 127 end 128 end 129 130 fn oargc to ulong 131 ret get otc 0 132 end 133 134 note the current job is `ask` with four or five arguments (MERGES is optional, as for sample) 135 fn oisask to bool 136 if and ne get otc 0 6 ne get otc 0 7 137 ret false 138 end 139 if ne get otl 1 3 140 ret false 141 end 142 b = get otb 1 143 ret and and eq ulong get ojob b 97 eq ulong get ojob add b 1 115 eq ulong get ojob add b 2 107 144 end 145 146 note ocon[0 .. n) to the console only (not OUT.TXT) 147 fn ocons n ulong to void 148 t = efi 13 0 ocon 0 n 149 end 150 151 note the console line `You: ` + the n typed bytes kept at ojob[64544 ..), after a carriage return and 152 note followed by e spaces and, when e > 0, the same line again (so a removed character disappears) 153 fn oaskline n ulong e ulong to void 154 put ocon 0 13 155 put ocon 1 89 156 put ocon 2 111 157 put ocon 3 117 158 put ocon 4 58 159 put ocon 5 32 160 for k ulong n 161 put ocon add 6 k get ojob add 64544 k 162 end 163 for k ulong e 164 put ocon add add 6 n k 32 165 end 166 ocons add add 6 n e 167 if gt e 0 168 ocons add 6 n 169 end 170 end 171 172 note read one typed line into ojob[64544 ..): its length, or OERR when Esc was pressed or no key came 173 note for ten minutes (30000 polls 20 ms apart, the count restarting at every key) 174 fn oaskread to ulong 175 n = ulong 0 176 oaskline 0 0 177 idle = ulong 0 178 for i ulong `4000000000` 179 st = efi 1 0 okey 0 4 180 if ne st 0 181 idle = add idle 1 182 if ge idle 30000 183 ret OERR 184 end 185 s2 = efi 2 20000 okey 0 0 186 else 187 idle = 0 188 c = or ulong get okey 2 shl ulong get okey 3 8 189 sc = or ulong get okey 0 shl ulong get okey 1 8 190 if eq c 13 191 ret n 192 end 193 if and eq c 0 eq sc 23 194 ret OERR 195 end 196 if and eq c 8 gt n 0 197 n = sub n 1 198 oaskline n 1 199 end 200 if and and ge c 32 le c 126 lt n 900 201 put ojob add 64544 n uchar c 202 n = add n 1 203 oaskline n 0 204 end 205 end 206 end 207 ret OERR 208 end 209 210 note v in decimal at ojob[64520 ..); the number of digits 211 fn oaskseed v ulong to ulong 212 dl = ulong 1 213 x = v 214 for k ulong 19 215 x = div x 10 216 if gt x 0 217 dl = add dl 1 218 end 219 end 220 x = v 221 for k ulong dl 222 p = sub add 64519 dl k 223 put ojob p uchar add 48 rem x 10 224 x = div x 10 225 end 226 ret dl 227 end 228 229 note the typed line of n bytes to OUT.TXT and the console as `You: line`, over the echoed one 230 fn oaskecho n ulong to void 231 put ocon 0 13 232 ocons 1 233 oputc 89 234 oputc 111 235 oputc 117 236 oputc 58 237 oputc 32 238 for k ulong n 239 oputc ulong get ojob add 64544 k 240 end 241 oputc 10 242 oflush 243 end 244 245 note the seed argument of the ask job as a number (exit 2 unless it is 1 to 19 decimal digits, the 246 note bound sample's own argument has, so the number never wraps) 247 fn oaskbase to ulong 248 sb = get otb 3 249 if or eq get otl 3 0 gt get otl 3 19 250 exit 2 251 end 252 seed = ulong 0 253 for k ulong get otl 3 254 d = ulong get ojob add sb k 255 if or lt d 48 gt d 57 256 exit 2 257 end 258 seed = add mul seed 10 sub d 48 259 end 260 ret seed 261 end 262 263 note ask CK SEED N TEMPMILLI [MERGES]: see the head of this file. The rewritten job is built in the last 264 note 1024 bytes of ojob, which the job file may not reach (exit 2): `sample` at 64512, the turn's seed 265 note in decimal at 64520, the typed line at 64544. 266 fn oask to void 267 if gt get ojn 0 64000 268 exit 2 269 end 270 put ojob 64512 115 271 put ojob 64513 97 272 put ojob 64514 109 273 put ojob 64515 112 274 put ojob 64516 108 275 put ojob 64517 101 276 seed = oaskbase 277 hm = eq get otc 0 7 278 mb = get otb 6 279 ml = get otl 6 280 for turn ulong `1000000` 281 n = oaskread 282 if or oeerr n eq n 0 283 break 284 end 285 oaskecho n 286 dl = oaskseed add seed turn 287 put otb 1 64512 288 put otl 1 6 289 put otb 3 64520 290 put otl 3 dl 291 put otb 6 64544 292 put otl 6 n 293 if hm 294 put otb 7 mb 295 put otl 7 ml 296 put otc 0 8 297 else 298 put otc 0 7 299 end 300 rc = ocmd 301 oflush 302 if ne get olc 0 10 303 oputc 10 304 oflush 305 end 306 end 307 put ocon 0 10 308 ocons 1 309 end 310 311 note token i of the current job into oarg (at most 4096 bytes copied); argv[0] is "ollm"; returns 312 note the token length, or -1 when there is no token i 313 fn oargr i ulong to long 314 if ge i get otc 0 315 ret sub long 0 long 1 316 end 317 if eq i 0 318 put oarg 0 111 319 put oarg 1 108 320 put oarg 2 108 321 put oarg 3 109 322 ret long 4 323 end 324 s = get otb i 325 n = get otl i 326 m = n 327 if gt m 4096 328 m = ulong 4096 329 end 330 for k ulong m 331 put oarg k get ojob add s k 332 end 333 ret long n 334 end 335 336 note append oout to OUT.TXT, then show it on the console 337 fn oflush to void 338 n = get oon 0 339 if gt n 0 340 opath 1 341 r = efi 12 oefa 5 0 opn 0 13 342 if oeerr r 343 exit 70 344 end 345 if ne r get oop 0 346 exit 70 347 end 348 w = efi 12 oefa 3 get oop 0 oout 0 n 349 if ne w n 350 exit 70 351 end 352 oeclose 353 put oop 0 add get oop 0 n 354 for k ulong n 355 c = ulong get oout k 356 ok = or or eq c 9 eq c 10 or eq c 13 and ge c 32 le c 126 357 if ok 358 put ocon k uchar c 359 else 360 put ocon k 63 361 end 362 end 363 t = efi 13 0 ocon 0 n 364 put olc 0 ulong get oout sub n 1 365 put oon 0 0 366 end 367 end 368 369 note v1 checkpoint stream (ckpt.om): create (or empty) the file named by argument ai and keep it 370 note open (efi 12 holds one open file; nothing else is opened until ocwend) 371 fn ocwopen ai ulong to void 372 pl = oargp ai 373 r = efi 12 oefa 1 0 oarg 0 pl 374 if oeerr r 375 exit 70 376 end 377 end 378 379 note write ock[0 .. n) at byte position pos of the open checkpoint file 380 fn ocwput pos ulong n ulong to void 381 w = efi 12 oefa 3 pos ock 0 n 382 if ne w n 383 exit 70 384 end 385 end 386 387 note close the checkpoint file (written in place: UEFI has no rename) 388 fn ocwend ai ulong to void 389 oeclose 390 end 391 392 note size in bytes of the file named by argument ai 393 fn ofsz ai ulong to ulong 394 pl = oargp ai 395 sz = efi 12 oefa 0 0 oarg 0 pl 396 if oeerr sz 397 exit 70 398 end 399 oeclose 400 ret sz 401 end 402 403 note gradient of the step loss: one process only, so K > 1 is refused (CONTRACT-V1 section 5.1) 404 fn ogradw to f64 405 if gt get og 45 1 406 exit 29 407 end 408 ret ograd 409 end 410 411 note cold store (CONTRACT-V3 section 2): GRD and the Adam moments, 3 P values, in three globals of 412 note OCSB = `15833472` values (the x86efi limit is the v2 bank-A capacity; one global holds at most 413 note `16777216` values) 414 const OCSB ulong `15833472` 415 global ocs0 f64 `15833472` 416 global ocs1 f64 `15833472` 417 global ocs2 f64 `15833472` 418 419 note capacity of the cold store in f64 values 420 fn ocsinit to ulong 421 ret mul 3 OCSB 422 end 423 424 fn ocsgrow need ulong to bool 425 ret le need mul 3 OCSB 426 end 427 428 fn ocsg i ulong to f64 429 if lt i OCSB 430 ret get ocs0 i 431 end 432 j = sub i OCSB 433 if lt j OCSB 434 ret get ocs1 j 435 end 436 ret get ocs2 sub j OCSB 437 end 438 439 fn ocsp i ulong v f64 to void 440 if lt i OCSB 441 put ocs0 i v 442 ret 443 end 444 j = sub i OCSB 445 if lt j OCSB 446 put ocs1 j v 447 else 448 put ocs2 sub j OCSB v 449 end 450 end 451 452 note read the file named by argument i into od0/od1; exit 21 when longer than ODCAP 453 fn odread i ulong to ulong 454 n = oargp i 455 sz = efi 12 oefa 0 0 oarg 0 n 456 if oeerr sz 457 exit 70 458 end 459 if gt sz ODCAP 460 exit 21 461 end 462 p = ulong 0 463 while lt p sz bound 999999 464 r = ulong 0 465 if lt p ODHALF 466 e = sz 467 if gt e ODHALF 468 e = ODHALF 469 end 470 r = efi 12 oefa 2 p od0 p sub e p 471 else 472 r = efi 12 oefa 2 p od1 sub p ODHALF sub sz p 473 end 474 if or oeerr r eq r 0 475 exit 70 476 end 477 p = add p r 478 end 479 if ne p sz 480 exit 70 481 end 482 oeclose 483 put odn 0 p 484 ret p 485 end 486 487 note prep output: append writer k's buffer to its file (efi 12 sub 5 opens without truncation and 488 note returns the current size, which must equal the bytes this writer has written) 489 fn owflush k ulong to void 490 n = get owbn k 491 if gt n 0 492 l = get owql k 493 r = ulong 0 494 if eq k 0 495 r = efi 12 oefa 5 0 owq0 0 l 496 else 497 r = efi 12 oefa 5 0 owq1 0 l 498 end 499 if oeerr r 500 exit 70 501 end 502 if ne r get owps k 503 exit 70 504 end 505 w = ulong 0 506 if eq k 0 507 w = efi 12 oefa 3 r owb0 0 n 508 else 509 w = efi 12 oefa 3 r owb1 0 n 510 end 511 if ne w n 512 exit 70 513 end 514 oeclose 515 put owps k add r n 516 end 517 put owbn k 0 518 end 519 520 note create (or empty) the file named by argument i for writer k 521 fn owopen k ulong i ulong to void 522 n = oargp i 523 if gt n 255 524 exit 70 525 end 526 for j ulong n 527 if eq k 0 528 put owq0 j get oarg j 529 else 530 put owq1 j get oarg j 531 end 532 end 533 put owql k n 534 r = efi 12 oefa 1 0 oarg 0 n 535 if oeerr r 536 exit 70 537 end 538 oeclose 539 put owps k 0 540 put owbn k 0 541 end 542 543 fn owclose k ulong to void 544 owflush k 545 end 546 547 note read argument ai (B little-endian u64 offsets) into ochk; exit 21 unless it holds exactly 8 B bytes 548 fn ooffrd ai ulong to void 549 n = oargp ai 550 sz = efi 12 oefa 0 0 oarg 0 n 551 if oeerr sz 552 exit 70 553 end 554 if ge sz 65536 555 exit 21 556 end 557 p = ulong 0 558 while lt p sz bound 70000 559 r = efi 12 oefa 2 p ochk p sub sz p 560 if or oeerr r eq r 0 561 exit 70 562 end 563 p = add p r 564 end 565 if ne p sz 566 exit 70 567 end 568 oeclose 569 if ne p mul 8 get og 6 570 exit 21 571 end 572 end 573 574 note ojob[p] is a token separator (space or tab) 575 fn ojsep p ulong to bool 576 ch = ulong get ojob p 577 ret or eq ch 32 eq ch 9 578 end 579 580 note split ojob[s .. e) into tokens 1.. (otb start, otl length); otc = 1 + tokens; exit 2 over 63 581 fn ojtok s ulong e ulong to void 582 c = ulong 1 583 p = s 584 while lt p e bound 65537 585 ch = ulong get ojob p 586 if or eq ch 32 eq ch 9 587 p = add p 1 588 else 589 q = p 590 r = p 591 if eq ch 34 592 q = add p 1 593 r = q 594 while and lt r e ne ulong get ojob r 34 bound 65537 595 r = add r 1 596 end 597 p = add r 1 598 else 599 while and lt r e not ojsep r bound 65537 600 r = add r 1 601 end 602 p = r 603 end 604 if ge c 64 605 exit 2 606 end 607 put otb c q 608 put otl c sub r q 609 c = add c 1 610 end 611 end 612 put otc 0 c 613 end 614 615 note read \OLLM\JOB.TXT into ojob; on a missing or over-long file print `OLLM efi JOB.TXT?`, wait, exit 2 616 fn ojread to void 617 opath 0 618 sz = efi 12 oefa 0 0 opn 0 13 619 bad = oeerr sz 620 if not bad 621 if ge sz OJCAP 622 bad = true 623 oeclose 624 end 625 end 626 if bad 627 oputw `7594869011017124943` 628 oputc 32 629 oputw `4563369441009749834` 630 oputc 10 631 n = get oon 0 632 for k ulong n 633 put ocon k get oout k 634 end 635 t = efi 13 0 ocon 0 n 636 owait 637 exit 2 638 end 639 p = ulong 0 640 while lt p sz bound 70000 641 r = efi 12 oefa 2 p ojob p sub sz p 642 if or oeerr r eq r 0 643 exit 70 644 end 645 p = add p r 646 end 647 if ne p sz 648 exit 70 649 end 650 oeclose 651 put ojn 0 p 652 end 653 654 note identity byte: c itself when 32..126, else ? 655 fn oidp c ulong to void 656 if and ge c 32 le c 126 657 oputc c 658 else 659 oputc 63 660 end 661 end 662 663 note CPUID leaf l into oidc (efi 14 sub 0); true when efi 14 answered 664 fn oidq l ulong to bool 665 r = efi 14 shl l 16 oidc 0 16 666 ret eq r 16 667 end 668 669 note the little-endian u32 at oidc[k] 670 fn oidu k ulong to ulong 671 v = ulong 0 672 for i ulong 4 673 v = or v shl ulong get oidc add k i mul i 8 674 end 675 ret v 676 end 677 678 note true when brand byte i is padding (32 or 0); and/or evaluate both sides, so the trim loops in 679 note oidcpu test the index in the while and the byte inside the body: oidb[48] is never read 680 fn oidbl i ulong to bool 681 v = ulong get oidb i 682 ret or eq v 32 eq v 0 683 end 684 685 note the CPUID brand string (leaves 0x80000002..4) without leading or trailing spaces and NULs, or - 686 fn oidcpu to void 687 ok = oidq `2147483648` 688 if ok 689 ok = ge oidu 0 `2147483652` 690 end 691 if not ok 692 oputc 45 693 ret 694 end 695 for j ulong 3 696 ok = oidq add `2147483650` j 697 if not ok 698 oputc 45 699 ret 700 end 701 for k ulong 16 702 put oidb add mul j 16 k get oidc k 703 end 704 end 705 s = ulong 0 706 while lt s 48 bound 48 707 if not oidbl s 708 break 709 end 710 s = add s 1 711 end 712 e = ulong 48 713 while gt e s bound 48 714 if not oidbl sub e 1 715 break 716 end 717 e = sub e 1 718 end 719 if eq e s 720 oputc 45 721 end 722 for i ulong sub e s 723 oidp ulong get oidb add s i 724 end 725 end 726 727 note SystemTable FirmwareVendor, one byte per UCS-2 code unit (? outside 32..126), or - 728 fn oidfw to void 729 r = efi 14 1 oidv 0 512 730 if or oeerr r eq r 0 731 oputc 45 732 ret 733 end 734 for k ulong div r 2 735 oidp or ulong get oidv mul k 2 shl ulong get oidv add mul k 2 1 8 736 end 737 end 738 739 note SystemTable FirmwareRevision as 8 lowercase hex digits, or - 740 fn oidrev to void 741 r = efi 14 2 oidc 0 0 742 if oeerr r 743 oputc 45 744 ret 745 end 746 for i ulong 8 747 d = and shr r mul sub 7 i 4 15 748 if lt d 10 749 oputc add 48 d 750 else 751 oputc add 87 d 752 end 753 end 754 end 755 756 note true when oids[q] and oids[q+1] are both 0 (the end of a structure's strings); callers keep q+1 < t 757 fn oidz q ulong to bool 758 ret and eq ulong get oids q 0 eq ulong get oids add q 1 0 759 end 760 761 note SMBIOS string number n of the structure at p (table length t), or - when n is 0, when the 762 note structure's string set ends first (a string never starts with 0: that 0 ends the set), or when 763 note the string's NUL lies at or past t. Every read is below t, so the walk never leaves the structure. 764 fn oidstr p ulong n ulong t ulong to void 765 if eq n 0 766 oputc 45 767 ret 768 end 769 q = add p ulong get oids add p 1 770 c = ulong 1 771 while lt q t bound 65536 772 if eq ulong get oids q 0 773 oputc 45 774 ret 775 end 776 if eq c n 777 e = q 778 while lt e t bound 65536 779 if eq ulong get oids e 0 780 break 781 end 782 e = add e 1 783 end 784 if ge e t 785 oputc 45 786 ret 787 end 788 while lt q e bound 65536 789 oidp ulong get oids q 790 q = add q 1 791 end 792 ret 793 end 794 while lt q t bound 65536 795 if eq ulong get oids q 0 796 break 797 end 798 q = add q 1 799 end 800 q = add q 1 801 c = add c 1 802 end 803 oputc 45 804 end 805 806 note field i (0 Manufacturer, 1 Product Name, 2 Version) of the type 1 structure at p, length ln; 807 note - when the field lies outside the formatted area or at or past t 808 fn oidf p ulong ln ulong i ulong t ulong to void 809 k = add add p 4 i 810 if and lt add 4 i ln lt k t 811 oidstr p ulong get oids k t 812 else 813 oputc 45 814 end 815 end 816 817 note SMBIOS type 1 Manufacturer/Product Name/Version, each - when missing; the serial number (offset 818 note 7) and the UUID (8..23) are never printed 819 fn oidsm to void 820 t = efi 14 3 oids 0 65536 821 p = ulong 0 822 if oeerr t 823 t = ulong 0 824 end 825 while lt add p 4 t bound 65537 826 ty = ulong get oids p 827 ln = ulong get oids add p 1 828 if eq ty 1 829 oidf p ln 0 t 830 oputc 47 831 oidf p ln 1 t 832 oputc 47 833 oidf p ln 2 t 834 ret 835 end 836 if or eq ty 127 lt ln 4 837 break 838 end 839 q = add p ln 840 while lt add q 1 t bound 65536 841 if oidz q 842 break 843 end 844 q = add q 1 845 end 846 p = add q 2 847 end 848 oputc 45 849 oputc 47 850 oputc 45 851 oputc 47 852 oputc 45 853 end 854 855 note the identity line: ID cpu=... fw=... fwrev=... smbios=.../.../... (ID, not M: mathck prints M e/M l) 856 fn oident to void 857 oputc 73 858 oputc 68 859 oputc 32 860 oputc 99 861 oputc 112 862 oputc 117 863 oputc 61 864 oidcpu 865 oputc 32 866 oputc 102 867 oputc 119 868 oputc 61 869 oidfw 870 oputc 32 871 oputc 102 872 oputc 119 873 oputc 114 874 oputc 101 875 oputc 118 876 oputc 61 877 oidrev 878 oputc 32 879 oputc 115 880 oputc 109 881 oputc 98 882 oputc 105 883 oputc 111 884 oputc 115 885 oputc 61 886 oidsm 887 oputc 10 888 end 889 890 fn main to int 891 ojread 892 opath 1 893 r = efi 12 oefa 1 0 opn 0 13 894 if oeerr r 895 exit 70 896 end 897 oeclose 898 put oop 0 0 899 oputw `7594869011017124943` 900 oputc 32 901 oputu get ojn 0 902 oputc 10 903 oident 904 oflush 905 t0 = oms 906 nj = ulong 0 907 n = get ojn 0 908 s = ulong 0 909 while lt s n bound 65537 910 e = s 911 while and lt e n ne ulong get ojob e 10 bound 65537 912 e = add e 1 913 end 914 lend = e 915 if gt lend s 916 if eq ulong get ojob sub lend 1 13 917 lend = sub lend 1 918 end 919 end 920 if gt lend s 921 if ne ulong get ojob s 35 922 oputc 62 923 oputc 32 924 for k ulong sub lend s 925 oputc ulong get ojob add s k 926 end 927 oputc 10 928 oflush 929 ojtok s lend 930 if ge oargc 2 931 t1 = oms 932 if oisask 933 oask 934 else 935 rc = ocmd 936 end 937 oflush 938 if ne get olc 0 10 939 oputc 10 940 end 941 oputc 74 942 oputc 32 943 oputu sub oms t1 944 oputc 10 945 oflush 946 nj = add nj 1 947 end 948 end 949 end 950 s = add e 1 951 end 952 oputw `5642803763645008975` 953 oputc 69 954 oputc 32 955 oputu nj 956 oputc 32 957 oputu sub oms t0 958 oputc 10 959 oflush 960 owait 961 ret 0 962 end 963 964 note v1 positioned read (CONTRACT-V1 section 3), as lio.om: up to n bytes of the file named by 965 note argument ai, from byte pos, into opw[off .. off + n); opened and closed on every call (efi 12 966 note holds one open file). Returns n, fewer only when the file ends first, 0 at or after its end. 967 fn oprd ai ulong pos ulong off ulong n ulong to ulong 968 pl = oargp ai 969 sz = efi 12 oefa 0 0 oarg 0 pl 970 if oeerr sz 971 exit 70 972 end 973 m = ulong 0 974 if lt pos sz 975 m = sub sz pos 976 if gt m n 977 m = n 978 end 979 end 980 p = ulong 0 981 for o ulong 3 982 while lt p m bound 999999 983 r = efi 12 oefa 2 add pos p opw add off p sub m p 984 if or oeerr r eq r 0 985 exit 70 986 end 987 p = add p r 988 end 989 end 990 oeclose 991 ret m 992 end 993 994 note v1 (CONTRACT-V1 section 7): write obm[0 .. n) (bpe.om) to the path in argument ai, in place 995 fn obmsave ai ulong n ulong to void 996 pl = oargp ai 997 r = efi 12 oefa 1 0 oarg 0 pl 998 if oeerr r 999 exit 70 1000 end 1001 w = efi 12 oefa 3 0 obm 0 n 1002 if ne w n 1003 exit 70 1004 end 1005 oeclose 1006 end 1007 1008 fn ocwput_opw pos ulong n ulong to void 1009 w = efi 12 oefa 3 pos opw 0 n 1010 if ne w n 1011 exit 70 1012 end 1013 end 1014 1015 fn ommap_open ai ulong to long 1016 put ommap_sz_g 0 ofsz ai 1017 ret neg long 1 1018 end 1019 1020 fn ommap_sz to ulong 1021 ret get ommap_sz_g 0 1022 end 1023 1024 fn ommap_read h long off ulong n ulong to void 1025 exit 70 1026 end 1027 1028 fn ommap_drop h long to void 1029 ret 1030 end 1031 1032 fn ocswrite off ulong n ulong to bool 1033 ret false 1034 end 1035 1036 fn ocsread off ulong n ulong to bool 1037 ret false 1038 end 1039 1040 fn ommap_fnv64 h long off ulong nw ulong init_h ulong to ulong 1041 ret init_h 1042 end