Skip to content

Commit 9273860

Browse files
committed
fix: remove static mut multiboot memory management
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
1 parent 0cb21fd commit 9273860

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/arch/x86_64/fdt.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ use alloc::format;
33
use multiboot::information::{MemoryType, Multiboot};
44
use vm_fdt::{Error as FdtError, FdtWriter};
55

6-
use super::{mb_info, MEM};
6+
use super::{mb_info, Mem};
77

88
pub struct DeviceTree;
99

1010
impl DeviceTree {
1111
#[cfg(all(target_os = "none", not(feature = "fc")))]
1212
pub fn create() -> Result<&'static [u8], FdtError> {
13-
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut MEM).unwrap() };
13+
let mut mem = Mem;
14+
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };
1415

1516
let all_regions = multiboot
1617
.memory_regions()

src/arch/x86_64/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ static mut COM1: SerialPort = unsafe { SerialPort::new(SERIAL_IO_PORT) };
5555

5656
#[cfg(all(target_os = "none", not(feature = "fc")))]
5757
struct Mem;
58-
#[cfg(all(target_os = "none", not(feature = "fc")))]
59-
static mut MEM: Mem = Mem;
6058

6159
#[cfg(all(target_os = "none", not(feature = "fc")))]
6260
impl MemoryManagement for Mem {
@@ -213,8 +211,9 @@ pub fn find_kernel() -> &'static [u8] {
213211
let page_address = unsafe { mb_info.align_down(Size4KiB::SIZE as usize) };
214212
paging::map::<Size4KiB>(page_address, page_address, 1, PageTableFlags::empty());
215213

214+
let mut mem = Mem;
216215
// Load the Multiboot information and identity-map the modules information.
217-
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut MEM).unwrap() };
216+
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };
218217
let modules_address = multiboot
219218
.modules()
220219
.expect("Could not find a memory map in the Multiboot information")
@@ -440,7 +439,8 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
440439
entry_point,
441440
} = kernel_info;
442441

443-
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut MEM).unwrap() };
442+
let mut mem = Mem;
443+
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };
444444

445445
// determine boot stack address
446446
let mut new_stack = ptr::addr_of!(kernel_end)

0 commit comments

Comments
 (0)