From: Ruslan Ruslichenko <[email protected]> Add new FDT_GENERIC_MMAP class and interface to allow devices to register own handlers for mapping memory regions in device tree's 'reg' property.
Signed-off-by: Ruslan Ruslichenko <[email protected]> --- hw/core/fdt_generic_util.c | 11 ++++++++ include/hw/core/fdt_generic_util.h | 44 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/hw/core/fdt_generic_util.c b/hw/core/fdt_generic_util.c index 2c3f4d6b09..c0e974e53a 100644 --- a/hw/core/fdt_generic_util.c +++ b/hw/core/fdt_generic_util.c @@ -766,3 +766,14 @@ static int fdt_init_qdev(char *node_path, FDTMachineInfo *fdti, char *compat) return 0; } +static const TypeInfo fdt_generic_mmap_info = { + .name = TYPE_FDT_GENERIC_MMAP, + .parent = TYPE_INTERFACE, + .class_size = sizeof(FDTGenericMMapClass), +}; + +static void fdt_generic_register_types(void) +{ + type_register_static(&fdt_generic_mmap_info); +} +type_init(fdt_generic_register_types) diff --git a/include/hw/core/fdt_generic_util.h b/include/hw/core/fdt_generic_util.h index e18c4f9c8b..38086ec1e4 100644 --- a/include/hw/core/fdt_generic_util.h +++ b/include/hw/core/fdt_generic_util.h @@ -16,4 +16,48 @@ FDTMachineInfo *fdt_generic_create_machine(void *fdt, qemu_irq *cpu_irq); +#define TYPE_FDT_GENERIC_MMAP "fdt-generic-mmap" + +#define FDT_GENERIC_MMAP_CLASS(klass) \ + OBJECT_CLASS_CHECK(FDTGenericMMapClass, (klass), TYPE_FDT_GENERIC_MMAP) +#define FDT_GENERIC_MMAP_GET_CLASS(obj) \ + OBJECT_GET_CLASS(FDTGenericMMapClass, (obj), TYPE_FDT_GENERIC_MMAP) +#define FDT_GENERIC_MMAP(obj) \ + INTERFACE_CHECK(FDTGenericMMap, (obj), TYPE_FDT_GENERIC_MMAP) + +typedef struct FDTGenericMMap { + /*< private >*/ + Object parent_obj; +} FDTGenericMMap; + +/* + * The number of "things" in the tuple. Not to be confused with the cell length + * of the tuple (which is variable based on content + */ + +#define FDT_GENERIC_REG_TUPLE_LENGTH 4 + +typedef struct FDTGenericRegPropInfo { + int n; + union { + struct { + uint64_t *a; + uint64_t *s; + uint64_t *b; + uint64_t *p; + }; + uint64_t *x[FDT_GENERIC_REG_TUPLE_LENGTH]; + }; + Object **parents; +} FDTGenericRegPropInfo; + +typedef struct FDTGenericMMapClass { + /*< private >*/ + InterfaceClass parent_class; + + /*< public >*/ + bool (*parse_reg)(FDTGenericMMap *obj, FDTGenericRegPropInfo info, + Error **errp); +} FDTGenericMMapClass; + #endif /* FDT_GENERIC_UTIL_H */ -- 2.43.0
