1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Hardware Abstraction Layer

#![no_std]
#![feature(linkage)]
#![deny(warnings)]

extern crate alloc;

pub mod defs {
    use bitflags::bitflags;
    use numeric_enum_macro::numeric_enum;

    bitflags! {
        pub struct MMUFlags: usize {
            #[allow(clippy::identity_op)]
            const CACHE_1   = 1 << 0;
            const CACHE_2   = 1 << 1;
            const READ      = 1 << 2;
            const WRITE     = 1 << 3;
            const EXECUTE   = 1 << 4;
            const USER      = 1 << 5;
            const RXW = Self::READ.bits | Self::WRITE.bits | Self::EXECUTE.bits;
        }
    }
    numeric_enum! {
        #[repr(u32)]
        #[derive(Debug, PartialEq, Clone, Copy)]
        pub enum CachePolicy {
            Cached = 0,
            Uncached = 1,
            UncachedDevice = 2,
            WriteCombining = 3,
        }
    }
    pub const CACHE_POLICY_MASK: u32 = 3;

    pub type PhysAddr = usize;
    pub type VirtAddr = usize;
    pub type DevVAddr = usize;
    pub const PAGE_SIZE: usize = 0x1000;
}

mod context;
mod dummy;
mod future;
pub mod user;
pub mod vdso;

pub use self::context::*;
pub use self::defs::*;
pub use self::dummy::*;
pub use self::future::*;
pub use trapframe::{GeneralRegs, UserContext};