interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / local-model.om

278 lines · 4589 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Opt-in local-model application for Aienux's Omega firmware environment.
3note Links the existing Allen base/runtime and aien-train's unchanged model/checkpoint/tokenizer.
4note Firmware Boot Services stay active. This is not a standalone-kernel or bare-metal M2 claim.
5note No network, Linux syscalls, shell, external inference provider or checkpoint writes.
6note Serial console protocol: LM1 ID TOKENS TEMPMILLI SEED HEX_PROMPT CR.
7note ID/SEED u32; TOKENS 1..128; TEMPMILLI 0..2000; prompt 1..159 printable ASCII bytes.
8note Output: LMREADY; LMSTART ID; LMDATA ID HEX_BYTES; LMDONE ID; LMERR ID CODE.
9note A request uses Allen's start/answer conversation lifecycle. Its history stores a bounded
10note printable preview; raw generated bytes are sent unchanged in the LMDATA frames.
11text Lmck "\\ASTRA.CK"
12text Lmbpe "\\BPE.BIN"
13text Lmboot "AIENUX OMEGA LOCAL MODEL: firmware hosted, no Linux"
14text Lmready "LMREADY"
15text Lmstart "LMSTART "
16text Lmdata "LMDATA "
17text Lmdone "LMDONE "
18text Lmerror "LMERR "
19global Lmstate ulong 8
20note state: input length, overflow, request ID, tokens, temperature, seed, preview length, reserved.
21global Lmline uchar 512
22global Lmkey uchar 8
23global Lmprev uchar 160
24
25fn lmput which ulong to void
26if eq which 0
27for i ulong len Lmboot
28emitb get Lmboot i
29end
30end
31if eq which 1
32for i ulong len Lmready
33emitb get Lmready i
34end
35end
36if eq which 2
37for i ulong len Lmstart
38emitb get Lmstart i
39end
40end
41if eq which 3
42for i ulong len Lmdata
43emitb get Lmdata i
44end
45end
46if eq which 4
47for i ulong len Lmdone
48emitb get Lmdone i
49end
50end
51if eq which 5
52for i ulong len Lmerror
53emitb get Lmerror i
54end
55end
56end
57
58fn lmsend to void
59emitb 10
60if ne get Err 0 0
61exit 71
62end
63r = efi 13 0 Outb 0 get Outlen 0
64if ne r get Outlen 0
65exit 70
66end
67end
68
69fn lmfail code ulong to void
70outreset
71lmput 5
72emitn get Lmstate 2
73emitb 32
74emitn code
75lmsend
76end
77
78fn lmhex c uchar to ulong
79if and ge c 48 le c 57
80ret sub ulong c 48
81end
82if and ge c 97 le c 102
83ret add sub ulong c 97 10
84end
85ret 256
86end
87
88note Platform output hook: flush every complete decoded token, with no terminal escape injection.
89fn oflush to void
90n = get oon 0
91if eq n 0
92ret
93end
94outreset
95lmput 3
96emitn get Lmstate 2
97emitb 32
98for i ulong n
99c = get oout i
100emitb get Digits ulong shr c 4
101emitb get Digits ulong and c 15
102p = get Lmstate 6
103if lt p 159
104shown = c
105if or lt shown 32 gt shown 126
106shown = 32
107end
108put Lmprev p shown
109put Lmstate 6 add p 1
110end
111end
112lmsend
113put oon 0 0
114end
115
116fn lmrequest to void
117put Lmstate 2 0
118if ne get Lmstate 1 0
119lmfail 1
120ret
121end
122n = get Lmstate 0
123for i ulong n
124put In i get Lmline i
125end
126put Inlen 0 n
127put P 0 0
128put P 2 0
129expect 76
130expect 77
131expect 49
132expect 32
133number
134put Lmstate 2 get P 1
135expect 32
136number
137put Lmstate 3 get P 1
138expect 32
139number
140put Lmstate 4 get P 1
141expect 32
142number
143put Lmstate 5 get P 1
144expect 32
145if ne get P 2 0
146lmfail 2
147ret
148end
149if eq get Lmstate 2 0
150lmfail 3
151ret
152end
153if eq get Lmstate 3 0
154lmfail 3
155ret
156end
157if gt get Lmstate 3 128
158lmfail 3
159ret
160end
161if gt get Lmstate 4 2000
162lmfail 3
163ret
164end
165pos = get P 0
166size = sub n pos
167if or or eq size 0 gt size 318 ne rem size 2 0
168lmfail 4
169ret
170end
171count = div size 2
172for i ulong count
173a = lmhex get Lmline add pos mul i 2
174b = lmhex get Lmline add add pos mul i 2 1
175if or eq a 256 eq b 256
176lmfail 5
177ret
178end
179c = uchar add mul a 16 b
180if or lt c 32 gt c 126
181lmfail 6
182ret
183end
184put ojob add 1024 i c
185put In i c
186end
187put Inlen 0 count
188if not start 1 oms
189lmfail 7
190ret
191end
192put otl 6 count
193put Lmstate 6 0
194outreset
195lmput 2
196emitn get Lmstate 2
197lmsend
198osampleloaded get Lmstate 5 get Lmstate 3 get Lmstate 4
199count = get Lmstate 6
200if eq count 0
201cancel
202else
203for i ulong count
204put In i get Lmprev i
205end
206put Inlen 0 count
207if not answer get R 0 oms
208cancel
209lmfail 8
210ret
211end
212end
213outreset
214lmput 4
215emitn get Lmstate 2
216lmsend
217end
218
219fn main to int
220outreset
221lmput 0
222lmsend
223put otc 0 8
224put otb 2 0
225put otl 2 len Lmck
226for i ulong len Lmck
227put ojob i get Lmck i
228end
229put otb 7 32
230put otl 7 len Lmbpe
231for i ulong len Lmbpe
232put ojob add 32 i get Lmbpe i
233end
234put otb 6 1024
235pl = oargp 2
236sz = efi 12 oefa 0 0 oarg 0 pl
237if oeerr sz
238outreset
239lmput 5
240emitn 0
241emitb 32
242emitn sz
243lmsend
244ret 70
245end
246oeclose
247ockload 2
248obload 7 get og 0
249outreset
250lmput 1
251lmsend
252for session ulong 1000000
253for beat ulong 1000000
254st = efi 1 0 Lmkey 0 4
255if ne st 0
256st = efi 2 1000 Lmkey 0 0
257else
258ch = or ulong get Lmkey 2 shl ulong get Lmkey 3 8
259if eq ch 13
260lmrequest
261put Lmstate 0 0
262put Lmstate 1 0
263else
264if and ge ch 32 le ch 126
265n = get Lmstate 0
266if lt n len Lmline
267put Lmline n uchar ch
268put Lmstate 0 add n 1
269else
270put Lmstate 1 1
271end
272end
273end
274end
275end
276end
277ret 0
278end