2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 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
|
|
|
|
|
|
|
|
// call periodic timers every N useconds
|
|
|
|
#define TIMER_DELTA 100
|
|
|
|
//#define TIMER_DELTA 10
|
|
|
|
|
|
|
|
bx_devices_c bx_devices;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// constructor for bx_devices_c
|
|
|
|
bx_devices_c::bx_devices_c(void)
|
|
|
|
{
|
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
|
|
|
setprefix("[DEV ]");
|
|
|
|
settype(DEVLOG);
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
#if BX_PCI_SUPPORT
|
|
|
|
pci = NULL;
|
|
|
|
#endif
|
|
|
|
pit = NULL;
|
|
|
|
keyboard = NULL;
|
|
|
|
dma = NULL;
|
|
|
|
floppy = NULL;
|
|
|
|
cmos = NULL;
|
|
|
|
serial = NULL;
|
|
|
|
parallel = NULL;
|
|
|
|
unmapped = NULL;
|
|
|
|
vga = NULL;
|
|
|
|
pic = NULL;
|
|
|
|
hard_drive = NULL;
|
|
|
|
sb16 = NULL;
|
|
|
|
ne2k = NULL;
|
|
|
|
g2h = NULL;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < 0x10000; i++) {
|
|
|
|
read_handler_id[i] = BX_MAX_IO_DEVICES; // not assigned
|
|
|
|
write_handler_id[i] = BX_MAX_IO_DEVICES; // not assigned
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < BX_MAX_IRQS; i++) {
|
|
|
|
irq_handler_name[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
timer_handle = BX_NULL_TIMER_HANDLE;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Init."));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bx_devices_c::~bx_devices_c(void)
|
|
|
|
{
|
|
|
|
// nothing needed for now
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Exit."));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-05-23 11:48:11 +04:00
|
|
|
bx_devices_c::init(BX_MEM_C *newmem)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2001-05-23 11:48:11 +04:00
|
|
|
mem = newmem;
|
2001-04-10 05:04:59 +04:00
|
|
|
// Start with all IO port address registered to unmapped handler
|
|
|
|
// MUST be called first
|
|
|
|
unmapped = &bx_unmapped;
|
|
|
|
unmapped->init(this);
|
|
|
|
|
|
|
|
#if BX_PCI_SUPPORT
|
|
|
|
// PCI logic (i440FX)
|
|
|
|
pci = & bx_pci;
|
|
|
|
pci->init(this);
|
|
|
|
pci->reset();
|
|
|
|
#endif
|
|
|
|
|
2001-05-23 11:48:11 +04:00
|
|
|
#if BX_APIC_SUPPORT
|
|
|
|
// I/O APIC 82093AA
|
|
|
|
ioapic = & bx_ioapic;
|
|
|
|
ioapic->init ();
|
|
|
|
ioapic->set_id (BX_IOAPIC_DEFAULT_ID);
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// CMOS RAM & RTC
|
|
|
|
cmos = &bx_cmos;
|
|
|
|
cmos->init(this);
|
|
|
|
cmos->reset();
|
|
|
|
|
|
|
|
/*--- HARD DRIVE ---*/
|
|
|
|
hard_drive = &bx_hard_drive;
|
|
|
|
hard_drive->init(this, cmos);
|
|
|
|
|
|
|
|
//--- FLOPPY ---
|
|
|
|
floppy = &bx_floppy;
|
|
|
|
floppy->init(this, cmos);
|
|
|
|
floppy->reset(BX_RESET_HARDWARE);
|
|
|
|
|
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
//--- SOUND ---
|
|
|
|
sb16 = &bx_sb16;
|
|
|
|
sb16->init(this);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_SUPPORT_VGA
|
|
|
|
/*--- VGA adapter ---*/
|
|
|
|
vga = & bx_vga;
|
|
|
|
vga->init(this, cmos);
|
|
|
|
#else
|
|
|
|
/*--- HGA adapter ---*/
|
|
|
|
bx_init_hga_hardware(cmos);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*--- 8259A PIC ---*/
|
|
|
|
pic = & bx_pic;
|
|
|
|
pic->init(this);
|
|
|
|
|
|
|
|
/*--- 8254 PIT ---*/
|
|
|
|
pit = & bx_pit;
|
|
|
|
pit->init(this);
|
|
|
|
|
|
|
|
|
|
|
|
dma = &bx_dma;
|
|
|
|
dma->init(this);
|
|
|
|
|
|
|
|
keyboard = &bx_keyboard;
|
|
|
|
keyboard->init(this, cmos);
|
|
|
|
|
|
|
|
/*--- PARALLEL PORT ---*/
|
|
|
|
parallel = &bx_parallel;
|
|
|
|
parallel->init(this);
|
|
|
|
|
|
|
|
/*--- SERIAL PORT ---*/
|
|
|
|
serial = &bx_serial;
|
|
|
|
serial->init(this);
|
|
|
|
|
|
|
|
#if BX_NE2K_SUPPORT
|
|
|
|
// NE2000 NIC
|
|
|
|
ne2k = &bx_ne2k;
|
|
|
|
ne2k->init(this);
|
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;
|
|
|
|
g2h->init(this);
|
|
|
|
#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;
|
2001-04-10 05:04:59 +04:00
|
|
|
cmos->s.reg[0x15] = (Bit8u) BASE_MEMORY_IN_K;
|
|
|
|
cmos->s.reg[0x16] = (Bit8u) (BASE_MEMORY_IN_K >> 8);
|
|
|
|
cmos->s.reg[0x17] = (Bit8u) extended_memory_in_k;
|
|
|
|
cmos->s.reg[0x18] = (Bit8u) (extended_memory_in_k >> 8);
|
|
|
|
cmos->s.reg[0x30] = (Bit8u) extended_memory_in_k;
|
|
|
|
cmos->s.reg[0x31] = (Bit8u) (extended_memory_in_k >> 8);
|
|
|
|
|
|
|
|
/* now perform checksum of CMOS memory */
|
|
|
|
cmos->checksum_cmos();
|
|
|
|
|
|
|
|
timer_handle = bx_pc_system.register_timer( this, timer_handler,
|
|
|
|
(unsigned) TIMER_DELTA, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("devices.c: 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-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("devices: port92h read partially supported!!!"));
|
|
|
|
BX_INFO(("devices: 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
|
|
|
|
Boolean bx_cpu_reset;
|
|
|
|
|
|
|
|
if (io_len > 1)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("devices.c: 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-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("devices: 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-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("devices: A20: set_enable_a20() called"));
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_SET_ENABLE_A20( (value & 0x02) >> 1 );
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
unsigned retval;
|
|
|
|
|
|
|
|
if ( pit->periodic( TIMER_DELTA ) ) {
|
|
|
|
pic->trigger_irq(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = keyboard->periodic( TIMER_DELTA );
|
|
|
|
if (retval & 0x01) {
|
|
|
|
if (bx_dbg.keyboard)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("keyboard: interrupt(1)"));
|
2001-04-10 05:04:59 +04:00
|
|
|
pic->trigger_irq(1);
|
|
|
|
}
|
|
|
|
if (retval & 0x02)
|
|
|
|
pic->trigger_irq(12);
|
2001-05-23 11:48:11 +04:00
|
|
|
|
|
|
|
#if BX_APIC_SUPPORT
|
|
|
|
// update local APIC timers
|
|
|
|
for (int i=0; i<BX_SMP_PROCESSORS; i++) {
|
|
|
|
BX_CPU(i)->local_apic.periodic (TIMER_DELTA);
|
|
|
|
}
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::drq(unsigned channel, Boolean val)
|
|
|
|
{
|
|
|
|
dma->DRQ(channel, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::raise_hlda(void)
|
|
|
|
{
|
|
|
|
dma->raise_HLDA( &bx_pc_system );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::dma_read8(unsigned channel, Bit8u *data_byte)
|
|
|
|
{
|
|
|
|
// UNUSED( channel );
|
|
|
|
if (channel == 2)
|
|
|
|
floppy->dma_read(data_byte);
|
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
else if (channel == (unsigned) sb16->currentdma8)
|
|
|
|
sb16->dma_read8(data_byte);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_devices_c::dma_write8(unsigned channel, Bit8u *data_byte)
|
|
|
|
{
|
|
|
|
// UNUSED( channel );
|
|
|
|
if (channel == 2)
|
|
|
|
floppy->dma_write(data_byte);
|
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
else if (channel == (unsigned) sb16->currentdma8)
|
|
|
|
sb16->dma_write8(data_byte);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
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));
|
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));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
irq_handler_name[irq] = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
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));
|
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));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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]));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
irq_handler_name[irq] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
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 */
|
|
|
|
if (num_read_handles >= BX_MAX_IO_DEVICES) {
|
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 */
|
|
|
|
if (read_handler_id[addr] < BX_MAX_IO_DEVICES) {
|
|
|
|
// another handler is already registered for that address
|
|
|
|
// if it is not the Unmapped port handler, bail
|
|
|
|
if ( strcmp( io_read_handler[read_handler_id[addr]].handler_name, "Unmapped" ) ) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("IO device address conflict(read) at IO address %Xh",
|
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) addr));
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC((" conflicting devices: %s & %s",
|
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
|
|
|
io_read_handler[handle].handler_name, io_read_handler[read_handler_id[addr]].handler_name));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
read_handler_id[addr] = handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
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 */
|
|
|
|
if (num_write_handles >= BX_MAX_IO_DEVICES) {
|
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 */
|
|
|
|
if (write_handler_id[addr] < BX_MAX_IO_DEVICES) {
|
|
|
|
// another handler is already registered for that address
|
|
|
|
// if it is not the Unmapped port handler, bail
|
|
|
|
if ( strcmp( io_write_handler[write_handler_id[addr]].handler_name, "Unmapped" ) ) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("IO device address conflict(write) at IO address %Xh",
|
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) addr));
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC((" conflicting devices: %s & %s",
|
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
|
|
|
io_write_handler[handle].handler_name, io_write_handler[write_handler_id[addr]].handler_name));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
write_handler_id[addr] = handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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];
|
|
|
|
ret = (* io_read_handler[handle].funct)(io_read_handler[handle].this_ptr,
|
|
|
|
(Bit32u) addr, io_len);
|
|
|
|
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);
|
|
|
|
|
|
|
|
BX_DBG_IO_REPORT(addr, io_len, BX_WRITE, value);
|
|
|
|
handle = write_handler_id[addr];
|
|
|
|
(* io_write_handler[handle].funct)(io_write_handler[handle].this_ptr,
|
|
|
|
(Bit32u) addr, value, io_len);
|
|
|
|
}
|