new file mode 100644
@@ -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 */
@@ -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 */
@@ -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"
@@ -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>
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