include/native/heap.h

Go to the documentation of this file.
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 /* 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_MAPPABLE 0x200        /* Memory is mappable to user-space. */
00034 #define H_SINGLE   0x400        /* Manage as single-block area. */
00035 #define H_SHARED   (H_MAPPABLE|H_SINGLE) /* I.e. shared memory segment. */
00036 
00037 typedef struct rt_heap_info {
00038 
00039     int nwaiters;               /* !< Number of pending tasks. */
00040 
00041     int mode;                   /* !< Creation mode. */
00042 
00043     size_t heapsize;            /* !< Size of heap memory. */
00044 
00045     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
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;   /* !< Magic code - must be first */
00068 
00069     xnsynch_t synch_base; /* !< Base synchronization object. */
00070 
00071     xnheap_t heap_base; /* !< Internal heap object. */
00072 
00073     int mode;           /* !< Creation mode. */
00074 
00075     size_t csize;       /* !< Original size at creation. */
00076 
00077     void *sba;          /* !< Single block ara (H_SINGLE only) */
00078 
00079     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00080 
00081     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00082 
00083 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
00084     pid_t cpid;                 /* !< Creator's pid. */
00085 #endif /* __KERNEL__ && CONFIG_XENO_OPT_PERVASIVE */
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 /* !(__KERNEL__ || __XENO_SIM__) */
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 /* __KERNEL__ || __XENO_SIM__ */
00120 
00121 #ifdef __cplusplus
00122 extern "C" {
00123 #endif
00124 
00125 /* Public interface. */
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 /* !_XENO_HEAP_H */

Generated on Mon Dec 25 13:57:10 2006 for Xenomai API by  doxygen 1.4.6