Skip to content

Commit

Permalink
Create memory module (#690)
Browse files Browse the repository at this point in the history
* Improve memory counting at boot

* Allow interrupts during heap init

* Load keyboard module after memory module

* Mask keyword interrupt instead of loading the module later

* Remove newline

* Create sys::mem module

* Refactor module

* Fix tests

* Add paging file in mem module

* Improve comment about keyboard interrupt masking

* Rename max_memory to heap_max
  • Loading branch information
vinc authored Oct 20, 2024
1 parent 7efec3c commit 92acc3e
Show file tree
Hide file tree
Showing 14 changed files with 400 additions and 360 deletions.
223 changes: 0 additions & 223 deletions src/sys/allocator.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/sys/fs/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl BlockDeviceIO for MemBlockDevice {
}

pub fn mount_mem() {
let mem = sys::allocator::memory_size() / 2; // Half the allocatable memory
let mem = sys::mem::memory_free() / 2;
let len = mem / super::BLOCK_SIZE; // TODO: take a size argument
let dev = MemBlockDevice::new(len);
*BLOCK_DEVICE.lock() = Some(BlockDevice::Mem(dev));
Expand Down
4 changes: 2 additions & 2 deletions src/sys/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extern "x86-interrupt" fn page_fault_handler(
};

if error_code.contains(PageFaultErrorCode::CAUSED_BY_WRITE) {
if sys::allocator::alloc_pages(&mut mapper, addr, 1).is_err() {
if sys::mem::alloc_pages(&mut mapper, addr, 1).is_err() {
printk!(
"{}Error:{} Could not allocate page at {:#X}\n",
csi_color, csi_reset, addr
Expand All @@ -154,7 +154,7 @@ extern "x86-interrupt" fn page_fault_handler(
// longer a simple clone of the kernel page table. Currently a process
// is executed from its kernel address that is shared with the process.
let start = (addr / 4096) * 4096;
if sys::allocator::alloc_pages(&mut mapper, start, 4096).is_ok() {
if sys::mem::alloc_pages(&mut mapper, start, 4096).is_ok() {
if sys::process::is_userspace(start) {
let code_addr = sys::process::code_addr();
let src = (code_addr + start) as *mut u8;
Expand Down
120 changes: 0 additions & 120 deletions src/sys/mem.rs

This file was deleted.

Loading

0 comments on commit 92acc3e

Please sign in to comment.