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 {
2626 hour: u8,
2727 minute: u8,
2828 second: u8,
29 pad1: u8,
29 _pad1: u8,
3030 nanosecond: u32,
3131 timezone: i16,
32 daylight: u8,
33 pad2: u8,
32 daylight: packed struct {
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;
3739 pub const unspecified_timezone: i16 = 0x7ff;
3840};
3941pub const TimeCapabilities = extern struct {
std/os/uefi/protocols.zig+1
......@@ -27,5 +27,6 @@ pub const EdidDiscoveredProtocol = @import("protocols/edid_discovered_protocol.z
2727pub const EdidActiveProtocol = @import("protocols/edid_active_protocol.zig").EdidActiveProtocol;
2828
2929pub const EdidOverrideProtocol = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocol;
30pub const EdidOverrideProtocolAttributes = @import("protocols/edid_override_protocol.zig").EdidOverrideProtocolAttributes;
3031
3132pub 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 {
3434 absolute_max_x: u64,
3535 absolute_max_y: u64,
3636 absolute_max_z: u64,
37 attributes: u32,
38
39 pub const supports_alt_active: u32 = 1;
40 pub const supports_pressure_as_z: u32 = 2;
37 attributes: packed struct {
38 _pad1: u6,
39 supports_pressure_as_z: bool,
40 supports_alt_active: bool,
41 _pad2: u24,
42 },
4143};
4244
4345pub const AbsolutePointerState = extern struct {
4446 current_x: u64,
4547 current_y: u64,
4648 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
4956 pub fn init() AbsolutePointerState {
5057 return AbsolutePointerState{
......@@ -54,7 +61,4 @@ pub const AbsolutePointerState = extern struct {
5461 .active_buttons = undefined,
5562 };
5663 }
57
58 pub const touch_active: u32 = 1;
59 pub const alt_active: u32 = 2;
6064};
std/os/uefi/protocols/edid_override_protocol.zig+9-3
......@@ -6,7 +6,8 @@ const Handle = uefi.Handle;
66pub const EdidOverrideProtocol = extern struct {
77 _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 {
1011 return self._get_edid(self, handle, attributes, edid_size, edid);
1112 }
1213
......@@ -18,6 +19,11 @@ pub const EdidOverrideProtocol = extern struct {
1819 .clock_seq_low = 0x22,
1920 .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 },
2021 };
21 pub const dont_override: u32 = 1;
22 pub const enable_hot_plug: u32 = 2;
22};
23
24pub const EdidOverrideProtocolAttributes = packed struct {
25 _pad1: u6,
26 enable_hot_plug: bool,
27 dont_override: bool,
28 _pad2: u24,
2329};
std/os/uefi/protocols/simple_text_input_ex_protocol.zig+24-19
......@@ -54,25 +54,30 @@ pub const KeyData = extern struct {
5454};
5555
5656pub const KeyState = extern struct {
57 key_shift_state: u32,
58 key_toggle_state: u8,
59
60 pub const shift_state_valid: u32 = 0x80000000;
61 pub const right_shift_pressed: u32 = 0x00000001;
62 pub const left_shift_pressed: u32 = 0x00000002;
63 pub const right_control_pressed: u32 = 0x00000004;
64 pub const left_control_pressed: u32 = 0x00000008;
65 pub const right_alt_pressed: u32 = 0x00000010;
66 pub const left_alt_pressed: u32 = 0x00000020;
67 pub const right_logo_pressed: u32 = 0x00000040;
68 pub const left_logo_pressed: u32 = 0x00000080;
69 pub const menu_key_pressed: u32 = 0x00000100;
70 pub const sys_req_pressed: u32 = 0x00000200;
71 pub const toggle_state_valid: u8 = 0x80;
72 pub const key_state_exposed: u8 = 0x40;
73 pub const scroll_lock_active: u8 = 0x01;
74 pub const num_lock_active: u8 = 0x02;
75 pub const caps_lock_active: u8 = 0x04;
57 key_shift_state: packed struct {
58 left_logo_pressed: bool,
59 right_logo_pressed: bool,
60 left_alt_pressed: bool,
61 right_alt_pressed: bool,
62 left_control_pressed: bool,
63 right_control_pressed: bool,
64 left_shift_pressed: bool,
65 right_shift_pressed: bool,
66 _pad1: u6,
67 sys_req_pressed: bool,
68 menu_key_pressed: bool,
69 _pad2: u15,
70 shift_state_valid: bool,
71 },
72 key_toggle_state: packed struct {
73 toggle_state_valid: bool,
74 _pad1: u2,
75 key_state_exposed: bool,
76 caps_lock_active: bool,
77 _pad2: u1,
78 num_lock_active: bool,
79 scroll_lock_active: bool,
80 },
7681};
7782
7883pub const InputKey = extern struct {