aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86_64/asm/e820.s2
-rw-r--r--src/arch/x86_64/linker.ld1
-rw-r--r--src/arch/x86_64/mem.rs16
-rw-r--r--src/arch/x86_64/mod.rs1
4 files changed, 20 insertions, 0 deletions
diff --git a/src/arch/x86_64/asm/e820.s b/src/arch/x86_64/asm/e820.s
new file mode 100644
index 0000000..59c672a
--- /dev/null
+++ b/src/arch/x86_64/asm/e820.s
@@ -0,0 +1,2 @@
+; getting an E820 memory map, code from osdev wiki.
+; this only works in real mode ... how to do it in long mode?
diff --git a/src/arch/x86_64/linker.ld b/src/arch/x86_64/linker.ld
index 7a03770..ae77deb 100644
--- a/src/arch/x86_64/linker.ld
+++ b/src/arch/x86_64/linker.ld
@@ -71,4 +71,5 @@ SECTIONS
*(".debug_aranges")
}
*/
+ PROVIDE (KERNEL_END = .);
}
diff --git a/src/arch/x86_64/mem.rs b/src/arch/x86_64/mem.rs
new file mode 100644
index 0000000..52ccdec
--- /dev/null
+++ b/src/arch/x86_64/mem.rs
@@ -0,0 +1,16 @@
+// to detect available memory to initialize PMA
+// https://wiki.osdev.org/Detecting_Memory_(x86)
+use core::arch::asm;
+use crate::io::*;
+
+extern "C" {
+ fn do_e820(start: usize) -> u32;
+}
+
+// Getting an E820 Memory Map -- osdev wiki
+pub fn prob_mem_bios(){
+ unsafe {
+ let res = do_e820(0x8000);
+ println!("res is {}", res)
+ }
+}
diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs
index 9429c8f..c3b226e 100644
--- a/src/arch/x86_64/mod.rs
+++ b/src/arch/x86_64/mod.rs
@@ -2,3 +2,4 @@ pub mod cpu;
pub mod interrupt;
pub mod io_port;
pub mod misc;
+pub mod mem;