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