Artemis bus-agnostic discovery: signature format + idle-loop generalization (FABRIC-3.md §XXVI follow-on)
Build / build-amd64-iso (push) Canceled after 0s
Build / build-aarch64-iso (push) Canceled after 0s
Build / build-riscv64-img (push) Canceled after 0s

Step 1: new artemis_sig_t header format (magic 'ARTM', sibling to
homeblocks_sig_t, distinct so a generic scan can tell Artemis's own disk
apart from an identity thumbdrive by content alone) -- artemis_sig.h/.c,
wired into Makefile.starkernel.

Step 2: sk_repl_idle()'s existing per-USB-MSC-slot attach handling (the
pattern WIREBIND already uses for identity thumbdrives) now also checks
for the ARTM signature whenever a device's home-blocks check comes back
BLANK. On a match, once Artemis's own storage-attach round-trip
(HERA-BLK-ATTACH-REQ/BLK-ATTACH-ACK) confirms success,
capsule_zuse_boot_load_root_pubkey() runs -- the same call kernel_main.c's
synchronous QEMU-only virtio-blk path already makes, now reachable
without a hardcoded PCI vendor/device scan. That function is already
idempotent (no-op once zuse_root_pubkey_known is set), so no boot
restructuring was needed despite the initial concern that deferring
Artemis discovery to the idle loop would require one.

Verified: clean build + QEMU boot to [zuse@Hera] ok> on all three
architectures, zero regression to the existing virtio-blk/Zuse-thumbdrive
attach path.

