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 unsigned long phys_addr;
00057
00058 } RT_HEAP_INFO;
00059
00060 typedef struct rt_heap_placeholder {
00061
00062 xnhandle_t opaque;
00063
00064 void *opaque2;
00065
00066 caddr_t mapbase;
00067
00068 size_t mapsize;
00069
00070 } RT_HEAP_PLACEHOLDER;
00071
00072 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00073
00074 #include <native/ppd.h>
00075
00076 #define XENO_HEAP_MAGIC 0x55550808
00077
00078 typedef struct rt_heap {
00079
00080 unsigned magic;
00081
00082 xnsynch_t synch_base;
00083
00084 xnheap_t heap_base;
00085
00086 int mode;
00087
00088 size_t csize;
00089
00090 void *sba;
00091
00092 xnhandle_t handle;
00093
00094 char name[XNOBJECT_NAME_LEN];
00095
00096 #ifdef CONFIG_XENO_OPT_PERVASIVE
00097 pid_t cpid;
00098 #endif
00099
00100 xnholder_t rlink;
00101
00102 #define rlink2heap(ln) container_of(ln, RT_HEAP, rlink)
00103
00104 xnqueue_t *rqueue;
00105
00106 } RT_HEAP;
00107
00108 #ifdef __cplusplus
00109 extern "C" {
00110 #endif
00111
00112 #ifdef CONFIG_XENO_OPT_NATIVE_HEAP
00113
00114 int __native_heap_pkg_init(void);
00115
00116 void __native_heap_pkg_cleanup(void);
00117
00118 static inline void __native_heap_flush_rq(xnqueue_t *rq)
00119 {
00120 xeno_flush_rq_norelease(RT_HEAP, rq, heap);
00121 }
00122
00123 int rt_heap_delete_inner(RT_HEAP *heap,
00124 void __user *mapaddr);
00125
00126 #else
00127
00128 #define __native_heap_pkg_init() ({ 0; })
00129 #define __native_heap_pkg_cleanup() do { } while(0)
00130 #define __native_heap_flush_rq(rq) do { } while(0)
00131
00132 #endif
00133
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137
00138 #else
00139
00140 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00141
00142 #ifdef __cplusplus
00143 extern "C" {
00144 #endif
00145
00146 int rt_heap_bind(RT_HEAP *heap,
00147 const char *name,
00148 RTIME timeout);
00149
00150 int rt_heap_unbind(RT_HEAP *heap);
00151
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155
00156 #endif
00157
00158 #ifdef __cplusplus
00159 extern "C" {
00160 #endif
00161
00162
00163
00164 int rt_heap_create(RT_HEAP *heap,
00165 const char *name,
00166 size_t heapsize,
00167 int mode);
00168
00169 int rt_heap_delete(RT_HEAP *heap);
00170
00171 int rt_heap_alloc(RT_HEAP *heap,
00172 size_t size,
00173 RTIME timeout,
00174 void **blockp);
00175
00176 int rt_heap_free(RT_HEAP *heap,
00177 void *block);
00178
00179 int rt_heap_inquire(RT_HEAP *heap,
00180 RT_HEAP_INFO *info);
00181
00182 #ifdef __cplusplus
00183 }
00184 #endif
00185
00186 #endif