Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
HermitOS
kernel
Commits
a4829d2d
Commit
a4829d2d
authored
2 years ago
by
Martin Kröning
Browse files
Options
Downloads
Patches
Plain Diff
Paging: Rework identity_map
parent
65dd01f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/arch/x86_64/kernel/acpi.rs
+9
-5
9 additions, 5 deletions
src/arch/x86_64/kernel/acpi.rs
src/arch/x86_64/mm/paging.rs
+17
-18
17 additions, 18 deletions
src/arch/x86_64/mm/paging.rs
with
26 additions
and
23 deletions
src/arch/x86_64/kernel/acpi.rs
+
9
−
5
View file @
a4829d2d
use
x86_64
::
structures
::
paging
::
PhysFrame
;
use
crate
::
arch
::
x86_64
::
kernel
::
processor
;
use
crate
::
arch
::
x86_64
::
mm
::
paging
::{
BasePageSize
,
PageSize
,
PageTableEntryFlags
,
PageTableEntryFlagsExt
,
...
...
@@ -255,10 +257,10 @@ fn detect_rsdp(start_address: PhysAddr, end_address: PhysAddr) -> Result<&'stati
// Have we crossed a page boundary in the last iteration?
if
current_address
/
BasePageSize
::
SIZE
as
usize
>
current_page
{
// Identity-map this possible page of the RSDP.
paging
::
identity_map
(
PhysAddr
::
from
(
current_address
)
,
PhysAddr
::
from
(
current_address
),
);
let
frame
=
PhysFrame
::
<
BasePageSize
>
::
containing_address
(
x86_64
::
PhysAddr
::
new
(
current_address
as
u64
,
));
paging
::
identity_map
(
frame
);
current_page
=
current_address
/
BasePageSize
::
SIZE
as
usize
;
}
...
...
@@ -304,7 +306,9 @@ fn detect_rsdp(start_address: PhysAddr, end_address: PhysAddr) -> Result<&'stati
/// Returns a reference to the ACPI RSDP within the Ok() if successful or an empty Err() on failure.
fn
detect_acpi
()
->
Result
<&
'static
AcpiRsdp
,
()
>
{
// Get the address of the EBDA.
paging
::
identity_map
(
EBDA_PTR_LOCATION
,
EBDA_PTR_LOCATION
);
let
frame
=
PhysFrame
::
<
BasePageSize
>
::
containing_address
(
x86_64
::
PhysAddr
::
new
(
EBDA_PTR_LOCATION
.0
));
paging
::
identity_map
(
frame
);
let
ebda_ptr_location
:
&
u16
=
unsafe
{
&*
(
VirtAddr
::
from
(
EBDA_PTR_LOCATION
.as_u64
())
.as_ptr
())
};
let
ebda_address
=
PhysAddr
((
*
ebda_ptr_location
as
u64
)
<<
4
);
...
...
This diff is collapsed.
Click to expand it.
src/arch/x86_64/mm/paging.rs
+
17
−
18
View file @
a4829d2d
...
...
@@ -239,28 +239,27 @@ pub fn unmap<S: PageSize>(virtual_address: VirtAddr, count: usize) {
}
#[cfg(feature
=
"acpi"
)]
pub
fn
identity_map
(
start_address
:
PhysAddr
,
end_address
:
PhysAddr
)
{
let
first_page
=
Page
::
<
BasePageSize
>
::
containing_address
(
x86_64
::
VirtAddr
::
new
(
start_address
.as_u64
()));
let
last_page
=
Page
::
<
BasePageSize
>
::
containing_address
(
x86_64
::
VirtAddr
::
new
(
end_address
.as_u64
()));
pub
fn
identity_map
<
S
>
(
frame
:
PhysFrame
<
S
>
)
where
S
:
PageSize
+
core
::
fmt
::
Debug
,
RecursivePageTable
<
'static
>
:
Mapper
<
S
>
,
{
assert!
(
last_pag
e
.start_address
()
.as_u64
()
<
mm
::
kernel_start_address
()
.0
,
fram
e
.start_address
()
.as_u64
()
<
mm
::
kernel_start_address
()
.0
,
"Address {:#X} to be identity-mapped is not below Kernel start address"
,
last_pag
e
.start_address
()
fram
e
.start_address
()
);
let
mut
flags
=
PageTableEntryFlags
::
empty
();
flags
.normal
()
.read_only
()
.execute_disable
();
let
count
=
(
last_page
.start_address
()
.as_u64
()
-
first_page
.start_address
()
.as_u64
())
/
BasePageSize
::
SIZE
+
1
;
map
::
<
BasePageSize
>
(
VirtAddr
(
first_page
.start_address
()
.as_u64
()),
PhysAddr
(
first_page
.start_address
()
.as_u64
()),
count
as
usize
,
flags
,
);
unsafe
{
recursive_page_table
()
.identity_map
(
frame
,
PageTableEntryFlags
::
PRESENT
|
PageTableEntryFlags
::
NO_EXECUTE
,
&
mut
physicalmem
::
FrameAlloc
,
)
.unwrap
()
.flush
();
}
}
#[inline]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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