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/aienux/blob/main/native/kernel/gpu/gpu_sim.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / gpu / gpu_sim.h` 95 lines ยท 3542 bytes Raw Blame History 1 /* gpu_sim.h -- a simulated GB10 for host tests of gpu/ (cut D). NOT the chip. 2 * 3 * Memory: one array the tests own (the unified LPDDR window). Registers: 4 * every read and write is logged in order. GPU-side accesses translate 5 * through the page tables in that memory with a decoder written separately 6 * from gmmu.c (from dev_mmu.h directly), through a small TLB that only a 7 * completed invalidate empties, so a missing invalidate shows up as a stale 8 * translation. A fault is recorded and the access does not touch memory. 9 * 10 * Simulator choices where the docs are silent are marked SIM-CHOICE. 11 * Limitation: a completed invalidate matches TLB entries by PDB address 12 * only; the PDB aperture bit is not checked here (the register-log test 13 * in test_gpu_sim.c is the guard for its encoding). */ 14 #ifndef CK_GPU_SIM_H 15 #define CK_GPU_SIM_H 16 17 #include 18 #include "gmmu.h" 19 #include "gpu_chan.h" 20 21 #define CK_GSIM_LOG_MAX 512u 22 #define CK_GSIM_TLB 16u 23 #define CK_GSIM_FAULTS 16u 24 #define CK_GSIM_CHANS 4u 25 26 enum ck_gsim_fault_kind { 27 CK_GSIM_F_UNMAPPED = 1, /* PDE aperture INVALID or PTE VALID=0 */ 28 CK_GSIM_F_BAD_PDE, /* PTE bit set at PD4/PD3, where the format has no PTE */ 29 CK_GSIM_F_APERTURE, /* VIDMEM or PEER: GB10 has neither (INFERRED, unified memory) */ 30 CK_GSIM_F_RO_WRITE, /* write through a read-only PCF */ 31 CK_GSIM_F_OUTSIDE, /* table or page physical address outside the memory array */ 32 }; 33 34 struct ck_gsim_reg_ev { 35 uint32_t off; 36 uint32_t val; 37 uint8_t write; 38 }; 39 40 struct ck_gsim_fault { 41 uint64_t va; 42 uint64_t pdb; 43 uint32_t kind; 44 uint8_t write; 45 }; 46 47 struct ck_gsim_tlb { 48 uint64_t pdb, va_page, pa_page, page; 49 uint32_t pte_lo; /* low 12 bits of the PTE: aperture, PCF, kind */ 50 uint8_t valid; 51 }; 52 53 struct ck_gsim_chan { 54 struct ck_gpu_chan_desc d; 55 uint32_t gp_get; 56 uint32_t words_read; 57 uint8_t bound, faulted, disabled; 58 }; 59 60 struct ck_gsim { 61 struct ck_gpu_window mem; 62 struct ck_gsim_reg_ev log[CK_GSIM_LOG_MAX]; 63 uint32_t nlog, log_dropped; 64 /* invalidate engine */ 65 uint32_t pdb_lo, pdb_hi; 66 uint32_t inval_pending, inval_left, inval_latency, inval_stuck, inval_done, inval_all; 67 /* TLB and faults */ 68 struct ck_gsim_tlb tlb[CK_GSIM_TLB]; 69 uint32_t tlb_next, tlb_hits; 70 struct ck_gsim_fault faults[CK_GSIM_FAULTS]; 71 uint32_t nfaults; 72 /* channels */ 73 struct ck_gsim_chan chan[CK_GSIM_CHANS]; 74 uint32_t doorbells, doorbell_unknown; 75 uint32_t hang; /* channels never go idle and never consume (teardown timeout tests) */ 76 uint32_t idle_polls; 77 }; 78 79 void ck_gsim_init(struct ck_gsim *s, uint8_t *mem, uint64_t pa_base, uint64_t size); 80 /* Register file for the code under test. */ 81 struct ck_gpu_regs ck_gsim_regs(struct ck_gsim *s); 82 /* Channel control the code under test calls (stands in for GSP RPC/CHRAM). */ 83 struct ck_gpu_chan_ops ck_gsim_chan_ops(void); 84 85 /* GPU-side 32-bit access through the address space whose PD4 is at pdb. 86 * Returns 0 or the fault kind (and records it). */ 87 uint32_t ck_gsim_gpu_read32(struct ck_gsim *s, uint64_t pdb, uint64_t va, uint32_t *out); 88 uint32_t ck_gsim_gpu_write32(struct ck_gsim *s, uint64_t pdb, uint64_t va, uint32_t val); 89 /* Translate without touching the TLB or recording a fault (test oracle). */ 90 uint32_t ck_gsim_walk(const struct ck_gsim *s, uint64_t pdb, uint64_t va, int write, uint64_t *pa, uint64_t *page, 91 uint32_t *pte_lo); 92 93 const struct ck_gsim_chan *ck_gsim_chan(const struct ck_gsim *s, uint32_t chid); 94 95 #endif