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
00108 int rt_heap_unbind(RT_HEAP *heap);
00109
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113
00114 #endif
00115
00116 #ifdef __cplusplus
00117 extern "C" {
00118 #endif
00119
00120
00121
00122 int rt_heap_create(RT_HEAP *heap,
00123 const char *name,
00124 size_t heapsize,
00125 int mode);
00126
00127 int rt_heap_delete(RT_HEAP *heap);
00128
00129 int rt_heap_alloc(RT_HEAP *heap,
00130 size_t size,
00131 RTIME timeout,
00132 void **blockp);
00133
00134 int rt_heap_free(RT_HEAP *heap,
00135 void *block);
00136
00137 int rt_heap_inquire(RT_HEAP *heap,
00138 RT_HEAP_INFO *info);
00139
00140 #ifdef __cplusplus
00141 }
00142 #endif
00143
00144 #endif