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
+26 -5
View File
@@ -18,8 +18,8 @@
* and a console exists only while Zuse's drive is attached and checked
* (sk_v4_identity.c; ENGINE.md 2, ruled 2026-10-20).
*
* This is the lone node, started before the kernel's fleet and beside it.
* It goes when the node is brought up in the VM's place (ENGINE.md step 4).
* The kernel brings it up in its own boot, after the Stadium (#189, ENGINE.md step 4,
* Phase 1): sk_v4_boot(), the kernel's checks after POST, then sk_v4_prompt().
*
* Nothing of the v3 VM is started. docs/v4.0.0/DECOMPOSITION.md.
*/
@@ -33,6 +33,10 @@
#include "starkernel/timer.h"
#include "v4/boot.h"
#include "block_subsystem.h"
#ifdef STARFORTH_ENABLE_VM
#include "starkernel/vm/stadium.h"
#include "starkernel/vm/stadium_ops.h"
#endif
#define SK_V4_LINE 1024u /* what the line editor here takes: a line, as the boot takes one (v4/system/boot.c) */
@@ -52,6 +56,16 @@ static char sk_v4_text[SK_V4_LINE + 1u];
* above them, and the kernel's real chain is set up afterwards. */
static uint8_t sk_v4_post_blk_ram[BLK_RAM_BLOCKS * BLK_FORTH_SIZE];
/* HEAT-OP into the Stadium (#189; Captain Bob: "Per heartbeat tick"): the node's opcode counts are
* charged to its opcode patrons at the heartbeat's service points -- where its host waits for a key,
* a tick at a time, and after each line. */
void sk_v4_charge_opcodes(void)
{
#ifdef STARFORTH_ENABLE_VM
stadium_ops_charge(stadium_node_key(SK_V4_HERA_NODE), sk_v4_heat.op, heartbeat_ticks());
#endif
}
static void sk_v4_out(const char *text, unsigned len)
{
unsigned i;
@@ -123,6 +137,7 @@ static int sk_v4_readline(void)
} else {
heartbeat_service();
}
sk_v4_charge_opcodes();
/* Nothing typed: wait for the next interrupt, not in a spin (#151 -- the spin kept a
* CPU core 100% busy at the prompt, and the demo's host with it). The heartbeat's
* timer wakes it at 100 Hz, so a key is seen within a tick, as the blink and the
@@ -148,10 +163,11 @@ static int sk_v4_readline(void)
}
}
void sk_v4_run(void (*chain)(void), const BootDisk *boot_disk)
{
v4_boot boot;
/* The node's boot record: sk_v4_boot() fills it, sk_v4_prompt() hands it lines. */
static v4_boot boot;
void sk_v4_boot(void (*chain)(void), const BootDisk *boot_disk)
{
console_println("StarForth v4: one host node, the F18-derived engine");
sk_v4_image = v4_map_image;
boot.n = &sk_v4_node; boot.es = &sk_v4_es; boot.h = &sk_v4_heat; boot.im = &sk_v4_image;
@@ -177,7 +193,10 @@ void sk_v4_run(void (*chain)(void), const BootDisk *boot_disk)
console_fb_mirror(1);
console_fb_enable_ttf();
#endif
}
void sk_v4_prompt(void)
{
/* The prompt is the host's: read a line, hand it to the node, say how it
* ended. */
for (;;) {
@@ -185,6 +204,8 @@ void sk_v4_run(void (*chain)(void), const BootDisk *boot_disk)
int how;
int logged_out = 0;
sk_v4_charge_opcodes(); /* what the last line retired (#189) */
#if !EMERGENCY_CONSOLE_ENABLED
/* no identity, no console: headless until Zuse's drive is checked.
* The drives are looked at first, now: one pulled while the last