L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
kdebug.h
Go to the documentation of this file.
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
19#pragma once
20
27#ifndef __KDEBUG_H__
28#define __KDEBUG_H__
29
30#include <l4/sys/compiler.h>
31#include <l4/sys/consts.h>
32#include <l4/sys/ipc.h>
33
34
35L4_INLINE void
36enter_kdebug(char const *text) L4_NOTHROW;
37
43{
44 L4_KDEBUG_ENTER = 0,
45 L4_KDEBUG_OUTCHAR = 1,
46 L4_KDEBUG_OUTNSTRING = 2,
47 L4_KDEBUG_OUTHEX32 = 3,
48 L4_KDEBUG_OUTHEX20 = 4,
49 L4_KDEBUG_OUTHEX16 = 5,
50 L4_KDEBUG_OUTHEX12 = 6,
51 L4_KDEBUG_OUTHEX8 = 7,
52 L4_KDEBUG_OUTDEC = 8,
53};
54
55
67{
68 l4_msgtag_t res;
69 l4_utcb_t *u = l4_utcb();
70 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
71 l4_umword_t mr0 = mr->mr[0];
72
73 mr->mr[0] = op;
77 mr->mr[0] = mr0;
78 return res;
79}
80
96__kdebug_text(unsigned op, char const *text, unsigned len) L4_NOTHROW
97{
98 l4_msg_regs_t store;
99 l4_msgtag_t res;
100 l4_utcb_t *u = l4_utcb();
101 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
102
103 if (len > (sizeof(store) - (2 * sizeof(l4_umword_t))))
104 len = sizeof(store) - (2 * sizeof(l4_umword_t));
105
106 __builtin_memcpy(&store, mr, sizeof(store));
107 mr->mr[0] = op;
108 mr->mr[1] = len;
109 __builtin_memcpy(&mr->mr[2], text, len);
112 l4_bytes_to_mwords(len) + 2, 0, 0),
114 __builtin_memcpy(mr, &store, sizeof(*mr));
115 return res;
116}
117
137__kdebug_3_text(unsigned op, char const *text, unsigned len,
139{
140 l4_msg_regs_t store;
141 l4_msgtag_t res;
142 l4_utcb_t *u = l4_utcb();
143 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
144
145 if (len > (sizeof(store) - (5 * sizeof(l4_umword_t))))
146 len = sizeof(store) - (5 * sizeof(l4_umword_t));
147
148 __builtin_memcpy(&store, mr, sizeof(store));
149 mr->mr[0] = op;
150 mr->mr[1] = v1;
151 mr->mr[2] = v2;
152 mr->mr[3] = v3;
153 mr->mr[4] = len;
154 __builtin_memcpy(&mr->mr[5], text, len);
157 l4_bytes_to_mwords(len) + 5, 0, 0),
159 __builtin_memcpy(mr, &store, sizeof(*mr));
160 return res;
161}
162
175{
176 l4_umword_t m[2];
177 l4_msgtag_t res;
178 l4_utcb_t *u = l4_utcb();
179 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
180
181 m[0] = mr->mr[0];
182 m[1] = mr->mr[1];
183 mr->mr[0] = op;
184 mr->mr[1] = val;
188 mr->mr[0] = m[0];
189 mr->mr[1] = m[1];
190 return res;
191}
192
202L4_INLINE void enter_kdebug(char const *text) L4_NOTHROW
203{
204 /* special case, enter without any text and use of the UTCB */
205 if (!text)
206 {
210 return;
211 }
212
213 __kdebug_text(L4_KDEBUG_ENTER, text, __builtin_strlen(text));
214}
215
224L4_INLINE void outnstring(char const *text, unsigned len)
225{ __kdebug_text(L4_KDEBUG_OUTNSTRING, text, len); }
226
235L4_INLINE void outstring(char const *text)
236{ outnstring(text, __builtin_strlen(text)); }
237
243L4_INLINE void outchar(char c)
244{
245 __kdebug_op_1(L4_KDEBUG_OUTCHAR, c);
246}
247
257{
258 if (sizeof(l4_umword_t) == sizeof(l4_uint64_t))
259 __kdebug_op_1(L4_KDEBUG_OUTHEX32, (l4_uint64_t)number >> 32);
260
261 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
262}
263
272{
273 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number >> 32);
274 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
275}
276
283{
284 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
285}
286
293{
294 __kdebug_op_1(L4_KDEBUG_OUTHEX20, number);
295}
296
303{
304 __kdebug_op_1(L4_KDEBUG_OUTHEX16, number);
305}
306
313{
314 __kdebug_op_1(L4_KDEBUG_OUTHEX12, number);
315}
316
323{
324 __kdebug_op_1(L4_KDEBUG_OUTHEX8, number);
325}
326
333{
334 __kdebug_op_1(L4_KDEBUG_OUTDEC, number);
335}
336
337#endif //__KDEBUG_H__
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
signed long l4_mword_t
Signed machine word.
Definition l4int.h:48
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:36
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:38
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
@ L4_BASE_DEBUGGER_CAP
Capability selector for the debugger cap.
Definition consts.h:355
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition ipc.h:576
unsigned l4_bytes_to_mwords(unsigned size) L4_NOTHROW
Determine how many machine words (l4_umword_t) are required to store a buffer of 'size' bytes.
Definition consts.h:485
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:428
@ L4_PROTO_DEBUGGER
Protocol ID for the debugger.
Definition types.h:75
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
l4_msgtag_t __kdebug_3_text(unsigned op, char const *text, unsigned len, l4_umword_t v1, l4_umword_t v2, l4_umword_t v3) L4_NOTHROW
Invoke a text output operation with 3 additional machine word arguments on the base debugger capabili...
Definition kdebug.h:137
void outhex32(l4_uint32_t number)
Output a 32-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:282
void outhex8(l4_uint8_t number)
Output an 8-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:322
void outstring(char const *text)
Output a string via the kernel debugger.
Definition kdebug.h:235
void outchar(char c)
Output a single character via the kernel debugger.
Definition kdebug.h:243
void enter_kdebug(char const *text) L4_NOTHROW
Enter the kernel debugger.
Definition kdebug.h:202
void outhex20(l4_uint32_t number)
Output a 20-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:292
void outhex64(l4_uint64_t number)
Output a 64-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:271
void outhex16(l4_uint16_t number)
Output a 16-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:302
l4_kdebug_ops_t
Op-codes for operations that can be invoked on the base debugger capability.
Definition kdebug.h:43
void outdec(l4_mword_t number)
Output a decimal unsigned machine word via the kernel debugger.
Definition kdebug.h:332
void outhex12(l4_uint16_t number)
Output a 12-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:312
void outumword(l4_umword_t number)
Output a hexadecimal unsigned machine word via the kernel debugger.
Definition kdebug.h:256
l4_msgtag_t __kdebug_text(unsigned op, char const *text, unsigned len) L4_NOTHROW
Invoke a text output operation on the base debugger capability.
Definition kdebug.h:96
l4_msgtag_t __kdebug_op_1(unsigned op, l4_mword_t val) L4_NOTHROW
Invoke an unary operation on the base debugger capability.
Definition kdebug.h:174
void outnstring(char const *text, unsigned len)
Output a fixed-length string via the kernel debugger.
Definition kdebug.h:224
l4_msgtag_t __kdebug_op(unsigned op) L4_NOTHROW
Invoke a nullary operation on the base debugger capability.
Definition kdebug.h:66
Message tag data structure.
Definition types.h:164
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80