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 / svc / setup_inv.h

161 lines · 6765 bytes Raw Blame History
1/* setup_inv.h -- what Allen knows about the computer he woke up on, for the
2 * setup wizard (svc/setup_wizard.h): graphics cards, screens and their modes,
3 * processors, memory, disks, USB devices, ACPI tables, the network around it
4 * (other AienOS machines, the gateway) and the language models already there.
5 *
6 * Two sources fill one inventory:
7 * 1. the machine itself: what this kernel finds (PCI, the screen mode the
8 * firmware set, the processor count, the disks); added with si_add_*;
9 * 2. a host description, when AienOS runs inside a launcher (aienos-run):
10 * the launcher sees the real computer around the virtual one (its
11 * graphics card, its screens, its model folders, its running model
12 * servers) and hands that over as text, one item per line:
13 *
14 * gpu vendor=10de device=2684 name="NVIDIA GeForce RTX 4090" vram_mib=24564 driver="NVIDIA 560.94"
15 * display name="Dell AW2723DF" w=2560 h=1440 hz=60 max_w=2560 max_h=1440 max_hz=240 vrr=1
16 * cpu name="AMD Ryzen 9 7950X" fast=16 efficient=0 threads=32
17 * ram mib=65536
18 * disk name="Samsung 990 PRO" gib=2000 kind=nvme
19 * usb name="Logitech G502 mouse"
20 * acpi tables="FACP APIC MCFG HPET"
21 * peer name="spark" kind=aienos addr=10.0.0.20 model="qwen3.8-27b-fp8" params_b10=270 url="http://10.0.0.20:18091"
22 * gateway addr=10.0.0.1
23 * model source=ollama name="llama3.1:8b" params_b10=80 bits10=48 mib=4700 path="/home/a/.ollama/models"
24 * server source=lmstudio name="qwen2.5-7b" url="http://127.0.0.1:1234"
25 * machine name="Games PC" from=host
26 *
27 * Keys are words, values are bare words or "quoted" (no escapes; a
28 * quote cannot appear inside). Unknown item kinds and unknown keys are
29 * skipped and counted, so an older Allen reads a newer launcher's text.
30 * '#' starts a comment line. Nothing in it is trusted for safety: it
31 * only changes what Allen says and suggests.
32 *
33 * Freestanding: no libc, no heap, integers only. Host tested in
34 * svc/tests/setup_wizard_test.c. */
35#ifndef AIENOS_SETUP_INV_H
36#define AIENOS_SETUP_INV_H
37#include <stdint.h>
38
39#define SI_NAME 48u
40#define SI_URL 96u
41#define SI_GPUS 4u
42#define SI_DISPLAYS 4u
43#define SI_DISKS 6u
44#define SI_USB 8u
45#define SI_PEERS 6u
46#define SI_MODELS 8u
47
48enum si_from { SI_FROM_HERE = 0, SI_FROM_HOST = 1 };
49
50/* how a graphics card is driven */
51enum si_gpu_kind { SI_GPU_UNKNOWN = 0, SI_GPU_DISCRETE, SI_GPU_INTEGRATED, SI_GPU_VIRTUAL, SI_GPU_UNIFIED };
52
53typedef struct {
54 uint16_t vendor, device;
55 char name[SI_NAME];
56 uint32_t vram_mib; /* its own memory; for a unified chip, what it may use */
57 char driver[SI_NAME]; /* who drives it now ("" none, or the vendor's driver and version) */
58 uint8_t kind, from;
59} si_gpu;
60
61typedef struct {
62 char name[SI_NAME];
63 uint16_t w, h, hz; /* the mode it runs now (hz 0: not known) */
64 uint16_t max_w, max_h, max_hz; /* the best mode it offers */
65 uint8_t vrr, from; /* variable refresh (G-Sync / FreeSync) */
66} si_display;
67
68typedef struct {
69 char name[SI_NAME];
70 uint16_t fast, efficient, threads; /* cores by class; efficient 0 for one class only */
71 uint8_t from;
72} si_cpu;
73
74enum si_disk_kind { SI_DISK_UNKNOWN = 0, SI_DISK_NVME, SI_DISK_SSD, SI_DISK_HDD, SI_DISK_VIRTUAL };
75typedef struct {
76 char name[SI_NAME];
77 uint32_t gib;
78 uint8_t kind, from;
79} si_disk;
80
81enum si_peer_kind { SI_PEER_AIENOS = 1, SI_PEER_PRINTER, SI_PEER_NAS, SI_PEER_OTHER };
82typedef struct {
83 char name[SI_NAME];
84 char addr[40];
85 char model[SI_NAME]; /* the model it serves ("" none) */
86 char url[SI_URL]; /* where it serves it */
87 uint16_t params_b10; /* that model's size, tenths of a billion parameters */
88 uint8_t kind;
89} si_peer;
90
91/* where a language model was found */
92enum si_model_src {
93 SI_SRC_OLLAMA = 1,
94 SI_SRC_LMSTUDIO,
95 SI_SRC_LLAMACPP, /* a GGUF file on a disk */
96 SI_SRC_SERVER, /* something answering the OpenAI shape on this computer */
97 SI_SRC_PEER, /* another AienOS machine on the network */
98 SI_SRC_PAIR, /* Allen's own model pair (27B + 30B working together) */
99};
100typedef struct {
101 char name[SI_NAME];
102 char where[SI_URL]; /* a folder or a URL */
103 uint16_t params_b10, bits10; /* 0: not known */
104 uint32_t mib; /* size on disk, 0: not known */
105 uint8_t src, running; /* running: answering now (a server) */
106} si_model;
107
108typedef struct {
109 char machine[SI_NAME]; /* what the host calls itself ("" none) */
110 int host; /* a host description was read */
111 si_gpu gpu[SI_GPUS];
112 unsigned ngpu;
113 si_display display[SI_DISPLAYS];
114 unsigned ndisplay;
115 si_cpu cpu; /* the processor (the host's when there is one, else this machine's) */
116 uint32_t ram_mib;
117 si_disk disk[SI_DISKS];
118 unsigned ndisk;
119 char usb[SI_USB][SI_NAME];
120 unsigned nusb;
121 unsigned npci; /* PCI functions this kernel found */
122 char acpi[64]; /* ACPI table signatures, space separated */
123 char gateway[40]; /* "" not found */
124 si_peer peer[SI_PEERS];
125 unsigned npeer;
126 si_model model[SI_MODELS];
127 unsigned nmodel;
128 unsigned skipped; /* host lines or keys not understood */
129} si_inv;
130
131void si_init(si_inv *v);
132
133/* Reads a host description (n bytes, not NUL-terminated). Returns the number
134 * of items taken; v->host is set when at least one was. */
135unsigned si_parse(si_inv *v, const char *text, unsigned n);
136
137/* What the kernel found itself (SI_FROM_HERE). Full lists keep the first. */
138void si_add_gpu(si_inv *v, uint16_t vendor, uint16_t device, uint32_t pci_class);
139void si_add_display(si_inv *v, uint16_t w, uint16_t h);
140void si_add_cpus(si_inv *v, unsigned count, const char *name);
141void si_add_disk(si_inv *v, const char *name, uint64_t bytes, uint8_t kind);
142void si_add_ram(si_inv *v, uint64_t bytes);
143
144/* PCI vendor id -> a plain name ("NVIDIA", "AMD", "Intel", ...; "a" when unknown). */
145const char *si_vendor(uint16_t vendor);
146
147/* The best graphics card for running a model: the most memory (-1: none). */
148int si_best_gpu(const si_inv *v);
149
150/* Plain-English lines saying what Allen found, at most max, each at most cap
151 * bytes with its NUL, in the order of FIRST_RUN_UX screen 5: "Screen: ...",
152 * "Graphics: NVIDIA GeForce RTX 4090, 24 GB of its own memory", ...
153 * Returns the count. */
154unsigned si_summary(const si_inv *v, char (*out)[96], unsigned max);
155
156/* small freestanding text helpers shared by the setup files */
157unsigned si_len(const char *s);
158unsigned si_copy(char *d, const char *s, unsigned cap);
159unsigned si_cat(char *d, unsigned at, const char *s, unsigned cap);
160unsigned si_num(char *d, unsigned at, uint32_t v, unsigned cap);
161#endif