aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2021-02-10 21:46:18 +0100
committerHelge Deller <deller@gmx.de>2021-09-24 11:10:17 +0200
commit036b64e8ab37d4a16cb23fee7f93f4f43ade06f1 (patch)
tree90d963344e107c0fd48fa49e470ff532baf06eeb
parentf79be5961e6233f2aa2e13df3335ca93d0126fc5 (diff)
downloadseabios-hppa-036b64e8ab37d4a16cb23fee7f93f4f43ade06f1.zip
seabios-hppa-036b64e8ab37d4a16cb23fee7f93f4f43ade06f1.tar.gz
seabios-hppa-036b64e8ab37d4a16cb23fee7f93f4f43ade06f1.tar.bz2
malloc.c: Implement a PA-RISC specific malloc()
On x86 mremap() is used to provide malloc'ed memory. This can't be used on PA-RISC, so provide an own malloc() implementation. Since PA-RISC is fully 32-/64-bit use "unsigned long" instead of "u32". Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--src/malloc.c4
-rw-r--r--src/malloc.h8
2 files changed, 8 insertions, 4 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 3733855..b840883 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -232,7 +232,7 @@ zonelow_expand(u32 size, u32 align, struct allocinfo_s *fill)
****************************************************************/
// Allocate physical memory from the given zone and track it as a PMM allocation
-u32
+unsigned long
malloc_palloc(struct zone_s *zone, u32 size, u32 align)
{
ASSERT32FLAT();
@@ -263,7 +263,7 @@ malloc_palloc(struct zone_s *zone, u32 size, u32 align)
// Allocate virtual memory from the given zone
void * __malloc
-_malloc(struct zone_s *zone, u32 size, u32 align)
+x86_malloc(struct zone_s *zone, u32 size, u32 align)
{
return memremap(malloc_palloc(zone, size, align), size);
}
diff --git a/src/malloc.h b/src/malloc.h
index 960a7f8..73962b4 100644
--- a/src/malloc.h
+++ b/src/malloc.h
@@ -1,6 +1,7 @@
#ifndef __MALLOC_H
#define __MALLOC_H
+#include "autoconf.h" // CONFIG_*
#include "types.h" // u32
// malloc.c
@@ -15,8 +16,11 @@ void malloc_preinit(void);
extern u32 LegacyRamSize;
void malloc_init(void);
void malloc_prepboot(void);
-u32 malloc_palloc(struct zone_s *zone, u32 size, u32 align);
-void *_malloc(struct zone_s *zone, u32 size, u32 align);
+unsigned long malloc_palloc(struct zone_s *zone, u32 size, u32 align);
+void *parisc_malloc(u32 size, u32 align);
+void *x86_malloc(struct zone_s *zone, u32 size, u32 align);
+#define _malloc(zone, size, align) \
+ (CONFIG_X86 ? x86_malloc(zone, size, align) : parisc_malloc(size, align))
int malloc_pfree(u32 data);
void free(void *data);
u32 malloc_getspace(struct zone_s *zone);