Convert uses of u64 to usize
Not all of them, but if you're measuring a size it's more appropriate to use usize than u64.
This commit is contained in:
parent
8598b1e8fc
commit
1ebd892c16
@ -15,9 +15,9 @@ extern const u8 end_of_kernel_rodata[1];
|
|||||||
extern const u8 start_of_kernel_data[1];
|
extern const u8 start_of_kernel_data[1];
|
||||||
extern const u8 end_of_kernel_data[1];
|
extern const u8 end_of_kernel_data[1];
|
||||||
|
|
||||||
static u64 free_mem = 0;
|
static usize free_mem = 0;
|
||||||
static u64 used_mem = 0;
|
static usize used_mem = 0;
|
||||||
static u64 reserved_mem = 0;
|
static usize reserved_mem = 0;
|
||||||
|
|
||||||
static u64 start_index = 0;
|
static u64 start_index = 0;
|
||||||
|
|
||||||
@ -38,12 +38,12 @@ namespace MemoryManager
|
|||||||
{
|
{
|
||||||
Result<void> protect_kernel_sections()
|
Result<void> protect_kernel_sections()
|
||||||
{
|
{
|
||||||
const u64 rodata_size = (u64)(end_of_kernel_rodata - start_of_kernel_rodata);
|
const usize rodata_size = (usize)(end_of_kernel_rodata - start_of_kernel_rodata);
|
||||||
const u64 rodata_pages = get_blocks_from_size(rodata_size, ARCH_PAGE_SIZE);
|
const usize rodata_pages = get_blocks_from_size(rodata_size, ARCH_PAGE_SIZE);
|
||||||
TRY(remap((u64)start_of_kernel_rodata, rodata_pages, MMU::NoExecute));
|
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 usize data_size = (usize)(end_of_kernel_data - start_of_kernel_data);
|
||||||
const u64 data_pages = get_blocks_from_size(data_size, ARCH_PAGE_SIZE);
|
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));
|
TRY(remap((u64)start_of_kernel_data, data_pages, MMU::NoExecute | MMU::ReadWrite));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -81,7 +81,7 @@ namespace MemoryManager
|
|||||||
while (iter.next().try_set_value(entry))
|
while (iter.next().try_set_value(entry))
|
||||||
{
|
{
|
||||||
const u64 index = entry.address() / ARCH_PAGE_SIZE;
|
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(); }
|
if (!entry.is_free()) { reserved_mem += entry.size(); }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,9 +110,9 @@ namespace MemoryManager
|
|||||||
free_mem -= ARCH_PAGE_SIZE;
|
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<u64> alloc_frame()
|
Result<u64> alloc_frame()
|
||||||
@ -242,22 +242,22 @@ namespace MemoryManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 free()
|
usize free()
|
||||||
{
|
{
|
||||||
return free_mem;
|
return free_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 used()
|
usize used()
|
||||||
{
|
{
|
||||||
return used_mem;
|
return used_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 reserved()
|
usize reserved()
|
||||||
{
|
{
|
||||||
return reserved_mem;
|
return reserved_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 total()
|
usize total()
|
||||||
{
|
{
|
||||||
return free_mem + used_mem + reserved_mem;
|
return free_mem + used_mem + reserved_mem;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace MemoryManager
|
|||||||
Result<void> free_frame(u64 frame);
|
Result<void> free_frame(u64 frame);
|
||||||
|
|
||||||
void lock_frame(u64 frame);
|
void lock_frame(u64 frame);
|
||||||
void lock_frames(u64 frames, u64 count);
|
void lock_frames(u64 frames, usize count);
|
||||||
|
|
||||||
Result<void> remap(u64 address, usize count, int flags);
|
Result<void> remap(u64 address, usize count, int flags);
|
||||||
Result<void> remap_unaligned(u64 address, usize count, int flags);
|
Result<void> remap_unaligned(u64 address, usize count, int flags);
|
||||||
@ -27,8 +27,8 @@ namespace MemoryManager
|
|||||||
Result<void> unmap_owned(u64 virt, usize count);
|
Result<void> unmap_owned(u64 virt, usize count);
|
||||||
Result<void> unmap_weak(u64 virt, usize count);
|
Result<void> unmap_weak(u64 virt, usize count);
|
||||||
|
|
||||||
u64 free();
|
usize free();
|
||||||
u64 used();
|
usize used();
|
||||||
u64 reserved();
|
usize reserved();
|
||||||
u64 total();
|
usize total();
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
extern const BOOTBOOT bootboot;
|
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)
|
: m_address(address), m_size(size), m_is_free(is_free)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ struct MemoryMapEntry
|
|||||||
{
|
{
|
||||||
MemoryMapEntry() = default;
|
MemoryMapEntry() = default;
|
||||||
MemoryMapEntry(const MemoryMapEntry& other) = 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
|
u64 address() const
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ struct MemoryMapEntry
|
|||||||
return (void*)m_address;
|
return (void*)m_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 size() const
|
usize size() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ struct MemoryMapEntry
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
u64 m_address;
|
u64 m_address;
|
||||||
u64 m_size;
|
usize m_size;
|
||||||
bool m_is_free;
|
bool m_is_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user