Skip to content

Commit

Permalink
efi: Add initial EFI variable support
Browse files Browse the repository at this point in the history
Signed-off-by: Akira Moroo <retrage01@gmail.com>
  • Loading branch information
retrage authored and rbradford committed Feb 24, 2021
1 parent 59068a9 commit 6f62488
Show file tree
Hide file tree
Showing 2 changed files with 367 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/efi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ mod alloc;
mod block;
mod console;
mod file;
mod var;

use alloc::Allocator;
use var::VariableAllocator;

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

pub static VARIABLES: AtomicRefCell<VariableAllocator> =
AtomicRefCell::new(VariableAllocator::new());

static mut RS: efi::RuntimeServices = efi::RuntimeServices {
hdr: efi::TableHeader {
signature: efi::RUNTIME_SERVICES_SIGNATURE,
Expand Down Expand Up @@ -249,13 +254,15 @@ pub extern "win64" fn convert_pointer(_: usize, _: *mut *mut c_void) -> Status {
}

pub extern "win64" fn get_variable(
_: *mut Char16,
_: *mut Guid,
_: *mut u32,
_: *mut usize,
_: *mut core::ffi::c_void,
variable_name: *mut Char16,
vendor_guid: *mut Guid,
attributes: *mut u32,
data_size: *mut usize,
data: *mut core::ffi::c_void,
) -> Status {
Status::NOT_FOUND
VARIABLES
.borrow_mut()
.get(variable_name, vendor_guid, attributes, data_size, data)
}

pub extern "win64" fn get_next_variable_name(
Expand All @@ -267,13 +274,15 @@ pub extern "win64" fn get_next_variable_name(
}

pub extern "win64" fn set_variable(
_: *mut Char16,
_: *mut Guid,
_: u32,
_: usize,
_: *mut c_void,
variable_name: *mut Char16,
vendor_guid: *mut Guid,
attributes: u32,
data_size: usize,
data: *mut c_void,
) -> Status {
Status::UNSUPPORTED
VARIABLES
.borrow_mut()
.set(variable_name, vendor_guid, attributes, data_size, data)
}

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

0 comments on commit 6f62488

Please sign in to comment.