Skip to content
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

Support UEFI OS #3996

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

Support UEFI OS #3996

wants to merge 5 commits into from

Conversation

jclab-joseph
Copy link

@jclab-joseph jclab-joseph commented Nov 13, 2023

Adds support for UEFI OS.

  • Working minimal
  • findGlobals
  • Refactoring
  • exit
  • amd64
  • smoke test
  • target.json

not goal

  • i386
  • arm64 (TODO)

Usage :

tinygo build -target uefi-amd64 -o test.efi main.go

image

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick pass over the code (not a full review).

My main comment is this: can you make this more like any other baremetal target instead of making it its own thing besides baremetal and regular OSes? A baremetal target is much easier to maintain than what you have here (for example, the existing Nintendo Switch support is more work than any weird chip someone added support for years ago).

Also, please add a smoke test so we can see how it works.

compileopts/target.go Outdated Show resolved Hide resolved
src/runtime/gc_globals.go Show resolved Hide resolved
src/runtime/runtime_uefi.go Outdated Show resolved Hide resolved
src/runtime/runtime_uefi.go Outdated Show resolved Hide resolved
src/runtime/runtime_uefi.go Outdated Show resolved Hide resolved
Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it will be a huge PR, so I suggest working on ways to simplify it. It can only be merged if it is maintainable, and right now it's so invasive I honestly don't want to merge it like this.

  • Don't copy code like you did for findGlobals. Instead, find ways to reuse it. For example, you can move it to a new gc_windows.go file that is compiled in both Windows and UEFI.
  • Do not make this a new GOOS. Instead, create targets/uefi.json that sets all the necessary properties (and adds at least the uefi and baremetal build tags). This probably means using GOOS=linux, like all the other baremetal targets. Then you can compile for UEFI using tinygo build -target=uefi ....
  • Add a smoke test to GNUmakefile (there are lots of smoke tests already in there).

(To be clear: there is a difference between big and invasive. Right now it modifies many parts that shouldn't need to be modified by a PR that adds a new build target. If you need to use many lines of code to implement UEFI support, that's fine as long as it doesn't affect the common code too much).

src/runtime/os_uefi.go Show resolved Hide resolved
src/runtime/gc_globals.go Show resolved Hide resolved
compileopts/target.go Outdated Show resolved Hide resolved
src/runtime/runtime_uefi.go Outdated Show resolved Hide resolved
@jclab-joseph
Copy link
Author

jclab-joseph commented Nov 20, 2023

Yes, it's not a good looking code right now.
It's a work in progress and needs a lot of refactoring.
Your opinion will help me a lot!

GOOS=linux is required, but with the exception uefi should use task_stack_windows_amd64 instead of task_stack_linux_amd64 . Cannot change name of task_stack.s without changing target.go.
I'm sorry. It was my mistake. It's being edited.

@jclab-joseph jclab-joseph changed the title WIP: Support UEFI OS Support UEFI OS Nov 21, 2023
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.

None yet

2 participants