Capsule blocks steps 3+4 for v4: capsules are placed in RAM and load their lowest block

Captain Bob ruled: Block n lands at n-R; the lowest block is
interpreted; chaining is the developer's; together, v4 first.
- v4_blocks_place_capsule copies each Block n into RAM block n - R as 16
  lines of 64, space-padded, in any file order. A later block of the
  same number overwrites. It refuses a block below R.
- The mesh's load(), its capsule reader (CAPSULE-OPEN/(LINES), so a
  child's forth79.4th via BIRTH too), boot.c and test_host_unit's model
  each place a capsule, then interpret "<lowest> LOAD".
- mkdictionary.py skips --> when it types capsules at the hosted prompt.
- The v4 capsules are renumbered into R..2R-1, landing at RAM 1900 and
  up, away from POST's blocks 0-5. Each is chained with -->, and
  centre.4th's gap at 8103 is closed.

Test first:
- test_host_blocks.c gained 6 placement checks; it failed to build
  before.
- test_mesh_boot.c checks forth79's lowest block in RAM block 1900; it
  failed before.

After: POST is 990/990; all 52 tests at 64 bits, test-32, hosted-check
and ASan/UBSan pass; the amd64 kernel builds; the dictionary has 404
words.

Logs are in logs/20261118-capsule-place.

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-18 20:33:21 +00:00
parent bcfca9fa19
commit 6dcfbe6740
27 changed files with 1399 additions and 97 deletions
+40
View File
@@ -7,6 +7,7 @@
* through v3's own calls.
*/
#include "v4/blocks.h"
#include "starkernel/capsule_blocks.h"
#include "block_subsystem.h"
static void let_go(v4_blocks *w)
@@ -162,3 +163,42 @@ int v4_blocks_serve(v4_blocks *w, v4_node *n, v4_cell request)
v4_dstack_push(&n->ds, (v4_cell)status);
return 1;
}
/* ---- a capsule of FORTH blocks, placed in RAM (blocks.h) ------------------------------ */
int v4_blocks_place_capsule(const uint8_t *p, const uint8_t *end, uint32_t *lowest)
{
uint8_t *b = 0;
uint32_t dest = 0;
unsigned line = 0;
int placed = 0;
while (p && p < end) {
const uint8_t *after, *nl;
uint32_t num;
unsigned len, i;
if (capsule_block_header(p, end, &num, &after)) {
if (b && blk_update(dest) != BLK_OK) return -1;
if (num < BLK_RAM_USER_BLOCKS) return -1;
dest = num - BLK_RAM_USER_BLOCKS;
b = blk_get_buffer(dest, 1);
if (!b) return -1;
for (i = 0; i < V4_BLOCK_CELLS * 4u; i++) b[i] = ' ';
if (placed == 0 || dest < *lowest) *lowest = dest;
placed++; line = 0; p = after;
continue;
}
for (nl = p; nl < end && *nl != '\n'; nl++) { }
len = (unsigned)(nl - p);
if (len && p[len - 1] == '\r') len--;
if (b) {
if (len > 64u || line >= 16u) return -1;
for (i = 0; i < len; i++) b[64u * line + i] = p[i];
line++;
}
p = nl < end ? nl + 1 : end;
}
if (b && blk_update(dest) != BLK_OK) return -1;
return placed;
}