refactor(userspace): split syscall/fat16/ext4 by concern; trim comments

This commit is contained in:
2026-10-27 13:21:53 +01:00
parent 99273db6d3
commit b4390b7b6d
25 changed files with 1283 additions and 1229 deletions

View File

@@ -1,7 +1,5 @@
//! Which driver gets which device. Boot gave init a capability to every
//! board device and a page saying where they are (`types::bootinfo`); init
//! asks each virtio slot what it is and hands the disk, the GPU and the
//! keyboard (or, without one, the UART) to their drivers.
//! Finds the board's devices (`types::bootinfo`): disk, GPU, and keyboard
//! (or the UART when there is none).
use hw_virtio::mmio::{
DEVICE_ID_BLOCK, DEVICE_ID_GPU, DEVICE_ID_INPUT, MAGIC, REG_DEVICE_ID, REG_MAGIC,
@@ -84,7 +82,7 @@ pub fn discover() -> Devices {
},
_ => continue,
};
// The first device of each kind wins.
// First device of each kind wins.
if place.mmio.is_none() {
*place = dev;
}

View File

@@ -1,13 +1,5 @@
//! SMP self-test, run only when the disk carries `smptest.elf` (the test
//! image built by `make test-qemu`). It checks on real harts what host
//! tests cannot: that unmapping a page and killing a process take effect
//! on every other hart before the call returns.
//!
//! A spinner process runs one thread per hart, each incrementing its own
//! counter in a page init also maps. Init then cuts the spinner off
//! (revoking its copy of the page, or killing it) and requires that no
//! counter moves afterwards: a stale TLB entry or a thread left running
//! on another hart would keep counting.
//! SMP self-test, run when the disk carries `smptest.elf`: after revoking a
//! spinner's page or killing it, no spinner counter may move on any hart.
use core::sync::atomic::{AtomicUsize, Ordering};
use libkos::fs::Storage;
@@ -17,7 +9,6 @@ use types::bounded::{CapSlot, PageCount};
use types::mapping::PagePerms;
use types::permission::{Permission, PermissionSet};
/// Where init sees the counter page; same layout as the spinner's.
const OBSERVE_VA: usize = 0x0140_0000;
const THREADS: usize = 4;
/// QEMU virt's timebase is 10 MHz.
@@ -79,9 +70,7 @@ fn run_phases(storage: &mut Storage, scratch: &mut [u8]) -> Result<(), &'static
syscall::map_region(page, VirtualAddress::from_raw(OBSERVE_VA), PagePerms::ReadWrite)
.map_err(|_| "cannot map the counter page")?;
// 1. Unmapping: revoking the spinner's copy of the page must unmap it
// on every hart before Revoke returns. The spinner then faults,
// which kills it from whichever hart faults first.
// Revoke must unmap the page on every hart; the spinner then faults and dies.
let spinner = start_spinner(storage, scratch, page)?;
if !syscall::revoke(page) {
return Err("revoke failed");
@@ -92,8 +81,7 @@ fn run_phases(storage: &mut Storage, scratch: &mut [u8]) -> Result<(), &'static
}
libkos::println!("smptest: revoke stops every hart: ok");
// 2. Killing: a process whose threads are running on other harts must
// stop everywhere before Kill returns.
// Kill must stop threads running on other harts before it returns.
let spinner = start_spinner(storage, scratch, page)?;
if !syscall::kill(spinner) {
return Err("kill failed");