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/aienux/blob/main/native/omega/allen/courier.om # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. 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 `aienux / native / omega / allen / courier.om` 261 lines ยท 3836 bytes Raw Blame History 1 note Pure courier datagrams. Q session, current seq, last LINE, head, count. 2 global Q ulong 8 3 global N ulong 8 4 global Queue uchar 2560 5 global Qlens ulong 8 6 global Jbuf uchar 4096 7 global Jhave uchar 5 8 global J ulong 3 9 text Keys "ALLEN-COURIER v=1 run= kind= seq= part= bytes=" 10 text Kinds "JOBLINEGOTACKHELLOHI" 11 fn keyread off ulong count ulong to void 12 for i ulong count 13 expect get Keys add off i 14 end 15 end 16 fn keyemit off ulong count ulong to void 17 for i ulong count 18 emitb get Keys add off i 19 end 20 end 21 fn kindoff k ulong to ulong 22 if eq k 1 23 ret 0 24 end 25 if eq k 2 26 ret 3 27 end 28 if eq k 3 29 ret 7 30 end 31 if eq k 4 32 ret 10 33 end 34 if eq k 5 35 ret 13 36 end 37 ret 18 38 end 39 fn kindlen k ulong to ulong 40 if eq k 2 41 ret 4 42 end 43 if eq k 5 44 ret 5 45 end 46 if eq k 6 47 ret 2 48 end 49 ret 3 50 end 51 fn qbegin run ulong seq ulong to void 52 for i ulong 8 53 put Q i 0 54 end 55 put Q 0 run 56 put Q 1 seq 57 for i ulong 5 58 put Jhave i 0 59 end 60 for i ulong 3 61 put J i 0 62 end 63 end 64 note Serializer takes body In/Inlen; Outb/Outlen are published only on success. 65 fn packet k ulong seq ulong part ulong total ulong bytes ulong to bool 66 if or lt k 1 gt k 6 67 ret false 68 end 69 if gt get Inlen 0 1000 70 ret false 71 end 72 outreset 73 keyemit 0 22 74 for i ulong 16 75 d = and shr get Q 0 mul sub 15 i 4 15 76 emitb get Digits d 77 end 78 keyemit 22 6 79 off = kindoff k 80 for i ulong kindlen k 81 emitb get Kinds add off i 82 end 83 keyemit 28 5 84 emitn seq 85 keyemit 33 6 86 emitn part 87 emitb 47 88 emitn total 89 keyemit 39 7 90 emitn bytes 91 emitb 10 92 for i ulong get Inlen 0 93 emitb get In i 94 end 95 ret eq get Err 0 0 96 end 97 fn pkparse to bool 98 if or gt get Inlen 0 1200 lt get Inlen 0 65 99 ret false 100 end 101 put P 0 0 102 put P 2 0 103 keyread 0 22 104 run = ulong 0 105 for i ulong 16 106 p = get P 0 107 c = get In p 108 d = ulong 16 109 if isdigit c 110 d = sub ulong c 48 111 else 112 if and ge c 97 le c 102 113 d = sub ulong c 87 114 end 115 end 116 if ge d 16 117 ret false 118 end 119 run = or shl run 4 d 120 put P 0 add p 1 121 end 122 if ne run get Q 0 123 ret false 124 end 125 keyread 22 6 126 kind = ulong 0 127 for k ulong 6 128 at = get P 0 129 off = kindoff add k 1 130 size = kindlen add k 1 131 ok = true 132 for i ulong size 133 if not ineq add at i get Kinds add off i 134 ok = false 135 end 136 end 137 if and ok ineq add at size 32 138 kind = add k 1 139 end 140 end 141 if eq kind 0 142 ret false 143 end 144 put N 0 kind 145 put P 0 add get P 0 kindlen kind 146 keyread 28 5 147 number 148 put N 1 get P 1 149 keyread 33 6 150 number 151 put N 2 get P 1 152 expect 47 153 number 154 put N 3 get P 1 155 keyread 39 7 156 number 157 put N 4 get P 1 158 expect 10 159 put N 5 get P 0 160 put N 6 sub get Inlen 0 get P 0 161 ret eq get P 2 0 162 end 163 fn jobtake to ulong 164 note n via N4 165 note part via N2 166 note total via N3 167 if or eq get N 4 0 gt get N 4 4096 168 ret 0 169 end 170 if ne get N 3 div add get N 4 999 1000 171 ret 0 172 end 173 if or eq get N 2 0 gt get N 2 get N 3 174 ret 0 175 end 176 want = ulong 1000 177 if eq get N 2 get N 3 178 want = sub get N 4 mul sub get N 3 1 1000 179 end 180 if ne want get N 6 181 ret 0 182 end 183 if ne get J 0 0 184 if or ne get J 0 get N 4 ne get J 1 get N 3 185 ret 0 186 end 187 end 188 slot = sub get N 2 1 189 off = mul slot 1000 190 if ne get Jhave slot 0 191 for i ulong want 192 if ne get Jbuf add off i get In add get N 5 i 193 ret 0 194 end 195 end 196 ret 2 197 end 198 for i ulong want 199 put Jbuf add off i get In add get N 5 i 200 end 201 put Jhave slot 1 202 put J 0 get N 4 203 put J 1 get N 3 204 put J 2 add get J 2 1 205 ret 1 206 end 207 note Return0 refused,1 accepted,2 duplicate requiring GOT/ACK again. 208 fn qreceive to ulong 209 if not pkparse 210 ret 0 211 end 212 if ne get N 1 get Q 1 213 ret 0 214 end 215 kind = get N 0 216 if eq kind 1 217 ret jobtake 218 end 219 if ne kind 2 220 if ne get N 6 0 221 ret 0 222 end 223 ret 1 224 end 225 note part via N2 226 if eq get N 2 0 227 ret 0 228 end 229 if le get N 2 get Q 2 230 ret 2 231 end 232 if or ne get N 2 add get Q 2 1 eq get Q 4 8 233 ret 0 234 end 235 n = get N 6 236 if or eq n 0 gt n 319 237 ret 0 238 end 239 slot = rem add get Q 3 get Q 4 8 240 for i ulong n 241 put Queue add mul slot 320 i get In add get N 5 i 242 end 243 put Qlens slot n 244 put Q 4 add get Q 4 1 245 put Q 2 get N 2 246 ret 1 247 end 248 fn qtake to bool 249 if eq get Q 4 0 250 ret false 251 end 252 slot = get Q 3 253 n = get Qlens slot 254 for i ulong n 255 put In i get Queue add mul slot 320 i 256 end 257 put Inlen 0 n 258 put Q 3 rem add slot 1 8 259 put Q 4 sub get Q 4 1 260 ret true 261 end