aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTianhao Wang <wth@riseup.net>2024-02-25 04:55:09 +0100
committerTianhao Wang <shrik3@mailbox.org>2024-06-11 15:13:38 +0200
commitdbefd9336cc808e76f8e9d8d238f5a348d14604a (patch)
treec373589d1492141da6caa1c0668f8cd3eeddac80 /src
parent9f7d1bf474ac3e3b1c658bf2167afbf056e99c58 (diff)
add mm and ds modules (yet empty)
Diffstat (limited to 'src')
-rw-r--r--src/ds/bitmap.rs0
-rw-r--r--src/ds/mod.rs2
-rw-r--r--src/ds/queue.rs0
-rw-r--r--src/lib.rs6
-rw-r--r--src/mm/heap_allocator.rs2
-rw-r--r--src/mm/mod.rs1
-rw-r--r--src/mm/pma.rs28
7 files changed, 33 insertions, 6 deletions
diff --git a/src/ds/bitmap.rs b/src/ds/bitmap.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/ds/bitmap.rs
diff --git a/src/ds/mod.rs b/src/ds/mod.rs
new file mode 100644
index 0000000..7cfb300
--- /dev/null
+++ b/src/ds/mod.rs
@@ -0,0 +1,2 @@
+pub mod bitmap;
+pub mod queue;
diff --git a/src/ds/queue.rs b/src/ds/queue.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/ds/queue.rs
diff --git a/src/lib.rs b/src/lib.rs
index b66afb5..d982d51 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,9 +3,11 @@
#![no_std]
#![no_main]
mod arch;
+mod defs;
+mod ds;
mod io;
mod machine;
-mod defs;
+mod mm;
use arch::x86_64::interrupt::pic_8259;
use arch::x86_64::interrupt::pic_8259::PicDeviceInt;
use core::panic::PanicInfo;
@@ -28,8 +30,6 @@ pub extern "C" fn _entry() -> ! {
println!(" (,-.`._,'( |\\`-/|");
println!(" `-.-' \\ )-`( , o o)");
println!(" `- \\`_`\"'-");
- println!("it works!");
-
// testing interrupt/PIC
// pic_8259::allow(PicDeviceInt::KEYBOARD);
// interrupt::interrupt_enable();
diff --git a/src/mm/heap_allocator.rs b/src/mm/heap_allocator.rs
new file mode 100644
index 0000000..5a7463d
--- /dev/null
+++ b/src/mm/heap_allocator.rs
@@ -0,0 +1,2 @@
+#![feature(global_allocator, allocator_api, heap_api)]
+struct HeapAllocator;
diff --git a/src/mm/mod.rs b/src/mm/mod.rs
index 1298d0d..b030dfb 100644
--- a/src/mm/mod.rs
+++ b/src/mm/mod.rs
@@ -1 +1,2 @@
+pub mod heap_allocator;
pub mod pma;
diff --git a/src/mm/pma.rs b/src/mm/pma.rs
index f9a40ee..aa5e193 100644
--- a/src/mm/pma.rs
+++ b/src/mm/pma.rs
@@ -1,9 +1,31 @@
-use core::ffi::c_void;
use crate::defs::Mem;
+use core::ffi::c_void;
+use core::{ptr, slice};
// this is POC code, it will be ugly
+
extern "C" {
- static KERNEL_END: *const c_void;
+ pub fn ___KERNEL_END__();
+}
+/// Bitmap for physical frames. to get around the chicken-egg problem, we provide a provisional
+/// bitmap of fixed length in the startup code.
+pub struct PFMap {
+ bm: &'static mut [u8],
+ skip: usize, // pfn to skip (because they are already used by the initial kernel image)
+ end: usize, // pfn limit
}
-// pub struct PageAlloctor;
+// TODO PMA initialization : needs to singleton
+
+impl PFMap {}
+pub struct Frame {
+ pfn: usize,
+}
+
+impl Frame {
+ pub fn addr(&self) -> usize {
+ self.pfn << Mem::PAGE_SHIFT
+ }
+}
+
+// pub struct PageAlloctor;