L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
6 */
7
8#pragma once
9
16#ifndef __KDEBUG_H__
17#define __KDEBUG_H__
18
19#include <l4/sys/compiler.h>
20#include <l4/sys/consts.h>
21#include <l4/sys/ipc.h>
22
23
24L4_INLINE void
25enter_kdebug(char const *text) L4_NOTHROW;
26
32{
33 L4_KDEBUG_GROUP_JDB = 0x000,
34 L4_KDEBUG_GROUP_KOBJ = 0x100, // see __kernel_object_impl.h
35 L4_KDEBUG_GROUP_TRACE = 0x200, // see __ktrace-impl.h
36 L4_KDEBUG_GROUP_COV = 0x400,
37 L4_KDEBUG_GROUP_DUMP = 0x500, // see kdump.h
38};
39
45{
46 L4_KDEBUG_ENTER = L4_KDEBUG_GROUP_JDB + 0,
47 L4_KDEBUG_OUTCHAR = L4_KDEBUG_GROUP_JDB + 1,
48 L4_KDEBUG_OUTNSTRING = L4_KDEBUG_GROUP_JDB + 2,
49 L4_KDEBUG_OUTHEX32 = L4_KDEBUG_GROUP_JDB + 3,
50 L4_KDEBUG_OUTHEX20 = L4_KDEBUG_GROUP_JDB + 4,
51 L4_KDEBUG_OUTHEX16 = L4_KDEBUG_GROUP_JDB + 5,
52 L4_KDEBUG_OUTHEX12 = L4_KDEBUG_GROUP_JDB + 6,
53 L4_KDEBUG_OUTHEX8 = L4_KDEBUG_GROUP_JDB + 7,
54 L4_KDEBUG_OUTDEC = L4_KDEBUG_GROUP_JDB + 8,
55};
56
57
69{
70 l4_msgtag_t res;
71 l4_utcb_t *u = l4_utcb();
72 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
73 l4_umword_t mr0 = mr->mr[0];
74
75 mr->mr[0] = op;
79 mr->mr[0] = mr0;
80 return res;
81}
82
98__kdebug_text(unsigned op, char const *text, unsigned len) L4_NOTHROW
99{
100 l4_msg_regs_t store;
101 l4_msgtag_t res;
102 l4_utcb_t *u = l4_utcb();
103 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
104
105 if (len > (sizeof(store) - (2 * sizeof(l4_umword_t))))
106 len = sizeof(store) - (2 * sizeof(l4_umword_t));
107
108 __builtin_memcpy(&store, mr, sizeof(store));
109 mr->mr[0] = op;
110 mr->mr[1] = len;
111 __builtin_memcpy(&mr->mr[2], text, len);
114 l4_bytes_to_mwords(len) + 2, 0, 0),
116 __builtin_memcpy(mr, &store, sizeof(*mr));
117 return res;
118}
119
139__kdebug_3_text(unsigned op, char const *text, unsigned len,
141{
142 l4_msg_regs_t store;
143 l4_msgtag_t res;
144 l4_utcb_t *u = l4_utcb();
145 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
146
147 if (len > (sizeof(store) - (5 * sizeof(l4_umword_t))))
148 len = sizeof(store) - (5 * sizeof(l4_umword_t));
149
150 __builtin_memcpy(&store, mr, sizeof(store));
151 mr->mr[0] = op;
152 mr->mr[1] = v1;
153 mr->mr[2] = v2;
154 mr->mr[3] = v3;
155 mr->mr[4] = len;
156 __builtin_memcpy(&mr->mr[5], text, len);
159 l4_bytes_to_mwords(len) + 5, 0, 0),
161 __builtin_memcpy(mr, &store, sizeof(*mr));
162 return res;
163}
164
177{
178 l4_umword_t m[2];
179 l4_msgtag_t res;
180 l4_utcb_t *u = l4_utcb();
181 l4_msg_regs_t *mr = l4_utcb_mr_u(u);
182
183 m[0] = mr->mr[0];
184 m[1] = mr->mr[1];
185 mr->mr[0] = op;
186 mr->mr[1] = val;
190 mr->mr[0] = m[0];
191 mr->mr[1] = m[1];
192 return res;
193}
194
204L4_INLINE void enter_kdebug(char const *text) L4_NOTHROW
205{
206 /* special case, enter without any text and use of the UTCB */
207 if (!text)
208 {
212 return;
213 }
214
215 __kdebug_text(L4_KDEBUG_ENTER, text, __builtin_strlen(text));
216}
217
226L4_INLINE void outnstring(char const *text, unsigned len)
227{ __kdebug_text(L4_KDEBUG_OUTNSTRING, text, len); }
228
237L4_INLINE void outstring(char const *text)
238{ outnstring(text, __builtin_strlen(text)); }
239
245L4_INLINE void outchar(char c)
246{
247 __kdebug_op_1(L4_KDEBUG_OUTCHAR, c);
248}
249
259{
260 if (sizeof(l4_umword_t) == sizeof(l4_uint64_t))
261 __kdebug_op_1(L4_KDEBUG_OUTHEX32, (l4_uint64_t)number >> 32);
262
263 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
264}
265
274{
275 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number >> 32);
276 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
277}
278
285{
286 __kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
287}
288
295{
296 __kdebug_op_1(L4_KDEBUG_OUTHEX20, number);
297}
298
305{
306 __kdebug_op_1(L4_KDEBUG_OUTHEX16, number);
307}
308
315{
316 __kdebug_op_1(L4_KDEBUG_OUTHEX12, number);
317}
318
325{
326 __kdebug_op_1(L4_KDEBUG_OUTHEX8, number);
327}
328
335{
336 __kdebug_op_1(L4_KDEBUG_OUTDEC, number);
337}
338
339#endif //__KDEBUG_H__
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
@ L4_BASE_DEBUGGER_CAP
Capability selector for the debugger cap.
Definition consts.h:370
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:565
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:500
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:404
@ L4_PROTO_DEBUGGER
Protocol ID for the debugger.
Definition types.h:64
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:159
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
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:139
void outhex32(l4_uint32_t number)
Output a 32-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:284
void outhex8(l4_uint8_t number)
Output an 8-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:324
void outstring(char const *text)
Output a string via the kernel debugger.
Definition kdebug.h:237
void outchar(char c)
Output a single character via the kernel debugger.
Definition kdebug.h:245
void enter_kdebug(char const *text) L4_NOTHROW
Enter the kernel debugger.
Definition kdebug.h:204
void outhex20(l4_uint32_t number)
Output a 20-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:294
void outhex64(l4_uint64_t number)
Output a 64-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:273
void outhex16(l4_uint16_t number)
Output a 16-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:304
l4_kdebug_ops_t
Op-codes for operations that can be invoked on the base debugger capability.
Definition kdebug.h:45
void outdec(l4_mword_t number)
Output a decimal unsigned machine word via the kernel debugger.
Definition kdebug.h:334
void outhex12(l4_uint16_t number)
Output a 12-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:314
void outumword(l4_umword_t number)
Output a hexadecimal unsigned machine word via the kernel debugger.
Definition kdebug.h:258
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:98
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:176
void outnstring(char const *text, unsigned len)
Output a fixed-length string via the kernel debugger.
Definition kdebug.h:226
l4_kdebug_group_t
Opcode groups for operations that can be invoked on the base debugger capability.
Definition kdebug.h:32
l4_msgtag_t __kdebug_op(unsigned op) L4_NOTHROW
Invoke a nullary operation on the base debugger capability.
Definition kdebug.h:68
Message tag data structure.
Definition types.h:153
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69