include/native/misc.h

Go to the documentation of this file.
00001 
00022 #ifndef _XENO_MISC_H
00023 #define _XENO_MISC_H
00024 
00025 #include <native/types.h>
00026 
00027 #define IORN_IOPORT     0x1
00028 #define IORN_IOMEM      0x2
00029 
00030 typedef struct rt_ioregion_placeholder {
00031         xnhandle_t opaque;
00032         /*
00033          * We keep the region start and length in the userland
00034          * placeholder to support deprecated rt_misc_io_*() calls.
00035          */
00036         uint64_t start;
00037         uint64_t len;
00038 } RT_IOREGION_PLACEHOLDER;
00039 
00040 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00041 
00042 #include <native/ppd.h>
00043 
00044 #define XENO_IOREGION_MAGIC 0x55550b0b
00045 
00046 typedef struct rt_ioregion {
00047 
00048         unsigned magic;         /* !< Magic code - must be first */
00049 
00050         xnhandle_t handle;      /* !< Handle in registry -- must be registered. */
00051 
00052         uint64_t start;         /* !< Start of I/O region. */
00053 
00054         uint64_t len;           /* !< Length of I/O region. */
00055 
00056         char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00057 
00058         int flags;              /* !< Operation flags. */
00059 
00060         pid_t cpid;             /* !< Creator's pid. */
00061 
00062         xnholder_t rlink;       /* !< Link in resource queue. */
00063 
00064 #define rlink2ioregion(ln)      container_of(ln, RT_IOREGION, rlink)
00065 
00066         xnqueue_t *rqueue;     /* !< Backpointer to resource queue. */
00067 
00068 } RT_IOREGION;
00069 
00070 int rt_ioregion_delete(RT_IOREGION *iorn);
00071 
00072 static inline void __native_ioregion_flush_rq(xnqueue_t *rq)
00073 {
00074 #ifdef CONFIG_XENO_OPT_PERVASIVE
00075         xeno_flush_rq(RT_IOREGION, rq, ioregion);
00076 #endif
00077 }
00078 
00079 static inline int __native_misc_pkg_init(void)
00080 {
00081         return 0;
00082 }
00083 
00084 static inline void __native_misc_pkg_cleanup(void)
00085 {
00086 #ifdef CONFIG_XENO_OPT_PERVASIVE
00087         __native_ioregion_flush_rq(&__native_global_rholder.ioregionq);
00088 #endif
00089 }
00090 
00091 #else /* !(__KERNEL__ && __XENO_SIM__) */
00092 
00093 typedef RT_IOREGION_PLACEHOLDER RT_IOREGION;
00094 
00095 #ifdef __cplusplus
00096 extern "C" {
00097 #endif
00098 
00099 /* Public interface. */
00100 
00101 int rt_io_get_region(RT_IOREGION *iorn,
00102                      const char *name,
00103                      uint64_t start,
00104                      uint64_t len,
00105                      int flags);
00106 
00107 int rt_io_put_region(RT_IOREGION *iorn);
00108 
00109 __deprecated_call__
00110 static inline int  rt_misc_get_io_region(unsigned long start,
00111                                          unsigned long len,
00112                                          const char *label)
00113 {
00114         RT_IOREGION iorn;
00115 
00116         return rt_io_get_region(&iorn, label, (uint64_t)start,
00117                                 (uint64_t)len, IORN_IOPORT);
00118 }
00119 
00120 __deprecated_call__
00121 static inline int rt_misc_put_io_region(unsigned long start,
00122                                         unsigned long len)
00123 {
00124         RT_IOREGION iorn;
00125 
00126         iorn.opaque = XN_NO_HANDLE;
00127         iorn.start = (uint64_t)start;
00128         iorn.len = (uint64_t)len;
00129         rt_io_put_region(&iorn);
00130 
00131         return 0;
00132 }
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 
00138 #endif /* !(__KERNEL__ || __XENO_SIM__) */
00139 
00140 #endif /* !_XENO_MISC_H */

Generated on Mon Mar 24 18:02:40 2008 for Xenomai API by  doxygen 1.5.3