diff --git a/src/arch/aarch64.rs b/src/arch/aarch64.rs index e771396..63c64cf 100644 --- a/src/arch/aarch64.rs +++ b/src/arch/aarch64.rs @@ -3,6 +3,8 @@ use core::ops::{Deref, DerefMut}; use super::error::{Error, Result}; +pub const PAGE_SIZE: usize = 4096; + macro_rules! syscall { ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { $( diff --git a/src/arch/nonredox.rs b/src/arch/nonredox.rs index f99a714..65c44fc 100644 --- a/src/arch/nonredox.rs +++ b/src/arch/nonredox.rs @@ -1,5 +1,8 @@ use super::error::{Error, Result, ENOSYS}; +// Doesn't really matter, but since we will most likely run on an x86_64 host, why not 4096? +pub const PAGE_SIZE: usize = 4096; + pub unsafe fn syscall0(_a: usize) -> Result { Err(Error::new(ENOSYS)) } diff --git a/src/arch/x86.rs b/src/arch/x86.rs index 2f9301e..a97ba81 100644 --- a/src/arch/x86.rs +++ b/src/arch/x86.rs @@ -4,6 +4,8 @@ use core::ops::{Deref, DerefMut}; use super::error::{Error, Result}; +pub const PAGE_SIZE: usize = 4096; + macro_rules! syscall { ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { $( diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index f71898e..2ff57bb 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -4,6 +4,8 @@ use core::ops::{Deref, DerefMut}; use super::error::{Error, Result}; +pub const PAGE_SIZE: usize = 4096; + macro_rules! syscall { ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { $( diff --git a/src/io/dma.rs b/src/io/dma.rs index e16ffba..f496a1e 100644 --- a/src/io/dma.rs +++ b/src/io/dma.rs @@ -4,6 +4,7 @@ use core::{ptr, slice}; use crate::Result; use crate::{PartialAllocStrategy, PhysallocFlags}; +use crate::arch::PAGE_SIZE; /// An RAII guard of a physical memory allocation. Currently all physically allocated memory are /// page-aligned and take up at least 4k of space (on x86_64). @@ -13,9 +14,6 @@ pub struct PhysBox { size: usize } -#[cfg(target_arch = "x86_64")] -const PAGE_SIZE: usize = 4096; - const fn round_up(x: usize) -> usize { (x + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE }