|
@@ -30,6 +30,7 @@
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kgdb.h>
|
|
#include <linux/kgdb.h>
|
|
|
|
+#include <linux/kdb.h>
|
|
#include <linux/reboot.h>
|
|
#include <linux/reboot.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/cacheflush.h>
|
|
@@ -62,6 +63,30 @@ static int hex(char ch)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_KGDB_KDB
|
|
|
|
+static int gdbstub_read_wait(void)
|
|
|
|
+{
|
|
|
|
+ int ret = -1;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ /* poll any additional I/O interfaces that are defined */
|
|
|
|
+ while (ret < 0)
|
|
|
|
+ for (i = 0; kdb_poll_funcs[i] != NULL; i++) {
|
|
|
|
+ ret = kdb_poll_funcs[i]();
|
|
|
|
+ if (ret > 0)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+#else
|
|
|
|
+static int gdbstub_read_wait(void)
|
|
|
|
+{
|
|
|
|
+ int ret = dbg_io_ops->read_char();
|
|
|
|
+ while (ret == NO_POLL_CHAR)
|
|
|
|
+ ret = dbg_io_ops->read_char();
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
/* scan for the sequence $<data>#<checksum> */
|
|
/* scan for the sequence $<data>#<checksum> */
|
|
static void get_packet(char *buffer)
|
|
static void get_packet(char *buffer)
|
|
{
|
|
{
|
|
@@ -75,7 +100,7 @@ static void get_packet(char *buffer)
|
|
* Spin and wait around for the start character, ignore all
|
|
* Spin and wait around for the start character, ignore all
|
|
* other characters:
|
|
* other characters:
|
|
*/
|
|
*/
|
|
- while ((ch = (dbg_io_ops->read_char())) != '$')
|
|
|
|
|
|
+ while ((ch = (gdbstub_read_wait())) != '$')
|
|
/* nothing */;
|
|
/* nothing */;
|
|
|
|
|
|
kgdb_connected = 1;
|
|
kgdb_connected = 1;
|
|
@@ -88,7 +113,7 @@ static void get_packet(char *buffer)
|
|
* now, read until a # or end of buffer is found:
|
|
* now, read until a # or end of buffer is found:
|
|
*/
|
|
*/
|
|
while (count < (BUFMAX - 1)) {
|
|
while (count < (BUFMAX - 1)) {
|
|
- ch = dbg_io_ops->read_char();
|
|
|
|
|
|
+ ch = gdbstub_read_wait();
|
|
if (ch == '#')
|
|
if (ch == '#')
|
|
break;
|
|
break;
|
|
checksum = checksum + ch;
|
|
checksum = checksum + ch;
|
|
@@ -98,8 +123,8 @@ static void get_packet(char *buffer)
|
|
buffer[count] = 0;
|
|
buffer[count] = 0;
|
|
|
|
|
|
if (ch == '#') {
|
|
if (ch == '#') {
|
|
- xmitcsum = hex(dbg_io_ops->read_char()) << 4;
|
|
|
|
- xmitcsum += hex(dbg_io_ops->read_char());
|
|
|
|
|
|
+ xmitcsum = hex(gdbstub_read_wait()) << 4;
|
|
|
|
+ xmitcsum += hex(gdbstub_read_wait());
|
|
|
|
|
|
if (checksum != xmitcsum)
|
|
if (checksum != xmitcsum)
|
|
/* failed checksum */
|
|
/* failed checksum */
|
|
@@ -144,10 +169,10 @@ static void put_packet(char *buffer)
|
|
dbg_io_ops->flush();
|
|
dbg_io_ops->flush();
|
|
|
|
|
|
/* Now see what we get in reply. */
|
|
/* Now see what we get in reply. */
|
|
- ch = dbg_io_ops->read_char();
|
|
|
|
|
|
+ ch = gdbstub_read_wait();
|
|
|
|
|
|
if (ch == 3)
|
|
if (ch == 3)
|
|
- ch = dbg_io_ops->read_char();
|
|
|
|
|
|
+ ch = gdbstub_read_wait();
|
|
|
|
|
|
/* If we get an ACK, we are done. */
|
|
/* If we get an ACK, we are done. */
|
|
if (ch == '+')
|
|
if (ch == '+')
|