Add PAGE_SIZE for all archs, make it public.

This commit is contained in:
4lDO2
2022-07-27 17:24:15 +02:00
parent d6af266119
commit 300b5e4a80
5 changed files with 10 additions and 3 deletions

View File

@@ -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, )?)?)?)?)?);)+) => {
$(

View File

@@ -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<usize> {
Err(Error::new(ENOSYS))
}

View File

@@ -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, )?)?)?)?)?);)+) => {
$(

View File

@@ -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, )?)?)?)?)?);)+) => {
$(

View File

@@ -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
}