From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH v3 6/8] x86: move x86/pci to the common lib Date: Mon, 18 Jan 2016 19:01:02 +0100 Message-ID: <1453140064-9040-7-git-send-email-drjones@redhat.com> References: <1453140064-9040-1-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: pbonzini@redhat.com, mst@redhat.com, agordeev@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:59511 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756140AbcARSBV (ORCPT ); Mon, 18 Jan 2016 13:01:21 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D7B848F86D for ; Mon, 18 Jan 2016 18:01:21 +0000 (UTC) In-Reply-To: <1453140064-9040-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Also move pci_config_read into asm/pci.h Signed-off-by: Andrew Jones Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- config/config-x86-common.mak | 2 +- lib/asm-generic/pci.h | 4 ++++ lib/{x86 =3D> }/pci.c | 14 ++++++-------- lib/{x86 =3D> }/pci.h | 9 ++++++++- lib/x86/asm/pci.h | 19 +++++++++++++++++++ x86/vmexit.c | 2 +- 6 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 lib/asm-generic/pci.h rename lib/{x86 =3D> }/pci.c (84%) rename lib/{x86 =3D> }/pci.h (60%) create mode 100644 lib/x86/asm/pci.h diff --git a/config/config-x86-common.mak b/config/config-x86-common.ma= k index 4a2746826784c..3a14feaaa7748 100644 --- a/config/config-x86-common.mak +++ b/config/config-x86-common.mak @@ -2,6 +2,7 @@ =20 all: test_cases =20 +cflatobjs +=3D lib/pci.o cflatobjs +=3D lib/x86/io.o cflatobjs +=3D lib/x86/smp.o cflatobjs +=3D lib/x86/vm.o @@ -10,7 +11,6 @@ cflatobjs +=3D lib/x86/apic.o cflatobjs +=3D lib/x86/atomic.o cflatobjs +=3D lib/x86/desc.o cflatobjs +=3D lib/x86/isr.o -cflatobjs +=3D lib/x86/pci.o cflatobjs +=3D lib/x86/acpi.o =20 $(libcflat): LDFLAGS +=3D -nostdlib diff --git a/lib/asm-generic/pci.h b/lib/asm-generic/pci.h new file mode 100644 index 0000000000000..3fa0b2ab1fe64 --- /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 6aa6d70353127..0058d70c888d8 100644 --- a/lib/x86/pci.c +++ b/lib/pci.c @@ -1,13 +1,11 @@ +/* + * Copyright (C) 2013, Red Hat Inc, Michael S. Tsirkin + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ #include #include "pci.h" -#include "io.h" - -static uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg) -{ - uint32_t index =3D reg | (dev << 8) | (0x1 << 31);=20 - outl(index, 0xCF8); - return inl(0xCFC); -} +#include "asm/pci.h" =20 /* 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 046e68f9a65b6..65fcd9444461c 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 + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ #include "libcflat.h" =20 typedef uint16_t pcidevaddr_t; diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h new file mode 100644 index 0000000000000..4ec20e17d25bb --- /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 + * + * 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 =3D reg | (dev << 8) | (0x1 << 31); + outl(index, 0xCF8); + return inl(0xCFC); +} + +#endif diff --git a/x86/vmexit.c b/x86/vmexit.c index e9f240872788a..81ac7a88fda93 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -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" =20 --=20 2.4.3