]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Add PCI CONFIG_ADDRESS register layout
authorPekka Enberg <penberg@cs.helsinki.fi>
Sat, 31 Jul 2010 14:54:56 +0000 (17:54 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sat, 31 Jul 2010 14:54:56 +0000 (17:54 +0300)
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/include/kvm/pci.h
tools/kvm/pci.c

index 2d743a9ed1d3eb13352fa822f83204fc61dff96b..34d408e22c98abd163c9363f29438019e1683fc2 100644 (file)
@@ -1,10 +1,24 @@
 #ifndef KVM__PCI_H
 #define KVM__PCI_H
 
-/* some known offsets and register names */
+/*
+ * PCI Configuration Mechanism #1 I/O ports. See Section 3.7.4.1.
+ * ("Configuration Mechanism #1") of the PCI Local Bus Specification 2.1 for
+ * details.
+ */
 #define PCI_CONFIG_ADDRESS     0xcf8
 #define PCI_CONFIG_DATA                0xcfc
 
+struct pci_config_address {
+       unsigned                zeros           : 2;            /* 1  .. 0  */
+       unsigned                register_number : 6;            /* 7  .. 2  */
+       unsigned                function_number : 3;            /* 10 .. 8  */
+       unsigned                device_number   : 5;            /* 15 .. 11 */
+       unsigned                bus_number      : 8;            /* 23 .. 16 */
+       unsigned                reserved        : 7;            /* 30 .. 24 */
+       unsigned                enable_bit      : 1;            /* 31       */
+};
+
 void pci__init(void);
 
 #endif /* KVM__PCI_H */
index 84a1bca02113d5124b7280c74ed4d4e4eff6780c..cbcf86406832f09470fd52ff12d76eb4ebc6da19 100644 (file)
@@ -4,11 +4,11 @@
 
 #include <stdint.h>
 
-static uint32_t pci_config_address;
+static struct pci_config_address pci_config_address;
 
 static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
 {
-       uint32_t *addr = data;
+       struct pci_config_address *addr = data;
 
        pci_config_address      = *addr;
 
@@ -17,7 +17,7 @@ static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data,
 
 static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
 {
-       uint32_t *addr = data;
+       struct pci_config_address *addr = data;
 
        *addr           =  pci_config_address;