• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

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 #define H_NONCACHED 0x800
00037 #define H_DMA32     0x1000      /* Use memory suitable for DMA32. */
00038 
00043 typedef struct rt_heap_info {
00044 
00045     int nwaiters;               /* !< Number of pending tasks. */
00046 
00047     int mode;                   /* !< Creation mode. */
00048 
00049     size_t heapsize;            /* !< Requested heap size. */
00050 
00051     size_t usablemem;           /* !< Available heap memory. */
00052 
00053     size_t usedmem;             /* !< Amount of memory used. */
00054 
00055     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00056 
00057     unsigned long phys_addr;    /* !< Physical address. */
00058 
00059 } RT_HEAP_INFO;
00060 
00061 typedef struct rt_heap_placeholder {
00062         xnhandle_t opaque;
00063         void *opaque2;
00064         caddr_t mapbase;
00065         size_t mapsize;
00066         unsigned long area;
00067 } RT_HEAP_PLACEHOLDER;
00068 
00069 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00070 
00071 #include <native/ppd.h>
00072 
00073 #define XENO_HEAP_MAGIC 0x55550808
00074 
00075 typedef struct rt_heap {
00076 
00077     unsigned magic;   /* !< Magic code - must be first */
00078 
00079     xnsynch_t synch_base; /* !< Base synchronization object. */
00080 
00081     xnheap_t heap_base; /* !< Internal heap object. */
00082 
00083     int mode;           /* !< Creation mode. */
00084 
00085     size_t csize;       /* !< Original size at creation. */
00086 
00087     void *sba;          /* !< Single block ara (H_SINGLE only) */
00088 
00089     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00090 
00091     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00092 
00093 #ifdef CONFIG_XENO_OPT_PERVASIVE
00094     pid_t cpid;                 /* !< Creator's pid. */
00095 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00096 
00097     xnholder_t rlink;           /* !< Link in resource queue. */
00098 
00099 #define rlink2heap(ln)          container_of(ln, RT_HEAP, rlink)
00100 
00101     xnqueue_t *rqueue;          /* !< Backpointer to resource queue. */
00102 
00103 } RT_HEAP;
00104 
00105 #ifdef __cplusplus
00106 extern "C" {
00107 #endif
00108 
00109 #ifdef CONFIG_XENO_OPT_NATIVE_HEAP
00110 
00111 int __native_heap_pkg_init(void);
00112 
00113 void __native_heap_pkg_cleanup(void);
00114 
00115 static inline void __native_heap_flush_rq(xnqueue_t *rq)
00116 {
00117         xeno_flush_rq_norelease(RT_HEAP, rq, heap);
00118 }
00119 
00120 int rt_heap_delete_inner(RT_HEAP *heap,
00121                          void __user *mapaddr);
00122 
00123 #else /* !CONFIG_XENO_OPT_NATIVE_HEAP */
00124 
00125 #define __native_heap_pkg_init()                ({ 0; })
00126 #define __native_heap_pkg_cleanup()             do { } while(0)
00127 #define __native_heap_flush_rq(rq)              do { } while(0)
00128 
00129 #endif /* !CONFIG_XENO_OPT_NATIVE_HEAP */
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 
00135 #else /* !(__KERNEL__ || __XENO_SIM__) */
00136 
00137 typedef RT_HEAP_PLACEHOLDER RT_HEAP;
00138 
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142 
00143 int rt_heap_bind(RT_HEAP *heap,
00144                  const char *name,
00145                  RTIME timeout);
00146 
00147 int rt_heap_unbind(RT_HEAP *heap);
00148 
00149 #ifdef __cplusplus
00150 }
00151 #endif
00152 
00153 #endif /* __KERNEL__ || __XENO_SIM__ */
00154 
00155 #ifdef __cplusplus
00156 extern "C" {
00157 #endif
00158 
00159 /* Public interface. */
00160 
00161 int rt_heap_create(RT_HEAP *heap,
00162                    const char *name,
00163                    size_t heapsize,
00164                    int mode);
00165 
00166 int rt_heap_delete(RT_HEAP *heap);
00167 
00168 int rt_heap_alloc(RT_HEAP *heap,
00169                   size_t size,
00170                   RTIME timeout,
00171                   void **blockp);
00172 
00173 int rt_heap_free(RT_HEAP *heap,
00174                  void *block);
00175 
00176 int rt_heap_inquire(RT_HEAP *heap,
00177                     RT_HEAP_INFO *info);
00178 
00179 #ifdef __cplusplus
00180 }
00181 #endif
00182 
00183 #endif /* !_XENO_HEAP_H */

Generated on Tue Jul 10 2012 20:41:22 for Xenomai API by  doxygen 1.7.1