Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
kernel
Commits
04cc8a2d
Verified
Commit
04cc8a2d
authored
4 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Simplify reserved memory hack
parent
7355ae16
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/arch/x86_64/rmm.rs
+16
-8
16 additions, 8 deletions
src/arch/x86_64/rmm.rs
with
16 additions
and
8 deletions
src/arch/x86_64/rmm.rs
+
16
−
8
View file @
04cc8a2d
...
@@ -50,7 +50,7 @@ unsafe fn page_flags<A: Arch>(virt: VirtualAddress) -> usize {
...
@@ -50,7 +50,7 @@ unsafe fn page_flags<A: Arch>(virt: VirtualAddress) -> usize {
}
}
}
}
unsafe
fn
inner
<
A
:
Arch
>
(
areas
:
&
'static
[
MemoryArea
],
bump_offset
:
usize
)
->
BuddyAllocator
<
A
>
{
unsafe
fn
inner
<
A
:
Arch
>
(
areas
:
&
'static
[
MemoryArea
],
kernel_base
:
usize
,
kernel_size_aligned
:
usize
,
bump_offset
:
usize
)
->
BuddyAllocator
<
A
>
{
// First, calculate how much memory we have
// First, calculate how much memory we have
let
mut
size
=
0
;
let
mut
size
=
0
;
for
area
in
areas
.iter
()
{
for
area
in
areas
.iter
()
{
...
@@ -65,7 +65,6 @@ unsafe fn inner<A: Arch>(areas: &'static [MemoryArea], bump_offset: usize) -> Bu
...
@@ -65,7 +65,6 @@ unsafe fn inner<A: Arch>(areas: &'static [MemoryArea], bump_offset: usize) -> Bu
// Create a basic allocator for the first pages
// Create a basic allocator for the first pages
let
mut
bump_allocator
=
BumpAllocator
::
<
A
>
::
new
(
areas
,
bump_offset
);
let
mut
bump_allocator
=
BumpAllocator
::
<
A
>
::
new
(
areas
,
bump_offset
);
//TODO: memory protection
{
{
let
mut
mapper
=
PageMapper
::
<
A
,
_
>
::
create
(
let
mut
mapper
=
PageMapper
::
<
A
,
_
>
::
create
(
&
mut
bump_allocator
&
mut
bump_allocator
...
@@ -86,6 +85,20 @@ unsafe fn inner<A: Arch>(areas: &'static [MemoryArea], bump_offset: usize) -> Bu
...
@@ -86,6 +85,20 @@ unsafe fn inner<A: Arch>(areas: &'static [MemoryArea], bump_offset: usize) -> Bu
}
}
}
}
//TODO: this is a hack to ensure kernel is mapped, even if it uses invalid memory. We need to
//properly utilize the firmware memory map and not assume 0x100000 and onwards is free
for
i
in
0
..
kernel_size_aligned
/
A
::
PAGE_SIZE
{
let
phys
=
PhysicalAddress
::
new
(
kernel_base
+
i
*
A
::
PAGE_SIZE
);
let
virt
=
A
::
phys_to_virt
(
phys
);
let
flags
=
page_flags
::
<
A
>
(
virt
);
let
flush
=
mapper
.map_phys
(
virt
,
phys
,
flags
)
.expect
(
"failed to map frame"
);
flush
.ignore
();
// Not the active table
}
//TODO: remove backwards compatible recursive mapping
//TODO: remove backwards compatible recursive mapping
mapper
.table
()
.set_entry
(
511
,
rmm
::
PageEntry
::
new
(
mapper
.table
()
.set_entry
(
511
,
rmm
::
PageEntry
::
new
(
mapper
.table
()
.phys
()
.data
()
|
A
::
ENTRY_FLAG_WRITABLE
|
A
::
ENTRY_FLAG_PRESENT
|
A
::
ENTRY_FLAG_NO_EXEC
mapper
.table
()
.phys
()
.data
()
|
A
::
ENTRY_FLAG_WRITABLE
|
A
::
ENTRY_FLAG_PRESENT
|
A
::
ENTRY_FLAG_NO_EXEC
...
@@ -216,13 +229,8 @@ pub unsafe fn init(kernel_base: usize, kernel_size: usize) {
...
@@ -216,13 +229,8 @@ pub unsafe fn init(kernel_base: usize, kernel_size: usize) {
area_i
+=
1
;
area_i
+=
1
;
}
}
//TODO: this is a hack to ensure kernel is mapped, even if it uses invalid memory. We need to
//properly utilize the firmware memory map and not assume 0x100000 and onwards is free
AREAS
[
area_i
]
.base
=
PhysicalAddress
::
new
(
kernel_base
);
AREAS
[
area_i
]
.size
=
kernel_size_aligned
;
println!
(
"bump_offset: {:X}"
,
bump_offset
);
println!
(
"bump_offset: {:X}"
,
bump_offset
);
let
allocator
=
inner
::
<
A
>
(
&
AREAS
,
bump_offset
);
let
allocator
=
inner
::
<
A
>
(
&
AREAS
,
kernel_base
,
kernel_size_aligned
,
bump_offset
);
*
FRAME_ALLOCATOR
.inner
.lock
()
=
Some
(
allocator
);
*
FRAME_ALLOCATOR
.inner
.lock
()
=
Some
(
allocator
);
}
}
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