Capsule blocks step 1: the RAM block count is a build knob, BLK_RAM_USER_BLOCKS

Captain Bob ruled that the offset is the RAM block count, not a literal
2048.
- v3/include/blk_layout.h defines it, 2048 by default. block_subsystem.h
  derives BLK_RAM_BLOCKS (2080) and BLK_DISK_START from it.
- Kconfig.kernel has the symbol. kernel/Makefile passes it to the
  kernel's C code and builds mkcapsule and mkartemis with it.
- mkcapsule's two literal 2048s are now the knob.

The default value is unchanged, so the layout and the media are as before.

Test first: scripts/test_capsule_ram_blocks.sh, 8 checks.
- The before-run failed 4: the knob did not exist and mkcapsule ignored
  it. Its three Makefile checks also hit a SIGPIPE flaw in the test,
  fixed before the after-run.
- After: all 8 pass.

The amd64 build and mkartemis build clean. All 40 capsules lint. The
mesh boot passes 109 checks with POST 990/990. test_host_blocks,
test_host_quit, test_host_unit and test-32 pass.

Logs are in logs/20261118-ram-blocks-knob.

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 17:35:15 +00:00
parent cda8aad8b2
commit 6f9900f805
14 changed files with 764 additions and 13 deletions
+22
View File
@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
* Copyright (c) 2023-2026 Robert A. James
*/
/* blk_layout.h -- the VM's user RAM block count, the one knob the block layout is derived from.
*
* BLK_RAM_USER_BLOCKS is how many blocks of fast RAM a VM sees (LBN 0 .. BLK_RAM_USER_BLOCKS - 1).
* It is a build knob (Kconfig BLK_RAM_USER_BLOCKS; kernel/Makefile passes it as -D), and the tools
* that make the kernel's media are built with the same value: mkcapsule takes it as its floor --
* a capsule's page `Block n` has n at least this, and is copied down by it to be interpreted --
* and mkartemis lays out a disk by it (block_subsystem.h derives BLK_RAM_BLOCKS and BLK_DISK_START).
* docs/v4.0.0/plans/2026-11-18-capsule-blocks.md, ruling 3 (Captain Bob: "The RAM block count").
*
* Nothing else is in this header, so a host tool can include it alone.
*/
#ifndef BLK_LAYOUT_H
#define BLK_LAYOUT_H
#ifndef BLK_RAM_USER_BLOCKS
#define BLK_RAM_USER_BLOCKS 2048u
#endif
#endif /* BLK_LAYOUT_H */
+3 -2
View File
@@ -68,6 +68,7 @@
#include <stddef.h>
#include "vm.h"
#include "blkio.h" /* ensure struct blkio_dev is fully visible */
#include "blk_layout.h" /* BLK_RAM_USER_BLOCKS, the knob the layout below is derived from */
#ifdef __cplusplus
extern "C" {
@@ -75,8 +76,8 @@ extern "C" {
/* Core configuration constants */
#define BLK_FORTH_SIZE 1024u /* Forth block size */
#define BLK_RAM_BLOCKS 2080u /* Physical RAM blocks (user-visible LBN 0..2047) */
#define BLK_DISK_START 2080u /* Device-backed Forth blocks start at LBN 2080 */
#define BLK_RAM_BLOCKS (BLK_RAM_USER_BLOCKS + BLK_FORTH_SYS_RESERVED) /* Physical RAM blocks: the user's (blk_layout.h; 2048 by default, LBN 0..2047) and the reserved ones -- 2080 by default */
#define BLK_DISK_START BLK_RAM_BLOCKS /* Device-backed Forth blocks start after the RAM blocks: LBN 2080 by default */
#define BLK_DEVICE_SECTOR 4096u /* Physical “devblock” size (4×1 KiB blkio units) */
#define BLK_PACK_RATIO 3u /* 3× 1 KiB data per 4 KiB devblock (plus 1 KiB metadata) */
#define BLK_META_TOTAL 1024u /* Last 1 KiB in a 4 KiB devblock is metadata */