new file mode 100644
@@ -0,0 +1,18 @@
+/*
+ * Flattened Device Tree alias helpers
+ *
+ * Copyright (C) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version. See the COPYING file in the
+ * top-level directory.
+ */
+#ifndef HW_SYSBUS_FDT_H
+#define HW_SYSBUS_FDT_H
+
+void type_register_fdt_alias(const char *name, const char *alias);
+void type_register_fdt_aliases(const char *name, const char **aliases);
+
+const char *type_resolve_fdt_alias(const char *alias);
+
+#endif /* HW_SYSBUS_FDT_H */
new file mode 100644
@@ -0,0 +1,30 @@
+#include "qemu/osdep.h"
+#include "hw/sysbus-fdt.h"
+
+static GHashTable *fdt_aliases(void)
+{
+ static GHashTable *fdt_aliases_singleton;
+
+ if (!fdt_aliases_singleton) {
+ fdt_aliases_singleton = g_hash_table_new(g_str_hash, g_str_equal);
+ }
+ return fdt_aliases_singleton;
+}
+
+void type_register_fdt_alias(const char *name, const char *alias)
+{
+ g_hash_table_insert(fdt_aliases(), (gpointer)name, (gpointer)name);
+ g_hash_table_insert(fdt_aliases(), (gpointer)alias, (gpointer)name);
+}
+
+void type_register_fdt_aliases(const char *name, const char **aliases)
+{
+ for (; *aliases; aliases++) {
+ type_register_fdt_alias(name, *aliases);
+ }
+}
+
+const char *type_resolve_fdt_alias(const char *alias)
+{
+ return g_hash_table_lookup(fdt_aliases(), alias);
+}
@@ -11,6 +11,7 @@ common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
common-obj-$(CONFIG_XILINX_AXI) += stream.o
common-obj-$(CONFIG_PTIMER) += ptimer.o
common-obj-$(CONFIG_SOFTMMU) += sysbus.o
+common-obj-$(CONFIG_SOFTMMU) += sysbus-fdt.o
common-obj-$(CONFIG_SOFTMMU) += machine.o
common-obj-$(CONFIG_SOFTMMU) += loader.o
common-obj-$(CONFIG_FITLOADER) += loader-fit.o
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/hw/sysbus-fdt.h | 18 ++++++++++++++++++ hw/core/sysbus-fdt.c | 30 ++++++++++++++++++++++++++++++ hw/core/Makefile.objs | 1 + 3 files changed, 49 insertions(+) create mode 100644 include/hw/sysbus-fdt.h create mode 100644 hw/core/sysbus-fdt.c