mm/pmm: Use uint64_t instead of size_t for the size argument for ext_mem_alloc/pmm_free functions
diff --git a/common/drivers/vga_textmode.c b/common/drivers/vga_textmode.c
index 57e57e10..5fcafc30 100644
--- a/common/drivers/vga_textmode.c
+++ b/common/drivers/vga_textmode.c
@@ -355,7 +355,7 @@ void vga_textmode_init(bool managed) {
term->full_refresh(term);
if (!managed) {
- term->deinit(term, pmm_free);
+ term->deinit(term, pmm_free_size_t);
pmm_free(terms, sizeof(void *));
terms_i = 0;
terms = NULL;
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index ad260b33..f465d81c 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -763,8 +763,8 @@ no_load_font:;
fb->framebuffer_height = tmp;
}
- terms[terms_i] = flanterm_fb_init(ext_mem_alloc,
- pmm_free,
+ terms[terms_i] = flanterm_fb_init(ext_mem_alloc_size_t,
+ pmm_free_size_t,
(void *)(uintptr_t)fb->framebuffer_addr,
fb->framebuffer_width, fb->framebuffer_height, fb->framebuffer_pitch,
fb->red_mask_size, fb->red_mask_shift,
diff --git a/common/lib/term.c b/common/lib/term.c
index 1cadb3d1..106ecba4 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -22,7 +22,7 @@ void term_notready(void) {
for (size_t i = 0; i < terms_i; i++) {
struct flanterm_context *term = terms[i];
- term->deinit(term, pmm_free);
+ term->deinit(term, pmm_free_size_t);
}
pmm_free(terms, terms_i * sizeof(void *));
diff --git a/common/mm/pmm.h b/common/mm/pmm.h
index b8768647..27053e2a 100644
--- a/common/mm/pmm.h
+++ b/common/mm/pmm.h
@@ -55,15 +55,17 @@ bool memmap_alloc_range_in(struct memmap_entry *m, size_t *_count,
bool memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type, uint32_t overlay_type, bool panic, bool simulation, bool new_entry);
void pmm_randomise_memory(void);
-void *ext_mem_alloc(size_t count);
-void *ext_mem_alloc_type(size_t count, uint32_t type);
-void *ext_mem_alloc_type_aligned(size_t count, uint32_t type, size_t alignment);
-void *ext_mem_alloc_type_aligned_mode(size_t count, uint32_t type, size_t alignment, bool allow_high_allocs);
+void *ext_mem_alloc_size_t(size_t count);
+void *ext_mem_alloc(uint64_t count);
+void *ext_mem_alloc_type(uint64_t count, uint32_t type);
+void *ext_mem_alloc_type_aligned(uint64_t count, uint32_t type, size_t alignment);
+void *ext_mem_alloc_type_aligned_mode(uint64_t count, uint32_t type, size_t alignment, bool allow_high_allocs);
-void *conv_mem_alloc(size_t count);
+void *conv_mem_alloc(uint64_t count);
-void pmm_free(void *ptr, size_t length);
-void *pmm_realloc(void *old_ptr, size_t old_size, size_t new_size);
+void pmm_free_size_t(void *ptr, size_t length);
+void pmm_free(void *ptr, uint64_t length);
+void *pmm_realloc(void *old_ptr, uint64_t old_size, uint64_t new_size);
#if defined (UEFI)
void pmm_release_uefi_mem(void);
diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index 81a74212..aced997f 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -19,7 +19,7 @@ extern symbol bss_end;
bool allocations_disallowed = true;
-void *conv_mem_alloc(size_t count) {
+void *conv_mem_alloc(uint64_t count) {
static uint64_t base = 4096;
if (allocations_disallowed)
@@ -564,14 +564,18 @@ struct memmap_entry *get_raw_memmap(size_t *entry_count) {
}
#endif
-void pmm_free(void *ptr, size_t count) {
+void pmm_free_size_t(void *ptr, size_t length) {
+ pmm_free(ptr, length);
+}
+
+void pmm_free(void *ptr, uint64_t count) {
count = ALIGN_UP(count, 4096);
if (allocations_disallowed)
panic(false, "Memory allocations disallowed");
memmap_alloc_range((uintptr_t)ptr, count, MEMMAP_USABLE, 0, false, false, true);
}
-void *pmm_realloc(void *old_ptr, size_t old_size, size_t new_size) {
+void *pmm_realloc(void *old_ptr, uint64_t old_size, uint64_t new_size) {
if (new_size == 0) {
if (old_ptr != NULL) {
pmm_free(old_ptr, old_size);
@@ -591,20 +595,24 @@ void *pmm_realloc(void *old_ptr, size_t old_size, size_t new_size) {
return new_ptr;
}
-void *ext_mem_alloc(size_t count) {
+void *ext_mem_alloc_size_t(size_t count) {
+ return ext_mem_alloc(count);
+}
+
+void *ext_mem_alloc(uint64_t count) {
return ext_mem_alloc_type(count, MEMMAP_BOOTLOADER_RECLAIMABLE);
}
-void *ext_mem_alloc_type(size_t count, uint32_t type) {
+void *ext_mem_alloc_type(uint64_t count, uint32_t type) {
return ext_mem_alloc_type_aligned(count, type, 4096);
}
-void *ext_mem_alloc_type_aligned(size_t count, uint32_t type, size_t alignment) {
+void *ext_mem_alloc_type_aligned(uint64_t count, uint32_t type, size_t alignment) {
return ext_mem_alloc_type_aligned_mode(count, type, alignment, false);
}
// Allocate memory top down.
-void *ext_mem_alloc_type_aligned_mode(size_t count, uint32_t type, size_t alignment, bool allow_high_allocs) {
+void *ext_mem_alloc_type_aligned_mode(uint64_t count, uint32_t type, size_t alignment, bool allow_high_allocs) {
#if !defined (__x86_64__) && !defined (__i386__)
(void)allow_high_allocs;
#endif
