diff options
| author | Tianhao Wang <wth@riseup.net> | 2024-02-05 14:04:25 +0100 |
|---|---|---|
| committer | Tianhao Wang <shrik3@mailbox.org> | 2024-06-11 15:13:38 +0200 |
| commit | 5e9190ff1a7d35e812b42c5bb9cbb742c2d313fb (patch) | |
| tree | 39fca5cda21500f51488193018a45f65c768d0ad /src/arch/x86_64 | |
| parent | 959d50d9117a0ed3f280bf7d5bfbffd1fa1a5740 (diff) | |
MM: add modules for memory management
Diffstat (limited to 'src/arch/x86_64')
| -rw-r--r-- | src/arch/x86_64/asm/e820.s | 2 | ||||
| -rw-r--r-- | src/arch/x86_64/linker.ld | 1 | ||||
| -rw-r--r-- | src/arch/x86_64/mem.rs | 16 | ||||
| -rw-r--r-- | src/arch/x86_64/mod.rs | 1 |
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; |
