Skip to content

Add PhysicalAddress and VirtualAddress type aliases #518

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

Merged
merged 1 commit into from
Sep 25, 2022

Conversation

nicholasbishop
Copy link
Member

@nicholasbishop nicholasbishop commented Sep 24, 2022

These correspond to EFI_PHYSICAL_ADDRESS and EFI_VIRTUAL_ADDRESS. These usually end up being converted to a pointer type, but notably they are always 64-bit regardless of the target platform. This change revealed a bug in the AllocateType enum; it was using usize for a couple members, but that is not correct for all targets, e.g. i686-unknown-uefi.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits): See the
    Rewriting History guide for
    help.
  • Update the changelog (if necessary)

These correspond to `EFI_PHYSICAL_ADDRESS` and
`EFI_VIRTUAL_ADDRESS`. These usually end up being converted to a pointer
type, but notably they are always 64-bit regardless of the target
platform. This change revealed a bug in the `AllocateType` enum; it was
using `usize` for a couple members, but that is not correct for all
targets, e.g. `i686-unknown-uefi`.
@phip1611
Copy link
Member

phip1611 commented Sep 25, 2022

I double-checked it against the spec, looks good!

PS: I do not understand why UEFI talks about virtual addresses. Due to the identity mapping, all virtual addresses correspond to physical addresses, right? Are there exceptions from that?

@phip1611 phip1611 merged commit ae7ba25 into rust-osdev:main Sep 25, 2022
@nicholasbishop nicholasbishop deleted the bishop-add-physicaladdr branch September 25, 2022 14:47
@nicholasbishop
Copy link
Member Author

PS: I do not understand why UEFI talks about virtual addresses. Due to the identity mapping, all virtual addresses correspond to physical addresses, right? Are there exceptions from that?

My understanding is that when boot services are active it has the identity mapping. After transitining to runtime-services mode it still has the identity mapping, but the OS probably doesn't want to stay in that mode, so it can call SetVirtualAddressMap to set up a virtual mapping. After that it can continue to use the runtime services with the new mapping.

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