2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-11-10 11:12:12 +03:00
|
|
|
// $Id: devices.cc,v 1.42 2002-11-10 08:12:12 vruppert Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2002-01-29 20:20:12 +03:00
|
|
|
// Copyright (C) 2002 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
|
|
#include "bochs.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS bx_devices.
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* main memory size (in Kbytes)
|
|
|
|
* subtract 1k for extended BIOS area
|
|
|
|
* report only base memory, not extended mem
|
|
|
|
*/
|
|
|
|
#define BASE_MEMORY_IN_K 640
|
|
|
|
|
|
|
|
|
|
|
|
bx_devices_c bx_devices;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-27 23:54:46 +04:00
|
|
|
// constructor for bx_devices_c
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_devices_c::bx_devices_c(void)
|
|
|
|
{
|
2001-06-27 23:16:01 +04:00
|
|
|
put("DEV");
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
settype(DEVLOG);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_PCI_SUPPORT
|
2002-11-09 23:51:40 +03:00
|
|
|
pluginPciBridge = &stubPci;
|
|
|
|
pluginPci2IsaBridge = NULL;
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
pit = NULL;
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginKeyboard = &stubKeyboard;
|
|
|
|
pluginDmaDevice = &stubDma;
|
|
|
|
pluginFloppyDevice = &stubFloppy;
|
|
|
|
pluginBiosDevice = NULL;
|
|
|
|
pluginCmosDevice = &stubCmos;
|
|
|
|
pluginSerialDevice = NULL;
|
|
|
|
pluginParallelDevice = NULL;
|
|
|
|
pluginUnmapped = NULL;
|
|
|
|
pluginVgaDevice = &stubVga;
|
|
|
|
pluginPicDevice = &stubPic;
|
|
|
|
pluginHardDrive = &stubHardDrive;
|
2001-04-10 05:04:59 +04:00
|
|
|
sb16 = NULL;
|
|
|
|
ne2k = NULL;
|
|
|
|
g2h = NULL;
|
2001-09-14 19:01:29 +04:00
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
iodebug = NULL;
|
|
|
|
#endif
|
2002-08-27 21:25:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bx_devices_c::~bx_devices_c(void)
|
|
|
|
{
|
|
|
|
// nothing needed for now
|
|
|
|
BX_DEBUG(("Exit."));
|
2002-10-06 23:04:47 +04:00
|
|
|
timer_handle = BX_NULL_TIMER_HANDLE;
|
2002-08-27 21:25:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::init(BX_MEM_C *newmem)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2002-11-10 11:12:12 +03:00
|
|
|
BX_DEBUG(("Init $Id: devices.cc,v 1.42 2002-11-10 08:12:12 vruppert Exp $"));
|
2002-08-27 21:25:18 +04:00
|
|
|
mem = newmem;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-08-27 21:25:18 +04:00
|
|
|
/* no read / write handlers defined */
|
2001-04-10 05:04:59 +04:00
|
|
|
num_read_handles = 0;
|
|
|
|
num_write_handles = 0;
|
|
|
|
|
|
|
|
/* set unused elements to appropriate values */
|
|
|
|
for (i=0; i < BX_MAX_IO_DEVICES; i++) {
|
|
|
|
io_read_handler[i].funct = NULL;
|
|
|
|
io_write_handler[i].funct = NULL;
|
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
/* set no-default handlers, will be overwritten by the real default handler */
|
|
|
|
io_read_handler[BX_DEFAULT_IO_DEVICE].handler_name = "Default";
|
|
|
|
io_read_handler[BX_DEFAULT_IO_DEVICE].funct = &default_read_handler;
|
|
|
|
io_read_handler[BX_DEFAULT_IO_DEVICE].this_ptr = NULL;
|
|
|
|
io_write_handler[BX_DEFAULT_IO_DEVICE].handler_name = "Default";
|
|
|
|
io_write_handler[BX_DEFAULT_IO_DEVICE].funct = &default_write_handler;
|
|
|
|
io_write_handler[BX_DEFAULT_IO_DEVICE].this_ptr = NULL;
|
|
|
|
|
|
|
|
/* set handlers to the default one */
|
2001-04-10 05:04:59 +04:00
|
|
|
for (i=0; i < 0x10000; i++) {
|
2002-10-25 01:07:56 +04:00
|
|
|
read_handler_id[i] = BX_DEFAULT_IO_DEVICE;
|
|
|
|
write_handler_id[i] = BX_DEFAULT_IO_DEVICE;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < BX_MAX_IRQS; i++) {
|
|
|
|
irq_handler_name[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2002-10-25 16:28:34 +04:00
|
|
|
// BBD: At present, the only difference between "core" and "optional"
|
|
|
|
// plugins is that initialization and reset of optional plugins is handled
|
|
|
|
// by the plugin device list (). Init and reset of core plugins is done
|
|
|
|
// "by hand" in this file. Basically, we're using core plugins when we
|
|
|
|
// want to control the init order.
|
|
|
|
//
|
|
|
|
// CB: UNMAPPED and BIOSDEV should maybe be optional
|
2002-10-25 01:07:56 +04:00
|
|
|
PLUG_load_plugin(unmapped, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(biosdev, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(cmos, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(dma, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(pic, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(vga, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(floppy, PLUGTYPE_CORE);
|
|
|
|
PLUG_load_plugin(harddrv, PLUGTYPE_OPTIONAL);
|
|
|
|
PLUG_load_plugin(keyboard, PLUGTYPE_OPTIONAL);
|
|
|
|
if (is_serial_enabled ())
|
|
|
|
PLUG_load_plugin(serial, PLUGTYPE_OPTIONAL);
|
|
|
|
if (is_parallel_enabled ())
|
|
|
|
PLUG_load_plugin(parallel, PLUGTYPE_OPTIONAL);
|
|
|
|
|
|
|
|
// Start with registering the default (unmapped) handler
|
|
|
|
pluginUnmapped->init ();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_PCI_SUPPORT
|
|
|
|
// PCI logic (i440FX)
|
2002-11-09 23:51:40 +03:00
|
|
|
if (bx_options.Oi440FXSupport->get ()) {
|
|
|
|
PLUG_load_plugin(pci, PLUGTYPE_OPTIONAL);
|
|
|
|
PLUG_load_plugin(pci2isa, PLUGTYPE_OPTIONAL);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
2001-06-12 17:07:43 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2002-10-25 01:07:56 +04:00
|
|
|
// I/O APIC 82093AA
|
|
|
|
ioapic = & bx_ioapic;
|
|
|
|
ioapic->init ();
|
2001-05-23 11:48:11 +04:00
|
|
|
#endif
|
|
|
|
|
2002-04-02 01:53:23 +04:00
|
|
|
// BIOS log
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginBiosDevice->init ();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// CMOS RAM & RTC
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginCmosDevice->init ();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-06-02 15:53:19 +04:00
|
|
|
/*--- 8237 DMA ---*/
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginDmaDevice->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
//--- FLOPPY ---
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginFloppyDevice->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
//--- SOUND ---
|
|
|
|
sb16 = &bx_sb16;
|
2002-10-25 01:07:56 +04:00
|
|
|
sb16->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*--- VGA adapter ---*/
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginVgaDevice->init ();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/*--- 8259A PIC ---*/
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginPicDevice->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/*--- 8254 PIT ---*/
|
|
|
|
pit = & bx_pit;
|
2002-10-25 01:07:56 +04:00
|
|
|
pit->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-09-24 16:09:45 +04:00
|
|
|
#if BX_USE_SLOWDOWN_TIMER
|
2002-10-25 01:07:56 +04:00
|
|
|
bx_slowdown_timer.init();
|
2001-08-18 07:28:23 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-09-14 19:01:29 +04:00
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
iodebug = &bx_iodebug;
|
2002-10-25 01:07:56 +04:00
|
|
|
iodebug->init();
|
2001-09-14 19:01:29 +04:00
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_NE2K_SUPPORT
|
|
|
|
// NE2000 NIC
|
|
|
|
ne2k = &bx_ne2k;
|
2002-10-25 01:07:56 +04:00
|
|
|
ne2k->init();
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("ne2k"));
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif // #if BX_NE2K_SUPPORT
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Guest to Host interface. Used with special guest drivers
|
|
|
|
// which move data to/from the host environment.
|
|
|
|
g2h = &bx_g2h;
|
2002-10-25 01:07:56 +04:00
|
|
|
g2h->init();
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// system hardware
|
|
|
|
register_io_read_handler( this,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
&read_handler,
|
2001-04-10 05:04:59 +04:00
|
|
|
0x0092,
|
|
|
|
"Port 92h System Control" );
|
|
|
|
register_io_write_handler(this,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
&write_handler,
|
2001-04-10 05:04:59 +04:00
|
|
|
0x0092,
|
|
|
|
"Port 92h System Control" );
|
|
|
|
|
|
|
|
// misc. CMOS
|
2001-05-23 11:48:11 +04:00
|
|
|
Bit16u extended_memory_in_k = mem->get_memory_in_k() - 1024;
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_cmos_set_reg(0x15, (Bit8u) BASE_MEMORY_IN_K);
|
|
|
|
DEV_cmos_set_reg(0x16, (Bit8u) (BASE_MEMORY_IN_K >> 8));
|
|
|
|
DEV_cmos_set_reg(0x17, (Bit8u) extended_memory_in_k);
|
|
|
|
DEV_cmos_set_reg(0x18, (Bit8u) (extended_memory_in_k >> 8));
|
|
|
|
DEV_cmos_set_reg(0x30, (Bit8u) extended_memory_in_k);
|
|
|
|
DEV_cmos_set_reg(0x31, (Bit8u) (extended_memory_in_k >> 8));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-16 11:38:37 +04:00
|
|
|
Bit16u extended_memory_in_64k = mem->get_memory_in_k() > 16384 ? (mem->get_memory_in_k() - 16384) / 64 : 0;
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_cmos_set_reg(0x34, (Bit8u) extended_memory_in_64k);
|
|
|
|
DEV_cmos_set_reg(0x35, (Bit8u) (extended_memory_in_64k >> 8));
|
2002-10-16 11:38:37 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
/* now perform checksum of CMOS memory */
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_cmos_checksum();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-06 23:04:47 +04:00
|
|
|
if (timer_handle != BX_NULL_TIMER_HANDLE) {
|
|
|
|
timer_handle = bx_pc_system.register_timer( this, timer_handler,
|
|
|
|
(unsigned) BX_IODEV_HANDLER_PERIOD, 1, 1, "devices.cc");
|
|
|
|
}
|
2002-09-09 20:56:56 +04:00
|
|
|
|
|
|
|
// Clear fields for bulk IO acceleration transfers.
|
|
|
|
bulkIOHostAddr = 0;
|
|
|
|
bulkIOQuantumsRequested = 0;
|
|
|
|
bulkIOQuantumsTransferred = 0;
|
2002-10-25 01:07:56 +04:00
|
|
|
|
|
|
|
bx_init_plugins();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-01 16:19:01 +04:00
|
|
|
void
|
2002-08-27 23:54:46 +04:00
|
|
|
bx_devices_c::reset(unsigned type)
|
2002-08-01 16:19:01 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginUnmapped->reset(type);
|
2002-08-01 16:19:01 +04:00
|
|
|
#if BX_PCI_SUPPORT
|
2002-11-09 23:51:40 +03:00
|
|
|
if (bx_options.Oi440FXSupport->get ()) {
|
|
|
|
pluginPciBridge->reset(type);
|
|
|
|
pluginPci2IsaBridge->reset(type);
|
|
|
|
}
|
2002-08-27 23:54:46 +04:00
|
|
|
#endif
|
|
|
|
#if BX_SUPPORT_IOAPIC
|
|
|
|
ioapic->reset (type);
|
|
|
|
#endif
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginBiosDevice->reset(type);
|
|
|
|
pluginCmosDevice->reset(type);
|
|
|
|
pluginDmaDevice->reset(type);
|
|
|
|
pluginFloppyDevice->reset(type);
|
2002-08-27 23:54:46 +04:00
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
sb16->reset(type);
|
|
|
|
#endif
|
2002-10-25 01:07:56 +04:00
|
|
|
pluginVgaDevice->reset(type);
|
|
|
|
pluginPicDevice->reset(type);
|
2002-08-27 23:54:46 +04:00
|
|
|
pit->reset(type);
|
|
|
|
#if BX_USE_SLOWDOWN_TIMER
|
|
|
|
bx_slowdown_timer.reset(type);
|
|
|
|
#endif
|
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
iodebug->reset(type);
|
|
|
|
#endif
|
|
|
|
#if BX_NE2K_SUPPORT
|
|
|
|
ne2k->reset(type);
|
2002-08-01 16:19:01 +04:00
|
|
|
#endif
|
2002-10-25 01:07:56 +04:00
|
|
|
|
|
|
|
bx_reset_plugins(type);
|
2002-08-01 16:19:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
Bit32u
|
|
|
|
bx_devices_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
|
|
|
{
|
|
|
|
#if !BX_USE_DEV_SMF
|
|
|
|
bx_devices_c *class_ptr = (bx_devices_c *) this_ptr;
|
|
|
|
|
|
|
|
return( class_ptr->port92_read(address, io_len) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bit32u
|
|
|
|
bx_devices_c::port92_read(Bit32u address, unsigned io_len)
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
#endif // !BX_USE_DEV_SMF
|
|
|
|
if (io_len > 1)
|
2001-06-27 23:16:01 +04:00
|
|
|
BX_PANIC(("port 92h: io read from address %08x, len=%u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address, (unsigned) io_len));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-27 23:16:01 +04:00
|
|
|
BX_DEBUG(("port92h read partially supported!!!"));
|
|
|
|
BX_DEBUG((" returning %02x", (unsigned) (BX_GET_ENABLE_A20() << 1)));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(BX_GET_ENABLE_A20() << 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
#if !BX_USE_DEV_SMF
|
|
|
|
bx_devices_c *class_ptr = (bx_devices_c *) this_ptr;
|
|
|
|
|
|
|
|
class_ptr->port92_write(address, value, io_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::port92_write(Bit32u address, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
#endif // !BX_USE_DEV_SMF
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool bx_cpu_reset;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (io_len > 1)
|
2001-06-27 23:16:01 +04:00
|
|
|
BX_PANIC(("port 92h: io read from address %08x, len=%u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) address, (unsigned) io_len));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-27 23:16:01 +04:00
|
|
|
BX_DEBUG(("port92h write of %02x partially supported!!!",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
(unsigned) value));
|
2001-06-27 23:16:01 +04:00
|
|
|
BX_DEBUG(("A20: set_enable_a20() called"));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_SET_ENABLE_A20( (value & 0x02) >> 1 );
|
2001-08-31 20:06:32 +04:00
|
|
|
BX_DEBUG(("A20: now %u", (unsigned) BX_GET_ENABLE_A20()));
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_cpu_reset = (value & 0x01); /* high speed reset */
|
|
|
|
if (bx_cpu_reset) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("PORT 92h write: CPU reset requested!"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
|
|
|
|
// This defines a no-default read handler,
|
|
|
|
// so Bochs does not segfault if unmapped is not loaded
|
|
|
|
Bit32u
|
|
|
|
bx_devices_c::default_read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
|
|
|
{
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
BX_PANIC(("No default io-read handler found for 0x%04x/%d. Unmapped io-device not loaded ?", address, io_len));
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This defines a no-default write handler,
|
|
|
|
// so Bochs does not segfault if unmapped is not loaded
|
|
|
|
void
|
|
|
|
bx_devices_c::default_write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
UNUSED(this_ptr);
|
|
|
|
BX_PANIC(("No default io-write handler found for 0x%04x/%d. Unmapped io-device not loaded ?", address, io_len));
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
void
|
|
|
|
bx_devices_c::timer_handler(void *this_ptr)
|
|
|
|
{
|
|
|
|
bx_devices_c *class_ptr = (bx_devices_c *) this_ptr;
|
|
|
|
|
|
|
|
class_ptr->timer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::timer()
|
|
|
|
{
|
2001-08-18 07:28:23 +04:00
|
|
|
#if (BX_USE_NEW_PIT==0)
|
2002-03-26 16:59:35 +03:00
|
|
|
if ( pit->periodic( BX_IODEV_HANDLER_PERIOD ) ) {
|
2002-01-29 20:20:12 +03:00
|
|
|
// This is a hack to make the IRQ0 work
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_pic_lower_irq(0);
|
|
|
|
DEV_pic_raise_irq(0);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-08-18 07:28:23 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-01-29 20:20:12 +03:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// separate calls to bx_gui->handle_events from the keyboard code.
|
|
|
|
{
|
|
|
|
static int multiple=0;
|
|
|
|
if ( ++multiple==10)
|
|
|
|
{
|
|
|
|
multiple=0;
|
|
|
|
SIM->periodic ();
|
|
|
|
if (!BX_CPU(0)->kill_bochs_request)
|
|
|
|
bx_gui->handle_events();
|
|
|
|
}
|
|
|
|
}
|
2001-05-23 11:48:11 +04:00
|
|
|
|
2002-10-03 19:47:13 +04:00
|
|
|
// KPL Removed lapic periodic timer registration here.
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_devices_c::register_irq(unsigned irq, const char *name)
|
|
|
|
{
|
|
|
|
if (irq >= BX_MAX_IRQS) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("IO device %s registered with IRQ=%d above %u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
name, irq, (unsigned) BX_MAX_IRQS-1));
|
2002-04-03 05:56:26 +04:00
|
|
|
return false;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (irq_handler_name[irq]) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("IRQ %u conflict, %s with %s", irq,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
irq_handler_name[irq], name));
|
2002-04-03 05:56:26 +04:00
|
|
|
return false;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
irq_handler_name[irq] = name;
|
2002-04-03 05:56:26 +04:00
|
|
|
return true;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_devices_c::unregister_irq(unsigned irq, const char *name)
|
|
|
|
{
|
|
|
|
if (irq >= BX_MAX_IRQS) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("IO device %s tried to unregister IRQ %d above %u",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
name, irq, (unsigned) BX_MAX_IRQS-1));
|
2002-04-03 05:56:26 +04:00
|
|
|
return false;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!irq_handler_name[irq]) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("IO device %s tried to unregister IRQ %d, not registered",
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
name, irq));
|
2002-04-03 05:56:26 +04:00
|
|
|
return false;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(irq_handler_name[irq], name)) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("IRQ %u not registered to %s but to %s", irq,
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
name, irq_handler_name[irq]));
|
2002-04-03 05:56:26 +04:00
|
|
|
return false;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
irq_handler_name[irq] = NULL;
|
2002-04-03 05:56:26 +04:00
|
|
|
return true;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_devices_c::register_io_read_handler( void *this_ptr, bx_read_handler_t f,
|
|
|
|
Bit32u addr, const char *name )
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
|
|
|
|
addr &= 0x0000ffff;
|
|
|
|
|
|
|
|
/* first find existing handle for function or create new one */
|
|
|
|
for (handle=0; handle < num_read_handles; handle++) {
|
|
|
|
if (io_read_handler[handle].funct == f) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handle >= num_read_handles) {
|
|
|
|
/* no existing handle found, create new one */
|
2002-10-25 01:07:56 +04:00
|
|
|
if (num_read_handles >= BX_DEFAULT_IO_DEVICE) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("too many IO devices installed."));
|
|
|
|
BX_PANIC((" try increasing BX_MAX_IO_DEVICES"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
num_read_handles++;
|
|
|
|
io_read_handler[handle].funct = f;
|
|
|
|
io_read_handler[handle].this_ptr = this_ptr;
|
|
|
|
io_read_handler[handle].handler_name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* change table to reflect new handler id for that address */
|
2002-10-25 01:07:56 +04:00
|
|
|
if (read_handler_id[addr] < BX_DEFAULT_IO_DEVICE) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// another handler is already registered for that address
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_ERROR(("IO device address conflict(read) at IO address %Xh",
|
|
|
|
(unsigned) addr));
|
|
|
|
BX_ERROR((" conflicting devices: %s & %s",
|
|
|
|
io_read_handler[handle].handler_name, io_read_handler[read_handler_id[addr]].handler_name));
|
|
|
|
return false; // address not available, return false.
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
read_handler_id[addr] = handle;
|
2002-04-03 05:56:26 +04:00
|
|
|
return true; // address mapped successfully
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_devices_c::register_io_write_handler( void *this_ptr, bx_write_handler_t f,
|
|
|
|
Bit32u addr, const char *name )
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
|
|
|
|
addr &= 0x0000ffff;
|
|
|
|
|
|
|
|
/* first find existing handle for function or create new one */
|
|
|
|
for (handle=0; handle < num_write_handles; handle++) {
|
|
|
|
if (io_write_handler[handle].funct == f) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handle >= num_write_handles) {
|
|
|
|
/* no existing handle found, create new one */
|
2002-10-25 01:07:56 +04:00
|
|
|
if (num_write_handles >= BX_DEFAULT_IO_DEVICE) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("too many IO devices installed."));
|
|
|
|
BX_PANIC((" try increasing BX_MAX_IO_DEVICES"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
num_write_handles++;
|
|
|
|
io_write_handler[handle].funct = f;
|
|
|
|
io_write_handler[handle].this_ptr = this_ptr;
|
|
|
|
io_write_handler[handle].handler_name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* change table to reflect new handler id for that address */
|
2002-10-25 01:07:56 +04:00
|
|
|
if (write_handler_id[addr] < BX_DEFAULT_IO_DEVICE) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// another handler is already registered for that address
|
2002-10-25 01:07:56 +04:00
|
|
|
BX_ERROR(("IO device address conflict(write) at IO address %Xh",
|
|
|
|
(unsigned) addr));
|
|
|
|
BX_ERROR((" conflicting devices: %s & %s",
|
|
|
|
io_write_handler[handle].handler_name, io_write_handler[write_handler_id[addr]].handler_name));
|
|
|
|
return false; //unable to map iodevice.
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
write_handler_id[addr] = handle;
|
2002-04-03 05:56:26 +04:00
|
|
|
return true; // done!
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Registration of default handlers (mainly be the unmapped device)
|
|
|
|
// The trick here is to define a handler for the max index, so
|
|
|
|
// unregisterd io address will get handled by the default function
|
|
|
|
// This will be helpful when we want to unregister io handlers
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2002-10-25 01:07:56 +04:00
|
|
|
bx_devices_c::register_default_io_read_handler( void *this_ptr, bx_read_handler_t f,
|
|
|
|
const char *name )
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
|
|
|
|
/* handle is fixed to the default I/O device */
|
|
|
|
handle = BX_DEFAULT_IO_DEVICE;
|
|
|
|
|
|
|
|
if (strcmp(io_read_handler[handle].handler_name, "Default")) {
|
|
|
|
BX_ERROR(("Default io read handler already registered '%s'",io_read_handler[handle].handler_name));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
io_read_handler[handle].funct = f;
|
|
|
|
io_read_handler[handle].this_ptr = this_ptr;
|
|
|
|
io_read_handler[handle].handler_name = name;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool
|
2002-10-25 01:07:56 +04:00
|
|
|
bx_devices_c::register_default_io_write_handler( void *this_ptr, bx_write_handler_t f,
|
|
|
|
const char *name )
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
|
|
|
|
/* handle is fixed to the MAX */
|
|
|
|
handle = BX_DEFAULT_IO_DEVICE;
|
|
|
|
|
|
|
|
if (strcmp(io_write_handler[handle].handler_name, "Default")) {
|
|
|
|
BX_ERROR(("Default io write handler already registered '%s'",io_write_handler[handle].handler_name));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
io_write_handler[handle].funct = f;
|
|
|
|
io_write_handler[handle].this_ptr = this_ptr;
|
|
|
|
io_write_handler[handle].handler_name = name;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a byte of data from the IO memory address space
|
|
|
|
*/
|
|
|
|
|
|
|
|
Bit32u
|
|
|
|
bx_devices_c::inp(Bit16u addr, unsigned io_len)
|
|
|
|
{
|
|
|
|
Bit8u handle;
|
|
|
|
Bit32u ret;
|
|
|
|
|
|
|
|
BX_INSTR_INP(addr, io_len);
|
|
|
|
|
|
|
|
handle = read_handler_id[addr];
|
2002-10-25 01:07:56 +04:00
|
|
|
// FIXME, we want to make sure that there is a default handler there
|
2001-04-10 05:04:59 +04:00
|
|
|
ret = (* io_read_handler[handle].funct)(io_read_handler[handle].this_ptr,
|
|
|
|
(Bit32u) addr, io_len);
|
2001-06-28 23:48:04 +04:00
|
|
|
BX_INSTR_INP2(addr, io_len, ret);
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_DBG_IO_REPORT(addr, io_len, BX_READ, ret);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a byte of data to the IO memory address space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::outp(Bit16u addr, Bit32u value, unsigned io_len)
|
|
|
|
{
|
|
|
|
Bit8u handle;
|
|
|
|
|
|
|
|
BX_INSTR_OUTP(addr, io_len);
|
2001-06-28 23:48:04 +04:00
|
|
|
BX_INSTR_OUTP2(addr, io_len, value);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
BX_DBG_IO_REPORT(addr, io_len, BX_WRITE, value);
|
|
|
|
handle = write_handler_id[addr];
|
2002-10-25 01:07:56 +04:00
|
|
|
// FIXME, we want to make sure that there is a default handler there
|
2001-04-10 05:04:59 +04:00
|
|
|
(* io_write_handler[handle].funct)(io_write_handler[handle].this_ptr,
|
|
|
|
(Bit32u) addr, value, io_len);
|
|
|
|
}
|
2002-10-25 01:07:56 +04:00
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool bx_devices_c::is_serial_enabled ()
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
|
|
|
for (int i=0; i<BX_N_SERIAL_PORTS; i++) {
|
|
|
|
if (SIM->get_param_bool (BXP_COMx_ENABLED(i+1))->get())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool bx_devices_c::is_parallel_enabled ()
|
2002-10-25 01:07:56 +04:00
|
|
|
{
|
|
|
|
for (int i=0; i<BX_N_PARALLEL_PORTS; i++) {
|
|
|
|
if (SIM->get_param_bool (BXP_PARPORTx_ENABLED(i+1))->get())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|