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