Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-28665-2608131
oskernel2024-9-2160
Commits
3b0a5cbd
Commit
3b0a5cbd
authored
3 months ago
by
只敲代码不玩耍,聪明baka也变傻ᗜˬᗜ
Browse files
Options
Download
Patches
Plain Diff
feat: add methods for converting between VirtualAddress and pointers/references
parent
426cb28a
submit
feat/docs
feat/docs-vendored
feat/ext4-filesystem
feat/ext4-filesystem-vendored
feat/lazy-symbol-table-build
feat/lazy-symbol-table-build-vendored
feat/paging-virtual-memory
feat/paging-virtual-memory-vendored
feat/setup-trap-control-flow
feat/setup-trap-control-flow-vendored
feat/test-final
feat/test-final-vendored
master
master-vendored
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/address/src/virtual_address.rs
+24
-0
crates/address/src/virtual_address.rs
with
24 additions
and
0 deletions
+24
-0
crates/address/src/virtual_address.rs
+
24
−
0
View file @
3b0a5cbd
...
...
@@ -12,6 +12,30 @@ impl VirtualAddress {
pub
fn
to_physical
(
self
)
->
PhysicalAddress
{
PhysicalAddress
::
from_usize
(
self
.as_usize
()
&
constants
::
PHYS_ADDR_MASK
)
}
pub
fn
from_ref
<
T
>
(
r
:
&
T
)
->
VirtualAddress
{
VirtualAddress
::
from_ptr
(
r
as
*
const
T
)
}
pub
fn
from_ptr
<
T
>
(
p
:
*
const
T
)
->
VirtualAddress
{
VirtualAddress
::
from_usize
(
p
as
usize
)
}
pub
unsafe
fn
as_ref
<
T
>
(
&
self
)
->
&
'static
T
{
&*
(
self
.as_usize
()
as
*
const
T
)
}
pub
unsafe
fn
as_mut
<
T
>
(
&
self
)
->
&
'static
mut
T
{
&
mut
*
(
self
.as_usize
()
as
*
mut
T
)
}
pub
unsafe
fn
as_ptr
<
T
>
(
&
self
)
->
*
const
T
{
self
.as_usize
()
as
*
const
T
}
pub
unsafe
fn
as_mut_ptr
<
T
>
(
&
self
)
->
*
mut
T
{
self
.as_usize
()
as
*
mut
T
}
}
#[cfg(test)]
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets