-
-
Notifications
You must be signed in to change notification settings - Fork 181
uefi-raw: Add bindings for more HII protocols #1822
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
crawfxrd
wants to merge
1
commit into
rust-osdev:main
Choose a base branch
from
crawfxrd:hii-bindings
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.
+449
−4
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
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,207 @@ | ||
| // SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
|
||
| //! Bindings for HII Font protocols and data types | ||
| use super::{HiiHandle, StringId}; | ||
| use crate::protocol::console::GraphicsOutputBltPixel; | ||
| use crate::protocol::hii::image::ImageOutput; | ||
| use crate::{Char8, Char16, Guid, Status, guid}; | ||
|
|
||
| pub type FontHandle = *mut core::ffi::c_void; | ||
|
|
||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct HiiGlyphInfo { | ||
| pub width: u16, | ||
| pub height: u16, | ||
| pub offset_x: i16, | ||
| pub offset_y: i16, | ||
| pub advance_x: i16, | ||
| } | ||
|
|
||
| bitflags::bitflags! { | ||
| /// EFI_FONT_INFO_MASK | ||
| #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
| #[repr(transparent)] | ||
| pub struct FontInfoMask: u32 { | ||
| const SYS_FONT = 1 << 0; | ||
| const SYS_SIZE = 1 << 1; | ||
| const SYS_STYLE = 1 << 2; | ||
| const SYS_FORE_COLOR = 1 << 4; | ||
| const SYS_BACK_COLOR = 1 << 5; | ||
| const RESIZE = 1 << 12; | ||
| const RESTYLE = 1 << 13; | ||
| const ANY_FONT = 1 << 16; | ||
| const ANY_SIZE = 1 << 17; | ||
| const ANY_STYLE = 1 << 18; | ||
| } | ||
| } | ||
|
|
||
| bitflags::bitflags! { | ||
| /// EFI_HII_FONT_STYLE | ||
| #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
| #[repr(transparent)] | ||
| pub struct HiiFontStyle: u32 { | ||
| const NORMAL = 0; | ||
| const BOLD = 1 << 0; | ||
| const ITALIC = 1 << 1; | ||
| const EMBOSS = 1 << 16; | ||
| const OUTLINE = 1 << 17; | ||
| const SHADOW = 1 << 18; | ||
| const UNDERLINE = 1 << 19; | ||
| const DBL_UNDER = 1 << 20; | ||
| } | ||
| } | ||
|
|
||
| /// EFI_FONT_INFO | ||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct FontInfo { | ||
| pub font_style: HiiFontStyle, | ||
| pub font_size: u16, | ||
| pub font_name: [Char16; 0], | ||
| } | ||
|
|
||
| /// EFI_FONT_DISPLAY_INFO | ||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct FontDisplayInfo { | ||
| pub foreground_color: GraphicsOutputBltPixel, | ||
| pub background_color: GraphicsOutputBltPixel, | ||
| pub font_mask_info: FontInfoMask, | ||
| pub font_info: FontInfo, | ||
| } | ||
|
|
||
| bitflags::bitflags! { | ||
| /// EFI_HII_OUT_FLAGS | ||
| #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
| #[repr(transparent)] | ||
| pub struct HiiOutFlags: u32 { | ||
| const CLIP = 1 << 0; | ||
| const WRAP = 1 << 1; | ||
| const CLIP_CLEAN_Y = 1 << 2; | ||
| const CLIP_CLEAN_X = 1 << 3; | ||
| const TRANSPARENT = 1 << 4; | ||
| const IGNORE_IF_NO_GLYPH = 1 << 5; | ||
| const IGNORE_LINE_BREAK = 1 << 6; | ||
| const DIRECT_TO_SCREEN = 1 << 7; | ||
| } | ||
| } | ||
|
|
||
| /// EFI_HII_ROW_INFO | ||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct HiiRowInfo { | ||
| pub start_index: usize, | ||
| pub end_index: usize, | ||
| pub line_height: usize, | ||
| pub line_width: usize, | ||
| pub baseline_offset: usize, | ||
| } | ||
|
|
||
| /// EFI_HII_FONT_PROTOCOL | ||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct HiiFontProtocol { | ||
| pub string_to_image: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| flags: HiiOutFlags, | ||
| string: *const Char16, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| blt_x: usize, | ||
| blt_y: usize, | ||
| row_info_array: *mut *mut HiiRowInfo, | ||
| row_info_array_size: *mut usize, | ||
| column_info_array: *mut usize, | ||
| ) -> Status, | ||
| pub string_id_to_image: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| flags: HiiOutFlags, | ||
| package_list: HiiHandle, | ||
| string_id: StringId, | ||
| language: *const Char8, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| blt_x: usize, | ||
| blt_y: usize, | ||
| row_info_array: *mut *mut HiiRowInfo, | ||
| row_info_array_size: *mut usize, | ||
| column_info_array: *mut usize, | ||
| ) -> Status, | ||
| pub get_glyph: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| char: Char16, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| baseline: *mut usize, | ||
| ) -> Status, | ||
| pub get_font_info: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| font_handle: *mut FontHandle, | ||
| string_info_in: *const FontDisplayInfo, | ||
| string_info_out: *mut *mut FontDisplayInfo, | ||
| string: *const Char16, | ||
| ) -> Status, | ||
| } | ||
|
|
||
| impl HiiFontProtocol { | ||
| pub const GUID: Guid = guid!("e9ca4775-8657-47fc-97e7-7ed65a084324"); | ||
| } | ||
|
|
||
| // NOTE: This protocol is declared in the UEFI spec, but not defined in edk2. | ||
| /// EFI_HII_FONT_EX_PROTOCOL | ||
| #[derive(Debug)] | ||
| #[repr(C)] | ||
| pub struct HiiFontExProtocol { | ||
| pub string_to_image_ex: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| flags: HiiOutFlags, | ||
| string: *const Char16, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| blt_x: usize, | ||
| blt_y: usize, | ||
| row_info_array: *mut *mut HiiRowInfo, | ||
| row_info_array_size: *mut usize, | ||
| column_info_array: *mut usize, | ||
| ) -> Status, | ||
| pub string_id_to_image_ex: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| flags: HiiOutFlags, | ||
| package_list: HiiHandle, | ||
| string_id: StringId, | ||
| language: *const Char8, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| blt_x: usize, | ||
| blt_y: usize, | ||
| row_info_array: *mut *mut HiiRowInfo, | ||
| row_info_array_size: *mut usize, | ||
| column_info_array: *mut usize, | ||
| ) -> Status, | ||
| pub get_glyph_ex: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| char: Char16, | ||
| string_info: *const FontDisplayInfo, | ||
| blt: *mut *mut ImageOutput, | ||
| baseline: *mut usize, | ||
| ) -> Status, | ||
| pub get_font_info_ex: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| font_handle: *mut FontHandle, | ||
| string_info_in: *const FontDisplayInfo, | ||
| string_info_out: *mut *mut FontDisplayInfo, | ||
| string: *const Char16, | ||
| ) -> Status, | ||
| pub get_glyph_info: unsafe extern "efiapi" fn( | ||
| this: *const Self, | ||
| char: Char16, | ||
| font_display_info: *const FontDisplayInfo, | ||
| glyph_info: *mut HiiGlyphInfo, | ||
| ) -> Status, | ||
| } | ||
|
|
||
| impl HiiFontExProtocol { | ||
| pub const GUID: Guid = guid!("849e6875-db35-4df8-b41e-c8f33718073f"); | ||
| } | ||
Oops, something went wrong.
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.
bitflags recommends against having zero-bit flags. Not sure what to do with UEFI flags that use it as a default/none value.
Just checked, and they're not even used internally by edk2.