heap.h

Go to the documentation of this file.
00001 
00049 #ifndef _RTAI_HEAP_H
00050 #define _RTAI_HEAP_H
00051 
00052 #include <nucleus/synch.h>
00053 #include <nucleus/heap.h>
00054 #include <rtai/types.h>
00055 
00056 struct RT_TASK;
00057 
00058 /* Creation flags. */
00059 #define H_PRIO   XNSYNCH_PRIO   /* Pend by task priority order. */
00060 #define H_FIFO   XNSYNCH_FIFO   /* Pend by FIFO order. */
00061 #define H_DMA    0x100          /* Use memory suitable for DMA. */
00062 #define H_SHARED 0x200          /* Use mappable shared memory. */
00063 
00064 typedef struct rt_heap_info {
00065 
00066     int nwaiters;               /* !< Number of pending tasks. */
00067 
00068     int mode;                   /* !< Creation mode. */
00069 
00070     size_t heapsize;            /* !< Size of heap memory. */
00071 
00072     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00073 
00074 } RT_HEAP_INFO;
00075 
00076 typedef struct rt_heap_placeholder {
00077 
00078     rt_handle_t opaque;
00079 
00080     void *opaque2;
00081 
00082     caddr_t mapbase;
00083 
00084     size_t mapsize;
00085 
00086 } RT_HEAP_PLACEHOLDER;
00087 
00088 #if defined(__KERNEL__) || defined(__RTAI_SIM__)
00089 
00090 #define RTAI_HEAP_MAGIC 0x55550808
00091 
00092 typedef struct rt_heap {
00093 
00094     unsigned magic;   /* !< Magic code - must be first */
00095 
00096     xnsynch_t synch_base; /* !< Base synchronization object. */
00097 
00098     xnheap_t heap_base; /* !< Internal heap object. */
00099 
00100     int mode;           /* !< Creation mode. */
00101 
00102     void *shm_block;    /* !< Single shared block (H_SHARED only) */
00103 
00104     rt_handle_t handle; /* !< Handle in registry -- zero if unregistered. */
00105 
00106     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00107 
00108 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00109     int source;         /* !< Creator's space. */
00110 #endif /* __KERNEL__ && CONFIG_RTAI_OPT_FUSION */
00111 
00112 } RT_HEAP;
00113 
00114 #ifdef __cplusplus
00115 extern "C" {
00116 #endif
00117 
00118 int __heap_pkg_init(void);
00119 
00120 void __heap_pkg_cleanup(void);
00121 
00122 #ifdef __cplusplus
00123 }
00124 #endif
00125 
00126 #else /* !(__KERNEL__ || __RTAI_SIM__) */
00127 
00128 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00129 
00130 int rt_heap_bind(RT_HEAP *heap,
00131                  const char *name);
00132 
00133 int rt_heap_unbind(RT_HEAP *heap);
00134 
00135 #endif /* __KERNEL__ || __RTAI_SIM__ */
00136 
00137 #ifdef __cplusplus
00138 extern "C" {
00139 #endif
00140 
00141 /* Public interface. */
00142 
00143 int rt_heap_create(RT_HEAP *heap,
00144                    const char *name,
00145                    size_t heapsize,
00146                    int mode);
00147 
00148 int rt_heap_delete(RT_HEAP *heap);
00149 
00150 int rt_heap_alloc(RT_HEAP *heap,
00151                   size_t size,
00152                   RTIME timeout,
00153                   void **blockp);
00154 
00155 int rt_heap_free(RT_HEAP *heap,
00156                  void *block);
00157 
00158 int rt_heap_inquire(RT_HEAP *heap,
00159                     RT_HEAP_INFO *info);
00160 
00161 #ifdef __cplusplus
00162 }
00163 #endif
00164 
00165 #endif /* !_RTAI_HEAP_H */

Generated on Mon Dec 13 09:49:49 2004 for RTAI API by  doxygen 1.3.9.1