mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Update blog to e272cc9257
This commit is contained in:
@@ -296,12 +296,12 @@ To convert the address into references, we add two functions:
|
|||||||
```rust
|
```rust
|
||||||
pub fn next_table(&self, index: usize) -> Option<&Table> {
|
pub fn next_table(&self, index: usize) -> Option<&Table> {
|
||||||
self.next_table_address(index)
|
self.next_table_address(index)
|
||||||
.map(|t| unsafe { &*(t as *const _) })
|
.map(|address| unsafe { &*(address as *const _) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> {
|
pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table> {
|
||||||
self.next_table_address(index)
|
self.next_table_address(index)
|
||||||
.map(|t| unsafe { &mut *(t as *mut _) })
|
.map(|address| unsafe { &mut *(address as *mut _) })
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
We convert the address into raw pointers and then convert them into references in `unsafe` blocks. Now we can start at the `P4` constant and use these functions to access the lower tables. And we don't even need `unsafe` blocks to do it!
|
We convert the address into raw pointers and then convert them into references in `unsafe` blocks. Now we can start at the `P4` constant and use these functions to access the lower tables. And we don't even need `unsafe` blocks to do it!
|
||||||
|
|||||||
Reference in New Issue
Block a user