begin console

This commit is contained in:
Michael Zhang 2024-02-22 21:50:13 -06:00
parent 5443c61db2
commit ea550ccaa6
7 changed files with 49 additions and 4 deletions

View file

@ -1,2 +1,5 @@
workspace.members = ["kernel"] workspace.members = ["kernel"]
workspace.resolver = "2" workspace.resolver = "2"
profile.dev.panic = "abort"
profile.release.panic = "abort"

View file

@ -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/ - https://lowenware.com/blog/aarch64-bare-metal-program-in-rust/

View file

@ -3,9 +3,6 @@ name = "kernel"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
profile.dev.panic = "abort"
profile.release.panic = "abort"
# [lib] # [lib]
# crate-type = ["staticlib"] # crate-type = ["staticlib"]

5
kernel/src/console.rs Normal file
View file

@ -0,0 +1,5 @@
use crate::uart::uart_init;
pub fn console_init() {
uart_init();
}

View file

@ -3,12 +3,19 @@
use core::{arch::global_asm, ptr}; use core::{arch::global_asm, ptr};
use crate::console::console_init;
mod console;
mod memory_layout;
mod panic; mod panic;
mod uart;
global_asm!(include_str!("start.s")); global_asm!(include_str!("start.s"));
#[no_mangle] #[no_mangle]
pub extern "C" fn not_main() { pub extern "C" fn not_main() {
console_init();
const UART0: *mut u8 = 0x0900_0000 as *mut u8; const UART0: *mut u8 = 0x0900_0000 as *mut u8;
let out_str = b"AArch64 Bare Metal"; let out_str = b"AArch64 Bare Metal";
for byte in out_str { for byte in out_str {

View file

@ -0,0 +1 @@
pub const UART0: u64 = 0x0900_0000;

26
kernel/src/uart.rs Normal file
View file

@ -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() {}