feat(v4.0.0): every node asks the kernel for its blocks; a born node is not POSTed
A block is a kernel request, as ENGINE.md 3.3 has it: the node puts the
block's number and the address of 256 cells on its stack and writes the
request to port 0, and the kernel leaves the status there. The requests
are -1, read, and -2, write, the same for every node. v4/system/blocks.c
serves them from the kernel's block subsystem, which is v3's. The four
storage registers are gone from the engine.
The device that spoke block messages (4a505a15) is withdrawn with its
test and its message types: Captain Bob ruled on 2026-10-07 that it, a
node's own drive, and nodes with no storage had left the OS as designed
(docs/v4.0.0/MESH.md 8.5).
Hera no longer sends POST to the nodes she births: POST is the kernel's,
once. Every node has its kernel on port 0; it serves a node's blocks and,
for Hera alone, her requests for nodes and capsules.
Bare metal: the node boots and is POSTed against POST's own block RAM,
and the kernel's chain -- fast RAM, the ramdrive, the virtio disk -- is
set up after POST and before the prompt, as on the v3 path. The disk is
read and not written: nothing in v4 yet gives the owner's word that it
may be formatted. A hosted program has the chain's fast RAM, as hosted
v3 has with no disk. Error 17 is Storage refused.
make -C v4 test and sanitize pass at both widths; hosted-check passes on
three ISAs; amd64, aarch64 and riscv64 boot, POST 538 of 538, with the
typed session: logs/20261007-081603, -081839, -082226. The hashes are
the same on all six.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
26a0748455
commit
d5b7235464
@@ -18,43 +18,6 @@ void v4_node_reset(v4_node *n)
|
||||
v4_node_stack_regs_attach(n, -1, -1);
|
||||
v4_node_error_attach(n, -1);
|
||||
v4_node_port_attach(n, -1);
|
||||
v4_node_storage_attach(n, -1, 0, 0);
|
||||
}
|
||||
|
||||
void v4_node_storage_attach(v4_node *n, v4_cell reg, unsigned char *bytes, unsigned blocks)
|
||||
{
|
||||
n->storage_reg = reg;
|
||||
n->storage = bytes;
|
||||
n->storage_blocks = blocks;
|
||||
}
|
||||
|
||||
/* BLOCK-COMMAND: do it, and leave the status in BLOCK-STATUS. */
|
||||
static void storage_command(v4_node *n, v4_cell command)
|
||||
{
|
||||
v4_cell num = n->mem[n->storage_reg], addr = n->mem[n->storage_reg + 1];
|
||||
unsigned char *b;
|
||||
unsigned i;
|
||||
|
||||
n->mem[n->storage_reg + 3] = (v4_cell)-1;
|
||||
if (!n->storage || num < 0 || (v4_ucell)num >= (v4_ucell)n->storage_blocks) return;
|
||||
if (!v4_node_addr_ok(addr) || !v4_node_addr_ok(addr + (v4_cell)(V4_BLOCK_CELLS - 1u))) return;
|
||||
b = n->storage + (size_t)num * V4_BLOCK_BYTES;
|
||||
if (command == 1) {
|
||||
for (i = 0; i < V4_BLOCK_CELLS; i++)
|
||||
n->mem[addr + (v4_cell)i] = (v4_cell)((v4_ucell)b[4u * i] | ((v4_ucell)b[4u * i + 1u] << 8)
|
||||
| ((v4_ucell)b[4u * i + 2u] << 16) | ((v4_ucell)b[4u * i + 3u] << 24));
|
||||
} else if (command == 2) {
|
||||
for (i = 0; i < V4_BLOCK_CELLS; i++) {
|
||||
v4_ucell w = (v4_ucell)n->mem[addr + (v4_cell)i];
|
||||
b[4u * i] = (unsigned char)(w & 0xFFu);
|
||||
b[4u * i + 1u] = (unsigned char)((w >> 8) & 0xFFu);
|
||||
b[4u * i + 2u] = (unsigned char)((w >> 16) & 0xFFu);
|
||||
b[4u * i + 3u] = (unsigned char)((w >> 24) & 0xFFu);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
n->mem[n->storage_reg + 3] = 0;
|
||||
}
|
||||
|
||||
void v4_node_error_attach(v4_node *n, v4_cell addr)
|
||||
@@ -137,8 +100,6 @@ void v4_node_store(v4_node *n, v4_cell addr, v4_cell value)
|
||||
if (addr == n->rstack_reg) { v4_rstack_clear(&n->rs); return; }
|
||||
if (!v4_node_addr_ok(addr)) return;
|
||||
n->mem[(unsigned)addr] = value;
|
||||
/* BLOCK-COMMAND. storage_reg is -1 when no device is attached. */
|
||||
if (n->storage_reg >= 0 && addr == n->storage_reg + 2) { storage_command(n, value); return; }
|
||||
/* NODE-ERROR: a non-zero code raises an error. -1 when not attached. */
|
||||
if (addr == n->error_reg && value != 0) v4_node_fault(n, V4_FAULT_RAISED, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user