feat(kernel): v4 boots in the kernel's boot -- the Stadium, its checks, the opcode patrons

#189, ENGINE step 4, Phase 1 (plan 2026-11-13-engine-step4-phase1), Tasks
1-4. Captain Bob, 2026-11-13: Q1 "A new node key", Q2 "Per heartbeat
tick", Q3 "All of v3's", Q4 "In Phase 1" / "Full births now", who runs
next "Hera by compudynamics now" (Task 5, to come).

- stadium.c/.h: stadium_node_key(node) ("NODE" | number),
  stadium_boot_init_for(first), stadium_birth_node(key, name);
  stadium_boot_init() and stadium_birth_hera() are them for Hera's key, so
  v3's path is as it was (only an impossible panic's words changed).
- kernel_main.c: the system is chosen and said first, then the Stadium,
  sessions, switch-signal and kernel-Hermes tables for both systems in
  v3's order; v4: Hera, node 10, patron zero under her node key, the word,
  block and opcode layers. The quota self-test and the heartbeat's line
  are functions now, called by both systems.
- sk_v4.c/.h: sk_v4_run() goes -- sk_v4_boot() returns, the kernel's
  checks after POST (opcodes, words, conservation, quota, heartbeat), then
  sk_v4_prompt(). sk_v4_charge_opcodes() at the heartbeat's service points
  (the key wait, after each line) and once after POST.
- stadium_ops.c/.h: a node's 32 opcodes as Stadium patrons (HEAT-OP's
  feed, "Both"): retirements charged as the word layer's dispatches, a
  quantum each, the reservoir's floor kept, shared by retirements when
  short; cooling per tick as words. ~0.5 us a charge on the host: kept.
- qemu_session.py: a v4 acceptance boot fails without "Stadium: N cells",
  "Stadium conservation: CONSERVED" and the heartbeat's ticks (#189).

Tests first (logs/20261113-122142): the physics check failed on the v4
boot; test_stadium_node, test_stadium_ops (and its share case, after a
real boot showed ";" taking all the heat) failed before. Now: kernel host
tests all pass; amd64 v4 boot passes, POST 539/539, dict_hash unchanged,
"Stadium opcodes: 30 resident, hottest opcode 8", CONSERVED; a system=v3
boot prints its Stadium lines as on 2026-11-06.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-13 12:50:02 +00:00
parent 3f4988e19e
commit b1cac339c1
35 changed files with 959 additions and 85 deletions
+21 -6
View File
@@ -183,7 +183,18 @@ static void console_put_u64(uint64_t v) {
console_puts(&buf[i]);
}
VMUuid stadium_node_key(uint32_t node) {
VMUuid k;
k.hi = STADIUM_NODE_KEY_HI;
k.lo = (uint64_t)node;
return k;
}
int stadium_boot_init(void) {
return stadium_boot_init_for(vm_uuid_hera());
}
int stadium_boot_init_for(VMUuid first) {
/* Budgeted from kmalloc_get_stats(), not pmm_get_stats() (corrected
* 2026-08-15 -- see this function's doc in stadium.h): kmalloc_init()
* (M6) already carved its own fixed-size heap out of PMM before this
@@ -283,7 +294,7 @@ int stadium_boot_init(void) {
quotas[i].consumed = 0;
}
}
quotas[0].vm_id = vm_uuid_hera();
quotas[0].vm_id = first; /* Hera on v3's path, the first node on v4's (#189) */
quotas[0].in_use = 1;
quotas[0].free_head = 0;
quotas[0].free_count = ncells;
@@ -811,6 +822,10 @@ int stadium_conserved(VMUuid vm_id) {
* must not break that.
*/
int stadium_birth_hera(void) {
return stadium_birth_node(vm_uuid_hera(), "Hera");
}
int stadium_birth_node(VMUuid key, const char *name) {
StadiumPatronHeader candidate;
size_t idx;
@@ -831,19 +846,19 @@ int stadium_birth_hera(void) {
candidate.flags = 0;
candidate.behaviour = (uint8_t)STADIUM_BEHAVIOUR_COOL;
idx = stadium_admit(vm_uuid_hera(), &candidate);
idx = stadium_admit(key, &candidate);
if (idx == STADIUM_CELL_NONE) return -1; /* refused; should not happen (quota is fresh and empty) */
if (idx != STADIUM_HERA_CELL_INDEX) {
sk_hal_panic("Stadium: birth_hera did not land on cell 0 -- patron-zero invariant broken");
sk_hal_panic("Stadium: the first patron did not land on cell 0 -- patron-zero invariant broken");
}
{
Session *s = session_register(vm_uuid_hera(), vm_uuid_hera(), "Hera");
Session *s = session_register(key, key, name);
if (s) {
s->stadium_cell = idx;
session_set_pinned(vm_uuid_hera(), 1);
session_set_pinned(key, 1);
} else {
console_println("Stadium: session_register failed for Hera (session.c not yet initialized?)");
console_println("Stadium: session_register failed for the first patron (session.c not yet initialized?)");
}
}