]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/kgdb.c
Merge branch 'master' of git://www.denx.de/git/u-boot
[karo-tx-uboot.git] / common / kgdb.c
index b563094d545e9efb77cf67c850395d38157134d1..b14898be9214929dbe44b3bb7e100e4f98564f34 100644 (file)
@@ -92,7 +92,7 @@
 #include <kgdb.h>
 #include <command.h>
 
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#if defined(CONFIG_CMD_KGDB)
 
 #undef KGDB_DEBUG
 
@@ -107,7 +107,7 @@ static char remcomRegBuffer[BUFMAX];
 static int initialized = 0;
 static int kgdb_active = 0, first_entry = 1;
 static struct pt_regs entry_regs;
-static u_int error_jmp_buf[BUFMAX/2];
+static long error_jmp_buf[BUFMAX/2];
 static int longjmp_on_fault = 0;
 #ifdef KGDB_DEBUG
 static int kdebug = 1;
@@ -144,7 +144,7 @@ mem2hex(char *mem, char *buf, int count)
        }
        *buf = 0;
        longjmp_on_fault = 0;
-       return buf;
+       return (unsigned char *)buf;
 }
 
 /* convert the hex array pointed to by buf into binary to be placed in mem
@@ -310,7 +310,7 @@ handle_exception (struct pt_regs *regs)
        /* probably should check which exception occured as well */
        if (longjmp_on_fault) {
                longjmp_on_fault = 0;
-               kgdb_longjmp((long*)error_jmp_buf, KGDBERR_MEMFAULT);
+               kgdb_longjmp(error_jmp_buf, KGDBERR_MEMFAULT);
                panic("kgdb longjump failed!\n");
        }
 
@@ -324,7 +324,7 @@ handle_exception (struct pt_regs *regs)
 
        printf("kgdb: handle_exception; trap [0x%x]\n", kgdb_trap(regs));
 
-       if (kgdb_setjmp((long*)error_jmp_buf) != 0)
+       if (kgdb_setjmp(error_jmp_buf) != 0)
                panic("kgdb: error or fault in entry init!\n");
 
        kgdb_enter(regs, &kd);
@@ -353,7 +353,7 @@ handle_exception (struct pt_regs *regs)
                *ptr++ = hexchars[rp->num >> 4];
                *ptr++ = hexchars[rp->num & 0xf];
                *ptr++ = ':';
-               ptr = mem2hex((char *)&rp->val, ptr, 4);
+               ptr = (char *)mem2hex((char *)&rp->val, ptr, 4);
                *ptr++ = ';';
        }
 
@@ -364,7 +364,7 @@ handle_exception (struct pt_regs *regs)
                printf("kgdb: remcomOutBuffer: %s\n", remcomOutBuffer);
 #endif
 
-       putpacket(remcomOutBuffer);
+       putpacket((unsigned char *)&remcomOutBuffer);
 
        while (1) {
                volatile int errnum;
@@ -379,7 +379,7 @@ handle_exception (struct pt_regs *regs)
                        printf("kgdb:  remcomInBuffer: %s\n", remcomInBuffer);
 #endif
 
-               errnum = kgdb_setjmp((long*)error_jmp_buf);
+               errnum = kgdb_setjmp(error_jmp_buf);
 
                if (errnum == 0) switch (remcomInBuffer[0]) {
 
@@ -508,7 +508,7 @@ handle_exception (struct pt_regs *regs)
 #endif
 
                /* reply to the request */
-               putpacket(remcomOutBuffer);
+               putpacket((unsigned char *)&remcomOutBuffer);
 
        } /* while(1) */
 }
@@ -532,7 +532,7 @@ void
 kgdb_error(int errnum)
 {
        longjmp_on_fault = 0;
-       kgdb_longjmp((long*)error_jmp_buf, errnum);
+       kgdb_longjmp(error_jmp_buf, errnum);
        panic("kgdb_error: longjmp failed!\n");
 }
 
@@ -548,7 +548,7 @@ kgdb_output_string (const char* s, unsigned int count)
 
        buffer[0] = 'O';
        mem2hex ((char *)s, &buffer[1], count);
-       putpacket(buffer);
+       putpacket((unsigned char *)&buffer);
 
        return 1;
 }
@@ -573,8 +573,22 @@ do_kgdb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
     return 0;
 }
 
+U_BOOT_CMD(
+       kgdb, CFG_MAXARGS, 1,   do_kgdb,
+       "kgdb    - enter gdb remote debug mode\n",
+       "[arg0 arg1 .. argN]\n"
+       "    - executes a breakpoint so that kgdb mode is\n"
+       "      entered via the exception handler. To return\n"
+       "      to the monitor, the remote gdb debugger must\n"
+       "      execute a \"continue\" or \"quit\" command.\n"
+       "\n"
+       "      if a program is loaded by the remote gdb, any args\n"
+       "      passed to the kgdb command are given to the loaded\n"
+       "      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 /* CFG_CMD_KGDB */
+#endif