|
| 1 | +const uefi = @import("std").os.uefi; |
| 2 | +const Guid = uefi.Guid; |
| 3 | + |
| 4 | +/// UEFI Specification, Version 2.8, 12.9 |
| 5 | +pub const GraphicsOutputProtocol = extern struct { |
| 6 | + _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) usize, |
| 7 | + _set_mode: extern fn (*const GraphicsOutputProtocol, u32) usize, |
| 8 | + _blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) usize, |
| 9 | + mode: *GraphicsOutputProtocolMode, |
| 10 | + |
| 11 | + pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) usize { |
| 12 | + return self._query_mode(self, mode, size_of_info, info); |
| 13 | + } |
| 14 | + |
| 15 | + pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) usize { |
| 16 | + return self._set_mode(self, mode); |
| 17 | + } |
| 18 | + |
| 19 | + pub fn blt(self: *const GraphicsOutputProtocol, blt_buffer: ?[*]GraphicsOutputBltPixel, blt_operation: GraphicsOutputBltOperation, source_x: usize, source_y: usize, destination_x: usize, destination_y: usize, width: usize, height: usize, delta: usize) usize { |
| 20 | + return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta); |
| 21 | + } |
| 22 | + |
| 23 | + pub const guid align(8) = Guid{ |
| 24 | + .time_low = 0x9042a9de, |
| 25 | + .time_mid = 0x23dc, |
| 26 | + .time_high_and_version = 0x4a38, |
| 27 | + .clock_seq_high_and_reserved = 0x96, |
| 28 | + .clock_seq_low = 0xfb, |
| 29 | + .node = [_]u8{ 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a }, |
| 30 | + }; |
| 31 | +}; |
| 32 | + |
| 33 | +pub const GraphicsOutputProtocolMode = extern struct { |
| 34 | + max_mode: u32, |
| 35 | + mode: u32, |
| 36 | + info: *GraphicsOutputModeInformation, |
| 37 | + size_of_info: usize, |
| 38 | + frame_buffer_base: u64, |
| 39 | + frame_buffer_size: usize, |
| 40 | +}; |
| 41 | + |
| 42 | +pub const GraphicsOutputModeInformation = extern struct { |
| 43 | + version: u32, |
| 44 | + horizontal_resolution: u32, |
| 45 | + vertical_resolution: u32, |
| 46 | + pixel_format: GraphicsPixelFormat, |
| 47 | + pixel_information: PixelBitmask, |
| 48 | + pixels_per_scan_line: u32, |
| 49 | + |
| 50 | + pub fn init() GraphicsOutputModeInformation { |
| 51 | + return GraphicsOutputModeInformation{ |
| 52 | + .version = undefined, |
| 53 | + .horizontal_resolution = undefined, |
| 54 | + .vertical_resolution = undefined, |
| 55 | + .pixel_format = undefined, |
| 56 | + .pixel_information = undefined, |
| 57 | + .pixels_per_scan_line = undefined, |
| 58 | + }; |
| 59 | + } |
| 60 | +}; |
| 61 | + |
| 62 | +pub const GraphicsPixelFormat = extern enum(u32) { |
| 63 | + PixelRedGreenBlueReserved8BitPerColor, |
| 64 | + PixelBlueGreenRedReserved8BitPerColor, |
| 65 | + PixelBitMask, |
| 66 | + PixelBltOnly, |
| 67 | + PixelFormatMax, |
| 68 | +}; |
| 69 | + |
| 70 | +pub const PixelBitmask = extern struct { |
| 71 | + red_mask: u32, |
| 72 | + green_mask: u32, |
| 73 | + blue_mask: u32, |
| 74 | + reserved_mask: u32, |
| 75 | +}; |
| 76 | + |
| 77 | +pub const GraphicsOutputBltPixel = extern struct { |
| 78 | + blue: u8, |
| 79 | + green: u8, |
| 80 | + red: u8, |
| 81 | + reserved: u8 = undefined, |
| 82 | +}; |
| 83 | + |
| 84 | +pub const GraphicsOutputBltOperation = extern enum(u32) { |
| 85 | + BltVideoFill, |
| 86 | + BltVideoToBltBuffer, |
| 87 | + BltBufferToVideo, |
| 88 | + BltVideoToVideo, |
| 89 | + GraphicsOutputBltOperationMax, |
| 90 | +}; |
0 commit comments