Commit d57f078b authored by David Howells's avatar David Howells

KGDB: Notify GDB of machine halt, reboot or power off

Notify GDB of the machine halting, rebooting or powering off by sending it an
exited command (remote protocol command 'W').  This is done by calling:

	void gdbstub_exit(int status)

from the arch's machine_{halt,restart,power_off}() functions with an
appropriate exit status to be reported to GDB.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent e460d644
...@@ -297,6 +297,7 @@ extern int ...@@ -297,6 +297,7 @@ extern int
kgdb_handle_exception(int ex_vector, int signo, int err_code, kgdb_handle_exception(int ex_vector, int signo, int err_code,
struct pt_regs *regs); struct pt_regs *regs);
extern int kgdb_nmicallback(int cpu, void *regs); extern int kgdb_nmicallback(int cpu, void *regs);
extern void gdbstub_exit(int status);
extern int kgdb_single_step; extern int kgdb_single_step;
extern atomic_t kgdb_active; extern atomic_t kgdb_active;
......
...@@ -1093,3 +1093,33 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd) ...@@ -1093,3 +1093,33 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd)
put_packet(remcom_out_buffer); put_packet(remcom_out_buffer);
return 0; return 0;
} }
/**
* gdbstub_exit - Send an exit message to GDB
* @status: The exit code to report.
*/
void gdbstub_exit(int status)
{
unsigned char checksum, ch, buffer[3];
int loop;
buffer[0] = 'W';
buffer[1] = hex_asc_hi(status);
buffer[2] = hex_asc_lo(status);
dbg_io_ops->write_char('$');
checksum = 0;
for (loop = 0; loop < 3; loop++) {
ch = buffer[loop];
checksum += ch;
dbg_io_ops->write_char(ch);
}
dbg_io_ops->write_char('#');
dbg_io_ops->write_char(hex_asc_hi(checksum));
dbg_io_ops->write_char(hex_asc_lo(checksum));
/* make sure the output is flushed, lest the bootloader clobber it */
dbg_io_ops->flush();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment