2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-12-04 22:50:29 +03:00
|
|
|
// Copyright (C) 2002-2009 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// 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
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-03-07 21:16:41 +03:00
|
|
|
#ifndef BX_IODEV_PCI_BRIDGE_H
|
|
|
|
#define BX_IODEV_PCI_BRIDGE_H
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-05-30 11:33:48 +04:00
|
|
|
#define BX_MAX_PCI_DEVICES 20
|
|
|
|
|
2003-01-23 22:31:28 +03:00
|
|
|
#define BX_PCI_DEVICE(device, function) ((device)<<3 | (function))
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_USE_PCI_SMF
|
|
|
|
# define BX_PCI_SMF static
|
2002-11-09 23:51:40 +03:00
|
|
|
# define BX_PCI_THIS thePciBridge->
|
2001-04-10 05:04:59 +04:00
|
|
|
#else
|
|
|
|
# define BX_PCI_SMF
|
|
|
|
# define BX_PCI_THIS this->
|
|
|
|
#endif
|
|
|
|
|
2004-07-04 21:10:05 +04:00
|
|
|
#define BX_PCI_INTA 1
|
|
|
|
#define BX_PCI_INTB 2
|
|
|
|
#define BX_PCI_INTC 3
|
|
|
|
#define BX_PCI_INTD 4
|
2004-07-02 02:18:20 +04:00
|
|
|
|
2006-03-08 00:11:20 +03:00
|
|
|
class bx_pci_device_stub_c;
|
|
|
|
|
2006-03-07 21:16:41 +03:00
|
|
|
class bx_pci_bridge_c : public bx_pci_bridge_stub_c {
|
2001-04-10 05:04:59 +04:00
|
|
|
public:
|
2006-03-07 21:16:41 +03:00
|
|
|
bx_pci_bridge_c();
|
2006-03-08 00:11:20 +03:00
|
|
|
virtual ~bx_pci_bridge_c();
|
2006-03-03 23:15:07 +03:00
|
|
|
virtual void init(void);
|
|
|
|
virtual void reset(unsigned type);
|
2006-05-27 19:54:49 +04:00
|
|
|
virtual void register_state(void);
|
|
|
|
virtual void after_restore_state(void);
|
2006-03-08 00:11:20 +03:00
|
|
|
virtual bx_bool register_pci_handlers(bx_pci_device_stub_c *device,
|
2004-06-29 23:24:34 +04:00
|
|
|
Bit8u *devfunc, const char *name,
|
|
|
|
const char *descr);
|
|
|
|
virtual bx_bool is_pci_device(const char *name);
|
2005-11-15 20:19:28 +03:00
|
|
|
virtual bx_bool pci_set_base_mem(void *this_ptr, memory_handler_t f1,
|
|
|
|
memory_handler_t f2, Bit32u *addr,
|
|
|
|
Bit8u *pci_conf, unsigned size);
|
|
|
|
virtual bx_bool pci_set_base_io(void *this_ptr, bx_read_handler_t f1,
|
|
|
|
bx_write_handler_t f2, Bit32u *addr,
|
|
|
|
Bit8u *pci_conf, unsigned size,
|
|
|
|
const Bit8u *iomask, const char *name);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-03-08 00:11:20 +03:00
|
|
|
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
|
|
|
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
2012-03-10 21:14:07 +04:00
|
|
|
#if BX_DEBUGGER
|
2012-04-23 21:06:19 +04:00
|
|
|
virtual void debug_dump(int argc, char **argv);
|
2012-03-10 21:14:07 +04:00
|
|
|
#endif
|
2009-04-22 00:27:35 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
private:
|
2002-05-30 11:33:48 +04:00
|
|
|
Bit8u pci_handler_id[0x100]; // 256 devices/functions
|
|
|
|
struct {
|
2006-03-08 00:11:20 +03:00
|
|
|
bx_pci_device_stub_c *handler;
|
2004-07-09 20:25:42 +04:00
|
|
|
} pci_handler[BX_MAX_PCI_DEVICES];
|
2006-03-08 00:11:20 +03:00
|
|
|
unsigned num_pci_handlers;
|
2002-05-30 11:33:48 +04:00
|
|
|
|
2004-07-09 20:25:42 +04:00
|
|
|
bx_bool slot_used[BX_N_PCI_SLOTS];
|
|
|
|
bx_bool slots_checked;
|
|
|
|
|
2011-06-23 19:56:02 +04:00
|
|
|
Bit32u confAddr;
|
|
|
|
Bit32u confData;
|
2002-08-17 13:23:42 +04:00
|
|
|
|
2006-03-27 02:15:07 +04:00
|
|
|
void smram_control(Bit8u value);
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
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);
|
|
|
|
#if !BX_USE_PCI_SMF
|
|
|
|
Bit32u read(Bit32u address, unsigned io_len);
|
|
|
|
void write(Bit32u address, Bit32u value, unsigned io_len);
|
|
|
|
#endif
|
2006-03-03 23:15:07 +03:00
|
|
|
};
|
2006-03-07 21:16:41 +03:00
|
|
|
|
|
|
|
#endif
|