mirror of https://github.com/xqemu/xqemu.git
Merge remote branch 'mst/for_anthony' into HEAD
This commit is contained in:
commit
3814109714
|
@ -15,14 +15,6 @@
|
||||||
#include "msix.h"
|
#include "msix.h"
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
||||||
/* Declaration from linux/pci_regs.h */
|
|
||||||
#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
|
|
||||||
#define PCI_MSIX_FLAGS 2 /* Table at lower 11 bits */
|
|
||||||
#define PCI_MSIX_FLAGS_QSIZE 0x7FF
|
|
||||||
#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
|
|
||||||
#define PCI_MSIX_FLAGS_MASKALL (1 << 14)
|
|
||||||
#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
|
|
||||||
|
|
||||||
/* MSI-X capability structure */
|
/* MSI-X capability structure */
|
||||||
#define MSIX_TABLE_OFFSET 4
|
#define MSIX_TABLE_OFFSET 4
|
||||||
#define MSIX_PBA_OFFSET 8
|
#define MSIX_PBA_OFFSET 8
|
||||||
|
|
|
@ -124,7 +124,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)
|
||||||
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
|
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
dev = pci_find_device(pci_find_root_bus(0), pci_bus, slot, 0);
|
dev = pci_find_device(pci_find_root_bus(dom), pci_bus, slot, 0);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
|
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -252,7 +252,8 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
|
||||||
|
|
||||||
if (dev) {
|
if (dev) {
|
||||||
monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
|
monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
|
||||||
0, pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
|
pci_find_domain(dev->bus),
|
||||||
|
pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
|
||||||
PCI_FUNC(dev->devfn));
|
PCI_FUNC(dev->devfn));
|
||||||
} else
|
} else
|
||||||
monitor_printf(mon, "failed to add %s\n", opts);
|
monitor_printf(mon, "failed to add %s\n", opts);
|
||||||
|
@ -269,7 +270,7 @@ int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = pci_find_device(pci_find_root_bus(0), bus, slot, 0);
|
d = pci_find_device(pci_find_root_bus(dom), bus, slot, 0);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
monitor_printf(mon, "slot %d empty\n", slot);
|
monitor_printf(mon, "slot %d empty\n", slot);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
34
hw/pci.c
34
hw/pci.c
|
@ -200,6 +200,26 @@ PCIBus *pci_find_root_bus(int domain)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pci_find_domain(const PCIBus *bus)
|
||||||
|
{
|
||||||
|
PCIDevice *d;
|
||||||
|
struct PCIHostBus *host;
|
||||||
|
|
||||||
|
/* obtain root bus */
|
||||||
|
while ((d = bus->parent_dev) != NULL) {
|
||||||
|
bus = d->bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLIST_FOREACH(host, &host_buses, next) {
|
||||||
|
if (host->bus == bus) {
|
||||||
|
return host->domain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abort(); /* should not be reached */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
|
void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
|
||||||
const char *name, int devfn_min)
|
const char *name, int devfn_min)
|
||||||
{
|
{
|
||||||
|
@ -419,14 +439,12 @@ int pci_device_load(PCIDevice *s, QEMUFile *f)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pci_set_default_subsystem_id(PCIDevice *pci_dev)
|
static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
|
||||||
{
|
{
|
||||||
uint16_t *id;
|
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
|
||||||
|
pci_default_sub_vendor_id);
|
||||||
id = (void*)(&pci_dev->config[PCI_SUBSYSTEM_VENDOR_ID]);
|
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
|
||||||
id[0] = cpu_to_le16(pci_default_sub_vendor_id);
|
pci_default_sub_device_id);
|
||||||
id[1] = cpu_to_le16(pci_default_sub_device_id);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -507,7 +525,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
*devfnp = slot << 3;
|
*devfnp = slot << 3;
|
||||||
return pci_find_bus(pci_find_root_bus(0), bus);
|
return pci_find_bus(pci_find_root_bus(dom), bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_init_cmask(PCIDevice *dev)
|
static void pci_init_cmask(PCIDevice *dev)
|
||||||
|
|
16
hw/pci.h
16
hw/pci.h
|
@ -97,17 +97,6 @@ typedef struct PCIIORegion {
|
||||||
/* PCI HEADER_TYPE */
|
/* PCI HEADER_TYPE */
|
||||||
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
|
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
|
||||||
|
|
||||||
#define PCI_STATUS_RESERVED_MASK_LO (PCI_STATUS_RESERVED1 | \
|
|
||||||
PCI_STATUS_INT_STATUS | PCI_STATUS_CAPABILITIES | \
|
|
||||||
PCI_STATUS_66MHZ | PCI_STATUS_RESERVED2 | PCI_STATUS_FAST_BACK)
|
|
||||||
|
|
||||||
#define PCI_STATUS_RESERVED_MASK_HI (PCI_STATUS_DEVSEL >> 8)
|
|
||||||
|
|
||||||
/* Bits in the PCI Command Register (PCI 2.3 spec) */
|
|
||||||
#define PCI_COMMAND_RESERVED 0xf800
|
|
||||||
|
|
||||||
#define PCI_COMMAND_RESERVED_MASK_HI (PCI_COMMAND_RESERVED >> 8)
|
|
||||||
|
|
||||||
/* Size of the standard PCI config header */
|
/* Size of the standard PCI config header */
|
||||||
#define PCI_CONFIG_HEADER_SIZE 0x40
|
#define PCI_CONFIG_HEADER_SIZE 0x40
|
||||||
/* Size of the standard PCI config space */
|
/* Size of the standard PCI config space */
|
||||||
|
@ -229,6 +218,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
|
||||||
int pci_bus_num(PCIBus *s);
|
int pci_bus_num(PCIBus *s);
|
||||||
void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d));
|
void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d));
|
||||||
PCIBus *pci_find_root_bus(int domain);
|
PCIBus *pci_find_root_bus(int domain);
|
||||||
|
int pci_find_domain(const PCIBus *bus);
|
||||||
PCIBus *pci_find_bus(PCIBus *bus, int bus_num);
|
PCIBus *pci_find_bus(PCIBus *bus, int bus_num);
|
||||||
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function);
|
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function);
|
||||||
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
|
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
|
||||||
|
@ -350,12 +340,12 @@ void pci_qdev_register_many(PCIDeviceInfo *info);
|
||||||
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
|
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
|
||||||
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
|
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
|
||||||
|
|
||||||
static inline int pci_is_express(PCIDevice *d)
|
static inline int pci_is_express(const PCIDevice *d)
|
||||||
{
|
{
|
||||||
return d->cap_present & QEMU_PCI_CAP_EXPRESS;
|
return d->cap_present & QEMU_PCI_CAP_EXPRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t pci_config_size(PCIDevice *d)
|
static inline uint32_t pci_config_size(const PCIDevice *d)
|
||||||
{
|
{
|
||||||
return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE;
|
return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue