Skip to content

Commit

Permalink
boot: use new address space handles and ::range() signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Sep 11, 2024
1 parent 31402f0 commit 6261606
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion oro-boot/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ pub fn map_kernel_stack<
) -> crate::Result<usize> {
let kernel_stack_segment = <TargetAddressSpace as AddressSpace>::kernel_stack();

let last_stack_page_virt = kernel_stack_segment.range().1 & !0xFFF;
// TODO(qix-): This is nutty. There needs to be a better way to express this.
let last_stack_page_virt =
<<TargetAddressSpace as AddressSpace>::SupervisorSegment as AddressSegment<
<TargetAddressSpace as AddressSpace>::SupervisorHandle,
>>::range(&kernel_stack_segment, supervisor_space)
.1 & !0xFFF;

// make sure top guard page is unmapped
match kernel_stack_segment.unmap(supervisor_space, pfa, pat, last_stack_page_virt) {
Expand Down
10 changes: 5 additions & 5 deletions oro-boot/src/target/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use core::arch::asm;
use oro_arch_aarch64::{
mair::MairEntry,
mem::address_space::{AddressSpaceHandle, AddressSpaceLayout},
mem::address_space::{AddressSpaceLayout, Ttbr1Handle},
reg::{
self,
tcr_el1::{
Expand All @@ -23,7 +23,7 @@ use oro_mem::{
#[expect(clippy::missing_docs_in_private_items)]
pub type AddressSpace = AddressSpaceLayout;
#[expect(clippy::missing_docs_in_private_items)]
pub type SupervisorHandle = AddressSpaceHandle;
pub type SupervisorHandle = Ttbr1Handle;

/// Passed from the [`prepare_transfer`] function to the [`transfer`] function,
/// allowing the common (arch-agnostic) boot routine to perform some finalization operations
Expand Down Expand Up @@ -72,7 +72,7 @@ const STUBS: &[u8] = &asm_buffer! {
/// Prepares the system for a transfer. Called before the memory map
/// is written, after which `transfer` is called.
pub unsafe fn prepare_transfer<P: Translator, A: Alloc>(
mapper: &mut AddressSpaceHandle,
mapper: &mut Ttbr1Handle,
alloc: &mut A,
pat: &P,
) -> crate::Result<TransferData> {
Expand Down Expand Up @@ -100,7 +100,7 @@ pub unsafe fn prepare_transfer<P: Translator, A: Alloc>(
// Map the stubs into the new page table using an identity mapping.
// SAFETY(qix-): We specify that TTBR0 must be 4KiB upon transferring to the kernel,
// SAFETY(qix-): and that TTBR0_EL1 is left undefined (for our usage).
let page_table = AddressSpaceLayout::new_supervisor_space_tt0(alloc, pat)
let page_table = AddressSpaceLayout::new_supervisor_space_ttbr0(alloc, pat)
.ok_or(crate::Error::MapError(MapError::OutOfMemory))?;

// Direct map it.
Expand All @@ -118,7 +118,7 @@ pub unsafe fn prepare_transfer<P: Translator, A: Alloc>(
/// Performs the transfer from pre-boot to the kernel.
#[expect(clippy::needless_pass_by_value)]
pub unsafe fn transfer(
mapper: &mut AddressSpaceHandle,
mapper: &mut Ttbr1Handle,
kernel_entry: usize,
stack_addr: usize,
prepare_data: TransferData,
Expand Down

0 comments on commit 6261606

Please sign in to comment.