mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
chore: move arch traits into plat
This commit is contained in:
parent
145b8cf076
commit
6cfdb4a237
@ -1,4 +1,4 @@
|
||||
use crate::utils::io::{Printer, RawConsole};
|
||||
use crate::plat::io::{Printer, RawConsole};
|
||||
|
||||
/*
|
||||
Theoretically, we should wait until
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::utils::io::{RawConsole, Reader};
|
||||
use crate::plat::io::{RawConsole, Reader};
|
||||
|
||||
impl Reader for RawConsole {
|
||||
#[inline]
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[allow(unused_imports)]
|
||||
use crate::utils::io::{Printer, RawConsole, Reader};
|
||||
use crate::plat::io::{Printer, RawConsole, Reader};
|
||||
|
||||
#[cfg(feature = "board_default")]
|
||||
impl Printer for RawConsole {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use log::error;
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
use crate::plat::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
#[cfg(feature = "board_virt")]
|
||||
use super::board::TEST_DEVICE;
|
||||
|
12
src/entry.rs
12
src/entry.rs
@ -1,17 +1,19 @@
|
||||
use log::{error, info};
|
||||
use log::{debug, error, info};
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
use crate::plat::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_main(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
crate::logging::init();
|
||||
|
||||
#[cfg(test)]
|
||||
crate::test_main(); // test_main will exit
|
||||
crate::test_main();
|
||||
// test_main will exit
|
||||
|
||||
info!("[rust_main] Kernel Started");
|
||||
|
||||
info!("Hello World!");
|
||||
info!("hart_id = {}", hart_id);
|
||||
info!("device_tree_addr = {:#x}", device_tree_addr);
|
||||
debug!("device_tree_addr = {:#x}", device_tree_addr);
|
||||
|
||||
// TODO: setup and start scheduler
|
||||
|
||||
|
@ -2,7 +2,7 @@ use core::panic::PanicInfo;
|
||||
|
||||
use log::error;
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
use crate::plat::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
|
@ -2,7 +2,7 @@ use core::fmt::Write;
|
||||
|
||||
use log::{self, LevelFilter, Log, Metadata, Record};
|
||||
|
||||
use crate::utils::io::RawConsole;
|
||||
use crate::plat::io::RawConsole;
|
||||
|
||||
struct SimpleLogger;
|
||||
|
||||
|
@ -26,12 +26,15 @@ pub mod entry;
|
||||
// page table
|
||||
pub mod mm;
|
||||
|
||||
// utils
|
||||
pub mod utils;
|
||||
// plat
|
||||
pub mod plat;
|
||||
|
||||
// logging
|
||||
pub mod logging;
|
||||
|
||||
// utils
|
||||
pub mod utils;
|
||||
|
||||
// test infrastructure
|
||||
#[cfg(test)]
|
||||
mod test_runner;
|
||||
|
2
src/plat/mod.rs
Normal file
2
src/plat/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod io;
|
||||
pub mod lowlevel;
|
@ -1,6 +1,6 @@
|
||||
use log::info;
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
use crate::plat::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
// Reference: https://os.phil-opp.com/testing/
|
||||
|
||||
|
12
src/utils/function_name.rs
Normal file
12
src/utils/function_name.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#[macro_export]
|
||||
macro_rules! function_name {
|
||||
() => {{
|
||||
fn f() {}
|
||||
fn type_name_of<T>(_: T) -> &'static str {
|
||||
core::any::type_name::<T>()
|
||||
}
|
||||
let name = type_name_of(f);
|
||||
// strip out `::f` at the end of the string
|
||||
&name[..name.len() - 3]
|
||||
}};
|
||||
}
|
@ -1,2 +1 @@
|
||||
pub mod io;
|
||||
pub mod lowlevel;
|
||||
pub mod function_name;
|
||||
|
Loading…
Reference in New Issue
Block a user