Skip to content

Commit

Permalink
revert SMP boot for BIOS systems to previous way, WIP for UEFI system…
Browse files Browse the repository at this point in the history
…s (currently only one core supported)
  • Loading branch information
sarahspberrypi committed Dec 13, 2023
1 parent 1a89693 commit c444c99
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,20 +693,37 @@ pub fn boot_application_processors() {
"SMP Boot Code is larger than a page"
);
debug!("SMP boot code is {} bytes long", smp_boot_code.len());
// We can only allocate full pages of physmem

if crate::kernel::is_uefi() {
// Currently, this does NOT work as intended, this only supports one core
let length = BasePageSize::SIZE as usize;
let phys_addr: PhysAddr = crate::arch::mm::physicalmem::allocate(length).unwrap();

let mut flags = PageTableEntryFlags::empty();
flags.normal().writable();
debug!(
"Mapping SMP boot code from physical address {phys_addr:x} to virtual address {:p}",
SMP_BOOT_CODE_ADDRESS
);
//map physical memory to SMP_BOOT_CODE_ADDRESS in virtual memory
paging::map::<BasePageSize>(SMP_BOOT_CODE_ADDRESS, phys_addr, 1, flags);
} else {
// Identity-map the boot code page and copy over the code.
debug!(
"Mapping SMP boot code to physical and virtual address {:p}",
SMP_BOOT_CODE_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.normal().writable();
paging::map::<BasePageSize>(
SMP_BOOT_CODE_ADDRESS,
PhysAddr(SMP_BOOT_CODE_ADDRESS.as_u64()),
1,
flags,
);
}

// Identity-map the boot code page and copy over the code.
debug!(
"Mapping SMP boot code to physical and virtual address {:p}",
SMP_BOOT_CODE_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.normal().writable();
paging::map::<BasePageSize>(
SMP_BOOT_CODE_ADDRESS,
PhysAddr(SMP_BOOT_CODE_ADDRESS.as_u64()),
1,
flags,
);
unsafe {
ptr::copy_nonoverlapping(
smp_boot_code.as_ptr(),
Expand Down

0 comments on commit c444c99

Please sign in to comment.