Files
LithosAnanake/kernel/include/starkernel/virtio_blk.h
T
rajamesandJunie a8b70e88d3 Reorganize source tree: kernel/, v3/, v4/ split and board infrastructure
Source tree reorganization:
- Move StarForth v3 engine to v3/ (src/, include/, Makefile)
- Move kernel to kernel/ (src/, include/, linker/, Makefile)
- Create v4/ skeleton for F18-ISA golden model (DECOMPOSITION.md, JUSTIFICATION.md)
- Move FABRIC-0..4.md to docs/fabric/
- Move ONTOLOGY.md and ROADMAP.md to docs/

Board infrastructure:
- Add boards/ser5/, boards/raspi/, boards/milkv/, boards/zynq7020/
- Each board has board.mk (ISA, CPU flags, boot recipe) and README.md
- Root Makefile becomes thin dispatcher: boot_image, all, clean, docs take TARGET
- make boot_image TARGET=SER5|RASPI|MILKV builds one GPT/MBR image per board
- ZYNQ7020 target exists but stops with clear error (ARMv7 port not built yet)
- scripts/mkdiskimage.sh builds disk images for all boards

Docs pipeline:
- docs/book/ with LaTeX master (main.tex) and Makefile
- pandoc converts Markdown to LaTeX at build time
- Two Lua filters: table-widths.lua (wide tables wrap), code-breaks.lua (inline code breaks)
- make docs builds single PDF (754 pages, 0 missing characters)
- make docs TARGET=<board> adds board appendix
- build/docs/<book|board>/meta.tex stamps git commit into PDF

Bug fixes:
- 42 include paths that only worked by accident now use correct relative paths
- clang-18 hardcode replaced with configurable CC variable (fixed aarch64 build)
- Pi 5: kernel_2712.img linked at 0x80000, .bss zeroed, memory reserved
- Doxyfile, .clang-tidy, README.md, Kconfig paths updated

Verified:
- Hosted v3 build passes 1012 tests, 0 failures
- SER5 image boots in QEMU (OVMF), POST passes, K exact (65536 = Q48_ONE)
- Milk-V image boots in QEMU (OpenSBI + U-Boot + bootefi), POST passes
- make clean TARGET=<board> removes only that board and its ISA objects
- make all builds all boards, hosted v3, and docs in one run

Co-authored-by: Junie <junie@jetbrains.com>
2026-10-01 15:40:09 -04:00

58 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 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 */