From f9915cc01a05748f5cc5b6d0c453ea9c00dddb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 17 Apr 2024 12:44:53 +0200 Subject: [PATCH] refactor(x86_64): extract `TOTAL_MEMORY` access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/x86_64/mm/physicalmem.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/arch/x86_64/mm/physicalmem.rs b/src/arch/x86_64/mm/physicalmem.rs index b9a61312be..01e80a64e8 100644 --- a/src/arch/x86_64/mm/physicalmem.rs +++ b/src/arch/x86_64/mm/physicalmem.rs @@ -108,6 +108,8 @@ 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); @@ -115,16 +117,18 @@ fn detect_from_limits() -> Result<(), ()> { 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(()) }