Share bootstrap_mem between all archs

This commit is contained in:
bjorn3
2024-02-25 15:53:04 +01:00
parent e23f0ed66b
commit 449abb8925
4 changed files with 10 additions and 32 deletions
-9
View File
@@ -68,15 +68,6 @@ pub unsafe extern "C" fn arch_copy_to_user(dst: usize, src: usize, len: usize) -
options(noreturn)
);
}
pub unsafe fn bootstrap_mem(bootstrap: &crate::Bootstrap) -> &'static [u8] {
use crate::memory::PAGE_SIZE;
use ::rmm::Arch;
core::slice::from_raw_parts(
CurrentRmmArch::phys_to_virt(bootstrap.base.start_address()).data() as *const u8,
bootstrap.page_count * PAGE_SIZE,
)
}
pub const KFX_SIZE: usize = 1024;
-8
View File
@@ -21,8 +21,6 @@ pub mod rmm;
/// Initialization and start function
pub mod start;
use crate::{memory::PAGE_SIZE, Bootstrap};
use ::rmm::Arch;
pub use ::rmm::X86Arch as CurrentRmmArch;
// Flags
@@ -56,12 +54,6 @@ pub unsafe extern "C" fn arch_copy_to_user(dst: usize, src: usize, len: usize) -
}
pub use arch_copy_to_user as arch_copy_from_user;
pub unsafe fn bootstrap_mem(bootstrap: &Bootstrap) -> &'static [u8] {
core::slice::from_raw_parts(
CurrentRmmArch::phys_to_virt(bootstrap.base.start_address()).data() as *const u8,
bootstrap.page_count * PAGE_SIZE,
)
}
pub const KFX_SIZE: usize = 512;
// This function exists as the KFX size is dynamic on x86_64.
-13
View File
@@ -1,7 +1,3 @@
use crate::Bootstrap;
use self::paging::PAGE_SIZE;
pub use crate::arch::x86_shared::*;
pub mod alternative;
@@ -33,7 +29,6 @@ pub mod rmm;
/// Initialization and start function
pub mod start;
use ::rmm::Arch;
pub use ::rmm::X8664Arch as CurrentRmmArch;
// Flags
@@ -73,12 +68,4 @@ pub unsafe extern "C" fn arch_copy_to_user(dst: usize, src: usize, len: usize) -
}
pub use arch_copy_to_user as arch_copy_from_user;
// TODO: This doesn't need to be arch-specific, right?
pub unsafe fn bootstrap_mem(bootstrap: &Bootstrap) -> &'static [u8] {
core::slice::from_raw_parts(
CurrentRmmArch::phys_to_virt(bootstrap.base.start_address()).data() as *const u8,
bootstrap.page_count * PAGE_SIZE,
)
}
pub use alternative::kfx_size;
+10 -2
View File
@@ -2,6 +2,7 @@ use alloc::{sync::Arc, vec::Vec};
use core::mem;
use spin::RwLock;
use rmm::Arch;
use crate::context::{
memory::{AddrSpace, PageSpan},
@@ -22,7 +23,7 @@ use crate::{
},
ptrace_event,
},
Bootstrap,
Bootstrap, CurrentRmmArch,
};
use super::usercopy::{UserSliceRo, UserSliceWo};
@@ -606,9 +607,16 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap) -> ! {
// TODO: Not all arches do linear mapping
UserSliceWo::new(0, bootstrap.page_count * PAGE_SIZE)
.expect("failed to create bootstrap user slice")
.copy_from_slice(unsafe { crate::arch::bootstrap_mem(bootstrap) })
.copy_from_slice(unsafe { bootstrap_mem(bootstrap) })
.expect("failed to copy memory to bootstrap");
// Start in a minimal environment without any stack.
usermode(bootstrap.entry, 0, 0, 0);
}
pub unsafe fn bootstrap_mem(bootstrap: &crate::Bootstrap) -> &'static [u8] {
core::slice::from_raw_parts(
CurrentRmmArch::phys_to_virt(bootstrap.base.start_address()).data() as *const u8,
bootstrap.page_count * PAGE_SIZE,
)
}