interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / aienux / allen / look-chat.om

142 lines · 2976 bytes Raw Blame History
1note SPDX-License-Identifier: MIT
2note COURIER lane: Allen's courier to the Spark relay over UDP 47033, the Omega
3note build's x86/courier_udp_x86.c. application.om (appinit, appask, apppoll,
4note appsent, appreceive) already speaks the courier wire; this module binds its
5note datagrams to net.om's netudpsend/Chrx hooks and the typed line to appask.
6note Needs base, runtime, code, courier, scheduler, memory, intent, reply,
7note context, application (gate.sh core list) and net.om before it in the unit.
8note Ch: 0 initialized, 1 last event, 2 datagrams out, 3 datagrams in,
9note 4 refused sends, 5 answers taken, 6 run id, 7 dropped-at-receive seen.
10note Chevent after chstep: 0 nothing, 1 answer visible in Chsay, 2 asked AGAIN,
11note 3 gave up, 4 refused, 5 slow notice, 6 silence (application.om A2).
12global Ch ulong 8
13global Chsay uchar 320
14global Chsayn ulong 1
15global Chevent ulong 1
16note Run id like the C kernel: the clock at start mixed with the MAC, never 0.
17fn chrun now ulong to ulong
18run = now
19for i ulong 6
20run = xor run shl ulong get Nmac i mul 8 add i 2
21end
22if eq run 0
23run = 1
24end
25ret run
26end
27note Refused (false, nothing touched) while application.om is still active.
28fn chinit now ulong run ulong to bool
29if eq run 0
30run = chrun now
31end
32if not appinit run now
33ret false
34end
35for i ulong 8
36put Ch i 0
37end
38put Chsayn 0 0
39put Chevent 0 0
40put Chrxn 0 0
41put Chdrop 0 0
42put Ch 0 1
43put Ch 6 run
44ret true
45end
46note The typed request is platform.om's Dprm[0..Dprmn); appask copies and
47note validates it (1..159 printable bytes). Dprmn is left for the caller.
48fn chask now ulong to bool
49if eq get Ch 0 0
50ret false
51end
52n = get Dprmn 0
53if gt n len Dprm
54ret false
55end
56for i ulong n
57put In i get Dprm i
58end
59put Inlen 0 n
60ret appask now
61end
62fn chbusy to bool
63if eq get Ch 0 0
64ret false
65end
66ret or ne get R 1 0 ne get A 1 0
67end
68fn chcancel to void
69if eq get Ch 0 0
70ret
71end
72appcancel
73put Chevent 0 0
74end
75fn chsay to void
76n = get R 8
77if gt n len Chsay
78n = len Chsay
79end
80for i ulong n
81put Chsay i get Answer i
82end
83put Chsayn 0 n
84put Ch 5 add get Ch 5 1
85end
86fn chevent to void
87e = get A 2
88if eq e 0
89ret
90end
91put Chevent 0 e
92put Ch 1 e
93if eq e 1
94chsay
95end
96end
97fn chtake now ulong to void
98n = get Chrxn 0
99put Chrxn 0 0
100put Ch 3 add get Ch 3 1
101put Ch 7 get Chdrop 0
102for i ulong n
103put In i get Chrx i
104end
105put Inlen 0 n
106if appreceive now
107chevent
108end
109end
110fn chsend now ulong to void
111n = get Outlen 0
112ok = false
113if and ne n 0 le n len Chtx
114for i ulong n
115put Chtx i get Outb i
116end
117ok = netudpsend n
118end
119if ok
120put Ch 2 add get Ch 2 1
121else
122put Ch 4 add get Ch 4 1
123end
124ok = appsent now ok
125end
126note One step of the courier, like the C pump: take the datagram waiting in
127note Chrx, then let the scheduler offer HELLO/JOB/GOT and send it. up is the
128note firmware's network-up flag (Es 6). Chevent reports this step's event.
129fn chstep now ulong up bool to void
130put Chevent 0 0
131if eq get Ch 0 0
132ret
133end
134if ne get Chrxn 0 0
135chtake now
136end
137off = apppoll now up
138chevent
139if off
140chsend now
141end
142end