Xenomai API  2.6.5
misc.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_MISC_H
23 #define _XENO_MISC_H
24 
25 #include <native/types.h>
26 
27 #define IORN_IOPORT 0x1
28 #define IORN_IOMEM 0x2
29 
30 typedef struct rt_ioregion_placeholder {
31  xnhandle_t opaque;
32 } RT_IOREGION_PLACEHOLDER;
33 
34 #if defined(__KERNEL__) || defined(__XENO_SIM__)
35 
36 #include <native/ppd.h>
37 
38 #define XENO_IOREGION_MAGIC 0x55550b0b
39 
40 typedef struct rt_ioregion {
41 
42  unsigned magic; /* !< Magic code - must be first */
43 
44  xnhandle_t handle; /* !< Handle in registry -- must be registered. */
45 
46  uint64_t start; /* !< Start of I/O region. */
47 
48  uint64_t len; /* !< Length of I/O region. */
49 
50  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
51 
52  int flags; /* !< Operation flags. */
53 
54  pid_t cpid; /* !< Creator's pid. */
55 
56  xnholder_t rlink; /* !< Link in resource queue. */
57 
58 #define rlink2ioregion(ln) container_of(ln, RT_IOREGION, rlink)
59 
60  xnqueue_t *rqueue; /* !< Backpointer to resource queue. */
61 
62 } RT_IOREGION;
63 
64 int rt_ioregion_delete(RT_IOREGION *iorn);
65 
66 static inline void __native_ioregion_flush_rq(xnqueue_t *rq)
67 {
68 #ifdef CONFIG_XENO_OPT_PERVASIVE
69  xeno_flush_rq(RT_IOREGION, rq, ioregion);
70 #endif
71 }
72 
73 static inline int __native_misc_pkg_init(void)
74 {
75  return 0;
76 }
77 
78 static inline void __native_misc_pkg_cleanup(void)
79 {
80 #ifdef CONFIG_XENO_OPT_PERVASIVE
81  __native_ioregion_flush_rq(&__native_global_rholder.ioregionq);
82 #endif
83 }
84 
85 #else /* !(__KERNEL__ && __XENO_SIM__) */
86 
87 typedef RT_IOREGION_PLACEHOLDER RT_IOREGION;
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 /* Public interface. */
94 
95 int rt_io_get_region(RT_IOREGION *iorn,
96  const char *name,
97  uint64_t start,
98  uint64_t len,
99  int flags);
100 
101 int rt_io_put_region(RT_IOREGION *iorn);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* !(__KERNEL__ || __XENO_SIM__) */
108 
109 #endif /* !_XENO_MISC_H */
This file is part of the Xenomai project.
This file is part of the Xenomai project.