mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
chore: refactor arch traits
This commit is contained in:
parent
58b050d2b5
commit
a57ece2f76
@ -1,10 +1,6 @@
|
||||
// Basic IO
|
||||
pub mod io;
|
||||
|
||||
// Low Level
|
||||
pub mod lowlevel;
|
||||
pub use arch::*;
|
||||
|
||||
// Arch Level
|
||||
#[cfg(any(feature = "arch_riscv64", feature = "arch_riscv32"))]
|
||||
#[path = "riscv/mod.rs"]
|
||||
mod riscv;
|
||||
mod arch;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::arch::io::{Printer, RawConsole};
|
||||
use crate::utils::io::{Printer, RawConsole};
|
||||
|
||||
/*
|
||||
Theoretically, we should wait until
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::arch::io::{RawConsole, Reader};
|
||||
use crate::utils::io::{RawConsole, Reader};
|
||||
|
||||
impl Reader for RawConsole {
|
||||
#[inline]
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[allow(unused_imports)]
|
||||
use crate::arch::io::{Printer, RawConsole, Reader};
|
||||
use crate::utils::io::{Printer, RawConsole, Reader};
|
||||
|
||||
#[cfg(feature = "board_default")]
|
||||
impl Printer for RawConsole {
|
||||
|
@ -1,4 +1,5 @@
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
pub use super::mm::page::PAGE_SIZE;
|
||||
|
||||
pub const KERNEL_MEM_START: usize = 0x8030_0000;
|
||||
|
||||
// TODO: currently a dummy value, figure out our memory layout
|
||||
|
@ -1,6 +1,6 @@
|
||||
use log::error;
|
||||
|
||||
use crate::arch::lowlevel::{Hardware, LowLevel};
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
#[cfg(feature = "board_virt")]
|
||||
use super::board::TEST_DEVICE;
|
||||
@ -40,7 +40,7 @@ impl LowLevel for Hardware {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reset(failure: bool) -> ! {
|
||||
fn reset(#[allow(unused_variables)] failure: bool) -> ! {
|
||||
#[cfg(not(feature = "board_virt"))]
|
||||
if failure {
|
||||
sbi_rt::system_reset(sbi_rt::ColdReboot, sbi_rt::SystemFailure);
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::mm::addr::{AddressOps, PhysAddr, VirtAddr};
|
||||
use crate::mm::page;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use static_assertions::assert_eq_size;
|
||||
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
use crate::mm::addr::{AddressOps, PhysAddr};
|
||||
use crate::mm::page;
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
const PAGE_TABLE_ENTRIES: usize = 512;
|
||||
|
||||
const PG_OFFSET: u64 = 12;
|
||||
|
@ -1,5 +0,0 @@
|
||||
pub struct Trap;
|
||||
|
||||
pub trait Trampoline {
|
||||
fn init();
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
use crate::arch::lowlevel::{Hardware, LowLevel};
|
||||
use log::{error, info};
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
pub extern "C" fn rust_main(hart_id: usize, device_tree_addr: usize) -> ! {
|
||||
crate::logging::init();
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::arch::lowlevel::{Hardware, LowLevel};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
use log::error;
|
||||
|
||||
use crate::utils::lowlevel::{Hardware, LowLevel};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
error!("[lang] Kernel panic!");
|
||||
|
@ -18,5 +18,8 @@ pub mod entry;
|
||||
// page table
|
||||
pub mod mm;
|
||||
|
||||
// utils
|
||||
pub mod utils;
|
||||
|
||||
// logging
|
||||
pub mod logging;
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::arch::io::RawConsole;
|
||||
use core::fmt::Write;
|
||||
|
||||
use log::{self, LevelFilter, Log, Metadata, Record};
|
||||
|
||||
use crate::utils::io::RawConsole;
|
||||
|
||||
struct SimpleLogger;
|
||||
|
||||
impl Log for SimpleLogger {
|
||||
|
@ -107,6 +107,9 @@ impl<B: BitmapOps> Bitmap<B> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub type Bitmap1K = Bitmap<Bitmap32>;
|
||||
#[allow(unused)]
|
||||
pub type Bitmap32K = Bitmap<Bitmap1K>;
|
||||
#[allow(unused)]
|
||||
pub type Bitmap1M = Bitmap<Bitmap32K>;
|
||||
|
2
src/utils/mod.rs
Normal file
2
src/utils/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod io;
|
||||
pub mod lowlevel;
|
Loading…
Reference in New Issue
Block a user