00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __sys_mm_h__
00027 #define __sys_mm_h__
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #include <config.h>
00034
00035 #ifdef CONF_MM
00036
00037 #include <mem.h>
00038 #include <stdlib.h>
00039
00040
00042
00043
00044
00046
00047 #define MM_FREE 0x0000
00048 #define MM_RESERVED 0xffff
00049
00050
00051
00052
00053 #define MM_HEADER_SIZE 2
00054 #define MM_SPLIT_THRESH (MM_HEADER_SIZE+8)
00055
00056 extern size_t mm_start;
00057
00058 extern size_t* mm_first_free;
00059
00060
00061
00062
00063
00065
00068 #define MM_BLOCK_FREE(addr) \
00069 next=(size_t*)(addr); \
00070 *current=((((size_t)next)-(size_t)current)-2)>>1; \
00071 *(next++)=MM_FREE; \
00072 current=next;
00073
00074
00076
00079 #define MM_BLOCK_RESERVED(addr) \
00080 next=(size_t*)(((size_t)addr)-4); \
00081 *current=((((size_t)next)-(size_t)current)-2)>>1; \
00082 *(next++)=MM_RESERVED; \
00083 current=next;
00084
00085
00087
00088
00089
00091
00093 extern void mm_init();
00094
00096 extern void mm_reaper();
00097
00099 extern int mm_free_mem(void);
00100
00101 #endif // CONF_MM
00102
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106
00107 #endif // __sys_mm_h__