00001
00022 #ifndef _XENO_HEAP_H
00023 #define _XENO_HEAP_H
00024
00025 #include <nucleus/synch.h>
00026 #include <nucleus/heap.h>
00027 #include <native/types.h>
00028
00029
00030 #define H_PRIO XNSYNCH_PRIO
00031 #define H_FIFO XNSYNCH_FIFO
00032 #define H_DMA 0x100
00033 #define H_MAPPABLE 0x200
00034 #define H_SINGLE 0x400
00035 #define H_SHARED (H_MAPPABLE|H_SINGLE)
00036 #define H_NONCACHED 0x800
00037
00042 typedef struct rt_heap_info {
00043
00044 int nwaiters;
00045
00046 int mode;
00047
00048 size_t heapsize;
00049
00050 size_t usablemem;
00051
00052 size_t usedmem;
00053
00054 char name[XNOBJECT_NAME_LEN];
00055
00056 } RT_HEAP_INFO;
00057
00058 typedef struct rt_heap_placeholder {
00059
00060 xnhandle_t opaque;
00061
00062 void *opaque2;
00063
00064 caddr_t mapbase;
00065
00066 size_t mapsize;
00067
00068 } RT_HEAP_PLACEHOLDER;
00069
00070 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00071
00072 #include <native/ppd.h>
00073
00074 #define XENO_HEAP_MAGIC 0x55550808
00075
00076 typedef struct rt_heap {
00077
00078 unsigned magic;
00079
00080 xnsynch_t synch_base;
00081
00082 xnheap_t heap_base;
00083
00084 int mode;
00085
00086 size_t csize;
00087
00088 void *sba;
00089
00090 xnhandle_t handle;
00091
00092 char name[XNOBJECT_NAME_LEN];
00093
00094 #ifdef CONFIG_XENO_OPT_PERVASIVE
00095 pid_t cpid;
00096 #endif
00097
00098 xnholder_t rlink;
00099
00100 #define rlink2heap(ln) container_of(ln, RT_HEAP, rlink)
00101
00102 xnqueue_t *rqueue;
00103
00104 } RT_HEAP;
00105
00106 #ifdef __cplusplus
00107 extern "C" {
00108 #endif
00109
00110 #ifdef CONFIG_XENO_OPT_NATIVE_HEAP
00111
00112 int __native_heap_pkg_init(void);
00113
00114 void __native_heap_pkg_cleanup(void);
00115
00116 static inline void __native_heap_flush_rq(xnqueue_t *rq)
00117 {
00118 xeno_flush_rq_norelease(RT_HEAP, rq, heap);
00119 }
00120
00121 int rt_heap_delete_inner(RT_HEAP *heap,
00122 void __user *mapaddr);
00123
00124 #else
00125
00126 #define __native_heap_pkg_init() ({ 0; })
00127 #define __native_heap_pkg_cleanup() do { } while(0)
00128 #define __native_heap_flush_rq(rq) do { } while(0)
00129
00130 #endif
00131
00132 #ifdef __cplusplus
00133 }
00134 #endif
00135
00136 #else
00137
00138 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00139
00140 #ifdef __cplusplus
00141 extern "C" {
00142 #endif
00143
00144 int rt_heap_bind(RT_HEAP *heap,
00145 const char *name,
00146 RTIME timeout);
00147
00148 int rt_heap_unbind(RT_HEAP *heap);
00149
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153
00154 #endif
00155
00156 #ifdef __cplusplus
00157 extern "C" {
00158 #endif
00159
00160
00161
00162 int rt_heap_create(RT_HEAP *heap,
00163 const char *name,
00164 size_t heapsize,
00165 int mode);
00166
00167 int rt_heap_delete(RT_HEAP *heap);
00168
00169 int rt_heap_alloc(RT_HEAP *heap,
00170 size_t size,
00171 RTIME timeout,
00172 void **blockp);
00173
00174 int rt_heap_free(RT_HEAP *heap,
00175 void *block);
00176
00177 int rt_heap_inquire(RT_HEAP *heap,
00178 RT_HEAP_INFO *info);
00179
00180 #ifdef __cplusplus
00181 }
00182 #endif
00183
00184 #endif