| 1 | const uefi = @import("std").os.uefi; |
| 2 | const Guid = uefi.Guid; |
| 3 | |
| 4 | pub const Handle = *opaque {}; |
| 5 | |
| 6 | /// The header found at the start of each package. |
| 7 | pub const PackageHeader = packed struct(u32) { |
| 8 | length: u24, |
| 9 | type: u8, |
| 10 | |
| 11 | pub const type_all: u8 = 0x0; |
| 12 | pub const type_guid: u8 = 0x1; |
| 13 | pub const forms: u8 = 0x2; |
| 14 | pub const strings: u8 = 0x4; |
| 15 | pub const fonts: u8 = 0x5; |
| 16 | pub const images: u8 = 0x6; |
| 17 | pub const simple_fonsts: u8 = 0x7; |
| 18 | pub const device_path: u8 = 0x8; |
| 19 | pub const keyboard_layout: u8 = 0x9; |
| 20 | pub const animations: u8 = 0xa; |
| 21 | pub const end: u8 = 0xdf; |
| 22 | pub const type_system_begin: u8 = 0xe0; |
| 23 | pub const type_system_end: u8 = 0xff; |
| 24 | }; |
| 25 | |
| 26 | /// The header found at the start of each package list. |
| 27 | pub const PackageList = extern struct { |
| 28 | package_list_guid: Guid, |
| 29 | |
| 30 | /// The size of the package list (in bytes), including the header. |
| 31 | package_list_length: u32, |
| 32 | |
| 33 | // TODO implement iterator |
| 34 | }; |
| 35 | |
| 36 | pub const SimplifiedFontPackage = extern struct { |
| 37 | header: PackageHeader, |
| 38 | number_of_narrow_glyphs: u16, |
| 39 | number_of_wide_glyphs: u16, |
| 40 | |
| 41 | pub fn getNarrowGlyphs(self: *SimplifiedFontPackage) []NarrowGlyph { |
| 42 | return @as([*]NarrowGlyph, @ptrCast(@alignCast(@as([*]u8, @ptrCast(self)) + @sizeOf(SimplifiedFontPackage))))[0..self.number_of_narrow_glyphs]; |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | pub const NarrowGlyphAttributes = packed struct(u8) { |
| 47 | non_spacing: bool, |
| 48 | wide: bool, |
| 49 | _pad: u6 = 0, |
| 50 | }; |
| 51 | |
| 52 | pub const NarrowGlyph = extern struct { |
| 53 | unicode_weight: u16, |
| 54 | attributes: NarrowGlyphAttributes, |
| 55 | glyph_col_1: [19]u8, |
| 56 | }; |
| 57 | |
| 58 | pub const WideGlyphAttributes = packed struct(u8) { |
| 59 | non_spacing: bool, |
| 60 | wide: bool, |
| 61 | _pad: u6 = 0, |
| 62 | }; |
| 63 | |
| 64 | pub const WideGlyph = extern struct { |
| 65 | unicode_weight: u16, |
| 66 | attributes: WideGlyphAttributes, |
| 67 | glyph_col_1: [19]u8, |
| 68 | glyph_col_2: [19]u8, |
| 69 | _pad: [3]u8 = @splat(0), |
| 70 | }; |
| 71 | |
| 72 | pub const StringPackage = extern struct { |
| 73 | header: PackageHeader, |
| 74 | hdr_size: u32, |
| 75 | string_info_offset: u32, |
| 76 | language_window: [16]u16, |
| 77 | language_name: u16, |
| 78 | language: [3]u8, |
| 79 | }; |