39 lines
870 B
Rust
39 lines
870 B
Rust
use crate::KernelSpace;
|
|
use address::{PhysicalAddress, VirtualAddress};
|
|
|
|
pub mod cpu;
|
|
pub mod smp;
|
|
pub mod exception;
|
|
pub mod intrin;
|
|
pub mod timer;
|
|
|
|
cfg_if! {
|
|
if #[cfg(feature = "mach_rpi3b")] {
|
|
pub mod mach_bcm283x;
|
|
pub use mach_bcm283x as machine;
|
|
} else if #[cfg(feature = "mach_virt")] {
|
|
pub mod mach_virt;
|
|
pub use mach_virt as machine;
|
|
}
|
|
}
|
|
|
|
pub trait MmioSize {}
|
|
impl MmioSize for u32 {}
|
|
impl MmioSize for i32 {}
|
|
impl MmioSize for u8 {}
|
|
|
|
#[inline]
|
|
pub unsafe fn mmio_write<T: MmioSize>(addr: PhysicalAddress, value: T) {
|
|
core::ptr::write_volatile(
|
|
VirtualAddress::<KernelSpace>::from(addr).as_mut_ptr(),
|
|
value,
|
|
);
|
|
}
|
|
|
|
#[inline]
|
|
pub unsafe fn mmio_read<T: MmioSize>(addr: PhysicalAddress) -> T {
|
|
core::ptr::read_volatile(
|
|
VirtualAddress::<KernelSpace>::from(addr).as_mut_ptr(),
|
|
)
|
|
}
|