From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH 06/11] x86: move x86/pci to the common lib Date: Fri, 15 Jan 2016 17:10:11 +0100 Message-ID: <1452874216-3087-7-git-send-email-drjones@redhat.com> References: <1452874216-3087-1-git-send-email-drjones@redhat.com> 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]:44309 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbcAOQKe (ORCPT ); Fri, 15 Jan 2016 11:10:34 -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 09D7AC0B73FA for ; Fri, 15 Jan 2016 16:10:34 +0000 (UTC) In-Reply-To: <1452874216-3087-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones --- config/config-x86-common.mak | 2 +- lib/{x86 => }/pci.c | 6 ++++++ lib/pci.h | 22 ++++++++++++++++++++++ lib/x86/asm/pci.h | 14 +++----------- x86/vmexit.c | 2 +- 5 files changed, 33 insertions(+), 13 deletions(-) rename lib/{x86 => }/pci.c (86%) create mode 100644 lib/pci.h diff --git a/config/config-x86-common.mak b/config/config-x86-common.mak index 4a2746826784c..860cbb0a7db4d 100644 --- a/config/config-x86-common.mak +++ b/config/config-x86-common.mak @@ -10,8 +10,8 @@ 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 +cflatobjs += lib/pci.o $(libcflat): LDFLAGS += -nostdlib $(libcflat): CFLAGS += -ffreestanding -I lib diff --git a/lib/x86/pci.c b/lib/pci.c similarity index 86% rename from lib/x86/pci.c rename to lib/pci.c index 7002d80836a4c..0058d70c888d8 100644 --- a/lib/x86/pci.c +++ b/lib/pci.c @@ -1,4 +1,10 @@ +/* + * 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 "asm/pci.h" /* Scan bus look for a specific device. Only bus 0 scanned for now. */ diff --git a/lib/pci.h b/lib/pci.h new file mode 100644 index 0000000000000..65fcd9444461c --- /dev/null +++ b/lib/pci.h @@ -0,0 +1,22 @@ +#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" + +typedef uint16_t pcidevaddr_t; +enum { + PCIDEVADDR_INVALID = 0x0 +}; +pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); +unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num); +bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num); +bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num); + +#endif diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h index 8ad93a87966c6..f7028defb63b2 100644 --- a/lib/x86/asm/pci.h +++ b/lib/x86/asm/pci.h @@ -1,18 +1,10 @@ -#ifndef PCI_H -#define PCI_H +#ifndef ASM_PCI_H +#define ASM_PCI_H #include "libcflat.h" +#include "pci.h" #include "asm/io.h" -typedef uint16_t pcidevaddr_t; -enum { - PCIDEVADDR_INVALID = 0x0 -}; -pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); -unsigned long pci_bar_addr(pcidevaddr_t dev, int bar_num); -bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num); -bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num); - static inline uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg) { uint32_t index = reg | (dev << 8) | (0x1 << 31); diff --git a/x86/vmexit.c b/x86/vmexit.c index 61243a9d63c9a..35c6fac747588 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 "asm/pci.h" #include "x86/acpi.h" #include "asm/io.h" -- 2.4.3