hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables
RFC PATCH 7/7 hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables
Expose the needed device information to the table generation insfrastructure and assemble the final compacted ACPI binary blob in the guest memory.
Signed-off-by Alvise Rigo <[email protected]>
--- hw/arm/boot.c | 26 +++++++++++++++++++++++++ hw/arm/virt-acpi.c | 18 +++++++++++++++++- hw/arm/virt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++---- include/hw/arm/arm.h | 2 ++ 4 files changed, 95 insertions(+), 5 deletions(-)
hw/arm/boot.c +26 -0
@@ -179,6 +179,11 @@ static inline bool have_dtb(const struct arm_boot_info *info)return info->dtb_filename || info->get_dtb; } +static inline bool have_acpi (const struct arm_boot_info *info) +{ +return info->get_acpi; +} +#define WRITE_WORD (p, value) do { \ stl_phys_notdirty(&address_space_memory, p, value); \ p += 4; \
@@ -438,6 +443,20 @@ fail:return -1 ; } +static int load_acpi (hwaddr addr,const struct arm_boot_info *binfo, +hwaddr addr_limit) +{ +void *acpi_blob =NULL ; +int acpi_size; + + acpi_blob = binfo->get_acpi (binfo, &acpi_size); +rom_add_blob_fixed ("acpi" , acpi_blob, acpi_size, binfo->acpi_base_addr); +g_free (acpi_blob); +/* TODO: check to not write outside memory boundaries */ + +return 0 ; +} +static void do_cpu_reset (void *opaque) {ARMCPU *cpu = opaque;
@@ -497,6 +516,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)qemu_register_reset (do_cpu_reset,ARM_CPU (cs)); } +/* load ACPI blob */ +if (have_acpi (info)) { +if (load_acpi (info->acpi_base_addr, info,0 ) <0 ) { +exit (1 ); + } + } +/* Load the kernel. */ if (!info->kernel_filename) {
hw/arm/virt-acpi.c +17 -1
@@ -535,5 +535,21 @@ void acpi_build_tables(int smp_cpus,uint32_t acpi_make_blob (void **blob_ptr) { -return 0 ; +uint8_t *acpi_blob_ptr =NULL ; +uint32_t blob_size, n; + +for (n =RSDP , blob_size =0 ; n <=DSDT ; n++) { + blob_size += acpi_size[n]; + } + + *blob_ptr = (void *)g_malloc0 (blob_size); + acpi_blob_ptr = *blob_ptr; + +for (n =RSDP ; n <=DSDT ; n++) { +memcpy (acpi_blob_ptr, acpi_table[n], acpi_size[n]); + acpi_blob_ptr += acpi_size[n]; +g_free (acpi_table[n]); + } + +return blob_size; }
hw/arm/virt.c +50 -4
102 lines not on this page · raw message
include/hw/arm/arm.h +2 -0
@@ -27,6 +27,7 @@ struct arm_boot_info {const char *initrd_filename;const char *dtb_filename;hwaddr loader_start; +hwaddr acpi_base_addr;/* multicore boards that use the default secondary core boot functions * need to put the address of the secondary boot code, the boot reg, * and the GIC address in the next 3 values, respectively. boards that
@@ -61,6 +62,7 @@ struct arm_boot_info {* the user it should implement this hook. */ void (*modify_dtb)(const struct arm_boot_info *info,void *fdt); +void *(*get_acpi)(const struct arm_boot_info *info,int *size);/* Used internally by arm_boot.c */ int is_linux;hwaddr initrd_start;
Signature · 1 line
1.9.1