5e520261db
BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
292 lines
12 KiB
C++
292 lines
12 KiB
C++
/////////////////////////////////////////////////////////////////////////
|
|
// $Id: plugin.h,v 1.2 2002-10-24 21:04:55 bdenney Exp $
|
|
/////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// This file provides macros and types needed for plugins. It is based on
|
|
// the plugin.h file from plex86, but with significant changes to make
|
|
// it work in Bochs.
|
|
// Plex86 is Copyright (C) 1999-2000 The plex86 developers team
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef __PLUGIN_H
|
|
#define __PLUGIN_H
|
|
|
|
#include "extplugin.h"
|
|
|
|
class bx_devices_c;
|
|
BOCHSAPI extern logfunctions *pluginlog;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define BX_PLUGIN_UNMAPPED "unmapped"
|
|
#define BX_PLUGIN_BIOSDEV "biosdev"
|
|
#define BX_PLUGIN_CMOS "cmos"
|
|
#define BX_PLUGIN_VGA "vga"
|
|
#define BX_PLUGIN_FLOPPY "floppy"
|
|
#define BX_PLUGIN_PARALLEL "parallel"
|
|
#define BX_PLUGIN_SERIAL "serial"
|
|
#define BX_PLUGIN_KEYBOARD "keyboard"
|
|
#define BX_PLUGIN_HARDDRV "harddrv"
|
|
#define BX_PLUGIN_DMA "dma"
|
|
#define BX_PLUGIN_PIC "pic"
|
|
|
|
#define BX_REGISTER_DEVICE pluginRegisterDevice
|
|
#define BX_REGISTER_DEVICE_DEVMODEL(a,b,c,d) pluginRegisterDeviceDevmodel(a,b,c,d)
|
|
|
|
#if BX_PLUGINS
|
|
|
|
#define DEV_init_devices() {bx_devices.init(BX_MEM(0)); }
|
|
#define DEV_reset_devices(type) {bx_devices.reset(type); }
|
|
#define PLUG_load_plugin(name,type) {bx_load_plugin(#name,type);}
|
|
|
|
#define DEV_register_ioread_handler(b,c,d,e,f) pluginRegisterIOReadHandler(b,c,d,e,f)
|
|
#define DEV_register_iowrite_handler(b,c,d,e,f) pluginRegisterIOWriteHandler(b,c,d,e,f)
|
|
#define DEV_register_default_ioread_handler(b,c,d,e) pluginRegisterDefaultIOReadHandler(b,c,d,e)
|
|
#define DEV_register_default_iowrite_handler(b,c,d,e) pluginRegisterDefaultIOWriteHandler(b,c,d,e)
|
|
|
|
#define DEV_register_irq(b,c) pluginRegisterIRQ(b,c)
|
|
#define DEV_unregister_irq(b,c) pluginUnregisterIRQ(b,c)
|
|
|
|
#else
|
|
|
|
#define DEV_init_devices() {bx_devices.init(BX_MEM(0)); }
|
|
#define DEV_reset_devices(type) {bx_devices.reset(type); }
|
|
// When plugins are off, PLUG_load_plugin will call the plugin_init function
|
|
// directly.
|
|
#define PLUG_load_plugin(name,type) {lib##name##_LTX_plugin_init(NULL,type,0,NULL);}
|
|
#define DEV_register_ioread_handler(b,c,d,e,f) bx_devices.register_io_read_handler(b,c,d,e)
|
|
#define DEV_register_iowrite_handler(b,c,d,e,f) bx_devices.register_io_write_handler(b,c,d,e)
|
|
#define DEV_register_default_ioread_handler(b,c,d,e) bx_devices.register_default_io_read_handler(b,c,d)
|
|
#define DEV_register_default_iowrite_handler(b,c,d,e) bx_devices.register_default_io_write_handler(b,c,d)
|
|
#define DEV_register_irq(b,c) bx_devices.register_irq(b,c)
|
|
#define DEV_unregister_irq(b,c) bx_devices.unregister_irq(b,c)
|
|
|
|
#endif // #if BX_PLUGINS
|
|
|
|
#define DEV_ioapic_present() (bx_devices.ioapic != NULL)
|
|
|
|
// FIXME Do we really need pluginRegisterTimer ?
|
|
#define DEV_register_timer(a,b,c,d,e,f) bx_pc_system.register_timer(a,b,c,d,e,f)
|
|
|
|
///////// CMOS macros
|
|
#define DEV_cmos_get_reg(a) (bx_devices.pluginCmosDevice->get_reg(a))
|
|
#define DEV_cmos_set_reg(a,b) (bx_devices.pluginCmosDevice->set_reg(a,b))
|
|
#define DEV_cmos_checksum() (bx_devices.pluginCmosDevice->checksum_cmos())
|
|
#define DEV_cmos_get_timeval() (bx_devices.pluginCmosDevice->get_timeval())
|
|
|
|
///////// keyboard macros
|
|
#define DEV_mouse_motion(dx, dy, state) \
|
|
(bx_devices.pluginKeyboard->mouse_motion(dx, dy, state))
|
|
#define DEV_kbd_gen_scancode(scancode) \
|
|
(bx_devices.pluginKeyboard->gen_scancode(scancode))
|
|
#define DEV_kbd_put_scancode(scancode, count) \
|
|
(bx_devices.pluginKeyboard->put_scancode(scancode, count))
|
|
#define DEV_kbd_paste_bytes(bytes, count) \
|
|
(bx_devices.pluginKeyboard->paste_bytes(bytes,count))
|
|
#define DEV_kbd_paste_delay_changed() \
|
|
(bx_devices.pluginKeyboard->paste_delay_changed())
|
|
#define DEV_mouse_enabled_changed(val) \
|
|
(bx_devices.pluginKeyboard->mouse_enabled_changed(val))
|
|
|
|
///////// hard drive macros
|
|
#define DEV_hd_read_handler(a, b, c) \
|
|
(bx_devices.pluginHardDrive->virt_read_handler(b, c))
|
|
#define DEV_hd_write_handler(a, b, c, d) \
|
|
(bx_devices.pluginHardDrive->virt_write_handler(b, c, d))
|
|
#define DEV_hd_get_first_cd_handle() \
|
|
(bx_devices.pluginHardDrive->get_first_cd_handle())
|
|
#define DEV_hd_get_device_handle(a,b) \
|
|
(bx_devices.pluginHardDrive->get_device_handle(a,b))
|
|
#define DEV_hd_get_cd_media_status(handle) \
|
|
(bx_devices.pluginHardDrive->get_cd_media_status(handle))
|
|
#define DEV_hd_set_cd_media_status(handle, status) \
|
|
(bx_devices.pluginHardDrive->set_cd_media_status(handle, status))
|
|
#define DEV_hd_close_harddrive() bx_devices.pluginHardDrive->close_harddrive()
|
|
#define DEV_hd_present() (bx_devices.pluginHardDrive != &bx_devices.stubHardDrive)
|
|
|
|
#define DEV_bulk_io_quantum_requested() (bx_devices.bulkIOQuantumsRequested)
|
|
#define DEV_bulk_io_quantum_transferred() (bx_devices.bulkIOQuantumsTransferred)
|
|
#define DEV_bulk_io_host_addr() (bx_devices.bulkIOHostAddr)
|
|
|
|
///////// FLOPPY macros
|
|
#define DEV_floppy_get_media_status(drive) bx_devices.pluginFloppyDevice->get_media_status(drive)
|
|
#define DEV_floppy_set_media_status(drive, status) bx_devices.pluginFloppyDevice->set_media_status(drive, status)
|
|
#define DEV_floppy_present() (bx_devices.pluginFloppyDevice != &bx_devices.stubFloppy)
|
|
|
|
///////// DMA macros
|
|
#define DEV_dma_register_8bit_channel(channel, dmaRead, dmaWrite, name) \
|
|
(bx_devices.pluginDmaDevice->registerDMA8Channel(channel, dmaRead, dmaWrite, name))
|
|
#define DEV_dma_register_16bit_channel(channel, dmaRead, dmaWrite, name) \
|
|
(bx_devices.pluginDmaDevice->registerDMA16Channel(channel, dmaRead, dmaWrite, name))
|
|
#define DEV_dma_unregister_channel(channel) \
|
|
(bx_devices.pluginDmaDevice->unregisterDMAChannel(channel))
|
|
#define DEV_dma_set_drq(channel, val) \
|
|
(bx_devices.pluginDmaDevice->set_DRQ(channel, val))
|
|
#define DEV_dma_get_tc() \
|
|
(bx_devices.pluginDmaDevice->get_TC())
|
|
#define DEV_dma_raise_hlda() \
|
|
(bx_devices.pluginDmaDevice->raise_HLDA())
|
|
|
|
///////// PIC macros
|
|
#define DEV_pic_lower_irq(b) (bx_devices.pluginPicDevice->lower_irq(b))
|
|
#define DEV_pic_raise_irq(b) (bx_devices.pluginPicDevice->raise_irq(b))
|
|
#define DEV_pic_iac() (bx_devices.pluginPicDevice->IAC())
|
|
|
|
///////// VGA macros
|
|
#define DEV_vga_mem_read(addr) (bx_devices.pluginVgaDevice->mem_read(addr))
|
|
#define DEV_vga_mem_write(addr, val) (bx_devices.pluginVgaDevice->mem_write(addr, val))
|
|
#define DEV_vga_redraw_area(left, top, right, bottom) \
|
|
(bx_devices.pluginVgaDevice->redraw_area(left, top, right, bottom))
|
|
#define DEV_vga_get_text_snapshot(rawsnap, height, width) \
|
|
(bx_devices.pluginVgaDevice->get_text_snapshot(rawsnap, height, width))
|
|
#define DEV_vga_refresh() \
|
|
(bx_devices.pluginVgaDevice->trigger_timer(bx_devices.pluginVgaDevice))
|
|
#define DEV_vga_set_update_interval(val) \
|
|
(bx_devices.pluginVgaDevice->set_update_interval(val))
|
|
|
|
|
|
#if BX_HAVE_DLFCN_H
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
typedef Bit32u (*ioReadHandler_t)(void *, Bit32u, unsigned);
|
|
typedef void (*ioWriteHandler_t)(void *, Bit32u, Bit32u, unsigned);
|
|
|
|
extern plugin_t *plugins;
|
|
|
|
typedef struct _device_t
|
|
{
|
|
const char *name;
|
|
plugin_t *plugin;
|
|
void (*device_init_mem)(BX_MEM_C *);
|
|
void (*device_init_dev)();
|
|
void (*device_reset)(unsigned);
|
|
void (*device_load_state)();
|
|
void (*device_save_state)();
|
|
|
|
int use_devmodel_interface; // BBD hack
|
|
class bx_devmodel_c *devmodel; // BBD hack
|
|
|
|
struct _device_t *next;
|
|
} device_t;
|
|
|
|
|
|
extern device_t *devices;
|
|
|
|
void plugin_startup (void);
|
|
void plugin_load (char *name, char *args, plugintype_t);
|
|
plugin_t *plugin_unload (plugin_t *plugin);
|
|
void plugin_init_all (void);
|
|
void plugin_fini_all (void);
|
|
|
|
/* === Device Stuff === */
|
|
typedef void (*deviceInitMem_t)(BX_MEM_C *);
|
|
typedef void (*deviceInitDev_t)(void);
|
|
typedef void (*deviceReset_t)(unsigned);
|
|
typedef void (*deviceLoad_t)(void);
|
|
typedef void (*deviceSave_t)(void);
|
|
|
|
BOCHSAPI void pluginRegisterDevice(deviceInitMem_t init_mem, deviceInitDev_t init_dev,
|
|
deviceReset_t reset, deviceLoad_t load,
|
|
deviceSave_t save, char *name);
|
|
BOCHSAPI void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *dev, char *name);
|
|
BOCHSAPI Boolean pluginDevicePresent(char *name);
|
|
|
|
/* === IO port stuff === */
|
|
BOCHSAPI extern int (*pluginRegisterIOReadHandler)(void *thisPtr, ioReadHandler_t callback,
|
|
unsigned base, const char *name, unsigned len);
|
|
BOCHSAPI extern int (*pluginRegisterIOWriteHandler)(void *thisPtr, ioWriteHandler_t callback,
|
|
unsigned base, const char *name, unsigned len);
|
|
BOCHSAPI extern int (*pluginRegisterDefaultIOReadHandler)(void *thisPtr, ioReadHandler_t callback,
|
|
const char *name, unsigned len);
|
|
BOCHSAPI extern int (*pluginRegisterDefaultIOWriteHandler)(void *thisPtr, ioWriteHandler_t callback,
|
|
const char *name, unsigned len);
|
|
|
|
/* === A20 enable line stuff === */
|
|
BOCHSAPI extern unsigned (*pluginGetA20E)(void);
|
|
BOCHSAPI extern void (*pluginSetA20E)(unsigned val);
|
|
|
|
/* === IRQ stuff === */
|
|
BOCHSAPI extern void (*pluginRegisterIRQ)(unsigned irq, const char *name);
|
|
BOCHSAPI extern void (*pluginUnregisterIRQ)(unsigned irq, const char *name);
|
|
|
|
/* === Floppy stuff ===*/
|
|
BOCHSAPI extern unsigned (* pluginFloppyGetMediaStatus)(unsigned drive);
|
|
BOCHSAPI extern unsigned (* pluginFloppySetMediaStatus)(unsigned drive, unsigned status);
|
|
|
|
/* === VGA stuff === */
|
|
BOCHSAPI extern void (* pluginVGARedrawArea)(unsigned x0, unsigned y0,
|
|
unsigned width, unsigned height);
|
|
BOCHSAPI extern Bit8u (* pluginVGAMemRead)(Bit32u addr);
|
|
BOCHSAPI extern void (* pluginVGAMemWrite)(Bit32u addr, Bit8u value);
|
|
BOCHSAPI extern void (* pluginVGAGetTextSnapshot)(Bit8u **text_snapshot,
|
|
unsigned *txHeight, unsigned *txWidth);
|
|
BOCHSAPI extern void (* pluginVGARefresh)(void *);
|
|
BOCHSAPI extern void (* pluginVGASetUpdateInterval)(unsigned);
|
|
|
|
/* === Timer stuff === */
|
|
BOCHSAPI extern int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *),
|
|
Bit32u useconds, Boolean continuous,
|
|
Boolean active, const char *name);
|
|
|
|
BOCHSAPI extern void (*pluginActivateTimer)(unsigned id, Bit32u usec, Boolean continuous);
|
|
BOCHSAPI extern void (*pluginDeactivateTimer)(unsigned id);
|
|
|
|
/* === HRQ stuff === */
|
|
BOCHSAPI extern void (*pluginSetHRQ)(unsigned val);
|
|
BOCHSAPI extern void (*pluginSetHRQHackCallback)( void (*callback)(void) );
|
|
|
|
/* === Reset stuff === */
|
|
BOCHSAPI extern void (*pluginResetSignal)(unsigned sig);
|
|
|
|
void plugin_abort (void);
|
|
|
|
// called from bochs main (hack)
|
|
extern int bx_load_plugins ();
|
|
int bx_load_plugin (const char *name, plugintype_t type);
|
|
extern void bx_init_plugins (void);
|
|
extern void bx_reset_plugins (unsigned);
|
|
|
|
// every plugin must define these, within the extern"C" block, so that
|
|
// a non-mangled function symbol is available in the shared library.
|
|
void plugin_fini(void);
|
|
int plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[]);
|
|
|
|
// still in extern "C"
|
|
#define DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(mod) \
|
|
int lib##mod##_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[]); \
|
|
void lib##mod##_LTX_plugin_fini(void);
|
|
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(harddrv)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(keyboard)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(serial)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(unmapped)
|
|
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(vga)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(floppy)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(parallel)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(amigaos)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(beos)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(carbon)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(macintosh)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(nogui)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(rfb)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(sdl)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(term)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(win32)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(wx)
|
|
DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(x)
|
|
|
|
|
|
#ifdef __cplusplus
|
|
};
|
|
#endif
|
|
|
|
#endif /* __PLUGIN_H */
|