160742802SPekka Enberg #include "kvm/pci.h" 260742802SPekka Enberg 360742802SPekka Enberg #include "kvm/ioport.h" 460742802SPekka Enberg 560742802SPekka Enberg #include <stdint.h> 660742802SPekka Enberg 7*305b72ceSCyrill Gorcunov static uint32_t pci_config_address; 860742802SPekka Enberg 9*305b72ceSCyrill Gorcunov static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 1060742802SPekka Enberg { 11*305b72ceSCyrill Gorcunov uint32_t *addr = data; 1260742802SPekka Enberg 13*305b72ceSCyrill Gorcunov pci_config_address = *p; 1460742802SPekka Enberg 1560742802SPekka Enberg return true; 1660742802SPekka Enberg } 1760742802SPekka Enberg 18*305b72ceSCyrill Gorcunov static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 1960742802SPekka Enberg { 20*305b72ceSCyrill Gorcunov uint32_t *addr = data; 2160742802SPekka Enberg 22*305b72ceSCyrill Gorcunov *addr = pci_config_address; 2360742802SPekka Enberg 2460742802SPekka Enberg return true; 2560742802SPekka Enberg } 2660742802SPekka Enberg 27*305b72ceSCyrill Gorcunov static struct ioport_operations pci_config_address_ops = { 28*305b72ceSCyrill Gorcunov .io_in = pci_config_address_in, 29*305b72ceSCyrill Gorcunov .io_out = pci_config_address_out, 3060742802SPekka Enberg }; 3160742802SPekka Enberg 32*305b72ceSCyrill 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 37*305b72ceSCyrill 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 42*305b72ceSCyrill Gorcunov static struct ioport_operations pci_config_data_ops = { 43*305b72ceSCyrill Gorcunov .io_in = pci_config_data_in, 44*305b72ceSCyrill Gorcunov .io_out = pci_config_data_out, 4560742802SPekka Enberg }; 4660742802SPekka Enberg 4760742802SPekka Enberg void pci__init(void) 4860742802SPekka Enberg { 49*305b72ceSCyrill Gorcunov ioport__register(PCI_CONFIG_DATA, &pci_config_data_ops); 50*305b72ceSCyrill Gorcunov ioport__register(PCI_CONFIG_ADDRESS, &pci_config_address_ops); 5160742802SPekka Enberg } 52