authorgravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-08-05 18:26:13+02:00
committergravatar for n@nirf.deNick Erdmann <n@nirf.de> 2019-08-05 18:26:13+02:00
log20ce0b9952167d531f0a0e679c1b0409e9049d09
tree2e28b4a23c26ccf4c3be539d07c05621ee8e26b6
parentb979fc1bcd6d1bdc19b7f518498fb8c9740d6dea
signature Commit is signed but in an unrecognized format.

std/os/uefi: replace integer bit fields with packed structs


5 files changed, 53 insertions(+), 35 deletions(-)

std/os/uefi.zig+7-5
...@@ -26,14 +26,16 @@ pub const Time = extern struct {...@@ -26,14 +26,16 @@ pub const Time = extern struct {
26 hour: u8,26 hour: u8,
27 minute: u8,27 minute: u8,
28 second: u8,28 second: u8,
29 pad1: u8,29 _pad1: u8,
30 nanosecond: u32,30 nanosecond: u32,
31 timezone: i16,31 timezone: i16,
32 daylight: u8,32 daylight: packed struct {
33 pad2: u8,33 _pad1: u6,
34 in_daylight: bool,
35 adjust_daylight: bool,
36 },
37 _pad2: u8,
3438
35 pub const adjust_daylight: u8 = 1;
36 pub const in_daylight: u8 = 2;
37 pub const unspecified_timezone: i16 = 0x7ff;39 pub const unspecified_timezone: i16 = 0x7ff;
38};40};
39pub const TimeCapabilities = extern struct {41pub const TimeCapabilities = extern struct {
std/os/uefi/protocols.zig+1
...@@ -27,5 +27,6 @@ pub const EdidDiscoveredProtocol = @import("protocols/edid_discovered_protocol.z...@@ -27,5 +27,6 @@ pub const EdidDiscoveredProtocol = @import("protocols/edid_discovered_protocol.z
27pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").EdidActiveProtocol;27pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").EdidActiveProtocol;
2828
29pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;29pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
30pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;
3031
31pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;32pub const RNGProtocol = @import("protocols/rng_protocol.zig").RNGProtocol;
std/os/uefi/protocols/absolute_pointer_protocol.zig+12-8
...@@ -34,17 +34,24 @@ pub const AbsolutePointerMode = extern struct {...@@ -34,17 +34,24 @@ pub const AbsolutePointerMode = extern struct {
34 absolute_max_x: u64,34 absolute_max_x: u64,
35 absolute_max_y: u64,35 absolute_max_y: u64,
36 absolute_max_z: u64,36 absolute_max_z: u64,
37 attributes: u32,37 attributes: packed struct {
3838 _pad1: u6,
39 pub const supports_alt_active: u32 = 1;39 supports_pressure_as_z: bool,
40 pub const supports_pressure_as_z: u32 = 2;40 supports_alt_active: bool,
41 _pad2: u24,
42 },
41};43};
4244
43pub const AbsolutePointerState = extern struct {45pub const AbsolutePointerState = extern struct {
44 current_x: u64,46 current_x: u64,
45 current_y: u64,47 current_y: u64,
46 current_z: u64,48 current_z: u64,
47 active_buttons: u32,49 active_buttons: packed struct {
50 _pad1: u6,
51 alt_active: bool,
52 touch_active: bool,
53 _pad2: u24,
54 },
4855
49 pub fn init() AbsolutePointerState {56 pub fn init() AbsolutePointerState {
50 return AbsolutePointerState{57 return AbsolutePointerState{
...@@ -54,7 +61,4 @@ pub const AbsolutePointerState = extern struct {...@@ -54,7 +61,4 @@ pub const AbsolutePointerState = extern struct {
54 .active_buttons = undefined,61 .active_buttons = undefined,
55 };62 };
56 }63 }
57
58 pub const touch_active: u32 = 1;
59 pub const alt_active: u32 = 2;
60};64};
std/os/uefi/protocols/edid_override_protocol.zig+9-3
...@@ -6,7 +6,8 @@ const Handle = uefi.Handle;...@@ -6,7 +6,8 @@ const Handle = uefi.Handle;
6pub const EdidOverrideProtocol = extern struct {6pub const EdidOverrideProtocol = extern struct {
7 _get_edid: extern fn (*const EdidOverrideProtocol, *const Handle, *u32, *usize, *?[*]u8) usize,7 _get_edid: extern fn (*const EdidOverrideProtocol, *const Handle, *u32, *usize, *?[*]u8) usize,
88
9 pub fn getEdid(self: *const EdidOverrideProtocol, handle: *const Handle, attributes: *u32, edid_size: *usize, edid: *?[*]u8) usize {9 /// attributes must be align(4)
10 pub fn getEdid(self: *const EdidOverrideProtocol, handle: *const Handle, attributes: *EdidOverrideProtocolAttributes, edid_size: *usize, edid: *?[*]u8) usize {
10 return self._get_edid(self, handle, attributes, edid_size, edid);11 return self._get_edid(self, handle, attributes, edid_size, edid);
11 }12 }
1213
...@@ -18,6 +19,11 @@ pub const EdidOverrideProtocol = extern struct {...@@ -18,6 +19,11 @@ pub const EdidOverrideProtocol = extern struct {
18 .clock_seq_low = 0x22,19 .clock_seq_low = 0x22,
19 .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },20 .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },
20 };21 };
21 pub const dont_override: u32 = 1;22};
22 pub const enable_hot_plug: u32 = 2;23
24pub const EdidOverrideProtocolAttributes = packed struct {
25 _pad1: u6,
26 enable_hot_plug: bool,
27 dont_override: bool,
28 _pad2: u24,
23};29};
std/os/uefi/protocols/simple_text_input_ex_protocol.zig+24-19
...@@ -54,25 +54,30 @@ pub const KeyData = extern struct {...@@ -54,25 +54,30 @@ pub const KeyData = extern struct {
54};54};
5555
56pub const KeyState = extern struct {56pub const KeyState = extern struct {
57 key_shift_state: u32,57 key_shift_state: packed struct {
58 key_toggle_state: u8,58 left_logo_pressed: bool,
5959 right_logo_pressed: bool,
60 pub const shift_state_valid: u32 = 0x80000000;60 left_alt_pressed: bool,
61 pub const right_shift_pressed: u32 = 0x00000001;61 right_alt_pressed: bool,
62 pub const left_shift_pressed: u32 = 0x00000002;62 left_control_pressed: bool,
63 pub const right_control_pressed: u32 = 0x00000004;63 right_control_pressed: bool,
64 pub const left_control_pressed: u32 = 0x00000008;64 left_shift_pressed: bool,
65 pub const right_alt_pressed: u32 = 0x00000010;65 right_shift_pressed: bool,
66 pub const left_alt_pressed: u32 = 0x00000020;66 _pad1: u6,
67 pub const right_logo_pressed: u32 = 0x00000040;67 sys_req_pressed: bool,
68 pub const left_logo_pressed: u32 = 0x00000080;68 menu_key_pressed: bool,
69 pub const menu_key_pressed: u32 = 0x00000100;69 _pad2: u15,
70 pub const sys_req_pressed: u32 = 0x00000200;70 shift_state_valid: bool,
71 pub const toggle_state_valid: u8 = 0x80;71 },
72 pub const key_state_exposed: u8 = 0x40;72 key_toggle_state: packed struct {
73 pub const scroll_lock_active: u8 = 0x01;73 toggle_state_valid: bool,
74 pub const num_lock_active: u8 = 0x02;74 _pad1: u2,
75 pub const caps_lock_active: u8 = 0x04;75 key_state_exposed: bool,
76 caps_lock_active: bool,
77 _pad2: u1,
78 num_lock_active: bool,
79 scroll_lock_active: bool,
80 },
76};81};
7782
78pub const InputKey = extern struct {83pub const InputKey = extern struct {