feat(kernel): a stick offered to a waiting mint, not attached or refused (#92, 4.4) [skip ci]

sk_v4_identity_offer_wait() beats until a stick that is not this system's arrives (offered), a key is pressed, or the system stick leaves; sk_v4_identity_recheck_offered() runs the arrival check again once the mint has written it. Builds on three ISAs; not yet called.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
Claude
2026-11-08 18:12:54 +00:00
parent e94cd3245d
commit cfa60fd0ec
3 changed files with 55 additions and 1 deletions
+43
View File
@@ -95,6 +95,11 @@ static struct {
static gpt_part_t g_gpt_parts[SK_V4_GPT_PARTS];
static uint64_t g_last_beat;
/* MINT-ZUSE (plan 2026-10-29-stick-5, Task 4): while a mint waits for a
* stick, one that arrives and is not this system's stick is offered to it,
* not refused; it is remembered here until the mint is done with it */
static int g_mint_waiting;
static sk_v4_drive_t *g_offered;
static const BootDisk *g_boot_disk; /* the loader's: the disk it booted from */
static int g_stick_in; /* a stick's Artemis partition is attached */
@@ -275,6 +280,13 @@ static int sk_v4_drive_arrived(sk_v4_drive_t *d)
d->used = (blkio_dev_t *)0;
d->art_used = (blkio_dev_t *)0;
gpt_rc = gpt_read(&d->raw, g_gpt_parts, SK_V4_GPT_PARTS, &nparts);
/* a mint waits: any stick that is not this system's, and can be read, is
* offered to it -- blank, foreign, or with a table that does not check out */
if (g_mint_waiting && !g_offered && gpt_rc != GPT_EIO &&
!(gpt_rc == GPT_OK && sk_v4_is_this_stick(nparts))) {
g_offered = d;
return 1;
}
if (gpt_rc == GPT_BAD) {
console_println("GPT: a USB drive has a damaged partition table -- not used");
return 1;
@@ -357,6 +369,8 @@ static void sk_v4_drive_left(sk_v4_drive_t *d)
{
blkio_dev_t *dev = d->used;
if (d == g_offered) g_offered = (sk_v4_drive_t *)0; /* the offered stick, pulled */
if (dev) {
d->used = (blkio_dev_t *)0;
blk_subsys_detach_device(dev);
@@ -439,6 +453,35 @@ void sk_v4_identity_check_now(void)
sk_v4_idle();
}
int sk_v4_identity_offer_wait(blkio_dev_t **raw, uint64_t *bytes)
{
int got = 0;
g_offered = (sk_v4_drive_t *)0;
g_mint_waiting = 1;
for (;;) {
sk_v4_identity_beat();
if (g_offered) { got = 1; break; }
if (!g_stick_in) break; /* the system stick left */
if (sk_input_getc() >= 0) break; /* any key stops it */
arch_halt();
}
g_mint_waiting = 0;
if (got) {
*raw = &g_offered->raw;
*bytes = (uint64_t)g_offered->raw.total_blocks * BLKIO_FORTH_BLOCK_SIZE;
}
return got;
}
void sk_v4_identity_recheck_offered(void)
{
sk_v4_drive_t *d = g_offered;
g_offered = (sk_v4_drive_t *)0;
if (d) (void)sk_v4_drive_arrived(d);
}
/* What was typed at a headless machine -- on the serial line or any
* keyboard -- is no one's: it is read and dropped, so that it does not run
* as whoever logs in next (the identity gate's final review, item 4,