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 / image.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | //! Bindings for HII Image protocols and data types |
| 4 | |
| 5 | use super::{HiiHandle, ImageId}; |
| 6 | use crate::protocol::console::{GraphicsOutputBltPixel, GraphicsOutputProtocol}; |
| 7 | use crate::{Guid, Status, guid}; |
| 8 | use core::{fmt, ptr}; |
| 9 | |
| 10 | bitflags::bitflags! { |
| 11 | /// EFI_HII_DRAW_FLAGS |
| 12 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 13 | #[repr(transparent)] |
| 14 | pub struct HiiDrawFlags: u32 { |
| 15 | const CLIP = 1 << 0; |
| 16 | const FORCE_TRANS = 1 << 4; |
| 17 | const FORCE_OPAQUE = 1 << 5; |
| 18 | const TRANSPARENT = Self::FORCE_TRANS.bits() | Self::FORCE_OPAQUE.bits(); |
| 19 | const DIRECT_TO_SCREEN = 1 << 7; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | impl HiiDrawFlags { |
| 24 | pub const DEFAULT: Self = Self::empty(); |
| 25 | } |
| 26 | |
| 27 | bitflags::bitflags! { |
| 28 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 29 | #[repr(transparent)] |
| 30 | pub struct ImageInputFlags: u32 { |
| 31 | const TRANSPARENT = 1 << 0; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | /// EFI_IMAGE_INPUT |
| 36 | #[derive(Debug)] |
| 37 | #[repr(C)] |
| 38 | pub struct ImageInput { |
| 39 | pub flags: ImageInputFlags, |
| 40 | pub width: u16, |
| 41 | pub height: u16, |
| 42 | pub bitmap: *const GraphicsOutputBltPixel, |
| 43 | } |
| 44 | |
| 45 | #[repr(C)] |
| 46 | pub union ImageOutputDest { |
| 47 | pub bitmap: *mut GraphicsOutputBltPixel, |
| 48 | pub screen: *mut GraphicsOutputProtocol, |
| 49 | } |
| 50 | |
| 51 | impl fmt::Debug for ImageOutputDest { |
| 52 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 53 | // SAFETY: Both union members are raw pointers, so reading either field |
| 54 | // only copies the stored address. |
| 55 | unsafe { |
| 56 | f.debug_struct("ImageOutputDest") |
| 57 | .field("bitmap", &self.bitmap) |
| 58 | .field("screen", &self.screen) |
| 59 | .finish() |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | impl Default for ImageOutputDest { |
| 65 | fn default() -> Self { |
| 66 | Self { |
| 67 | bitmap: ptr::null_mut(), |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /// EFI_IMAGE_OUTPUT |
| 73 | #[derive(Debug)] |
| 74 | #[repr(C)] |
| 75 | pub struct ImageOutput { |
| 76 | pub width: u16, |
| 77 | pub height: u16, |
| 78 | pub image: ImageOutputDest, |
| 79 | } |
| 80 | |
| 81 | /// EFI_HII_IMAGE_PROTOCOL |
| 82 | #[derive(Debug)] |
| 83 | #[repr(C)] |
| 84 | pub struct HiiImageProtocol { |
| 85 | pub new_image: unsafe extern "efiapi" fn( |
| 86 | this: *const Self, |
| 87 | package_list: HiiHandle, |
| 88 | image_id: *mut ImageId, |
| 89 | image: *const ImageInput, |
| 90 | ) -> Status, |
| 91 | pub get_image: unsafe extern "efiapi" fn( |
| 92 | this: *const Self, |
| 93 | package_list: HiiHandle, |
| 94 | image_id: ImageId, |
| 95 | image: *mut ImageInput, |
| 96 | ) -> Status, |
| 97 | pub set_image: unsafe extern "efiapi" fn( |
| 98 | this: *const Self, |
| 99 | package_list: HiiHandle, |
| 100 | image_id: ImageId, |
| 101 | image: *const ImageInput, |
| 102 | ) -> Status, |
| 103 | pub draw_image: unsafe extern "efiapi" fn( |
| 104 | this: *const Self, |
| 105 | flags: HiiDrawFlags, |
| 106 | image: *const ImageInput, |
| 107 | blt: *mut *mut ImageOutput, |
| 108 | blt_x: usize, |
| 109 | blt_y: usize, |
| 110 | ) -> Status, |
| 111 | pub draw_image_id: unsafe extern "efiapi" fn( |
| 112 | this: *const Self, |
| 113 | flags: HiiDrawFlags, |
| 114 | package_list: HiiHandle, |
| 115 | image_id: ImageId, |
| 116 | blt: *mut *mut ImageOutput, |
| 117 | blt_x: usize, |
| 118 | blt_y: usize, |
| 119 | ) -> Status, |
| 120 | } |
| 121 | |
| 122 | impl HiiImageProtocol { |
| 123 | pub const GUID: Guid = guid!("31a6406a-6bdf-4e46-b2a2-ebaa89c40920"); |
| 124 | } |
| 125 | |
| 126 | /// EFI_HII_IMAGE_EX_PROTOCOL |
| 127 | #[derive(Debug)] |
| 128 | #[repr(C)] |
| 129 | pub struct HiiImageExProtocol { |
| 130 | // NOTE: UEFI 2.11 declares `image` as an inout value; edk2 declares it as |
| 131 | // an input-only value, matching the non-extended protocol version. |
| 132 | pub new_image_ex: unsafe extern "efiapi" fn( |
| 133 | this: *const Self, |
| 134 | package_list: HiiHandle, |
| 135 | image_id: *mut ImageId, |
| 136 | image: *const ImageInput, |
| 137 | ) -> Status, |
| 138 | pub get_image_ex: unsafe extern "efiapi" fn( |
| 139 | this: *const Self, |
| 140 | package_list: HiiHandle, |
| 141 | image_id: ImageId, |
| 142 | image: *mut ImageInput, |
| 143 | ) -> Status, |
| 144 | pub set_image_ex: unsafe extern "efiapi" fn( |
| 145 | this: *const Self, |
| 146 | package_list: HiiHandle, |
| 147 | image_id: ImageId, |
| 148 | image: *const ImageInput, |
| 149 | ) -> Status, |
| 150 | pub draw_image_ex: unsafe extern "efiapi" fn( |
| 151 | this: *const Self, |
| 152 | flags: HiiDrawFlags, |
| 153 | image: *const ImageInput, |
| 154 | blt: *mut *mut ImageOutput, |
| 155 | blt_x: usize, |
| 156 | blt_y: usize, |
| 157 | ) -> Status, |
| 158 | pub draw_image_id_ex: unsafe extern "efiapi" fn( |
| 159 | this: *const Self, |
| 160 | flags: HiiDrawFlags, |
| 161 | package_list: HiiHandle, |
| 162 | image_id: ImageId, |
| 163 | blt: *mut *mut ImageOutput, |
| 164 | blt_x: usize, |
| 165 | blt_y: usize, |
| 166 | ) -> Status, |
| 167 | pub get_image_info: unsafe extern "efiapi" fn( |
| 168 | this: *const Self, |
| 169 | package_list: HiiHandle, |
| 170 | image_id: ImageId, |
| 171 | image: *mut ImageOutput, |
| 172 | ) -> Status, |
| 173 | } |
| 174 | |
| 175 | impl HiiImageExProtocol { |
| 176 | pub const GUID: Guid = guid!("1a1241e6-8f19-41a9-bc0e-e8ef39e06546"); |
| 177 | } |