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 char name[XNOBJECT_NAME_LEN];
00046
00047 } RT_HEAP_INFO;
00048
00049 typedef struct rt_heap_placeholder {
00050
00051 xnhandle_t opaque;
00052
00053 void *opaque2;
00054
00055 caddr_t mapbase;
00056
00057 size_t mapsize;
00058
00059 } RT_HEAP_PLACEHOLDER;
00060
00061 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00062
00063 #define XENO_HEAP_MAGIC 0x55550808
00064
00065 typedef struct rt_heap {
00066
00067 unsigned magic;
00068
00069 xnsynch_t synch_base;
00070
00071 xnheap_t heap_base;
00072
00073 int mode;
00074
00075 size_t csize;
00076
00077 void *sba;
00078
00079 xnhandle_t handle;
00080
00081 char name[XNOBJECT_NAME_LEN];
00082
00083 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
00084 pid_t cpid;
00085 #endif
00086
00087 } RT_HEAP;
00088
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092
00093 int __native_heap_pkg_init(void);
00094
00095 void __native_heap_pkg_cleanup(void);
00096
00097 #ifdef __cplusplus
00098 }
00099 #endif
00100
00101 #else
00102
00103 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00104
00105 #ifdef __cplusplus
00106 extern "C" {
00107 #endif
00108
00109 int rt_heap_bind(RT_HEAP *heap,
00110 const char *name,
00111 RTIME timeout);
00112
00113 int rt_heap_unbind(RT_HEAP *heap);
00114
00115 #ifdef __cplusplus
00116 }
00117 #endif
00118
00119 #endif
00120
00121 #ifdef __cplusplus
00122 extern "C" {
00123 #endif
00124
00125
00126
00127 int rt_heap_create(RT_HEAP *heap,
00128 const char *name,
00129 size_t heapsize,
00130 int mode);
00131
00132 int rt_heap_delete(RT_HEAP *heap);
00133
00134 int rt_heap_alloc(RT_HEAP *heap,
00135 size_t size,
00136 RTIME timeout,
00137 void **blockp);
00138
00139 int rt_heap_free(RT_HEAP *heap,
00140 void *block);
00141
00142 int rt_heap_inquire(RT_HEAP *heap,
00143 RT_HEAP_INFO *info);
00144
00145 #ifdef __cplusplus
00146 }
00147 #endif
00148
00149 #endif