00001
00022 #ifndef _RTAI_HEAP_H
00023 #define _RTAI_HEAP_H
00024
00025 #include <nucleus/synch.h>
00026 #include <nucleus/heap.h>
00027 #include <rtai/types.h>
00028
00029
00030 #define H_PRIO XNSYNCH_PRIO
00031 #define H_FIFO XNSYNCH_FIFO
00032 #define H_DMA 0x100
00033 #define H_SHARED 0x200
00034
00035 typedef struct rt_heap_info {
00036
00037 int nwaiters;
00038
00039 int mode;
00040
00041 size_t heapsize;
00042
00043 char name[XNOBJECT_NAME_LEN];
00044
00045 } RT_HEAP_INFO;
00046
00047 typedef struct rt_heap_placeholder {
00048
00049 rt_handle_t opaque;
00050
00051 void *opaque2;
00052
00053 caddr_t mapbase;
00054
00055 size_t mapsize;
00056
00057 } RT_HEAP_PLACEHOLDER;
00058
00059 #if defined(__KERNEL__) || defined(__RTAI_SIM__)
00060
00061 #define RTAI_HEAP_MAGIC 0x55550808
00062
00063 typedef struct rt_heap {
00064
00065 unsigned magic;
00066
00067 xnsynch_t synch_base;
00068
00069 xnheap_t heap_base;
00070
00071 int mode;
00072
00073 void *shm_block;
00074
00075 rt_handle_t handle;
00076
00077 char name[XNOBJECT_NAME_LEN];
00078
00079 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00080 pid_t cpid;
00081 #endif
00082
00083 } RT_HEAP;
00084
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088
00089 int __heap_pkg_init(void);
00090
00091 void __heap_pkg_cleanup(void);
00092
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096
00097 #else
00098
00099 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00100
00101 #ifdef __cplusplus
00102 extern "C" {
00103 #endif
00104
00105 int rt_heap_bind(RT_HEAP *heap,
00106 const char *name,
00107 RTIME timeout);
00108
00109 int rt_heap_unbind(RT_HEAP *heap);
00110
00111 #ifdef __cplusplus
00112 }
00113 #endif
00114
00115 #endif
00116
00117 #ifdef __cplusplus
00118 extern "C" {
00119 #endif
00120
00121
00122
00123 int rt_heap_create(RT_HEAP *heap,
00124 const char *name,
00125 size_t heapsize,
00126 int mode);
00127
00128 int rt_heap_delete(RT_HEAP *heap);
00129
00130 int rt_heap_alloc(RT_HEAP *heap,
00131 size_t size,
00132 RTIME timeout,
00133 void **blockp);
00134
00135 int rt_heap_free(RT_HEAP *heap,
00136 void *block);
00137
00138 int rt_heap_inquire(RT_HEAP *heap,
00139 RT_HEAP_INFO *info);
00140
00141 #ifdef __cplusplus
00142 }
00143 #endif
00144
00145 #endif