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 / svc / slot_service.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 | /* slot_service.h -- the kernel side of the AIENOS image slots (native v1 |
| 18 | * plan P11 cut 2b, gate N7; docs/NATIVE_IMAGE_SLOTS.md "Kernel promotion"). |
| 19 | * |
| 20 | * Linked only into a CK_SERVICE=1 image. SLOTLDR.EFI hands the kernel one |
| 21 | * boot record (native/boot/slot_format.h, struct ck_slot_boot_record) in a |
| 22 | * page of memory type CK_SLOT_BOOT_MEMTYPE; ck_slot_boot_capture copies it in |
| 23 | * ck_kernel_entry, before the kernel builds its own page tables. The |
| 24 | * lifecycle then calls: |
| 25 | * ck_slot_service_start(healthy) once, after the lifecycle reached its |
| 26 | * first state: abandons an exhausted or |
| 27 | * invalid candidate, promotes a healthy one; |
| 28 | * ck_slot_service_health(healthy) after a successful `unlock`: promotes a |
| 29 | * candidate that was waiting for health; |
| 30 | * ck_slot_service_stop() at the stop order: says when a candidate |
| 31 | * was never promoted (its tries keep |
| 32 | * counting down in the loader). |
| 33 | * healthy = the service health milestone: Store open + continuity committed |
| 34 | * this boot (PROVISIONED or RESUMED: the self-test record) + lifecycle READY. |
| 35 | * |
| 36 | * Every write is one control record commit through the torn-slot protocol |
| 37 | * (ck_slot_control_commit, the same routine as the loader) over the slots |
| 38 | * partition view (dev/devices.c ck_dev_slots_disk); the decision is the pure |
| 39 | * ck_slot_kernel_action (native/boot/slot_select.c). No boot record, an |
| 40 | * invalid one, no slots partition, no control record, a manifest on disk |
| 41 | * that differs from the record, or a control record whose sequence moved |
| 42 | * since the loader read it: the kernel writes nothing and says why. */ |
| 43 | #ifndef CK_SLOT_SERVICE_H |
| 44 | #define CK_SLOT_SERVICE_H |
| 45 | void ck_slot_service_start(int healthy); |
| 46 | void ck_slot_service_health(int healthy); |
| 47 | void ck_slot_service_stop(void); |
| 48 | /* P11 cut 3: operator verb `update` (lifecycle READY only): write the signed |
| 49 | * image in the update inbox partition into the inactive slot and stage it as |
| 50 | * the candidate (native/boot/slot_update.h). Prints one "slot: update ..." |
| 51 | * outcome line. */ |
| 52 | #include <stddef.h> |
| 53 | void ck_slot_service_update(const char *arg, size_t len); |
| 54 | #endif |