dpci_infos.pci_access = pci_access;
}
-u32 pt_pci_host_read(int bus, int dev, int fn, u32 addr, int len)
+struct pci_dev *pt_pci_get_dev(int bus, int dev, int fn)
{
+ pci_access_init();
+ return pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
+}
- struct pci_dev *pci_dev;
+u32 pt_pci_host_read(struct pci_dev *pci_dev, u32 addr, int len)
+{
u32 val = -1;
pci_access_init();
- pci_dev = pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
- if ( !pci_dev )
- return 0;
-
pci_read_block(pci_dev, addr, (u8 *) &val, len);
return val;
}
-int pt_pci_host_write(int bus, int dev, int fn, u32 addr, u32 val, int len)
+int pt_pci_host_write(struct pci_dev *pci_dev, u32 addr, u32 val, int len)
{
- struct pci_dev *pci_dev;
int ret = 0;
pci_access_init();
- pci_dev = pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
- if ( !pci_dev )
- return 0;
-
ret = pci_write_block(pci_dev, addr, (u8 *) &val, len);
return ret;
}
}
uint8_t pci_intx(struct pt_dev *ptdev);
-u32 pt_pci_host_read(int bus, int dev, int fn, u32 addr, int len);
-int pt_pci_host_write(int bus, int dev, int fn, u32 addr, u32 val, int len);
+struct pci_dev *pt_pci_get_dev(int bus, int dev, int func);
+u32 pt_pci_host_read(struct pci_dev *pci_dev, u32 addr, int len);
+int pt_pci_host_write(struct pci_dev *pci_dev, u32 addr, u32 val, int len);
void intel_pch_init(PCIBus *bus);
int register_vga_regions(struct pt_dev *real_device);
int unregister_vga_regions(struct pt_dev *real_device);
{
uint16_t vid, did;
uint8_t rid;
+ struct pci_dev *pci_dev_1f = pt_pci_get_dev(0, 0x1f, 0);
- if ( !gfx_passthru )
+ if ( !gfx_passthru || !pci_dev_1f )
return;
- vid = pt_pci_host_read(0, 0x1f, 0, 0, 2);
- did = pt_pci_host_read(0, 0x1f, 0, 2, 2);
- rid = pt_pci_host_read(0, 0x1f, 0, 8, 1);
+ vid = pt_pci_host_read(pci_dev_1f, PCI_VENDOR_ID, 2);
+ did = pt_pci_host_read(pci_dev_1f, PCI_DEVICE_ID, 2);
+ rid = pt_pci_host_read(pci_dev_1f, PCI_REVISION, 1);
if ( vid == 0x8086 )
pci_bridge_init(bus, PCI_DEVFN(0x1f, 0), vid, did, rid,
void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int len)
{
+ struct pci_dev *pci_dev_host_bridge = pt_pci_get_dev(0, 0, 0);
assert(pci_dev->devfn == 0x00);
if ( !igd_passthru ) {
pci_default_write_config(pci_dev, config_addr, val, len);
switch (config_addr)
{
case 0x58: // PAVPC Offset
- pt_pci_host_write(0, 0, 0, config_addr, val, len);
+ pt_pci_host_write(pci_dev_host_bridge, config_addr, val, len);
PT_LOG("pci_config_write: %x:%x.%x: addr=%x len=%x val=%x\n",
pci_bus_num(pci_dev->bus), PCI_SLOT(pci_dev->devfn),
PCI_FUNC(pci_dev->devfn), config_addr, len, val);
uint32_t igd_pci_read(PCIDevice *pci_dev, uint32_t config_addr, int len)
{
+ struct pci_dev *pci_dev_host_bridge = pt_pci_get_dev(0, 0, 0);
uint32_t val;
assert(pci_dev->devfn == 0x00);
case 0x58: /* SNB: PAVPC Offset */
case 0xa4: /* SNB: graphics base of stolen memory */
case 0xa8: /* SNB: base of GTT stolen memory */
- val = pt_pci_host_read(0, PCI_SLOT(pci_dev->devfn),
- 0, config_addr, len);
+ val = pt_pci_host_read(pci_dev_host_bridge, config_addr, len);
PT_LOG("pci_config_read: %x:%x.%x: addr=%x len=%x val=%x\n",
pci_bus_num(pci_dev->bus), PCI_SLOT(pci_dev->devfn),
PCI_FUNC(pci_dev->devfn), config_addr, len, val);
DPCI_ADD_MAPPING);
/* 1:1 map ASL Storage register value */
- vendor_id = pt_pci_host_read(0, 2, 0, 0, 2);
- igd_opregion = pt_pci_host_read(0, 2, 0, 0xfc, 4);
+ vendor_id = pt_pci_host_read(real_device->pci_dev, 0, 2);
+ igd_opregion = pt_pci_host_read(real_device->pci_dev, 0xfc, 4);
if ( (vendor_id == 0x8086) && igd_opregion )
{
ret |= xc_domain_memory_mapping(xc_handle, domid,
20,
DPCI_REMOVE_MAPPING);
- vendor_id = pt_pci_host_read(0, 2, 0, 0, 2);
- igd_opregion = pt_pci_host_read(0, 2, 0, 0xfc, 4);
+ vendor_id = pt_pci_host_read(real_device->pci_dev, 0, 2);
+ igd_opregion = pt_pci_host_read(real_device->pci_dev, 0xfc, 4);
if ( (vendor_id == 0x8086) && igd_opregion )
{
ret |= xc_domain_memory_mapping(xc_handle, domid,