physics-mv
FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.
Brought by drakestapleton
physics-mv / m15 / physics_accel_native.h
| 1 | #ifndef PHYSICS_ACCEL_NATIVE_H |
| 2 | #define PHYSICS_ACCEL_NATIVE_H |
| 3 | |
| 4 | #include "physics_accel.h" |
| 5 | #include <stdbool.h> |
| 6 | #include <stdint.h> |
| 7 | #include <stddef.h> |
| 8 | |
| 9 | #define SMMU_V3_1_AUTO_BASE 0x13000000ULL |
| 10 | #define SMMU_V3_1_AUTO_SIZE 0x00020000ULL /* 128 KiB */ |
| 11 | #define GB10_STREAM_ID 0x0100 /* 256 decimal: Segment 15 BDF 01:00.0 */ |
| 12 | #define GB10_PCI_BDF_STRING "000f:01:00.0" |
| 13 | #define GB10_PCI_VENDOR_ID 0x10de |
| 14 | #define GB10_PCI_DEVICE_ID 0x2e12 |
| 15 | #define GB10_BAR0_BASE 0x24000000ULL |
| 16 | #define GB10_BAR0_SIZE 0x04000000ULL /* 64 MiB */ |
| 17 | #define DGX_SPARK_DRAM_BASE 0x0000000080000000ULL |
| 18 | #define DGX_SPARK_DRAM_SIZE 0x0000002000000000ULL /* 128 GiB */ |
| 19 | |
| 20 | /* ========================================================================= */ |
| 21 | /* 1. HARDWARE OBSERVATION: Live Host Device Probe Record */ |
| 22 | /* ========================================================================= */ |
| 23 | |
| 24 | typedef struct { |
| 25 | bool present; |
| 26 | bool smmu_matched; |
| 27 | bool device_matched; |
| 28 | uint32_t stream_id; |
| 29 | uint64_t smmu_base; |
| 30 | char smmu_name[64]; |
| 31 | uint64_t bar0_base; |
| 32 | uint64_t bar0_size; |
| 33 | uint32_t iommu_group; |
| 34 | char pci_bdf[32]; |
| 35 | uint16_t vendor_id; |
| 36 | uint16_t device_id; |
| 37 | char device_name[64]; |
| 38 | bool coherent_unified_dram; |
| 39 | } Smmuv3NativeProbe; |
| 40 | |
| 41 | /* ========================================================================= */ |
| 42 | /* 2. HARDWARE OWNERSHIP BOUNDARIES: Explicit Subsystem Governance */ |
| 43 | /* ========================================================================= */ |
| 44 | |
| 45 | typedef struct { |
| 46 | const char *subsystem; |
| 47 | const char *current_owner; |
| 48 | const char *physics_status; |
| 49 | const char *transfer_plan; |
| 50 | } HardwareOwnershipBoundary; |
| 51 | |
| 52 | /* ========================================================================= */ |
| 53 | /* 3. CORE ROUTINES & CLASSIFICATIONS */ |
| 54 | /* ========================================================================= */ |
| 55 | |
| 56 | /* CLASSIFICATION: HARDWARE OBSERVATION |
| 57 | * Inspects live Linux sysfs for physical device, SMMUv3 base, BDF, and BAR0. |
| 58 | * Performs NO register writes and makes NO unproven architectural claims. */ |
| 59 | int physics_accel_native_probe(Smmuv3NativeProbe *out_probe); |
| 60 | |
| 61 | /* CLASSIFICATION: HARDWARE BOUNDARY CHARACTERIZATION |
| 62 | * Verifies live DGX Spark accelerator topology against physical reality. */ |
| 63 | int physics_accel_native_verify_hardware_boundary(Smmuv3NativeProbe *out_probe); |
| 64 | |
| 65 | /* CLASSIFICATION: HARDWARE OWNERSHIP BOUNDARY RECORD |
| 66 | * Returns canonical table documenting active subsystem ownership. */ |
| 67 | const HardwareOwnershipBoundary *physics_accel_get_hardware_ownership_boundaries(size_t *out_count); |
| 68 | |
| 69 | /* CLASSIFICATION: HARDWARE BOUNDARY RECEIPT COMMIT |
| 70 | * Commits formal 192-byte EffectReceipt binding measured hardware topology. */ |
| 71 | int physics_accel_native_commit_boundary_receipt(PhysicsAcceleratorLink *link, |
| 72 | const Smmuv3NativeProbe *probe, |
| 73 | EffectReceipt *out_receipt); |
| 74 | |
| 75 | /* ========================================================================= */ |
| 76 | /* 4. MODEL / DISCOVERY PLACEHOLDERS (Intentionally deferred to M16) */ |
| 77 | /* The following functions represent software simulations or discovery */ |
| 78 | /* scaffolding. They are EXPLICITLY NOT QUALIFIED AS PHYSICAL CONTROL. */ |
| 79 | /* Native Blackwell submission protocol is the subject of Milestone 16. */ |
| 80 | /* ========================================================================= */ |
| 81 | |
| 82 | typedef struct { |
| 83 | uint64_t iova; |
| 84 | uint64_t phys_base; |
| 85 | uint64_t size_bytes; |
| 86 | uint32_t permissions; |
| 87 | bool coherent; |
| 88 | void *vaddr; |
| 89 | } DmaModelMapping; |
| 90 | |
| 91 | typedef struct { |
| 92 | uint64_t ring_phys_base; |
| 93 | uint8_t *ring_vaddr; |
| 94 | uint32_t slot_count; |
| 95 | uint32_t slot_size; |
| 96 | uint32_t head_index; |
| 97 | uint32_t tail_index; |
| 98 | bool active; |
| 99 | } ModelCommandRing; |
| 100 | |
| 101 | /* CLASSIFICATION: MODEL / PLACEHOLDER (Hardware translation owned by Linux SMMU driver) */ |
| 102 | int physics_accel_model_map_dma(const Smmuv3NativeProbe *probe, |
| 103 | uint64_t iova, |
| 104 | uint64_t size_bytes, |
| 105 | uint32_t perms, |
| 106 | DmaModelMapping *out_map); |
| 107 | |
| 108 | /* CLASSIFICATION: MODEL / PLACEHOLDER */ |
| 109 | int physics_accel_model_unmap_dma(DmaModelMapping *map); |
| 110 | |
| 111 | /* CLASSIFICATION: MODEL / PLACEHOLDER (Queue layout deferred to M16) */ |
| 112 | int physics_accel_model_ring_init(DmaModelMapping *map, |
| 113 | ModelCommandRing *out_ring); |
| 114 | |
| 115 | /* CLASSIFICATION: MODEL / PLACEHOLDER (No guessed MMIO writes in M15) */ |
| 116 | int physics_accel_model_ring_doorbell(uint64_t doorbell_phys_reg, uint32_t token); |
| 117 | |
| 118 | /* CLASSIFICATION: MODEL / PLACEHOLDER (Completion mechanism deferred to M16) */ |
| 119 | int physics_accel_model_observe_completion(ModelCommandRing *ring); |
| 120 | |
| 121 | /* CLASSIFICATION: MODEL / PLACEHOLDER (Raw reset registers deferred to M16) */ |
| 122 | int physics_accel_model_reset(Smmuv3NativeProbe *probe, |
| 123 | ModelCommandRing *ring, |
| 124 | DmaModelMapping *map); |
| 125 | |
| 126 | #endif /* PHYSICS_ACCEL_NATIVE_H */ |