rust-osdev / x86_64

Library to program x86_64 hardware.
https://docs.rs/x86_64
Apache License 2.0
797 stars 132 forks source link

VirtAddr improvements #370

Closed josephlr closed 2 years ago

josephlr commented 2 years ago

The first commit removes our *const T -> VirtAddr conversion on 32-bit platforms. Per the comment, it's "only here for backwards compatibility". Should we go even further and remove the conversions on all non-x86_64 platforms?

The second commit makes it so new and try_new fail on non-canonical addresses. Fixes #299

The third commit make new and try_new const. Other VirtAddr/PhysAddr methods are made const in #369 (which will be pulled back into this branch when its merged).

josephlr commented 2 years ago

We should also update the docs of new_truncate because it still mentions new and try_new as alternative methods with similar behavior, but these methods don't do any sign extension anymore. So maybe remove that last sentence, or change it to "If you want to check whether an address is canonical ...".

I updated the docs for new and try_new to make it clear that they don't sign extend anything (they just check if addresses are canonical). I also made your recommended changes to new_truncate, added some cross links, and fixed some typos.