Serial 'file' mode: added support for changing output file at runtime.
This commit is contained in:
parent
c1c158c0a2
commit
ccdcb9cd1b
@ -838,9 +838,10 @@ debugger_log: -
|
||||
# -k com:pipe,port=\\.\pipe\pipename). Socket modes use simple TCP communication,
|
||||
# pipe modes use duplex byte mode pipes.
|
||||
# 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
|
||||
# construction for win32), 'mouse' (standard serial mouse - requires
|
||||
# mouse option setting 'type=serial', 'type=serial_wheel' or 'type=serial_msys').
|
||||
# specified as the 'dev' parameter and changeable at runtime), 'raw' (use the
|
||||
# real serial port - partly implemented on win32), 'mouse' (standard serial
|
||||
# mouse - requires mouse option setting 'type=serial', 'type=serial_wheel' or
|
||||
# 'type=serial_msys').
|
||||
#
|
||||
# Examples:
|
||||
# com1: enabled=1, mode=null
|
||||
@ -861,7 +862,7 @@ debugger_log: -
|
||||
# defined the emulated printer port sends characters printed by the guest OS
|
||||
# into the output file. On some platforms a device filename can be used to
|
||||
# send the data to the real parallel port (e.g. "/dev/lp0" on Linux, "lpt1" on
|
||||
# win32 platforms).
|
||||
# win32 platforms). The output file can be changed at runtime.
|
||||
#
|
||||
# Examples:
|
||||
# parport1: enabled=1, file="parport.out"
|
||||
|
@ -30,7 +30,7 @@ Changes after 2.6.8 release:
|
||||
emulation code. (patch by Ben Lunt).
|
||||
- Hard drive
|
||||
- Several fixes in some disk image modes.
|
||||
- Parallel port
|
||||
- Serial / Parallel ports
|
||||
- Added support for changing output file at runtime.
|
||||
- Sound
|
||||
- Added separate thread for the PCM data conversion.
|
||||
|
@ -4362,10 +4362,10 @@ Examples:
|
||||
</para>
|
||||
<para>
|
||||
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
|
||||
construction for win32), 'mouse' (standard serial mouse - requires
|
||||
<link linkend="bochsopt-mouse">mouse option</link> setting 'type=serial'
|
||||
or 'type=serial_wheel').
|
||||
specified as the 'dev' parameter and changeable at runtime), 'raw' (use the
|
||||
real serial port - partly implemented on win32), 'mouse' (standard serial
|
||||
mouse - requires <link linkend="bochsopt-mouse">mouse option</link> setting
|
||||
'type=serial', 'type=serial_wheel' or 'type=serial_msys').
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@ -4382,7 +4382,7 @@ This defines a parallel (printer) port. When turned on and an output file is
|
||||
defined, the emulated printer port sends characters printed by the guest OS
|
||||
into the output file. On some platforms, a device filename can be used to
|
||||
send the data to the real parallel port (e.g. "/dev/lp0" on Linux, "lpt1" on
|
||||
win32 platforms).
|
||||
win32 platforms). The output file can be changed at runtime.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
|
||||
.TH bochsrc 5 "28 Dec 2016" "bochsrc" "The Bochs Project"
|
||||
.TH bochsrc 5 "27 Jan 2017" "bochsrc" "The Bochs Project"
|
||||
.\"SKIP_SECTION"
|
||||
.SH NAME
|
||||
bochsrc \- Configuration file for Bochs.
|
||||
@ -905,10 +905,20 @@ using the `tty' command, and use that as the `dev' parameter. Then do
|
||||
and run bochs in the other window. Serial I/O to com1 (port 0x3f8) will all
|
||||
go to the other window.
|
||||
|
||||
In socket* and pipe* (win32 only) modes Bochs becomes either socket/named pipe
|
||||
client or server. In client mode it connects to an already running server (if
|
||||
connection fails Bochs treats com port as not connected). 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 debugging (e.g.
|
||||
with gdb's "target remote host:port" command or windbg's command line option
|
||||
-k com:pipe,port=\\.\pipe\pipename). Socket modes use simple TCP communication,
|
||||
pipe modes use duplex byte mode pipes.
|
||||
|
||||
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
|
||||
construction for win32) and 'mouse' (standard serial mouse - requires
|
||||
mouse option setting 'type=serial' or 'type=serial_wheel')
|
||||
specified as the 'dev' parameter and changeable at runtime), 'raw' (use the
|
||||
real serial port - partly implemented on win32) and 'mouse' (standard serial
|
||||
mouse - requires mouse option setting 'type=serial', 'type=serial_wheel'
|
||||
or 'type=serial_msys')
|
||||
|
||||
Examples:
|
||||
com1: enabled=1, mode=term, dev=/dev/ttyp7
|
||||
@ -920,7 +930,8 @@ Examples:
|
||||
This defines a parallel (printer) port. When turned on and an output file is
|
||||
defined the emulated printer port sends characters printed by the guest
|
||||
OS into the output file. On some platforms a device filename can be used to
|
||||
send the data to the real parallel port (e.g. "/dev/lp0" on Linux).
|
||||
send the data to the real parallel port (e.g. "/dev/lp0" on Linux). The
|
||||
output file can be changed at runtime.
|
||||
|
||||
Examples:
|
||||
parport1: enabled=1, file=parport.out
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001-2015 The Bochs Project
|
||||
// Copyright (C) 2001-2017 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -230,6 +230,8 @@ bx_serial_c::~bx_serial_c(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
bx_list_c *misc_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_MISC);
|
||||
misc_rt->remove("serial");
|
||||
SIM->get_bochs_root()->remove("serial");
|
||||
BX_DEBUG(("Exit"));
|
||||
}
|
||||
@ -240,7 +242,7 @@ bx_serial_c::init(void)
|
||||
{
|
||||
Bit16u ports[BX_SERIAL_MAXDEV] = {0x03f8, 0x02f8, 0x03e8, 0x02e8};
|
||||
char name[16], pname[20];
|
||||
bx_list_c *base;
|
||||
bx_list_c *base, *misc_rt = NULL, *menu = NULL;
|
||||
unsigned i, count = 0;
|
||||
|
||||
BX_SER_THIS detect_mouse = 0;
|
||||
@ -371,16 +373,24 @@ bx_serial_c::init(void)
|
||||
|
||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_NULL;
|
||||
Bit8u mode = SIM->get_param_enum("mode", base)->get();
|
||||
bx_param_string_c *devparam = SIM->get_param_string("dev", base);
|
||||
const char *dev = devparam->getptr();
|
||||
BX_SER_THIS s[i].file = SIM->get_param_string("dev", base);
|
||||
const char *dev = BX_SER_THIS s[i].file->getptr();
|
||||
if (mode == BX_SER_MODE_FILE) {
|
||||
if (!devparam->isempty()) {
|
||||
if (!BX_SER_THIS s[i].file->isempty()) {
|
||||
// tx_timer() opens the output file on demand
|
||||
BX_SER_THIS s[i].io_mode = BX_SER_MODE_FILE;
|
||||
BX_SER_THIS s[i].file->set_handler(serial_file_param_handler);
|
||||
// init runtime parameters
|
||||
if (misc_rt == NULL) {
|
||||
misc_rt = (bx_list_c*)SIM->get_param(BXPN_MENU_RUNTIME_MISC);
|
||||
menu = new bx_list_c(misc_rt, "serial", "Serial Port Runtime Options");
|
||||
menu->set_options(menu->SHOW_PARENT | menu->USE_BOX_TITLE);
|
||||
}
|
||||
menu->add(BX_SER_THIS s[i].file);
|
||||
}
|
||||
} else if (mode == BX_SER_MODE_TERM) {
|
||||
#if defined(SERIAL_ENABLE) && !defined(BX_SER_WIN32)
|
||||
if (!devparam->isempty()) {
|
||||
if (!BX_SER_THIS s[i].file->isempty()) {
|
||||
BX_SER_THIS s[i].tty_id = open(dev, O_RDWR|O_NONBLOCK,600);
|
||||
if (BX_SER_THIS s[i].tty_id < 0) {
|
||||
BX_PANIC(("open of com%d (%s) failed", i+1, dev));
|
||||
@ -1399,20 +1409,16 @@ void bx_serial_c::tx_timer(void)
|
||||
{
|
||||
bx_bool gen_int = 0;
|
||||
Bit8u port = (Bit8u)bx_pc_system.triggeredTimerParam();
|
||||
char pname[20];
|
||||
|
||||
switch (BX_SER_THIS s[port].io_mode) {
|
||||
case BX_SER_MODE_FILE:
|
||||
if (BX_SER_THIS s[port].output == NULL) {
|
||||
sprintf(pname, "ports.serial.%d", port+1);
|
||||
bx_list_c *base = (bx_list_c*) SIM->get_param(pname);
|
||||
bx_param_string_c *devparam = SIM->get_param_string("dev", base);
|
||||
if (!devparam->isempty()) {
|
||||
BX_SER_THIS s[port].output = fopen(devparam->getptr(), "wb");
|
||||
if (!BX_SER_THIS s[port].file->isempty()) {
|
||||
BX_SER_THIS s[port].output = fopen(BX_SER_THIS s[port].file->getptr(), "wb");
|
||||
}
|
||||
if (BX_SER_THIS s[port].output == NULL) {
|
||||
BX_ERROR(("Could not open '%s' to write com%d output",
|
||||
devparam->getptr(), port+1));
|
||||
BX_SER_THIS s[port].file->getptr(), port+1));
|
||||
BX_SER_THIS s[port].io_mode = BX_SER_MODE_NULL;
|
||||
}
|
||||
}
|
||||
@ -1748,3 +1754,18 @@ void bx_serial_c::update_mouse_data()
|
||||
}
|
||||
BX_SER_THIS mouse_update = 0;
|
||||
}
|
||||
|
||||
const char* bx_serial_c::serial_file_param_handler(bx_param_string_c *param, int set,
|
||||
const char *oldval, const char *val,
|
||||
int maxlen)
|
||||
{
|
||||
if ((set) && (strcmp(val, oldval))) {
|
||||
int port = atoi((param->get_parent())->get_name()) - 1;
|
||||
if (BX_SER_THIS s[port].output != NULL) {
|
||||
fclose(BX_SER_THIS s[port].output);
|
||||
BX_SER_THIS s[port].output = NULL;
|
||||
}
|
||||
// tx_timer() re-opens the output file on demand
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001-2014 The Bochs Project
|
||||
// Copyright (C) 2001-2017 The Bochs Project
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
@ -116,6 +116,7 @@ typedef struct {
|
||||
int tty_id;
|
||||
SOCKET socket_id;
|
||||
FILE *output;
|
||||
bx_param_string_c *file;
|
||||
#ifdef BX_SER_WIN32
|
||||
HANDLE pipe;
|
||||
#endif
|
||||
@ -249,6 +250,9 @@ private:
|
||||
Bit32u read(Bit32u address, unsigned io_len);
|
||||
void write(Bit32u address, Bit32u value, unsigned io_len);
|
||||
#endif
|
||||
static const char* serial_file_param_handler(bx_param_string_c *param, int set,
|
||||
const char *oldval, const char *val,
|
||||
int maxlen);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user