Loading...
Searching...
No Matches
kdebug.h
Go to the documentation of this file.
/*
* (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#ifndef __KDEBUG_H__
#define __KDEBUG_H__
#include <l4/sys/compiler.h>
#include <l4/sys/consts.h>
#include <l4/sys/ipc.h>
L4_INLINE void
enter_kdebug(char const *text) L4_NOTHROW;
enum l4_kdebug_group_t
{
L4_KDEBUG_GROUP_JDB = 0x000,
L4_KDEBUG_GROUP_KOBJ = 0x100, // see __kernel_object_impl.h
L4_KDEBUG_GROUP_TRACE = 0x200, // see __ktrace-impl.h
L4_KDEBUG_GROUP_COV = 0x400,
L4_KDEBUG_GROUP_DUMP = 0x500, // see kdump.h
};
enum l4_kdebug_ops_t
{
L4_KDEBUG_ENTER = L4_KDEBUG_GROUP_JDB + 0,
L4_KDEBUG_OUTCHAR = L4_KDEBUG_GROUP_JDB + 1,
L4_KDEBUG_OUTNSTRING = L4_KDEBUG_GROUP_JDB + 2,
L4_KDEBUG_OUTHEX32 = L4_KDEBUG_GROUP_JDB + 3,
L4_KDEBUG_OUTHEX20 = L4_KDEBUG_GROUP_JDB + 4,
L4_KDEBUG_OUTHEX16 = L4_KDEBUG_GROUP_JDB + 5,
L4_KDEBUG_OUTHEX12 = L4_KDEBUG_GROUP_JDB + 6,
L4_KDEBUG_OUTHEX8 = L4_KDEBUG_GROUP_JDB + 7,
L4_KDEBUG_OUTDEC = L4_KDEBUG_GROUP_JDB + 8,
};
L4_INLINE l4_msgtag_t
__kdebug_op(unsigned op) L4_NOTHROW
{
l4_msgtag_t res;
l4_utcb_t *u = l4_utcb();
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
l4_umword_t mr0 = mr->mr[0];
mr->mr[0] = op;
res = l4_ipc_call(L4_BASE_DEBUGGER_CAP, u,
l4_msgtag(L4_PROTO_DEBUGGER, 1, 0, 0),
L4_IPC_NEVER);
mr->mr[0] = mr0;
return res;
}
L4_INLINE l4_msgtag_t
__kdebug_text(unsigned op, char const *text, unsigned len) L4_NOTHROW
{
l4_msg_regs_t store;
l4_msgtag_t res;
l4_utcb_t *u = l4_utcb();
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
if (len > (sizeof(store) - (2 * sizeof(l4_umword_t))))
len = sizeof(store) - (2 * sizeof(l4_umword_t));
__builtin_memcpy(&store, mr, sizeof(store));
mr->mr[0] = op;
mr->mr[1] = len;
__builtin_memcpy(&mr->mr[2], text, len);
res = l4_ipc_call(L4_BASE_DEBUGGER_CAP, u,
l4_msgtag(L4_PROTO_DEBUGGER,
l4_bytes_to_mwords(len) + 2, 0, 0),
L4_IPC_NEVER);
__builtin_memcpy(mr, &store, sizeof(*mr));
return res;
}
L4_INLINE 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
{
l4_msg_regs_t store;
l4_msgtag_t res;
l4_utcb_t *u = l4_utcb();
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
if (len > (sizeof(store) - (5 * sizeof(l4_umword_t))))
len = sizeof(store) - (5 * sizeof(l4_umword_t));
__builtin_memcpy(&store, mr, sizeof(store));
mr->mr[0] = op;
mr->mr[1] = v1;
mr->mr[2] = v2;
mr->mr[3] = v3;
mr->mr[4] = len;
__builtin_memcpy(&mr->mr[5], text, len);
res = l4_ipc_call(L4_BASE_DEBUGGER_CAP, u,
l4_msgtag(L4_PROTO_DEBUGGER,
l4_bytes_to_mwords(len) + 5, 0, 0),
L4_IPC_NEVER);
__builtin_memcpy(mr, &store, sizeof(*mr));
return res;
}
L4_INLINE l4_msgtag_t
__kdebug_op_1(unsigned op, l4_mword_t val) L4_NOTHROW
{
l4_umword_t m[2];
l4_msgtag_t res;
l4_utcb_t *u = l4_utcb();
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
m[0] = mr->mr[0];
m[1] = mr->mr[1];
mr->mr[0] = op;
mr->mr[1] = val;
res = l4_ipc_call(L4_BASE_DEBUGGER_CAP, u,
l4_msgtag(L4_PROTO_DEBUGGER, 2, 0, 0),
L4_IPC_NEVER);
mr->mr[0] = m[0];
mr->mr[1] = m[1];
return res;
}
L4_INLINE void enter_kdebug(char const *text) L4_NOTHROW
{
/* special case, enter without any text and use of the UTCB */
if (!text)
{
l4_ipc_call(L4_BASE_DEBUGGER_CAP, 0,
l4_msgtag(L4_PROTO_DEBUGGER, 0, 0, 0),
L4_IPC_NEVER);
return;
}
__kdebug_text(L4_KDEBUG_ENTER, text, __builtin_strlen(text));
}
L4_INLINE void outnstring(char const *text, unsigned len)
{ __kdebug_text(L4_KDEBUG_OUTNSTRING, text, len); }
L4_INLINE void outstring(char const *text)
{ outnstring(text, __builtin_strlen(text)); }
L4_INLINE void outchar(char c)
{
__kdebug_op_1(L4_KDEBUG_OUTCHAR, c);
}
L4_INLINE void outumword(l4_umword_t number)
{
if (sizeof(l4_umword_t) == sizeof(l4_uint64_t))
__kdebug_op_1(L4_KDEBUG_OUTHEX32, (l4_uint64_t)number >> 32);
__kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
}
L4_INLINE void outhex64(l4_uint64_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX32, number >> 32);
__kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
}
L4_INLINE void outhex32(l4_uint32_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX32, number);
}
L4_INLINE void outhex20(l4_uint32_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX20, number);
}
L4_INLINE void outhex16(l4_uint16_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX16, number);
}
L4_INLINE void outhex12(l4_uint16_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX12, number);
}
L4_INLINE void outhex8(l4_uint8_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTHEX8, number);
}
L4_INLINE void outdec(l4_mword_t number)
{
__kdebug_op_1(L4_KDEBUG_OUTDEC, number);
}
#endif //__KDEBUG_H__
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_mword_t
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
L4_BASE_DEBUGGER_CAP
@ L4_BASE_DEBUGGER_CAP
Capability selector for the debugger cap.
Definition consts.h:366
l4_ipc_call
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
l4_bytes_to_mwords
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:496
l4_msgtag
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:405
L4_PROTO_DEBUGGER
@ L4_PROTO_DEBUGGER
Protocol ID for the debugger.
Definition types.h:65
L4_IPC_NEVER
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
__kdebug_3_text
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
outhex32
void outhex32(l4_uint32_t number)
Output a 32-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:284
outhex8
void outhex8(l4_uint8_t number)
Output an 8-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:324
outstring
void outstring(char const *text)
Output a string via the kernel debugger.
Definition kdebug.h:237
outchar
void outchar(char c)
Output a single character via the kernel debugger.
Definition kdebug.h:245
enter_kdebug
void enter_kdebug(char const *text) L4_NOTHROW
Enter the kernel debugger.
Definition kdebug.h:204
outhex20
void outhex20(l4_uint32_t number)
Output a 20-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:294
outhex64
void outhex64(l4_uint64_t number)
Output a 64-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:273
outhex16
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
l4_kdebug_ops_t
Op-codes for operations that can be invoked on the base debugger capability.
Definition kdebug.h:45
outdec
void outdec(l4_mword_t number)
Output a decimal unsigned machine word via the kernel debugger.
Definition kdebug.h:334
outhex12
void outhex12(l4_uint16_t number)
Output a 12-bit unsigned hexadecimal number via the kernel debugger.
Definition kdebug.h:314
outumword
void outumword(l4_umword_t number)
Output a hexadecimal unsigned machine word via the kernel debugger.
Definition kdebug.h:258
__kdebug_text
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
__kdebug_op_1
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
outnstring
void outnstring(char const *text, unsigned len)
Output a fixed-length string via the kernel debugger.
Definition kdebug.h:226
l4_kdebug_group_t
l4_kdebug_group_t
Opcode groups for operations that can be invoked on the base debugger capability.
Definition kdebug.h:32
__kdebug_op
l4_msgtag_t __kdebug_op(unsigned op) L4_NOTHROW
Invoke a nullary operation on the base debugger capability.
Definition kdebug.h:68
consts.h
Common constants.
ipc.h
Common IPC interface.
l4_msgtag_t
Message tag data structure.
Definition types.h:154
l4_msg_regs_t
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_msg_regs_t::mr
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69