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.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * visor_machine.h -- Omega Visor V1, lane 5: machine view (read-only). |
| 19 | * |
| 20 | * Shows the canonical OmegaMachineGraph the Visor realizes against. In V1 no |
| 21 | * physics descriptor is ingested, so every view is an ASSUMED canonical |
| 22 | * profile (observed=false); provenance records what the host reported |
| 23 | * verbatim and where it does not match the profile's own labels. |
| 24 | */ |
| 25 | #ifndef OMEGA_VISOR_MACHINE_H |
| 26 | #define OMEGA_VISOR_MACHINE_H |
| 27 | |
| 28 | #include <stdbool.h> |
| 29 | #include <stddef.h> |
| 30 | #include <stdint.h> |
| 31 | |
| 32 | #include "omega_machine.h" |
| 33 | |
| 34 | #define VISOR_MACHINE_MAX_TARGETS 4 |
| 35 | #define VISOR_TARGET_AARCH64 "aarch64-v8a" |
| 36 | #define VISOR_TARGET_DGX_SPARK "dgx-spark" |
| 37 | #define VISOR_TARGET_QEMU_VIRT "qemu-virt" |
| 38 | #define VISOR_TARGET_BLACKWELL "blackwell-gb10-sm121" |
| 39 | |
| 40 | typedef struct { |
| 41 | const char *type_name; |
| 42 | uint32_t count, latency, throughput; |
| 43 | } VisorMachineUnit; |
| 44 | |
| 45 | typedef struct { |
| 46 | uint32_t level; |
| 47 | bool is_instruction; |
| 48 | uint64_t size; |
| 49 | uint32_t line, assoc, latency; |
| 50 | } VisorMachineCache; |
| 51 | |
| 52 | typedef struct { |
| 53 | char name[32]; |
| 54 | char machine_id[72]; |
| 55 | bool linked; /* code for this target is linked into this binary */ |
| 56 | bool runnable; /* Visor `run` may execute realizations for it */ |
| 57 | const char *note; |
| 58 | } VisorMachineTarget; |
| 59 | |
| 60 | typedef struct { |
| 61 | char name[64]; |
| 62 | char id_text[72]; |
| 63 | uint8_t target_profile; |
| 64 | bool observed; /* false = assumed canonical profile (always in V1) */ |
| 65 | char provenance[384]; |
| 66 | uint32_t issue_width, max_in_flight; |
| 67 | bool out_of_order; |
| 68 | size_t unit_count; |
| 69 | VisorMachineUnit units[OMEGA_MACHINE_MAX_UNITS]; |
| 70 | uint32_t gpr_count, gpr_width, vec_count, vec_width; |
| 71 | size_t cache_count; |
| 72 | VisorMachineCache caches[OMEGA_MACHINE_MAX_CACHES]; |
| 73 | uint64_t dram_base, dram_size; |
| 74 | bool physics_authorized; /* the graph's flag, as stored */ |
| 75 | bool physics_seal_is_placeholder; /* canonical builder constant seal, not a receipt */ |
| 76 | bool topology_valid; |
| 77 | char topology_error[96]; |
| 78 | size_t target_count; |
| 79 | VisorMachineTarget targets[VISOR_MACHINE_MAX_TARGETS]; |
| 80 | } VisorMachineView; |
| 81 | |
| 82 | /* Host facts used to pick a canonical profile (uname / DMI sysfs / cpuinfo). */ |
| 83 | typedef struct { |
| 84 | char uname_machine[32]; |
| 85 | char dmi_product[64]; |
| 86 | char cpu_parts[64]; /* distinct "CPU part" values, sorted, comma separated */ |
| 87 | } VisorHostFacts; |
| 88 | |
| 89 | int visor_machine_host_facts(VisorHostFacts *out); |
| 90 | |
| 91 | /* Pick a canonical profile from host facts (pure; testable): |
| 92 | * dgx_spark when uname==aarch64 AND (DMI product mentions DGX_Spark / DGX Spark |
| 93 | * OR a CPU part is 0xd4f = Neoverse-V2), else qemu_virt. observed is ALWAYS false. */ |
| 94 | int visor_machine_from_facts(const VisorHostFacts *f, OmegaMachineGraph *out_mg, |
| 95 | VisorMachineView *out_view); |
| 96 | |
| 97 | /* visor_machine_from_facts(visor_machine_host_facts()). */ |
| 98 | int visor_machine_current(OmegaMachineGraph *out_mg, VisorMachineView *out_view); |
| 99 | |
| 100 | /* Describe any machine graph (observed=false, generic provenance). */ |
| 101 | int visor_machine_view(const OmegaMachineGraph *mg, VisorMachineView *out); |
| 102 | |
| 103 | /* Deterministic text / JSON. Return bytes written (excluding NUL) or -1 when truncated. */ |
| 104 | int visor_machine_format_text(const VisorMachineView *v, char *out, size_t n); |
| 105 | int visor_machine_format_json(const VisorMachineView *v, char *out, size_t n); |
| 106 | |
| 107 | /* Blackwell GB10 target id via omega_blackwell_get_machine_id when that object |
| 108 | * is linked (weak reference). Returns 0 and fills id, or -1 when not linked. */ |
| 109 | int visor_machine_blackwell_id(SemanticId *out_id); |
| 110 | |
| 111 | const char *visor_machine_unit_name(ComputeUnitType t); |
| 112 | |
| 113 | #endif /* OMEGA_VISOR_MACHINE_H */ |