* SOFTWARE.
*/
-#include <hal/io.h>
+#include <hal/serial.h>
#include <klibc/string.h>
-#include <lunaix/peripheral/serial.h>
#include <sdbg/gdbstub.h>
+#include <sys/port_io.h>
/*****************************************************************************
* Types
struct gdb_state
{
int signum;
+ struct serial_dev* sdev;
reg registers[GDB_CPU_NUM_REGISTERS];
};
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;
}
/*
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;
}
/*****************************************************************************
/*****************************************************************************
* 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)
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;
}
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;
}
/*