4 #include "types.h" // u32
7 extern struct zone_s ZoneLow, ZoneHigh, ZoneFSeg, ZoneTmpLow, ZoneTmpHigh;
9 u32 rom_get_last(void);
10 struct rom_header *rom_reserve(u32 size);
11 int rom_confirm(u32 size);
12 void csm_malloc_preinit(u32 low_pmm, u32 low_pmm_size, u32 hi_pmm,
14 void malloc_preinit(void);
15 extern u32 LegacyRamSize;
16 void malloc_init(void);
17 void malloc_prepboot(void);
18 void *_malloc(struct zone_s *zone, u32 size, u32 align);
19 int _free(void *data);
20 u32 malloc_getspace(struct zone_s *zone);
21 void malloc_sethandle(void *data, u32 handle);
22 void *malloc_findhandle(u32 handle);
24 #define MALLOC_DEFAULT_HANDLE 0xFFFFFFFF
25 // Minimum alignment of malloc'd memory
26 #define MALLOC_MIN_ALIGN 16
27 // Helper functions for memory allocation.
28 static inline void *malloc_low(u32 size) {
29 return _malloc(&ZoneLow, size, MALLOC_MIN_ALIGN);
31 static inline void *malloc_high(u32 size) {
32 return _malloc(&ZoneHigh, size, MALLOC_MIN_ALIGN);
34 static inline void *malloc_fseg(u32 size) {
35 return _malloc(&ZoneFSeg, size, MALLOC_MIN_ALIGN);
37 static inline void *malloc_tmplow(u32 size) {
38 return _malloc(&ZoneTmpLow, size, MALLOC_MIN_ALIGN);
40 static inline void *malloc_tmphigh(u32 size) {
41 return _malloc(&ZoneTmpHigh, size, MALLOC_MIN_ALIGN);
43 static inline void *malloc_tmp(u32 size) {
44 void *ret = malloc_tmphigh(size);
47 return malloc_tmplow(size);
49 static inline void *memalign_low(u32 align, u32 size) {
50 return _malloc(&ZoneLow, size, align);
52 static inline void *memalign_high(u32 align, u32 size) {
53 return _malloc(&ZoneHigh, size, align);
55 static inline void *memalign_tmplow(u32 align, u32 size) {
56 return _malloc(&ZoneTmpLow, size, align);
58 static inline void *memalign_tmphigh(u32 align, u32 size) {
59 return _malloc(&ZoneTmpHigh, size, align);
61 static inline void *memalign_tmp(u32 align, u32 size) {
62 void *ret = memalign_tmphigh(align, size);
65 return memalign_tmplow(align, size);
67 static inline void free(void *data) {