From patchwork Mon Nov 12 11:57:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 1727981 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 23B8C3FCDE for ; Mon, 12 Nov 2012 11:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037Ab2KLL6G (ORCPT ); Mon, 12 Nov 2012 06:58:06 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:55172 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752719Ab2KLL5k (ORCPT ); Mon, 12 Nov 2012 06:57:40 -0500 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.79.58]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id qACBvZE7025858; Mon, 12 Nov 2012 11:57:35 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id E2B9CC277E; Mon, 12 Nov 2012 11:57:33 +0000 (GMT) From: Will Deacon To: kvm@vger.kernel.org Cc: penberg@kernel.org, marc.zyngier@arm.com, c.dall@virtualopensystems.com, matt.evans@arm.com, peter.maydell@linaro.org, Will Deacon Subject: [RFC PATCH 09/16] kvm tools: make _FDT macro usable by other architectures Date: Mon, 12 Nov 2012 11:57:23 +0000 Message-Id: <1352721450-11340-10-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1352721450-11340-1-git-send-email-will.deacon@arm.com> References: <1352721450-11340-1-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The _FDT macro is useful when generating device trees for a guest, so make it available to other architectures. Signed-off-by: Will Deacon --- tools/kvm/include/kvm/fdt.h | 26 ++++++++++++++++++++++++++ tools/kvm/powerpc/include/kvm/kvm-arch.h | 11 ----------- tools/kvm/powerpc/kvm.c | 2 +- tools/kvm/powerpc/spapr_pci.c | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 tools/kvm/include/kvm/fdt.h diff --git a/tools/kvm/include/kvm/fdt.h b/tools/kvm/include/kvm/fdt.h new file mode 100644 index 0000000..19f95ac --- /dev/null +++ b/tools/kvm/include/kvm/fdt.h @@ -0,0 +1,26 @@ +#ifndef KVM__FDT_H +#define KVM__FDT_H + +#include "libfdt.h" + +#include + +#define FDT_MAX_SIZE 0x10000 + +/* Helper for the various bits of code that generate FDT nodes */ +#define _FDT(exp) \ + do { \ + int ret = (exp); \ + if (ret < 0) { \ + die("Error creating device tree: %s: %s\n", \ + #exp, fdt_strerror(ret)); \ + } \ + } while (0) + +static inline u32 fdt__alloc_phandle(void) +{ + static u32 phandle = 0; + return ++phandle; +} + +#endif /* KVM__FDT_H */ diff --git a/tools/kvm/powerpc/include/kvm/kvm-arch.h b/tools/kvm/powerpc/include/kvm/kvm-arch.h index 97181c4..dd8a307 100644 --- a/tools/kvm/powerpc/include/kvm/kvm-arch.h +++ b/tools/kvm/powerpc/include/kvm/kvm-arch.h @@ -27,7 +27,6 @@ #define KERNEL_SECONDARY_START_ADDR 0x0000000000000060 #define INITRD_LOAD_ADDR 0x0000000002800000 -#define FDT_MAX_SIZE 0x10000 #define RTAS_MAX_SIZE 0x10000 #define TIMEBASE_FREQ 512000000ULL @@ -55,14 +54,4 @@ struct kvm_arch { struct spapr_phb *phb; }; -/* Helper for the various bits of code that generate FDT nodes */ -#define _FDT(exp) \ - do { \ - int ret = (exp); \ - if (ret < 0) { \ - die("Error creating device tree: %s: %s\n", \ - #exp, fdt_strerror(ret)); \ - } \ - } while (0) - #endif /* KVM__KVM_ARCH_H */ diff --git a/tools/kvm/powerpc/kvm.c b/tools/kvm/powerpc/kvm.c index d675265..d8dfc01 100644 --- a/tools/kvm/powerpc/kvm.c +++ b/tools/kvm/powerpc/kvm.c @@ -11,9 +11,9 @@ * by the Free Software Foundation. */ +#include "kvm/fdt.h" #include "kvm/kvm.h" #include "kvm/util.h" -#include "libfdt.h" #include "cpu_info.h" #include "spapr.h" diff --git a/tools/kvm/powerpc/spapr_pci.c b/tools/kvm/powerpc/spapr_pci.c index 5bfcec1..5f4016c 100644 --- a/tools/kvm/powerpc/spapr_pci.c +++ b/tools/kvm/powerpc/spapr_pci.c @@ -15,9 +15,9 @@ #include "spapr.h" #include "spapr_pci.h" +#include "kvm/fdt.h" #include "kvm/util.h" #include "kvm/pci.h" -#include "libfdt.h" #include #include