maint: fix warnings
This commit is contained in:
@@ -5,7 +5,7 @@ use kernel_arch_interface::{
|
||||
task::{ForkFrame, StackBuilder, TaskContext, TaskFrame, UserContextInfo},
|
||||
};
|
||||
use kernel_arch_x86::registers::{FpuContext, CR3, MSR_IA32_FS_BASE};
|
||||
use libk_mm_interface::address::{AsPhysicalAddress, PhysicalAddress};
|
||||
use libk_mm_interface::address::PhysicalAddress;
|
||||
use tock_registers::interfaces::Writeable;
|
||||
use yggdrasil_abi::{arch::SavedFrame, error::Error};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::ops::Range;
|
||||
|
||||
use kernel_arch_interface::mem::DeviceMemoryAttributes;
|
||||
use kernel_arch_interface::{mem::DeviceMemoryAttributes, sync::IrqSafeSpinlock, Architecture};
|
||||
use kernel_arch_x86::registers::CR3;
|
||||
use libk_mm_interface::{
|
||||
address::PhysicalAddress,
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
auto_lower_address,
|
||||
table::{PageAttributes, PageEntry, PageTable, L0, L1, L2, L3},
|
||||
},
|
||||
KERNEL_VIRT_OFFSET,
|
||||
ArchitectureImpl, KERNEL_VIRT_OFFSET,
|
||||
};
|
||||
|
||||
pub const IDENTITY_SIZE_L1: usize = 64;
|
||||
@@ -23,6 +23,7 @@ pub const DEVICE_L1: usize = IDENTITY_SIZE_L1;
|
||||
pub const DEVICE_MAPPING_L3_COUNT: usize = 32;
|
||||
pub const DEVICE_MAPPING_OFFSET: usize = KERNEL_VIRT_OFFSET + (DEVICE_L1 << L1::SHIFT);
|
||||
|
||||
pub static LOCK: IrqSafeSpinlock<ArchitectureImpl, ()> = IrqSafeSpinlock::new(());
|
||||
pub static mut KERNEL_PDPT: PageTable<L1> = PageTable::zeroed();
|
||||
pub static mut KERNEL_PML4: PageTable<L0> = PageTable::zeroed();
|
||||
|
||||
@@ -61,7 +62,7 @@ impl DevicePageTableLevel for L2DeviceMemory {
|
||||
}
|
||||
|
||||
fn flush_range(range: Range<usize>) {
|
||||
// TODO
|
||||
let _ = range;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +96,7 @@ impl DevicePageTableLevel for L3DeviceMemory {
|
||||
}
|
||||
|
||||
fn flush_range(range: Range<usize>) {
|
||||
// TODO
|
||||
// let start = range.start * L3::SIZE + Self::VIRTUAL_BASE;
|
||||
// let size = (range.end - range.start) * L3::SIZE;
|
||||
// tlb_flush_range_va(start, size);
|
||||
let _ = range;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +110,8 @@ pub(super) unsafe fn setup(have_1gib_pages: bool) {
|
||||
KERNEL_PDPT[i] = PageEntry::<L1>::block(phys, PageAttributes::WRITABLE);
|
||||
}
|
||||
} else {
|
||||
loop {}
|
||||
// TODO
|
||||
ArchitectureImpl::halt();
|
||||
}
|
||||
|
||||
// DEVICE_L1 -> Device L2 table
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
use core::{
|
||||
alloc::Layout,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
use kernel_arch_interface::{
|
||||
mem::{DeviceMemoryAttributes, KernelTableManager, RawDeviceMemoryMapping},
|
||||
split_spinlock,
|
||||
};
|
||||
use kernel_arch_x86::registers::CR3;
|
||||
use libk_mm_interface::{
|
||||
address::PhysicalAddress,
|
||||
table::{page_index, EntryLevel, EntryLevelExt},
|
||||
use kernel_arch_interface::mem::{
|
||||
DeviceMemoryAttributes, KernelTableManager, RawDeviceMemoryMapping,
|
||||
};
|
||||
use libk_mm_interface::{address::PhysicalAddress, table::EntryLevel};
|
||||
use yggdrasil_abi::error::Error;
|
||||
|
||||
use crate::KERNEL_VIRT_OFFSET;
|
||||
|
||||
use self::table::{PageAttributes, PageEntry, PageTable, L0, L1, L2, L3};
|
||||
use self::table::{PageTable, L0, L1};
|
||||
|
||||
pub mod fixed;
|
||||
pub mod process;
|
||||
@@ -26,55 +15,6 @@ pub mod table;
|
||||
#[derive(Debug)]
|
||||
pub struct KernelTableManagerImpl;
|
||||
|
||||
// const CANONICAL_ADDRESS_MASK: usize = 0xFFFF000000000000;
|
||||
// const KERNEL_PHYS_BASE: usize = 0x200000;
|
||||
//
|
||||
// // Mapped at compile time
|
||||
// const KERNEL_MAPPING_BASE: usize = KERNEL_VIRT_OFFSET + KERNEL_PHYS_BASE;
|
||||
// const KERNEL_L0_INDEX: usize = page_index::<L0>(KERNEL_MAPPING_BASE);
|
||||
// const KERNEL_L1_INDEX: usize = page_index::<L1>(KERNEL_MAPPING_BASE);
|
||||
// const KERNEL_START_L2_INDEX: usize = page_index::<L2>(KERNEL_MAPPING_BASE);
|
||||
//
|
||||
// // Must not be zero, should be at 4MiB
|
||||
// const_assert_ne!(KERNEL_START_L2_INDEX, 0);
|
||||
// // From static mapping
|
||||
// const_assert_eq!(KERNEL_L0_INDEX, 511);
|
||||
// const_assert_eq!(KERNEL_L1_INDEX, 0);
|
||||
//
|
||||
// // Mapped at boot
|
||||
// const EARLY_MAPPING_L2I: usize = KERNEL_START_L2_INDEX - 1;
|
||||
// const DEVICE_MAPPING_L1I: usize = KERNEL_L1_INDEX + 2;
|
||||
// const RAM_MAPPING_L0I: usize = KERNEL_L0_INDEX - 1;
|
||||
//
|
||||
// const DEVICE_MAPPING_L3_COUNT: usize = 4;
|
||||
//
|
||||
// split_spinlock! {
|
||||
// use libk_mm_interface::KernelImageObject;
|
||||
// use memtables::x86_64::FixedTables;
|
||||
// use crate::ArchitectureImpl;
|
||||
//
|
||||
// #[link_section = ".data.tables"]
|
||||
// static KERNEL_TABLES: KernelImageObject<FixedTables> =
|
||||
// unsafe { KernelImageObject::new(FixedTables::zeroed()) };
|
||||
// }
|
||||
//
|
||||
// // 2MiB for early mappings
|
||||
// const EARLY_MAPPING_OFFSET: usize = CANONICAL_ADDRESS_MASK
|
||||
// | (KERNEL_L0_INDEX * L0::SIZE)
|
||||
// | (KERNEL_L1_INDEX * L1::SIZE)
|
||||
// | (EARLY_MAPPING_L2I * L2::SIZE);
|
||||
// static mut EARLY_MAPPING_L3: PageTable<L3> = PageTable::zeroed();
|
||||
// // 1GiB for device MMIO mapping
|
||||
// const DEVICE_MAPPING_OFFSET: usize =
|
||||
// CANONICAL_ADDRESS_MASK | (KERNEL_L0_INDEX * L0::SIZE) | (DEVICE_MAPPING_L1I * L1::SIZE);
|
||||
// static mut DEVICE_MAPPING_L2: PageTable<L2> = PageTable::zeroed();
|
||||
// static mut DEVICE_MAPPING_L3S: [PageTable<L3>; DEVICE_MAPPING_L3_COUNT] =
|
||||
// [PageTable::zeroed(); DEVICE_MAPPING_L3_COUNT];
|
||||
// // 512GiB for whole RAM mapping
|
||||
// pub const RAM_MAPPING_OFFSET: usize = CANONICAL_ADDRESS_MASK | (RAM_MAPPING_L0I * L0::SIZE);
|
||||
// pub static MEMORY_LIMIT: AtomicUsize = AtomicUsize::new(0);
|
||||
// pub static mut RAM_MAPPING_L1: PageTable<L1> = PageTable::zeroed();
|
||||
|
||||
impl KernelTableManager for KernelTableManagerImpl {
|
||||
fn virtualize(address: u64) -> usize {
|
||||
let address = address as usize;
|
||||
@@ -99,11 +39,16 @@ impl KernelTableManager for KernelTableManagerImpl {
|
||||
count: usize,
|
||||
attrs: DeviceMemoryAttributes,
|
||||
) -> Result<RawDeviceMemoryMapping<Self>, Error> {
|
||||
let _lock = fixed::LOCK.lock();
|
||||
#[allow(static_mut_refs)]
|
||||
fixed::DEVICE_MEMORY.map_device_pages(PhysicalAddress::from_u64(base), count, attrs)
|
||||
}
|
||||
|
||||
unsafe fn unmap_device_pages(mapping: &RawDeviceMemoryMapping<Self>) {}
|
||||
unsafe fn unmap_device_pages(mapping: &RawDeviceMemoryMapping<Self>) {
|
||||
let _lock = fixed::LOCK.lock();
|
||||
#[allow(static_mut_refs)]
|
||||
fixed::DEVICE_MEMORY.unmap_device_pages(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clone_kernel_tables(dst: &mut PageTable<L0>) {
|
||||
|
||||
Reference in New Issue
Block a user