]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/ARCH-sparc/kdebug.h
62be74b514800e3b95a72578e6560eee427af136
[l4.git] / l4 / pkg / l4sys / include / ARCH-sparc / kdebug.h
1 /*
2  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  *
9  * As a special exception, you may use this file as part of a free software
10  * library without restriction.  Specifically, if other files instantiate
11  * templates or use macros or inline functions from this file, or you compile
12  * this file and link it with other files to produce an executable, this
13  * file does not by itself cause the resulting executable to be covered by
14  * the GNU General Public License.  This exception does not however
15  * invalidate any other reasons why the executable file might be covered by
16  * the GNU General Public License.
17  */
18 #ifndef __L4SYS__INCLUDE__ARCH_SPARC__KDEBUG_H__
19 #define __L4SYS__INCLUDE__ARCH_SPARC__KDEBUG_H__
20
21 #include <l4/sys/compiler.h>
22 #include <l4/sys/consts.h>
23 #ifdef __GNUC__
24
25 #ifndef L4_SYSCALL_MAGIC_OFFSET
26 #  define L4_SYSCALL_MAGIC_OFFSET       8
27 #endif
28 #define L4_SYSCALL_ENTER_KDEBUG         (-0x00000020-L4_SYSCALL_MAGIC_OFFSET)
29
30
31 #define enter_kdebug(text...) do { } while (1) 
32
33 L4_INLINE void
34 outnstring(const char* x, unsigned len);
35
36 L4_INLINE void
37 outstring(const char *text);
38
39 L4_INLINE void
40 outchar(char c);
41
42 L4_INLINE void
43 outdec(int number);
44
45 L4_INLINE void
46 outhex32(int number);
47
48 L4_INLINE void
49 outhex20(int number);
50
51 L4_INLINE void
52 outhex16(int number);
53
54 L4_INLINE void
55 outhex12(int number);
56
57 L4_INLINE void
58 outhex8(int number);
59
60 L4_INLINE void
61 kd_display(char *text);
62
63 L4_INLINE int
64 l4kd_inchar(void);
65
66 L4_INLINE void
67 l4_sys_cli(void);
68
69 L4_INLINE void
70 l4_sys_sti(void);
71
72 L4_INLINE void
73 l4_kdebug_imb(void);
74
75 EXTERN_C long int
76 l4_atomic_add(volatile long int* mem, long int offset) L4_NOTHROW;
77
78 EXTERN_C long int
79 l4_atomic_cmpxchg(volatile long int* mem, long int oldval, long int newval) L4_NOTHROW;
80
81 L4_INLINE int
82 l4_irq_enabled(void);
83
84 L4_INLINE void __touch_ro(const char *x, unsigned len);
85
86 L4_INLINE unsigned long
87 __kdebug_param(unsigned long nr, unsigned long p1, unsigned long p2);
88
89 L4_INLINE unsigned long
90 __kdebug_param_5(unsigned long nr, unsigned long p1, unsigned long p2,
91                  unsigned long p3, unsigned long p4, unsigned long p5);
92
93 L4_INLINE
94 unsigned long
95 __kdebug_param(unsigned long nr, unsigned long p1, unsigned long p2)
96 {
97         (void)nr;
98         (void)p1;
99         (void)p2;
100         return -1;
101 }
102
103 L4_INLINE
104 unsigned long
105 __kdebug_param_5(unsigned long nr, unsigned long p1, unsigned long p2,
106                  unsigned long p3, unsigned long p4, unsigned long p5)
107 {
108         (void)nr;
109         (void)p1;
110         (void)p2;
111         (void)p3;
112         (void)p4;
113         (void)p5;
114         return -1;
115 }
116
117 L4_INLINE void
118 __touch_ro(const char *x, unsigned len)
119 {
120    volatile const char *sptr, *eptr;
121    sptr = (const char*)((unsigned)x & L4_PAGEMASK);
122    eptr = (const char*)(((unsigned)x + len -1) & L4_PAGEMASK);
123
124    for(;sptr <= eptr; sptr += L4_PAGESIZE)
125      (void)(*sptr);
126 }
127
128 L4_INLINE void
129 outnstring(const char* x, unsigned len)
130 {
131   __touch_ro(x, len);
132   __kdebug_param(3, (unsigned long)x, (unsigned long)len);
133 }
134
135 L4_INLINE void
136 outstring(const char *text)
137 {
138   unsigned i = 0;
139   while(text[i++]) ;
140   outnstring(text, i);
141 }
142
143 L4_INLINE void
144 outchar(char c)
145 {
146   __kdebug_param(1, (unsigned long)c, 0);
147 }
148
149 L4_INLINE void
150 outdec(int number)
151 {
152   __kdebug_param(4, (unsigned long)number, 0);
153 }
154
155 L4_INLINE void
156 outhex32(int number)
157 {
158   __kdebug_param(5, (unsigned long)number, 0);
159 }
160
161 L4_INLINE void
162 outhex20(int number)
163 {
164   __kdebug_param(6, (unsigned long)number, 0);
165 }
166
167 L4_INLINE void
168 outhex16(int number)
169 {
170   __kdebug_param(7, (unsigned long)number, 0);
171 }
172
173 L4_INLINE void
174 outhex12(int number)
175 {
176   __kdebug_param(8, (unsigned long)number, 0);
177 }
178
179 L4_INLINE void
180 outhex8(int number)
181 {
182   __kdebug_param(9, (unsigned long)number, 0);
183 }
184
185 L4_INLINE void
186 kd_display(char *text)
187 {
188   outstring(text);
189 }
190
191 L4_INLINE int
192 l4kd_inchar(void)
193 {
194   return __kdebug_param(0xd, 0, 0);
195 }
196
197 L4_INLINE void
198 l4_sys_cli(void)
199 {
200   __kdebug_param(0x32, 0, 0);
201 }
202
203 L4_INLINE void
204 l4_sys_sti(void)
205 {
206   __kdebug_param(0x33, 0, 0);
207 }
208
209 L4_INLINE void
210 l4_kdebug_imb(void)
211 {
212  // __KDEBUG_ARM_PARAM_0(0x3f);
213 }
214 L4_INLINE int
215 l4_irq_enabled(void)
216 {
217   return __kdebug_param(0x34, 0, 0);
218 }
219 #endif //__GNUC__
220
221 #endif /* ! __L4SYS__INCLUDE__ARCH_SPARC__KDEBUG_H__ */