2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-08-01 16:19:01 +04:00
|
|
|
// $Id: iodev.h,v 1.15 2002-08-01 12:19:01 vruppert Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2002-06-16 19:02:28 +04: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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* maximum number of emulated devices allowed. floppy, mda, etc...
|
|
|
|
you can increase this to anything below 256 since an 8-bit handle
|
|
|
|
is used for each device */
|
|
|
|
#define BX_MAX_IO_DEVICES 20
|
|
|
|
|
|
|
|
/* number of IRQ lines supported. In an ISA PC there are two
|
|
|
|
PIC chips cascaded together. each has 8 IRQ lines, so there
|
|
|
|
should be 16 IRQ's total */
|
|
|
|
#define BX_MAX_IRQS 16
|
|
|
|
#define BX_NO_IRQ -1
|
|
|
|
|
|
|
|
|
2002-04-02 01:53:23 +04:00
|
|
|
class bx_biosdev_c;
|
2001-04-10 05:04:59 +04:00
|
|
|
class bx_pit_c;
|
|
|
|
class bx_keyb_c;
|
|
|
|
class bx_dma_c;
|
|
|
|
class bx_floppy_ctrl_c;
|
|
|
|
class bx_cmos_c;
|
|
|
|
class bx_serial_c;
|
|
|
|
class bx_parallel_c;
|
|
|
|
class bx_unmapped_c;
|
|
|
|
class bx_vga_c;
|
|
|
|
class bx_pic_c;
|
|
|
|
class bx_hard_drive_c;
|
|
|
|
class bx_sb16_c;
|
|
|
|
class bx_pci_c;
|
2001-05-23 11:48:11 +04:00
|
|
|
class bx_ioapic_c;
|
2001-04-10 05:04:59 +04:00
|
|
|
class bx_ne2k_c;
|
|
|
|
class bx_g2h_c;
|
2001-09-14 19:01:29 +04:00
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
class bx_iodebug_c;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef Bit32u (*bx_read_handler_t)(void *, Bit32u, unsigned);
|
|
|
|
typedef void (*bx_write_handler_t)(void *, Bit32u, Bit32u, unsigned);
|
|
|
|
|
|
|
|
|
|
|
|
#if BX_USE_DEV_SMF
|
|
|
|
# define BX_DEV_SMF static
|
|
|
|
# define BX_DEV_THIS bx_devices.
|
|
|
|
#else
|
|
|
|
# define BX_DEV_SMF
|
|
|
|
# define BX_DEV_THIS this->
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
class bx_devices_c : public logfunctions {
|
2001-04-10 05:04:59 +04:00
|
|
|
public:
|
|
|
|
bx_devices_c(void);
|
|
|
|
~bx_devices_c(void);
|
2001-05-23 11:48:11 +04:00
|
|
|
void init(BX_MEM_C *);
|
2002-08-01 16:19:01 +04:00
|
|
|
void reset(void);
|
2001-05-23 11:48:11 +04:00
|
|
|
BX_MEM_C *mem; // address space associated with these devices
|
2002-04-03 05:56:26 +04:00
|
|
|
Boolean register_io_read_handler(void *this_ptr, bx_read_handler_t f, Bit32u addr, const char *name );
|
|
|
|
Boolean register_io_write_handler(void *this_ptr, bx_write_handler_t f, Bit32u addr, const char *name );
|
|
|
|
Boolean register_irq(unsigned irq, const char *name);
|
|
|
|
Boolean unregister_irq(unsigned irq, const char *name);
|
2001-04-10 05:04:59 +04:00
|
|
|
void iodev_init(void);
|
|
|
|
Bit32u inp(Bit16u addr, unsigned io_len);
|
|
|
|
void outp(Bit16u addr, Bit32u value, unsigned io_len);
|
|
|
|
|
|
|
|
static void timer_handler(void *);
|
|
|
|
void timer(void);
|
|
|
|
|
2002-04-02 01:53:23 +04:00
|
|
|
bx_biosdev_c *biosdev;
|
2001-05-23 11:48:11 +04:00
|
|
|
bx_ioapic_c *ioapic;
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_pci_c *pci;
|
|
|
|
bx_pit_c *pit;
|
|
|
|
bx_keyb_c *keyboard;
|
|
|
|
bx_dma_c *dma;
|
|
|
|
bx_floppy_ctrl_c *floppy;
|
|
|
|
bx_cmos_c *cmos;
|
|
|
|
bx_serial_c *serial;
|
|
|
|
bx_parallel_c *parallel;
|
|
|
|
bx_unmapped_c *unmapped;
|
|
|
|
bx_vga_c *vga;
|
|
|
|
bx_pic_c *pic;
|
|
|
|
bx_hard_drive_c *hard_drive;
|
|
|
|
bx_sb16_c *sb16;
|
|
|
|
bx_ne2k_c *ne2k;
|
|
|
|
bx_g2h_c *g2h;
|
2001-09-14 19:01:29 +04:00
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
bx_iodebug_c *iodebug;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
Bit8u read_handler_id[0x10000]; // 64K
|
|
|
|
struct {
|
|
|
|
bx_read_handler_t funct;
|
|
|
|
void *this_ptr;
|
|
|
|
const char *handler_name; // name of device
|
|
|
|
} io_read_handler[BX_MAX_IO_DEVICES];
|
|
|
|
unsigned num_read_handles;
|
|
|
|
|
|
|
|
Bit8u write_handler_id[0x10000]; // 64K
|
|
|
|
struct {
|
|
|
|
bx_write_handler_t funct;
|
|
|
|
void *this_ptr;
|
|
|
|
const char *handler_name; // name of device
|
|
|
|
} io_write_handler[BX_MAX_IO_DEVICES];
|
|
|
|
unsigned num_write_handles;
|
|
|
|
|
|
|
|
// more for informative purposes, the names of the devices which
|
|
|
|
// are use each of the IRQ 0..15 lines are stored here
|
|
|
|
const char *irq_handler_name[BX_MAX_IRQS];
|
|
|
|
|
|
|
|
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
|
|
|
|
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
BX_DEV_SMF Bit32u port92_read(Bit32u address, unsigned io_len);
|
|
|
|
BX_DEV_SMF void port92_write(Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
|
|
|
|
int timer_handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "iodev/pci.h"
|
|
|
|
#if BX_SUPPORT_VGA
|
|
|
|
# include "iodev/vga.h"
|
|
|
|
#else
|
|
|
|
# include "iodev/hga.h"
|
|
|
|
#endif
|
2001-06-12 17:07:43 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2001-05-23 11:48:11 +04:00
|
|
|
# include "iodev/ioapic.h"
|
|
|
|
#endif
|
2002-04-02 01:53:23 +04:00
|
|
|
#include "iodev/biosdev.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "iodev/cmos.h"
|
|
|
|
#include "iodev/dma.h"
|
|
|
|
#include "iodev/floppy.h"
|
|
|
|
#include "iodev/harddrv.h"
|
2001-09-14 19:01:29 +04:00
|
|
|
#if BX_IODEBUG_SUPPORT
|
|
|
|
# include "iodev/iodebug.h"
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "iodev/keyboard.h"
|
|
|
|
#include "iodev/parallel.h"
|
|
|
|
#include "iodev/pic.h"
|
|
|
|
#include "iodev/pit.h"
|
2001-07-02 00:49:46 +04:00
|
|
|
#include "iodev/pit_wrap.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "iodev/serial.h"
|
|
|
|
#if BX_SUPPORT_SB16
|
|
|
|
# include "iodev/sb16.h"
|
|
|
|
#endif
|
|
|
|
#include "iodev/unmapped.h"
|
|
|
|
#include "iodev/eth.h"
|
|
|
|
#include "iodev/ne2k.h"
|
|
|
|
#include "iodev/guest2host.h"
|
2001-08-18 07:28:23 +04:00
|
|
|
#include "iodev/slowdown_timer.h"
|