Skip to content

Conversation

@mintsuki
Copy link
Collaborator

This PR replaces POSIX-UEFI with Nyu-EFI. The build system code is taken from the Nyu-EFI template.

This is a work in progress as it currently GPFs when executing some CALL16 and the GitHub Actions part hasn't been modified. If this PR is of interest I will continue working on it.

Nyu-EFI is a much simpler solution for making EFI applications. It only provides headers, no library, except a small relocation stub that allows ELF toolchains (both GCC and LLVM) to be used for building and examining the executable, prior to the conversion to PE.

@mintsuki
Copy link
Collaborator Author

I got it working!

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

Please go ahead! I was a little bit concerned about POSIX-UEFI's ia32 compatibility and it seems like Nyu-EFI is doing better in this perspective.

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

I just pushed some of my local work, please rebase.

@mintsuki
Copy link
Collaborator Author

Doing so as we speak :)

@mintsuki
Copy link
Collaborator Author

Done.

@mintsuki mintsuki force-pushed the nyu-efi branch 4 times, most recently from 9e1d13e to c422530 Compare May 17, 2025 11:12
@mintsuki mintsuki marked this pull request as ready for review May 17, 2025 11:12
@mintsuki
Copy link
Collaborator Author

I believe everything should be fine now.

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

Thanks for your work!

I have a couple of nits like BS/ST declaration should be in csmwrap.h and so on, do you mind to clean them up?

Also is it possible to use git submodule to manage dependency instead of custom scripts? I found that's much easier for me.

For libc functions my personal perference would be pull in https://github.com/picolibc/picolibc but I'm happy leave it as is given that we are not using much functions.

@mintsuki
Copy link
Collaborator Author

No problem!

The BS/ST variables are declared in csmwrap.h as externs, but they are defined in csmwrap.c as they need to be stored somewhere. Having variable definitions in a header is bad practice, and it wouldn't even work properly without -fcommon anymore.

Sure, I will convert to submodules if you prefer that.

Yeah, I agree that given we only use 5 libc functions, it's better to not pull in too many unnecessary foreign dependencies.

Furthermore, I forgot to clean up a bit the code to exit boot services in order to add all workarounds needed for real machines to work properly. This was a quick PoC that would work in QEMU with OVMF.

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

cc -g -O2 -pipe -Wall -Wextra -std=gnu11 -nostdinc -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -fPIE -ffunction-sections -fdata-sections -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -I src -I nyu-efi/inc -isystem freestnd-c-hdrs  -MMD -MP -c src/printf.c -o obj-x86_64/printf.c.o
src/printf.c:10:10: fatal error: nanoprintf.h: No such file or directory
   10 | #include <nanoprintf.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

CI seems to be failing.

@mintsuki
Copy link
Collaborator Author

Fixed.

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

Seems like cbvga stopped to work.
I'll investigate.

@FlyGoat
Copy link
Owner

FlyGoat commented May 17, 2025

I'll merge atm and try to debug further as we are not going to make a release any time soon.

@FlyGoat FlyGoat merged commit 48f59f5 into FlyGoat:main May 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants