cleaned up serial mode handling and some other minor changes
This commit is contained in:
parent
ab57c1fb2f
commit
37b1f11fa6
@ -663,10 +663,10 @@ debugger_log: -
|
|||||||
|
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
# COM1, COM2, COM3, COM4:
|
# COM1, COM2, COM3, COM4:
|
||||||
# This defines a serial port (UART type 16550A). In the 'term' you can specify
|
# This defines a serial port (UART type 16550A). In the 'term' mode you can
|
||||||
# a device to use as com1. This can be a real serial line, or a pty. To use
|
# specify a device to use as com1. This can be a real serial line, or a pty.
|
||||||
# a pty (under X/Unix), create two windows (xterms, usually). One of them will
|
# To use a pty (under X/Unix), create two windows (xterms, usually). One of
|
||||||
# run bochs, and the other will act as com1. Find out the tty the com1
|
# them will run bochs, and the other will act as com1. Find out the tty the com1
|
||||||
# window using the `tty' command, and use that as the `dev' parameter.
|
# window using the `tty' command, and use that as the `dev' parameter.
|
||||||
# Then do `sleep 1000000' in the com1 window to keep the shell from
|
# Then do `sleep 1000000' in the com1 window to keep the shell from
|
||||||
# messing with things, and run bochs in the other window. Serial I/O to
|
# messing with things, and run bochs in the other window. Serial I/O to
|
||||||
@ -677,9 +677,8 @@ debugger_log: -
|
|||||||
# opens socket/named pipe and waits until a client application connects to it
|
# opens socket/named pipe and waits until a client application connects to it
|
||||||
# before starting simulation. This mode is useful for remote debugging (e.g.
|
# before starting simulation. This mode is useful for remote debugging (e.g.
|
||||||
# with gdb's "target remote host:port" command or windbg's command line option
|
# with gdb's "target remote host:port" command or windbg's command line option
|
||||||
# -k com:pipe,port=\\.\pipe\pipename). Note: 'socket' is a shorthand for
|
# -k com:pipe,port=\\.\pipe\pipename). Socket modes use simple TCP communication,
|
||||||
# 'socket-client' and 'pipe' for 'pipe-client'. Socket modes use simple TCP
|
# pipe modes use duplex byte mode pipes.
|
||||||
# communication, pipe modes use duplex byte mode pipes.
|
|
||||||
# Other serial modes are 'null' (no input/output), 'file' (output to a file
|
# Other serial modes are 'null' (no input/output), 'file' (output to a file
|
||||||
# specified as the 'dev' parameter), 'raw' (use the real serial port - under
|
# specified as the 'dev' parameter), 'raw' (use the real serial port - under
|
||||||
# construction for win32), 'mouse' (standard serial mouse - requires
|
# construction for win32), 'mouse' (standard serial mouse - requires
|
||||||
|
@ -3861,10 +3861,8 @@ Examples:
|
|||||||
In server mode it opens socket/named pipe and waits until a client application
|
In server mode it opens socket/named pipe and waits until a client application
|
||||||
connects to it before starting simulation. This mode is useful for remote
|
connects to it before starting simulation. This mode is useful for remote
|
||||||
debugging (e.g. with gdb's "target remote host:port" command or windbg's command
|
debugging (e.g. with gdb's "target remote host:port" command or windbg's command
|
||||||
line option -k com:pipe,port=\\.\pipe\pipename).
|
line option -k com:pipe,port=\\.\pipe\pipename). Socket modes use simple TCP
|
||||||
|
communication, pipe modes use duplex byte mode pipes.
|
||||||
Note: 'socket' is a shorthand for 'socket-client', 'pipe' for 'pipe-client'.
|
|
||||||
Socket modes use simple TCP communication, pipe modes use duplex byte mode pipes.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Other serial modes are 'null' (no input/output), 'file' (output to a file
|
Other serial modes are 'null' (no input/output), 'file' (output to a file
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
|
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
|
||||||
.TH bochsrc 5 "27 Jan 2013" "bochsrc" "The Bochs Project"
|
.TH bochsrc 5 "23 Feb 2013" "bochsrc" "The Bochs Project"
|
||||||
.\"SKIP_SECTION"
|
.\"SKIP_SECTION"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
bochsrc \- Configuration file for Bochs.
|
bochsrc \- Configuration file for Bochs.
|
||||||
@ -561,7 +561,7 @@ Examples:
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.I "com1: \fP, \fIcom2: \fP, \fIcom3: \fPor \fIcom4:"
|
.I "com1: \fP, \fIcom2: \fP, \fIcom3: \fPor \fIcom4:"
|
||||||
This defines a serial port (UART type 16550A). In the 'term' you can specify
|
This defines a serial port (UART type 16550A). In the 'term' mode you can specify
|
||||||
a device to use as com1. This can be a real serial line, or a pty. To use
|
a device to use as com1. This can be a real serial line, or a pty. To use
|
||||||
a pty (under X/Unix), create two windows (xterms, usually). One of them will
|
a pty (under X/Unix), create two windows (xterms, usually). One of them will
|
||||||
run bochs, and the other will act as com1. Find out the tty the com1 window
|
run bochs, and the other will act as com1. Find out the tty the com1 window
|
||||||
|
@ -61,15 +61,13 @@ void serial_init_options(void)
|
|||||||
static const char *serial_mode_list[] = {
|
static const char *serial_mode_list[] = {
|
||||||
"null",
|
"null",
|
||||||
"file",
|
"file",
|
||||||
"pipe",
|
|
||||||
"pipe-client",
|
|
||||||
"pipe-server",
|
|
||||||
"term",
|
"term",
|
||||||
"raw",
|
"raw",
|
||||||
"mouse",
|
"mouse",
|
||||||
"socket",
|
|
||||||
"socket-client",
|
"socket-client",
|
||||||
"socket-server",
|
"socket-server",
|
||||||
|
"pipe-client",
|
||||||
|
"pipe-server",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,8 +85,8 @@ void serial_init_options(void)
|
|||||||
(i==0)?1 : 0); // only enable the first by default
|
(i==0)?1 : 0); // only enable the first by default
|
||||||
sprintf(label, "I/O mode of the serial device for COM%d", i+1);
|
sprintf(label, "I/O mode of the serial device for COM%d", i+1);
|
||||||
bx_param_enum_c *mode = new bx_param_enum_c(menu, "mode", label,
|
bx_param_enum_c *mode = new bx_param_enum_c(menu, "mode", label,
|
||||||
"The mode can be one these: 'null', 'file', 'pipe', 'term', 'raw', 'mouse', 'socket'",
|
"The mode can be one these: 'null', 'file', 'term', 'raw', 'mouse', 'socket*', 'pipe*'",
|
||||||
serial_mode_list, 0, 0);
|
serial_mode_list, BX_SER_MODE_NULL, BX_SER_MODE_NULL);
|
||||||
mode->set_ask_format("Choose I/O mode of the serial device [%s] ");
|
mode->set_ask_format("Choose I/O mode of the serial device [%s] ");
|
||||||
sprintf(label, "Pathname of the serial device for COM%d", i+1);
|
sprintf(label, "Pathname of the serial device for COM%d", i+1);
|
||||||
bx_param_filename_c *path = new bx_param_filename_c(menu, "dev", label,
|
bx_param_filename_c *path = new bx_param_filename_c(menu, "dev", label,
|
||||||
@ -212,10 +210,12 @@ bx_serial_c::~bx_serial_c(void)
|
|||||||
delete [] BX_SER_THIS s[i].raw;
|
delete [] BX_SER_THIS s[i].raw;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case BX_SER_MODE_SOCKET:
|
case BX_SER_MODE_SOCKET_CLIENT:
|
||||||
|
case BX_SER_MODE_SOCKET_SERVER:
|
||||||
if (BX_SER_THIS s[i].socket_id >= 0) closesocket(BX_SER_THIS s[i].socket_id);
|
if (BX_SER_THIS s[i].socket_id >= 0) closesocket(BX_SER_THIS s[i].socket_id);
|
||||||
break;
|
break;
|
||||||
case BX_SER_MODE_PIPE:
|
case BX_SER_MODE_PIPE_CLIENT:
|
||||||
|
case BX_SER_MODE_PIPE_SERVER:
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (BX_SER_THIS s[i].pipe)
|
if (BX_SER_THIS s[i].pipe)
|
||||||
CloseHandle(BX_SER_THIS s[i].pipe);
|
CloseHandle(BX_SER_THIS s[i].pipe);
|
||||||
@ -353,15 +353,15 @@ bx_serial_c::init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_NULL;
|
BX_SER_THIS s[i].io_mode = BX_SER_MODE_NULL;
|
||||||
const char *mode = SIM->get_param_enum("mode", base)->get_selected();
|
Bit8u mode = SIM->get_param_enum("mode", base)->get();
|
||||||
const char *dev = SIM->get_param_string("dev", base)->getptr();
|
const char *dev = SIM->get_param_string("dev", base)->getptr();
|
||||||
if (!strcmp(mode, "file")) {
|
if (mode == BX_SER_MODE_FILE) {
|
||||||
if (strlen(dev) > 0) {
|
if (strlen(dev) > 0) {
|
||||||
BX_SER_THIS s[i].output = fopen(dev, "wb");
|
BX_SER_THIS s[i].output = fopen(dev, "wb");
|
||||||
if (BX_SER_THIS s[i].output)
|
if (BX_SER_THIS s[i].output)
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_FILE;
|
BX_SER_THIS s[i].io_mode = BX_SER_MODE_FILE;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(mode, "term")) {
|
} else if (mode == BX_SER_MODE_TERM) {
|
||||||
#if defined(SERIAL_ENABLE) && !defined(WIN32)
|
#if defined(SERIAL_ENABLE) && !defined(WIN32)
|
||||||
if (strlen(dev) > 0) {
|
if (strlen(dev) > 0) {
|
||||||
BX_SER_THIS s[i].tty_id = open(dev, O_RDWR|O_NONBLOCK,600);
|
BX_SER_THIS s[i].tty_id = open(dev, O_RDWR|O_NONBLOCK,600);
|
||||||
@ -400,25 +400,26 @@ bx_serial_c::init(void)
|
|||||||
#else
|
#else
|
||||||
BX_PANIC(("serial terminal support not available"));
|
BX_PANIC(("serial terminal support not available"));
|
||||||
#endif /* def SERIAL_ENABLE */
|
#endif /* def SERIAL_ENABLE */
|
||||||
} else if (!strcmp(mode, "raw")) {
|
} else if (mode == BX_SER_MODE_RAW) {
|
||||||
#if USE_RAW_SERIAL
|
#if USE_RAW_SERIAL
|
||||||
BX_SER_THIS s[i].raw = new serial_raw(dev);
|
BX_SER_THIS s[i].raw = new serial_raw(dev);
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_RAW;
|
BX_SER_THIS s[i].io_mode = BX_SER_MODE_RAW;
|
||||||
#else
|
#else
|
||||||
BX_PANIC(("raw serial support not present"));
|
BX_PANIC(("raw serial support not present"));
|
||||||
#endif
|
#endif
|
||||||
} else if (!strcmp(mode, "mouse")) {
|
} else if (mode == BX_SER_MODE_MOUSE) {
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_MOUSE;
|
BX_SER_THIS s[i].io_mode = BX_SER_MODE_MOUSE;
|
||||||
BX_SER_THIS mouse_port = i;
|
BX_SER_THIS mouse_port = i;
|
||||||
BX_SER_THIS mouse_type = SIM->get_param_enum(BXPN_MOUSE_TYPE)->get();
|
BX_SER_THIS mouse_type = SIM->get_param_enum(BXPN_MOUSE_TYPE)->get();
|
||||||
} else if (!strncmp(mode, "socket", 6)) {
|
} else if ((mode == BX_SER_MODE_SOCKET_CLIENT) ||
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_SOCKET;
|
(mode == BX_SER_MODE_SOCKET_SERVER)) {
|
||||||
|
BX_SER_THIS s[i].io_mode = mode;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
char host[BX_PATHNAME_LEN];
|
char host[BX_PATHNAME_LEN];
|
||||||
int port;
|
int port;
|
||||||
SOCKET socket;
|
SOCKET socket;
|
||||||
bx_bool server = !strcmp(mode, "socket-server");
|
bx_bool server = (mode == BX_SER_MODE_SOCKET_SERVER);
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
static bx_bool winsock_init = false;
|
static bx_bool winsock_init = false;
|
||||||
@ -487,13 +488,14 @@ bx_serial_c::init(void)
|
|||||||
if (socket > 0)
|
if (socket > 0)
|
||||||
BX_INFO(("com%d - inet %s - socket_id: %d, ip:%s, port:%d",
|
BX_INFO(("com%d - inet %s - socket_id: %d, ip:%s, port:%d",
|
||||||
i+1, server ? "server" : "client", socket, host, port));
|
i+1, server ? "server" : "client", socket, host, port));
|
||||||
} else if (!strncmp(mode, "pipe", 4)) {
|
} else if ((mode == BX_SER_MODE_PIPE_CLIENT) ||
|
||||||
|
(mode == BX_SER_MODE_PIPE_SERVER)) {
|
||||||
if (strlen(dev) > 0) {
|
if (strlen(dev) > 0) {
|
||||||
|
bx_bool server = (mode == BX_SER_MODE_PIPE_SERVER);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
bx_bool server = !strcmp(mode, "pipe-server");
|
|
||||||
HANDLE pipe;
|
HANDLE pipe;
|
||||||
|
|
||||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_PIPE;
|
BX_SER_THIS s[i].io_mode = mode;
|
||||||
|
|
||||||
// server mode
|
// server mode
|
||||||
if (server) {
|
if (server) {
|
||||||
@ -526,11 +528,11 @@ bx_serial_c::init(void)
|
|||||||
if (pipe != INVALID_HANDLE_VALUE)
|
if (pipe != INVALID_HANDLE_VALUE)
|
||||||
BX_SER_THIS s[i].pipe = pipe;
|
BX_SER_THIS s[i].pipe = pipe;
|
||||||
#else
|
#else
|
||||||
BX_PANIC(("support for serial mode '%s' not available", mode));
|
BX_PANIC(("support for serial mode 'pipe-%s' not available", server?"server":"client"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (strcmp(mode, "null")) {
|
} else if (mode != BX_SER_MODE_NULL) {
|
||||||
BX_PANIC(("unknown serial i/o mode '%s'", mode));
|
BX_PANIC(("unknown serial i/o mode %d", mode));
|
||||||
}
|
}
|
||||||
// simulate device connected
|
// simulate device connected
|
||||||
if (BX_SER_THIS s[i].io_mode != BX_SER_MODE_RAW) {
|
if (BX_SER_THIS s[i].io_mode != BX_SER_MODE_RAW) {
|
||||||
@ -1201,8 +1203,7 @@ void bx_serial_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
|||||||
BX_SER_THIS s[port].line_status.framing_error = 1;
|
BX_SER_THIS s[port].line_status.framing_error = 1;
|
||||||
rx_fifo_enq(port, 0x00);
|
rx_fifo_enq(port, 0x00);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/* transition to normal mode */
|
/* transition to normal mode */
|
||||||
#if USE_RAW_SERIAL
|
#if USE_RAW_SERIAL
|
||||||
if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_RAW) {
|
if (BX_SER_THIS s[port].io_mode == BX_SER_MODE_RAW) {
|
||||||
@ -1269,9 +1270,7 @@ void bx_serial_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
|||||||
BX_SER_THIS s[port].raw->set_modem_control(value & 0x03);
|
BX_SER_THIS s[port].raw->set_modem_control(value & 0x03);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* simulate device connected */
|
/* simulate device connected */
|
||||||
BX_SER_THIS s[port].modem_status.cts = 1;
|
BX_SER_THIS s[port].modem_status.cts = 1;
|
||||||
BX_SER_THIS s[port].modem_status.dsr = 1;
|
BX_SER_THIS s[port].modem_status.dsr = 1;
|
||||||
@ -1397,7 +1396,8 @@ void bx_serial_c::tx_timer(void)
|
|||||||
case BX_SER_MODE_MOUSE:
|
case BX_SER_MODE_MOUSE:
|
||||||
BX_INFO(("com%d: write to mouse ignored: 0x%02x", port+1, BX_SER_THIS s[port].tsrbuffer));
|
BX_INFO(("com%d: write to mouse ignored: 0x%02x", port+1, BX_SER_THIS s[port].tsrbuffer));
|
||||||
break;
|
break;
|
||||||
case BX_SER_MODE_SOCKET:
|
case BX_SER_MODE_SOCKET_CLIENT:
|
||||||
|
case BX_SER_MODE_SOCKET_SERVER:
|
||||||
if (BX_SER_THIS s[port].socket_id >= 0) {
|
if (BX_SER_THIS s[port].socket_id >= 0) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
BX_INFO(("attempting to write win32 : %c", BX_SER_THIS s[port].tsrbuffer));
|
BX_INFO(("attempting to write win32 : %c", BX_SER_THIS s[port].tsrbuffer));
|
||||||
@ -1408,7 +1408,9 @@ void bx_serial_c::tx_timer(void)
|
|||||||
(bx_ptr_t) & BX_SER_THIS s[port].tsrbuffer, 1);
|
(bx_ptr_t) & BX_SER_THIS s[port].tsrbuffer, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
case BX_SER_MODE_PIPE:
|
break;
|
||||||
|
case BX_SER_MODE_PIPE_CLIENT:
|
||||||
|
case BX_SER_MODE_PIPE_SERVER:
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (BX_SER_THIS s[port].pipe) {
|
if (BX_SER_THIS s[port].pipe) {
|
||||||
DWORD written;
|
DWORD written;
|
||||||
@ -1490,7 +1492,8 @@ void bx_serial_c::rx_timer(void)
|
|||||||
if ((BX_SER_THIS s[port].line_status.rxdata_ready == 0) ||
|
if ((BX_SER_THIS s[port].line_status.rxdata_ready == 0) ||
|
||||||
(BX_SER_THIS s[port].fifo_cntl.enable)) {
|
(BX_SER_THIS s[port].fifo_cntl.enable)) {
|
||||||
switch (BX_SER_THIS s[port].io_mode) {
|
switch (BX_SER_THIS s[port].io_mode) {
|
||||||
case BX_SER_MODE_SOCKET:
|
case BX_SER_MODE_SOCKET_CLIENT:
|
||||||
|
case BX_SER_MODE_SOCKET_SERVER:
|
||||||
#if BX_HAVE_SELECT && defined(SERIAL_ENABLE)
|
#if BX_HAVE_SELECT && defined(SERIAL_ENABLE)
|
||||||
if (BX_SER_THIS s[port].line_status.rxdata_ready == 0) {
|
if (BX_SER_THIS s[port].line_status.rxdata_ready == 0) {
|
||||||
tval.tv_sec = 0;
|
tval.tv_sec = 0;
|
||||||
@ -1573,7 +1576,8 @@ void bx_serial_c::rx_timer(void)
|
|||||||
data_ready = 1;
|
data_ready = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BX_SER_MODE_PIPE:
|
case BX_SER_MODE_PIPE_CLIENT:
|
||||||
|
case BX_SER_MODE_PIPE_SERVER:
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
DWORD avail = 0;
|
DWORD avail = 0;
|
||||||
if (BX_SER_THIS s[port].pipe &&
|
if (BX_SER_THIS s[port].pipe &&
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2004-2009 The Bochs Project
|
// Copyright (C) 2004-2013 The Bochs Project
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -68,8 +68,10 @@ extern "C" {
|
|||||||
#define BX_SER_MODE_TERM 2
|
#define BX_SER_MODE_TERM 2
|
||||||
#define BX_SER_MODE_RAW 3
|
#define BX_SER_MODE_RAW 3
|
||||||
#define BX_SER_MODE_MOUSE 4
|
#define BX_SER_MODE_MOUSE 4
|
||||||
#define BX_SER_MODE_SOCKET 5
|
#define BX_SER_MODE_SOCKET_CLIENT 5
|
||||||
#define BX_SER_MODE_PIPE 6
|
#define BX_SER_MODE_SOCKET_SERVER 6
|
||||||
|
#define BX_SER_MODE_PIPE_CLIENT 7
|
||||||
|
#define BX_SER_MODE_PIPE_SERVER 8
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BX_SER_INT_IER,
|
BX_SER_INT_IER,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2004 The Bochs Project
|
// Copyright (C) 2004-2013 The Bochs Project
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -107,7 +107,7 @@ serial_raw::~serial_raw(void)
|
|||||||
|
|
||||||
void serial_raw::set_baudrate(int rate)
|
void serial_raw::set_baudrate(int rate)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set_baudrate %d", rate));
|
BX_DEBUG(("set_baudrate %d", rate));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
switch (rate) {
|
switch (rate) {
|
||||||
case 110: dcb.BaudRate = CBR_110; break;
|
case 110: dcb.BaudRate = CBR_110; break;
|
||||||
@ -129,7 +129,7 @@ void serial_raw::set_baudrate(int rate)
|
|||||||
|
|
||||||
void serial_raw::set_data_bits(int val)
|
void serial_raw::set_data_bits(int val)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set data bits (%d)", val));
|
BX_DEBUG(("set data bits (%d)", val));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
dcb.ByteSize = val;
|
dcb.ByteSize = val;
|
||||||
DCBchanged = TRUE;
|
DCBchanged = TRUE;
|
||||||
@ -138,7 +138,7 @@ void serial_raw::set_data_bits(int val)
|
|||||||
|
|
||||||
void serial_raw::set_stop_bits(int val)
|
void serial_raw::set_stop_bits(int val)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set stop bits (%d)", val));
|
BX_DEBUG(("set stop bits (%d)", val));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (val == 1) {
|
if (val == 1) {
|
||||||
dcb.StopBits = ONESTOPBIT;
|
dcb.StopBits = ONESTOPBIT;
|
||||||
@ -153,26 +153,26 @@ void serial_raw::set_stop_bits(int val)
|
|||||||
|
|
||||||
void serial_raw::set_parity_mode(int mode)
|
void serial_raw::set_parity_mode(int mode)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set parity mode %d", mode));
|
BX_DEBUG(("set parity mode %d", mode));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0:
|
case P_NONE:
|
||||||
dcb.fParity = FALSE;
|
dcb.fParity = FALSE;
|
||||||
dcb.Parity = NOPARITY;
|
dcb.Parity = NOPARITY;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case P_ODD:
|
||||||
dcb.fParity = TRUE;
|
dcb.fParity = TRUE;
|
||||||
dcb.Parity = ODDPARITY;
|
dcb.Parity = ODDPARITY;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case P_EVEN:
|
||||||
dcb.fParity = TRUE;
|
dcb.fParity = TRUE;
|
||||||
dcb.Parity = EVENPARITY;
|
dcb.Parity = EVENPARITY;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case P_HIGH:
|
||||||
dcb.fParity = TRUE;
|
dcb.fParity = TRUE;
|
||||||
dcb.Parity = MARKPARITY;
|
dcb.Parity = MARKPARITY;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case P_LOW:
|
||||||
dcb.fParity = TRUE;
|
dcb.fParity = TRUE;
|
||||||
dcb.Parity = SPACEPARITY;
|
dcb.Parity = SPACEPARITY;
|
||||||
break;
|
break;
|
||||||
@ -183,7 +183,7 @@ void serial_raw::set_parity_mode(int mode)
|
|||||||
|
|
||||||
void serial_raw::set_break(int mode)
|
void serial_raw::set_break(int mode)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set break %s", mode?"on":"off"));
|
BX_DEBUG(("set break %s", mode?"on":"off"));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (mode) {
|
if (mode) {
|
||||||
SetCommBreak(hCOM);
|
SetCommBreak(hCOM);
|
||||||
@ -195,7 +195,7 @@ void serial_raw::set_break(int mode)
|
|||||||
|
|
||||||
void serial_raw::set_modem_control(int ctrl)
|
void serial_raw::set_modem_control(int ctrl)
|
||||||
{
|
{
|
||||||
BX_DEBUG (("set modem control 0x%02x", ctrl));
|
BX_DEBUG(("set modem control 0x%02x", ctrl));
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
EscapeCommFunction(hCOM, (ctrl & 0x01)?SETDTR:CLRDTR);
|
EscapeCommFunction(hCOM, (ctrl & 0x01)?SETDTR:CLRDTR);
|
||||||
EscapeCommFunction(hCOM, (ctrl & 0x02)?SETRTS:CLRRTS);
|
EscapeCommFunction(hCOM, (ctrl & 0x02)?SETRTS:CLRRTS);
|
||||||
@ -209,7 +209,7 @@ int serial_raw::get_modem_status()
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
status = MSR_value;
|
status = MSR_value;
|
||||||
#endif
|
#endif
|
||||||
BX_DEBUG (("get modem status returns 0x%02x", status));
|
BX_DEBUG(("get modem status returns 0x%02x", status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ void serial_raw::transmit(Bit8u byte)
|
|||||||
OVERLAPPED tx_ovl;
|
OVERLAPPED tx_ovl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BX_DEBUG (("transmit %d", byte));
|
BX_DEBUG(("transmit %d", byte));
|
||||||
if (present) {
|
if (present) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (DCBchanged) {
|
if (DCBchanged) {
|
||||||
@ -265,7 +265,7 @@ void serial_raw::transmit(Bit8u byte)
|
|||||||
|
|
||||||
bx_bool serial_raw::ready_transmit()
|
bx_bool serial_raw::ready_transmit()
|
||||||
{
|
{
|
||||||
BX_DEBUG (("ready_transmit returning %d", present));
|
BX_DEBUG(("ready_transmit returning %d", present));
|
||||||
return present;
|
return present;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ bx_bool serial_raw::ready_receive()
|
|||||||
SetEvent(rx_ovl.hEvent);
|
SetEvent(rx_ovl.hEvent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
BX_DEBUG (("ready_receive returning %d", (rxdata_count > 0)));
|
BX_DEBUG(("ready_receive returning %d", (rxdata_count > 0)));
|
||||||
return (rxdata_count > 0);
|
return (rxdata_count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,11 +327,11 @@ int serial_raw::receive()
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
#else
|
#else
|
||||||
BX_DEBUG (("receive returning 'A'"));
|
BX_DEBUG(("receive returning 'A'"));
|
||||||
return (int)'A';
|
return (int)'A';
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
BX_DEBUG (("receive returning 'A'"));
|
BX_DEBUG(("receive returning 'A'"));
|
||||||
return (int)'A';
|
return (int)'A';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2004 The Bochs Project
|
// Copyright (C) 2004-2013 The Bochs Project
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -56,8 +56,8 @@ public:
|
|||||||
serial_raw(const char *devname);
|
serial_raw(const char *devname);
|
||||||
virtual ~serial_raw();
|
virtual ~serial_raw();
|
||||||
void set_baudrate(int rate);
|
void set_baudrate(int rate);
|
||||||
void set_data_bits(int);
|
void set_data_bits(int val);
|
||||||
void set_stop_bits(int);
|
void set_stop_bits(int val);
|
||||||
void set_parity_mode(int mode);
|
void set_parity_mode(int mode);
|
||||||
void set_break(int mode);
|
void set_break(int mode);
|
||||||
void set_modem_control(int ctrl);
|
void set_modem_control(int ctrl);
|
||||||
@ -65,7 +65,7 @@ public:
|
|||||||
void transmit(Bit8u byte);
|
void transmit(Bit8u byte);
|
||||||
bx_bool ready_transmit();
|
bx_bool ready_transmit();
|
||||||
bx_bool ready_receive();
|
bx_bool ready_receive();
|
||||||
int receive ();
|
int receive();
|
||||||
#ifdef WIN32_RECEIVE_RAW
|
#ifdef WIN32_RECEIVE_RAW
|
||||||
void serial_thread();
|
void serial_thread();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user