160742802SPekka Enberg #include "kvm/pci.h" 260742802SPekka Enberg 360742802SPekka Enberg #include "kvm/ioport.h" 460742802SPekka Enberg 560742802SPekka Enberg #include <stdint.h> 660742802SPekka Enberg 7305b72ceSCyrill Gorcunov static uint32_t pci_config_address; 860742802SPekka Enberg 9305b72ceSCyrill Gorcunov static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 1060742802SPekka Enberg { 11305b72ceSCyrill Gorcunov uint32_t *addr = data; 1260742802SPekka Enberg 13*dad5bc09SCyrill Gorcunov pci_config_address = *addr; 1460742802SPekka Enberg 1560742802SPekka Enberg return true; 1660742802SPekka Enberg } 1760742802SPekka Enberg 18305b72ceSCyrill Gorcunov static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 1960742802SPekka Enberg { 20305b72ceSCyrill Gorcunov uint32_t *addr = data; 2160742802SPekka Enberg 22305b72ceSCyrill Gorcunov *addr = pci_config_address; 2360742802SPekka Enberg 2460742802SPekka Enberg return true; 2560742802SPekka Enberg } 2660742802SPekka Enberg 27305b72ceSCyrill Gorcunov static struct ioport_operations pci_config_address_ops = { 28305b72ceSCyrill Gorcunov .io_in = pci_config_address_in, 29305b72ceSCyrill Gorcunov .io_out = pci_config_address_out, 3060742802SPekka Enberg }; 3160742802SPekka Enberg 32305b72ceSCyrill Gorcunov static bool pci_config_data_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 3360742802SPekka Enberg { 3460742802SPekka Enberg return true; 3560742802SPekka Enberg } 3660742802SPekka Enberg 37305b72ceSCyrill Gorcunov static bool pci_config_data_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 3860742802SPekka Enberg { 3960742802SPekka Enberg return true; 4060742802SPekka Enberg } 4160742802SPekka Enberg 42305b72ceSCyrill Gorcunov static struct ioport_operations pci_config_data_ops = { 43305b72ceSCyrill Gorcunov .io_in = pci_config_data_in, 44305b72ceSCyrill Gorcunov .io_out = pci_config_data_out, 4560742802SPekka Enberg }; 4660742802SPekka Enberg 4760742802SPekka Enberg void pci__init(void) 4860742802SPekka Enberg { 49305b72ceSCyrill Gorcunov ioport__register(PCI_CONFIG_DATA, &pci_config_data_ops); 50305b72ceSCyrill Gorcunov ioport__register(PCI_CONFIG_ADDRESS, &pci_config_address_ops); 5160742802SPekka Enberg } 52