Skip to content

Commit

Permalink
refactor(x86_64): extract TOTAL_MEMORY access
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 17, 2024
1 parent 3a05b1b commit f9915cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/arch/x86_64/mm/physicalmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,27 @@ fn detect_from_limits() -> Result<(), ()> {
return Err(());
}

let total_memory;

// add gap for the APIC
if limit > KVM_32BIT_GAP_START {
let entry = FreeListEntry::new(mm::kernel_end_address().as_usize(), KVM_32BIT_GAP_START);
PHYSICAL_FREE_LIST.lock().push(entry);
if limit > KVM_32BIT_GAP_START + KVM_32BIT_GAP_SIZE {
let entry = FreeListEntry::new(KVM_32BIT_GAP_START + KVM_32BIT_GAP_SIZE, limit);
PHYSICAL_FREE_LIST.lock().push(entry);
TOTAL_MEMORY.store(limit - KVM_32BIT_GAP_SIZE, Ordering::Relaxed);
total_memory = limit - KVM_32BIT_GAP_SIZE;
} else {
TOTAL_MEMORY.store(KVM_32BIT_GAP_START, Ordering::Relaxed);
total_memory = KVM_32BIT_GAP_START;
}
} else {
let entry = FreeListEntry::new(mm::kernel_end_address().as_usize(), limit);
PHYSICAL_FREE_LIST.lock().push(entry);
TOTAL_MEMORY.store(limit, Ordering::Relaxed);
total_memory = limit;
}

TOTAL_MEMORY.store(total_memory, Ordering::Relaxed);

Ok(())
}

Expand Down

0 comments on commit f9915cc

Please sign in to comment.