-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: implement basic io and improve alloc in uefi #22226
base: master
Are you sure you want to change the base?
Conversation
@@ -1,5 +1,7 @@ | |||
const std = @import("../std.zig"); | |||
|
|||
pub const posix = @import("uefi/posix.zig"); |
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.
Last I talked with Andrew about the future of std.posix
, one thing we agreed on is that probably all Windows code in std.posix
should be deleted. I would expect that the exact same thing is true of UEFI, as it is also not a POSIX platform in any meaningful sense?
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.
Yeah, I agree. The UEFI POSIX stuff is just a POSIX wrapper around the UEFI protocols. We can always ditch it. UEFI is close to Windows so I think whatever we do for Windows and POSIX, it would apply to UEFI.
lib/std/Thread/Futex.zig
Outdated
@@ -66,7 +66,7 @@ pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { | |||
Impl.wake(ptr, max_waiters); | |||
} | |||
|
|||
const Impl = if (builtin.single_threaded) | |||
const Impl = if (builtin.single_threaded or builtin.os.tag == .uefi) |
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.
Should UEFI be treated as a proper single-threaded target?
Lines 66 to 81 in 82f35c5
pub fn alwaysSingleThreaded(target: std.Target) bool { | |
_ = target; | |
return false; | |
} | |
pub fn defaultSingleThreaded(target: std.Target) bool { | |
switch (target.cpu.arch) { | |
.wasm32, .wasm64 => return true, | |
else => {}, | |
} | |
switch (target.os.tag) { | |
.haiku => return true, | |
else => {}, | |
} | |
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.
Yes, I just didn't know where the source was which defined that heh.
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.
I've updated this and changed the defaultSingleThreaded
for UEFI.
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.
Out of curiosity, is UEFI not always single threaded instead of just default single threaded?
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.
You technically could implement a form of multithreading, just like with wasm. It's just builtin.single_threaded
will default to true
when single_threaded
is not changed in your build. You probably could write a custom scheduler + mutltithreading stuff and use root.os
stuff to get it working but no implementation will be made for upstream.
87beafb
to
2a2c072
Compare
Largely based on #19486, this PR marks me starting to work on UEFI support in Zig again. This time, there will be multiple PR's instead of one so it becomes easier to manage. This PR simply makes the
zig init
example build.I tested this in QEMU by loading in OVMF, entering the UEFI shell, loading
FS0:\bin\$.efi
. Thezig-out
can be shared by adding:-drive file=fat:rw:zig-out
.