static void gdbstub_report_exception(frame_context *frame,s32 thread) { s32 sigval; char *ptr; ptr = remcomOutBuffer; sigval = computeSignal(frame->EXCPT_Number); *ptr++ = 'T'; *ptr++ = highhex(sigval); *ptr++ = lowhex(sigval); *ptr++ = highhex(SP_REGNUM); *ptr++ = lowhex(SP_REGNUM); *ptr++ = ':'; ptr = mem2hstr(ptr,(char*)&frame->GPR[1],4); *ptr++ = ';'; *ptr++ = highhex(PC_REGNUM); *ptr++ = lowhex(PC_REGNUM); *ptr++ = ':'; ptr = mem2hstr(ptr,(char*)&frame->SRR0,4); *ptr++ = ';'; *ptr++ = 't'; *ptr++ = 'h'; *ptr++ = 'r'; *ptr++ = 'e'; *ptr++ = 'a'; *ptr++ = 'd'; *ptr++ = ':'; ptr = thread2vhstr(ptr,thread); *ptr++ = ';'; *ptr++ = '\0'; }
static void put_string(struct sci_port *sci_port, const char *buffer, int count) { struct uart_port *port = &sci_port->port; const unsigned char *p = buffer; int i; #if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) int checksum; int usegdb=0; #ifdef CONFIG_SH_STANDARD_BIOS /* This call only does a trap the first time it is * called, and so is safe to do here unconditionally */ usegdb |= sh_bios_in_gdb_mode(); #endif #ifdef CONFIG_SH_KGDB usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port)); #endif if (usegdb) { /* $<packet info>#<checksum>. */ do { unsigned char c; put_char(port, '$'); put_char(port, 'O'); /* 'O'utput to console */ checksum = 'O'; for (i=0; i<count; i++) { /* Don't use run length encoding */ int h, l; c = *p++; h = highhex(c); l = lowhex(c); put_char(port, h); put_char(port, l); checksum += h + l; } put_char(port, '#'); put_char(port, highhex(checksum)); put_char(port, lowhex(checksum)); } while (get_char(port) != '+'); } else #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */ for (i=0; i<count; i++) { if (*p == 10) put_char(port, '\r'); put_char(port, *p++); } }
static void put_string(struct sci_port *port, const char *buffer, int count) { int i; const unsigned char *p = buffer; #ifdef CONFIG_SH_STANDARD_BIOS int checksum; /* This call only does a trap the first time it is * called, and so is safe to do here unconditionally */ if (sh_bios_in_gdb_mode()) { /* $<packet info>#<checksum>. */ do { unsigned char c; put_char(port, '$'); put_char(port, 'O'); /* 'O'utput to console */ checksum = 'O'; for (i=0; i<count; i++) { /* Don't use run length encoding */ int h, l; c = *p++; h = highhex(c); l = lowhex(c); put_char(port, h); put_char(port, l); checksum += h + l; } put_char(port, '#'); put_char(port, highhex(checksum)); put_char(port, lowhex(checksum)); } while (get_char(port) != '+'); } else #endif for (i=0; i<count; i++) { if (*p == 10) put_char(port, '\r'); put_char(port, *p++); } }
/* Convert the memory pointed to by mem into hex, placing result in buf. Returns a pointer to the last char put in buf (null) */ static char *mem_to_hex(const char *mem, char *buf, const int count) { int i; int ch; unsigned short s_val; unsigned long l_val; /* Check for 16 or 32 */ if (count == 2 && ((long) mem & 1) == 0) { s_val = *(unsigned short *) mem; mem = (char *) &s_val; } else if (count == 4 && ((long) mem & 3) == 0) { l_val = *(unsigned long *) mem; mem = (char *) &l_val; } for (i = 0; i < count; i++) { ch = *mem++; *buf++ = highhex(ch); *buf++ = lowhex(ch); } *buf = 0; return (buf); }