-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
improve uefi support #2944
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
Merged
Merged
improve uefi support #2944
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
63d56c5
src/target.cpp: UEFI improvements
nrdmn 6e8ef5b
std/build.zig: add checks for UEFI
nrdmn b979fc1
initial work torwards std lib support for uefi
nrdmn 20ce0b9
std/os/uefi: replace integer bit fields with packed structs
nrdmn 88fdb30
std/os/uefi: replace init() with default values
nrdmn 9445b3f
std/os/uefi: change type of Handle from @OpaqueType to *@OpaqueType
nrdmn 47ce736
std/os/uefi: add basic Event support
nrdmn a9b3700
src/codegen: configure stack probes explicitly
nrdmn 70e62b8
std/os/uefi: some more events
nrdmn 03abc6e
std/os/uefi: add global_variable guid
nrdmn 8db41b7
std/os/uefi: add support for getting memory map
nrdmn 5e874a8
std/os/uefi: fix ordering of packed bit fields
nrdmn 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
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 |
---|---|---|
@@ -1,6 +1,45 @@ | ||
// TODO this is where the extern declarations go. For example, see | ||
// inc/efilib.h in gnu-efi-code | ||
pub const protocols = @import("uefi/protocols.zig"); | ||
pub const status = @import("uefi/status.zig"); | ||
pub const tables = @import("uefi/tables.zig"); | ||
|
||
const builtin = @import("builtin"); | ||
|
||
pub const is_the_target = builtin.os == .uefi; | ||
|
||
pub var handle: Handle = undefined; | ||
pub var system_table: *tables.SystemTable = undefined; | ||
|
||
pub const Event = *@OpaqueType(); | ||
// GUIDs must be align(8) | ||
pub const Guid = extern struct { | ||
time_low: u32, | ||
time_mid: u16, | ||
time_high_and_version: u16, | ||
clock_seq_high_and_reserved: u8, | ||
clock_seq_low: u8, | ||
node: [6]u8, | ||
}; | ||
pub const Handle = *@OpaqueType(); | ||
pub const Time = extern struct { | ||
year: u16, | ||
month: u8, | ||
day: u8, | ||
hour: u8, | ||
minute: u8, | ||
second: u8, | ||
_pad1: u8, | ||
nanosecond: u32, | ||
timezone: i16, | ||
daylight: packed struct { | ||
_pad1: u6, | ||
in_daylight: bool, | ||
adjust_daylight: bool, | ||
}, | ||
_pad2: u8, | ||
|
||
pub const unspecified_timezone: i16 = 0x7ff; | ||
}; | ||
pub const TimeCapabilities = extern struct { | ||
resolution: u32, | ||
accuracy: u32, | ||
sets_to_zero: bool, | ||
}; |
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,32 @@ | ||
pub const InputKey = @import("protocols/simple_text_input_ex_protocol.zig").InputKey; | ||
pub const KeyData = @import("protocols/simple_text_input_ex_protocol.zig").KeyData; | ||
pub const KeyState = @import("protocols/simple_text_input_ex_protocol.zig").KeyState; | ||
pub const SimpleTextInputExProtocol = @import("protocols/simple_text_input_ex_protocol.zig").SimpleTextInputExProtocol; | ||
|
||
pub const SimpleTextOutputMode = @import("protocols/simple_text_output_protocol.zig").SimpleTextOutputMode; | ||
pub const SimpleTextOutputProtocol = @import("protocols/simple_text_output_protocol.zig").SimpleTextOutputProtocol; | ||
|
||
pub const SimplePointerMode = @import("protocols/simple_pointer_protocol.zig").SimplePointerMode; | ||
pub const SimplePointerProtocol = @import("protocols/simple_pointer_protocol.zig").SimplePointerProtocol; | ||
pub const SimplePointerState = @import("protocols/simple_pointer_protocol.zig").SimplePointerState; | ||
|
||
pub const AbsolutePointerMode = @import("protocols/absolute_pointer_protocol.zig").AbsolutePointerMode; | ||
pub const AbsolutePointerProtocol = @import("protocols/absolute_pointer_protocol.zig").AbsolutePointerProtocol; | ||
pub const AbsolutePointerState = @import("protocols/absolute_pointer_protocol.zig").AbsolutePointerState; | ||
|
||
pub const GraphicsOutputBltPixel = @import("protocols/graphics_output_protocol.zig").GraphicsOutputBltPixel; | ||
pub const GraphicsOutputBltOperation = @import("protocols/graphics_output_protocol.zig").GraphicsOutputBltOperation; | ||
pub const GraphicsOutputModeInformation = @import("protocols/graphics_output_protocol.zig").GraphicsOutputModeInformation; | ||
pub const GraphicsOutputProtocol = @import("protocols/graphics_output_protocol.zig").GraphicsOutputProtocol; | ||
pub const GraphicsOutputProtocolMode = @import("protocols/graphics_output_protocol.zig").GraphicsOutputProtocolMode; | ||
pub const GraphicsPixelFormat = @import("protocols/graphics_output_protocol.zig").GraphicsPixelFormat; | ||
pub const PixelBitmask = @import("protocols/graphics_output_protocol.zig").PixelBitmask; | ||
|
||
pub const EdidDiscoveredProtocol = @import("protocols/edid_discovered_protocol.zig").EdidDiscoveredProtocol; | ||
|
||
pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").EdidActiveProtocol; | ||
|
||
pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol; | ||
pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes; | ||
|
||
pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol; |
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,53 @@ | ||
const uefi = @import("std").os.uefi; | ||
const Event = uefi.Event; | ||
const Guid = uefi.Guid; | ||
|
||
/// UEFI Specification, Version 2.8, 12.7 | ||
pub const AbsolutePointerProtocol = extern struct { | ||
_reset: extern fn (*const AbsolutePointerProtocol, bool) usize, | ||
_get_state: extern fn (*const AbsolutePointerProtocol, *AbsolutePointerState) usize, | ||
wait_for_input: Event, | ||
mode: *AbsolutePointerMode, | ||
|
||
pub fn reset(self: *const AbsolutePointerProtocol, verify: bool) usize { | ||
return self._reset(self, verify); | ||
} | ||
|
||
pub fn getState(self: *const AbsolutePointerProtocol, state: *AbsolutePointerState) usize { | ||
return self._get_state(self, state); | ||
} | ||
|
||
pub const guid align(8) = Guid{ | ||
.time_low = 0x8d59d32b, | ||
.time_mid = 0xc655, | ||
.time_high_and_version = 0x4ae9, | ||
.clock_seq_high_and_reserved = 0x9b, | ||
.clock_seq_low = 0x15, | ||
.node = [_]u8{ 0xf2, 0x59, 0x04, 0x99, 0x2a, 0x43 }, | ||
}; | ||
}; | ||
|
||
pub const AbsolutePointerMode = extern struct { | ||
absolute_min_x: u64, | ||
absolute_min_y: u64, | ||
absolute_min_z: u64, | ||
absolute_max_x: u64, | ||
absolute_max_y: u64, | ||
absolute_max_z: u64, | ||
attributes: packed struct { | ||
supports_alt_active: bool, | ||
supports_pressure_as_z: bool, | ||
_pad1: u30, | ||
}, | ||
}; | ||
|
||
pub const AbsolutePointerState = extern struct { | ||
current_x: u64 = undefined, | ||
current_y: u64 = undefined, | ||
current_z: u64 = undefined, | ||
active_buttons: packed struct { | ||
touch_active: bool, | ||
alt_active: bool, | ||
_pad1: u30, | ||
} = undefined, | ||
}; |
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,17 @@ | ||
const uefi = @import("std").os.uefi; | ||
const Guid = uefi.Guid; | ||
|
||
/// UEFI Specification, Version 2.8, 12.9 | ||
pub const EdidActiveProtocol = extern struct { | ||
size_of_edid: u32, | ||
edid: ?[*]u8, | ||
|
||
pub const guid align(8) = Guid{ | ||
.time_low = 0xbd8c1056, | ||
.time_mid = 0x9f36, | ||
.time_high_and_version = 0x44ec, | ||
.clock_seq_high_and_reserved = 0x92, | ||
.clock_seq_low = 0xa8, | ||
.node = [_]u8{ 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 }, | ||
}; | ||
}; |
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,17 @@ | ||
const uefi = @import("std").os.uefi; | ||
const Guid = uefi.Guid; | ||
|
||
/// UEFI Specification, Version 2.8, 12.9 | ||
pub const EdidDiscoveredProtocol = extern struct { | ||
size_of_edid: u32, | ||
edid: ?[*]u8, | ||
|
||
pub const guid align(8) = Guid{ | ||
.time_low = 0x1c0c34f6, | ||
.time_mid = 0xd380, | ||
.time_high_and_version = 0x41fa, | ||
.clock_seq_high_and_reserved = 0xa0, | ||
.clock_seq_low = 0x49, | ||
.node = [_]u8{ 0x8a, 0xd0, 0x6c, 0x1a, 0x66, 0xaa }, | ||
}; | ||
}; |
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,28 @@ | ||
const uefi = @import("std").os.uefi; | ||
const Guid = uefi.Guid; | ||
const Handle = uefi.Handle; | ||
|
||
/// UEFI Specification, Version 2.8, 12.9 | ||
pub const EdidOverrideProtocol = extern struct { | ||
_get_edid: extern fn (*const EdidOverrideProtocol, Handle, *u32, *usize, *?[*]u8) usize, | ||
|
||
/// attributes must be align(4) | ||
pub fn getEdid(self: *const EdidOverrideProtocol, handle: Handle, attributes: *EdidOverrideProtocolAttributes, edid_size: *usize, edid: *?[*]u8) usize { | ||
return self._get_edid(self, handle, attributes, edid_size, edid); | ||
} | ||
|
||
pub const guid align(8) = Guid{ | ||
.time_low = 0x48ecb431, | ||
.time_mid = 0xfb72, | ||
.time_high_and_version = 0x45c0, | ||
.clock_seq_high_and_reserved = 0xa9, | ||
.clock_seq_low = 0x22, | ||
.node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 }, | ||
}; | ||
}; | ||
|
||
pub const EdidOverrideProtocolAttributes = packed struct { | ||
dont_override: bool, | ||
enable_hot_plug: bool, | ||
_pad1: u30, | ||
}; |
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,79 @@ | ||
const uefi = @import("std").os.uefi; | ||
const Guid = uefi.Guid; | ||
|
||
/// UEFI Specification, Version 2.8, 12.9 | ||
pub const GraphicsOutputProtocol = extern struct { | ||
_query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) usize, | ||
_set_mode: extern fn (*const GraphicsOutputProtocol, u32) usize, | ||
_blt: extern fn (*const GraphicsOutputProtocol, ?[*]GraphicsOutputBltPixel, GraphicsOutputBltOperation, usize, usize, usize, usize, usize, usize, usize) usize, | ||
mode: *GraphicsOutputProtocolMode, | ||
|
||
pub fn queryMode(self: *const GraphicsOutputProtocol, mode: u32, size_of_info: *usize, info: **GraphicsOutputModeInformation) usize { | ||
return self._query_mode(self, mode, size_of_info, info); | ||
} | ||
|
||
pub fn setMode(self: *const GraphicsOutputProtocol, mode: u32) usize { | ||
return self._set_mode(self, mode); | ||
} | ||
|
||
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 { | ||
return self._blt(self, blt_buffer, blt_operation, source_x, source_y, destination_x, destination_y, width, height, delta); | ||
} | ||
|
||
pub const guid align(8) = Guid{ | ||
.time_low = 0x9042a9de, | ||
.time_mid = 0x23dc, | ||
.time_high_and_version = 0x4a38, | ||
.clock_seq_high_and_reserved = 0x96, | ||
.clock_seq_low = 0xfb, | ||
.node = [_]u8{ 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a }, | ||
}; | ||
}; | ||
|
||
pub const GraphicsOutputProtocolMode = extern struct { | ||
max_mode: u32, | ||
mode: u32, | ||
info: *GraphicsOutputModeInformation, | ||
size_of_info: usize, | ||
frame_buffer_base: u64, | ||
frame_buffer_size: usize, | ||
}; | ||
|
||
pub const GraphicsOutputModeInformation = extern struct { | ||
version: u32 = undefined, | ||
horizontal_resolution: u32 = undefined, | ||
vertical_resolution: u32 = undefined, | ||
pixel_format: GraphicsPixelFormat = undefined, | ||
pixel_information: PixelBitmask = undefined, | ||
pixels_per_scan_line: u32 = undefined, | ||
}; | ||
|
||
pub const GraphicsPixelFormat = extern enum(u32) { | ||
PixelRedGreenBlueReserved8BitPerColor, | ||
PixelBlueGreenRedReserved8BitPerColor, | ||
PixelBitMask, | ||
PixelBltOnly, | ||
PixelFormatMax, | ||
}; | ||
|
||
pub const PixelBitmask = extern struct { | ||
red_mask: u32, | ||
green_mask: u32, | ||
blue_mask: u32, | ||
reserved_mask: u32, | ||
}; | ||
|
||
pub const GraphicsOutputBltPixel = extern struct { | ||
blue: u8, | ||
green: u8, | ||
red: u8, | ||
reserved: u8 = undefined, | ||
}; | ||
|
||
pub const GraphicsOutputBltOperation = extern enum(u32) { | ||
BltVideoFill, | ||
BltVideoToBltBuffer, | ||
BltBufferToVideo, | ||
BltVideoToVideo, | ||
GraphicsOutputBltOperationMax, | ||
}; |
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.
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.
Can we at least exit with non-zero status?