Skip to content

Commit

Permalink
fix(extern static): unsafe_op_in_unsafe_fn
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 4, 2024
1 parent 46bbfd3 commit 0cc400a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn output_message_byte(byte: u8) {
}

pub unsafe fn get_memory(_memory_size: u64) -> u64 {
(ptr::addr_of!(kernel_end).addr() as u64).align_up(LargePageSize::SIZE as u64)
(unsafe { ptr::addr_of!(kernel_end) }.addr() as u64).align_up(LargePageSize::SIZE as u64)
}

pub fn find_kernel() -> &'static [u8] {
Expand Down Expand Up @@ -159,21 +159,21 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = ptr::addr_of!(l1_pgtable).addr() as u64 + PT_PT;
pgt_slice[511] = ptr::addr_of!(l0_pgtable).addr() as u64 + PT_PT + PT_SELF;
pgt_slice[0] = unsafe { ptr::addr_of!(l1_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[511] = unsafe { ptr::addr_of!(l0_pgtable) }.addr() as u64 + PT_PT + PT_SELF;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l1_pgtable), 512) };
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = ptr::addr_of!(l2_pgtable).addr() as u64 + PT_PT;
pgt_slice[1] = ptr::addr_of!(l2k_pgtable).addr() as u64 + PT_PT;
pgt_slice[0] = unsafe { ptr::addr_of!(l2_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[1] = unsafe { ptr::addr_of!(l2k_pgtable) }.addr() as u64 + PT_PT;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l2_pgtable), 512) };
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = ptr::addr_of!(l3_pgtable).addr() as u64 + PT_PT;
pgt_slice[0] = unsafe { ptr::addr_of!(l3_pgtable) }.addr() as u64 + PT_PT;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l3_pgtable), 512) };
for i in pgt_slice.iter_mut() {
Expand All @@ -187,8 +187,9 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
*i = 0;
}
for (i, pgt_slice) in pgt_slice.iter_mut().enumerate().take(10) {
*pgt_slice =
ptr::addr_of!(L0mib_pgtable).addr() as u64 + (i * BasePageSize::SIZE) as u64 + PT_PT;
*pgt_slice = unsafe { ptr::addr_of!(L0mib_pgtable) }.addr() as u64
+ (i * BasePageSize::SIZE) as u64
+ PT_PT;
}

let pgt_slice =
Expand Down
5 changes: 3 additions & 2 deletions src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
} = kernel_info;

// determine boot stack address
let new_stack = (ptr::addr_of!(kernel_end).addr() + 0x1000).align_up(Size4KiB::SIZE as usize);
let new_stack =
(unsafe { ptr::addr_of!(kernel_end) }.addr() + 0x1000).align_up(Size4KiB::SIZE as usize);

let cmdline_ptr = unsafe {
*(sptr::from_exposed_addr(boot_params + LINUX_SETUP_HEADER_OFFSET + CMD_LINE_PTR_OFFSET))
Expand Down Expand Up @@ -443,7 +444,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };

// determine boot stack address
let mut new_stack = ptr::addr_of!(kernel_end)
let mut new_stack = unsafe { ptr::addr_of!(kernel_end) }
.addr()
.align_up(Size4KiB::SIZE as usize);

Expand Down

0 comments on commit 0cc400a

Please sign in to comment.