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/gpu/intel/xe/records.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 / gpu / intel / xe / records.om` 187 lines ยท 2690 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note records.om: pure seeded-Omega Linux drm/xe ioctl wire-record serializer (mirrors gpu/amd/kfd/records.om). 3 note Usage: records TABLE RECORD_INDEX [FIELD_VALUE ...] 4 note Serializes the indexed record from requests.tsv to stdout in little-endian wire format. 5 note No field values -> zero-filled record. Otherwise one unsigned decimal value per scalar field slot. 6 note Exit: 0 emitted; 2 bad numeric input; 3 malformed table/record; 64 usage; 74 I/O error. 7 om2 8 9 global gpath uchar 4096 10 global garg uchar 64 11 global gbuf uchar 256 12 global grb uchar 1 13 global grfd int 1 14 15 fn rbyte to ulong 16 r = read get grfd 0 grb 0 1 17 if eq r 0 18 ret 256 19 end 20 if ne r 1 21 exit 74 22 end 23 ret ulong get grb 0 24 end 25 26 fn tnum to ulong 27 c = rbyte 28 while true bound 999999 29 if eq c 256 30 exit 3 31 end 32 if eq c 35 33 while ne c 10 bound 999999 34 c = rbyte 35 if eq c 256 36 exit 3 37 end 38 end 39 c = rbyte 40 continue 41 end 42 if or eq c 32 or eq c 9 or eq c 10 eq c 13 43 c = rbyte 44 continue 45 end 46 break 47 end 48 if or lt c 48 gt c 57 49 exit 3 50 end 51 v = sub c 48 52 while true bound 999999 53 c = rbyte 54 if eq c 256 55 ret v 56 end 57 if eq c 35 58 while ne c 10 bound 999999 59 c = rbyte 60 if eq c 256 61 ret v 62 end 63 end 64 ret v 65 end 66 if or eq c 32 or eq c 9 or eq c 10 eq c 13 67 ret v 68 end 69 if or lt c 48 gt c 57 70 exit 3 71 end 72 v = add mul v 10 sub c 48 73 end 74 ret v 75 end 76 77 fn parseu ai ulong to ulong 78 n = argread ai garg 0 len garg 79 if or le n 0 gt n 20 80 exit 2 81 end 82 v = ulong 0 83 for i ulong ulong n 84 c = get garg i 85 if or lt c 48 gt c 57 86 exit 2 87 end 88 v = add mul v 10 ulong sub c 48 89 end 90 ret v 91 end 92 93 fn putle off ulong w ulong v ulong to void 94 for k ulong w 95 put gbuf add off k uchar and shr v mul k 8 255 96 end 97 end 98 99 fn skip_recs want ulong to void 100 rec = ulong 0 101 while lt rec want bound 256 102 req = tnum 103 sz = tnum 104 nf = tnum 105 for i ulong nf 106 o = tnum 107 w = tnum 108 cnt = tnum 109 end 110 rec = add rec 1 111 end 112 end 113 114 fn valid_w w ulong to bool 115 if eq w 1 116 ret true 117 end 118 if eq w 2 119 ret true 120 end 121 if eq w 4 122 ret true 123 end 124 ret eq w 8 125 end 126 127 fn read_fields sz ulong nf ulong ac long to void 128 has_vals = gt ac 3 129 ai = ulong 3 130 for i ulong nf 131 o = tnum 132 w = tnum 133 cnt = tnum 134 if not valid_w w 135 exit 3 136 end 137 if gt add o mul w cnt sz 138 exit 3 139 end 140 for k ulong cnt 141 if has_vals 142 if ge long ai ac 143 exit 2 144 end 145 putle add o mul k w w parseu ai 146 ai = add ai 1 147 end 148 end 149 end 150 if and has_vals ne long ai ac 151 exit 2 152 end 153 end 154 155 fn main to int 156 ac = argcnt 157 if lt ac 3 158 exit 64 159 end 160 pn = argread 1 gpath 0 len gpath 161 if le pn 0 162 exit 64 163 end 164 fd = fopen gpath 0 ulong pn 0 0 165 if lt fd 0 166 exit 74 167 end 168 put grfd 0 int fd 169 skip_recs parseu 2 170 req = tnum 171 sz = tnum 172 nf = tnum 173 if or eq sz 0 gt sz 256 174 c = fclose int fd 175 exit 3 176 end 177 for i ulong sz 178 put gbuf i 0 179 end 180 read_fields sz nf ac 181 c = fclose int fd 182 wr = write 1 gbuf 0 sz 183 if ne wr long sz 184 exit 74 185 end 186 ret 0 187 end