@@ -2,6 +2,7 @@
all: test_cases
+cflatobjs += lib/pci.o
cflatobjs += lib/x86/io.o
cflatobjs += lib/x86/smp.o
cflatobjs += lib/x86/vm.o
@@ -10,7 +11,6 @@ cflatobjs += lib/x86/apic.o
cflatobjs += lib/x86/atomic.o
cflatobjs += lib/x86/desc.o
cflatobjs += lib/x86/isr.o
-cflatobjs += lib/x86/pci.o
cflatobjs += lib/x86/acpi.o
$(libcflat): LDFLAGS += -nostdlib
new file mode 100644
@@ -0,0 +1,4 @@
+#ifndef _ASM_GENERIC_PCI_H_
+#define _ASM_GENERIC_PCI_H_
+#error need architecture specific asm/pci.h
+#endif
similarity index 84%
rename from lib/x86/pci.c
rename to 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)
similarity index 60%
rename from lib/x86/pci.h
rename to 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;
new file mode 100644
@@ -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
@@ -2,9 +2,9 @@
#include "smp.h"
#include "processor.h"
#include "atomic.h"
+#include "pci.h"
#include "x86/vm.h"
#include "x86/desc.h"
-#include "x86/pci.h"
#include "x86/acpi.h"
#include "x86/io.h"