diff --git a/kernel_api/src/bridge.rs b/kernel_api/src/bridge.rs index 7f0d4c85..ef8c790d 100644 --- a/kernel_api/src/bridge.rs +++ b/kernel_api/src/bridge.rs @@ -29,13 +29,18 @@ pub mod hal { } pub mod paging { + use core::marker::PhantomData; use core::ops::DerefMut; use crate::memory::{Frame, Page, PhysicalAddress, VirtualAddress}; use crate::memory::allocator::{AllocError, BackingAllocator, GlobalAllocator}; use crate::sync::RwWriteGuard; + // FIXME: replace with extern type when alignment can be specified + #[repr(align(8))] + pub struct KTable((), PhantomData); + extern "Rust" { - pub type KTable; + type KTableInner; pub fn __popcorn_paging_ktable_translate_page(this: &KTable, page: Page) -> Option; pub fn __popcorn_paging_ktable_translate_address(this: &KTable, addr: VirtualAddress) -> Option; diff --git a/kernel_hal/src/arch/amd64/paging2/mod.rs b/kernel_hal/src/arch/amd64/paging2/mod.rs index cae124bc..ba7befb1 100644 --- a/kernel_hal/src/arch/amd64/paging2/mod.rs +++ b/kernel_hal/src/arch/amd64/paging2/mod.rs @@ -34,6 +34,7 @@ pub(crate) unsafe fn construct_tables() -> (Amd64KTable, Amd64TTable) { #[derive(Debug)] struct KTablePtr(Frame); // points to a [Table; 256] +#[repr(align(8))] pub struct Amd64KTable { tables: KTablePtr, // points to a [Table; 256] allocator: &'static dyn BackingAllocator, diff --git a/kernel_hal/src/lib.rs b/kernel_hal/src/lib.rs index ee4e69c7..ca9ea711 100644 --- a/kernel_hal/src/lib.rs +++ b/kernel_hal/src/lib.rs @@ -55,6 +55,8 @@ pub unsafe trait Hal { unsafe extern "C" fn switch_thread(from: &mut ThreadControlBlock, to: &ThreadControlBlock); } +const _: () = { if core::mem::align_of::<::KTableTy>() != 8 { panic!("for... reasons... KTables must be 8 byte aligned"); } }; + pub trait FormatWriter { fn print(fmt: core::fmt::Arguments); }