Skip to content

Commit e2fa3bc

Browse files
committed
* Add doc reference to SystemTable::get_current_system_table_addr() to method SystemTable::set_virtual_address_map().
* Cleanup implementation of SystemTable::set_virtual_address_map().
1 parent 6e57127 commit e2fa3bc

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/table/system.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::marker::PhantomData;
22
use core::{ptr, slice};
33

44
use crate::proto::console::text;
5-
use crate::{CStr16, Char16, Completion, Handle, Result, ResultExt, Status};
5+
use crate::{CStr16, Char16, Handle, Result, ResultExt, Status};
66

77
use super::boot::{BootServices, MemoryDescriptor};
88
use super::runtime::RuntimeServices;
@@ -212,11 +212,13 @@ impl SystemTable<Runtime> {
212212
/// Changes the runtime addressing mode of EFI firmware from physical to virtual.
213213
/// It is up to the caller to translate the old SystemTable address to a new virtual
214214
/// address and provide it for this function.
215-
/// See `get_current_system_table_addr()`
215+
/// See [`get_current_system_table_addr`]
216216
///
217217
/// # Safety
218218
///
219219
/// Setting new virtual memory map is unsafe and may cause undefined behaviors.
220+
///
221+
/// ['get_current_system_table_addr']: SystemTable::get_current_system_table_addr
220222
pub unsafe fn set_virtual_address_map(
221223
self,
222224
map: &mut [MemoryDescriptor],
@@ -230,27 +232,15 @@ impl SystemTable<Runtime> {
230232
let entry_size = core::mem::size_of::<MemoryDescriptor>();
231233
let entry_version = crate::table::boot::MEMORY_DESCRIPTOR_VERSION;
232234
let map_ptr = map.as_mut_ptr();
233-
let result: Result = (self.table.runtime.set_virtual_address_map)(
234-
map_size,
235-
entry_size,
236-
entry_version,
237-
map_ptr,
238-
)
239-
.into();
240-
match result {
241-
Ok(completion) => {
235+
(self.table.runtime.set_virtual_address_map)(map_size, entry_size, entry_version, map_ptr)
236+
.into_with_val(|| {
242237
let new_table_ref =
243238
&mut *(new_system_table_virtual_addr as usize as *mut SystemTableImpl);
244-
Ok(Completion::new(
245-
completion.status(),
246-
Self {
247-
table: new_table_ref,
248-
_marker: PhantomData,
249-
},
250-
))
251-
}
252-
Err(err) => Err(err),
253-
}
239+
Self {
240+
table: new_table_ref,
241+
_marker: PhantomData,
242+
}
243+
})
254244
}
255245

256246
/// Return the address of the SystemTable that resides in a UEFI runtime services

0 commit comments

Comments
 (0)