diff mbox

[RFC,09/16] kvm tools: make _FDT macro usable by other architectures

Message ID 1352721450-11340-10-git-send-email-will.deacon@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Will Deacon Nov. 12, 2012, 11:57 a.m. UTC
The _FDT macro is useful when generating device trees for a guest, so
make it available to other architectures.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 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 mbox

Patch

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 <linux/types.h>
+
+#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 <linux/pci_regs.h>
 #include <linux/byteorder.h>