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/svc/setup_store.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 / svc / setup_store.h` 42 lines ยท 1922 bytes Raw Blame History 1 /* setup_store.h -- the setup wizard's records on Allen's disk section, just 2 * after his memory and notes (allen_memory.h): two copies, so a power cut in 3 * the middle of a save spoils only the copy being written. 4 * 5 * unit CK_SETUP_FIRST copy A unit CK_SETUP_FIRST + 1 copy B 6 * 7 * One copy is one unit (4096 bytes): 8 * 0 "AIENSET1" 8 bytes 9 * 8 version (1) u32 little endian 10 * 12 text length u32 (at most CK_SETUP_TEXT) 11 * 16 generation u64, +1 on every save 12 * 24 zero 8 bytes 13 * 32 SHA-256 of bytes 0..31 and the text 14 * 64 the text: printable ASCII and newlines (svc/setup_wizard.h: the saved 15 * step, then llm.conf and the consent record, each starting with its 16 * own first line); never a key: sw_save and sw_llm_conf hold none 17 * 64+len zero to the end of the unit (a copy with any other byte there is 18 * not valid: the SHA-256 does not cover it) 19 * A save writes generation g+1 over the older copy, flushes, reads it back 20 * and checks it. Loading keeps the valid copy with the highest generation. 21 * Freestanding; host tested in svc/tests/setup_wizard_test.c. */ 22 #ifndef AIENOS_SETUP_STORE_H 23 #define AIENOS_SETUP_STORE_H 24 #include 25 #include "disk.h" 26 #include "allen_memory.h" 27 28 #define CK_SETUP_FIRST CK_ALLEN_DISK_UNITS 29 #define CK_SETUP_UNITS 2u 30 #define CK_SETUP_TEXT (CK_ALLEN_MEM_UNIT - 64u) 31 32 typedef struct { 33 const disk_dev *dev; /* the AIENOS partition view */ 34 uint64_t gen; /* newest valid copy's generation, 0 none */ 35 unsigned newest; 36 } ck_setup_store; 37 38 /* 0 and text (NUL-terminated, *n bytes), 1 when no valid copy (a first start), or <0 (CK_ALLEN_MEM_E*). */ 39 int ck_setup_load(ck_setup_store *st, const disk_dev *part, char *text, unsigned cap, unsigned *n); 40 /* 0, or <0; on error the previous newest copy is untouched. */ 41 int ck_setup_save(ck_setup_store *st, const char *text, unsigned n); 42 #endif