static struct pci_config_address pci_config_address;
+static void *pci_config_address_ptr(uint16_t port)
+{
+ unsigned long offset;
+ void *base;
+
+ offset = port - PCI_CONFIG_ADDRESS;
+ base = &pci_config_address;
+
+ return base + offset;
+}
+
static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
- struct pci_config_address *addr = data;
+ void *p = pci_config_address_ptr(port);
- pci_config_address = *addr;
+ memcpy(p, data, size);
return true;
}
static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
{
- struct pci_config_address *addr = data;
+ void *p = pci_config_address_ptr(port);
- *addr = pci_config_address;
+ memcpy(data, p, size);
return true;
}
void pci__init(void)
{
+ ioport__register(IOPORT_VIRTIO, &virtio_io_ops);
- ioport__register(IOPORT_VIRTIO, &virtio_io_ops);
-
- ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops);
- ioport__register(PCI_CONFIG_DATA + 1, &pci_config_data_ops);
- ioport__register(PCI_CONFIG_DATA + 2, &pci_config_data_ops);
- ioport__register(PCI_CONFIG_DATA + 3, &pci_config_data_ops);
+ ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops);
+ ioport__register(PCI_CONFIG_DATA + 1, &pci_config_data_ops);
+ ioport__register(PCI_CONFIG_DATA + 2, &pci_config_data_ops);
+ ioport__register(PCI_CONFIG_DATA + 3, &pci_config_data_ops);
- ioport__register(PCI_CONFIG_ADDRESS, &pci_config_address_ops);
+ ioport__register(PCI_CONFIG_ADDRESS + 0, &pci_config_address_ops);
+ ioport__register(PCI_CONFIG_ADDRESS + 1, &pci_config_address_ops);
+ ioport__register(PCI_CONFIG_ADDRESS + 2, &pci_config_address_ops);
+ ioport__register(PCI_CONFIG_ADDRESS + 3, &pci_config_address_ops);
}