test: on-hardware SMP self-test (revoke/kill must stop every hart) + make test-qemu
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
extern crate alloc;
|
||||
|
||||
mod devices;
|
||||
mod selftest;
|
||||
|
||||
use types::address::{EntryPoint, StackPointer, VirtualAddress};
|
||||
use types::bounded::{CapSlot, PageCount};
|
||||
@@ -12,7 +13,7 @@ use libkos::syscall;
|
||||
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
const USER_CODE_BASE: usize = 0x10000;
|
||||
const USER_STACK_TOP: StackPointer = StackPointer::from_raw(USER_CODE_BASE);
|
||||
pub(crate) const USER_STACK_TOP: StackPointer = StackPointer::from_raw(USER_CODE_BASE);
|
||||
const USER_STACK_PAGES: usize = 4;
|
||||
/// Where a program file is read to before it is loaded (16 pages: the
|
||||
/// largest program init will load).
|
||||
@@ -36,12 +37,12 @@ fn read_file(storage: &mut Storage, scratch: &mut [u8], filename: &[u8]) -> Opti
|
||||
read.filter(|r| Some(*r) == size)
|
||||
}
|
||||
|
||||
struct LoadedProcess {
|
||||
process_cap: CapSlot,
|
||||
entry_point: EntryPoint,
|
||||
pub(crate) struct LoadedProcess {
|
||||
pub(crate) process_cap: CapSlot,
|
||||
pub(crate) entry_point: EntryPoint,
|
||||
}
|
||||
|
||||
fn load_binary(storage: &mut Storage, scratch: &mut [u8], filename: &[u8]) -> Option<LoadedProcess> {
|
||||
pub(crate) fn load_binary(storage: &mut Storage, scratch: &mut [u8], filename: &[u8]) -> Option<LoadedProcess> {
|
||||
let file_size = read_file(storage, scratch, filename)?;
|
||||
let elf_data = &scratch[..file_size];
|
||||
let elf_info = match elf::parse(elf_data) {
|
||||
@@ -156,6 +157,13 @@ pub fn run() -> ! {
|
||||
libkos::println!("ok (entry={:#x})", loaded.entry_point.raw());
|
||||
}
|
||||
|
||||
// The test image carries the SMP self-test; it runs instead of the
|
||||
// desktop and halts the machine.
|
||||
if storage.open(b"smptest.elf").is_ok_and(|h| storage.close(h).is_ok()) {
|
||||
libkos::println!("init: running the SMP self-test");
|
||||
selftest::run(&mut storage, scratch);
|
||||
}
|
||||
|
||||
libkos::print!("init: loading snake... ");
|
||||
if let Some(snake) = load_binary(&mut storage, scratch, b"snake.elf") {
|
||||
// A client only calls: Execute, never Read, so it cannot pose as
|
||||
@@ -189,7 +197,7 @@ fn scratch() -> Option<&'static mut [u8]> {
|
||||
|
||||
/// Nothing to supervise yet: block on a notification nobody signals
|
||||
/// rather than spin a core on Yield.
|
||||
fn idle() -> ! {
|
||||
pub(crate) fn idle() -> ! {
|
||||
let idle = syscall::create_notification();
|
||||
loop {
|
||||
match idle {
|
||||
|
||||
Reference in New Issue
Block a user