The header scan (Captain Bob, 2026-11-10): 788 source files -- 351 with the
SL-1.0 header, 12 with the old name (docs/working/experiments, kept by
ruling), 31 under someone else's licence (tools/kconfig, Linux's, GPL-2.0:
kept), and 394 with none. Ruled: the SPDX form; capsules (.4th, .f18) and
proofs (.thy) left for a ruling of their own (mkcapsule's 64x16 block format,
content-addressed capsules).
253 files now begin
SPDX-License-Identifier: LicenseRef-Starship-1.0
Copyright (c) 2023-2026 Robert A. James
as a /* */ block (C, headers, assembly, linker scripts) or # lines (scripts,
Makefiles, Kconfig; below a shebang or a coding line); tools/mkcapsule.c,
which had the copyright line, gets the SPDX line only.
Not touched: docs/working/ (archive and old campaign material, as the
ruling kept the experiments); v4/system/post_cases.c (generated by
v4/tools/mkpost.py, "do not edit" -- the generator has the header).
Comments only: the kernel builds on amd64, aarch64, riscv64; make -C v4
test-32: 39 programs, 0 failures; every changed script parses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
61 lines
2.0 KiB
C
61 lines
2.0 KiB
C
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
||
* Copyright (c) 2023-2026 Robert A. James
|
||
*/
|
||
/*
|
||
* virtio_blk.h — Virtio 1.0 block device driver for StarKernel
|
||
*
|
||
* Presents a blkio_dev_t interface for attachment to the StarForth
|
||
* block subsystem via blk_subsys_attach_device().
|
||
*
|
||
* Only one virtio-blk device is supported (the Artemis disk).
|
||
* I/O is synchronous (polling) — no interrupts, no DMA descriptors
|
||
* beyond the split virtqueue shared memory.
|
||
*
|
||
* Artemis disk identification heuristic:
|
||
* The Artemis disk image is 30 MB (61440 sectors). The first virtio-blk
|
||
* device matching PCI vendor=0x1AF4 / device=0x1042 or 0x1001 whose
|
||
* sector count equals 61440 is selected. If no exact match, the first
|
||
* device found is used.
|
||
*/
|
||
|
||
#ifndef STARKERNEL_VIRTIO_BLK_H
|
||
#define STARKERNEL_VIRTIO_BLK_H
|
||
|
||
#include <stdint.h>
|
||
#include "blkio.h"
|
||
|
||
/* StarForth block size and sector ratio */
|
||
#define VBLK_SECTOR_SIZE 512u
|
||
#define VBLK_SECTORS_PER_BLOK 2u /* 1 KiB Forth block = 2 × 512-byte sectors */
|
||
#define VBLK_ARTEMIS_SECTORS 61440u /* 30 MB */
|
||
|
||
/* virtio PCI vendor */
|
||
#define VIRTIO_PCI_VENDOR_ID 0x1AF4u
|
||
/* device IDs */
|
||
#define VIRTIO_BLK_DEVICE_MODERN 0x1042u
|
||
#define VIRTIO_BLK_DEVICE_LEGACY 0x1001u
|
||
|
||
/* virtio-blk request types */
|
||
#define VIRTIO_BLK_T_IN 0u
|
||
#define VIRTIO_BLK_T_OUT 1u
|
||
|
||
/* virtio-blk status codes (device → driver) */
|
||
#define VIRTIO_BLK_S_OK 0u
|
||
#define VIRTIO_BLK_S_IOERR 1u
|
||
#define VIRTIO_BLK_S_UNSUPP 2u
|
||
|
||
/*
|
||
* virtio_blk_find_artemis — locate the Artemis virtio-blk disk, initialise
|
||
* the driver, and fill in *dev_out so the caller
|
||
* can pass it to blk_subsys_attach_device().
|
||
*
|
||
* dev_out must point to a zero-initialised blkio_dev_t.
|
||
*
|
||
* Returns 0 on success.
|
||
* Returns -1 if no virtio-blk device was found on the PCI bus.
|
||
* Returns -2 on driver initialisation failure (bad BAR, queue setup, etc.).
|
||
*/
|
||
int virtio_blk_find_artemis(blkio_dev_t *dev_out);
|
||
|
||
#endif /* STARKERNEL_VIRTIO_BLK_H */
|