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;
|
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();
|
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_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use core::fmt::Write;
|
||||||
use core::{arch::global_asm, ptr};
|
use core::{arch::global_asm, ptr};
|
||||||
|
|
||||||
use crate::console::console_init;
|
use crate::console::Console;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod macros;
|
||||||
|
|
||||||
mod console;
|
mod console;
|
||||||
|
mod io;
|
||||||
mod memory_layout;
|
mod memory_layout;
|
||||||
mod panic;
|
mod panic;
|
||||||
mod uart;
|
mod uart;
|
||||||
|
@ -14,13 +19,14 @@ global_asm!(include_str!("start.s"));
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn not_main() {
|
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;
|
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 {
|
||||||
unsafe {
|
unsafe {
|
||||||
ptr::write_volatile(UART0, *byte);
|
ptr::write_volatile(UART0, *byte);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@ use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn on_panic(_info: &PanicInfo) -> ! {
|
fn on_panic(_info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ use crate::memory_layout::UART0;
|
||||||
enum Register {}
|
enum Register {}
|
||||||
|
|
||||||
impl Register {
|
impl Register {
|
||||||
fn offset(&self) -> u64 {
|
fn offset(&self) -> u64 {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the UART control registers are memory-mapped
|
/// the UART control registers are memory-mapped
|
||||||
|
@ -14,7 +14,7 @@ impl Register {
|
||||||
/// address of one of the registers
|
/// address of one of the registers
|
||||||
#[inline]
|
#[inline]
|
||||||
fn register(reg: Register) -> *mut u8 {
|
fn register(reg: Register) -> *mut u8 {
|
||||||
(UART0 + reg.offset()) as *mut u8
|
(UART0 + reg.offset()) as *mut u8
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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 \
|
-m 1024M \
|
||||||
-cpu cortex-a53 \
|
-cpu cortex-a53 \
|
||||||
-nographic \
|
-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