summaryrefslogtreecommitdiff
path: root/Debugger
diff options
context:
space:
mode:
Diffstat (limited to 'Debugger')
-rw-r--r--Debugger/_c_arm_macros.h97
-rw-r--r--Debugger/debug_comm.S8
-rw-r--r--Debugger/debug_macros.h215
-rw-r--r--Debugger/debug_stub.S199
-rw-r--r--Debugger/debug_stub.h7
-rw-r--r--Debugger/types.h46
-rw-r--r--Debugger/undef_handler.S3
7 files changed, 250 insertions, 325 deletions
diff --git a/Debugger/_c_arm_macros.h b/Debugger/_c_arm_macros.h
index f356a25..025542e 100644
--- a/Debugger/_c_arm_macros.h
+++ b/Debugger/_c_arm_macros.h
@@ -3,21 +3,25 @@
*
*/
-/* Copyright (C) 2007,2009 the NxOS developers
+/* Copyright (C) 2010 the NxOS developers
+ *
+ * Module Developed by: TC Wan <tcwan@cs.usm.my>
+ *
* Thanks to Bartli (forum post @ embdev.net ARM programming with GCC/GNU tools forum)
*
* See AUTHORS for a full list of the developers.
*
- * Redistribution of this file is permitted under
- * the terms of the GNU Public License (GPL) version 2.
+ * See COPYING for redistribution license
+ *
*/
-#ifndef __NXOS_BASE_C_ARM_MACROS__
-#define __NXOS_BASE_C_ARM_MACROS__
+#ifndef __C_ARM_MACROS__
+#define __C_ARM_MACROS__
+
#ifdef __ASSEMBLY__
-#define NULL 0x0 /* Stick the definition here instead of making types.h messy */
+#define NULL 0x0
#define FALSE 0
#define TRUE ~FALSE
@@ -38,71 +42,7 @@
enum_val name
#define ENUM_END(enum_name)
-/** Macro to define driver ioctl table
- * First five table entries are predefined
- * 0: init
- * 1: shutdown
- * 2: sleep
- * 3: wakeup
- * 4: poll
- *
- */
-#define DRIVER_IOCTL(driver) \
-/* Dummy sleep and wakeup routines for now */ ;\
- .set driver ## _sleep, NULL ;\
- .set driver ## _wakeup, NULL ;\
- .set driver ## _poll, NULL ;\
-.data ;\
- .align 4 ;\
- .global driver ## _ioctl ;\
-driver ## _ioctl: ;\
- .word driver ## _init ;\
- .word driver ## _shutdown ;\
- .word driver ## _sleep ;\
- .word driver ## _wakeup ;\
- .word driver ## _poll ;\
- .set num_ ## driver ## _cmds, 5
-
-/** Macro to define additional driver ioctl commands
- * Be careful to follow the sequence defined for the CMD enums
- * The first CMD should have an enum value of 5
- *
- */
-#define DRIVER_CMD(driver, cmd) \
- .word driver ## _ ## cmd ;\
- .set num_ ## driver ## _cmds, num_ ## driver ## _cmds + 1
-
-/** Macro to define driver state
- * MUST BE DEFINED AFTER DRIVER_IOCTL section
- * @param driver name of driver
- * @param driverenum enum value of driver (in [31:25])
- *
- * The number of commands for driver (in [24:17]) -- derived from num_driver_cmds
- *
- * Format of driver_state table:
- * driver signature (driverenum << 24 | numcommands << 16)
- * driver parameters (per device instance)
- */
-#define DRIVER_STATE(driver, driverenum) \
-.bss ;\
- .global driver ## _state ;\
-driver ## _state: ;\
- .set driver ## _signature, (driverenum << 24) | (num_ ## driver ## _cmds << 16) ;\
- .word NULL /* driver_signature */
-
-
-/** Macro to define actual driver routine in .S
- * On entry:
- * r0 - address of driver_state
- * r1-r3 - parameters (variable)
- * r12 - number of parameters (IPC scratch register)
- * Stack - parameters (variable)
- */
-#define DRIVER_ROUTINE(driver, cmd) \
- .global driver ## _ ## cmd ## ;\
-driver ## _ ## cmd ## :
-
-#else
+#else /* C Defines */
/** Macro to control typedef generation
*
*/
@@ -137,13 +77,12 @@ driver ## _ ## cmd ## :
#endif
+/* Example of how to use the ENUM definition macros
ENUM_BEGIN
-ENUM_VAL(INIT) /**< Driver Init Routine. */
-ENUM_VAL(SHUTDOWN) /**< Driver Shutdown Routine. */
-ENUM_VAL(SLEEP) /**< Driver Sleep Routine. */
-ENUM_VAL(WAKEUP) /**< Driver Wakeup Routine. */
-ENUM_VAL(POLL) /**< Driver Poll Routine. */
-ENUM_END(nx_driver_default_cmd)
-
+ENUM_VAL(INIT)
+ENUM_VAL(RESET)
+ENUM_VAL(CONFIGURED)
+ENUM_END(enum_label)
+*/
-#endif /* __NXOS_BASE_C_ARM_MACROS__ */
+#endif /* __C_ARM_MACROS__ */
diff --git a/Debugger/debug_comm.S b/Debugger/debug_comm.S
index af69391..857c3ea 100644
--- a/Debugger/debug_comm.S
+++ b/Debugger/debug_comm.S
@@ -1,3 +1,7 @@
+/** @file debug_comm.S
+ * @brief GDB Server communications support routines
+ *
+ */
/* Copyright (C) 2007-2010 the NxOS developers
*
@@ -5,8 +9,8 @@
*
* See AUTHORS for a full list of the developers.
*
- * Redistribution of this file is permitted under
- * the terms of the GNU Public License (GPL) version 2.
+ * See COPYING for redistribution license
+ *
*/
#define __ASSEMBLY__
diff --git a/Debugger/debug_macros.h b/Debugger/debug_macros.h
new file mode 100644
index 0000000..44ded9d
--- /dev/null
+++ b/Debugger/debug_macros.h
@@ -0,0 +1,215 @@
+/** @file debug_macros.h
+ * @brief internal macros used by debug_stub routines
+ *
+ */
+
+/* Copyright (C) 2007-2010 the NxOS developers
+ *
+ * Module Developed by: TC Wan <tcwan@cs.usm.my>
+ *
+ * See AUTHORS for a full list of the developers.
+ *
+ * See COPYING for redistribution license
+ *
+ */
+
+#ifndef __DEBUG_MACROS_H__
+#define __DEBUG_MACROS_H__
+
+#include "_c_arm_macros.h"
+
+
+/** @addtogroup debug_macros */
+/*@{*/
+
+/* _dbg_jumpTableHandler
+ * Call Jump Table Routine based on Index
+ * On entry:
+ * jumptableaddr is the address (constant) of the Jump Table
+ * jumpreg is the register used to perform the indirect jump
+ * indexreg contains jump table index value
+ */
+ .macro _dbg_jumpTableHandler jumptableaddr, jumpreg, indexreg
+
+ ldr \jumpreg, =\jumptableaddr
+ ldr \jumpreg, [\jumpreg, \indexreg, lsl #2]
+ mov lr, pc
+ bx \jumpreg /* Call Command Handler Routine */
+ .endm
+
+
+/* _dbg_stpcpy
+ * _dbg_stpcpy macro
+ * On entry:
+ * deststrptr: Destination string [Cannot be R0]
+ * sourcestrptr: Source string [Cannot be R0]
+ * On exit:
+ * deststrptr: Pointer to NULL character in destination string
+ * R0: destroyed
+ */
+ .macro _dbg_stpcpy deststrptr, sourcestrptr
+1: ldrb r0, [\sourcestrptr], #1
+ strb r0, [\deststrptr], #1
+ teq r0, #0
+ bne 1b
+ sub \deststrptr, \deststrptr, #1 /* Adjust Destination string pointer to point at NULL character */
+ .endm
+
+/* _dbg_outputMsgValidResponse
+ * Return Message with valid response ('+$')
+ * On exit:
+ * R0: destroyed
+ * R1: points to NULL character after the prefix
+ * R2: destroyed
+ */
+ .macro _dbg_outputMsgValidResponse
+ ldr r1, =debug_OutMsgBuf
+ ldr r2, =debug_ValidResponsePrefix
+ _dbg_stpcpy r1, r2
+ .endm
+
+
+/* _dbg_outputMsgStatusOk
+ * Return Message with Ok ('+OK') status
+ * On exit:
+ * R0: destroyed
+ * R1: destroyed
+ * R2: destroyed
+ */
+ .macro _dbg_outputMsgStatusOk
+ ldr r1, =debug_OutMsgBuf
+ ldr r2, =debug_OkResponse
+ _dbg_stpcpy r1, r2
+ .endm
+
+/* _dbg_outputMsgStatusErr
+ * Return Message with Error ('-ENN') status
+ * On entry:
+ * R0: register containing error value (byte)
+ * On exit:
+ * R0: destroyed
+ * R1: destroyed
+ * R2: destroyed
+ * R3: destroyed
+ */
+ .macro _dbg_outputMsgStatusErr
+ mov r3, r0
+ ldr r1, =debug_OutMsgBuf
+ ldr r2, =debug_ErrorResponsePrefix
+ _dbg_stpcpy r1, r2
+ mov r0, r3
+ bl byte2ascii /* R1 points to NULL character after the prefix */
+ .endm
+
+/* _dbg_outputMsgStatusSig
+ * Return Message with Signal ('+SNN') status
+ * On entry:
+ * R0: register containing error value (byte)
+ * On exit:
+ * R0: destroyed
+ * R1: destroyed
+ * R2: destroyed
+ * R3: destroyed
+ */
+ .macro _dbg_outputMsgStatusSig
+ mov r3, r0
+ ldr r1, =debug_OutMsgBuf
+ ldr r2, =debug_SignalResponsePrefix
+ _dbg_stpcpy r1, r2
+ mov r0, r3
+ bl byte2ascii /* R1 points to NULL character after the prefix */
+ .endm
+
+/* _index2dbgstackaddr
+ * Convert debugger stack index to Debugger Stack register address
+ *
+ * On entry:
+ * indexreg contains debugger stack index value (0-max entries)
+ * On exit:
+ * indexreg: Breakpoint index (preserved)
+ * addrreg: Debugger Stack Register Address
+ */
+ .macro _index2dbgstackaddr indexreg, addrreg
+ ldr \addrreg, =__debugger_stack_bottom__
+ add \addrreg, \addrreg, \indexreg, lsl #2 /* Calculate Debugger Stack Register Address */
+ .endm
+
+/* _index2bkptindex_addr
+ * Convert Breakpoint index to breakpoing entry address
+ *
+ * On entry:
+ * indexreg contains breakpoint index value
+ * On exit:
+ * indexreg: Breakpoint index (preserved)
+ * addrreg: Breakpoint Entry Address
+ */
+ .macro _index2bkptindex_addr indexreg, addrreg
+ ldr \addrreg, =__breakpoints_start__
+ add \addrreg, \addrreg, \indexreg, lsl #3 /* Calculate Breakpoint Entry Address */
+ .endm
+
+/* _dbg_getstate
+ * Get Debugger State
+ * On exit:
+ * reg: Debugger State enum
+ */
+ .macro _dbg_getstate reg
+ ldr \reg, =debug_state
+ ldr \reg, [\reg]
+ .endm
+
+/* _dbg_setstate
+ * Set Debugger State to given value
+ * On exit:
+ * r0, r1: destroyed
+ */
+ .macro _dbg_setstate state
+ ldr r0, =\state
+ ldr r1, =debug_state
+ str r0, [r1]
+ .endm
+
+/* _dbg_getcurrbkpt_index
+ * Get current breakpoint index
+ * On exit:
+ * reg: Breakpoint index
+ */
+ .macro _dbg_getcurrbkpt_index reg
+ ldr \reg, =debug_curr_breakpoint
+ ldr \reg, [\reg]
+ .endm
+
+/* _dbg_setcurrbkpt_index
+ * Set current breakpoint index
+ * On exit:
+ * r1: destroyed
+ */
+ .macro _dbg_setcurrbkpt_index reg
+ ldr r1, =debug_curr_breakpoint
+ str \reg, [r1]
+ .endm
+
+/* _dbg_getabortedinstr_addr
+ * Get aborted instruction address
+ * On exit:
+ * reg: aborted instruction address
+ */
+ .macro _dbg_getabortedinstr_addr reg
+ ldr \reg, =__debugger_stack_bottom__
+ ldr \reg, [\reg]
+ .endm
+
+/* _dbg_setabortedinstr_addr
+ * Set aborted instruction address
+ * On exit:
+ * r1: destroyed
+ */
+ .macro _dbg_setabortedinstr_addr reg
+ ldr r1, =__debugger_stack_bottom__
+ str \reg, [r1]
+ .endm
+
+
+ /*@}*/
+
+#endif /* __DEBUG_MACROS_H__ */
diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S
index 030ce40..ec6432e 100644
--- a/Debugger/debug_stub.S
+++ b/Debugger/debug_stub.S
@@ -1,3 +1,7 @@
+/** @file debug_stub.S
+ * @brief ARM Breakpoint Debugger support routines
+ *
+ */
/* Copyright (C) 2007-2010 the NxOS developers
*
@@ -5,8 +9,8 @@
*
* See AUTHORS for a full list of the developers.
*
- * Redistribution of this file is permitted under
- * the terms of the GNU Public License (GPL) version 2.
+ * See COPYING for redistribution license
+ *
*/
/* GDB sparc-stub.c comments header included below to document GDB Server Remote protocol */
@@ -108,6 +112,7 @@
#define __ASSEMBLY__
#include "debug_stub.h"
+#include "debug_macros.h"
.bss
.align 4
@@ -183,194 +188,6 @@ debug_cmdJumpTable:
.extern dbg__getDebugMsg /* Read a message from the communications link */
.extern dbg__putDebugMsg /* Write a message to the communications link */
-/* _dbg_jumpTableHandler
- * Call Jump Table Routine based on Index
- * On entry:
- * jumptableaddr is the address (constant) of the Jump Table
- * jumpreg is the register used to perform the indirect jump
- * indexreg contains jump table index value
- */
- .macro _dbg_jumpTableHandler jumptableaddr, jumpreg, indexreg
-
- ldr \jumpreg, =\jumptableaddr
- ldr \jumpreg, [\jumpreg, \indexreg, lsl #2]
- mov lr, pc
- bx \jumpreg /* Call Command Handler Routine */
- .endm
-
-
-/* _dbg_stpcpy
- * _dbg_stpcpy macro
- * On entry:
- * deststrptr: Destination string [Cannot be R0]
- * sourcestrptr: Source string [Cannot be R0]
- * On exit:
- * deststrptr: Pointer to NULL character in destination string
- * R0: destroyed
- */
- .macro _dbg_stpcpy deststrptr, sourcestrptr
-1: ldrb r0, [\sourcestrptr], #1
- strb r0, [\deststrptr], #1
- teq r0, #0
- bne 1b
- sub \deststrptr, \deststrptr, #1 /* Adjust Destination string pointer to point at NULL character */
- .endm
-
-/* _dbg_outputMsgValidResponse
- * Return Message with valid response ('+$')
- * On exit:
- * R0: destroyed
- * R1: points to NULL character after the prefix
- * R2: destroyed
- */
- .macro _dbg_outputMsgValidResponse
- ldr r1, =debug_OutMsgBuf
- ldr r2, =debug_ValidResponsePrefix
- _dbg_stpcpy r1, r2
- .endm
-
-
-/* _dbg_outputMsgStatusOk
- * Return Message with Ok ('+OK') status
- * On exit:
- * R0: destroyed
- * R1: destroyed
- * R2: destroyed
- */
- .macro _dbg_outputMsgStatusOk
- ldr r1, =debug_OutMsgBuf
- ldr r2, =debug_OkResponse
- _dbg_stpcpy r1, r2
- .endm
-
-/* _dbg_outputMsgStatusErr
- * Return Message with Error ('-ENN') status
- * On entry:
- * R0: register containing error value (byte)
- * On exit:
- * R0: destroyed
- * R1: destroyed
- * R2: destroyed
- * R3: destroyed
- */
- .macro _dbg_outputMsgStatusErr
- mov r3, r0
- ldr r1, =debug_OutMsgBuf
- ldr r2, =debug_ErrorResponsePrefix
- _dbg_stpcpy r1, r2
- mov r0, r3
- bl byte2ascii /* R1 points to NULL character after the prefix */
- .endm
-
-/* _dbg_outputMsgStatusSig
- * Return Message with Signal ('+SNN') status
- * On entry:
- * R0: register containing error value (byte)
- * On exit:
- * R0: destroyed
- * R1: destroyed
- * R2: destroyed
- * R3: destroyed
- */
- .macro _dbg_outputMsgStatusSig
- mov r3, r0
- ldr r1, =debug_OutMsgBuf
- ldr r2, =debug_SignalResponsePrefix
- _dbg_stpcpy r1, r2
- mov r0, r3
- bl byte2ascii /* R1 points to NULL character after the prefix */
- .endm
-
-/* _index2dbgstackaddr
- * Convert debugger stack index to Debugger Stack register address
- *
- * On entry:
- * indexreg contains debugger stack index value (0-max entries)
- * On exit:
- * indexreg: Breakpoint index (preserved)
- * addrreg: Debugger Stack Register Address
- */
- .macro _index2dbgstackaddr indexreg, addrreg
- ldr \addrreg, =__debugger_stack_bottom__
- add \addrreg, \addrreg, \indexreg, lsl #2 /* Calculate Debugger Stack Register Address */
- .endm
-
-/* _index2bkptindex_addr
- * Convert Breakpoint index to breakpoing entry address
- *
- * On entry:
- * indexreg contains breakpoint index value
- * On exit:
- * indexreg: Breakpoint index (preserved)
- * addrreg: Breakpoint Entry Address
- */
- .macro _index2bkptindex_addr indexreg, addrreg
- ldr \addrreg, =__breakpoints_start__
- add \addrreg, \addrreg, \indexreg, lsl #3 /* Calculate Breakpoint Entry Address */
- .endm
-
-/* _dbg_getstate
- * Get Debugger State
- * On exit:
- * reg: Debugger State enum
- */
- .macro _dbg_getstate reg
- ldr \reg, =debug_state
- ldr \reg, [\reg]
- .endm
-
-/* _dbg_setstate
- * Set Debugger State to given value
- * On exit:
- * r0, r1: destroyed
- */
- .macro _dbg_setstate state
- ldr r0, =\state
- ldr r1, =debug_state
- str r0, [r1]
- .endm
-
-/* _dbg_getcurrbkpt_index
- * Get current breakpoint index
- * On exit:
- * reg: Breakpoint index
- */
- .macro _dbg_getcurrbkpt_index reg
- ldr \reg, =debug_curr_breakpoint
- ldr \reg, [\reg]
- .endm
-
-/* _dbg_setcurrbkpt_index
- * Set current breakpoint index
- * On exit:
- * r1: destroyed
- */
- .macro _dbg_setcurrbkpt_index reg
- ldr r1, =debug_curr_breakpoint
- str \reg, [r1]
- .endm
-
-/* _dbg_getabortedinstr_addr
- * Get aborted instruction address
- * On exit:
- * reg: aborted instruction address
- */
- .macro _dbg_getabortedinstr_addr reg
- ldr \reg, =__debugger_stack_bottom__
- ldr \reg, [\reg]
- .endm
-
-/* _dbg_setabortedinstr_addr
- * Set aborted instruction address
- * On exit:
- * r1: destroyed
- */
- .macro _dbg_setabortedinstr_addr reg
- ldr r1, =__debugger_stack_bottom__
- str \reg, [r1]
- .endm
-
-
/* The Debugger Interface can handle a total of (n-1) Breakpoint States and 1 Single Stepping State,
* where n is a power of 2. The value of n is given by __breakpoints_num__ defined in the linker file.
@@ -1273,7 +1090,7 @@ _dbg_next_instruction_addr:
beq _next_instr_is_arm
_next_instr_is_thumb:
add r5, r2, #2 /* set next Thumb instruction address */
- _is_thumb_branch_instr r0 /* check if the current instruction is a branch instruction */
+ /*_is_thumb_branch_instr r0 */ /* check if the current instruction is a branch instruction */
_next_instr_is_arm:
add r5, r2, #4 /* Is ARM, set next ARM instruction address */
@@@@@@@@@
diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h
index 311fa93..897c2b8 100644
--- a/Debugger/debug_stub.h
+++ b/Debugger/debug_stub.h
@@ -9,8 +9,8 @@
*
* See AUTHORS for a full list of the developers.
*
- * Redistribution of this file is permitted under
- * the terms of the GNU Public License (GPL) version 2.
+ * See COPYING for redistribution license
+ *
*/
#ifndef __DEBUG_STUB_H__
@@ -18,9 +18,6 @@
#include "_c_arm_macros.h"
-#ifndef __ASSEMBLY__
-#include "types.h"
-#endif
/** @addtogroup debugger */
/*@{*/
diff --git a/Debugger/types.h b/Debugger/types.h
deleted file mode 100644
index 3a1d4cb..0000000
--- a/Debugger/types.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/** @file types.h
- * @brief Basic type definitions for the Arm7 platform.
- */
-
-/* Copyright (c) 2007,2008 the NxOS developers
- *
- * See AUTHORS for a full list of the developers.
- *
- * Redistribution of this file is permitted under
- * the terms of the GNU Public License (GPL) version 2.
- */
-
-#ifndef __NXOS_BASE_TYPES_H__
-#define __NXOS_BASE_TYPES_H__
-
-/** @addtogroup typesAndUtils */
-/*@{*/
-
-typedef unsigned char U8; /**< Unsigned 8-bit integer. */
-typedef signed char S8; /**< Signed 8-bit integer. */
-typedef unsigned short U16; /**< Unsigned 16-bit integer. */
-typedef signed short S16; /**< Signed 16-bit integer. */
-typedef unsigned long U32; /**< Unsigned 32-bit integer. */
-typedef signed long S32; /**< Signed 32-bit integer. */
-
-#ifndef __SIZE_TYPE__
-#define __SIZE_TYPE__ U32 /**< Used to go conform with gcc, otherwise we are
- risking an error because of conflicting types for size_t */
-#endif
-typedef __SIZE_TYPE__ size_t; /**< Abstract size type, needed by the memory allocator. */
-
-typedef U8 bool; /**< Boolean data type. */
-#define FALSE (0) /**< False boolean value. */
-#define TRUE (!FALSE) /**< True boolean value. */
-
-#ifndef NULL
-/** Definition of the NULL pointer. */
-#define NULL ((void*)0)
-#endif
-
-/** A function that takes no arguments and returns nothing. */
-typedef void (*nx_closure_t)(void);
-
-/*@}*/
-
-#endif
diff --git a/Debugger/undef_handler.S b/Debugger/undef_handler.S
index 34bca92..385bf0c 100644
--- a/Debugger/undef_handler.S
+++ b/Debugger/undef_handler.S
@@ -19,6 +19,7 @@
.extern dbg__thumb_bkpt_handler
.extern dbg__arm_bkpt_handler
+ .extern default_undef_handler
.global undef_handler
@@ -69,5 +70,3 @@ _is_arm:
mov pc, lr /* Invoke Debugger State (Supervisor Mode) */
-default_undef_handler:
- b default_undef_handler /* Infinite loop */