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-mv/blob/main/om/runtime/rx_coherent_om2.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / om / runtime / rx_coherent_om2.om` 72 lines ยท 1562 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: AGPL-3.0-only 3 note Pure seeded OM-2 coherent projection primitives backing src/runtime/rx_coherent.c: 4 note Castagnoli CRC32C, ring message validation, required rights, and fault code mapping. 5 6 const CRC32C_POLY ulong 0x82f63b78 7 const U32_MASK ulong 0xffffffff 8 9 note Compute Castagnoli CRC32C over data[0..n-1]. 10 export fn rx_coh_crc32c data view uchar * n ulong to ulong 11 c = U32_MASK 12 for i ulong n bound 65536 13 b = ulong get data i 14 c = xor c b 15 for bit ulong 8 16 low = and c 1 17 c = shr c 1 18 if ne low 0 19 c = xor c CRC32C_POLY 20 end 21 end 22 end 23 ret and xor c U32_MASK U32_MASK 24 end 25 26 note Validate coherent ring message type. Returns 1 if valid, 0 otherwise. 27 export fn rx_coh_ring_msg t ulong to ulong 28 if eq t 0x0003 29 ret 1 30 end 31 if and ge t 0x0010 le t 0x0015 32 ret 1 33 end 34 ret 0 35 end 36 37 note Return required capability right for ring message type: READ (1) or WRITE (2). 38 export fn rx_coh_msg_rights t ulong to ulong 39 if eq t 0x0003 40 ret 1 41 end 42 if or eq t 0x0010 eq t 0x0011 43 ret 1 44 end 45 if or eq t 0x0013 eq t 0x0014 46 ret 1 47 end 48 ret 2 49 end 50 51 note Map OMEGA_SW_FAULT_* / RX_FAULT_* to RX_ERR_*. 52 export fn rx_coh_fault_err fault ulong to long 53 if or eq fault 0x0004 eq fault 0x0105 54 ret -3 55 end 56 if eq fault 0x0005 57 ret -21 58 end 59 if or eq fault 0x0008 eq fault 0x0103 60 ret -22 61 end 62 if or eq fault 0x0007 or eq fault 0x0101 eq fault 0x0104 63 ret -20 64 end 65 if eq fault 0x0102 66 ret -4 67 end 68 if eq fault 0x0106 69 ret -24 70 end 71 ret -23 72 end