-
-
Notifications
You must be signed in to change notification settings - Fork 170
uefi-raw: Add HII_CONFIG_ACCESS and KEYWORD_HANDLER protocol bindings #1683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seijikun
wants to merge
1
commit into
rust-osdev:main
Choose a base branch
from
seijikun:mr-raw-hiicfg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
//! Bindings for HII protocols relating to system configuration. | ||
|
||
use core::fmt::Debug; | ||
|
||
use crate::{Char16, Guid, Status, guid}; | ||
|
||
/// EFI_KEYWORD_HANDLER_PROTOCOL | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct HiiKeywordHandlerProtocol { | ||
pub set_data: unsafe extern "efiapi" fn( | ||
this: *mut Self, | ||
keyword_string: *const Char16, | ||
progress: *mut *const Char16, | ||
progress_err: *mut u32, | ||
) -> Status, | ||
pub get_data: unsafe extern "efiapi" fn( | ||
this: *const Self, | ||
namespace_id: *const Char16, | ||
keyword_string: *const Char16, | ||
progress: *mut *const Char16, | ||
progress_err: *mut u32, | ||
results: *mut *const Char16, | ||
) -> Status, | ||
} | ||
|
||
impl HiiKeywordHandlerProtocol { | ||
pub const GUID: Guid = guid!("0a8badd5-03b8-4d19-b128-7b8f0edaa596"); | ||
} | ||
|
||
newtype_enum! { | ||
/// Type of action taken by the form browser | ||
#[derive(Default)] | ||
pub enum EfiBrowserAction: u32 => { | ||
/// Called before the browser changes the value in the display (for questions which have a value) | ||
/// or takes an action (in the case of an action button or cross-reference). | ||
/// If EFI_SUCCESS is returned, the browser uses the value returned by Callback(). | ||
CHANGING = 0, | ||
/// Called after the browser has changed its internal copy of the question value and displayed it (if appropriate). | ||
/// For action buttons, this is called after processing. Errors are ignored. | ||
CHANGED = 1, | ||
/// Called after the browser has read the current question value but before displaying it. | ||
/// If EFI_SUCCESS is returned, the updated value is used. | ||
RETRIEVE = 2, | ||
/// Called for each question on a form prior to its value being retrieved or displayed. | ||
/// If a question appears on more than one form, this may be called more than once. | ||
FORM_OPEN = 3, | ||
/// Called for each question on a form after processing any submit actions for that form. | ||
/// If a question appears on multiple forms, this will be called more than once. | ||
FORM_CLOSE = 4, | ||
/// Called after the browser submits the modified question value. | ||
/// ActionRequest is ignored. | ||
SUBMITTED = 5, | ||
/// Represents the standard default action, selecting a default value based on lower-priority methods. | ||
DEFAULT_STANDARD = 0x1000, | ||
/// Represents the manufacturing default action, selecting a default value relevant to manufacturing. | ||
DEFAULT_MANUFACTURING = 0x1001, | ||
/// Represents the safe default action, selecting the safest possible default value. | ||
DEFAULT_SAFE = 0x1002, | ||
/// Represents platform-defined default values within a range of possible store identifiers. | ||
DEFAULT_PLATFORM = 0x2000, | ||
/// Represents hardware-defined default values within a range of possible store identifiers. | ||
DEFAULT_HARDWARE = 0x3000, | ||
/// Represents firmware-defined default values within a range of possible store identifiers. | ||
DEFAULT_FIRMWARE = 0x4000, | ||
} | ||
} | ||
|
||
newtype_enum! { | ||
/// Represents actions requested by the Forms Browser in response to user interactions. | ||
#[derive(Default)] | ||
pub enum EfiBrowserActionRequest: usize => { | ||
/// No special behavior is taken by the Forms Browser. | ||
NONE = 0, | ||
/// The Forms Browser will exit and request the platform to reset. | ||
RESET = 1, | ||
/// The Forms Browser will save all modified question values to storage and exit. | ||
SUBMIT = 2, | ||
/// The Forms Browser will discard all modified question values and exit. | ||
EXIT = 3, | ||
/// The Forms Browser will write all modified question values on the selected form to storage and exit the form. | ||
FORM_SUBMIT_EXIT = 4, | ||
/// The Forms Browser will discard the modified question values on the selected form and exit the form. | ||
FORM_DISCARD_EXIT = 5, | ||
/// The Forms Browser will write all modified current question values on the selected form to storage. | ||
FORM_APPLY = 6, | ||
/// The Forms Browser will discard the current question values on the selected form and replace them with the original values. | ||
FORM_DISCARD = 7, | ||
/// The user performed a hardware or software configuration change, requiring controller reconnection. | ||
/// The Forms Browser calls `DisconnectController()` followed by `ConnectController()`. | ||
RECONNECT = 8, | ||
/// The Forms Browser will write the current modified question value on the selected form to storage. | ||
QUESTION_APPLY = 9, | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct EfiHiiTime { | ||
pub hour: u8, | ||
pub minute: u8, | ||
pub second: u8, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct EfiHiiDate { | ||
pub year: u16, | ||
pub month: u8, | ||
pub day: u8, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct EfiHiiRef { | ||
pub question_id: EfiQuestionId, | ||
pub form_id: EfiFormId, | ||
pub guid: Guid, | ||
pub string_id: EfiStringId, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone)] | ||
pub union EfiIfrTypeValue { | ||
pub u8: u8, // EFI_IFR_TYPE_NUM_SIZE_8 | ||
pub u16: u16, // EFI_IFR_TYPE_NUM_SIZE_16 | ||
pub u32: u32, // EFI_IFR_TYPE_NUM_SIZE_32 | ||
pub u64: u64, // EFI_IFR_TYPE_NUM_SIZE_64 | ||
pub b: bool, // EFI_IFR_TYPE_BOOLEAN | ||
pub time: EfiHiiTime, // EFI_IFR_TYPE_TIME | ||
pub date: EfiHiiDate, // EFI_IFR_TYPE_DATE | ||
pub string: EfiStringId, // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION | ||
pub hii_ref: EfiHiiRef, // EFI_IFR_TYPE_REF | ||
} | ||
impl core::fmt::Debug for EfiIfrTypeValue { | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
f.debug_struct("EfiIfrTypeValue").finish() | ||
} | ||
} | ||
|
||
pub type EfiQuestionId = u16; | ||
pub type EfiFormId = u16; | ||
pub type EfiStringId = u16; | ||
|
||
/// EFI_HII_CONFIG_ACCESS_PROTOCOL | ||
#[derive(Debug)] | ||
#[repr(C)] | ||
pub struct HiiConfigAccessProtocol { | ||
pub extract_config: unsafe extern "efiapi" fn( | ||
this: *const Self, | ||
request: *const Char16, | ||
progress: *mut *const Char16, | ||
results: *mut *const Char16, | ||
) -> Status, | ||
pub route_config: unsafe extern "efiapi" fn( | ||
this: *const Self, | ||
configuration: *const Char16, | ||
progress: *mut *const Char16, | ||
) -> Status, | ||
pub callback: unsafe extern "efiapi" fn( | ||
this: *const Self, | ||
action: EfiBrowserAction, | ||
question_id: u16, | ||
value_type: u8, | ||
value: *mut EfiIfrTypeValue, | ||
action_request: *mut EfiBrowserActionRequest, | ||
) -> Status, | ||
} | ||
|
||
impl HiiConfigAccessProtocol { | ||
pub const GUID: Guid = guid!("330d4706-f2a0-4e4f-a369-b66fa8d54385"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
//! HII Protocols | ||
|
||
pub mod config; | ||
pub mod database; | ||
|
||
use crate::{Char16, Guid}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found myself confused by naming when looking at this in the spec. It starts out referring to
EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL
, but then in the parameters ofGetData
andSetData
the type of theThis
pointer isEFI_KEYWORD_HANDLER_PROTOCOL
.I guess this is just a mistake in the spec? It looks like edk2 sticks with the
EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL
naming, so (unless I'm missing something, which is very possible) I think the name here should beConfigKeywordHandlerProtocol
.