Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: kernel virtmem cont #189

Merged
merged 42 commits into from
Dec 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
208e3b0
fix(wavltree): return tree lifetimes from `Cursor`
JonasKruckenberg Dec 18, 2024
c1e2e78
feat(loader): report stacks & TLS region and online hart mask
JonasKruckenberg Dec 18, 2024
f3baa84
wip
JonasKruckenberg Dec 18, 2024
00d08e2
Merge branch 'main' into jonas/feat/kernel-virtmem
JonasKruckenberg Dec 18, 2024
0f7372e
fmt & clippy
JonasKruckenberg Dec 18, 2024
2b5a77b
Update aspace.rs
JonasKruckenberg Dec 18, 2024
e1685b6
refactor: properly setup address space range constants
JonasKruckenberg Dec 19, 2024
ac64c0f
fix tests
JonasKruckenberg Dec 19, 2024
a254b3f
fmt
JonasKruckenberg Dec 19, 2024
e83c1ca
fix: fix tests by identity mapping RTC driver
JonasKruckenberg Dec 19, 2024
5d4c116
fmt
JonasKruckenberg Dec 19, 2024
5fb8160
wip
JonasKruckenberg Dec 19, 2024
1768a22
refactor: rename `pmm` to `mmu`
JonasKruckenberg Dec 19, 2024
04c2a8f
refactor(loader): report physical address offset and physical memory …
JonasKruckenberg Dec 22, 2024
d7b3564
fix(mmu): report error if Flush is dropped with unflushed changes
JonasKruckenberg Dec 22, 2024
c299420
wip
JonasKruckenberg Dec 22, 2024
e6417ea
refactor(mmu): allow any `FramesIterator` implementation
JonasKruckenberg Dec 22, 2024
f7d4abc
fix(dtb-parser): implement `Iterator` for `Strings`
JonasKruckenberg Dec 22, 2024
7fcd97b
refactor: don't explicitly map RTC device
JonasKruckenberg Dec 22, 2024
f7d2deb
chore(mmu): better printing of addresses
JonasKruckenberg Dec 22, 2024
55cbfe1
fix(wavltree): return `Pin<&mut T>` from `insert`
JonasKruckenberg Dec 22, 2024
d91e4da
fix(mmu): correct pretty printing of addresses
JonasKruckenberg Dec 25, 2024
ab95d6e
wip
JonasKruckenberg Dec 25, 2024
dfe403b
fmt & fixes
JonasKruckenberg Dec 26, 2024
5c2feec
fix: expand initial heap for elf processing
JonasKruckenberg Dec 26, 2024
d3ca827
fix startup
JonasKruckenberg Dec 26, 2024
a21a111
fix: print stack trace on panic
JonasKruckenberg Dec 26, 2024
e4c6580
feat: support short backtrace
JonasKruckenberg Dec 26, 2024
119d3bf
fix tests
JonasKruckenberg Dec 26, 2024
240e2af
don't panic in drop
JonasKruckenberg Dec 26, 2024
86a216b
fix(kernel/vm): don't panic when virt allocation range is empty
JonasKruckenberg Dec 26, 2024
e8e2ece
fmt
JonasKruckenberg Dec 26, 2024
188ea02
fix(loader): prevent frame allocator from handing out loader memory
JonasKruckenberg Dec 28, 2024
b66b360
test: add tests for `mmu` crate
JonasKruckenberg Dec 28, 2024
22d9609
fix: better address arithmetic
JonasKruckenberg Dec 28, 2024
ca9f574
fix(mmu): correct `align_down` implementation
JonasKruckenberg Dec 28, 2024
2f999ab
tests(mmu): fix tests
JonasKruckenberg Dec 28, 2024
13c85c3
fix(kernel/vm): return gap size zero instead of panic
JonasKruckenberg Dec 28, 2024
485e14b
Merge branch 'main' into jonas/feat/kernel-virtmem
JonasKruckenberg Dec 29, 2024
f53a165
enable debug assertions in release mode
JonasKruckenberg Dec 29, 2024
3d13f23
fix: increase QEMU physical memory for tests
JonasKruckenberg Dec 29, 2024
3a0c09d
clippy & fmt
JonasKruckenberg Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
JonasKruckenberg committed Dec 22, 2024
commit c299420e48f73a88c7123a33fe2a0b5744902406
24 changes: 24 additions & 0 deletions libs/mmu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ mod error;
mod flush;
pub mod frame_alloc;

use core::alloc::{Layout, LayoutError};
use core::fmt;
use core::fmt::Formatter;
use core::ops::Range;

pub use address_space::AddressSpace;
Expand All @@ -29,6 +31,12 @@ bitflags::bitflags! {
}
}

impl fmt::Display for Flags {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
bitflags::parser::to_writer(self, f)
}
}

#[repr(transparent)]
#[derive(Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct VirtualAddress(usize);
Expand Down Expand Up @@ -236,6 +244,8 @@ pub trait AddressRangeExt {
fn align_in(self, align: usize) -> Self;
#[must_use]
fn align_out(self, align: usize) -> Self;
fn align(&self) -> usize;
fn into_layout(self) -> core::result::Result<Layout, LayoutError>;
fn is_user_accessible(&self) -> bool;
}

Expand All @@ -258,6 +268,13 @@ impl AddressRangeExt for Range<PhysicalAddress> {
fn align_out(self, align: usize) -> Self {
self.start.align_down(align)..self.end.align_up(align)
}
// TODO test
fn align(&self) -> usize {
self.start.as_raw() & (!self.start.as_raw() + 1)
}
fn into_layout(self) -> core::result::Result<Layout, LayoutError> {
Layout::from_size_align(self.size(), self.align())
}
fn is_user_accessible(&self) -> bool {
unimplemented!("PhysicalAddress is never user accessible")
}
Expand All @@ -282,6 +299,13 @@ impl AddressRangeExt for Range<VirtualAddress> {
fn align_out(self, align: usize) -> Self {
self.start.align_down(align)..self.end.align_up(align)
}
// TODO test
fn align(&self) -> usize {
self.start.as_raw() & (!self.start.as_raw() + 1)
}
fn into_layout(self) -> core::result::Result<Layout, LayoutError> {
Layout::from_size_align(self.size(), self.align())
}
fn is_user_accessible(&self) -> bool {
if self.is_empty() {
return false;
Expand Down