Skip to content

Commit 9a3ca5f

Browse files
committed
build: Allow use of static mut refs
Signed-off-by: Akira Moroo <[email protected]>
1 parent 441c2ba commit 9a3ca5f

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

src/arch/aarch64/paging.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,17 @@ impl interface::Mmu for MemoryManagementUnit {
277277
self.setup_mair();
278278

279279
// Populate translation tables.
280+
#[allow(static_mut_refs)]
280281
KERNEL_TABLES
281282
.get_mut()
282283
.populate_tt_entries()
283284
.map_err(MmuEnableError::Other)?;
284285

285286
// Set the "Translation Table Base Register".
286-
TTBR0_EL1.set_baddr(KERNEL_TABLES.get_mut().phys_base_address());
287+
TTBR0_EL1.set_baddr(
288+
#[allow(static_mut_refs)]
289+
KERNEL_TABLES.get_mut().phys_base_address(),
290+
);
287291

288292
self.configure_translation_control();
289293

src/arch/x86_64/paging.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static mut L2_TABLES: SyncUnsafeCell<[PageTable; ADDRESS_SPACE_GIB]> =
2525
pub fn setup() {
2626
// SAFETY: This function is idempontent and only writes to static memory and
2727
// CR3. Thus, it is safe to run multiple times or on multiple threads.
28+
#[allow(static_mut_refs)]
2829
let (l4, l3, l2s) = unsafe { (L4_TABLE.get_mut(), L3_TABLE.get_mut(), L2_TABLES.get_mut()) };
2930
info!("Setting up {} GiB identity mapping", ADDRESS_SPACE_GIB);
3031
let pt_flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;

src/efi/boot_services.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ pub extern "efiapi" fn locate_handle(
275275
handles: *mut Handle,
276276
) -> Status {
277277
if unsafe { *guid } == r_efi::protocols::block_io::PROTOCOL_GUID {
278+
#[allow(static_mut_refs)]
278279
let count = unsafe { BLOCK_WRAPPERS.get_mut().count };
279280
if unsafe { *size } < size_of::<Handle>() * count {
280281
unsafe { *size = size_of::<Handle>() * count };
@@ -286,7 +287,8 @@ pub extern "efiapi" fn locate_handle(
286287

287288
let wrappers_as_handles: &[Handle] = unsafe {
288289
core::slice::from_raw_parts_mut(
289-
BLOCK_WRAPPERS.get_mut().wrappers.as_mut_ptr() as *mut Handle,
290+
(#[allow(static_mut_refs)]
291+
BLOCK_WRAPPERS.get_mut().wrappers.as_mut_ptr()) as *mut Handle,
290292
count,
291293
)
292294
};
@@ -310,7 +312,9 @@ pub extern "efiapi" fn locate_device_path(
310312
}
311313

312314
pub extern "efiapi" fn install_configuration_table(guid: *mut Guid, table: *mut c_void) -> Status {
315+
#[allow(static_mut_refs)]
313316
let st = unsafe { ST.get_mut() };
317+
#[allow(static_mut_refs)]
314318
let ct = unsafe { CT.get_mut() };
315319

316320
for entry in ct.iter_mut() {
@@ -436,6 +440,7 @@ pub extern "efiapi" fn start_image(
436440
let ptr = address as *const ();
437441
let code: extern "efiapi" fn(Handle, *mut efi::SystemTable) -> Status =
438442
unsafe { core::mem::transmute(ptr) };
443+
#[allow(static_mut_refs)]
439444
(code)(image_handle, unsafe { ST.get() })
440445
}
441446

@@ -521,7 +526,8 @@ pub extern "efiapi" fn open_protocol(
521526
{
522527
unsafe {
523528
if let Some(block_part_id) = (*(handle as *mut file::FileSystemWrapper)).block_part_id {
524-
*out = (&mut (*(BLOCK_WRAPPERS.get_mut().wrappers[block_part_id as usize]))
529+
*out = (&mut (*(#[allow(static_mut_refs)]
530+
BLOCK_WRAPPERS.get_mut().wrappers[block_part_id as usize]))
525531
.controller_path) as *mut _ as *mut c_void;
526532

527533
return Status::SUCCESS;

src/efi/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ fn new_image_handle(
168168
proto: LoadedImageProtocol {
169169
revision: r_efi::protocols::loaded_image::REVISION,
170170
parent_handle,
171+
#[allow(static_mut_refs)]
171172
system_table: unsafe { ST.get_mut() },
172173
device_handle,
173174
file_path,
@@ -195,6 +196,7 @@ pub fn efi_exec(
195196
) {
196197
let vendor_data = 0u32;
197198

199+
#[allow(static_mut_refs)]
198200
let ct = unsafe { CT.get_mut() };
199201
let mut ct_index = 0;
200202

@@ -250,24 +252,31 @@ pub fn efi_exec(
250252

251253
let mut stdin = console::STDIN;
252254
let mut stdout = console::STDOUT;
255+
#[allow(static_mut_refs)]
253256
let st = unsafe { ST.get_mut() };
254257
st.con_in = &mut stdin;
255258
st.con_out = &mut stdout;
256259
st.std_err = &mut stdout;
257-
st.runtime_services = unsafe { RS.get_mut() };
258-
st.boot_services = unsafe { BS.get_mut() };
260+
st.runtime_services = unsafe {
261+
#[allow(static_mut_refs)]
262+
RS.get_mut()
263+
};
264+
st.boot_services = unsafe {
265+
#[allow(static_mut_refs)]
266+
BS.get_mut()
267+
};
259268
st.number_of_table_entries = 1;
260269
st.configuration_table = &mut ct[0];
261270

262271
populate_allocator(info, loaded_address, loaded_size);
263272

273+
#[allow(static_mut_refs)]
264274
let efi_part_id = unsafe { block::populate_block_wrappers(BLOCK_WRAPPERS.get_mut(), block) };
265275

266276
let wrapped_fs = file::FileSystemWrapper::new(fs, efi_part_id);
267277

268278
let mut path = [0u8; 256];
269-
path[0..crate::efi::EFI_BOOT_PATH.len()]
270-
.copy_from_slice(crate::efi::EFI_BOOT_PATH.as_bytes());
279+
path[0..crate::efi::EFI_BOOT_PATH.len()].copy_from_slice(crate::efi::EFI_BOOT_PATH.as_bytes());
271280
let device_path = DevicePath::File(path);
272281
let image = new_image_handle(
273282
device_path.generate(),

src/efi/runtime_services.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ pub static mut RS: SyncUnsafeCell<efi::RuntimeServices> =
4646

4747
#[allow(clippy::missing_transmute_annotations)]
4848
unsafe fn fixup_at_virtual(descriptors: &[MemoryDescriptor]) {
49+
#[allow(static_mut_refs)]
4950
let st = ST.get_mut();
51+
#[allow(static_mut_refs)]
5052
let rs = RS.get_mut();
5153

5254
let ptr = ALLOCATOR

0 commit comments

Comments
 (0)