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
std/os/uefi: additional improvements/fixes #10604
Conversation
`uefi/protocols.zig` and `uefi/tables.zig` just re-exported all the public symbols, which is basically the purpose of `usingnamespace` import-wise.
Writes the panic message to stderr as well as passing it to boot_services.exit when boot_services is available.
Uses comptime loops over the types instead of writing out a large switch.
Beyond adding default zero-initialization, this commit changes undefined initialization to zero, as some cases reserved the padding and on other cases, I've found some systems act strange when giving uninit instead of zero even when it shouldn't be an issue, one example being FileProtocol.Open's attributes, which *should* be ignored when not creating a file, but ended up giving an unrelated error.
This makes the struct align(4), which allows it to be passed as flags more easily.
Allows handling uefi function errors in a more zig-style way with try and catch, using `try f().err()` when a `Status` is returned.
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.
Have you checked that the changes you made to padding don't affect the structs? Packed structs are still a bit buggy at the moment.
Yeah, I used fn test_types(comptime TPrev: type, comptime TPost: type) void {
var a = std.mem.zeroes(TPrev);
var b = std.mem.zeroes(TPost);
inline for (@typeInfo(TPost).Struct.fields) |field| {
assert(@bitOffsetOf(TPrev, field.name) == @bitOffsetOf(TPost, field.name));
assert(@offsetOf(TPrev, field.name) == @offsetOf(TPost, field.name));
}
assert(@sizeOf(TPrev) == @sizeOf(TPost));
assert(@alignOf(@TypeOf(&a)) == @alignOf(@TypeOf(&b)));
}
test "align" {
test_types(Time, Time2);
test_types(AbsolutePointerMode, AbsolutePointerMode2);
test_types(AbsolutePointerState, AbsolutePointerState2);
test_types(EdidOverrideProtocolAttributes, EdidOverrideProtocolAttributes2);
test_types(SimpleNetworkReceiveFilter, SimpleNetworkReceiveFilter2);
test_types(SimpleNetworkInterruptStatus, SimpleNetworkInterruptStatus2);
test_types(OpenProtocolAttributes, OpenProtocolAttributes2);
var a = std.mem.zeroes(AbsolutePointerMode);
var a2 = std.mem.zeroes(AbsolutePointerMode2);
var b = std.mem.zeroes(AbsolutePointerState);
var b2 = std.mem.zeroes(AbsolutePointerState2);
test_types(@TypeOf(a.attributes), @TypeOf(a2.attributes));
test_types(@TypeOf(b.active_buttons), @TypeOf(b2.active_buttons));
} For the tests I changed |
No description provided.