From 386df39c9866a4d945de46ef0dcab2363c674e0e Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Sun, 1 Sep 2024 19:59:44 -0500 Subject: Move almost all the kernel into crates/. --- crates/kernel/src/arch/hosted.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 crates/kernel/src/arch/hosted.rs (limited to 'crates/kernel/src/arch/hosted.rs') diff --git a/crates/kernel/src/arch/hosted.rs b/crates/kernel/src/arch/hosted.rs new file mode 100644 index 0000000..df62bab --- /dev/null +++ b/crates/kernel/src/arch/hosted.rs @@ -0,0 +1,29 @@ +//! Support for running under an operating system that provides libstd, for testing. + +extern crate std; + +use std::{thread::sleep, time::Duration}; + +/// The size of a page of memory. +/// +/// Obviously, this value is unrealistic, but for now we just need the hosted arch to compile. +pub const PAGE_SIZE: usize = 64; + +/// The number of bits in the size of a page of memory. +/// +/// Obviously, this value is unrealistic, but for now we just need the hosted arch to compile. +pub const PAGE_SIZE_BITS: usize = 6; + +/// No-opped interrupt support. +/// +/// TODO: Should this use Unix signals? +pub mod interrupts { + pub fn disable_interrupts() {} +} + +/// Sleeps forever, in one-second chunks. +pub fn sleep_forever() -> ! { + loop { + sleep(Duration::from_secs(1)); + } +} -- cgit v1.2.3