interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / kernel / core / dmar.h

48 lines · 1921 bytes Raw Blame History
1/* Intel VT-d firmware inventory only. No register access or DMA authority.
2 * Source: Intel VT-d Architecture Specification rev. 5.0, sections 8.1-8.4
3 * https://cdrdv2-public.intel.com/831418/vt-directed-io-spec.pdf */
4#ifndef AIENOS_CK_DMAR_H
5#define AIENOS_CK_DMAR_H
6#include <stddef.h>
7#include <stdint.h>
8
9#define CK_DMAR_MAX_BYTES 65536u
10#define CK_DMAR_MAX_UNITS 8u
11#define CK_DMAR_MAX_REGIONS 16u
12#define CK_DMAR_MAX_SCOPES 64u
13#define CK_DMAR_MAX_PATH 8u
14#define CK_DMAR_BAD_TABLE (-1)
15#define CK_DMAR_CAPACITY (-2)
16#define CK_DMAR_UNSUPPORTED (-3)
17
18struct ck_dmar_unit {
19 uint64_t base;
20 uint32_t register_bytes;
21 uint16_t segment;
22 uint8_t include_all;
23};
24struct ck_dmar_region {
25 uint64_t base, limit; /* inclusive, not an allocation or a granted window */
26 uint16_t segment;
27};
28struct ck_dmar_scope {
29 uint16_t owner; /* index into unit[] (kind 0) or region[] (kind 1) */
30 uint8_t kind, type, enumeration_id, start_bus, npath;
31 struct { uint8_t device, function; } path[CK_DMAR_MAX_PATH];
32};
33struct ck_dmar {
34 uint32_t bytes, nunits, nregions, nscopes, nother;
35 uint8_t address_bits, flags;
36 struct ck_dmar_unit unit[CK_DMAR_MAX_UNITS];
37 struct ck_dmar_region region[CK_DMAR_MAX_REGIONS];
38 struct ck_dmar_scope scope[CK_DMAR_MAX_SCOPES];
39};
40/* Bounded parse of exactly one DMAR table. Checks the supplied buffer span,
41 * table checksum, nested lengths, reserved fields and storage capacities.
42 * Success is an inventory, never proof that protection is enabled. Other
43 * structure types are counted and skipped as required for forward compatibility.
44 * Unknown scope types or revisions are UNSUPPORTED. Any failure clears out.
45 * Multi-hop paths remain paths: resolving their final requester ID requires
46 * reading each bridge's secondary bus, not guessing it from the last hop. */
47int ck_dmar_parse(const void *table, size_t available, struct ck_dmar *out);
48#endif