1c7eab67fSIngo Weinhold/*
299f00556SIngo Weinhold * Copyright 2005-2016, Ingo Weinhold, ingo_weinhold@gmx.de.
3c7eab67fSIngo Weinhold * Distributed under the terms of the MIT License.
4c7eab67fSIngo Weinhold */
5c7eab67fSIngo Weinhold#ifndef KERNEL_ARCH_USER_DEBUGGER_H
6c7eab67fSIngo Weinhold#define KERNEL_ARCH_USER_DEBUGGER_H
7c7eab67fSIngo Weinhold
84535495dSIngo Weinhold
96e595b29SIngo Weinhold#include "kernel_debug_config.h"
100490454cSIngo Weinhold
110490454cSIngo Weinhold#ifndef _ASSEMBLER
120490454cSIngo Weinhold
13dd07f600SIngo Weinhold#include <debugger.h>
14dd07f600SIngo Weinhold
15dd07f600SIngo Weinhold#ifdef __cplusplus
16dd07f600SIngo Weinholdextern "C" {
17dd07f600SIngo Weinhold#endif
18dd07f600SIngo Weinhold
19dd07f600SIngo Weinholdstruct arch_team_debug_info;
2000a2b607SIngo Weinholdstruct arch_thread_debug_info;
214535495dSIngo Weinhold
2299f00556SIngo Weinholdnamespace BKernel {
2399f00556SIngo Weinhold    struct Thread;
2499f00556SIngo Weinhold}
2599f00556SIngo Weinholdusing BKernel::Thread;
2699f00556SIngo Weinhold
27dd07f600SIngo Weinhold
28dd07f600SIngo Weinholdvoid arch_clear_team_debug_info(struct arch_team_debug_info *info);
29dd07f600SIngo Weinholdvoid arch_destroy_team_debug_info(struct arch_team_debug_info *info);
3000a2b607SIngo Weinholdvoid arch_clear_thread_debug_info(struct arch_thread_debug_info *info);
3100a2b607SIngo Weinholdvoid arch_destroy_thread_debug_info(struct arch_thread_debug_info *info);
32dd07f600SIngo Weinhold
3334b3b26bSIngo Weinholdvoid arch_update_thread_single_step();
3434b3b26bSIngo Weinhold
350b11ecb1SIngo Weinholdvoid arch_set_debug_cpu_state(const debug_cpu_state *cpuState);
360b11ecb1SIngo Weinholdvoid arch_get_debug_cpu_state(debug_cpu_state *cpuState);
3799f00556SIngo Weinholdstatus_t arch_get_thread_debug_cpu_state(Thread *thread,
3899f00556SIngo Weinhold	debug_cpu_state *cpuState);
39c7eab67fSIngo Weinhold
40dd07f600SIngo Weinholdstatus_t arch_set_breakpoint(void *address);
41dd07f600SIngo Weinholdstatus_t arch_clear_breakpoint(void *address);
42dd07f600SIngo Weinholdstatus_t arch_set_watchpoint(void *address, uint32 type, int32 length);
43dd07f600SIngo Weinholdstatus_t arch_clear_watchpoint(void *address);
4434b3b26bSIngo Weinholdbool arch_has_breakpoints(struct arch_team_debug_info *info);
45dd07f600SIngo Weinhold
46667f1eebSIngo Weinhold#if KERNEL_BREAKPOINTS
47667f1eebSIngo Weinholdstatus_t arch_set_kernel_breakpoint(void *address);
48667f1eebSIngo Weinholdstatus_t arch_clear_kernel_breakpoint(void *address);
49667f1eebSIngo Weinholdstatus_t arch_set_kernel_watchpoint(void *address, uint32 type, int32 length);
50667f1eebSIngo Weinholdstatus_t arch_clear_kernel_watchpoint(void *address);
51667f1eebSIngo Weinhold#endif
52667f1eebSIngo Weinhold
53dd07f600SIngo Weinhold#ifdef __cplusplus
54dd07f600SIngo Weinhold}
55dd07f600SIngo Weinhold#endif
56dd07f600SIngo Weinhold
57dd07f600SIngo Weinhold#include <arch_user_debugger.h>
58dd07f600SIngo Weinhold
59b0f12d64SIngo Weinhold// Defaults for macros defined by the architecture specific header:
60b0f12d64SIngo Weinhold
61b0f12d64SIngo Weinhold// maximum number of instruction breakpoints
62b0f12d64SIngo Weinhold#ifndef DEBUG_MAX_BREAKPOINTS
63b0f12d64SIngo Weinhold#	define DEBUG_MAX_BREAKPOINTS 0
64b0f12d64SIngo Weinhold#endif
65b0f12d64SIngo Weinhold
66b0f12d64SIngo Weinhold// maximum number of data watchpoints
67b0f12d64SIngo Weinhold#ifndef DEBUG_MAX_WATCHPOINTS
68b0f12d64SIngo Weinhold#	define DEBUG_MAX_WATCHPOINTS 0
69b0f12d64SIngo Weinhold#endif
70b0f12d64SIngo Weinhold
71b0f12d64SIngo Weinhold// the software breakpoint instruction
72b0f12d64SIngo Weinhold#if !defined(DEBUG_SOFTWARE_BREAKPOINT)	\
73b0f12d64SIngo Weinhold	|| !defined(DEBUG_SOFTWARE_BREAKPOINT_SIZE)
74b0f12d64SIngo Weinhold#	undef DEBUG_SOFTWARE_BREAKPOINT
75b0f12d64SIngo Weinhold#	undef DEBUG_SOFTWARE_BREAKPOINT_SIZE
76b0f12d64SIngo Weinhold#	define DEBUG_SOFTWARE_BREAKPOINT		NULL
77b0f12d64SIngo Weinhold#	define DEBUG_SOFTWARE_BREAKPOINT_SIZE	0
78b0f12d64SIngo Weinhold#endif
79b0f12d64SIngo Weinhold
80b0f12d64SIngo Weinhold// Boolean whether break- and watchpoints use the same registers. If != 0, then
81b0f12d64SIngo Weinhold// DEBUG_MAX_BREAKPOINTS == DEBUG_MAX_WATCHPOINTS and either specifies the
82b0f12d64SIngo Weinhold// total count of break- plus watchpoints.
83b0f12d64SIngo Weinhold#ifndef DEBUG_SHARED_BREAK_AND_WATCHPOINTS
84b0f12d64SIngo Weinhold#	define DEBUG_SHARED_BREAK_AND_WATCHPOINTS 0
85b0f12d64SIngo Weinhold#endif
86b0f12d64SIngo Weinhold
870490454cSIngo Weinhold#endif	// _ASSEMBLER
880490454cSIngo Weinhold
89c7eab67fSIngo Weinhold#endif	// KERNEL_ARCH_USER_DEBUGGER_H
90