Renamed bx_pci_device_stub_c to bx_pci_device_c and derive it now from class

bx_devmodel_c. The early version of the combined vga / svga_cirrus code
required the now obsolete implementation. Some related cleanups in the
devices code.
This commit is contained in:
Volker Ruppert 2017-03-26 08:09:28 +00:00
parent 411ea954b4
commit 76b54ecb61
19 changed files with 118 additions and 96 deletions

View File

@ -68,19 +68,14 @@ bx_devices_c::~bx_devices_c()
void bx_devices_c::init_stubs()
{
pluginPci2IsaBridge = &stubPci2Isa;
pluginPciIdeController = &stubPciIde;
#if BX_SUPPORT_PCI
pluginACPIController = &stubACPIController;
#endif
pluginKeyboard = &stubKeyboard;
pluginCmosDevice = &stubCmos;
pluginDmaDevice = &stubDma;
pluginFloppyDevice = &stubFloppy;
pluginCmosDevice = &stubCmos;
pluginVgaDevice = &stubVga;
pluginPicDevice = &stubPic;
pluginHardDrive = &stubHardDrive;
pluginKeyboard = &stubKeyboard;
pluginPicDevice = &stubPic;
pluginSpeaker = &stubSpeaker;
pluginVgaDevice = &stubVga;
#if BX_SUPPORT_IODEBUG
pluginIODebug = &stubIODebug;
#endif
@ -90,6 +85,11 @@ void bx_devices_c::init_stubs()
#if BX_SUPPORT_GAMEPORT
pluginGameport = &stubGameport;
#endif
#if BX_SUPPORT_PCI
pluginPci2IsaBridge = &stubPci2Isa;
pluginPciIdeController = &stubPciIde;
pluginACPIController = &stubACPIController;
#endif
#if BX_SUPPORT_PCIUSB
pluginUsbDevCtl = &stubUsbDevCtl;
#endif
@ -97,7 +97,10 @@ void bx_devices_c::init_stubs()
void bx_devices_c::init(BX_MEM_C *newmem)
{
unsigned i, chipset;
#if BX_SUPPORT_PCI
unsigned chipset;
#endif
unsigned i;
const char def_name[] = "Default";
const char *vga_ext;
@ -170,8 +173,8 @@ void bx_devices_c::init(BX_MEM_C *newmem)
// PCI logic (i440FX)
pci.enabled = SIM->get_param_bool(BXPN_PCI_ENABLED)->get();
if (pci.enabled) {
chipset = SIM->get_param_enum(BXPN_PCI_CHIPSET)->get();
#if BX_SUPPORT_PCI
chipset = SIM->get_param_enum(BXPN_PCI_CHIPSET)->get();
PLUG_load_plugin(pci, PLUGTYPE_CORE);
PLUG_load_plugin(pci2isa, PLUGTYPE_CORE);
#if BX_SUPPORT_PCIUSB
@ -1140,8 +1143,9 @@ void bx_devices_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned
}
}
#if BX_SUPPORT_PCI
// generic PCI support
void bx_pci_device_stub_c::init_pci_conf(Bit16u vid, Bit16u did, Bit8u rev, Bit32u classc, Bit8u headt)
void bx_pci_device_c::init_pci_conf(Bit16u vid, Bit16u did, Bit8u rev, Bit32u classc, Bit8u headt)
{
memset(pci_conf, 0, 256);
pci_conf[0x00] = (Bit8u)(vid & 0xff);
@ -1155,12 +1159,12 @@ void bx_pci_device_stub_c::init_pci_conf(Bit16u vid, Bit16u did, Bit8u rev, Bit3
pci_conf[0x0e] = headt;
}
void bx_pci_device_stub_c::register_pci_state(bx_list_c *list)
void bx_pci_device_c::register_pci_state(bx_list_c *list)
{
new bx_shadow_data_c(list, "pci_conf", pci_conf, 256, 1);
}
void bx_pci_device_stub_c::load_pci_rom(const char *path)
void bx_pci_device_c::load_pci_rom(const char *path)
{
struct stat stat_buf;
int fd, ret;
@ -1217,7 +1221,7 @@ void bx_pci_device_stub_c::load_pci_rom(const char *path)
BX_INFO(("loaded PCI ROM '%s' (size=%u / PCI=%uk)", path, (unsigned) stat_buf.st_size, pci_rom_size >> 10));
}
Bit32u bx_pci_device_stub_c::pci_read_handler(Bit8u address, unsigned io_len)
Bit32u bx_pci_device_c::pci_read_handler(Bit8u address, unsigned io_len)
{
Bit32u value = 0;
@ -1235,8 +1239,7 @@ Bit32u bx_pci_device_stub_c::pci_read_handler(Bit8u address, unsigned io_len)
return value;
}
#if BX_SUPPORT_PCI
bx_bool bx_devices_c::register_pci_handlers(bx_pci_device_stub_c *dev,
bx_bool bx_devices_c::register_pci_handlers(bx_pci_device_c *dev,
Bit8u *devfunc, const char *name,
const char *descr)
{

View File

@ -463,11 +463,12 @@ void bx_svga_cirrus_c::redraw_area(unsigned x0, unsigned y0,
if ((width == 0) || (height == 0)) {
return;
}
#if BX_SUPPORT_PCI
if (BX_CIRRUS_THIS s.vga_override && (BX_CIRRUS_THIS s.nvgadev != NULL)) {
BX_CIRRUS_THIS s.nvgadev->redraw_area(x0, y0, width, height);
return;
}
#endif
if ((BX_CIRRUS_THIS sequencer.reg[0x07] & 0x01) == CIRRUS_SR7_BPP_VGA) {
BX_CIRRUS_THIS bx_vgacore_c::redraw_area(x0,y0,width,height);
return;
@ -1013,14 +1014,16 @@ void bx_svga_cirrus_c::svga_write(Bit32u address, Bit32u value, unsigned io_len)
void bx_svga_cirrus_c::refresh_display(void *this_ptr, bx_bool redraw)
{
#if BX_SUPPORT_PCI
if (BX_CIRRUS_THIS s.vga_override && (BX_CIRRUS_THIS s.nvgadev != NULL)) {
BX_CIRRUS_THIS s.nvgadev->refresh_display(BX_CIRRUS_THIS s.nvgadev, redraw);
} else {
if (redraw) {
redraw_area(0, 0, BX_CIRRUS_THIS s.last_xres, BX_CIRRUS_THIS s.last_yres);
}
svga_timer_handler(this_ptr);
return;
}
#endif
if (redraw) {
redraw_area(0, 0, BX_CIRRUS_THIS s.last_xres, BX_CIRRUS_THIS s.last_yres);
}
svga_timer_handler(this_ptr);
}
void bx_svga_cirrus_c::svga_timer_handler(void *this_ptr)

View File

@ -345,14 +345,16 @@ Bit64s bx_vga_c::vga_param_handler(bx_param_c *param, int set, Bit64s val)
void bx_vga_c::refresh_display(void *this_ptr, bx_bool redraw)
{
#if BX_SUPPORT_PCI
if (BX_VGA_THIS s.vga_override && (BX_VGA_THIS s.nvgadev != NULL)) {
BX_VGA_THIS s.nvgadev->refresh_display(BX_VGA_THIS s.nvgadev, redraw);
} else {
if (redraw) {
redraw_area(0, 0, BX_VGA_THIS s.last_xres, BX_VGA_THIS s.last_yres);
}
timer_handler(this_ptr);
return;
}
#endif
if (redraw) {
redraw_area(0, 0, BX_VGA_THIS s.last_xres, BX_VGA_THIS s.last_yres);
}
timer_handler(this_ptr);
}
void bx_vga_c::timer_handler(void *this_ptr)
@ -780,11 +782,12 @@ void bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
if (width == 0 || height == 0) {
return;
}
#if BX_SUPPORT_PCI
if (BX_VGA_THIS s.vga_override && (BX_VGA_THIS s.nvgadev != NULL)) {
BX_VGA_THIS s.nvgadev->redraw_area(x0, y0, width, height);
return;
}
#endif
if (BX_VGA_THIS vbe.enabled) {
BX_VGA_THIS s.vga_mem_updated = 1;
xmax = BX_VGA_THIS vbe.xres;

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2015 The Bochs Project
// Copyright (C) 2001-2017 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -1300,7 +1300,9 @@ void bx_vgacore_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool
void bx_vgacore_c::set_override(bx_bool enabled, void *dev)
{
BX_VGA_THIS s.vga_override = enabled;
#if BX_SUPPORT_PCI
BX_VGA_THIS s.nvgadev = (bx_nonvga_device_c*)dev;
#endif
if (enabled) {
bx_virt_timer.deactivate_timer(BX_VGA_THIS timer_id);
} else {

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2015 The Bochs Project
// Copyright (C) 2001-2017 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -45,18 +45,16 @@
#define X_TILESIZE 16
#define Y_TILESIZE 24
class bx_nonvga_device_c : public bx_devmodel_c {
#if BX_SUPPORT_PCI
class bx_nonvga_device_c : public bx_pci_device_c {
public:
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height) {}
virtual void refresh_display(void *this_ptr, bx_bool redraw) {}
};
class bx_vgacore_c : public bx_vga_stub_c
#if BX_SUPPORT_PCI
, public bx_pci_device_stub_c
#endif
{
class bx_vgacore_c : public bx_vga_stub_c {
public:
bx_vgacore_c();
virtual ~bx_vgacore_c();
@ -235,7 +233,9 @@ protected:
Bit16u num_y_tiles;
// vga override mode
bx_bool vga_override;
#if BX_SUPPORT_PCI
bx_nonvga_device_c *nvgadev;
#endif
} s; // state information
int timer_id;

View File

@ -43,7 +43,7 @@ typedef struct {
} bx_voodoo_t;
class bx_voodoo_c : public bx_nonvga_device_c, bx_pci_device_stub_c {
class bx_voodoo_c : public bx_nonvga_device_c {
public:
bx_voodoo_c();
virtual ~bx_voodoo_c();

View File

@ -667,7 +667,9 @@ void bx_hard_drive_c::seek_timer()
controller->status.seek_complete = 1;
controller->status.drq = 1;
controller->status.corrected_data = 0;
#if BX_SUPPORT_PCI
DEV_ide_bmdma_start_transfer(channel);
#endif
break;
case 0x70: // SEEK
BX_SELECTED_DRIVE(channel).curr_lsector = BX_SELECTED_DRIVE(channel).next_lsector;
@ -3165,7 +3167,9 @@ bx_hard_drive_c::ready_to_send_atapi(Bit8u channel)
controller->status.err = 0;
if (BX_SELECTED_CONTROLLER(channel).packet_dma) {
#if BX_SUPPORT_PCI
DEV_ide_bmdma_start_transfer(channel);
#endif
} else {
raise_interrupt(channel);
}

View File

@ -83,15 +83,14 @@ class device_image_t;
class cdrom_base_c;
//////////////////////////////////////////////////////////////////////
// declare stubs for PCI devices
// bx_pci_device_c declaration
//////////////////////////////////////////////////////////////////////
// the best should be deriving of bx_pci_device_stub_c from bx_devmodel_c
// but it make serious problems for cirrus_svga device
class BOCHSAPI bx_pci_device_stub_c {
#if BX_SUPPORT_PCI
class BOCHSAPI bx_pci_device_c : public bx_devmodel_c {
public:
bx_pci_device_stub_c(): pci_rom(NULL), pci_rom_size(0) {}
virtual ~bx_pci_device_stub_c() {
bx_pci_device_c(): pci_rom(NULL), pci_rom_size(0) {}
virtual ~bx_pci_device_c() {
if (pci_rom != NULL) delete [] pci_rom;
}
@ -109,6 +108,7 @@ protected:
Bit32u pci_rom_address;
Bit32u pci_rom_size;
};
#endif
//////////////////////////////////////////////////////////////////////
// declare stubs for devices
@ -226,7 +226,13 @@ public:
}
};
class BOCHSAPI bx_vga_stub_c : public bx_devmodel_c {
class BOCHSAPI bx_vga_stub_c
#if BX_SUPPORT_PCI
: public bx_pci_device_c
#else
: public bx_devmodel_c
#endif
{
public:
virtual void redraw_area(unsigned x0, unsigned y0,
unsigned width, unsigned height) {
@ -250,22 +256,6 @@ public:
}
};
class BOCHSAPI bx_pci2isa_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c {
public:
virtual void pci_set_irq (Bit8u devfunc, unsigned line, bx_bool level) {
STUBFUNC(pci2isa, pci_set_irq);
}
};
class BOCHSAPI bx_pci_ide_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c {
public:
virtual bx_bool bmdma_present(void) {
return 0;
}
virtual void bmdma_start_transfer(Bit8u channel) {}
virtual void bmdma_set_irq(Bit8u channel) {}
};
class BOCHSAPI bx_speaker_stub_c : public bx_devmodel_c {
public:
virtual void beep_on(float frequency) {
@ -277,7 +267,23 @@ public:
};
#if BX_SUPPORT_PCI
class BOCHSAPI bx_acpi_ctrl_stub_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class BOCHSAPI bx_pci2isa_stub_c : public bx_pci_device_c {
public:
virtual void pci_set_irq (Bit8u devfunc, unsigned line, bx_bool level) {
STUBFUNC(pci2isa, pci_set_irq);
}
};
class BOCHSAPI bx_pci_ide_stub_c : public bx_pci_device_c {
public:
virtual bx_bool bmdma_present(void) {
return 0;
}
virtual void bmdma_start_transfer(Bit8u channel) {}
virtual void bmdma_set_irq(Bit8u channel) {}
};
class BOCHSAPI bx_acpi_ctrl_stub_c : public bx_pci_device_c {
public:
virtual void generate_smi(Bit8u value) {}
};
@ -385,7 +391,7 @@ public:
#if BX_SUPPORT_PCI
Bit32u pci_get_confAddr(void) {return pci.confAddr;}
bx_bool register_pci_handlers(bx_pci_device_stub_c *device, Bit8u *devfunc,
bx_bool register_pci_handlers(bx_pci_device_c *device, Bit8u *devfunc,
const char *name, const char *descr);
bx_bool pci_set_base_mem(void *this_ptr, memory_handler_t f1, memory_handler_t f2,
Bit32u *addr, Bit8u *pci_conf, unsigned size);
@ -397,21 +403,15 @@ public:
static void timer_handler(void *);
void timer(void);
bx_pci2isa_stub_c *pluginPci2IsaBridge;
bx_pci_ide_stub_c *pluginPciIdeController;
#if BX_SUPPORT_PCI
bx_acpi_ctrl_stub_c *pluginACPIController;
#endif
bx_devmodel_c *pluginPitDevice;
bx_keyb_stub_c *pluginKeyboard;
bx_cmos_stub_c *pluginCmosDevice;
bx_dma_stub_c *pluginDmaDevice;
bx_floppy_stub_c *pluginFloppyDevice;
bx_cmos_stub_c *pluginCmosDevice;
bx_vga_stub_c *pluginVgaDevice;
bx_pic_stub_c *pluginPicDevice;
bx_hard_drive_stub_c *pluginHardDrive;
bx_hdimage_ctl_stub_c *pluginHDImageCtl;
bx_keyb_stub_c *pluginKeyboard;
bx_pic_stub_c *pluginPicDevice;
bx_speaker_stub_c *pluginSpeaker;
bx_vga_stub_c *pluginVgaDevice;
#if BX_SUPPORT_IODEBUG
bx_iodebug_stub_c *pluginIODebug;
#endif
@ -421,6 +421,11 @@ public:
#if BX_SUPPORT_GAMEPORT
bx_game_stub_c *pluginGameport;
#endif
#if BX_SUPPORT_PCI
bx_pci2isa_stub_c *pluginPci2IsaBridge;
bx_pci_ide_stub_c *pluginPciIdeController;
bx_acpi_ctrl_stub_c *pluginACPIController;
#endif
#if BX_SUPPORT_PCIUSB
bx_usb_devctl_stub_c *pluginUsbDevCtl;
#endif
@ -428,19 +433,14 @@ public:
// stub classes that the pointers (above) can point to until a plugin is
// loaded
bx_cmos_stub_c stubCmos;
bx_keyb_stub_c stubKeyboard;
bx_dma_stub_c stubDma;
bx_floppy_stub_c stubFloppy;
bx_hard_drive_stub_c stubHardDrive;
bx_hdimage_ctl_stub_c stubHDImage;
bx_dma_stub_c stubDma;
bx_keyb_stub_c stubKeyboard;
bx_pic_stub_c stubPic;
bx_floppy_stub_c stubFloppy;
bx_vga_stub_c stubVga;
bx_pci2isa_stub_c stubPci2Isa;
bx_pci_ide_stub_c stubPciIde;
bx_speaker_stub_c stubSpeaker;
#if BX_SUPPORT_PCI
bx_acpi_ctrl_stub_c stubACPIController;
#endif
bx_vga_stub_c stubVga;
#if BX_SUPPORT_IODEBUG
bx_iodebug_stub_c stubIODebug;
#endif
@ -450,6 +450,11 @@ public:
#if BX_SUPPORT_GAMEPORT
bx_game_stub_c stubGameport;
#endif
#if BX_SUPPORT_PCI
bx_pci2isa_stub_c stubPci2Isa;
bx_pci_ide_stub_c stubPciIde;
bx_acpi_ctrl_stub_c stubACPIController;
#endif
#if BX_SUPPORT_PCIUSB
bx_usb_devctl_stub_c stubUsbDevCtl;
#endif
@ -510,7 +515,7 @@ private:
#if BX_SUPPORT_PCI
Bit8u handler_id[0x100]; // 256 devices/functions
struct {
bx_pci_device_stub_c *handler;
bx_pci_device_c *handler;
} pci_handler[BX_MAX_PCI_DEVICES];
unsigned num_pci_handlers;

View File

@ -113,7 +113,7 @@ typedef struct {
} bx_e1000_t;
class bx_e1000_c : public bx_devmodel_c, bx_pci_device_stub_c {
class bx_e1000_c : public bx_pci_device_c {
public:
bx_e1000_c();
virtual ~bx_e1000_c();

View File

@ -197,9 +197,11 @@ typedef struct {
#endif
} bx_ne2k_t;
class bx_ne2k_c : public bx_devmodel_c
class bx_ne2k_c
#if BX_SUPPORT_PCI
, public bx_pci_device_stub_c
: public bx_pci_device_c
#else
: public bx_devmodel_c
#endif
{
public:

View File

@ -60,7 +60,7 @@ typedef struct {
} bx_pnic_t;
class bx_pcipnic_c : public bx_devmodel_c, bx_pci_device_stub_c {
class bx_pcipnic_c : public bx_pci_device_c {
public:
bx_pcipnic_c();
virtual ~bx_pcipnic_c();

View File

@ -36,7 +36,7 @@
#define BX_PCI_INTC 3
#define BX_PCI_INTD 4
class bx_pci_bridge_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_pci_bridge_c : public bx_pci_device_c {
public:
bx_pci_bridge_c();
virtual ~bx_pci_bridge_c();

View File

@ -4,7 +4,8 @@
/*
* PCIDEV: PCI host device mapping
* Copyright (C) 2003 - Frank Cornelis
* Copyright (C) 2003 Frank Cornelis
* Copyright (C) 2003-2017 The Bochs Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -39,7 +40,7 @@ struct region_struct {
class bx_pcidev_c *pcidev;
};
class bx_pcidev_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_pcidev_c : public bx_pci_device_c {
public:
bx_pcidev_c();
virtual ~bx_pcidev_c();

View File

@ -37,7 +37,6 @@ int CDECL libpit_LTX_plugin_init(plugin_t *plugin, plugintype_t type)
{
if (type == PLUGTYPE_CORE) {
thePit = new bx_pit_c();
bx_devices.pluginPitDevice = thePit;
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, thePit, BX_PLUGIN_PIT);
return 0; // Success
} else {

View File

@ -82,7 +82,7 @@ typedef struct {
} bx_es1370_t;
class bx_es1370_c : public bx_devmodel_c, bx_pci_device_stub_c {
class bx_es1370_c : public bx_pci_device_c {
public:
bx_es1370_c();
virtual ~bx_es1370_c();

View File

@ -170,7 +170,7 @@ struct HCSTACK {
bx_bool t;
};
class bx_uhci_core_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_uhci_core_c : public bx_pci_device_c {
public:
bx_uhci_core_c();
virtual ~bx_uhci_core_c();

View File

@ -322,7 +322,7 @@ struct EHCIQueue {
QTAILQ_HEAD(, EHCIPacket) packets;
};
class bx_usb_ehci_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_usb_ehci_c : public bx_pci_device_c {
public:
bx_usb_ehci_c();
virtual ~bx_usb_ehci_c();

View File

@ -248,7 +248,7 @@ typedef struct {
class bx_usb_ohci_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_usb_ohci_c : public bx_pci_device_c {
public:
bx_usb_ohci_c();
virtual ~bx_usb_ohci_c();

View File

@ -532,7 +532,7 @@ typedef struct {
#error "ERSTABADD_MASK not defined"
#endif
class bx_usb_xhci_c : public bx_devmodel_c, public bx_pci_device_stub_c {
class bx_usb_xhci_c : public bx_pci_device_c {
public:
bx_usb_xhci_c();
virtual ~bx_usb_xhci_c();