These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / seabios / src / malloc.h
1 #ifndef __MALLOC_H
2 #define __MALLOC_H
3
4 #include "types.h" // u32
5
6 // malloc.c
7 extern struct zone_s ZoneLow, ZoneHigh, ZoneFSeg, ZoneTmpLow, ZoneTmpHigh;
8 u32 rom_get_max(void);
9 u32 rom_get_last(void);
10 struct rom_header *rom_reserve(u32 size);
11 int rom_confirm(u32 size);
12 void malloc_csm_preinit(u32 low_pmm, u32 low_pmm_size, u32 hi_pmm,
13                         u32 hi_pmm_size);
14 void malloc_preinit(void);
15 extern u32 LegacyRamSize;
16 void malloc_init(void);
17 void malloc_prepboot(void);
18 u32 malloc_palloc(struct zone_s *zone, u32 size, u32 align);
19 void *_malloc(struct zone_s *zone, u32 size, u32 align);
20 int malloc_pfree(u32 data);
21 void free(void *data);
22 u32 malloc_getspace(struct zone_s *zone);
23 void malloc_sethandle(u32 data, u32 handle);
24 u32 malloc_findhandle(u32 handle);
25
26 #define MALLOC_DEFAULT_HANDLE 0xFFFFFFFF
27 // Minimum alignment of malloc'd memory
28 #define MALLOC_MIN_ALIGN 16
29 // Helper functions for memory allocation.
30 static inline void *malloc_low(u32 size) {
31     return _malloc(&ZoneLow, size, MALLOC_MIN_ALIGN);
32 }
33 static inline void *malloc_high(u32 size) {
34     return _malloc(&ZoneHigh, size, MALLOC_MIN_ALIGN);
35 }
36 static inline void *malloc_fseg(u32 size) {
37     return _malloc(&ZoneFSeg, size, MALLOC_MIN_ALIGN);
38 }
39 static inline void *malloc_tmplow(u32 size) {
40     return _malloc(&ZoneTmpLow, size, MALLOC_MIN_ALIGN);
41 }
42 static inline void *malloc_tmphigh(u32 size) {
43     return _malloc(&ZoneTmpHigh, size, MALLOC_MIN_ALIGN);
44 }
45 static inline void *malloc_tmp(u32 size) {
46     void *ret = malloc_tmphigh(size);
47     if (ret)
48         return ret;
49     return malloc_tmplow(size);
50 }
51 static inline void *memalign_low(u32 align, u32 size) {
52     return _malloc(&ZoneLow, size, align);
53 }
54 static inline void *memalign_high(u32 align, u32 size) {
55     return _malloc(&ZoneHigh, size, align);
56 }
57 static inline void *memalign_tmplow(u32 align, u32 size) {
58     return _malloc(&ZoneTmpLow, size, align);
59 }
60 static inline void *memalign_tmphigh(u32 align, u32 size) {
61     return _malloc(&ZoneTmpHigh, size, align);
62 }
63 static inline void *memalign_tmp(u32 align, u32 size) {
64     void *ret = memalign_tmphigh(align, size);
65     if (ret)
66         return ret;
67     return memalign_tmplow(align, size);
68 }
69
70 #endif // malloc.h