-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std.os.uefi.protocol: ziggify function signatures #23214
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
Conversation
4f65107
to
c5ad247
Compare
one problem I'm struggling to address in this PR is the potential for the underlying API to return status codes - most of std.os.uefi already assumes non- |
c5ad247
to
3c4cfa8
Compare
3c4cfa8
to
29c91b7
Compare
pub fn delete(self: *File) bool { | ||
switch (self._delete(self)) { | ||
.success => return true, | ||
.warn_delete_failure => return false, |
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.
That seems like a good solution. Once we find an API that can return both a value and a warning it'll get awkward though.
for warnings, i'm considering a global alternatively, I can make a |
as mentioned in the last commit message, i've finished the initial refactorings :D I don't have time for a self-review right now, I'll get to it later today (I'm traveling in Japan for another couple days) |
lib/std/os/uefi/protocol.zig
Outdated
pub const Udp6 = @import("protocol/udp6.zig").Udp6; | ||
|
||
pub const HiiDatabase = @import("protocol/hii_database.zig").HiiDatabase; | ||
pub const HiiPopup = @import("protocol/hii_popup.zig").HiiPopup; | ||
|
||
pub fn ServiceBinding(service_guid: uefi.Guid) type { |
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.
there's more ServiceBinding
types, and none of them provide more specific info about errors, nor do I see any of them have more functionality...
pub fn getStatus( | ||
self: *SimpleNetwork, | ||
interrupt_status: ?*InterruptStatus, | ||
tx_buf: ?*?[*]u8, | ||
) GetStatusError!void { |
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.
lol there's 4 different ways to return values here, so i just left it as is...
pub fn outputString(self: *SimpleTextOutput, msg: [*:0]const u16) OutputStringError!bool { | ||
switch (self._output_string(self, msg)) { | ||
.success => return true, | ||
.warn_unknown_glyph => return false, |
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.
another instance of a defined warning being possible, luckily this one is also easy...
getEdid should return all values via return value nitty mcpicky more enum Flag types oops didnt update the signature IpAddress union
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.
Great work, I really like where this is going 🙂
Please ping me when you consider this done and want a full review.
ah dang, i'm getting some compiler errors as i'm integrating this into my code 😅 sorry if i push while you're reviewing, i'll try to push only once (after i get regular |
ok fixed the compiler errors :) done pushing for the (japanese) night! |
added 5205b19 because in my work on my next PR, i realized that the |
Apologies for the delay on this, I haven't forgotten about it yet 🙂 |
No worries! Thanks for letting me know |
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.
Finally got around to testing this with my own project - std.debug needs an update:
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -629,9 +629,9 @@ pub fn defaultPanic(
// isn't visible on actual hardware if directly booted into
inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| {
if (o) |out| {
- _ = out.setAttribute(uefi.protocol.SimpleTextOutput.red);
- _ = out.outputString(exit_msg);
- _ = out.setAttribute(uefi.protocol.SimpleTextOutput.white);
+ out.setAttribute(.{ .foreground = .red }) catch {};
+ _ = out.outputString(exit_msg) catch {};
+ out.setAttribute(.{ .foreground = .white }) catch {};
}
}
Please do a quick grep around std to see if any other UEFI-specific code paths need updating.
Once this is merged I think we should look into supporting returning std.os.uefi.Status.Error
from main()
, having to convert the errors back into a status every time is a bit tedious :)
Co-authored-by: linusg <[email protected]>
I grepped and none of the other none of the rest of the codebase uses anything from good idea! i'll open a PR in a bit :) |
* master: Sema: increment extra index even if return type is generic std.start: allow return uefi error union in main (ziglang#23425) std.os.uefi.protocol: ziggify function signatures (ziglang#23214) zon: normalize negative zeroes Elf: fix incrementally reallocating the last atom in a section Sema: allow `@ptrCast` slice of zero-bit type to slice of non-zero-bit type translate-c: fix referencing extern locals from nested blocks Add quota for comptime sort, add test std.compress.zstd: ensure window size fits into usize std.compress.zstd: fix OOB access in literal decode ci: Build stage4 and run behavior tests with it on aarch64-linux-debug. ci: Don't do the update-zig1 test steps on aarch64-linux. ci: Don't build the compiler for arm-linux-musleabihf on aarch64-linux. ci: Set execute bit on aarch64-linux scripts.
A lot of the function signatures in
std.os.uefi.protocol
aren't very ziggy. This PR modifies a significant number of the namespace's functions to align more with verbose Zig code.*
to*const
and vice-versa as appropriateuefi.unexpectedError
, which is akin toposix.unexpectedError
.success
, rather than requiring an output pointer parameternote: most of
std.os.uefi
is untested, and that's not really changing here. I'm mostly focused on making sure there are no compiler errors. Any further problems will require a future PR to address.