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

Use new UEFI bootloader #792

Merged

Conversation

tsoutsman
Copy link
Member

@tsoutsman tsoutsman commented Jan 8, 2023

The bootloader is at https://github.com/theseus-os/uefi-bootloader. It will also need to be reviewed.

Depends on #785, #786, and #790. I haven't been able to properly review all the changes in this PR because it builds on top of many different PRs. Once they are merged, I'll be able to review the changes properly.

tsoutsman and others added 30 commits December 30, 2022 12:48
Older Rust toolchains didn't have the `rust-std` component for
`*-unknown-uefi` targets meaning they couldn't be used for artifact
dependencies.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Works with tsoutsman/uefi-bootloader#9c85f8e.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
This is the first step in supporting Theseus loaded at an aribtrary
address.

The changes to `frame_allocator` are necessary for the frame allocator
to correctly initialise when a reserved memory region overlaps with more
than one reserved memory region that came before it. Reshuffling the
order that the bootloader info and modules memory regions are added to
the reserved memory regions revealed the problem.

The PR also removes `bios` as the default feature for `nano_core` as it
makes it impossible to compile for UEFI, as discussed on Discord.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Co-authored-by: Kevin Boos <1139460+kevinaboos@users.noreply.github.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
@tsoutsman tsoutsman requested a review from kevinaboos January 11, 2023 03:18
Older Rust toolchains didn't have the `rust-std` component for
`*-unknown-uefi` targets meaning they couldn't be used for artifact
dependencies.

The upcoming switch to the new UEFI bootloader uses artifact
dependencies on `*-unknown-uefi` targets.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
@tsoutsman
Copy link
Member Author

Depends on #803.

Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

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

Minor to-do: add a description of the uefi_builder* tool crates to the tools/README.md file

tsoutsman and others added 3 commits January 11, 2023 20:15
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Co-authored-by: Kevin Boos <1139460+kevinaboos@users.noreply.github.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
@tsoutsman tsoutsman force-pushed the new-uefi-bootloader-no-aarch branch from e02fe09 to b4af63d Compare January 11, 2023 09:28
@tsoutsman tsoutsman requested a review from kevinaboos January 11, 2023 09:28
@kevinaboos
Copy link
Member

LGTM; will approve & merge pending a review of uefi-bootloader

@kevinaboos kevinaboos merged commit 922cb09 into theseus-os:theseus_main Jan 12, 2023
github-actions bot pushed a commit that referenced this pull request Jan 12, 2023
* Removes old assumptions/requirements that all sections
  in the kernel base image are loaded into physically-contiguous
  memory, especially the stack and bootloader info.
  * IOW, we stop relying upon a fixed `KERNEL_OFFSET` to
    calculate virtual addresses from physical addresses and vice versa;
    instead, we actually translate addresses via the initial page table.
  * Thus, we must obtain the address of the GDT used to boot
    secondary CPUs (APs on x86) and pass it through the various
    init routines so that it can be used when booting secondary CPUs.

* `PageRange` and `FrameRange` constructors will now return an
  empty range if invoked with a size of 0 bytes, instead of panicking.

* The major changes in this commit is to introduce new crates that
  support building Theseus for and booting it on UEFI bootloaders.
  * `tools/uefi-builder` is now multi-architecture,
    but aarch64 support is a WIP.
  * The separate `theseus-os/uefi-bootloader` repo is a fork of
    `rust-osdev/bootloader` but heavily changed to support Theseus's
    needs and additional architectures.
    * aarch64 is still a WIP here too.

* Currently we manually ensure that the same version of the
  `uefi-bootloader*` crates are used in the Theseus workspace
  and in the `tools/uefi-builder/*` crates. Ideally this would be
  ensured automatically in the future.

* `uefi-builder` consists of separate, per-arch crates; we can combine
  them once <rust-lang/cargo#10030> is fixed.

Co-authored-by: Kevin Boos <kevinaboos@gmail.com> 922cb09
github-actions bot pushed a commit to tsoutsman/Theseus that referenced this pull request Jan 12, 2023
* Removes old assumptions/requirements that all sections
  in the kernel base image are loaded into physically-contiguous
  memory, especially the stack and bootloader info.
  * IOW, we stop relying upon a fixed `KERNEL_OFFSET` to
    calculate virtual addresses from physical addresses and vice versa;
    instead, we actually translate addresses via the initial page table.
  * Thus, we must obtain the address of the GDT used to boot
    secondary CPUs (APs on x86) and pass it through the various
    init routines so that it can be used when booting secondary CPUs.

* `PageRange` and `FrameRange` constructors will now return an
  empty range if invoked with a size of 0 bytes, instead of panicking.

* The major changes in this commit is to introduce new crates that
  support building Theseus for and booting it on UEFI bootloaders.
  * `tools/uefi-builder` is now multi-architecture,
    but aarch64 support is a WIP.
  * The separate `theseus-os/uefi-bootloader` repo is a fork of
    `rust-osdev/bootloader` but heavily changed to support Theseus's
    needs and additional architectures.
    * aarch64 is still a WIP here too.

* Currently we manually ensure that the same version of the
  `uefi-bootloader*` crates are used in the Theseus workspace
  and in the `tools/uefi-builder/*` crates. Ideally this would be
  ensured automatically in the future.

* `uefi-builder` consists of separate, per-arch crates; we can combine
  them once <rust-lang/cargo#10030> is fixed.

Co-authored-by: Kevin Boos <kevinaboos@gmail.com> 922cb09
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