aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / core / fact_req.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* fact_req.h -- the card fact request file of the Pi Cortex qualification image |
| 18 | * (PI5-5, build flag CK_PI5_FACT, only with CK_PI5_UNLOCK_CARD). |
| 19 | * |
| 20 | * QUALIFICATION ONLY. Nothing reads the Pi's serial port during a run, so the run tool may place |
| 21 | * \EFI\AIENOS\FACT.REQ on the card's EFI partition holding ONE short fact. The UEFI stub |
| 22 | * (native/boot/efi_fact.c) reads it before ExitBootServices; after the Store is open the fact stage |
| 23 | * (svc/pi5_fact.c) appends it to the Cortex journal of the sealed Store, the same record |
| 24 | * `remember <text>` writes in the service lifecycle. The run tool deletes the file after the run. |
| 25 | * A fact is not a secret, but the file is still a labelled qualification input, not a user interface. |
| 26 | * |
| 27 | * File layout, exactly 512 bytes, little endian, everything else zero: |
| 28 | * 0 magic "AIENFCT1" |
| 29 | * 8 version 1 |
| 30 | * 12 flags 0 |
| 31 | * 16 tag "QUALIF-FACT-DATA" (16 ASCII bytes, no NUL) |
| 32 | * 32 length of the fact, 1..48 |
| 33 | * 36 reserved 0 |
| 34 | * 40 fact text, printable ASCII 0x20..0x7e, `length` bytes, then zero to byte 88 |
| 35 | * 88 zero padding to 512 */ |
| 36 | #ifndef AIENOS_CK_FACT_REQ_H |
| 37 | #define AIENOS_CK_FACT_REQ_H |
| 38 | #include <stddef.h> |
| 39 | #include <stdint.h> |
| 40 | |
| 41 | #define CK_FACT_REQ_MAGIC "AIENFCT1" |
| 42 | #define CK_FACT_REQ_TAG "QUALIF-FACT-DATA" |
| 43 | #define CK_FACT_REQ_VERSION 1u |
| 44 | #define CK_FACT_REQ_SIZE 512u |
| 45 | #define CK_FACT_REQ_TEXT_MAX 48u |
| 46 | #define CK_FACT_REQ_PATH "\\EFI\\AIENOS\\FACT.REQ" |
| 47 | |
| 48 | struct ck_fact_req { |
| 49 | uint8_t magic[8]; |
| 50 | uint32_t version; |
| 51 | uint32_t flags; |
| 52 | uint8_t tag[16]; |
| 53 | uint32_t len; |
| 54 | uint32_t reserved; |
| 55 | uint8_t text[CK_FACT_REQ_TEXT_MAX]; |
| 56 | uint8_t pad[CK_FACT_REQ_SIZE - 88]; |
| 57 | }; |
| 58 | |
| 59 | /* 0 = well formed; else -1 and *why names the first failed check. */ |
| 60 | int ck_fact_req_check(const struct ck_fact_req *q, const char **why); |
| 61 | |
| 62 | enum { CK_FACT_REQ_NONE = 0, CK_FACT_REQ_ABSENT = 1, CK_FACT_REQ_REFUSED = 2, CK_FACT_REQ_FOUND = 3 }; |
| 63 | |
| 64 | /* What the UEFI stub found (the stub and the kernel are one image). */ |
| 65 | struct ck_fact_req_boot { |
| 66 | int state; /* CK_FACT_REQ_* */ |
| 67 | uint32_t len; /* only while FOUND */ |
| 68 | uint8_t text[CK_FACT_REQ_TEXT_MAX]; /* only while FOUND */ |
| 69 | }; |
| 70 | extern struct ck_fact_req_boot ck_fact_req_boot; |
| 71 | |
| 72 | void ck_fact_req_store(const struct ck_fact_req *q); /* the stub stores a checked request */ |
| 73 | void ck_fact_req_clear(void); /* one-shot: the fact stage wipes it after use */ |
| 74 | #endif |