Skip to content

Commit 6f62488

Browse files
retragerbradford
authored andcommitted
efi: Add initial EFI variable support
Signed-off-by: Akira Moroo <retrage01@gmail.com>
1 parent 59068a9 commit 6f62488

File tree

2 files changed

+367
-12
lines changed

2 files changed

+367
-12
lines changed

src/efi/mod.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ mod alloc;
3434
mod block;
3535
mod console;
3636
mod file;
37+
mod var;
3738

3839
use alloc::Allocator;
40+
use var::VariableAllocator;
3941

4042
#[derive(Copy, Clone, PartialEq)]
4143
enum HandleType {
@@ -63,6 +65,9 @@ fn heap_alloc_error_handler(layout: heap_alloc::Layout) -> ! {
6365
panic!("heap allocation error: {:?}", layout);
6466
}
6567

68+
pub static VARIABLES: AtomicRefCell<VariableAllocator> =
69+
AtomicRefCell::new(VariableAllocator::new());
70+
6671
static mut RS: efi::RuntimeServices = efi::RuntimeServices {
6772
hdr: efi::TableHeader {
6873
signature: efi::RUNTIME_SERVICES_SIGNATURE,
@@ -249,13 +254,15 @@ pub extern "win64" fn convert_pointer(_: usize, _: *mut *mut c_void) -> Status {
249254
}
250255

251256
pub extern "win64" fn get_variable(
252-
_: *mut Char16,
253-
_: *mut Guid,
254-
_: *mut u32,
255-
_: *mut usize,
256-
_: *mut core::ffi::c_void,
257+
variable_name: *mut Char16,
258+
vendor_guid: *mut Guid,
259+
attributes: *mut u32,
260+
data_size: *mut usize,
261+
data: *mut core::ffi::c_void,
257262
) -> Status {
258-
Status::NOT_FOUND
263+
VARIABLES
264+
.borrow_mut()
265+
.get(variable_name, vendor_guid, attributes, data_size, data)
259266
}
260267

261268
pub extern "win64" fn get_next_variable_name(
@@ -267,13 +274,15 @@ pub extern "win64" fn get_next_variable_name(
267274
}
268275

269276
pub extern "win64" fn set_variable(
270-
_: *mut Char16,
271-
_: *mut Guid,
272-
_: u32,
273-
_: usize,
274-
_: *mut c_void,
277+
variable_name: *mut Char16,
278+
vendor_guid: *mut Guid,
279+
attributes: u32,
280+
data_size: usize,
281+
data: *mut c_void,
275282
) -> Status {
276-
Status::UNSUPPORTED
283+
VARIABLES
284+
.borrow_mut()
285+
.set(variable_name, vendor_guid, attributes, data_size, data)
277286
}
278287

279288
pub extern "win64" fn get_next_high_mono_count(_: *mut u32) -> Status {

0 commit comments

Comments
 (0)