- parport1 enable/disable support added. Now you can control the presence of

parport1 with the new option "enabled". The old option "enable" only
  controlled the output. The parport1 is enabled with no output by default.
  Changes:
  * bochrc option "enable" replaced by "enabled"
  * parport option "Oenable" replaced by "Opresent"
  * bx_parport_options par1 and par2 replaced by an array par[2]
  * initialize parport1 resources only when enabled
  * renamed variable "parport_init_list" to "par_ser_init_list" since it
    contains parport and serial options
  * documentation and bochsrc updates
- the parport variables "output" and "initmode" now belong to the bx_par_t
  structure
- TODO: add parport2 (disabled by default), parport detection in the bios
This commit is contained in:
Volker Ruppert 2002-08-24 10:20:35 +00:00
parent eb0e95f54d
commit 56952f9132
8 changed files with 104 additions and 98 deletions

View File

@ -227,14 +227,18 @@ debug: action=ignore
#=======================================================================
# PARPORT1:
# This defines a parallel (printer) port. When turned on, the emulated
# printer port sends characters printed by the guest OS into an output file.
# 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).
#
# Examples:
# parport1: enable=1, file="parport.out"
# parport1: enable=0
# parport1: enabled=1, file="parport.out"
# parport1: enabled=1, file="/dev/lp0"
# parport1: enabled=0
#=======================================================================
parport1: enable=0
parport1: enabled=1, file="parport.out"
#=======================================================================
# SB16:

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.77 2002-08-22 22:38:40 cbothamy Exp $
// $Id: bochs.h,v 1.78 2002-08-24 10:20:34 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -556,7 +556,7 @@ typedef struct {
} bx_mem_options;
typedef struct {
bx_param_bool_c *Oenable;
bx_param_bool_c *Opresent;
bx_param_string_c *Ooutfile;
} bx_parport_options;
@ -638,8 +638,7 @@ typedef struct {
bx_vgarom_options vgarom;
bx_rom_options optrom[4]; // Optional rom images
bx_mem_options memory;
bx_parport_options par1; // parallel port #1
bx_parport_options par2; // parallel port #2 (not implemented)
bx_parport_options par[2]; // parallel port #1 / #2
bx_sb16_options sb16;
bx_param_num_c *Obootdrive;
bx_param_bool_c *OfloppySigCheck;

View File

@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.44 2002-08-13 13:50:54 vruppert Exp $
$Id: user.dbk,v 1.45 2002-08-24 10:20:34 vruppert Exp $
This is the top level file for the Bochs Users Manual.
================================================================
@ -2498,14 +2498,18 @@ com1: dev=/dev/cua0
<section><title>parport1</title>
<para>
This defines a parallel (printer) port. When turned on, the emulated
printer port sends characters printed by the guest OS into an output file.
This defines a parallel (printer) port. When turned on and an output file is
defined 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).
</para>
<para>
Examples:
<screen>
parport1: enable=1, file="parport.out"
parport1: enable=0
parport1: enabled=1, file="parport.out"
parport1: enabled=1, file="/dev/lp0"
parport1: enabled=0
</screen>
</para>
</section>

View File

@ -113,12 +113,15 @@ Example:
.TP
.I "parport1:"
Point this to the pathname of an output file or device.
When turned on, the emulated printer port sends characters
printed by the guest OS into an output file.
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).
Example:
parport1: enable=1, file=parport.out
Examples:
parport1: enabled=1, file=parport.out
parport1: enabled=1, file="/dev/lp0"
parport1: enabled=0
.TP
.I "cdromd:"

View File

