wtf lol
This commit is contained in:
parent
ea550ccaa6
commit
4499d611e1
8 changed files with 42 additions and 15 deletions
|
@ -1,5 +1,19 @@
|
|||
use core::fmt::{self, Write};
|
||||
|
||||
use crate::uart::uart_init;
|
||||
|
||||
pub fn console_init() {
|
||||
/// A wrapper around the console
|
||||
pub struct Console {}
|
||||
|
||||
impl Console {
|
||||
pub fn init() -> Self {
|
||||
uart_init();
|
||||
Console {}
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for Console {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
1
kernel/src/io.rs
Normal file
1
kernel/src/io.rs
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
kernel/src/macros.rs
Normal file
1
kernel/src/macros.rs
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::fmt::Write;
|
||||
use core::{arch::global_asm, ptr};
|
||||
|
||||
use crate::console::console_init;
|
||||
use crate::console::Console;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
mod console;
|
||||
mod io;
|
||||
mod memory_layout;
|
||||
mod panic;
|
||||
mod uart;
|
||||
|
@ -14,13 +19,14 @@ global_asm!(include_str!("start.s"));
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn not_main() {
|
||||
console_init();
|
||||
let mut console = Console::init();
|
||||
let _ = writeln!(console, "eos0 is booting...");
|
||||
|
||||
const UART0: *mut u8 = 0x0900_0000 as *mut u8;
|
||||
let out_str = b"AArch64 Bare Metal";
|
||||
for byte in out_str {
|
||||
unsafe {
|
||||
ptr::write_volatile(UART0, *byte);
|
||||
}
|
||||
const UART0: *mut u8 = 0x0900_0000 as *mut u8;
|
||||
let out_str = b"AArch64 Bare Metal";
|
||||
for byte in out_str {
|
||||
unsafe {
|
||||
ptr::write_volatile(UART0, *byte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ use core::panic::PanicInfo;
|
|||
|
||||
#[panic_handler]
|
||||
fn on_panic(_info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
loop {}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use crate::memory_layout::UART0;
|
|||
enum Register {}
|
||||
|
||||
impl Register {
|
||||
fn offset(&self) -> u64 {
|
||||
todo!()
|
||||
}
|
||||
fn offset(&self) -> u64 {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// the UART control registers are memory-mapped
|
||||
|
@ -14,7 +14,7 @@ impl Register {
|
|||
/// address of one of the registers
|
||||
#[inline]
|
||||
fn register(reg: Register) -> *mut u8 {
|
||||
(UART0 + reg.offset()) as *mut u8
|
||||
(UART0 + reg.offset()) as *mut u8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
5
run.sh
5
run.sh
|
@ -1,4 +1,7 @@
|
|||
exec qemu-system-aarch64 -machine virt \
|
||||
set -euo pipefail
|
||||
cargo build
|
||||
exec qemu-system-aarch64 \
|
||||
-machine virt \
|
||||
-m 1024M \
|
||||
-cpu cortex-a53 \
|
||||
-nographic \
|
||||
|
|
2
rustfmt.toml
Normal file
2
rustfmt.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
tab_spaces = 2
|
||||
max_width = 80
|
Loading…
Reference in a new issue