Steps 3 (genesis-stamping onto disk/artemis.img) and 4 (growable
production log-persistence region) not yet started.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXieurDfDSsDFdnSyusuWo
This commit is contained in:
Robert Allan James
2026-09-13 07:16:48 -04:00
co-authored by Claude Sonnet 5
parent a8b16d41da
commit 29b6789860
8 changed files with 27473 additions and 8 deletions
+69 -5
View File
@@ -39,6 +39,7 @@
#include "starkernel/blkio_usb.h"
#include "starkernel/kmalloc.h"
#include "starkernel/homeblocks_sig.h"
#include "starkernel/artemis_sig.h"
#include "starkernel/capsule_birth.h"
#include "starkernel/capsule_zuse_boot.h"
#include "starkernel/capsule_wirebind.h"
@@ -158,6 +159,22 @@ blkio_dev_t *sk_repl_get_attached_blk_dev(void) {
return g_attached_blk_dev;
}
/* FABRIC-3.md §XXVI follow-on (2026-09-13): Artemis's own disk, once found
* generically via USB-MSC content signature (artemis_sig_t, 'ARTM') rather
* than the QEMU-only PCI virtio-blk vendor/device scan kernel_main.c still
* does synchronously at boot. Mirrors g_homeblocks_dev's own accessor
* shape. NULL on QEMU (virtio-blk finds Artemis before this file's idle
* loop ever runs) and on any boot where no USB-MSC device presents the
* 'ARTM' signature -- real bare-metal hardware is the case this exists
* for. Set once sk_word_blk_attach_ack() below confirms the storage-attach
* succeeded for a device this loop already recognized as Artemis's own;
* cleared on detach alongside g_homeblocks_dev/g_attached_blk_dev. */
static blkio_dev_t *g_artemis_usb_dev = (void *)0;
blkio_dev_t *sk_repl_get_artemis_usb_dev(void) {
return g_artemis_usb_dev;
}
/* Storage-attach messaging migration (Bob, 2026-09-07): Hera keeps
* polling/sig-checking, but no longer registers a newly-attached drive
* into the block subsystem herself -- that's Artemis's own domain now,
@@ -190,6 +207,14 @@ typedef struct {
int pending;
homeblocks_sig_result_t sig_rc;
homeblocks_sig_t sig;
/* FABRIC-3.md §XXVI follow-on: set when the attach loop below already
* recognized this device as Artemis's own disk (artemis_sig_t 'ARTM'
* check, only attempted when sig_rc is HOMEBLOCKS_SIG_BLANK -- a
* device can't be both an identity thumbdrive and Artemis's disk).
* The ack handler uses this to run capsule_zuse_boot_load_root_pubkey()
* once storage-attach is confirmed, same as kernel_main.c's own
* virtio-blk path already does synchronously. */
int is_artemis;
} sk_blk_attach_pending_t;
static sk_blk_attach_pending_t *g_blk_attach_pending = (void *)0;
@@ -227,8 +252,25 @@ static void sk_word_blk_attach_ack(VM *vm) {
if (ms) ms->bot_msc_attached = 1;
g_attached_blk_dev = dev;
homeblocks_sig_result_t sig_rc = g_blk_attach_pending[found_slot].sig_rc;
homeblocks_sig_t sig = g_blk_attach_pending[found_slot].sig;
homeblocks_sig_result_t sig_rc = g_blk_attach_pending[found_slot].sig_rc;
homeblocks_sig_t sig = g_blk_attach_pending[found_slot].sig;
int is_artemis = g_blk_attach_pending[found_slot].is_artemis;
if (is_artemis) {
/* FABRIC-3.md §XXVI follow-on: bus-agnostic Artemis discovery.
* Mirrors kernel_main.c's own virtio-blk-found branch exactly
* (blk_subsys_attach_device() there is this device's equivalent,
* already done for us above via HERA-BLK-ATTACH-REQ/BLK-ATTACH --
* ok_flag being true is that confirmation). Safe to call even if
* virtio-blk already found Artemis first (the common QEMU case,
* since that path runs synchronously before this idle loop ever
* gets a beat): capsule_zuse_boot_load_root_pubkey() is a no-op
* once mama_vm->zuse_root_pubkey_known is already set. */
g_artemis_usb_dev = dev;
log_message(LOG_INFO, "xhci: Artemis's own disk attached via USB-MSC");
capsule_zuse_boot_load_root_pubkey((VM *)sk_get_mama_vm());
}
capsule_zuse_boot_try_attach(dev, sig_rc, &sig, (VM *)sk_get_mama_vm());
if (sig_rc == HOMEBLOCKS_SIG_OK) {
capsule_wirebind_try_attach(dev, &sig, (VM *)sk_get_mama_vm());
@@ -441,6 +483,27 @@ static void sk_repl_idle(VM *active_vm)
break;
}
/* FABRIC-3.md §XXVI follow-on: a device isn't an identity
* thumbdrive (sig_rc above came back BLANK, i.e. no 'LAHB'
* magic) -- check whether it's Artemis's own disk instead
* (distinct 'ARTM' magic, same devblock-1 convention). Only
* attempted on BLANK, not on every device: a drive that
* already checked out as home-blocks (or failed a home-blocks
* version/CRC check) can't also be Artemis's disk, and
* skipping the second read keeps the common identity-drive
* case down to one signature check per attach, same as
* before this feature existed. */
int is_artemis_disk = 0;
if (sig_rc == HOMEBLOCKS_SIG_BLANK) {
artemis_sig_t asig;
artemis_sig_result_t art_rc =
artemis_sig_check(usb_blk_dev, ARTEMIS_SIG_START_FBLOCK, &asig);
if (art_rc == ARTEMIS_SIG_OK) {
log_message(LOG_DEBUG, "xhci: USB drive recognized as Artemis's own disk");
is_artemis_disk = 1;
}
}
/* FABRIC-2.md §F.20/§F.21 / §F.5/§F.23 (WIREBIND): Zuse
* genesis-mint/attach-authenticate and regular-identity
* verify-then-birth-then-pair both used to run synchronously,
@@ -451,9 +514,10 @@ static void sk_repl_idle(VM *active_vm)
* no longer happens on top of storage that might not have
* registered. Stash what that deferred call needs. */
if (g_blk_attach_pending) {
g_blk_attach_pending[slot_id].pending = 1;
g_blk_attach_pending[slot_id].sig_rc = sig_rc;
g_blk_attach_pending[slot_id].sig = sig;
g_blk_attach_pending[slot_id].pending = 1;
g_blk_attach_pending[slot_id].sig_rc = sig_rc;
g_blk_attach_pending[slot_id].sig = sig;
g_blk_attach_pending[slot_id].is_artemis = is_artemis_disk;
}
/* Storage-attach registration (blk_subsys_attach_device(),