@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.43 2002-08-09 06:16:43 vruppert Exp $
// $Id: siminterface.h,v 1.44 2002-08-24 10:20:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
/*
* gui/siminterface.h
* $Id: siminterface.h,v 1.43 2002-08-09 06:16:43 vruppert Exp $
* $Id: siminterface.h,v 1.44 2002-08-24 10:20:35 vruppert Exp $
*
* Interface to the simulator, currently only used by control.cc.
* The base class bx_simulator_interface_c, contains only virtual functions
@ -151,9 +151,9 @@ typedef enum {
BXP_SB16_LOGLEVEL,
BXP_SB16_DMATIMER,
BXP_SB16,
BXP_PARPORT1_ENABLE,
BXP_PARPORT1_PRESENT,
BXP_PARPORT1_OUTFILE,
BXP_PARPORT2_ENABLE,
BXP_PARPORT2_PRESENT,
BXP_PARPORT2_OUTFILE,
BXP_KEYBOARD_USEMAPPING,
BXP_KEYBOARD_MAP,

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: parallel.cc,v 1.17 2002-01-29 17:20:11 vruppert Exp $
// $Id: parallel.cc,v 1.18 2002-08-24 10:20:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -32,7 +32,7 @@
#include "bochs.h"
#define LOG_THIS bx_parallel.
#define OUTPUT (BX_PAR_THIS output)
#define OUTPUT (BX_PAR_THIS s.output)
bx_parallel_c bx_parallel;
@ -58,40 +58,43 @@ bx_parallel_c::~bx_parallel_c(void)
void
bx_parallel_c::init(bx_devices_c *d)
{
BX_DEBUG(("Init $Id: parallel.cc,v 1.17 2002-01-29 17:20:11 vruppert Exp $"));
BX_DEBUG(("Init $Id: parallel.cc,v 1.18 2002-08-24 10:20:35 vruppert Exp $"));
BX_PAR_THIS devices = d;
/* PARALLEL PORT 1 */
if (bx_options.par[0].Opresent->get ()) {
BX_PAR_THIS devices->register_irq(7, "Parallel Port 1");
for (unsigned addr=0x0378; addr<=0x037A; addr++) {
BX_PAR_THIS devices->register_io_read_handler(this,
read_handler, addr, "Parallel Port 1");
/* PARALLEL PORT 1 */
BX_PAR_THIS devices->register_irq(7, "Parallel Port 1");
for (unsigned addr=0x0378; addr<=0x037A; addr++) {
BX_PAR_THIS devices->register_io_read_handler(this,
read_handler, addr, "Parallel Port 1");
}
BX_PAR_THIS devices->register_io_write_handler(this,
write_handler, 0x0378, "Parallel Port 1");
BX_PAR_THIS devices->register_io_write_handler(this,
write_handler, 0x037A, "Parallel Port 1");
BX_PAR_THIS s.STATUS.error = 1;
BX_PAR_THIS s.STATUS.slct = 1;
BX_PAR_THIS s.STATUS.pe = 0;
BX_PAR_THIS s.STATUS.ack = 1;
BX_PAR_THIS s.STATUS.busy = 1;
BX_PAR_THIS s.CONTROL.strobe = 0;
BX_PAR_THIS s.CONTROL.autofeed = 0;
BX_PAR_THIS s.CONTROL.init = 1;
BX_PAR_THIS s.CONTROL.slct_in = 1;
BX_PAR_THIS s.CONTROL.irq = 0;
BX_PAR_THIS s.CONTROL.input = 0;
BX_PAR_THIS s.initmode = 0;
if (strlen(bx_options.par[0].Ooutfile->getptr ()) > 0) {
OUTPUT = fopen(bx_options.par[0].Ooutfile->getptr (), "wb");
if (!OUTPUT)
BX_PANIC (("Could not open '%s' to write parport1 output"));
}
BX_PAR_THIS devices->register_io_write_handler(this,
write_handler, 0x0378, "Parallel Port 1");
BX_PAR_THIS devices->register_io_write_handler(this,
write_handler, 0x037A, "Parallel Port 1");
BX_PAR_THIS s.STATUS.error = 1;
BX_PAR_THIS s.STATUS.slct = 1;
BX_PAR_THIS s.STATUS.pe = 0;
BX_PAR_THIS s.STATUS.ack = 1;
BX_PAR_THIS s.STATUS.busy = 1;
BX_PAR_THIS s.CONTROL.strobe = 0;
BX_PAR_THIS s.CONTROL.autofeed = 0;
BX_PAR_THIS s.CONTROL.init = 1;
BX_PAR_THIS s.CONTROL.slct_in = 1;
BX_PAR_THIS s.CONTROL.irq = 0;
BX_PAR_THIS s.CONTROL.input = 0;
BX_PAR_THIS initmode = 0;
if (bx_options.par1.Oenable->get ()) {
OUTPUT = fopen(bx_options.par1.Ooutfile->getptr (), "wb");
if (!OUTPUT)
BX_PANIC (("Could not open '%s' to write parport1 output"));
}
}
@ -160,10 +163,10 @@ bx_parallel_c::read(Bit32u address, unsigned io_len)
BX_PAR_THIS devices->pic->lower_irq(7);
}
}
if (BX_PAR_THIS initmode == 1) {
if (BX_PAR_THIS s.initmode == 1) {
BX_PAR_THIS s.STATUS.busy = 1;
BX_PAR_THIS s.STATUS.slct = 1;
BX_PAR_THIS initmode = 0;
BX_PAR_THIS s.initmode = 0;
}
BX_DEBUG(("read: status register returns 0x%02x", retval));
return retval;
@ -231,7 +234,7 @@ bx_parallel_c::write(Bit32u address, Bit32u value, unsigned io_len)
BX_PAR_THIS s.CONTROL.init = 1;
BX_PAR_THIS s.STATUS.busy = 0;
BX_PAR_THIS s.STATUS.slct = 0;
BX_PAR_THIS initmode = 1;
BX_PAR_THIS s.initmode = 1;
BX_DEBUG(("printer init requested"));
}
} else {

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: parallel.h,v 1.7 2001-12-18 21:58:59 vruppert Exp $
// $Id: parallel.h,v 1.8 2002-08-24 10:20:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -50,6 +50,8 @@ typedef struct {
Boolean irq;
Boolean input;
} CONTROL;
FILE *output;
Boolean initmode;
} bx_par_t;
@ -62,10 +64,6 @@ public:
BX_PAR_SMF void init(bx_devices_c *);
private:
FILE *output;
Boolean initmode;
bx_par_t s;
bx_devices_c *devices;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.114 2002-08-22 22:38:40 cbothamy Exp $
// $Id: main.cc,v 1.115 2002-08-24 10:20:34 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -82,8 +82,7 @@ bx_options_t bx_options = {
{ NULL }, // vgarom
{{ NULL, NULL }, { NULL, NULL }, { NULL, NULL }, { NULL, NULL }}, // optrom[4]
{ NULL }, // memory
{ 0, NULL }, // parallel port 1
{ 0, NULL }, // parallel port 2
{{ 0, NULL }, { 0, NULL }}, // parallel port 1 + 2
{ 0, NULL, NULL, NULL, 0, 0, 0, 0 }, // SB16
NULL, // boot drive
NULL, // boot signature check
@ -132,10 +131,10 @@ bx_param_handler (bx_param_c *param, int set, Bit32s val)
bx_keyboard.mouse_enabled_changed (val!=0);
}
break;
case BXP_PARPORT1_ENABLE:
case BXP_PARPORT1_PRESENT:
SIM->get_param (BXP_PARPORT1_OUTFILE)->set_enabled (val!=0);
break;
case BXP_PARPORT2_ENABLE:
case BXP_PARPORT2_PRESENT:
SIM->get_param (BXP_PARPORT2_OUTFILE)->set_enabled (val!=0);
break;
case BXP_COM1_PRESENT:
@ -640,31 +639,31 @@ void bx_init_options ()
bx_options.memory.Osize->set_format ("Memory size in megabytes: %d");
bx_options.memory.Osize->set_ask_format ("Enter memory size (MB): [%d] ");
bx_options.par1.Oenable = new bx_param_bool_c (BXP_PARPORT1_ENABLE,
bx_options.par[0].Opresent = new bx_param_bool_c (BXP_PARPORT1_PRESENT,
"Enable parallel port #1",
"Enables the first parallel port",
0);
bx_options.par1.Oenable->set_handler (bx_param_handler);
bx_options.par1.Ooutfile = new bx_param_filename_c (BXP_PARPORT1_OUTFILE,
1);
bx_options.par[0].Opresent->set_handler (bx_param_handler);
bx_options.par[0].Ooutfile = new bx_param_filename_c (BXP_PARPORT1_OUTFILE,
"Parallel port #1 output file",
"Data written to parport#1 by the guest OS is written to this file",
"parport.out", BX_PATHNAME_LEN);
"", BX_PATHNAME_LEN);
#if 0
bx_options.par2.Oenable = new bx_param_bool_c (BXP_PARPORT2_ENABLE,
bx_options.par[1].Opresent = new bx_param_bool_c (BXP_PARPORT2_PRESENT,
"Enable parallel port #2",
"Enables the second parallel port",
0);
bx_options.par2.Oenable->set_handler (bx_param_handler);
bx_options.par2.Ooutfile = new bx_param_filename_c (BXP_PARPORT2_OUTFILE,
bx_options.par[1].Opresent->set_handler (bx_param_handler);
bx_options.par[1].Ooutfile = new bx_param_filename_c (BXP_PARPORT2_OUTFILE,
"Parallel port #2 output file",
"Data written to parport#2 by the guest OS is written to this file",
"parport2.out", BX_PATHNAME_LEN);
"", BX_PATHNAME_LEN);
#endif
bx_param_c *parport_init_list[] = {
bx_options.par1.Oenable,
bx_options.par1.Ooutfile,
//bx_options.par2.Oenable,
//bx_options.par2.Ooutfile,
bx_param_c *par_ser_init_list[] = {
bx_options.par[0].Opresent,
bx_options.par[0].Ooutfile,
//bx_options.par[1].Opresent,
//bx_options.par[1].Ooutfile,
bx_options.com1.Opresent,
bx_options.com1.Odev,
//bx_options.com2.Opresent,
@ -675,7 +674,7 @@ void bx_init_options ()
//bx_options.com4.Odev,
NULL
};
menu = new bx_list_c (BXP_MENU_SERIAL_PARALLEL, "Serial and Parallel Port Options", "serial_parallel_menu", parport_init_list);
menu = new bx_list_c (BXP_MENU_SERIAL_PARALLEL, "Serial and Parallel Port Options", "serial_parallel_menu", par_ser_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
bx_options.rom.Opath = new bx_param_filename_c (BXP_ROM_PATH,
@ -2190,11 +2189,11 @@ parse_line_formatted(char *context, int num_params, char *params[])
else if (!strcmp(params[0], "parport1")) {
for (i=1; i<num_params; i++) {
if (!strncmp(params[i], "enable=", 7)) {
bx_options.par1.Oenable->set (atol(&params[i][7]));
if (!strncmp(params[i], "enabled=", 8)) {
bx_options.par[0].Opresent->set (atol(&params[i][8]));
}
else if (!strncmp(params[i], "file=", 5)) {
bx_options.par1.Ooutfile->set (strdup(&params[i][5]));
bx_options.par[0].Ooutfile->set (strdup(&params[i][5]));
}
}
}
@ -2202,11 +2201,11 @@ parse_line_formatted(char *context, int num_params, char *params[])
#if 0
else if (!strcmp(params[0], "parport2")) {
for (i=1; i<num_params; i++) {
if (!strncmp(params[i], "enable=", 7)) {
bx_options.par1.Oenable->set (atol(&params[i][7]));
if (!strncmp(params[i], "enabled=", 8)) {
bx_options.par[1].Opresent->set (atol(&params[i][8]));
}
else if (!strncmp(params[i], "file=", 5)) {
bx_options.par1.Ooutfile->set (strdup(&params[i][5]));
bx_options.par[1].Ooutfile->set (strdup(&params[i][5]));
}
}
}
@ -2464,13 +2463,9 @@ bx_write_cdrom_options (FILE *fp, int drive, bx_cdrom_options *opt)
int
bx_write_parport_options (FILE *fp, bx_parport_options *opt, int n)
{
if (!opt->Oenable->get ()) {
fprintf (fp, "# no parport #%d\n", n);
return 0;
}
fprintf (fp, "parport%d: enable=%d", n, opt->Oenable->get ());
if (opt->Oenable->get ()) {
fprintf (fp, ", file=\"%s\"", opt->Ooutfile->getptr ());
fprintf (fp, "parport%d: enabled=%d", n, opt->Opresent->get ());
if (opt->Opresent->get ()) {
fprintf (fp, ", file=\"%s\"", opt->Ooutfile->getptr ());
}
fprintf (fp, "\n");
return 0;
@ -2618,8 +2613,8 @@ bx_write_configuration (char *rc, int overwrite)
if (strlen (bx_options.optrom[3].Opath->getptr ()) > 0)
fprintf (fp, "optromimage4: file=%s, address=0x%05x\n", bx_options.optrom[3].Opath->getptr(), (unsigned int)bx_options.optrom[3].Oaddress->get ());
fprintf (fp, "megs: %d\n", bx_options.memory.Osize->get ());
bx_write_parport_options (fp, &bx_options.par1, 1);
//bx_write_parport_options (fp, &bx_options.par2);
bx_write_parport_options (fp, &bx_options.par[0], 1);
//bx_write_parport_options (fp, &bx_options.par[1], 2);
bx_write_sb16_options (fp, &bx_options.sb16);
int bootdrive = bx_options.Obootdrive->get ();
fprintf (fp, "boot: %s\n", (bootdrive==BX_BOOT_FLOPPYA) ? "a" : (bootdrive==BX_BOOT_DISKC) ? "c" : "cdrom");