mirror of
https://github.com/iceHtwoO/novaOS.git
synced 2026-04-17 04:32:27 +00:00
Introduce Logger trait
This commit is contained in:
39
src/lib.rs
39
src/lib.rs
@@ -1,14 +1,21 @@
|
||||
#![no_std]
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::{
|
||||
arch::asm,
|
||||
fmt,
|
||||
panic::PanicInfo,
|
||||
ptr::{read_volatile, write_volatile},
|
||||
};
|
||||
|
||||
use heap::Heap;
|
||||
|
||||
pub static PERIPHERAL_BASE: u32 = 0x3F00_0000;
|
||||
use crate::logger::{DefaultLogger, Logger};
|
||||
|
||||
static PERIPHERAL_BASE: u32 = 0x3F00_0000;
|
||||
|
||||
unsafe extern "C" {
|
||||
unsafe static mut __heap_start: u8;
|
||||
@@ -33,37 +40,23 @@ fn panic(_panic: &PanicInfo) -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
() => {};
|
||||
($($arg:tt)*) => {
|
||||
$crate::peripherals::uart::_print(format_args!($($arg)*))
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
() => {};
|
||||
($($arg:tt)*) => {
|
||||
print!($($arg)*);
|
||||
print!("\r\n");
|
||||
};
|
||||
}
|
||||
|
||||
pub mod peripherals;
|
||||
|
||||
pub mod configuration;
|
||||
pub mod framebuffer;
|
||||
pub mod irq_interrupt;
|
||||
pub mod interrupt_handlers;
|
||||
pub mod logger;
|
||||
pub mod mailbox;
|
||||
pub mod power_management;
|
||||
pub mod timer;
|
||||
|
||||
pub fn mmio_read(address: u32) -> u32 {
|
||||
#[inline(always)]
|
||||
pub unsafe fn read_address(address: u32) -> u32 {
|
||||
unsafe { read_volatile(address as *const u32) }
|
||||
}
|
||||
|
||||
pub fn mmio_write(address: u32, data: u32) {
|
||||
#[inline(always)]
|
||||
pub unsafe fn write_address(address: u32, data: u32) {
|
||||
unsafe { write_volatile(address as *mut u32, data) }
|
||||
}
|
||||
|
||||
@@ -78,3 +71,7 @@ pub fn get_current_el() -> u64 {
|
||||
}
|
||||
el >> 2
|
||||
}
|
||||
|
||||
pub fn initialize_kernel() {
|
||||
logger::set_logger(Box::new(DefaultLogger));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user