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:
@@ -354,7 +354,7 @@ Tasks 1-3 accepted and merged (#159, master 594d2f93); #155 merged with them.
|
|||||||
- [x] 4.1 the first failing test: `qemu_session.py` mode `mint_zuse` and `add_stick(n, img, port)`
|
- [x] 4.1 the first failing test: `qemu_session.py` mode `mint_zuse` and `add_stick(n, img, port)`
|
||||||
- [x] 4.2 run `mint_zuse` on amd64 before any kernel change: FAIL, "UNKNOWN WORD: 'MINT-ZUSE'" (logs/20261108-175928); the prompt check tightened to need the minted line first
|
- [x] 4.2 run `mint_zuse` on amd64 before any kernel change: FAIL, "UNKNOWN WORD: 'MINT-ZUSE'" (logs/20261108-175928); the prompt check tightened to need the minted line first
|
||||||
- [x] 4.3 `gpt_write_one()` in `kernel/src/gpt.c` (one partition, protective MBR, both headers): builds clean on three ISAs; checked on the host (a throwaway harness, not in the tree) -- 600 MiB and 32 MiB blank images and the pair's used Zuse stick each give one identity partition, `gpt_read` reads it back, `sfdisk --verify` clean. Not yet called.
|
- [x] 4.3 `gpt_write_one()` in `kernel/src/gpt.c` (one partition, protective MBR, both headers): builds clean on three ISAs; checked on the host (a throwaway harness, not in the tree) -- 600 MiB and 32 MiB blank images and the pair's used Zuse stick each give one identity partition, `gpt_read` reads it back, `sfdisk --verify` clean. Not yet called.
|
||||||
- [ ] 4.4 `sk_v4_identity_offer_wait()` / `sk_v4_identity_recheck_offered()`: a stick offered, not attached, while a mint waits
|
- [x] 4.4 `sk_v4_identity_offer_wait()` / `sk_v4_identity_recheck_offered()`: a stick offered, not attached, while a mint waits (`g_mint_waiting`, `g_offered` in `sk_v4_identity.c`; any stick not this system's and readable -- blank, foreign or a bad table; ends on a stick, a key, or the system stick leaving). Builds on three ISAs; not yet called.
|
||||||
- [ ] 4.5 `sk_v4_mint.c`: the flow -- plug-in line, size line, `YES`, GPT, zeroed, minted, read back, marker
|
- [ ] 4.5 `sk_v4_mint.c`: the flow -- plug-in line, size line, `YES`, GPT, zeroed, minted, read back, marker
|
||||||
- [ ] 4.6 `MINT-ZUSE` in `sk_v4_words[]` (request 2): word_count 317 -> 318
|
- [ ] 4.6 `MINT-ZUSE` in `sk_v4_words[]` (request 2): word_count 317 -> 318
|
||||||
- [ ] 4.7 the real Zuse stick recognised and attached after the system stick; her session
|
- [ ] 4.7 the real Zuse stick recognised and attached after the system stick; her session
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#define STARKERNEL_V4_SK_V4_IDENTITY_H
|
#define STARKERNEL_V4_SK_V4_IDENTITY_H
|
||||||
|
|
||||||
#include "uefi.h" /* BootDisk */
|
#include "uefi.h" /* BootDisk */
|
||||||
|
#include "blkio.h"
|
||||||
|
|
||||||
/* After POST and the block chain: every xHCI controller brought up, and the
|
/* After POST and the block chain: every xHCI controller brought up, and the
|
||||||
* heartbeat started, as the v3 path does before its headless wait. `boot_disk`
|
* heartbeat started, as the v3 path does before its headless wait. `boot_disk`
|
||||||
@@ -31,6 +32,16 @@ void sk_v4_identity_beat(void);
|
|||||||
* is seen before a prompt is shown. */
|
* is seen before a prompt is shown. */
|
||||||
void sk_v4_identity_check_now(void);
|
void sk_v4_identity_check_now(void);
|
||||||
|
|
||||||
|
/* MINT-ZUSE (plan 2026-10-29-stick-5, Task 4): beat until a stick that is not
|
||||||
|
* this system's arrives -- it is offered, not attached or refused: 1, its raw
|
||||||
|
* device and size in bytes -- or a key is pressed, or the system stick
|
||||||
|
* leaves: 0. */
|
||||||
|
int sk_v4_identity_offer_wait(blkio_dev_t **raw, uint64_t *bytes);
|
||||||
|
|
||||||
|
/* The arrival check run again on the offered stick, now that the mint has
|
||||||
|
* written its GPT and identity (it is then recognised as the real Zuse's). */
|
||||||
|
void sk_v4_identity_recheck_offered(void);
|
||||||
|
|
||||||
/* Headless: no prompt, and what is typed is read and dropped, until Zuse's
|
/* Headless: no prompt, and what is typed is read and dropped, until Zuse's
|
||||||
* session begins (v3's sk_repl_headless_wait()). */
|
* session begins (v3's sk_repl_headless_wait()). */
|
||||||
void sk_v4_identity_wait(void);
|
void sk_v4_identity_wait(void);
|
||||||
|
|||||||
@@ -95,6 +95,11 @@ static struct {
|
|||||||
static gpt_part_t g_gpt_parts[SK_V4_GPT_PARTS];
|
static gpt_part_t g_gpt_parts[SK_V4_GPT_PARTS];
|
||||||
|
|
||||||
static uint64_t g_last_beat;
|
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 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 */
|
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->used = (blkio_dev_t *)0;
|
||||||
d->art_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);
|
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) {
|
if (gpt_rc == GPT_BAD) {
|
||||||
console_println("GPT: a USB drive has a damaged partition table -- not used");
|
console_println("GPT: a USB drive has a damaged partition table -- not used");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -357,6 +369,8 @@ static void sk_v4_drive_left(sk_v4_drive_t *d)
|
|||||||
{
|
{
|
||||||
blkio_dev_t *dev = d->used;
|
blkio_dev_t *dev = d->used;
|
||||||
|
|
||||||
|
if (d == g_offered) g_offered = (sk_v4_drive_t *)0; /* the offered stick, pulled */
|
||||||
|
|
||||||
if (dev) {
|
if (dev) {
|
||||||
d->used = (blkio_dev_t *)0;
|
d->used = (blkio_dev_t *)0;
|
||||||
blk_subsys_detach_device(dev);
|
blk_subsys_detach_device(dev);
|
||||||
@@ -439,6 +453,35 @@ void sk_v4_identity_check_now(void)
|
|||||||
sk_v4_idle();
|
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
|
/* 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
|
* 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,
|
* as whoever logs in next (the identity gate's final review, item 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user