Commit 10277bd9 authored by Jeremy Soller's avatar Jeremy Soller

Add HII database protocol

parent 2f6cbde2
Pipeline #3239 failed with stages
in 47 seconds
......@@ -38,6 +38,7 @@ pub const DEBUG_IMAGE_INFO_TABLE_GUID : Guid = Guid(0x49152e77, 0x1ada, 0x
pub const SHELL_GUID : Guid = Guid(0x6302d008, 0x7f9b, 0x4f30, [0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e]);
pub const SHELL_PARAMETERS_GUID : Guid = Guid(0x752f3136, 0x4e16, 0x4fdc, [0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca]);
pub const SIMPLE_POINTER_GUID : Guid = Guid(0x31878c87, 0x0b75, 0x11d5, [0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d]);
pub const HII_DATABASE_GUID : Guid = Guid(0xef9fc172, 0xa1b2, 0x4693, [0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42]);
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(C)]
......@@ -83,6 +84,7 @@ pub enum GuidKind {
Shell,
ShellParameters,
SimplePointer,
HiiDatabase,
Unknown
}
......@@ -127,6 +129,7 @@ impl Guid {
SHELL_GUID => GuidKind::Shell,
SHELL_PARAMETERS_GUID => GuidKind::ShellParameters,
SIMPLE_POINTER_GUID => GuidKind::SimplePointer,
HII_DATABASE_GUID => GuidKind::HiiDatabase,
_ => GuidKind::Unknown
}
}
......
use Handle;
use guid::Guid;
use status::Status;
use super::package::{HiiPackageKind, HiiPackageHeader, HiiPackageListHeader};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct HiiHandle(pub usize);
pub type HiiDatabaseNotify = extern "win64" fn (
PackageKind: HiiPackageKind,
PackageGuid: &Guid,
Package: &HiiPackageHeader,
Handle: HiiHandle,
NotifyKind: HiiDatabaseNotifyKind
) -> Status;
#[repr(usize)]
pub enum HiiDatabaseNotifyKind {
NewPack = 1,
RemovePack = 2,
ExportPack = 4,
AddPack = 8,
}
#[repr(C)]
pub struct HiiKeyboardLayout {
/// The length of the current keyboard layout
pub LayoutLength: u16,
/// The unique ID associated with this keyboard layout
pub Guid: Guid,
/// An offset location of the string which describes this keyboard layout, as a DescriptionStringBundle
pub LayoutDescriptorStringOffset: u32,
/// The number of Descriptor entries in this layout
pub DescriptorCount: u8,
//Descriptors: [KeyDescriptor; DescriptorCount]
}
#[repr(C)]
pub struct HiiDatabase {
/// Adds the packages in the package list to the HII database
pub NewPackageList: extern "win64" fn (
&HiiDatabase,
PackageList: &HiiPackageListHeader,
DriverHandle: Handle,
Handle: &mut HiiHandle
) -> Status,
/// Removes a package list from the HII database
pub RemovePackageList: extern "win64" fn (
&HiiDatabase,
Handle: HiiHandle
) -> Status,
/// Update a package list in the HII database
pub UpdatePackageList: extern "win64" fn (
&HiiDatabase,
Handle: HiiHandle,
PackageList: &HiiPackageListHeader
) -> Status,
/// Determines the handles that are currently active in the database
pub ListPackageLists: extern "win64" fn (
&HiiDatabase,
PackageKind: HiiPackageKind,
PackageGuid: &Guid,
HandleBufferLength: &mut usize,
Handle: &mut HiiHandle
) -> Status,
/// Exports the contents of one or all package lists in the HII database into a buffer
pub ExportPackageLists: extern "win64" fn (
&HiiDatabase,
Handle: HiiHandle,
BufferSize: &mut usize,
Buffer: &mut HiiPackageListHeader
) -> Status,
/// Registers a notification function for HII database-related events
pub RegisterPackageNotify: extern "win64" fn (
&HiiDatabase,
PackageKind: HiiPackageKind,
PackageGuid: &Guid,
PackageNotifyFn: HiiDatabaseNotify,
NotifyKind: HiiDatabaseNotifyKind,
NotifyHandle: &mut Handle
) -> Status,
/// Removes the specified HII database package-related notification
pub UnregisterPackageNotify: extern "win64" fn (
&HiiDatabase,
NotificationHandle: Handle
) -> Status,
/// Retrieves a list of the keyboard layouts in the system
pub FindKeyboardLayouts: extern "win64" fn (
&HiiDatabase,
KeyGuidBufferLength: &mut u16,
KeyGuidBuffer: *mut Guid
) -> Status,
/// Retrieves the requested keyboard layout
pub GetKeyboardLayout: extern "win64" fn (
&HiiDatabase,
KeyGuid: &Guid,
KeyboardLayoutLength: &mut u16,
KeyboardLayout: *mut HiiKeyboardLayout
) -> Status,
/// Sets the currently active keyboard layout
pub SetKeyboardLayout: extern "win64" fn (
&HiiDatabase,
KeyGuid: &Guid
) -> Status,
/// Return the EFI handle associated with a package list
pub GetPackageListHandle: extern "win64" fn (
&HiiDatabase,
PackageListHandle: HiiHandle,
DriverHandle: &mut Handle
) -> Status,
}
pub mod database;
pub mod package;
use core::{mem, slice};
use guid::Guid;
#[repr(u8)]
pub enum HiiPackageKind {
/// Pseudo-package type used when exporting package lists
All = 0x00,
/// Package type where the format of the data is specified using a GUID immediately following the package header
Guid = 0x01,
/// Forms package
Forms = 0x02,
/// Strings package
Strings = 0x04,
/// Fonts package
Fonts = 0x05,
/// Images package
Images = 0x06,
/// Simplified (8x19, 16x19) Fonts package
SimpleFonts = 0x07,
/// Binary-encoded device path
DevicePath = 0x08,
/// Keyboard Layout package
KeyboardLayout = 0x09,
/// Animations package
Animations = 0x0A,
/// Used to mark the end of a package list
End = 0xDF,
// Package types reserved for firmware implementations
//SystemBegin = 0xE0,
//SystemEnd = 0xFF,
}
#[repr(C)]
pub struct HiiPackageHeader {
pub Length_Kind: u32,
}
impl HiiPackageHeader {
pub fn Length(&self) -> u32 {
self.Length_Kind & 0xFFFFFF
}
pub fn Kind(&self) -> HiiPackageKind {
unsafe { mem::transmute((self.Length_Kind >> 24) as u8) }
}
pub fn Data(&self) -> &[u8] {
let size = mem::size_of::<Self>();
unsafe {
slice::from_raw_parts(
(self as *const Self as *const u8).add(size),
self.Length() as usize - size
)
}
}
}
#[repr(C)]
pub struct HiiPackageListHeader {
pub PackageListGuid: Guid,
pub PackageLength: u32,
}
impl HiiPackageListHeader {
pub fn Data(&self) -> &[u8] {
let size = mem::size_of::<Self>();
unsafe {
slice::from_raw_parts(
(self as *const Self as *const u8).add(size),
self.PackageLength as usize - size
)
}
}
}
......@@ -11,6 +11,7 @@ pub mod device;
pub mod fs;
pub mod graphics;
pub mod guid;
pub mod hii;
pub mod loaded_image;
pub mod memory;
pub mod pointer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment