interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / native / omegallm / eio.om

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