Move arch specific EntryFlags into rmm
This commit is contained in:
Generated
+3
@@ -212,6 +212,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rmm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@ version = "0.1.0"
|
||||
authors = ["Jeremy Soller <jeremy@system76.com>"]
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
std = []
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -99,6 +99,13 @@ impl Arch for AArch64Arch {
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 2;
|
||||
const DEV_MEM = 2 << 2;
|
||||
}
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
assert!(AArch64Arch::PAGE_SIZE == 4096);
|
||||
assert!(AArch64Arch::PAGE_OFFSET_MASK == 0xFFF);
|
||||
|
||||
+7
-18
@@ -3,27 +3,16 @@ use core::ptr;
|
||||
use crate::{PhysicalAddress, TableKind, VirtualAddress};
|
||||
|
||||
//TODO: Support having all page tables compile on all architectures
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub mod aarch64;
|
||||
#[cfg(all(feature = "std", target_pointer_width = "64"))]
|
||||
pub use self::emulate::EmulateArch;
|
||||
pub mod emulate;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub mod riscv64;
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
pub use self::x86::X86Arch;
|
||||
pub mod x86;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub use self::{
|
||||
aarch64::AArch64Arch,
|
||||
riscv64::{RiscV64Sv39Arch, RiscV64Sv48Arch},
|
||||
x86_64::X8664Arch,
|
||||
};
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
mod aarch64;
|
||||
#[cfg(all(feature = "std", target_pointer_width = "64"))]
|
||||
mod emulate;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
mod riscv64;
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
mod x86;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
mod x86_64;
|
||||
pub mod x86_64;
|
||||
|
||||
pub trait Arch: Clone + Copy {
|
||||
/// Does the architecture use a separate page table for the kernel.
|
||||
|
||||
@@ -3,3 +3,11 @@ pub use sv48::RiscV64Sv48Arch;
|
||||
|
||||
mod sv39;
|
||||
mod sv48;
|
||||
|
||||
bitflags::bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 4;
|
||||
const DEV_MEM = 0;
|
||||
const WRITE_COMBINING = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,15 @@ impl Arch for X86Arch {
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 4;
|
||||
const HUGE_PAGE = 1 << 7;
|
||||
const GLOBAL = 1 << 8;
|
||||
const DEV_MEM = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
assert!(X86Arch::PAGE_SIZE == 4096);
|
||||
assert!(X86Arch::PAGE_OFFSET_MASK == 0xFFF);
|
||||
|
||||
@@ -60,6 +60,15 @@ impl Arch for X8664Arch {
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 4;
|
||||
const HUGE_PAGE = 1 << 7;
|
||||
const GLOBAL = 1 << 8;
|
||||
const DEV_MEM = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const _: () = {
|
||||
assert!(X8664Arch::PAGE_SIZE == 4096);
|
||||
assert!(X8664Arch::PAGE_OFFSET_MASK == 0xFFF);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#![cfg(target_pointer_width = "64")]
|
||||
|
||||
use rmm::{
|
||||
Arch, BuddyAllocator, BumpAllocator, EmulateArch, Flusher, FrameAllocator, FrameCount,
|
||||
emulate::EmulateArch, Arch, BuddyAllocator, BumpAllocator, Flusher, FrameAllocator, FrameCount,
|
||||
MemoryArea, PageFlags, PageFlushAll, PageMapper, PageTable, PhysicalAddress, TableKind,
|
||||
VirtualAddress, GIGABYTE, KILOBYTE, MEGABYTE, TERABYTE,
|
||||
};
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ impl Hpet {
|
||||
unsafe {
|
||||
use crate::{
|
||||
memory::{Frame, KernelMapper},
|
||||
paging::{entry::EntryFlags, Page, VirtualAddress},
|
||||
paging::{EntryFlags, Page, VirtualAddress},
|
||||
};
|
||||
use rmm::PageFlags;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ pub mod vectors;
|
||||
|
||||
pub mod time;
|
||||
|
||||
pub use ::rmm::AArch64Arch as CurrentRmmArch;
|
||||
pub use ::rmm::aarch64::AArch64Arch as CurrentRmmArch;
|
||||
|
||||
pub use arch_copy_to_user as arch_copy_from_user;
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
//! # Page table entry
|
||||
//! Some code borrowed from [Phil Opp's Blog](http://os.phil-opp.com/modifying-page-tables.html)
|
||||
|
||||
bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 2;
|
||||
const DEV_MEM = 2 << 2;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@
|
||||
use crate::device::cpu::registers::control_regs;
|
||||
|
||||
pub use super::CurrentRmmArch as RmmA;
|
||||
pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress};
|
||||
pub use rmm::{
|
||||
aarch64::EntryFlags, Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress,
|
||||
};
|
||||
|
||||
pub type PageMapper = rmm::PageMapper<RmmA, crate::memory::TheFrameAllocator>;
|
||||
|
||||
pub mod entry;
|
||||
pub mod mapper;
|
||||
|
||||
/// Size of pages
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod start;
|
||||
pub mod stop;
|
||||
pub mod time;
|
||||
|
||||
pub use ::rmm::RiscV64Sv48Arch as CurrentRmmArch;
|
||||
pub use ::rmm::riscv64::RiscV64Sv48Arch as CurrentRmmArch;
|
||||
use core::arch::naked_asm;
|
||||
|
||||
pub use arch_copy_to_user as arch_copy_from_user;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/// A page table entry
|
||||
#[repr(packed(8))]
|
||||
pub struct Entry(u64);
|
||||
|
||||
bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 4;
|
||||
const DEV_MEM = 0;
|
||||
const WRITE_COMBINING = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
#![allow(unused)]
|
||||
|
||||
pub use super::CurrentRmmArch as RmmA;
|
||||
pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress};
|
||||
pub use rmm::{
|
||||
aarch64::EntryFlags, Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress,
|
||||
};
|
||||
|
||||
pub type PageMapper = rmm::PageMapper<RmmA, crate::memory::TheFrameAllocator>;
|
||||
pub use crate::rmm::KernelMapper;
|
||||
|
||||
pub mod entry;
|
||||
pub mod mapper;
|
||||
|
||||
/// Size of pages
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::acpi::madt::{self, Madt, MadtEntry, MadtIntSrcOverride, MadtIoApic};
|
||||
use crate::{
|
||||
arch::interrupt::irq,
|
||||
memory::{Frame, KernelMapper},
|
||||
paging::{entry::EntryFlags, Page, PageFlags, PhysicalAddress},
|
||||
paging::{EntryFlags, Page, PageFlags, PhysicalAddress},
|
||||
};
|
||||
|
||||
use super::{local_apic::ApicId, pic};
|
||||
|
||||
@@ -36,7 +36,7 @@ pub mod stop;
|
||||
pub mod time;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub use ::rmm::X86Arch as CurrentRmmArch;
|
||||
pub use ::rmm::x86::X86Arch as CurrentRmmArch;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use ::rmm::X8664Arch as CurrentRmmArch;
|
||||
pub use ::rmm::x86_64::X8664Arch as CurrentRmmArch;
|
||||
|
||||
@@ -10,16 +10,10 @@ pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAdd
|
||||
|
||||
pub type PageMapper = rmm::PageMapper<RmmA, crate::memory::TheFrameAllocator>;
|
||||
|
||||
pub mod entry {
|
||||
bitflags! {
|
||||
pub struct EntryFlags: usize {
|
||||
const NO_CACHE = 1 << 4;
|
||||
const HUGE_PAGE = 1 << 7;
|
||||
const GLOBAL = 1 << 8;
|
||||
const DEV_MEM = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub use rmm::x86::EntryFlags;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use rmm::x86_64::EntryFlags;
|
||||
|
||||
pub mod mapper;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ use crate::{
|
||||
memory::{AccessMode, PfError},
|
||||
},
|
||||
kernel_executable_offsets::{__usercopy_end, __usercopy_start},
|
||||
paging::{entry::EntryFlags, Page, PageFlags},
|
||||
paging::{EntryFlags, Page, PageFlags},
|
||||
sync::CleanLockToken,
|
||||
syscall::error::{Error, ENOMEM},
|
||||
};
|
||||
|
||||
+7
-11
@@ -9,18 +9,14 @@ use crate::{
|
||||
memory::{handle_notify_files, AddrSpace, AddrSpaceWrapper, Grant, PageSpan},
|
||||
},
|
||||
memory::{free_frames, used_frames, Frame, PAGE_SIZE},
|
||||
paging::VirtualAddress,
|
||||
paging::{EntryFlags, VirtualAddress},
|
||||
sync::CleanLockToken,
|
||||
syscall::usercopy::UserSliceRw,
|
||||
};
|
||||
|
||||
use crate::paging::entry::EntryFlags;
|
||||
|
||||
use crate::syscall::{
|
||||
data::{Map, StatVfs},
|
||||
error::*,
|
||||
flag::MapFlags,
|
||||
usercopy::UserSliceWo,
|
||||
syscall::{
|
||||
data::{Map, StatVfs},
|
||||
error::*,
|
||||
flag::MapFlags,
|
||||
usercopy::{UserSliceRw, UserSliceWo},
|
||||
},
|
||||
};
|
||||
|
||||
use super::{CallerCtx, KernelScheme, OpenResult, StrOrBytes};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
arch::{consts::KERNEL_OFFSET, paging::entry::EntryFlags, rmm::page_flags, CurrentRmmArch},
|
||||
arch::{consts::KERNEL_OFFSET, paging::EntryFlags, rmm::page_flags, CurrentRmmArch},
|
||||
memory::PAGE_SIZE,
|
||||
startup::{memory::BootloaderMemoryKind::Null, KernelArgs},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user