X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/7804c2dae30700296c3205aaf7f546f491999bf4..0765e7c133eb393d8cd0292af444543c2edf8ccc:/lunaix-os/kernel/debug/gdbstub.c diff --git a/lunaix-os/kernel/debug/gdbstub.c b/lunaix-os/kernel/debug/gdbstub.c index 38d35ad..963e5ff 100644 --- a/lunaix-os/kernel/debug/gdbstub.c +++ b/lunaix-os/kernel/debug/gdbstub.c @@ -32,10 +32,10 @@ * SOFTWARE. */ -#include +#include #include -#include #include +#include /***************************************************************************** * Types @@ -74,6 +74,7 @@ enum GDB_REGISTER struct gdb_state { int signum; + struct serial_dev* sdev; reg registers[GDB_CPU_NUM_REGISTERS]; }; @@ -884,13 +885,9 @@ gdb_send_error_packet(struct gdb_state* state, static int gdb_write(struct gdb_state* state, const char* buf, unsigned int len) { - while (len--) { - if (gdb_sys_putchar(state, *buf++) == GDB_EOF) { - return GDB_EOF; - } - } + int err = serial_rwbuf_sync(state->sdev, buf, len, SERIAL_RW_TX); - return 0; + return err < 0 ? GDB_EOF : 0; } /* @@ -913,14 +910,9 @@ gdb_read(struct gdb_state* state, return GDB_EOF; } - while (len--) { - if ((c = gdb_sys_getc(state)) == GDB_EOF) { - return GDB_EOF; - } - *buf++ = c; - } + int err = serial_rwbuf_sync(state->sdev, buf, buf_len, SERIAL_RW_RX); - return 0; + return err < 0 ? GDB_EOF : 0; } /***************************************************************************** @@ -1191,8 +1183,8 @@ struct gdb_idt_gate /***************************************************************************** * Prototypes ****************************************************************************/ -#define gdb_x86_io_write_8(port, val) io_outb(port, val) -#define gdb_x86_io_read_8(port) io_inb(port) +#define gdb_x86_io_write_8(port, val) port_wrbyte(port, val) +#define gdb_x86_io_read_8(port) port_rdbyte(port) #define gdb_x86_serial_getc() serial_rx_byte(COM_PORT) #define gdb_x86_serial_putchar(ch) serial_tx_byte(COM_PORT, ch) @@ -1271,7 +1263,7 @@ gdbstub_loop(isr_param* param) int gdb_sys_putchar(struct gdb_state* state, int ch) { - gdb_x86_serial_putchar(ch); + serial_rwbuf_sync(state->sdev, &ch, 1, SERIAL_RW_TX); return ch; } @@ -1281,7 +1273,9 @@ gdb_sys_putchar(struct gdb_state* state, int ch) int gdb_sys_getc(struct gdb_state* state) { - return gdb_x86_serial_getc() & 0xff; + char ch; + serial_rwbuf_sync(state->sdev, &ch, 1, SERIAL_RW_RX); + return ch & 0xff; } /*