diff options
Diffstat (limited to '')
| -rw-r--r-- | rsnix/src/memory.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs index c80edab..54ff7be 100644 --- a/rsnix/src/memory.rs +++ b/rsnix/src/memory.rs | |||
| @@ -289,7 +289,7 @@ pub fn capture_memory_map(bs: &BootServices) -> Result<usize, Status> { | |||
| 289 | let buf_size = buf_size.div_ceil(desc_size) * desc_size; | 289 | let buf_size = buf_size.div_ceil(desc_size) * desc_size; |
| 290 | 290 | ||
| 291 | // If our static buffer is too small, fall back to pool (rare) | 291 | // If our static buffer is too small, fall back to pool (rare) |
| 292 | if buf_size > unsafe { MAP_WORK_BUF.len() } { | 292 | if buf_size > unsafe { (*core::ptr::addr_of!(MAP_WORK_BUF)).len() } { |
| 293 | return Err(EFI_BUFFER_TOO_SMALL); | 293 | return Err(EFI_BUFFER_TOO_SMALL); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| @@ -337,7 +337,12 @@ pub fn capture_memory_map(bs: &BootServices) -> Result<usize, Status> { | |||
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | /// Retry ExitBootServices with a fresh memory map. | 339 | /// Retry ExitBootServices with a fresh memory map. |
| 340 | pub fn refresh_and_exit(bs: &BootServices, image_handle: Handle) -> Result<usize, Status> { | 340 | /// |
| 341 | /// # Safety | ||
| 342 | /// | ||
| 343 | /// `image_handle` must be the valid EFI image handle this kernel was | ||
| 344 | /// started with (opaque firmware pointer; never dereferenced here). | ||
| 345 | pub unsafe fn refresh_and_exit(bs: &BootServices, image_handle: Handle) -> Result<usize, Status> { | ||
| 341 | let key = capture_memory_map(bs)?; | 346 | let key = capture_memory_map(bs)?; |
| 342 | let status = unsafe { (bs.exit_boot_services)(image_handle, key) }; | 347 | let status = unsafe { (bs.exit_boot_services)(image_handle, key) }; |
| 343 | if status == EFI_SUCCESS { | 348 | if status == EFI_SUCCESS { |
| @@ -591,7 +596,7 @@ pub fn init_page_allocator() -> bool { | |||
| 591 | 596 | ||
| 592 | // The bitmap itself lives in the heap (one allocation, never freed). | 597 | // The bitmap itself lives in the heap (one allocation, never freed). |
| 593 | // `bytes` >= 1 and align 16 is a power of two, so this cannot fail. | 598 | // `bytes` >= 1 and align 16 is a power of two, so this cannot fail. |
| 594 | let layout = unsafe { Layout::from_size_align_unchecked(bytes, 16) }; | 599 | let layout = Layout::from_size_align_unchecked(bytes, 16); |
| 595 | let bm = ALLOCATOR.alloc(layout); | 600 | let bm = ALLOCATOR.alloc(layout); |
| 596 | if bm.is_null() { | 601 | if bm.is_null() { |
| 597 | return false; | 602 | return false; |
