aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / uefi-raw / src / protocol / hii / font.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | //! Bindings for HII Font protocols and data types |
| 4 | |
| 5 | use super::image::ImageOutput; |
| 6 | use super::{HiiHandle, StringId}; |
| 7 | use crate::protocol::console::GraphicsOutputBltPixel; |
| 8 | use crate::{Char8, Char16, Guid, Status, guid}; |
| 9 | use core::ffi; |
| 10 | |
| 11 | pub type FontHandle = *mut ffi::c_void; |
| 12 | |
| 13 | #[derive(Debug)] |
| 14 | #[repr(C)] |
| 15 | pub struct HiiGlyphInfo { |
| 16 | pub width: u16, |
| 17 | pub height: u16, |
| 18 | pub offset_x: i16, |
| 19 | pub offset_y: i16, |
| 20 | pub advance_x: i16, |
| 21 | } |
| 22 | |
| 23 | bitflags::bitflags! { |
| 24 | /// EFI_FONT_INFO_MASK |
| 25 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 26 | #[repr(transparent)] |
| 27 | pub struct FontInfoMask: u32 { |
| 28 | const SYS_FONT = 1 << 0; |
| 29 | const SYS_SIZE = 1 << 1; |
| 30 | const SYS_STYLE = 1 << 2; |
| 31 | const SYS_FORE_COLOR = 1 << 4; |
| 32 | const SYS_BACK_COLOR = 1 << 5; |
| 33 | const RESIZE = 1 << 12; |
| 34 | const RESTYLE = 1 << 13; |
| 35 | const ANY_FONT = 1 << 16; |
| 36 | const ANY_SIZE = 1 << 17; |
| 37 | const ANY_STYLE = 1 << 18; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | bitflags::bitflags! { |
| 42 | /// EFI_HII_FONT_STYLE |
| 43 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 44 | #[repr(transparent)] |
| 45 | pub struct HiiFontStyle: u32 { |
| 46 | const BOLD = 1 << 0; |
| 47 | const ITALIC = 1 << 1; |
| 48 | const EMBOSS = 1 << 16; |
| 49 | const OUTLINE = 1 << 17; |
| 50 | const SHADOW = 1 << 18; |
| 51 | const UNDERLINE = 1 << 19; |
| 52 | const DBL_UNDER = 1 << 20; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | impl HiiFontStyle { |
| 57 | pub const NORMAL: Self = Self::empty(); |
| 58 | } |
| 59 | |
| 60 | /// EFI_FONT_INFO |
| 61 | #[derive(Debug)] |
| 62 | #[repr(C)] |
| 63 | pub struct FontInfo { |
| 64 | pub font_style: HiiFontStyle, |
| 65 | pub font_size: u16, |
| 66 | pub font_name: [Char16; 0], |
| 67 | } |
| 68 | |
| 69 | /// EFI_FONT_DISPLAY_INFO |
| 70 | #[derive(Debug)] |
| 71 | #[repr(C)] |
| 72 | pub struct FontDisplayInfo { |
| 73 | pub foreground_color: GraphicsOutputBltPixel, |
| 74 | pub background_color: GraphicsOutputBltPixel, |
| 75 | pub font_mask_info: FontInfoMask, |
| 76 | pub font_info: FontInfo, |
| 77 | } |
| 78 | |
| 79 | bitflags::bitflags! { |
| 80 | /// EFI_HII_OUT_FLAGS |
| 81 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 82 | #[repr(transparent)] |
| 83 | pub struct HiiOutFlags: u32 { |
| 84 | const CLIP = 1 << 0; |
| 85 | const WRAP = 1 << 1; |
| 86 | const CLIP_CLEAN_Y = 1 << 2; |
| 87 | const CLIP_CLEAN_X = 1 << 3; |
| 88 | const TRANSPARENT = 1 << 4; |
| 89 | const IGNORE_IF_NO_GLYPH = 1 << 5; |
| 90 | const IGNORE_LINE_BREAK = 1 << 6; |
| 91 | const DIRECT_TO_SCREEN = 1 << 7; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /// EFI_HII_ROW_INFO |
| 96 | #[derive(Debug)] |
| 97 | #[repr(C)] |
| 98 | pub struct HiiRowInfo { |
| 99 | pub start_index: usize, |
| 100 | pub end_index: usize, |
| 101 | pub line_height: usize, |
| 102 | pub line_width: usize, |
| 103 | pub baseline_offset: usize, |
| 104 | } |
| 105 | |
| 106 | /// EFI_HII_FONT_PROTOCOL |
| 107 | #[derive(Debug)] |
| 108 | #[repr(C)] |
| 109 | pub struct HiiFontProtocol { |
| 110 | pub string_to_image: unsafe extern "efiapi" fn( |
| 111 | this: *const Self, |
| 112 | flags: HiiOutFlags, |
| 113 | string: *const Char16, |
| 114 | string_info: *const FontDisplayInfo, |
| 115 | blt: *mut *mut ImageOutput, |
| 116 | blt_x: usize, |
| 117 | blt_y: usize, |
| 118 | row_info_array: *mut *mut HiiRowInfo, |
| 119 | row_info_array_size: *mut usize, |
| 120 | column_info_array: *mut usize, |
| 121 | ) -> Status, |
| 122 | pub string_id_to_image: unsafe extern "efiapi" fn( |
| 123 | this: *const Self, |
| 124 | flags: HiiOutFlags, |
| 125 | package_list: HiiHandle, |
| 126 | string_id: StringId, |
| 127 | language: *const Char8, |
| 128 | string_info: *const FontDisplayInfo, |
| 129 | blt: *mut *mut ImageOutput, |
| 130 | blt_x: usize, |
| 131 | blt_y: usize, |
| 132 | row_info_array: *mut *mut HiiRowInfo, |
| 133 | row_info_array_size: *mut usize, |
| 134 | column_info_array: *mut usize, |
| 135 | ) -> Status, |
| 136 | pub get_glyph: unsafe extern "efiapi" fn( |
| 137 | this: *const Self, |
| 138 | char: Char16, |
| 139 | string_info: *const FontDisplayInfo, |
| 140 | blt: *mut *mut ImageOutput, |
| 141 | baseline: *mut usize, |
| 142 | ) -> Status, |
| 143 | pub get_font_info: unsafe extern "efiapi" fn( |
| 144 | this: *const Self, |
| 145 | font_handle: *mut FontHandle, |
| 146 | string_info_in: *const FontDisplayInfo, |
| 147 | string_info_out: *mut *mut FontDisplayInfo, |
| 148 | string: *const Char16, |
| 149 | ) -> Status, |
| 150 | } |
| 151 | |
| 152 | impl HiiFontProtocol { |
| 153 | pub const GUID: Guid = guid!("e9ca4775-8657-47fc-97e7-7ed65a084324"); |
| 154 | } |
| 155 | |
| 156 | // NOTE: This protocol is declared in the UEFI spec, but not defined in edk2. |
| 157 | /// EFI_HII_FONT_EX_PROTOCOL |
| 158 | #[derive(Debug)] |
| 159 | #[repr(C)] |
| 160 | pub struct HiiFontExProtocol { |
| 161 | pub string_to_image_ex: unsafe extern "efiapi" fn( |
| 162 | this: *const Self, |
| 163 | flags: HiiOutFlags, |
| 164 | string: *const Char16, |
| 165 | string_info: *const FontDisplayInfo, |
| 166 | blt: *mut *mut ImageOutput, |
| 167 | blt_x: usize, |
| 168 | blt_y: usize, |
| 169 | row_info_array: *mut *mut HiiRowInfo, |
| 170 | row_info_array_size: *mut usize, |
| 171 | column_info_array: *mut usize, |
| 172 | ) -> Status, |
| 173 | pub string_id_to_image_ex: unsafe extern "efiapi" fn( |
| 174 | this: *const Self, |
| 175 | flags: HiiOutFlags, |
| 176 | package_list: HiiHandle, |
| 177 | string_id: StringId, |
| 178 | language: *const Char8, |
| 179 | string_info: *const FontDisplayInfo, |
| 180 | blt: *mut *mut ImageOutput, |
| 181 | blt_x: usize, |
| 182 | blt_y: usize, |
| 183 | row_info_array: *mut *mut HiiRowInfo, |
| 184 | row_info_array_size: *mut usize, |
| 185 | column_info_array: *mut usize, |
| 186 | ) -> Status, |
| 187 | // NOTE: UEFI 2.11 declares `Baseline` by value in this prototype but |
| 188 | // refers to `GetGlyph()` for its meaning, where it is `OUT UINTN *`. |
| 189 | pub get_glyph_ex: unsafe extern "efiapi" fn( |
| 190 | this: *const Self, |
| 191 | char: Char16, |
| 192 | string_info: *const FontDisplayInfo, |
| 193 | blt: *mut *mut ImageOutput, |
| 194 | baseline: *mut usize, |
| 195 | ) -> Status, |
| 196 | pub get_font_info_ex: unsafe extern "efiapi" fn( |
| 197 | this: *const Self, |
| 198 | font_handle: *mut FontHandle, |
| 199 | string_info_in: *const FontDisplayInfo, |
| 200 | string_info_out: *mut *mut FontDisplayInfo, |
| 201 | string: *const Char16, |
| 202 | ) -> Status, |
| 203 | pub get_glyph_info: unsafe extern "efiapi" fn( |
| 204 | this: *const Self, |
| 205 | char: Char16, |
| 206 | font_display_info: *const FontDisplayInfo, |
| 207 | glyph_info: *mut HiiGlyphInfo, |
| 208 | ) -> Status, |
| 209 | } |
| 210 | |
| 211 | impl HiiFontExProtocol { |
| 212 | pub const GUID: Guid = guid!("849e6875-db35-4df8-b41e-c8f33718073f"); |
| 213 | } |