projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
common: Drop linux/delay.h from common header
[oweals/u-boot.git]
/
common
/
kgdb.c
diff --git
a/common/kgdb.c
b/common/kgdb.c
index b14898be9214929dbe44b3bb7e100e4f98564f34..4493a1591986c3380df2c86d40a8996b1688b96a 100644
(file)
--- a/
common/kgdb.c
+++ b/
common/kgdb.c
@@
-1,4
+1,4
@@
-/* taken from arch/ppc/kernel/ppc-stub.c */
+/* taken from arch/p
ower
pc/kernel/ppc-stub.c */
/****************************************************************************
/****************************************************************************
@@
-88,12
+88,11
@@
****************************************************************************/
#include <common.h>
****************************************************************************/
#include <common.h>
+#include <asm/ptrace.h>
#include <kgdb.h>
#include <command.h>
#include <kgdb.h>
#include <command.h>
-#if defined(CONFIG_CMD_KGDB)
-
#undef KGDB_DEBUG
/*
#undef KGDB_DEBUG
/*
@@
-105,7
+104,7
@@
static char remcomOutBuffer[BUFMAX];
static char remcomRegBuffer[BUFMAX];
static int initialized = 0;
static char remcomRegBuffer[BUFMAX];
static int initialized = 0;
-static int kgdb_active
= 0, first_entry = 1
;
+static int kgdb_active;
static struct pt_regs entry_regs;
static long error_jmp_buf[BUFMAX/2];
static int longjmp_on_fault = 0;
static struct pt_regs entry_regs;
static long error_jmp_buf[BUFMAX/2];
static int longjmp_on_fault = 0;
@@
-134,11
+133,20
@@
hex(unsigned char ch)
static unsigned char *
mem2hex(char *mem, char *buf, int count)
{
static unsigned char *
mem2hex(char *mem, char *buf, int count)
{
+ char *tmp;
unsigned char ch;
unsigned char ch;
+ /*
+ * We use the upper half of buf as an intermediate buffer for the
+ * raw memory copy. Hex conversion will work against this one.
+ */
+ tmp = buf + count;
longjmp_on_fault = 1;
longjmp_on_fault = 1;
+
+ memcpy(tmp, mem, count);
+
while (count-- > 0) {
while (count-- > 0) {
- ch = *
mem
++;
+ ch = *
tmp
++;
*buf++ = hexchars[ch >> 4];
*buf++ = hexchars[ch & 0xf];
}
*buf++ = hexchars[ch >> 4];
*buf++ = hexchars[ch & 0xf];
}
@@
-153,21
+161,33
@@
mem2hex(char *mem, char *buf, int count)
static char *
hex2mem(char *buf, char *mem, int count)
{
static char *
hex2mem(char *buf, char *mem, int count)
{
- int i, hexValue;
- unsigned char ch;
- char *mem_start = mem;
+ int hexValue;
+ char *tmp_raw, *tmp_hex;
+
+ /*
+ * We use the upper half of buf as an intermediate buffer for the
+ * raw memory that is converted from hex.
+ */
+ tmp_raw = buf + count * 2;
+ tmp_hex = tmp_raw - 1;
longjmp_on_fault = 1;
longjmp_on_fault = 1;
- for (i=0; i<count; i++) {
- if ((hexValue = hex(*buf++)) < 0)
+ while (tmp_hex >= buf) {
+ tmp_raw--;
+ hexValue = hex(*tmp_hex--);
+ if (hexValue < 0)
kgdb_error(KGDBERR_NOTHEXDIG);
kgdb_error(KGDBERR_NOTHEXDIG);
- ch = hexValue << 4;
- if ((hexValue = hex(*buf++)) < 0)
+ *tmp_raw = hexValue;
+ hexValue = hex(*tmp_hex--);
+ if (hexValue < 0)
kgdb_error(KGDBERR_NOTHEXDIG);
kgdb_error(KGDBERR_NOTHEXDIG);
-
ch |= hexValue
;
- *mem++ = ch;
+
*tmp_raw |= hexValue << 4
;
+
}
}
- kgdb_flush_cache_range((void *)mem_start, (void *)(mem - 1));
+
+ memcpy(mem, tmp_raw, count);
+
+ kgdb_flush_cache_range((void *)mem, (void *)(mem+count));
longjmp_on_fault = 0;
return buf;
longjmp_on_fault = 0;
return buf;
@@
-307,7
+327,7
@@
handle_exception (struct pt_regs *regs)
return (0);
}
return (0);
}
- /* probably should check which exception occured as well */
+ /* probably should check which exception occur
r
ed as well */
if (longjmp_on_fault) {
longjmp_on_fault = 0;
kgdb_longjmp(error_jmp_buf, KGDBERR_MEMFAULT);
if (longjmp_on_fault) {
longjmp_on_fault = 0;
kgdb_longjmp(error_jmp_buf, KGDBERR_MEMFAULT);
@@
-329,16
+349,7
@@
handle_exception (struct pt_regs *regs)
kgdb_enter(regs, &kd);
kgdb_enter(regs, &kd);
- if (first_entry) {
- /*
- * the first time we enter kgdb, we save the processor
- * state so that we can return to the monitor if the
- * remote end quits gdb (or at least, tells us to quit
- * with the 'k' packet)
- */
- entry_regs = *regs;
- first_entry = 0;
- }
+ entry_regs = *regs;
ptr = remcomOutBuffer;
ptr = remcomOutBuffer;
@@
-440,7
+451,6
@@
handle_exception (struct pt_regs *regs)
case 'k': /* kill the program, actually return to monitor */
kd.extype = KGDBEXIT_KILL;
*regs = entry_regs;
case 'k': /* kill the program, actually return to monitor */
kd.extype = KGDBEXIT_KILL;
*regs = entry_regs;
- first_entry = 1;
goto doexit;
case 'C': /* CSS continue with signal SS */
goto doexit;
case 'C': /* CSS continue with signal SS */
@@
-565,7
+575,7
@@
breakpoint(void)
}
int
}
int
-do_kgdb(
cmd_tbl_t *cmdtp, int flag, int argc, char *
argv[])
+do_kgdb(
struct cmd_tbl *cmdtp, int flag, int argc, char *const
argv[])
{
printf("Entering KGDB mode via exception handler...\n\n");
kgdb_breakpoint(argc - 1, argv + 1);
{
printf("Entering KGDB mode via exception handler...\n\n");
kgdb_breakpoint(argc - 1, argv + 1);
@@
-574,8
+584,8
@@
do_kgdb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
U_BOOT_CMD(
}
U_BOOT_CMD(
- kgdb, C
FG_MAXARGS, 1,
do_kgdb,
- "
kgdb - enter gdb remote debug mode\n
",
+ kgdb, C
ONFIG_SYS_MAXARGS, 1,
do_kgdb,
+ "
enter gdb remote debug mode
",
"[arg0 arg1 .. argN]\n"
" - executes a breakpoint so that kgdb mode is\n"
" entered via the exception handler. To return\n"
"[arg0 arg1 .. argN]\n"
" - executes a breakpoint so that kgdb mode is\n"
" entered via the exception handler. To return\n"
@@
-587,8
+597,3
@@
U_BOOT_CMD(
" program if it is executed (see the \"hello_world\"\n"
" example program in the U-Boot examples directory)."
);
" program if it is executed (see the \"hello_world\"\n"
" example program in the U-Boot examples directory)."
);
-#else
-
-int kgdb_not_configured = 1;
-
-#endif