hw/acpi: extract acpi_add_rom_blob()
PATCH v3 1/1 hw/acpi: extract acpi_add_rom_blob()
arm and i386 has almost the same function acpi_add_rom_blob(), except giving different FWCfgCallback function.
This patch extract acpi_add_rom_blob() to utils.c by passing FWCfgCallback to it.
---
v3:
* put acpi_add_rom_blob() to hw/acpi/utils.c
v2:
* remove unused header in original source file
--- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.h
hw/acpi/Makefile.objs +1 -1
@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_IPMI) += ipmi.o
hw/acpi/utils.c new file +35 -0
@@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests +* +* Copyright (C) 2019 Intel Corporation +* Copyright (C) 2019 Red Hat Inc +* +* Author: Wei Yang <[email protected]> +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include <glib/gprintf.h> +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size) +{ +return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , + name, update, opaque,NULL , true); +} +
hw/arm/virt-acpi-build.c +10 -16
@@ -37,9 +37,9 @@#include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h"
@@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, virt_acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_virt_acpi_build = { .name ="virt_acpi_build" , .version_id =1 ,
@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (virt_acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 );qemu_register_reset (virt_acpi_build_reset, build_state);virt_acpi_build_reset (build_state);
hw/i386/acpi-build.c +10 -16
@@ -37,7 +37,6 @@#include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h"
@@ -58,6 +57,7 @@#include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h"
@@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =0 ; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_acpi_build = { .name ="acpi_build" , .version_id =1 ,
@@ -2891,14 +2883,15 @@ void acpi_setup(void)acpi_build (&tables,MACHINE (pcms));/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog));
@@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =NULL ; }else { build_state->rsdp =NULL ; - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); }qemu_register_reset (acpi_build_reset, build_state);
include/hw/acpi/utils.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size); +#endif
Signature · 1 line
2.19.1
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:
in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passing
s/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>
otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as well
Quoted 213 lines
---
v3:
* putacpi_add_rom_blob()tohw/acpi/utils.c
v2:
* remove unused header in original source file--- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.hhw/acpi/Makefile.objs +1
-1@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/acpi/utils.c new file +35
-0@@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests +* +* Copyright (C) 2019 Intel Corporation +* Copyright (C) 2019 Red Hat Inc +* +* Author: Wei Yang <[email protected]> +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include <glib/gprintf.h> +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size) +{ +return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , + name, update, opaque,NULL , true); +} +hw/arm/virt-acpi-build.c +10
-16@@ -37,9 +37,9 @@#include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, virt_acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_virt_acpi_build = { .name ="virt_acpi_build" , .version_id =1 ,@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (virt_acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 );qemu_register_reset (virt_acpi_build_reset, build_state);virt_acpi_build_reset (build_state);hw/i386/acpi-build.c +10
-16@@ -37,7 +37,6 @@#include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@#include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =0 ; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_acpi_build = { .name ="acpi_build" , .version_id =1 ,@@ -2891,14 +2883,15 @@ void acpi_setup(void)acpi_build (&tables,MACHINE (pcms));/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog));@@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =NULL ; }else { build_state->rsdp =NULL ; - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); }qemu_register_reset (acpi_build_reset, build_state);include/hw/acpi/utils.h new file +9
-0@@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size); +#endif
Quoted 9 lines · Igor Mammedov
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passing
Quoted 8 lines
s/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as well
Yes, I see the warning from checkpatch.
Quoted 29 lines
Quoted 29 lines
---
v3:
* putacpi_add_rom_blob()tohw/acpi/utils.c
v2:
* remove unused header in original source file--- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.hhw/acpi/Makefile.objs +1
-1@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_TPM) += tpm.o
Quoted 8 lines
hw/acpi/utils.c line 1
Quoted 8 lines
hw/acpi/Makefile.objs +0
-0common-obj-$(CONFIG_IPMI) += ipmi.ohw/acpi/utils.c new file +1
-0@@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests
The warning is to this line. I thought this is a special case :-)
Will fix it in next version.
Quoted 178 lines
Quoted 177 lines
hw/acpi/utils.c new file +34
-0+* +* Copyright (C) 2019 Intel Corporation +* Copyright (C) 2019 Red Hat Inc +* +* Author: Wei Yang <[email protected]> +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include <glib/gprintf.h> +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size) +{ +return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , + name, update, opaque,NULL , true); +} +hw/arm/virt-acpi-build.c +10
-16@@ -37,9 +37,9 @@#include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, virt_acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_virt_acpi_build = { .name ="virt_acpi_build" , .version_id =1 ,@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (virt_acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 );qemu_register_reset (virt_acpi_build_reset, build_state);virt_acpi_build_reset (build_state);hw/i386/acpi-build.c +10
-16@@ -37,7 +37,6 @@#include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@#include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =0 ; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_acpi_build = { .name ="acpi_build" , .version_id =1 ,@@ -2891,14 +2883,15 @@ void acpi_setup(void)acpi_build (&tables,MACHINE (pcms));/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog));@@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =NULL ; }else { build_state->rsdp =NULL ; - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); }qemu_register_reset (acpi_build_reset, build_state);include/hw/acpi/utils.h new file +9
-0@@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size); +#endif
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 9 lines · Igor Mammedov
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passing
Quoted 9 lines
s/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as well
BTW, the checkpatch also says
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
Do I need to fix this?
Quoted 213 lines
Quoted 213 lines
---
v3:
* putacpi_add_rom_blob()tohw/acpi/utils.c
v2:
* remove unused header in original source file--- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.hhw/acpi/Makefile.objs +1
-1@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/acpi/utils.c new file +35
-0@@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests +* +* Copyright (C) 2019 Intel Corporation +* Copyright (C) 2019 Red Hat Inc +* +* Author: Wei Yang <[email protected]> +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include <glib/gprintf.h> +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size) +{ +return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , + name, update, opaque,NULL , true); +} +hw/arm/virt-acpi-build.c +10
-16@@ -37,9 +37,9 @@#include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, virt_acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_virt_acpi_build = { .name ="virt_acpi_build" , .version_id =1 ,@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (virt_acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 );qemu_register_reset (virt_acpi_build_reset, build_state);virt_acpi_build_reset (build_state);hw/i386/acpi-build.c +10
-16@@ -37,7 +37,6 @@#include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@#include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =0 ; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_acpi_build = { .name ="acpi_build" , .version_id =1 ,@@ -2891,14 +2883,15 @@ void acpi_setup(void)acpi_build (&tables,MACHINE (pcms));/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog));@@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =NULL ; }else { build_state->rsdp =NULL ; - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); }qemu_register_reset (acpi_build_reset, build_state);include/hw/acpi/utils.h new file +9
-0@@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size); +#endif
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 20 lines · On Tue, 19 Mar 2019 08:45:23 +0800 Wei Yang <[email protected]>…
Quoted 9 lines · Igor Mammedov
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passingQuoted 9 lines
s/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as well
Quoted 5 lines
BTW, the checkpatch also says
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?Do I need to fix this?
yep, add me and Michael as maintainers for these new files.
Quoted 213 lines
Quoted 212 lines
Quoted 212 lines
---
v3:
* putacpi_add_rom_blob()tohw/acpi/utils.c
v2:
* remove unused header in original source file--- hw/acpi/Makefile.objs | 2 +- hw/acpi/utils.c | 35 +++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++++---------------- hw/i386/acpi-build.c | 26 ++++++++++---------------- include/hw/acpi/utils.h | 9 +++++++++ 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 hw/acpi/utils.c create mode 100644 include/hw/acpi/utils.hhw/acpi/Makefile.objs +1
-1@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o -common-obj-y += aml-build.o +common-obj-y += aml-build.o utils.o common-obj-$(CONFIG_TPM) += tpm.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/acpi/utils.c new file +35
-0@@ -0,0 +1,35 @@ +/* Utilities for generating ACPI tables and passing them to Guests +* +* Copyright (C) 2019 Intel Corporation +* Copyright (C) 2019 Red Hat Inc +* +* Author: Wei Yang <[email protected]> +* Author: Igor Mammedov <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include <glib/gprintf.h> +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size) +{ +return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , + name, update, opaque,NULL , true); +} +hw/arm/virt-acpi-build.c +10
-16@@ -37,9 +37,9 @@#include "hw/acpi/acpi.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque) build_state->patched = false; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, virt_acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_virt_acpi_build = { .name ="virt_acpi_build" , .version_id =1 ,@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)virt_acpi_build (vms, &tables);/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (virt_acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (vms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog)); - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (virt_acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 );qemu_register_reset (virt_acpi_build_reset, build_state);virt_acpi_build_reset (build_state);hw/i386/acpi-build.c +10
-16@@ -37,7 +37,6 @@#include "hw/acpi/cpu.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/loader.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" @@ -58,6 +57,7 @@#include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -2842,14 +2842,6 @@ static void acpi_build_reset(void *build_opaque) build_state->patched =0 ; } -static MemoryRegion *acpi_add_rom_blob (AcpiBuildState *build_state, -GArray *blob,const char *name, -uint64_t max_size) -{ -return rom_add_blob (name, blob->data,acpi_data_len (blob), max_size,-1 , - name, acpi_build_update, build_state,NULL , true); -} -static const VMStateDescription vmstate_acpi_build = { .name ="acpi_build" , .version_id =1 ,@@ -2891,14 +2883,15 @@ void acpi_setup(void)acpi_build (&tables,MACHINE (pcms));/* Now expose it all to Guest */ - build_state->table_mr =acpi_add_rom_blob (build_state, tables.table_data, -ACPI_BUILD_TABLE_FILE , -ACPI_BUILD_TABLE_MAX_SIZE ); + build_state->table_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.table_data, +ACPI_BUILD_TABLE_FILE , +ACPI_BUILD_TABLE_MAX_SIZE );assert (build_state->table_mr !=NULL ); build_state->linker_mr = -acpi_add_rom_blob (build_state, tables.linker->cmd_blob, -"etc/table-loader" ,0 ); +acpi_add_rom_blob (acpi_build_update, build_state, + tables.linker->cmd_blob,"etc/table-loader" ,0 );fw_cfg_add_file (pcms->fw_cfg,ACPI_BUILD_TPMLOG_FILE , tables.tcpalog->data,acpi_data_len (tables.tcpalog));@@ -2935,8 +2928,9 @@ void acpi_setup(void) build_state->rsdp_mr =NULL ; }else { build_state->rsdp =NULL ; - build_state->rsdp_mr =acpi_add_rom_blob (build_state, tables.rsdp, -ACPI_BUILD_RSDP_FILE ,0 ); + build_state->rsdp_mr =acpi_add_rom_blob (acpi_build_update, + build_state, tables.rsdp, +ACPI_BUILD_RSDP_FILE ,0 ); }qemu_register_reset (acpi_build_reset, build_state);include/hw/acpi/utils.h new file +9
-0@@ -0,0 +1,9 @@ +#ifndef HW_ACPI_UTILS_H +#define HW_ACPI_UTILS_H + +#include "hw/loader.h" + +MemoryRegion *acpi_add_rom_blob (FWCfgCallback update,void *opaque, +GArray *blob,const char *name, +uint64_t max_size); +#endif
Quoted 23 lines · Igor Mammedov
Quoted 20 lines · On Tue, 19 Mar 2019 08:45:23 +0800 Wei Yang <[email protected]>…
Quoted 18 lines · Igor Mammedov
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passings/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as well
Quoted 7 lines
Quoted 5 lines
BTW, the checkpatch also says
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?Do I need to fix this?
yep, add me and Michael as maintainers for these new files.
It looks current statement already includes those files.
ACPI/SMBIOS
M: Michael S. Tsirkin <[email protected]>
M: Igor Mammedov <[email protected]>
S: Supported
F: include/hw/acpi/*
F: hw/acpi/*
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 32 lines · On Wed, 20 Mar 2019 08:37:14 +0800 Wei Yang <[email protected]>…
Quoted 23 lines · Igor Mammedov
Quoted 20 lines · On Tue, 19 Mar 2019 08:45:23 +0800 Wei Yang <[email protected]>…
Quoted 18 lines · Igor Mammedov
On Fri, 15 Mar 2019 08:44:32 +0800
Wei Yang <[email protected]> wrote:in subject: s/extract/generalize/
Quoted 4 lines
arm and i386 has almost the same function
acpi_add_rom_blob(), except giving different FWCfgCallback function.This patch extract
acpi_add_rom_blob()toutils.cby passings/extract/moves/
Quoted 3 lines
FWCfgCallback to it.
Signed-off-by Wei Yang <[email protected]>otherwise patch looks fine to me,
but checkpatch complains about comment style so that needs to be fixed as wellQuoted 7 lines
Quoted 5 lines
BTW, the checkpatch also says
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?Do I need to fix this?
yep, add me and Michael as maintainers for these new files.
Quoted 8 lines
It looks current statement already includes those files.
ACPI/SMBIOS
M: Michael S. Tsirkin <[email protected]>
M: Igor Mammedov <[email protected]>
S: Supported
F:include/hw/acpi/*
F: hw/acpi/*
Agreed, checkpatch warning look like false positive, pls ignore it