x86: move x86/pci to the common lib

Also move pci_config_read into asm/pci.h

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Message-Id: <1453140064-9040-7-git-send-email-drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/lib/asm-generic/pci.h b/lib/asm-generic/pci.h
new file mode 100644
index 0000000..3fa0b2a
--- /dev/null
+++ b/lib/asm-generic/pci.h
@@ -0,0 +1,4 @@
+#ifndef _ASM_GENERIC_PCI_H_
+#define _ASM_GENERIC_PCI_H_
+#error need architecture specific asm/pci.h
+#endif
diff --git a/lib/x86/pci.c b/lib/pci.c
similarity index 84%
rename from lib/x86/pci.c
rename to lib/pci.c
index 6aa6d70..0058d70 100644
--- a/lib/x86/pci.c
+++ b/lib/pci.c
@@ -1,13 +1,11 @@
+/*
+ * Copyright (C) 2013, Red Hat Inc, Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
 #include <linux/pci_regs.h>
 #include "pci.h"
-#include "io.h"
-
-static uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg)
-{
-    uint32_t index = reg | (dev << 8) | (0x1 << 31); 
-    outl(index, 0xCF8);
-    return inl(0xCFC);
-}
+#include "asm/pci.h"
 
 /* Scan bus look for a specific device. Only bus 0 scanned for now. */
 pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id)
diff --git a/lib/x86/pci.h b/lib/pci.h
similarity index 60%
rename from lib/x86/pci.h
rename to lib/pci.h
index 046e68f..65fcd94 100644
--- a/lib/x86/pci.h
+++ b/lib/pci.h
@@ -1,6 +1,13 @@
 #ifndef PCI_H
 #define PCI_H
-
+/*
+ * API for scanning a PCI bus for a given device, as well to access
+ * BAR registers.
+ *
+ * Copyright (C) 2013, Red Hat Inc, Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
 #include "libcflat.h"
 
 typedef uint16_t pcidevaddr_t;
diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h
new file mode 100644
index 0000000..4ec20e1
--- /dev/null
+++ b/lib/x86/asm/pci.h
@@ -0,0 +1,19 @@
+#ifndef ASM_PCI_H
+#define ASM_PCI_H
+/*
+ * Copyright (C) 2013, Red Hat Inc, Michael S. Tsirkin <mst@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include "libcflat.h"
+#include "pci.h"
+#include "x86/io.h"
+
+static inline uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg)
+{
+    uint32_t index = reg | (dev << 8) | (0x1 << 31);
+    outl(index, 0xCF8);
+    return inl(0xCFC);
+}
+
+#endif