From: Pekka Enberg Date: Sun, 15 Aug 2010 12:03:01 +0000 (+0300) Subject: kvm: Add port range to ioport__register() X-Git-Tag: next-20110824~3^2~528^2~55 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5dcb3f3a72ff5e6d27e7d28f470a30182820e3d8;p=karo-tx-linux.git kvm: Add port range to ioport__register() This patch adds a 'count' argument to ioport__register() to allow callers to register a range of ioports. Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/blk-virtio.c b/tools/kvm/blk-virtio.c index 65b1dd7bfc4d..2eab5cc144e6 100644 --- a/tools/kvm/blk-virtio.c +++ b/tools/kvm/blk-virtio.c @@ -38,5 +38,5 @@ void blk_virtio__init(void) { pci__register(&virtio_device, 1); - ioport__register(IOPORT_VIRTIO, &virtio_io_ops); + ioport__register(IOPORT_VIRTIO, &virtio_io_ops, 1); } diff --git a/tools/kvm/early_printk.c b/tools/kvm/early_printk.c index 118407c86e04..cb9fe2437675 100644 --- a/tools/kvm/early_printk.c +++ b/tools/kvm/early_printk.c @@ -50,6 +50,6 @@ static struct ioport_operations early_serial_lsr_ops = { void early_printk__init(void) { - ioport__register(early_serial_base + TXR, &early_serial_txr_rxr_ops); - ioport__register(early_serial_base + LSR, &early_serial_lsr_ops); + ioport__register(early_serial_base + TXR, &early_serial_txr_rxr_ops, 1); + ioport__register(early_serial_base + LSR, &early_serial_lsr_ops, 1); } diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h index 75678c0974a5..eaedc1e7be82 100644 --- a/tools/kvm/include/kvm/ioport.h +++ b/tools/kvm/include/kvm/ioport.h @@ -15,6 +15,6 @@ struct ioport_operations { bool (*io_out)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count); }; -void ioport__register(uint16_t port, struct ioport_operations *ops); +void ioport__register(uint16_t port, struct ioport_operations *ops, int count); #endif /* KVM__IOPORT_H */ diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c index 874894f47ef5..4579e89135f6 100644 --- a/tools/kvm/ioport.c +++ b/tools/kvm/ioport.c @@ -137,9 +137,12 @@ static struct ioport_operations *ioport_ops[USHRT_MAX] = { [0x0CFE] = &dummy_read_write_ioport_ops, }; -void ioport__register(uint16_t port, struct ioport_operations *ops) +void ioport__register(uint16_t port, struct ioport_operations *ops, int count) { - ioport_ops[port] = ops; + int i; + + for (i = 0; i < count; i++) + ioport_ops[port + i] = ops; } static const char *to_direction(int direction) diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c index 34a903340e62..0b96990c42a7 100644 --- a/tools/kvm/pci.c +++ b/tools/kvm/pci.c @@ -111,13 +111,6 @@ void pci__register(struct pci_device_header *dev, uint8_t dev_num) void pci__init(void) { - 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 + 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); + ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops, 4); + ioport__register(PCI_CONFIG_ADDRESS + 0, &pci_config_address_ops, 4); }