heap.h

Go to the documentation of this file.
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 /* Creation flags. */
00030 #define H_PRIO   XNSYNCH_PRIO   /* Pend by task priority order. */
00031 #define H_FIFO   XNSYNCH_FIFO   /* Pend by FIFO order. */
00032 #define H_DMA    0x100          /* Use memory suitable for DMA. */
00033 #define H_SHARED 0x200          /* Use mappable shared memory. */
00034 
00035 typedef struct rt_heap_info {
00036 
00037     int nwaiters;               /* !< Number of pending tasks. */
00038 
00039     int mode;                   /* !< Creation mode. */
00040 
00041     size_t heapsize;            /* !< Size of heap memory. */
00042 
00043     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
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;   /* !< Magic code - must be first */
00066 
00067     xnsynch_t synch_base; /* !< Base synchronization object. */
00068 
00069     xnheap_t heap_base; /* !< Internal heap object. */
00070 
00071     int mode;           /* !< Creation mode. */
00072 
00073     void *shm_block;    /* !< Single shared block (H_SHARED only) */
00074 
00075     rt_handle_t handle; /* !< Handle in registry -- zero if unregistered. */
00076 
00077     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00078 
00079 #if defined(__KERNEL__) && defined(CONFIG_RTAI_OPT_FUSION)
00080     pid_t cpid;                 /* !< Creator's pid. */
00081 #endif /* __KERNEL__ && CONFIG_RTAI_OPT_FUSION */
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 /* !(__KERNEL__ || __RTAI_SIM__) */
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 /* __KERNEL__ || __RTAI_SIM__ */
00115 
00116 #ifdef __cplusplus
00117 extern "C" {
00118 #endif
00119 
00120 /* Public interface. */
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 /* !_RTAI_HEAP_H */

Generated on Wed Jun 22 22:54:02 2005 for RTAI Fusion API by  doxygen 1.4.1