diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index acaaf1b1..8ebe0b98 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -15,9 +15,9 @@ extern const u8 end_of_kernel_rodata[1]; extern const u8 start_of_kernel_data[1]; extern const u8 end_of_kernel_data[1]; -static u64 free_mem = 0; -static u64 used_mem = 0; -static u64 reserved_mem = 0; +static usize free_mem = 0; +static usize used_mem = 0; +static usize reserved_mem = 0; static u64 start_index = 0; @@ -38,12 +38,12 @@ namespace MemoryManager { Result protect_kernel_sections() { - const u64 rodata_size = (u64)(end_of_kernel_rodata - start_of_kernel_rodata); - const u64 rodata_pages = get_blocks_from_size(rodata_size, ARCH_PAGE_SIZE); + const usize rodata_size = (usize)(end_of_kernel_rodata - start_of_kernel_rodata); + const usize rodata_pages = get_blocks_from_size(rodata_size, ARCH_PAGE_SIZE); TRY(remap((u64)start_of_kernel_rodata, rodata_pages, MMU::NoExecute)); - const u64 data_size = (u64)(end_of_kernel_data - start_of_kernel_data); - const u64 data_pages = get_blocks_from_size(data_size, ARCH_PAGE_SIZE); + const usize data_size = (usize)(end_of_kernel_data - start_of_kernel_data); + const usize data_pages = get_blocks_from_size(data_size, ARCH_PAGE_SIZE); TRY(remap((u64)start_of_kernel_data, data_pages, MMU::NoExecute | MMU::ReadWrite)); return {}; @@ -81,7 +81,7 @@ namespace MemoryManager while (iter.next().try_set_value(entry)) { const u64 index = entry.address() / ARCH_PAGE_SIZE; - const u64 pages = entry.size() / ARCH_PAGE_SIZE; + const usize pages = entry.size() / ARCH_PAGE_SIZE; if (!entry.is_free()) { reserved_mem += entry.size(); } else { @@ -110,9 +110,9 @@ namespace MemoryManager free_mem -= ARCH_PAGE_SIZE; } - void lock_frames(u64 frames, u64 count) + void lock_frames(u64 frames, usize count) { - for (u64 index = 0; index < count; index++) { lock_frame(frames + (index * ARCH_PAGE_SIZE)); } + for (usize index = 0; index < count; index++) { lock_frame(frames + (index * ARCH_PAGE_SIZE)); } } Result alloc_frame() @@ -242,22 +242,22 @@ namespace MemoryManager return false; } - u64 free() + usize free() { return free_mem; } - u64 used() + usize used() { return used_mem; } - u64 reserved() + usize reserved() { return reserved_mem; } - u64 total() + usize total() { return free_mem + used_mem + reserved_mem; } diff --git a/kernel/src/memory/MemoryManager.h b/kernel/src/memory/MemoryManager.h index 8179e12e..5ef62177 100644 --- a/kernel/src/memory/MemoryManager.h +++ b/kernel/src/memory/MemoryManager.h @@ -12,7 +12,7 @@ namespace MemoryManager Result free_frame(u64 frame); void lock_frame(u64 frame); - void lock_frames(u64 frames, u64 count); + void lock_frames(u64 frames, usize count); Result remap(u64 address, usize count, int flags); Result remap_unaligned(u64 address, usize count, int flags); @@ -27,8 +27,8 @@ namespace MemoryManager Result unmap_owned(u64 virt, usize count); Result unmap_weak(u64 virt, usize count); - u64 free(); - u64 used(); - u64 reserved(); - u64 total(); + usize free(); + usize used(); + usize reserved(); + usize total(); } \ No newline at end of file diff --git a/kernel/src/memory/MemoryMap.cpp b/kernel/src/memory/MemoryMap.cpp index 9573a7d7..4aa24521 100644 --- a/kernel/src/memory/MemoryMap.cpp +++ b/kernel/src/memory/MemoryMap.cpp @@ -2,7 +2,7 @@ extern const BOOTBOOT bootboot; -MemoryMapEntry::MemoryMapEntry(u64 address, u64 size, bool is_free) +MemoryMapEntry::MemoryMapEntry(u64 address, usize size, bool is_free) : m_address(address), m_size(size), m_is_free(is_free) { } diff --git a/kernel/src/memory/MemoryMap.h b/kernel/src/memory/MemoryMap.h index 05b30b8d..4c53bde4 100644 --- a/kernel/src/memory/MemoryMap.h +++ b/kernel/src/memory/MemoryMap.h @@ -7,7 +7,7 @@ struct MemoryMapEntry { MemoryMapEntry() = default; MemoryMapEntry(const MemoryMapEntry& other) = default; - MemoryMapEntry(u64 address, u64 size, bool is_free); + MemoryMapEntry(u64 address, usize size, bool is_free); u64 address() const { @@ -19,7 +19,7 @@ struct MemoryMapEntry return (void*)m_address; } - u64 size() const + usize size() const { return m_size; } @@ -33,7 +33,7 @@ struct MemoryMapEntry private: u64 m_address; - u64 m_size; + usize m_size; bool m_is_free; };