- converted device PIT 82C54 to a plugin (internal / virtual timers remain in

Bochs core)
- removed obsolete and unused PIT methods
- updated FSF address
This commit is contained in:
Volker Ruppert 2009-01-11 18:46:01 +00:00
parent 2b61cf3b41
commit 1e578b3b28
7 changed files with 68 additions and 68 deletions

@ -18,7 +18,7 @@
#
# 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
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
# Makefile for the iodev component of bochs
@ -69,7 +69,6 @@ PCIDEV_CXXFLAGS = -I$(srcdir)/../host/linux/pcidev
OBJS_THAT_CANNOT_BE_PLUGINS = \
devices.o \
pit82c54.o pit_wrap.o \
virt_timer.o \
slowdown_timer.o \
$(MCH_OBJS) \
@ -77,6 +76,7 @@ OBJS_THAT_CANNOT_BE_PLUGINS = \
OBJS_THAT_CAN_BE_PLUGINS = \
pic.o \
pit_wrap.o \
serial.o \
parallel.o \
floppy.o \
@ -97,6 +97,7 @@ OBJS_THAT_CAN_BE_PLUGINS = \
@IODEBUG_OBJS@
OBJS_THAT_SUPPORT_OTHER_PLUGINS = \
pit82c54.o \
scancodes.o \
serial_raw.o \
svga_cirrus.o \
@ -146,7 +147,7 @@ libbx_harddrv.la: harddrv.lo hdimage.lo vmware3.lo vmware4.lo $(CDROM_OBJS:.o=.l
libbx_keyboard.la: keyboard.lo scancodes.lo
$(LIBTOOL) --mode=link $(CXX) -module keyboard.lo scancodes.lo -o libbx_keyboard.la -rpath $(PLUGIN_PATH)
libbx_pit.la: pit82c54.lo pit_wrap.lo
libbx_pit_wrap.la: pit82c54.lo pit_wrap.lo
$(LIBTOOL) --mode=link $(CXX) -module pit82c54.lo pit_wrap.lo -o libbx_pit.la -rpath $(PLUGIN_PATH)
libbx_sb16.la: sb16.lo $(SOUNDLOW_OBJS:.o=.lo)
@ -178,7 +179,7 @@ bx_harddrv.dll: harddrv.o hdimage.o vmware3.o vmware4.o $(CDROM_OBJS)
bx_keyboard.dll: keyboard.o scancodes.o
$(CXX) $(CXXFLAGS) -shared -o bx_keyboard.dll keyboard.o scancodes.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_pit.dll: pit82c54.o pit_wrap.o
bx_pit_wrap.dll: pit82c54.o pit_wrap.o
$(CXX) $(CXXFLAGS) -shared -o bx_pit.dll pit82c54.o pit_wrap.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_sb16.dll: sb16.o $(SOUNDLOW_OBJS)

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: devices.cc,v 1.130 2009-01-10 11:30:20 vruppert Exp $
// $Id: devices.cc,v 1.131 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -31,7 +31,6 @@
#include "iodev.h"
#include "iodev/pit_wrap.h"
#include "iodev/virt_timer.h"
#include "iodev/slowdown_timer.h"
@ -84,7 +83,6 @@ void bx_devices_c::init_stubs()
pluginPciUSBAdapter = &stubUsbAdapter;
#endif
#endif
pit = NULL;
pluginKeyboard = &stubKeyboard;
pluginDmaDevice = &stubDma;
pluginFloppyDevice = &stubFloppy;
@ -112,7 +110,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
unsigned i;
const char def_name[] = "Default";
BX_DEBUG(("Init $Id: devices.cc,v 1.130 2009-01-10 11:30:20 vruppert Exp $"));
BX_DEBUG(("Init $Id: devices.cc,v 1.131 2009-01-11 18:46:01 vruppert Exp $"));
mem = newmem;
/* set no-default handlers, will be overwritten by the real default handler */
@ -159,6 +157,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
PLUG_load_plugin(cmos, PLUGTYPE_CORE);
PLUG_load_plugin(dma, PLUGTYPE_CORE);
PLUG_load_plugin(pic, PLUGTYPE_CORE);
PLUG_load_plugin(pit, PLUGTYPE_CORE);
PLUG_load_plugin(vga, PLUGTYPE_CORE);
PLUG_load_plugin(floppy, PLUGTYPE_CORE);
PLUG_load_plugin(biosdev, PLUGTYPE_OPTIONAL);
@ -264,9 +263,8 @@ void bx_devices_c::init(BX_MEM_C *newmem)
/*--- 8259A PIC ---*/
pluginPicDevice->init();
/*--- 8254 PIT ---*/
pit = & bx_pit;
pit->init();
/*--- 82C54 PIT ---*/
pluginPitDevice->init();
#if 0
// Guest to Host interface. Used with special guest drivers
@ -332,7 +330,7 @@ void bx_devices_c::reset(unsigned type)
pluginFloppyDevice->reset(type);
pluginVgaDevice->reset(type);
pluginPicDevice->reset(type);
pit->reset(type);
pluginPitDevice->reset(type);
// now reset optional plugins
bx_reset_plugins(type);
}
@ -354,7 +352,7 @@ void bx_devices_c::register_state()
pluginFloppyDevice->register_state();
pluginVgaDevice->register_state();
pluginPicDevice->register_state();
pit->register_state();
pluginPitDevice->register_state();
// now register state of optional plugins
bx_plugins_register_state();
}
@ -396,10 +394,10 @@ void bx_devices_c::exit()
delete curr;
}
pit->exit();
bx_virt_timer.setup();
bx_slowdown_timer.exit();
PLUG_unload_plugin(pit);
PLUG_unload_plugin(unmapped);
PLUG_unload_plugin(cmos);
PLUG_unload_plugin(dma);

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.102 2009-01-04 21:46:20 vruppert Exp $
// $Id: iodev.h,v 1.103 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -24,7 +24,7 @@
//
// 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
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
//
/////////////////////////////////////////////////////////////////////////
@ -47,7 +47,6 @@
#define BX_MAX_IRQS 16
#define BX_NO_IRQ -1
class bx_pit_c;
#if BX_SUPPORT_APIC
class bx_ioapic_c;
#endif
@ -435,7 +434,7 @@ public:
#if BX_SUPPORT_ACPI
bx_acpi_ctrl_stub_c *pluginACPIController;
#endif
bx_pit_c *pit;
bx_devmodel_c *pluginPitDevice;
bx_keyb_stub_c *pluginKeyboard;
bx_dma_stub_c *pluginDmaDevice;
bx_floppy_stub_c *pluginFloppyDevice;

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pit82c54.cc,v 1.33 2009-01-10 11:30:20 vruppert Exp $
// $Id: pit82c54.cc,v 1.34 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
/*
@ -26,6 +26,11 @@
* write?
*/
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#include "iodev.h"
#include "pit82c54.h"
#define LOG_THIS this->

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.cc,v 1.72 2009-01-10 11:30:20 vruppert Exp $
// $Id: pit_wrap.cc,v 1.73 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -24,13 +24,34 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#include "iodev.h"
#include "pit_wrap.h"
#include "virt_timer.h"
#include "speaker.h"
#define LOG_THIS thePit->
bx_pit_c *thePit = NULL;
int libpit_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
{
thePit = new bx_pit_c();
bx_devices.pluginPitDevice = thePit;
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, thePit, BX_PLUGIN_PIT);
return(0); // Success
}
void libpit_LTX_plugin_fini(void)
{
delete thePit;
}
//Important constant #defines:
#define USEC_PER_SECOND (1000000)
//1.193181MHz Clock
@ -44,17 +65,6 @@
#define F2I(x) ((Bit64u)(Bit64s) (x))
#define I2F(x) ((double)(Bit64s) (x))
//DEBUG configuration:
//Set up Logging.
#define LOG_THIS bx_pit.
//A single instance.
bx_pit_c bx_pit;
#if BX_USE_PIT_SMF
#define this (&bx_pit)
#endif
//Generic MAX and MIN Functions
#define BX_MAX(a,b) ( ((a)>(b))?(a):(b) )
@ -82,12 +92,12 @@ bx_pit_c::bx_pit_c()
/* 8254 PIT (Programmable Interval Timer) */
BX_PIT_THIS s.timer_handle[1] = BX_NULL_TIMER_HANDLE;
BX_PIT_THIS s.timer_handle[2] = BX_NULL_TIMER_HANDLE;
BX_PIT_THIS s.timer_handle[0] = BX_NULL_TIMER_HANDLE;
s.timer_handle[1] = BX_NULL_TIMER_HANDLE;
s.timer_handle[2] = BX_NULL_TIMER_HANDLE;
s.timer_handle[0] = BX_NULL_TIMER_HANDLE;
}
int bx_pit_c::init(void)
void bx_pit_c::init(void)
{
DEV_register_irq(0, "8254 PIT");
DEV_register_ioread_handler(this, read_handler, 0x0040, "8254 PIT", 1);
@ -136,14 +146,6 @@ int bx_pit_c::init(void)
BX_DEBUG(("s.timer_id=%d",BX_PIT_THIS s.timer_handle[0]));
BX_DEBUG(("s.timer.get_next_event_time=%d",BX_PIT_THIS s.timer.get_next_event_time()));
BX_DEBUG(("s.last_next_event_time=%d",BX_PIT_THIS s.last_next_event_time));
return(1);
}
void bx_pit_c::exit(void)
{
BX_PIT_THIS s.timer_handle[0] = BX_NULL_TIMER_HANDLE;
BX_PIT_THIS s.timer.init();
}
void bx_pit_c::reset(unsigned type)
@ -308,9 +310,9 @@ void bx_pit_c::write(Bit32u address, Bit32u dvalue, unsigned io_len)
case 0x61:
BX_PIT_THIS s.speaker_data_on = (value >> 1) & 0x01;
if (BX_PIT_THIS s.speaker_data_on) {
DEV_speaker_beep_on((float)(1193180.0 / this->get_timer(2)));
DEV_speaker_beep_on((float)(1193180.0 / BX_PIT_THIS get_timer(2)));
} else {
DEV_speaker_beep_off();
DEV_speaker_beep_off();
}
/* ??? only on AT+ */
BX_PIT_THIS s.timer.set_GATE(2, value & 0x01);
@ -375,3 +377,7 @@ void bx_pit_c::irq_handler(bx_bool value)
DEV_pic_lower_irq(0);
}
}
Bit16u bx_pit_c::get_timer(int Timer) {
return BX_PIT_THIS s.timer.get_inlatch(Timer);
}

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.h,v 1.29 2008-11-09 22:04:14 vruppert Exp $
// $Id: pit_wrap.h,v 1.30 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -22,7 +22,7 @@
//
// 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
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#ifndef _BX_PIT_WRAP_H
#define _BX_PIT_WRAP_H
@ -32,25 +32,19 @@
#if BX_USE_PIT_SMF
# define BX_PIT_SMF static
# define BX_PIT_THIS bx_pit.
# define BX_PIT_THIS thePit->
#else
# define BX_PIT_SMF
# define BX_PIT_THIS this->
#endif
class bx_pit_c : public logfunctions {
class bx_pit_c : public bx_devmodel_c {
public:
bx_pit_c();
virtual ~bx_pit_c() {}
BX_PIT_SMF int init(void);
BX_PIT_SMF void exit(void);
BX_PIT_SMF void reset(unsigned type);
BX_PIT_SMF bx_bool periodic(Bit32u usec_delta);
BX_PIT_SMF void register_state(void);
Bit16u get_timer(int Timer) {
return s.timer.get_inlatch(Timer);
}
virtual void init(void);
virtual void reset(unsigned type);
virtual void register_state(void);
private:
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
@ -73,16 +67,11 @@ private:
static void timer_handler(void *this_ptr);
BX_PIT_SMF void handle_timer();
BX_PIT_SMF void write_count_reg(Bit8u value, unsigned timerid);
BX_PIT_SMF Bit8u read_counter(unsigned timerid);
BX_PIT_SMF void latch(unsigned timerid);
BX_PIT_SMF void set_GATE(unsigned pit_id, unsigned value);
BX_PIT_SMF void start(unsigned timerid);
BX_PIT_SMF bx_bool periodic(Bit32u usec_delta);
BX_PIT_SMF void irq_handler(bx_bool value);
BX_PIT_SMF Bit16u get_timer(int Timer);
};
extern bx_pit_c bx_pit;
#endif // #ifndef _BX_PIT_WRAP_H

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.69 2009-01-11 08:48:47 vruppert Exp $
// $Id: plugin.h,v 1.70 2009-01-11 18:46:01 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -51,6 +51,7 @@ extern "C" {
#define BX_PLUGIN_HARDDRV "harddrv"
#define BX_PLUGIN_DMA "dma"
#define BX_PLUGIN_PIC "pic"
#define BX_PLUGIN_PIT "pit"
#define BX_PLUGIN_PCI "pci"
#define BX_PLUGIN_PCI2ISA "pci2isa"
#define BX_PLUGIN_PCI_IDE "pci_ide"
@ -379,6 +380,7 @@ DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(biosdev)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(cmos)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(dma)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pic)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(pit)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(vga)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(floppy)
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(parallel)