-
Notifications
You must be signed in to change notification settings - Fork 3
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
Riscv64 mmu #35
Riscv64 mmu #35
Conversation
src/allocator/mod.rs
Outdated
// TODO: Find real value | ||
const PAGE_NUMBER: usize = 50; | ||
|
||
static mut PageUsage: [UsageFlags; PAGE_NUMBER] = [UsageFlags::Free; PAGE_NUMBER]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static mut PageUsage: [UsageFlags; PAGE_NUMBER] = [UsageFlags::Free; PAGE_NUMBER]; | |
static mut PAGE_USAGE: [UsageFlags; PAGE_NUMBER] = [UsageFlags::Free; PAGE_NUMBER]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will sed this
src/allocator/mod.rs
Outdated
let mut index = 0; | ||
|
||
// FIXME: Iterator | ||
while index < 50 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 50?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had problems with .bss and .data section. I've removed most of the statics and const to test if it will work. This will be fixed before going out of draft state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I hadn't even noticed it was a draft :D My bad!
src/allocator/mod.rs
Outdated
|
||
// FIXME: Iterator | ||
while index < 50 { | ||
unsafe { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put the unsafe block just around the "pointer arithmetics"? Or does rustc disagree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PageUsage[index]
is unsafe (static mut), line 26 is also unsafe. So I made a big unsafe block. But you're right it's better to see exactly where is the unsafe code in the most fine grained manner as possible. I will change this
src/allocator/mod.rs
Outdated
mod test { | ||
use super::*; | ||
use crate::utest::uassert_eq; | ||
#[test_case] | ||
fn page_alloc_test() { | ||
let test = page_alloc(); | ||
kassert_eq!(test.is_some(), true, "Page alloc test"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test for .is_none()
, when all pages are allocated, just so we're sure we don't introduce regressions on future updates of the MMU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test for .is_none(), when all pages are allocated
Yup makes sense.
future updates of the MMU
This is independent of the MMU, we are just managing the heap here, nothing more
@@ -45,7 +45,7 @@ pub fn runner(tests: &[&dyn Fn()]) { | |||
end_utests(); | |||
} | |||
|
|||
fn uassert_eq<T: PartialEq + core::fmt::Debug>(lhs: T, rhs: T, test_name: &str) { | |||
pub fn uassert_eq<T: PartialEq + core::fmt::Debug>(lhs: T, rhs: T, test_name: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to expose the function? There are macros available IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason macros doesn't work in I can't get access to this in src/allocator/mod.rs (see line 42). I will try to figure this out, but I just wanted to make something work x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to use
the macros at the beginning of the file
use crate::kassert_eq;
use crate::kassert;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get this error:
error[E0425]: cannot find function `uassert_eq` in this scope
--> src/utest/mod.rs:34:9
|
34 | uassert_eq($stmt, true, $name)
| ^^^^^^^^^^ not found in this scope
|
::: src/spin_lock/mod.rs:58:13
|
58 | kassert!(*data, 1);
| ------------------- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this function
|
44 | use crate::utest::uassert_eq;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh that's odd. I'm gonna take a look at it on your branch
I found the bug which blocked iterators and range. The stack was misaligned and rust was calling abort. And OpensSBI rebooted our kernel. We should override rust |
No description provided.