mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
pci: convert to QEMU Object Model
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
6e4ec3f9bb
commit
40021f0888
53 changed files with 1591 additions and 1042 deletions
80
hw/pci.h
80
hw/pci.h
|
@ -127,6 +127,46 @@ enum {
|
|||
QEMU_PCI_CAP_SERR = (1 << QEMU_PCI_CAP_SERR_BITNR),
|
||||
};
|
||||
|
||||
#define TYPE_PCI_DEVICE "pci-device"
|
||||
#define PCI_DEVICE(obj) \
|
||||
OBJECT_CHECK(PCIDevice, (obj), TYPE_PCI_DEVICE)
|
||||
#define PCI_DEVICE_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(PCIDeviceClass, (klass), TYPE_PCI_DEVICE)
|
||||
#define PCI_DEVICE_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(PCIDeviceClass, (obj), TYPE_PCI_DEVICE)
|
||||
|
||||
typedef struct PCIDeviceClass {
|
||||
DeviceClass parent_class;
|
||||
|
||||
int (*init)(PCIDevice *dev);
|
||||
PCIUnregisterFunc *exit;
|
||||
PCIConfigReadFunc *config_read;
|
||||
PCIConfigWriteFunc *config_write;
|
||||
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t revision;
|
||||
uint16_t class_id;
|
||||
uint16_t subsystem_vendor_id; /* only for header type = 0 */
|
||||
uint16_t subsystem_id; /* only for header type = 0 */
|
||||
|
||||
/*
|
||||
* pci-to-pci bridge or normal device.
|
||||
* This doesn't mean pci host switch.
|
||||
* When card bus bridge is supported, this would be enhanced.
|
||||
*/
|
||||
int is_bridge;
|
||||
|
||||
/* pcie stuff */
|
||||
int is_express; /* is this device pci express? */
|
||||
|
||||
/* device isn't hot-pluggable */
|
||||
int no_hotplug;
|
||||
|
||||
/* rom bar */
|
||||
const char *romfile;
|
||||
} PCIDeviceClass;
|
||||
|
||||
struct PCIDevice {
|
||||
DeviceState qdev;
|
||||
/* PCI config space */
|
||||
|
@ -196,11 +236,6 @@ struct PCIDevice {
|
|||
uint32_t rom_bar;
|
||||
};
|
||||
|
||||
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
||||
int instance_size, int devfn,
|
||||
PCIConfigReadFunc *config_read,
|
||||
PCIConfigWriteFunc *config_write);
|
||||
|
||||
void pci_register_bar(PCIDevice *pci_dev, int region_num,
|
||||
uint8_t attr, MemoryRegion *memory);
|
||||
pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num);
|
||||
|
@ -429,40 +464,7 @@ pci_quad_test_and_set_mask(uint8_t *config, uint64_t mask)
|
|||
return val & mask;
|
||||
}
|
||||
|
||||
typedef int (*pci_qdev_initfn)(PCIDevice *dev);
|
||||
typedef struct {
|
||||
DeviceInfo qdev;
|
||||
pci_qdev_initfn init;
|
||||
PCIUnregisterFunc *exit;
|
||||
PCIConfigReadFunc *config_read;
|
||||
PCIConfigWriteFunc *config_write;
|
||||
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t revision;
|
||||
uint16_t class_id;
|
||||
uint16_t subsystem_vendor_id; /* only for header type = 0 */
|
||||
uint16_t subsystem_id; /* only for header type = 0 */
|
||||
|
||||
/*
|
||||
* pci-to-pci bridge or normal device.
|
||||
* This doesn't mean pci host switch.
|
||||
* When card bus bridge is supported, this would be enhanced.
|
||||
*/
|
||||
int is_bridge;
|
||||
|
||||
/* pcie stuff */
|
||||
int is_express; /* is this device pci express? */
|
||||
|
||||
/* device isn't hot-pluggable */
|
||||
int no_hotplug;
|
||||
|
||||
/* rom bar */
|
||||
const char *romfile;
|
||||
} PCIDeviceInfo;
|
||||
|
||||
void pci_qdev_register(PCIDeviceInfo *info);
|
||||
void pci_qdev_register_many(PCIDeviceInfo *info);
|
||||
void pci_qdev_register(DeviceInfo *info);
|
||||
|
||||
PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
|
||||
const char *name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue