From d6a62ffd471654b79d02042e685a2361c105921f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Mar 2014 14:41:36 +0000 Subject: [PATCH] Shuffle PCI and some more PC related devices around (nw) cirrus is not moved since it's not made as proper pci device --- .gitattributes | 30 +- src/emu/bus/bus.mak | 16 + src/{mess/machine => emu/bus/pci}/i82371ab.c | 0 src/{mess/machine => emu/bus/pci}/i82371ab.h | 4 +- src/{mess/machine => emu/bus/pci}/i82371sb.c | 0 src/{mess/machine => emu/bus/pci}/i82371sb.h | 4 +- src/{mess/machine => emu/bus/pci}/i82439tx.c | 0 src/{mess/machine => emu/bus/pci}/i82439tx.h | 4 +- src/{mess/machine => emu/bus/pci}/mpc105.c | 2 +- src/{mess/machine => emu/bus/pci}/mpc105.h | 4 +- .../machine => emu/bus/pci}/northbridge.c | 2 +- .../machine => emu/bus/pci}/northbridge.h | 0 src/emu/bus/pci/pci.c | 332 ++++++++++++++++++ src/emu/bus/pci/pci.h | 110 ++++++ .../machine => emu/bus/pci}/southbridge.c | 2 +- .../machine => emu/bus/pci}/southbridge.h | 2 +- src/emu/emu.mak | 1 + src/{mess => emu}/machine/at_keybc.c | 0 src/{mess => emu}/machine/at_keybc.h | 0 src/emu/machine/machine.mak | 8 + src/emu/machine/pci.c | 261 +------------- src/emu/machine/pci.h | 99 ------ src/mame/drivers/gammagic.c | 4 +- src/mess/drivers/bebox.c | 4 +- src/mess/includes/at.h | 8 +- src/mess/machine/bebox.c | 2 +- src/mess/mess.mak | 13 +- src/mess/video/cirrus.h | 2 +- 28 files changed, 508 insertions(+), 406 deletions(-) rename src/{mess/machine => emu/bus/pci}/i82371ab.c (100%) rename src/{mess/machine => emu/bus/pci}/i82371ab.h (96%) rename src/{mess/machine => emu/bus/pci}/i82371sb.c (100%) rename src/{mess/machine => emu/bus/pci}/i82371sb.h (96%) rename src/{mess/machine => emu/bus/pci}/i82439tx.c (100%) rename src/{mess/machine => emu/bus/pci}/i82439tx.h (96%) rename src/{mess/machine => emu/bus/pci}/mpc105.c (99%) rename src/{mess/machine => emu/bus/pci}/mpc105.h (97%) rename src/{mess/machine => emu/bus/pci}/northbridge.c (97%) rename src/{mess/machine => emu/bus/pci}/northbridge.h (100%) create mode 100644 src/emu/bus/pci/pci.c create mode 100644 src/emu/bus/pci/pci.h rename src/{mess/machine => emu/bus/pci}/southbridge.c (99%) rename src/{mess/machine => emu/bus/pci}/southbridge.h (99%) rename src/{mess => emu}/machine/at_keybc.c (100%) rename src/{mess => emu}/machine/at_keybc.h (100%) diff --git a/.gitattributes b/.gitattributes index 5278032f96b..29703de96ee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -919,6 +919,20 @@ src/emu/bus/pc_kbd/pcat84.c svneol=native#text/plain src/emu/bus/pc_kbd/pcat84.h svneol=native#text/plain src/emu/bus/pc_kbd/pcxt83.c svneol=native#text/plain src/emu/bus/pc_kbd/pcxt83.h svneol=native#text/plain +src/emu/bus/pci/i82371ab.c svneol=native#text/plain +src/emu/bus/pci/i82371ab.h svneol=native#text/plain +src/emu/bus/pci/i82371sb.c svneol=native#text/plain +src/emu/bus/pci/i82371sb.h svneol=native#text/plain +src/emu/bus/pci/i82439tx.c svneol=native#text/plain +src/emu/bus/pci/i82439tx.h svneol=native#text/plain +src/emu/bus/pci/mpc105.c svneol=native#text/plain +src/emu/bus/pci/mpc105.h svneol=native#text/plain +src/emu/bus/pci/northbridge.c svneol=native#text/plain +src/emu/bus/pci/northbridge.h svneol=native#text/plain +src/emu/bus/pci/pci.c svneol=native#text/plain +src/emu/bus/pci/pci.h svneol=native#text/plain +src/emu/bus/pci/southbridge.c svneol=native#text/plain +src/emu/bus/pci/southbridge.h svneol=native#text/plain src/emu/bus/pet/64k.c svneol=native#text/plain src/emu/bus/pet/64k.h svneol=native#text/plain src/emu/bus/pet/c2n.c svneol=native#text/plain @@ -1939,6 +1953,8 @@ src/emu/machine/at29040a.c svneol=native#text/plain src/emu/machine/at29040a.h svneol=native#text/plain src/emu/machine/at45dbxx.c svneol=native#text/plain src/emu/machine/at45dbxx.h svneol=native#text/plain +src/emu/machine/at_keybc.c svneol=native#text/plain +src/emu/machine/at_keybc.h svneol=native#text/plain src/emu/machine/atadev.c svneol=native#text/plain src/emu/machine/atadev.h svneol=native#text/plain src/emu/machine/ataflash.c svneol=native#text/plain @@ -8035,8 +8051,6 @@ src/mess/machine/applefdc.h svneol=native#text/plain src/mess/machine/apricotkb.c svneol=native#text/plain src/mess/machine/apricotkb.h svneol=native#text/plain src/mess/machine/at.c svneol=native#text/plain -src/mess/machine/at_keybc.c svneol=native#text/plain -src/mess/machine/at_keybc.h svneol=native#text/plain src/mess/machine/ataricrt.c svneol=native#text/plain src/mess/machine/atarifdc.c svneol=native#text/plain src/mess/machine/atarifdc.h svneol=native#text/plain @@ -8152,12 +8166,6 @@ src/mess/machine/hd64610.h svneol=native#text/plain src/mess/machine/hec2hrp.c svneol=native#text/plain src/mess/machine/hecdisk2.c svneol=native#text/plain src/mess/machine/hp48.c svneol=native#text/plain -src/mess/machine/i82371ab.c svneol=native#text/plain -src/mess/machine/i82371ab.h svneol=native#text/plain -src/mess/machine/i82371sb.c svneol=native#text/plain -src/mess/machine/i82371sb.h svneol=native#text/plain -src/mess/machine/i82439tx.c svneol=native#text/plain -src/mess/machine/i82439tx.h svneol=native#text/plain src/mess/machine/i8271.c svneol=native#text/plain src/mess/machine/i8271.h svneol=native#text/plain src/mess/machine/intv.c svneol=native#text/plain @@ -8224,8 +8232,6 @@ src/mess/machine/micropolis.c svneol=native#text/plain src/mess/machine/micropolis.h svneol=native#text/plain src/mess/machine/microtan.c svneol=native#text/plain src/mess/machine/mikro80.c svneol=native#text/plain -src/mess/machine/mpc105.c svneol=native#text/plain -src/mess/machine/mpc105.h svneol=native#text/plain src/mess/machine/msm6222b.c svneol=native#text/plain src/mess/machine/msm6222b.h svneol=native#text/plain src/mess/machine/msx.c svneol=native#text/plain @@ -8341,8 +8347,6 @@ src/mess/machine/nextkbd.c svneol=native#text/plain src/mess/machine/nextkbd.h svneol=native#text/plain src/mess/machine/nextmo.c svneol=native#text/plain src/mess/machine/nextmo.h svneol=native#text/plain -src/mess/machine/northbridge.c svneol=native#text/plain -src/mess/machine/northbridge.h svneol=native#text/plain src/mess/machine/ondra.c svneol=native#text/plain src/mess/machine/orao.c svneol=native#text/plain src/mess/machine/oric.c svneol=native#text/plain @@ -8482,8 +8486,6 @@ src/mess/machine/sns_upd.h svneol=native#text/plain src/mess/machine/sonydriv.c svneol=native#text/plain src/mess/machine/sonydriv.h svneol=native#text/plain src/mess/machine/sorcerer.c svneol=native#text/plain -src/mess/machine/southbridge.c svneol=native#text/plain -src/mess/machine/southbridge.h svneol=native#text/plain src/mess/machine/spec_snqk.c svneol=native#text/plain src/mess/machine/spec_snqk.h svneol=native#text/plain src/mess/machine/special.c svneol=native#text/plain diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index b63079e04f1..84d8e1689ef 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -667,3 +667,19 @@ BUSOBJS += $(BUSOBJ)/midi/midi.o BUSOBJS += $(BUSOBJ)/midi/midiinport.o BUSOBJS += $(BUSOBJ)/midi/midioutport.o endif + +#------------------------------------------------- +# +#@src/emu/bus/pci/pci.h,BUSES += PCI +#------------------------------------------------- + +ifneq ($(filter PCI,$(BUSES)),) +BUSOBJS += $(BUSOBJ)/pci/pci.o +BUSOBJS += $(BUSOBJ)/pci/i82371ab.o +BUSOBJS += $(BUSOBJ)/pci/i82371sb.o +BUSOBJS += $(BUSOBJ)/pci/i82439tx.o +BUSOBJS += $(BUSOBJ)/pci/northbridge.o +BUSOBJS += $(BUSOBJ)/pci/southbridge.o +BUSOBJS += $(BUSOBJ)/pci/mpc105.o +endif + diff --git a/src/mess/machine/i82371ab.c b/src/emu/bus/pci/i82371ab.c similarity index 100% rename from src/mess/machine/i82371ab.c rename to src/emu/bus/pci/i82371ab.c diff --git a/src/mess/machine/i82371ab.h b/src/emu/bus/pci/i82371ab.h similarity index 96% rename from src/mess/machine/i82371ab.h rename to src/emu/bus/pci/i82371ab.h index a7a2d4ebd4a..c90468e0481 100644 --- a/src/mess/machine/i82371ab.h +++ b/src/emu/bus/pci/i82371ab.h @@ -9,8 +9,8 @@ #ifndef __I82371AB_H__ #define __I82371AB_H__ -#include "machine/pci.h" -#include "machine/southbridge.h" +#include "pci.h" +#include "southbridge.h" // ======================> i82371ab_device diff --git a/src/mess/machine/i82371sb.c b/src/emu/bus/pci/i82371sb.c similarity index 100% rename from src/mess/machine/i82371sb.c rename to src/emu/bus/pci/i82371sb.c diff --git a/src/mess/machine/i82371sb.h b/src/emu/bus/pci/i82371sb.h similarity index 96% rename from src/mess/machine/i82371sb.h rename to src/emu/bus/pci/i82371sb.h index c58c3f804e3..c9ccbff9a8c 100644 --- a/src/mess/machine/i82371sb.h +++ b/src/emu/bus/pci/i82371sb.h @@ -9,8 +9,8 @@ #ifndef __I82371SB_H__ #define __I82371SB_H__ -#include "machine/pci.h" -#include "machine/southbridge.h" +#include "pci.h" +#include "southbridge.h" // ======================> i82371sb_device diff --git a/src/mess/machine/i82439tx.c b/src/emu/bus/pci/i82439tx.c similarity index 100% rename from src/mess/machine/i82439tx.c rename to src/emu/bus/pci/i82439tx.c diff --git a/src/mess/machine/i82439tx.h b/src/emu/bus/pci/i82439tx.h similarity index 96% rename from src/mess/machine/i82439tx.h rename to src/emu/bus/pci/i82439tx.h index 8beba4dbbfc..3e8d1514e49 100644 --- a/src/mess/machine/i82439tx.h +++ b/src/emu/bus/pci/i82439tx.h @@ -9,8 +9,8 @@ #ifndef __I82439TX_H__ #define __I82439TX_H__ -#include "machine/pci.h" -#include "machine/northbridge.h" +#include "pci.h" +#include "northbridge.h" #define MCFG_I82439TX_CPU( _tag ) \ i82439tx_device::static_set_cpu(*device, _tag); diff --git a/src/mess/machine/mpc105.c b/src/emu/bus/pci/mpc105.c similarity index 99% rename from src/mess/machine/mpc105.c rename to src/emu/bus/pci/mpc105.c index 93aca8aeb0c..da1998af79b 100644 --- a/src/mess/machine/mpc105.c +++ b/src/emu/bus/pci/mpc105.c @@ -1,6 +1,6 @@ /*************************************************************************** - machine/mpc105.h + mpc105.h Motorola MPC105 PCI bridge diff --git a/src/mess/machine/mpc105.h b/src/emu/bus/pci/mpc105.h similarity index 97% rename from src/mess/machine/mpc105.h rename to src/emu/bus/pci/mpc105.h index 66efd12751e..ae3f4f2b1cc 100644 --- a/src/mess/machine/mpc105.h +++ b/src/emu/bus/pci/mpc105.h @@ -1,6 +1,6 @@ /*************************************************************************** - machine/mpc105.h + mpc105.h Motorola MPC105 PCI bridge @@ -9,7 +9,7 @@ #ifndef MPC105_H #define MPC105_H -#include "machine/pci.h" +#include "pci.h" #define MPC105_MEMORYBANK_COUNT 8 diff --git a/src/mess/machine/northbridge.c b/src/emu/bus/pci/northbridge.c similarity index 97% rename from src/mess/machine/northbridge.c rename to src/emu/bus/pci/northbridge.c index 97c3829b6db..83db12613b9 100644 --- a/src/mess/machine/northbridge.c +++ b/src/emu/bus/pci/northbridge.c @@ -5,7 +5,7 @@ ***************************************************************************/ #include "emu.h" -#include "machine/northbridge.h" +#include "northbridge.h" //************************************************************************** // GLOBAL VARIABLES diff --git a/src/mess/machine/northbridge.h b/src/emu/bus/pci/northbridge.h similarity index 100% rename from src/mess/machine/northbridge.h rename to src/emu/bus/pci/northbridge.h diff --git a/src/emu/bus/pci/pci.c b/src/emu/bus/pci/pci.c new file mode 100644 index 00000000000..1f13b78dfe4 --- /dev/null +++ b/src/emu/bus/pci/pci.c @@ -0,0 +1,332 @@ +/*************************************************************************** + + pci.c + + PCI bus + + The PCI bus is a 32-bit bus introduced by Intel, so it is little endian + + Control word: + bit 31: Enable bit + bits 30-24: Reserved + bits 23-16: PCI bus number + bits 15-11: PCI device number + bits 10- 8: PCI function number + bits 7- 0: Offset address + + Standard PCI registers: + 0x00 2 Vendor ID + 0x02 2 Device ID + 0x04 2 PCI Command + 0x06 2 PCI Status + 0x08 1 Revision ID + 0x09 1 Programming Interface + 0x0A 1 Subclass Code + 0x0B 1 Class Code + + Class Code/Subclass Code/Programming Interface + 0x00XXXX Pre-PCI 2.0 devices + 0x000000 Non-VGA device + 0x000101 VGA device + 0x01XXXX Storage Controller + 0x010000 SCSI + 0x0101XX IDE + 0x0102XX Floppy + 0x0103XX IPI + 0x0104XX RAID + 0x0180XX Other + 0x02XXXX Network Card + 0x020000 Ethernet + 0x020100 Tokenring + 0x020200 FDDI + 0x020300 ATM + 0x028000 Other + 0x03XXXX Display Controller + 0x030000 VGA + 0x030001 8514 Compatible + 0x030100 XGA + 0x038000 Other + 0x04XXXX Multimedia + 0x040000 Video + 0x040100 Audio + 0x048000 Other + 0x05XXXX Memory Controller + 0x050000 RAM + 0x050100 Flash + 0x058000 Other + 0x06XXXX Bridge + 0x060000 Host/PCI + 0x060100 PCI/ISA + 0x060200 PCI/EISA + 0x060300 PCI/Micro Channel + 0x060400 PCI/PCI + 0x060500 PCI/PCMCIA + 0x060600 PCI/NuBus + 0x060700 PCI/CardBus + 0x068000 Other + + Information on PCI vendors can be found at http://www.pcidatabase.com/ + +***************************************************************************/ + +#include "emu.h" +#include "pci.h" + +#define LOG_PCI 0 + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type PCI_BUS = &device_creator; + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// pci_bus_device - constructor +//------------------------------------------------- +pci_bus_device::pci_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PCI_BUS, "PCI Bus", tag, owner, clock, "pci_bus", __FILE__), + m_father(NULL) +{ + for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) { + m_devtag[i]= NULL; + } + m_siblings_count = 0; +} + +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +READ32_MEMBER( pci_bus_device::read ) +{ + UINT32 result = 0xffffffff; + int function, reg; + + offset %= 2; + + switch (offset) + { + case 0: + result = m_address; + break; + + case 1: + if (m_devicenum != -1) + { + if (m_busnumaddr->m_device[m_devicenum] != NULL) + { + function = (m_address >> 8) & 0x07; + reg = (m_address >> 0) & 0xfc; + result = m_busnumaddr->m_device[m_devicenum]->pci_read(m_busnumaddr, function, reg, mem_mask); + } + } + break; + } + + if (LOG_PCI) + logerror("read('%s'): offset=%d result=0x%08X\n", tag(), offset, result); + + return result; +} + + + +pci_bus_device *pci_bus_device::pci_search_bustree(int busnum, int devicenum, pci_bus_device *pcibus) +{ + int a; + pci_bus_device *ret; + + if (pcibus->m_busnum == busnum) + { + return pcibus; + } + for (a = 0; a < pcibus->m_siblings_count; a++) + { + ret = pci_search_bustree(busnum, devicenum, pcibus->m_siblings[a]); + if (ret != NULL) + return ret; + } + return NULL; +} + + + +WRITE32_MEMBER( pci_bus_device::write ) +{ + offset %= 2; + + if (LOG_PCI) + logerror("write('%s'): offset=%d data=0x%08X\n", tag(), offset, data); + + switch (offset) + { + case 0: + m_address = data; + + /* lookup current device */ + if (m_address & 0x80000000) + { + int busnum = (m_address >> 16) & 0xff; + int devicenum = (m_address >> 11) & 0x1f; + m_busnumaddr = pci_search_bustree(busnum, devicenum, this); + if (m_busnumaddr != NULL) + { + m_busnumber = busnum; + m_devicenum = devicenum; + } + else + m_devicenum = -1; + if (LOG_PCI) + logerror(" bus:%d device:%d\n", busnum, devicenum); + } + break; + + case 1: + if (m_devicenum != -1) + { + if (m_busnumaddr->m_device[m_devicenum] != NULL) + { + int function = (m_address >> 8) & 0x07; + int reg = (m_address >> 0) & 0xfc; + m_busnumaddr->m_device[m_devicenum]->pci_write(m_busnumaddr, function, reg, data, mem_mask); + } + if (LOG_PCI) + logerror(" function:%d register:%d\n", (m_address >> 8) & 0x07, (m_address >> 0) & 0xfc); + } + break; + } +} + + + +READ64_MEMBER(pci_bus_device::read_64be) +{ + UINT64 result = 0; + mem_mask = FLIPENDIAN_INT64(mem_mask); + if (ACCESSING_BITS_0_31) + result |= (UINT64)read(space, offset * 2 + 0, mem_mask >> 0) << 0; + if (ACCESSING_BITS_32_63) + result |= (UINT64)read(space, offset * 2 + 1, mem_mask >> 32) << 32; + return FLIPENDIAN_INT64(result); +} + +WRITE64_MEMBER(pci_bus_device::write_64be) +{ + data = FLIPENDIAN_INT64(data); + mem_mask = FLIPENDIAN_INT64(mem_mask); + if (ACCESSING_BITS_0_31) + write(space, offset * 2 + 0, data >> 0, mem_mask >> 0); + if (ACCESSING_BITS_32_63) + write(space, offset * 2 + 1, data >> 32, mem_mask >> 32); +} + + +void pci_bus_device::add_sibling(pci_bus_device *sibling, int busnum) +{ + m_siblings[m_siblings_count] = sibling; + m_siblings_busnum[m_siblings_count] = busnum; + m_siblings_count++; +} + + +//------------------------------------------------- +// device_post_load - handle updating after a +// restore +//------------------------------------------------- + +void pci_bus_device::device_post_load() +{ + if (m_devicenum != -1) + { + m_busnumaddr = pci_search_bustree(m_busnumber, m_devicenum, this); + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void pci_bus_device::device_start() +{ + /* store a pointer back to the device */ + m_devicenum = -1; + + char id[3]; + /* find all our devices */ + for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) + { + sprintf(id, "%d", i); + pci_connector *conn = downcast(subdevice(id)); + if (conn!=NULL) + m_device[i] = conn->get_device(); + else + m_device[i] = NULL; + } + + if (m_father != NULL) { + pci_bus_device *father = machine().device(m_father); + if (father) + father->add_sibling(this, m_busnum); + } + + /* register pci states */ + save_item(NAME(m_address)); + save_item(NAME(m_devicenum)); + save_item(NAME(m_busnum)); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void pci_bus_device::device_reset() +{ + /* reset the drive state */ + m_devicenum = -1; + m_address = 0; +} + +//------------------------------------------------- +// pci_device_interface - constructor +//------------------------------------------------- + +pci_device_interface::pci_device_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) +{ +} + +//------------------------------------------------- +// ~pci_device_interface - destructor +//------------------------------------------------- + +pci_device_interface::~pci_device_interface() +{ +} + + +const device_type PCI_CONNECTOR = &device_creator; + + +pci_connector::pci_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PCI_CONNECTOR, "PCI device connector abstraction", tag, owner, clock, "pci_connector", __FILE__), + device_slot_interface(mconfig, *this) +{ +} + +pci_connector::~pci_connector() +{ +} + +void pci_connector::device_start() +{ +} + +pci_device_interface *pci_connector::get_device() +{ + return dynamic_cast(get_card_device()); +} diff --git a/src/emu/bus/pci/pci.h b/src/emu/bus/pci/pci.h new file mode 100644 index 00000000000..97d7b45d988 --- /dev/null +++ b/src/emu/bus/pci/pci.h @@ -0,0 +1,110 @@ +/*************************************************************************** + + pci.h + + PCI bus + +***************************************************************************/ + +#ifndef PCI_H +#define PCI_H + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** +class pci_bus_device; + +// ======================> pci_device_interface + +class pci_device_interface : public device_slot_card_interface +{ +public: + // construction/destruction + pci_device_interface(const machine_config &mconfig, device_t &device); + virtual ~pci_device_interface(); + + virtual UINT32 pci_read(pci_bus_device *pcibus, int function, int offset, UINT32 mem_mask) = 0; + virtual void pci_write(pci_bus_device *pcibus, int function, int offset, UINT32 data, UINT32 mem_mask) = 0; +private: +}; + +class pci_connector: public device_t, + public device_slot_interface +{ +public: + pci_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~pci_connector(); + + pci_device_interface *get_device(); + +protected: + virtual void device_start(); +}; + +extern const device_type PCI_CONNECTOR; + +// ======================> pci_bus_device + +class pci_bus_device : public device_t +{ +public: + // construction/destruction + pci_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + DECLARE_READ32_MEMBER( read ); + DECLARE_WRITE32_MEMBER( write ); + + DECLARE_READ64_MEMBER( read_64be ); + DECLARE_WRITE64_MEMBER( write_64be ); + + void set_busnum(int busnum) { m_busnum = busnum; } + void set_father(const char *father) { m_father = father; } + void set_device(int num, const char *tag) { + m_devtag[num] = tag; } + + pci_bus_device *pci_search_bustree(int busnum, int devicenum, pci_bus_device *pcibus); + void add_sibling(pci_bus_device *sibling, int busnum); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_post_load(); + +private: + UINT8 m_busnum; + + const char * m_devtag[32]; + pci_device_interface *m_device[32]; + + const char * m_father; + pci_bus_device * m_siblings[8]; + UINT8 m_siblings_busnum[8]; + int m_siblings_count; + + offs_t m_address; + INT8 m_devicenum; // device number we are addressing + INT8 m_busnumber; // pci bus number we are addressing + pci_bus_device * m_busnumaddr; // pci bus we are addressing +}; + +// device type definition +extern const device_type PCI_BUS; + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_PCI_BUS_ADD(_tag, _busnum) \ + MCFG_DEVICE_ADD(_tag, PCI_BUS, 0) \ + downcast(device)->set_busnum(_busnum); +#define MCFG_PCI_BUS_DEVICE(_tag, _slot_intf, _def_slot, _fixed) \ + MCFG_DEVICE_ADD(_tag, PCI_CONNECTOR, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed) + +#define MCFG_PCI_BUS_SIBLING(_father_tag) \ + downcast(device)->set_father(_father_tag); + + +#endif /* PCI_H */ diff --git a/src/mess/machine/southbridge.c b/src/emu/bus/pci/southbridge.c similarity index 99% rename from src/mess/machine/southbridge.c rename to src/emu/bus/pci/southbridge.c index d2ff9516d7c..109a3c34e41 100644 --- a/src/mess/machine/southbridge.c +++ b/src/emu/bus/pci/southbridge.c @@ -6,7 +6,7 @@ #include "emu.h" #include "cpu/i386/i386.h" -#include "machine/southbridge.h" +#include "southbridge.h" #include "bus/pc_kbd/keyboards.h" diff --git a/src/mess/machine/southbridge.h b/src/emu/bus/pci/southbridge.h similarity index 99% rename from src/mess/machine/southbridge.h rename to src/emu/bus/pci/southbridge.h index 92977ae9d0c..2a44422a477 100644 --- a/src/mess/machine/southbridge.h +++ b/src/emu/bus/pci/southbridge.h @@ -14,7 +14,7 @@ #include "machine/at_keybc.h" #include "imagedev/harddriv.h" -#include "machine/pci.h" +#include "pci.h" #include "sound/dac.h" #include "sound/speaker.h" diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 423aef3f902..063611c890e 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -45,6 +45,7 @@ OBJDIRS += \ $(EMUOBJ)/bus/isa \ $(EMUOBJ)/bus/isbx \ $(EMUOBJ)/bus/midi \ + $(EMUOBJ)/bus/pci \ $(EMUOBJ)/bus/pc_joy \ $(EMUOBJ)/bus/pc_kbd \ $(EMUOBJ)/bus/pet \ diff --git a/src/mess/machine/at_keybc.c b/src/emu/machine/at_keybc.c similarity index 100% rename from src/mess/machine/at_keybc.c rename to src/emu/machine/at_keybc.c diff --git a/src/mess/machine/at_keybc.h b/src/emu/machine/at_keybc.h similarity index 100% rename from src/mess/machine/at_keybc.h rename to src/emu/machine/at_keybc.h diff --git a/src/emu/machine/machine.mak b/src/emu/machine/machine.mak index 15300e77c2b..bed733d2533 100644 --- a/src/emu/machine/machine.mak +++ b/src/emu/machine/machine.mak @@ -1652,3 +1652,11 @@ ifneq ($(filter MPU401,$(MACHINES)),) MACHINEOBJS += $(MACHINEOBJ)/mpu401.o endif +#------------------------------------------------- +# +#@src/emu/machine/at_keybc.h,MACHINES += AT_KEYBC +#------------------------------------------------- + +ifneq ($(filter AT_KEYBC,$(MACHINES)),) +MACHINEOBJS += $(MACHINEOBJ)/at_keybc.o +endif diff --git a/src/emu/machine/pci.c b/src/emu/machine/pci.c index 5f372cbfbe6..abb59481aa9 100644 --- a/src/emu/machine/pci.c +++ b/src/emu/machine/pci.c @@ -88,7 +88,7 @@ const device_type PCI_BUS_LEGACY = &device_creator; // pci_bus_legacy_device - constructor //------------------------------------------------- pci_bus_legacy_device::pci_bus_legacy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, PCI_BUS, "PCI Bus Legacy", tag, owner, clock, "pci_bus_legacy", __FILE__), + device_t(mconfig, PCI_BUS_LEGACY, "PCI Bus Legacy", tag, owner, clock, "pci_bus_legacy", __FILE__), m_father(NULL) { for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) { @@ -288,262 +288,3 @@ void pci_bus_legacy_device::device_reset() m_address = 0; } - -// NEW IMPLEMENTATION - -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -const device_type PCI_BUS = &device_creator; - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// pci_bus_device - constructor -//------------------------------------------------- -pci_bus_device::pci_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, PCI_BUS, "PCI Bus", tag, owner, clock, "pci_bus", __FILE__), - m_father(NULL) -{ - for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) { - m_devtag[i]= NULL; - } - m_siblings_count = 0; -} - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -READ32_MEMBER( pci_bus_device::read ) -{ - UINT32 result = 0xffffffff; - int function, reg; - - offset %= 2; - - switch (offset) - { - case 0: - result = m_address; - break; - - case 1: - if (m_devicenum != -1) - { - if (m_busnumaddr->m_device[m_devicenum] != NULL) - { - function = (m_address >> 8) & 0x07; - reg = (m_address >> 0) & 0xfc; - result = m_busnumaddr->m_device[m_devicenum]->pci_read(m_busnumaddr, function, reg, mem_mask); - } - } - break; - } - - if (LOG_PCI) - logerror("read('%s'): offset=%d result=0x%08X\n", tag(), offset, result); - - return result; -} - - - -pci_bus_device *pci_bus_device::pci_search_bustree(int busnum, int devicenum, pci_bus_device *pcibus) -{ - int a; - pci_bus_device *ret; - - if (pcibus->m_busnum == busnum) - { - return pcibus; - } - for (a = 0; a < pcibus->m_siblings_count; a++) - { - ret = pci_search_bustree(busnum, devicenum, pcibus->m_siblings[a]); - if (ret != NULL) - return ret; - } - return NULL; -} - - - -WRITE32_MEMBER( pci_bus_device::write ) -{ - offset %= 2; - - if (LOG_PCI) - logerror("write('%s'): offset=%d data=0x%08X\n", tag(), offset, data); - - switch (offset) - { - case 0: - m_address = data; - - /* lookup current device */ - if (m_address & 0x80000000) - { - int busnum = (m_address >> 16) & 0xff; - int devicenum = (m_address >> 11) & 0x1f; - m_busnumaddr = pci_search_bustree(busnum, devicenum, this); - if (m_busnumaddr != NULL) - { - m_busnumber = busnum; - m_devicenum = devicenum; - } - else - m_devicenum = -1; - if (LOG_PCI) - logerror(" bus:%d device:%d\n", busnum, devicenum); - } - break; - - case 1: - if (m_devicenum != -1) - { - if (m_busnumaddr->m_device[m_devicenum] != NULL) - { - int function = (m_address >> 8) & 0x07; - int reg = (m_address >> 0) & 0xfc; - m_busnumaddr->m_device[m_devicenum]->pci_write(m_busnumaddr, function, reg, data, mem_mask); - } - if (LOG_PCI) - logerror(" function:%d register:%d\n", (m_address >> 8) & 0x07, (m_address >> 0) & 0xfc); - } - break; - } -} - - - -READ64_MEMBER(pci_bus_device::read_64be) -{ - UINT64 result = 0; - mem_mask = FLIPENDIAN_INT64(mem_mask); - if (ACCESSING_BITS_0_31) - result |= (UINT64)read(space, offset * 2 + 0, mem_mask >> 0) << 0; - if (ACCESSING_BITS_32_63) - result |= (UINT64)read(space, offset * 2 + 1, mem_mask >> 32) << 32; - return FLIPENDIAN_INT64(result); -} - -WRITE64_MEMBER(pci_bus_device::write_64be) -{ - data = FLIPENDIAN_INT64(data); - mem_mask = FLIPENDIAN_INT64(mem_mask); - if (ACCESSING_BITS_0_31) - write(space, offset * 2 + 0, data >> 0, mem_mask >> 0); - if (ACCESSING_BITS_32_63) - write(space, offset * 2 + 1, data >> 32, mem_mask >> 32); -} - - -void pci_bus_device::add_sibling(pci_bus_device *sibling, int busnum) -{ - m_siblings[m_siblings_count] = sibling; - m_siblings_busnum[m_siblings_count] = busnum; - m_siblings_count++; -} - - -//------------------------------------------------- -// device_post_load - handle updating after a -// restore -//------------------------------------------------- - -void pci_bus_device::device_post_load() -{ - if (m_devicenum != -1) - { - m_busnumaddr = pci_search_bustree(m_busnumber, m_devicenum, this); - } -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void pci_bus_device::device_start() -{ - /* store a pointer back to the device */ - m_devicenum = -1; - - char id[3]; - /* find all our devices */ - for (int i = 0; i < ARRAY_LENGTH(m_devtag); i++) - { - sprintf(id, "%d", i); - pci_connector *conn = downcast(subdevice(id)); - if (conn!=NULL) - m_device[i] = conn->get_device(); - else - m_device[i] = NULL; - } - - if (m_father != NULL) { - pci_bus_device *father = machine().device(m_father); - if (father) - father->add_sibling(this, m_busnum); - } - - /* register pci states */ - save_item(NAME(m_address)); - save_item(NAME(m_devicenum)); - save_item(NAME(m_busnum)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void pci_bus_device::device_reset() -{ - /* reset the drive state */ - m_devicenum = -1; - m_address = 0; -} - -//------------------------------------------------- -// pci_device_interface - constructor -//------------------------------------------------- - -pci_device_interface::pci_device_interface(const machine_config &mconfig, device_t &device) - : device_slot_card_interface(mconfig, device) -{ -} - -//------------------------------------------------- -// ~pci_device_interface - destructor -//------------------------------------------------- - -pci_device_interface::~pci_device_interface() -{ -} - - -const device_type PCI_CONNECTOR = &device_creator; - - -pci_connector::pci_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, PCI_CONNECTOR, "PCI device connector abstraction", tag, owner, clock, "pci_connector", __FILE__), - device_slot_interface(mconfig, *this) -{ -} - -pci_connector::~pci_connector() -{ -} - -void pci_connector::device_start() -{ -} - -pci_device_interface *pci_connector::get_device() -{ - return dynamic_cast(get_card_device()); -} diff --git a/src/emu/machine/pci.h b/src/emu/machine/pci.h index b940b42fac2..c878ebd2d71 100644 --- a/src/emu/machine/pci.h +++ b/src/emu/machine/pci.h @@ -77,104 +77,5 @@ extern const device_type PCI_BUS_LEGACY; #define MCFG_PCI_BUS_LEGACY_SIBLING(_father_tag) \ downcast(device)->set_father(_father_tag); -// NEW IMPLEMENTATION - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** -class pci_bus_device; - -// ======================> pci_device_interface - -class pci_device_interface : public device_slot_card_interface -{ -public: - // construction/destruction - pci_device_interface(const machine_config &mconfig, device_t &device); - virtual ~pci_device_interface(); - - virtual UINT32 pci_read(pci_bus_device *pcibus, int function, int offset, UINT32 mem_mask) = 0; - virtual void pci_write(pci_bus_device *pcibus, int function, int offset, UINT32 data, UINT32 mem_mask) = 0; -private: -}; - -class pci_connector: public device_t, - public device_slot_interface -{ -public: - pci_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - virtual ~pci_connector(); - - pci_device_interface *get_device(); - -protected: - virtual void device_start(); -}; - -extern const device_type PCI_CONNECTOR; - -// ======================> pci_bus_device - -class pci_bus_device : public device_t -{ -public: - // construction/destruction - pci_bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_READ32_MEMBER( read ); - DECLARE_WRITE32_MEMBER( write ); - - DECLARE_READ64_MEMBER( read_64be ); - DECLARE_WRITE64_MEMBER( write_64be ); - - void set_busnum(int busnum) { m_busnum = busnum; } - void set_father(const char *father) { m_father = father; } - void set_device(int num, const char *tag) { - m_devtag[num] = tag; } - - pci_bus_device *pci_search_bustree(int busnum, int devicenum, pci_bus_device *pcibus); - void add_sibling(pci_bus_device *sibling, int busnum); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_post_load(); - -private: - UINT8 m_busnum; - - const char * m_devtag[32]; - pci_device_interface *m_device[32]; - - const char * m_father; - pci_bus_device * m_siblings[8]; - UINT8 m_siblings_busnum[8]; - int m_siblings_count; - - offs_t m_address; - INT8 m_devicenum; // device number we are addressing - INT8 m_busnumber; // pci bus number we are addressing - pci_bus_device * m_busnumaddr; // pci bus we are addressing -}; - -// device type definition -extern const device_type PCI_BUS; - - -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ - -#define MCFG_PCI_BUS_ADD(_tag, _busnum) \ - MCFG_DEVICE_ADD(_tag, PCI_BUS, 0) \ - downcast(device)->set_busnum(_busnum); -#define MCFG_PCI_BUS_DEVICE(_tag, _slot_intf, _def_slot, _fixed) \ - MCFG_DEVICE_ADD(_tag, PCI_CONNECTOR, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed) - -#define MCFG_PCI_BUS_SIBLING(_father_tag) \ - downcast(device)->set_father(_father_tag); - #endif /* PCI_H */ diff --git a/src/mame/drivers/gammagic.c b/src/mame/drivers/gammagic.c index 158c918826c..04ff43313a8 100644 --- a/src/mame/drivers/gammagic.c +++ b/src/mame/drivers/gammagic.c @@ -64,7 +64,7 @@ static ADDRESS_MAP_START( gammagic_io, AS_IO, 32, gammagic_state) AM_RANGE(0x03b0, 0x03bf) AM_DEVREADWRITE8("vga", vga_device, port_03b0_r, port_03b0_w, 0xffffffff) AM_RANGE(0x03c0, 0x03cf) AM_DEVREADWRITE8("vga", vga_device, port_03c0_r, port_03c0_w, 0xffffffff) AM_RANGE(0x03d0, 0x03df) AM_DEVREADWRITE8("vga", vga_device, port_03d0_r, port_03d0_w, 0xffffffff) - AM_RANGE(0x0cf8, 0x0cff) AM_DEVREADWRITE("pcibus", pci_bus_device, read, write) + AM_RANGE(0x0cf8, 0x0cff) AM_DEVREADWRITE("pcibus", pci_bus_legacy_device, read, write) AM_RANGE(0x0400, 0xffff) AM_NOP ADDRESS_MAP_END @@ -131,7 +131,7 @@ static MACHINE_CONFIG_START( gammagic, gammagic_state ) // MCFG_I82371SB_ADD("i82371sb") // MCFG_I82439TX_ADD("i82439tx", "maincpu", "user") - MCFG_PCI_BUS_ADD("pcibus", 0) + MCFG_PCI_BUS_LEGACY_ADD("pcibus", 0) // MCFG_PCI_BUS_DEVICE(0, "i82439tx", i82439tx_pci_read, i82439tx_pci_write) // MCFG_PCI_BUS_DEVICE(1, "i82371sb", i82371sb_pci_read, i82371sb_pci_write) /* video hardware */ diff --git a/src/mess/drivers/bebox.c b/src/mess/drivers/bebox.c index 48ad3124b74..330212a4fcd 100644 --- a/src/mess/drivers/bebox.c +++ b/src/mess/drivers/bebox.c @@ -18,12 +18,12 @@ #include "machine/ins8250.h" #include "machine/pic8259.h" #include "machine/mc146818.h" -#include "machine/pci.h" +#include "bus/pci/pci.h" #include "machine/am9517a.h" #include "machine/pckeybrd.h" #include "machine/8042kbdc.h" #include "machine/idectrl.h" -#include "machine/mpc105.h" +#include "bus/pci/mpc105.h" #include "machine/intelfsh.h" #include "machine/scsibus.h" #include "machine/53c810.h" diff --git a/src/mess/includes/at.h b/src/mess/includes/at.h index c3d98a42366..ffc3c8f6f40 100644 --- a/src/mess/includes/at.h +++ b/src/mess/includes/at.h @@ -17,9 +17,9 @@ #include "machine/ins8250.h" #include "machine/mc146818.h" #include "machine/pic8259.h" -#include "machine/i82371ab.h" -#include "machine/i82371sb.h" -#include "machine/i82439tx.h" +#include "bus/pci/i82371ab.h" +#include "bus/pci/i82371sb.h" +#include "bus/pci/i82439tx.h" #include "machine/cs8221.h" #include "machine/pit8253.h" #include "video/pc_cga.h" @@ -29,7 +29,7 @@ #include "imagedev/harddriv.h" #include "machine/am9517a.h" -#include "machine/pci.h" +#include "bus/pci/pci.h" #include "sound/dac.h" #include "sound/speaker.h" diff --git a/src/mess/machine/bebox.c b/src/mess/machine/bebox.c index deea3655491..7b7f8184bb1 100644 --- a/src/mess/machine/bebox.c +++ b/src/mess/machine/bebox.c @@ -101,7 +101,7 @@ #include "machine/pic8259.h" #include "machine/am9517a.h" #include "machine/ataintf.h" -#include "machine/pci.h" +#include "bus/pci/pci.h" #include "machine/intelfsh.h" #include "machine/53c810.h" #include "machine/ram.h" diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 40fbe63bb64..364c97c315f 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -418,7 +418,6 @@ MACHINES += NMC9306 MACHINES += NSCSI MACHINES += PCCARD MACHINES += PCF8593 -MACHINES += PCI MACHINES += PCKEYBRD MACHINES += PD4990A_OLD MACHINES += PIC8259 @@ -485,6 +484,7 @@ MACHINES += PC_LPT MACHINES += PC_FDC MACHINES += DP8390 MACHINES += MPU401 +MACHINES += AT_KEYBC #MACHINES += PROFILE #------------------------------------------------- @@ -512,6 +512,7 @@ BUSES += ISBX BUSES += KC BUSES += MIDI BUSES += NUBUS +BUSES += PCI BUSES += PC_JOY BUSES += PC_KBD BUSES += PET @@ -648,7 +649,6 @@ DRVLIBS += \ $(MESSOBJ)/parker.a \ $(MESSOBJ)/pc.a \ $(MESSOBJ)/pc9801.a \ - $(MESSOBJ)/pcshare.a \ $(MESSOBJ)/pdp1.a \ $(MESSOBJ)/pel.a \ $(MESSOBJ)/philips.a \ @@ -811,7 +811,6 @@ $(MESSOBJ)/shared.a: \ $(MESS_MACHINE)/kr2376.o \ $(MESS_MACHINE)/mb8795.o \ $(MESS_MACHINE)/microdrv.o \ - $(MESS_MACHINE)/mpc105.o \ $(MESS_MACHINE)/msm6222b.o \ $(MESS_MACHINE)/ncr5380.o \ $(MESS_MACHINE)/ncr5390.o \ @@ -955,7 +954,6 @@ $(MESSOBJ)/ascii.a: \ $(MESS_MACHINE)/msx_slot.o \ $(MESSOBJ)/at.a: \ - $(MESS_MACHINE)/at_keybc.o \ $(MESS_MACHINE)/cs8221.o \ $(MESS_MACHINE)/at.o \ $(MESS_DRIVERS)/at.o \ @@ -1640,13 +1638,6 @@ $(MESSOBJ)/pc9801.a: \ $(MESS_MACHINE)/pc9801_cbus.o \ $(MESS_MACHINE)/pc9801_kbd.o\ -$(MESSOBJ)/pcshare.a: \ - $(MESS_MACHINE)/i82371ab.o \ - $(MESS_MACHINE)/i82371sb.o \ - $(MESS_MACHINE)/i82439tx.o \ - $(MESS_MACHINE)/northbridge.o \ - $(MESS_MACHINE)/southbridge.o \ - $(MESSOBJ)/pdp1.a: \ $(MESS_VIDEO)/pdp1.o \ $(MESS_DRIVERS)/pdp1.o \ diff --git a/src/mess/video/cirrus.h b/src/mess/video/cirrus.h index 65bd68477e1..8a458039650 100644 --- a/src/mess/video/cirrus.h +++ b/src/mess/video/cirrus.h @@ -9,7 +9,7 @@ #ifndef CIRRUS_H #define CIRRUS_H -#include "machine/pci.h" +#include "bus/pci/pci.h" // ======================> cirrus_device