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
omega-mv / src / visor / visor_machine.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Pure seeded OM-2 Visor lane 5: machine view (replaces src/visor/visor_machine.c). |
| 3 | note Depends on visor.om. |
| 4 | |
| 5 | text vmch_n_spark "dgx-spark" |
| 6 | text vmch_n_qemu "qemu-virt" |
| 7 | text vmch_t_a64 "aarch64-v8a" |
| 8 | text vmch_t_bw "blackwell-gb10-sm121" |
| 9 | text vmch_bw_seed "omega.machine.blackwell.gb10.sm121.v1" |
| 10 | text vmch_spark_seed "omega.machine.dgx-spark.v1" |
| 11 | text vmch_qemu_seed "omega.machine.qemu-virt.v1" |
| 12 | text vmch_prov_pfx "assumed: canonical profile (no physics descriptor ingested)" |
| 13 | text vmch_prov_mis "assumed: canonical dgx-spark profile (no physics descriptor ingested; host cores do NOT match Neoverse-V2)" |
| 14 | text vmch_p_dmi "/sys/class/dmi/id/product_name" |
| 15 | text vmch_p_cpu "/proc/cpuinfo" |
| 16 | text vmch_k_dgx "DGX" |
| 17 | text vmch_k_d4f "0xd4f" |
| 18 | text vmch_f1 "machine: " |
| 19 | text vmch_f2 " id: sha256:" |
| 20 | text vmch_f3 " observed: false\n provenance: " |
| 21 | text vmch_f4 " pipeline: issue_width=" |
| 22 | text vmch_f5 " units=" |
| 23 | text vmch_f6 " caches=" |
| 24 | text vmch_f7 " target aarch64-v8a linked=yes runnable=yes\n target blackwell-gb10-sm121 linked=yes runnable=no (requires GPU submit authority)\n" |
| 25 | text vmch_j1 "{\"name\":\"" |
| 26 | text vmch_j2 "\",\"id\":\"sha256:" |
| 27 | text vmch_j3 "\",\"observed\":false,\"provenance\":\"" |
| 28 | text vmch_j4 "\",\"pipeline\":{\"issue_width\":" |
| 29 | text vmch_j5 "},\"registers\":{\"gpr_count\":" |
| 30 | text vmch_j6 "},\"caches\":" |
| 31 | text vmch_j7 ",\"physics_seal_is_placeholder\":true,\"targets\":[{\"name\":\"aarch64-v8a\",\"linked\":true,\"runnable\":true},{\"name\":\"blackwell-gb10-sm121\",\"linked\":true,\"runnable\":false,\"note\":\"requires GPU submit authority\"}]}" |
| 32 | |
| 33 | global vmch_is_spark ulong 1 |
| 34 | global vmch_profile ulong 1 |
| 35 | global vmch_issue ulong 1 |
| 36 | global vmch_units ulong 1 |
| 37 | global vmch_caches ulong 1 |
| 38 | global vmch_gprs ulong 1 |
| 39 | global vmch_topo_ok ulong 1 |
| 40 | global vmch_observed ulong 1 |
| 41 | global vmch_placeholder ulong 1 |
| 42 | global vmch_id uchar 32 |
| 43 | global vmch_bw_id uchar 32 |
| 44 | global vmch_mismatch ulong 1 |
| 45 | global vmch_fbuf uchar 4096 |
| 46 | |
| 47 | fn vmch_hash_seed s view uchar * to void |
| 48 | n = len s |
| 49 | for i ulong n bound 128 |
| 50 | put v_sha_in i get s i |
| 51 | end |
| 52 | sha256_hash n |
| 53 | end |
| 54 | |
| 55 | fn vmch_init_bw_id to void |
| 56 | vmch_hash_seed vmch_bw_seed |
| 57 | for i ulong 32 |
| 58 | put vmch_bw_id i get v_sha_out i |
| 59 | end |
| 60 | end |
| 61 | |
| 62 | fn vmch_build_spark to void |
| 63 | put vmch_is_spark 0 1 |
| 64 | put vmch_profile 0 1 |
| 65 | put vmch_issue 0 4 |
| 66 | put vmch_units 0 6 |
| 67 | put vmch_caches 0 4 |
| 68 | put vmch_gprs 0 31 |
| 69 | put vmch_topo_ok 0 1 |
| 70 | put vmch_observed 0 0 |
| 71 | put vmch_placeholder 0 1 |
| 72 | vmch_hash_seed vmch_spark_seed |
| 73 | for i ulong 32 |
| 74 | put vmch_id i get v_sha_out i |
| 75 | end |
| 76 | vmch_init_bw_id |
| 77 | end |
| 78 | |
| 79 | fn vmch_build_qemu to void |
| 80 | put vmch_is_spark 0 0 |
| 81 | put vmch_profile 0 1 |
| 82 | put vmch_issue 0 2 |
| 83 | put vmch_units 0 5 |
| 84 | put vmch_caches 0 3 |
| 85 | put vmch_gprs 0 31 |
| 86 | put vmch_topo_ok 0 1 |
| 87 | put vmch_observed 0 0 |
| 88 | put vmch_placeholder 0 1 |
| 89 | vmch_hash_seed vmch_qemu_seed |
| 90 | for i ulong 32 |
| 91 | put vmch_id i get v_sha_out i |
| 92 | end |
| 93 | vmch_init_bw_id |
| 94 | end |
| 95 | |
| 96 | fn vmch_validate_topo to long |
| 97 | g = get vmch_gprs 0 |
| 98 | if lt g 16 |
| 99 | put vmch_topo_ok 0 0 |
| 100 | ret -1 |
| 101 | end |
| 102 | put vmch_topo_ok 0 1 |
| 103 | ret 0 |
| 104 | end |
| 105 | |
| 106 | fn vmch_buf_has buf_len ulong needle view uchar * to bool |
| 107 | nl = len needle |
| 108 | if or eq nl 0 gt nl buf_len |
| 109 | ret false |
| 110 | end |
| 111 | lim = add sub buf_len nl 1 |
| 112 | for i ulong lim bound 4096 |
| 113 | ok = true |
| 114 | for j ulong nl bound 64 |
| 115 | if ne get vmch_fbuf add i j get needle j |
| 116 | ok = false |
| 117 | break |
| 118 | end |
| 119 | end |
| 120 | if ok |
| 121 | ret true |
| 122 | end |
| 123 | end |
| 124 | ret false |
| 125 | end |
| 126 | |
| 127 | fn vmch_detect_current to void |
| 128 | put vmch_mismatch 0 0 |
| 129 | is_sp = false |
| 130 | fd = fopen vmch_p_dmi 0 len vmch_p_dmi 0 0 |
| 131 | if ge fd 0 |
| 132 | k = read int fd vmch_fbuf 0 256 |
| 133 | u = fclose int fd |
| 134 | if gt k 0 |
| 135 | if vmch_buf_has ulong k vmch_k_dgx |
| 136 | is_sp = true |
| 137 | end |
| 138 | end |
| 139 | end |
| 140 | fd2 = fopen vmch_p_cpu 0 len vmch_p_cpu 0 0 |
| 141 | if ge fd2 0 |
| 142 | k2 = read int fd2 vmch_fbuf 0 4095 |
| 143 | u2 = fclose int fd2 |
| 144 | if gt k2 0 |
| 145 | if vmch_buf_has ulong k2 vmch_k_d4f |
| 146 | is_sp = true |
| 147 | else |
| 148 | if is_sp |
| 149 | put vmch_mismatch 0 1 |
| 150 | end |
| 151 | end |
| 152 | end |
| 153 | end |
| 154 | if is_sp |
| 155 | vmch_build_spark |
| 156 | else |
| 157 | vmch_build_qemu |
| 158 | end |
| 159 | end |
| 160 | |
| 161 | fn vmch_format_text cap ulong to long |
| 162 | ob_reset cap |
| 163 | ob_puts vmch_f1 |
| 164 | if ne get vmch_is_spark 0 0 |
| 165 | ob_puts vmch_n_spark |
| 166 | else |
| 167 | ob_puts vmch_n_qemu |
| 168 | end |
| 169 | ob_putc uchar 10 |
| 170 | ob_puts vmch_f2 |
| 171 | for i ulong 32 |
| 172 | ob_put_hex_byte ulong get vmch_id i |
| 173 | end |
| 174 | ob_putc uchar 10 |
| 175 | ob_puts vmch_f3 |
| 176 | if ne get vmch_mismatch 0 0 |
| 177 | ob_puts vmch_prov_mis |
| 178 | else |
| 179 | ob_puts vmch_prov_pfx |
| 180 | end |
| 181 | ob_putc uchar 10 |
| 182 | ob_puts vmch_f4 |
| 183 | ob_put_u64 get vmch_issue 0 |
| 184 | ob_puts vmch_f5 |
| 185 | ob_put_u64 get vmch_units 0 |
| 186 | ob_puts vmch_f6 |
| 187 | ob_put_u64 get vmch_caches 0 |
| 188 | ob_putc uchar 10 |
| 189 | ob_puts vmch_f7 |
| 190 | if ne get v_ob_ovf 0 0 |
| 191 | ret -1 |
| 192 | end |
| 193 | ret long get v_ob_len 0 |
| 194 | end |
| 195 | |
| 196 | fn vmch_format_json cap ulong to long |
| 197 | ob_reset cap |
| 198 | ob_puts vmch_j1 |
| 199 | if ne get vmch_is_spark 0 0 |
| 200 | ob_puts vmch_n_spark |
| 201 | else |
| 202 | ob_puts vmch_n_qemu |
| 203 | end |
| 204 | ob_puts vmch_j2 |
| 205 | for i ulong 32 |
| 206 | ob_put_hex_byte ulong get vmch_id i |
| 207 | end |
| 208 | ob_puts vmch_j3 |
| 209 | if ne get vmch_mismatch 0 0 |
| 210 | ob_puts vmch_prov_mis |
| 211 | else |
| 212 | ob_puts vmch_prov_pfx |
| 213 | end |
| 214 | ob_puts vmch_j4 |
| 215 | ob_put_u64 get vmch_issue 0 |
| 216 | ob_puts vmch_j5 |
| 217 | ob_put_u64 get vmch_gprs 0 |
| 218 | ob_puts vmch_j6 |
| 219 | ob_put_u64 get vmch_caches 0 |
| 220 | ob_puts vmch_j7 |
| 221 | if ne get v_ob_ovf 0 0 |
| 222 | ret -1 |
| 223 | end |
| 224 | ret long get v_ob_len 0 |
| 225 | end |