2010-07-13 08:01:39 +04:00
|
|
|
/*
|
|
|
|
* QEMU PCI bridge
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* split out pci bus specific stuff from pci.[hc] to pci_bridge.[hc]
|
|
|
|
* Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
|
|
|
|
* VA Linux Systems Japan K.K.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_PCI_BRIDGE_H
|
|
|
|
#define QEMU_PCI_BRIDGE_H
|
|
|
|
|
2012-12-13 01:05:42 +04:00
|
|
|
#include "hw/pci/pci.h"
|
2017-11-29 11:46:23 +03:00
|
|
|
#include "hw/pci/pci_bus.h"
|
|
|
|
|
|
|
|
typedef struct PCIBridgeWindows PCIBridgeWindows;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Aliases for each of the address space windows that the bridge
|
|
|
|
* can forward. Mapped into the bridge's parent's address space,
|
|
|
|
* as subregions.
|
|
|
|
*/
|
|
|
|
struct PCIBridgeWindows {
|
|
|
|
MemoryRegion alias_pref_mem;
|
|
|
|
MemoryRegion alias_mem;
|
|
|
|
MemoryRegion alias_io;
|
|
|
|
/*
|
|
|
|
* When bridge control VGA forwarding is enabled, bridges will
|
|
|
|
* provide positive decode on the PCI VGA defined I/O port and
|
|
|
|
* MMIO ranges. When enabled forwarding is only qualified on the
|
|
|
|
* I/O and memory enable bits in the bridge command register.
|
|
|
|
*/
|
|
|
|
MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TYPE_PCI_BRIDGE "base-pci-bridge"
|
|
|
|
#define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE)
|
|
|
|
|
|
|
|
struct PCIBridge {
|
|
|
|
/*< private >*/
|
|
|
|
PCIDevice parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
|
|
|
/* private member */
|
|
|
|
PCIBus sec_bus;
|
|
|
|
/*
|
|
|
|
* Memory regions for the bridge's address spaces. These regions are not
|
|
|
|
* directly added to system_memory/system_io or its descendants.
|
|
|
|
* Bridge's secondary bus points to these, so that devices
|
|
|
|
* under the bridge see these regions as its address spaces.
|
|
|
|
* The regions are as large as the entire address space -
|
|
|
|
* they don't take into account any windows.
|
|
|
|
*/
|
|
|
|
MemoryRegion address_space_mem;
|
|
|
|
MemoryRegion address_space_io;
|
|
|
|
|
|
|
|
PCIBridgeWindows *windows;
|
|
|
|
|
|
|
|
pci_map_irq_fn map_irq;
|
|
|
|
const char *bus_name;
|
|
|
|
};
|
2010-07-13 08:01:39 +04:00
|
|
|
|
2015-06-19 05:40:10 +03:00
|
|
|
#define PCI_BRIDGE_DEV_PROP_CHASSIS_NR "chassis_nr"
|
2015-06-19 05:40:11 +03:00
|
|
|
#define PCI_BRIDGE_DEV_PROP_MSI "msi"
|
2015-06-19 05:40:13 +03:00
|
|
|
#define PCI_BRIDGE_DEV_PROP_SHPC "shpc"
|
2015-06-19 05:40:10 +03:00
|
|
|
|
2010-09-06 11:46:17 +04:00
|
|
|
int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
|
2017-06-27 09:16:52 +03:00
|
|
|
uint16_t svid, uint16_t ssid,
|
|
|
|
Error **errp);
|
2010-09-06 11:46:17 +04:00
|
|
|
|
2010-07-13 08:01:39 +04:00
|
|
|
PCIDevice *pci_bridge_get_device(PCIBus *bus);
|
2010-07-13 08:01:42 +04:00
|
|
|
PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);
|
2010-07-13 08:01:39 +04:00
|
|
|
|
2010-07-13 08:01:42 +04:00
|
|
|
pcibus_t pci_bridge_get_base(const PCIDevice *bridge, uint8_t type);
|
|
|
|
pcibus_t pci_bridge_get_limit(const PCIDevice *bridge, uint8_t type);
|
2010-07-13 08:01:39 +04:00
|
|
|
|
2013-07-09 19:40:02 +04:00
|
|
|
void pci_bridge_update_mappings(PCIBridge *br);
|
2010-07-13 08:01:42 +04:00
|
|
|
void pci_bridge_write_config(PCIDevice *d,
|
|
|
|
uint32_t address, uint32_t val, int len);
|
2010-10-20 12:18:51 +04:00
|
|
|
void pci_bridge_disable_base_limit(PCIDevice *dev);
|
2010-07-13 08:01:42 +04:00
|
|
|
void pci_bridge_reset(DeviceState *qdev);
|
|
|
|
|
2016-01-15 05:23:32 +03:00
|
|
|
void pci_bridge_initfn(PCIDevice *pci_dev, const char *typename);
|
2012-07-04 08:39:27 +04:00
|
|
|
void pci_bridge_exitfn(PCIDevice *pci_dev);
|
2010-07-13 08:01:42 +04:00
|
|
|
|
2018-12-12 12:16:21 +03:00
|
|
|
void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
|
Error **errp);
|
2018-12-12 12:16:22 +03:00
|
|
|
void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
|
Error **errp);
|
2018-12-12 12:16:21 +03:00
|
|
|
void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
|
|
DeviceState *dev, Error **errp);
|
2010-07-13 08:01:42 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* before qdev initialization(qdev_init()), this function sets bus_name and
|
2020-02-05 21:51:23 +03:00
|
|
|
* map_irq callback which are necessary for pci_bridge_initfn() to
|
2010-07-13 08:01:42 +04:00
|
|
|
* initialize bus.
|
|
|
|
*/
|
|
|
|
void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,
|
|
|
|
pci_map_irq_fn map_irq);
|
2010-07-13 08:01:39 +04:00
|
|
|
|
2013-03-04 13:23:49 +04:00
|
|
|
/* TODO: add this define to pci_regs.h in linux and then in qemu. */
|
|
|
|
#define PCI_BRIDGE_CTL_VGA_16BIT 0x10 /* VGA 16-bit decode */
|
|
|
|
#define PCI_BRIDGE_CTL_DISCARD 0x100 /* Primary discard timer */
|
|
|
|
#define PCI_BRIDGE_CTL_SEC_DISCARD 0x200 /* Secondary discard timer */
|
|
|
|
#define PCI_BRIDGE_CTL_DISCARD_STATUS 0x400 /* Discard timer status */
|
|
|
|
#define PCI_BRIDGE_CTL_DISCARD_SERR 0x800 /* Discard timer SERR# enable */
|
|
|
|
|
2017-08-18 02:36:48 +03:00
|
|
|
typedef struct PCIBridgeQemuCap {
|
|
|
|
uint8_t id; /* Standard PCI capability header field */
|
|
|
|
uint8_t next; /* Standard PCI capability header field */
|
|
|
|
uint8_t len; /* Standard PCI vendor-specific capability header field */
|
|
|
|
uint8_t type; /* Red Hat vendor-specific capability type.
|
|
|
|
Types are defined with REDHAT_PCI_CAP_ prefix */
|
|
|
|
|
|
|
|
uint32_t bus_res; /* Minimum number of buses to reserve */
|
|
|
|
uint64_t io; /* IO space to reserve */
|
|
|
|
uint32_t mem; /* Non-prefetchable memory to reserve */
|
|
|
|
/* At most one of the following two fields may be set to a value
|
|
|
|
* different from -1 */
|
|
|
|
uint32_t mem_pref_32; /* Prefetchable memory to reserve (32-bit MMIO) */
|
|
|
|
uint64_t mem_pref_64; /* Prefetchable memory to reserve (64-bit MMIO) */
|
|
|
|
} PCIBridgeQemuCap;
|
|
|
|
|
|
|
|
#define REDHAT_PCI_CAP_RESOURCE_RESERVE 1
|
|
|
|
|
2018-08-21 06:18:06 +03:00
|
|
|
/*
|
|
|
|
* PCI BUS/IO/MEM/PREFMEM additional resources recorded as a
|
|
|
|
* capability in PCI configuration space to reserve on firmware init.
|
|
|
|
*/
|
|
|
|
typedef struct PCIResReserve {
|
|
|
|
uint32_t bus;
|
|
|
|
uint64_t io;
|
|
|
|
uint64_t mem_non_pref;
|
|
|
|
uint64_t mem_pref_32;
|
|
|
|
uint64_t mem_pref_64;
|
|
|
|
} PCIResReserve;
|
|
|
|
|
2017-08-18 02:36:48 +03:00
|
|
|
int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
|
2018-08-21 06:18:06 +03:00
|
|
|
PCIResReserve res_reserve, Error **errp);
|
2017-08-18 02:36:48 +03:00
|
|
|
|
2016-06-29 16:29:06 +03:00
|
|
|
#endif /* QEMU_PCI_BRIDGE_H */
|