uefi/hii/
database.rs

1use crate::prelude::*;
2
3use super::package::{HiiPackageHeader, HiiPackageKind, HiiPackageListHeader};
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
6#[repr(transparent)]
7pub struct HiiHandle(pub usize);
8
9pub type HiiDatabaseNotify = extern "efiapi" fn(
10    PackageKind: HiiPackageKind,
11    PackageGuid: &Guid,
12    Package: &HiiPackageHeader,
13    Handle: HiiHandle,
14    NotifyKind: HiiDatabaseNotifyKind,
15) -> Status;
16
17#[repr(usize)]
18pub enum HiiDatabaseNotifyKind {
19    NewPack = 1,
20    RemovePack = 2,
21    ExportPack = 4,
22    AddPack = 8,
23}
24
25#[repr(C)]
26pub struct HiiKeyboardLayout {
27    /// The length of the current keyboard layout
28    pub LayoutLength: u16,
29    /// The unique ID associated with this keyboard layout
30    pub Guid: Guid,
31    /// An offset location of the string which describes this keyboard layout, as a DescriptionStringBundle
32    pub LayoutDescriptorStringOffset: u32,
33    /// The number of Descriptor entries in this layout
34    pub DescriptorCount: u8,
35    //Descriptors: [KeyDescriptor; DescriptorCount]
36}
37
38#[repr(C)]
39pub struct HiiDatabase {
40    /// Adds the packages in the package list to the HII database
41    pub NewPackageList: extern "efiapi" fn(
42        &HiiDatabase,
43        PackageList: &HiiPackageListHeader,
44        DriverHandle: Handle,
45        Handle: &mut HiiHandle,
46    ) -> Status,
47
48    /// Removes a package list from the HII database
49    pub RemovePackageList: extern "efiapi" fn(&HiiDatabase, Handle: HiiHandle) -> Status,
50
51    /// Update a package list in the HII database
52    pub UpdatePackageList: extern "efiapi" fn(
53        &HiiDatabase,
54        Handle: HiiHandle,
55        PackageList: &HiiPackageListHeader,
56    ) -> Status,
57
58    /// Determines the handles that are currently active in the database
59    pub ListPackageLists: extern "efiapi" fn(
60        &HiiDatabase,
61        PackageKind: HiiPackageKind,
62        PackageGuid: &Guid,
63        HandleBufferLength: &mut usize,
64        Handle: *mut HiiHandle,
65    ) -> Status,
66
67    /// Exports the contents of one or all package lists in the HII database into a buffer
68    pub ExportPackageLists: extern "efiapi" fn(
69        &HiiDatabase,
70        Handle: HiiHandle,
71        BufferSize: &mut usize,
72        Buffer: &mut HiiPackageListHeader,
73    ) -> Status,
74
75    /// Registers a notification function for HII database-related events
76    pub RegisterPackageNotify: extern "efiapi" fn(
77        &HiiDatabase,
78        PackageKind: HiiPackageKind,
79        PackageGuid: &Guid,
80        PackageNotifyFn: HiiDatabaseNotify,
81        NotifyKind: HiiDatabaseNotifyKind,
82        NotifyHandle: &mut Handle,
83    ) -> Status,
84
85    /// Removes the specified HII database package-related notification
86    pub UnregisterPackageNotify:
87        extern "efiapi" fn(&HiiDatabase, NotificationHandle: Handle) -> Status,
88
89    /// Retrieves a list of the keyboard layouts in the system
90    pub FindKeyboardLayouts: extern "efiapi" fn(
91        &HiiDatabase,
92        KeyGuidBufferLength: &mut u16,
93        KeyGuidBuffer: *mut Guid,
94    ) -> Status,
95
96    /// Retrieves the requested keyboard layout
97    pub GetKeyboardLayout: extern "efiapi" fn(
98        &HiiDatabase,
99        KeyGuid: &Guid,
100        KeyboardLayoutLength: &mut u16,
101        KeyboardLayout: *mut HiiKeyboardLayout,
102    ) -> Status,
103
104    /// Sets the currently active keyboard layout
105    pub SetKeyboardLayout: extern "efiapi" fn(&HiiDatabase, KeyGuid: &Guid) -> Status,
106
107    /// Return the EFI handle associated with a package list
108    pub GetPackageListHandle: extern "efiapi" fn(
109        &HiiDatabase,
110        PackageListHandle: HiiHandle,
111        DriverHandle: &mut Handle,
112    ) -> Status,
113}
114
115impl HiiDatabase {
116    pub const GUID: Guid = guid!("ef9fc172-a1b2-4693-b327-6d32fc416042");
117}