-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ready to publish page_table_entry to crates.io
- Loading branch information
1 parent
a0dc70c
commit 84120cd
Showing
5 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# page_table_entry | ||
|
||
This crate provides the definition of page table entry for various hardware | ||
architectures. | ||
|
||
Currently supported architectures and page table entry types: | ||
|
||
- x86: [`x86_64::X64PTE`][1] | ||
- ARM: [`aarch64::A64PTE`][2] | ||
- RISC-V: [`riscv::Rv64PTE`][3] | ||
|
||
All these types implement the [`GenericPTE`][4] trait, which provides unified | ||
methods for manipulating various page table entries. | ||
|
||
[1]: https://docs.rs/page_table_entry/latest/page_table_entry/x86_64/struct.X64PTE.html | ||
[2]: https://docs.rs/page_table_entry/latest/page_table_entry/aarch64/struct.A64PTE.html | ||
[3]: https://docs.rs/page_table_entry/latest/page_table_entry/riscv/struct.Rv64PTE.html | ||
[4]: https://docs.rs/page_table_entry/latest/page_table_entry/trait.GenericPTE.html | ||
|
||
## Examples (x86_64) | ||
|
||
```rust | ||
use memory_addr::PhysAddr; | ||
use page_table_entry::{GenericPTE, MappingFlags, x86_64::X64PTE}; | ||
use x86_64::structures::paging::page_table::PageTableFlags; | ||
|
||
let paddr = PhysAddr::from(0x233000); | ||
let pte = X64PTE::new_page( | ||
paddr, | ||
/*flags:*/ MappingFlags::READ | MappingFlags::WRITE, | ||
/*is_huge:*/ false, | ||
); | ||
assert!(!pte.is_unused()); | ||
assert!(pte.is_present()); | ||
assert_eq!(pte.paddr(), paddr); | ||
assert_eq!(pte.bits(), 0x800_0000000233_003); // PRESENT | WRITE | NO_EXECUTE | paddr(0x233000) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters