diff --git a/Cargo.toml b/Cargo.toml index 7a0a86f..1820d3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,5 @@ workspace.members = ["kernel"] workspace.resolver = "2" + +profile.dev.panic = "abort" +profile.release.panic = "abort" diff --git a/README.md b/README.md index 4fd1d1a..445709a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ -References: +# EOS0 + +This is mainly a port of MIT's xv6 operating system, for educational purposes. + +You can consider the "e" in EOS to be either educational or experimental. + +## References - https://lowenware.com/blog/aarch64-bare-metal-program-in-rust/ diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index ad17cd9..abbacf8 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -3,9 +3,6 @@ name = "kernel" version = "0.1.0" edition = "2021" -profile.dev.panic = "abort" -profile.release.panic = "abort" - # [lib] # crate-type = ["staticlib"] diff --git a/kernel/src/console.rs b/kernel/src/console.rs new file mode 100644 index 0000000..5ae8740 --- /dev/null +++ b/kernel/src/console.rs @@ -0,0 +1,5 @@ +use crate::uart::uart_init; + +pub fn console_init() { + uart_init(); +} diff --git a/kernel/src/main.rs b/kernel/src/main.rs index c20feff..3ed6d7b 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -3,12 +3,19 @@ use core::{arch::global_asm, ptr}; +use crate::console::console_init; + +mod console; +mod memory_layout; mod panic; +mod uart; global_asm!(include_str!("start.s")); #[no_mangle] pub extern "C" fn not_main() { + console_init(); + const UART0: *mut u8 = 0x0900_0000 as *mut u8; let out_str = b"AArch64 Bare Metal"; for byte in out_str { diff --git a/kernel/src/memory_layout.rs b/kernel/src/memory_layout.rs new file mode 100644 index 0000000..50e15b3 --- /dev/null +++ b/kernel/src/memory_layout.rs @@ -0,0 +1 @@ +pub const UART0: u64 = 0x0900_0000; diff --git a/kernel/src/uart.rs b/kernel/src/uart.rs new file mode 100644 index 0000000..67a8de7 --- /dev/null +++ b/kernel/src/uart.rs @@ -0,0 +1,26 @@ +use crate::memory_layout::UART0; + +/// http://byterunner.com/16550.html +enum Register {} + +impl Register { + fn offset(&self) -> u64 { + todo!() + } +} + +/// the UART control registers are memory-mapped +/// at address UART0. this macro returns the +/// address of one of the registers +#[inline] +fn register(reg: Register) -> *mut u8 { + (UART0 + reg.offset()) as *mut u8 +} + +#[inline] +fn read_register() {} + +#[inline] +fn write_register() {} + +pub fn uart_init() {}