forked from AbleOS/ableos
ARM: Add serial console logging
This commit is contained in:
parent
ea49841de2
commit
7865bca782
23
kernel/src/arch/aarch64/logging.rs
Normal file
23
kernel/src/arch/aarch64/logging.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use {core::fmt::Write, spin::Mutex};
|
||||||
|
|
||||||
|
const SERIAL_CONSOLE: Mutex<SerialConsole> = Mutex::new(SerialConsole {
|
||||||
|
uart: 0x09000000 as *mut u8,
|
||||||
|
});
|
||||||
|
|
||||||
|
struct SerialConsole {
|
||||||
|
uart: *mut u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Write for SerialConsole {
|
||||||
|
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||||||
|
for c in s.chars() {
|
||||||
|
unsafe { *self.uart = c as u8 }
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||||
|
SERIAL_CONSOLE.lock().write_fmt(args)
|
||||||
|
}
|
|
@ -1,9 +1,15 @@
|
||||||
use {core::arch::asm, limine::FramebufferRequest};
|
use {core::arch::asm, limine::FramebufferRequest};
|
||||||
|
|
||||||
|
pub mod logging;
|
||||||
|
pub use logging::log;
|
||||||
|
|
||||||
pub const PAGE_SIZE: usize = 4096;
|
pub const PAGE_SIZE: usize = 4096;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn _kernel_start() -> ! {
|
unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
|
crate::logger::init().expect("failed to set logger");
|
||||||
|
log::info!("Initialising AKern {}", crate::VERSION);
|
||||||
|
|
||||||
static FB_REQ: FramebufferRequest = FramebufferRequest::new(0);
|
static FB_REQ: FramebufferRequest = FramebufferRequest::new(0);
|
||||||
let fb1 = &FB_REQ.get_response().get().unwrap().framebuffers()[0];
|
let fb1 = &FB_REQ.get_response().get().unwrap().framebuffers()[0];
|
||||||
|
|
||||||
|
@ -26,7 +32,3 @@ pub fn spin_loop() -> ! {
|
||||||
pub fn hardware_random_u64() -> u64 {
|
pub fn hardware_random_u64() -> u64 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log(_args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,9 +19,7 @@ pub fn init() {
|
||||||
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||||
x86_64::instructions::interrupts::without_interrupts(|| {
|
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||||
// TERMINAL_LOGGER.lock().write_fmt(args)?;
|
// TERMINAL_LOGGER.lock().write_fmt(args)?;
|
||||||
let mut sc = SERIAL_CONSOLE.lock();
|
SERIAL_CONSOLE.lock().write_fmt(args)
|
||||||
sc.write_fmt(args)?;
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue