Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-27 Thread Shannon Zhao
On 2015/1/27 18:30, Igor Mammedov wrote:
> On Tue, 27 Jan 2015 14:47:44 +0800
> Shannon Zhao  wrote:
> 
>> On 2015/1/26 18:19, Igor Mammedov wrote:
>>> On Sat, 24 Jan 2015 17:21:11 +0800
>>> Shannon Zhao  wrote:
>>>
 Introduce a preliminary framework in virt-acpi-build.c with the main
 ACPI build functions. It exposes the generated ACPI contents to
 guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.

 The minimum required ACPI v5.1 tables for ARM are:
 - RSDP: Initial table that points to XSDT
 - XSDT: Points to all other tables (except FACS & DSDT)
 - FADT: Generic information about the machine
 - DSDT: Holds all information about system devices/peripherals
 - FACS: Needs to be pointed from FADT
>>>
>>> most of table manipulation code (tables adding to blob/linking)
>>> could/should be shared with x86,
>>> could you generalize it instead of just copying, please.
>>>
>>
>> Thanks for your suggestion and your great work to make ACPI table generation 
>> simpler :-)
>>
>> Apparently this code is similar with the x86 as their approach are same.
>> But the detail of implementation is different at some degree.
>> E.g, X86 use some static DSL files while this dynamically generate all thing.
> I'm talking not about build_fooTable() functions but rather helpers, like:
> acpi_data_push, acpi_add_table, acpi_build_*, huge chunk of acpi_build()
> you also probably don't need ACPI_BUILD_TABLE_SIZE and other related macroes.
> 

Ok, thanks.

>>

 Signed-off-by: Shannon Zhao 
 ---
  hw/arm/Makefile.objs |1 +
  hw/arm/virt-acpi-build.c |  263 
 ++
  include/hw/arm/virt-acpi-build.h |   71 ++
  3 files changed, 335 insertions(+), 0 deletions(-)
  create mode 100644 hw/arm/virt-acpi-build.c
  create mode 100644 include/hw/arm/virt-acpi-build.h

 diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
 index 6088e53..8daf825 100644
 --- a/hw/arm/Makefile.objs
 +++ b/hw/arm/Makefile.objs
 @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
 +obj-$(CONFIG_ACPI) += virt-acpi-build.o
  
  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
  obj-$(CONFIG_DIGIC) += digic.o
 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
 new file mode 100644
 index 000..4eed0a3
 --- /dev/null
 +++ b/hw/arm/virt-acpi-build.c
 @@ -0,0 +1,263 @@
 +/* Support for generating ACPI tables and passing them to Guests
 + *
 + * ARM virt ACPI generation
 + *
 + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
 + *
 + * Author: Shannon Zhao 
 + *
 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms and conditions of the GNU General Public License,
 + * version 2 or later, as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope 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 .
 + */
 +
 +#include "hw/arm/virt-acpi-build.h"
 +#include 
 +#include 
 +#include "qemu-common.h"
 +#include "qemu/bitmap.h"
 +#include "qemu/osdep.h"
 +#include "qemu/range.h"
 +#include "qemu/error-report.h"
 +#include "qom/cpu.h"
 +#include "target-arm/cpu.h"
 +#include "hw/acpi/acpi-defs.h"
 +#include "hw/acpi/acpi.h"
 +#include "hw/nvram/fw_cfg.h"
 +#include "hw/acpi/bios-linker-loader.h"
 +#include "hw/loader.h"
 +
 +#include "hw/acpi/acpi-build-utils.h"
 +
 +#include "qapi/qmp/qint.h"
 +#include "qom/qom-qobject.h"
 +#include "exec/ram_addr.h"
 +
 +
 +#define ACPI_BUILD_TABLE_SIZE 0x2
 +
 +/* Reserve RAM space for tables: add another order of magnitude. */
 +#define ACPI_BUILD_TABLE_MAX_SIZE 0x20
 +
 +/* #define DEBUG_ACPI_BUILD */
 +#ifdef DEBUG_ACPI_BUILD
 +#define ACPI_BUILD_DPRINTF(fmt, ...)\
 +do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0)
 +#else
 +#define ACPI_BUILD_DPRINTF(fmt, ...)
 +#endif
 +
 +#define ACPI_BUILD_APPNAME  "Bochs"
 +#define ACPI_BUILD_APPNAME6 "BOCHS "
 +
 +#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
 +#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
 +
 +static inline void *acpi_data_push(GArr

Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-27 Thread Hanjun Guo

On 2015年01月24日 17:21, Shannon Zhao wrote:

Introduce a preliminary framework in virt-acpi-build.c with the main
ACPI build functions. It exposes the generated ACPI contents to
guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.

The minimum required ACPI v5.1 tables for ARM are:
- RSDP: Initial table that points to XSDT
- XSDT: Points to all other tables (except FACS & DSDT)
- FADT: Generic information about the machine
- DSDT: Holds all information about system devices/peripherals
- FACS: Needs to be pointed from FADT


For ARM, GTDT and MADT are required also, or we can not init SMP,
GIC and Arch timer, you need to update the change log for this patch :)

Thanks
Hanjun




Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-27 Thread Igor Mammedov
On Tue, 27 Jan 2015 14:47:44 +0800
Shannon Zhao  wrote:

> On 2015/1/26 18:19, Igor Mammedov wrote:
> > On Sat, 24 Jan 2015 17:21:11 +0800
> > Shannon Zhao  wrote:
> > 
> >> Introduce a preliminary framework in virt-acpi-build.c with the main
> >> ACPI build functions. It exposes the generated ACPI contents to
> >> guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.
> >>
> >> The minimum required ACPI v5.1 tables for ARM are:
> >> - RSDP: Initial table that points to XSDT
> >> - XSDT: Points to all other tables (except FACS & DSDT)
> >> - FADT: Generic information about the machine
> >> - DSDT: Holds all information about system devices/peripherals
> >> - FACS: Needs to be pointed from FADT
> > 
> > most of table manipulation code (tables adding to blob/linking)
> > could/should be shared with x86,
> > could you generalize it instead of just copying, please.
> > 
> 
> Thanks for your suggestion and your great work to make ACPI table generation 
> simpler :-)
> 
> Apparently this code is similar with the x86 as their approach are same.
> But the detail of implementation is different at some degree.
> E.g, X86 use some static DSL files while this dynamically generate all thing.
I'm talking not about build_fooTable() functions but rather helpers, like:
acpi_data_push, acpi_add_table, acpi_build_*, huge chunk of acpi_build()
you also probably don't need ACPI_BUILD_TABLE_SIZE and other related macroes.

> 
> >>
> >> Signed-off-by: Shannon Zhao 
> >> ---
> >>  hw/arm/Makefile.objs |1 +
> >>  hw/arm/virt-acpi-build.c |  263 
> >> ++
> >>  include/hw/arm/virt-acpi-build.h |   71 ++
> >>  3 files changed, 335 insertions(+), 0 deletions(-)
> >>  create mode 100644 hw/arm/virt-acpi-build.c
> >>  create mode 100644 include/hw/arm/virt-acpi-build.h
> >>
> >> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
> >> index 6088e53..8daf825 100644
> >> --- a/hw/arm/Makefile.objs
> >> +++ b/hw/arm/Makefile.objs
> >> @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
> >>  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
> >>  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
> >>  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
> >> +obj-$(CONFIG_ACPI) += virt-acpi-build.o
> >>  
> >>  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
> >>  obj-$(CONFIG_DIGIC) += digic.o
> >> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> >> new file mode 100644
> >> index 000..4eed0a3
> >> --- /dev/null
> >> +++ b/hw/arm/virt-acpi-build.c
> >> @@ -0,0 +1,263 @@
> >> +/* Support for generating ACPI tables and passing them to Guests
> >> + *
> >> + * ARM virt ACPI generation
> >> + *
> >> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> >> + *
> >> + * Author: Shannon Zhao 
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify it
> >> + * under the terms and conditions of the GNU General Public License,
> >> + * version 2 or later, as published by the Free Software Foundation.
> >> + *
> >> + * This program is distributed in the hope 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 .
> >> + */
> >> +
> >> +#include "hw/arm/virt-acpi-build.h"
> >> +#include 
> >> +#include 
> >> +#include "qemu-common.h"
> >> +#include "qemu/bitmap.h"
> >> +#include "qemu/osdep.h"
> >> +#include "qemu/range.h"
> >> +#include "qemu/error-report.h"
> >> +#include "qom/cpu.h"
> >> +#include "target-arm/cpu.h"
> >> +#include "hw/acpi/acpi-defs.h"
> >> +#include "hw/acpi/acpi.h"
> >> +#include "hw/nvram/fw_cfg.h"
> >> +#include "hw/acpi/bios-linker-loader.h"
> >> +#include "hw/loader.h"
> >> +
> >> +#include "hw/acpi/acpi-build-utils.h"
> >> +
> >> +#include "qapi/qmp/qint.h"
> >> +#include "qom/qom-qobject.h"
> >> +#include "exec/ram_addr.h"
> >> +
> >> +
> >> +#define ACPI_BUILD_TABLE_SIZE 0x2
> >> +
> >> +/* Reserve RAM space for tables: add another order of magnitude. */
> >> +#define ACPI_BUILD_TABLE_MAX_SIZE 0x20
> >> +
> >> +/* #define DEBUG_ACPI_BUILD */
> >> +#ifdef DEBUG_ACPI_BUILD
> >> +#define ACPI_BUILD_DPRINTF(fmt, ...)\
> >> +do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0)
> >> +#else
> >> +#define ACPI_BUILD_DPRINTF(fmt, ...)
> >> +#endif
> >> +
> >> +#define ACPI_BUILD_APPNAME  "Bochs"
> >> +#define ACPI_BUILD_APPNAME6 "BOCHS "
> >> +
> >> +#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
> >> +#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
> >> +
> >> +static inline void *acpi_data_push(GArray *table_data, uint64_t size)
> >> +{
> >> +unsigned off = table_da

Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-26 Thread Shannon Zhao
On 2015/1/26 18:19, Igor Mammedov wrote:
> On Sat, 24 Jan 2015 17:21:11 +0800
> Shannon Zhao  wrote:
> 
>> Introduce a preliminary framework in virt-acpi-build.c with the main
>> ACPI build functions. It exposes the generated ACPI contents to
>> guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.
>>
>> The minimum required ACPI v5.1 tables for ARM are:
>> - RSDP: Initial table that points to XSDT
>> - XSDT: Points to all other tables (except FACS & DSDT)
>> - FADT: Generic information about the machine
>> - DSDT: Holds all information about system devices/peripherals
>> - FACS: Needs to be pointed from FADT
> 
> most of table manipulation code (tables adding to blob/linking)
> could/should be shared with x86,
> could you generalize it instead of just copying, please.
> 

Thanks for your suggestion and your great work to make ACPI table generation 
simpler :-)

Apparently this code is similar with the x86 as their approach are same.
But the detail of implementation is different at some degree.
E.g, X86 use some static DSL files while this dynamically generate all thing.

>>
>> Signed-off-by: Shannon Zhao 
>> ---
>>  hw/arm/Makefile.objs |1 +
>>  hw/arm/virt-acpi-build.c |  263 
>> ++
>>  include/hw/arm/virt-acpi-build.h |   71 ++
>>  3 files changed, 335 insertions(+), 0 deletions(-)
>>  create mode 100644 hw/arm/virt-acpi-build.c
>>  create mode 100644 include/hw/arm/virt-acpi-build.h
>>
>> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
>> index 6088e53..8daf825 100644
>> --- a/hw/arm/Makefile.objs
>> +++ b/hw/arm/Makefile.objs
>> @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
>>  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
>>  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
>>  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
>> +obj-$(CONFIG_ACPI) += virt-acpi-build.o
>>  
>>  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
>>  obj-$(CONFIG_DIGIC) += digic.o
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> new file mode 100644
>> index 000..4eed0a3
>> --- /dev/null
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -0,0 +1,263 @@
>> +/* Support for generating ACPI tables and passing them to Guests
>> + *
>> + * ARM virt ACPI generation
>> + *
>> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
>> + *
>> + * Author: Shannon Zhao 
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2 or later, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope 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 .
>> + */
>> +
>> +#include "hw/arm/virt-acpi-build.h"
>> +#include 
>> +#include 
>> +#include "qemu-common.h"
>> +#include "qemu/bitmap.h"
>> +#include "qemu/osdep.h"
>> +#include "qemu/range.h"
>> +#include "qemu/error-report.h"
>> +#include "qom/cpu.h"
>> +#include "target-arm/cpu.h"
>> +#include "hw/acpi/acpi-defs.h"
>> +#include "hw/acpi/acpi.h"
>> +#include "hw/nvram/fw_cfg.h"
>> +#include "hw/acpi/bios-linker-loader.h"
>> +#include "hw/loader.h"
>> +
>> +#include "hw/acpi/acpi-build-utils.h"
>> +
>> +#include "qapi/qmp/qint.h"
>> +#include "qom/qom-qobject.h"
>> +#include "exec/ram_addr.h"
>> +
>> +
>> +#define ACPI_BUILD_TABLE_SIZE 0x2
>> +
>> +/* Reserve RAM space for tables: add another order of magnitude. */
>> +#define ACPI_BUILD_TABLE_MAX_SIZE 0x20
>> +
>> +/* #define DEBUG_ACPI_BUILD */
>> +#ifdef DEBUG_ACPI_BUILD
>> +#define ACPI_BUILD_DPRINTF(fmt, ...)\
>> +do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0)
>> +#else
>> +#define ACPI_BUILD_DPRINTF(fmt, ...)
>> +#endif
>> +
>> +#define ACPI_BUILD_APPNAME  "Bochs"
>> +#define ACPI_BUILD_APPNAME6 "BOCHS "
>> +
>> +#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
>> +#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
>> +
>> +static inline void *acpi_data_push(GArray *table_data, uint64_t size)
>> +{
>> +unsigned off = table_data->len;
>> +g_array_set_size(table_data, off + size);
>> +return table_data->data + off;
>> +}
>> +
>> +static unsigned acpi_data_len(GArray *table)
>> +{
>> +#if GLIB_CHECK_VERSION(2, 22, 0)
>> +assert(g_array_get_element_size(table) == 1);
>> +#endif
>> +return table->len;
>> +}
>> +
>> +static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>> +{
>> +uint32_t offset = cpu_to_le32(table_data->len);
>> +g_array_append_val(table_offsets, offset);
>> +}
>> +
>> +/* RSDP */
>> +static G

Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-26 Thread Igor Mammedov
On Sat, 24 Jan 2015 17:21:11 +0800
Shannon Zhao  wrote:

> Introduce a preliminary framework in virt-acpi-build.c with the main
> ACPI build functions. It exposes the generated ACPI contents to
> guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.
> 
> The minimum required ACPI v5.1 tables for ARM are:
> - RSDP: Initial table that points to XSDT
> - XSDT: Points to all other tables (except FACS & DSDT)
> - FADT: Generic information about the machine
> - DSDT: Holds all information about system devices/peripherals
> - FACS: Needs to be pointed from FADT

most of table manipulation code (tables adding to blob/linking)
could/should be shared with x86,
could you generalize it instead of just copying, please.

> 
> Signed-off-by: Shannon Zhao 
> ---
>  hw/arm/Makefile.objs |1 +
>  hw/arm/virt-acpi-build.c |  263 
> ++
>  include/hw/arm/virt-acpi-build.h |   71 ++
>  3 files changed, 335 insertions(+), 0 deletions(-)
>  create mode 100644 hw/arm/virt-acpi-build.c
>  create mode 100644 include/hw/arm/virt-acpi-build.h
> 
> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
> index 6088e53..8daf825 100644
> --- a/hw/arm/Makefile.objs
> +++ b/hw/arm/Makefile.objs
> @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
>  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
>  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
>  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
> +obj-$(CONFIG_ACPI) += virt-acpi-build.o
>  
>  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
>  obj-$(CONFIG_DIGIC) += digic.o
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> new file mode 100644
> index 000..4eed0a3
> --- /dev/null
> +++ b/hw/arm/virt-acpi-build.c
> @@ -0,0 +1,263 @@
> +/* Support for generating ACPI tables and passing them to Guests
> + *
> + * ARM virt ACPI generation
> + *
> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> + *
> + * Author: Shannon Zhao 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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 .
> + */
> +
> +#include "hw/arm/virt-acpi-build.h"
> +#include 
> +#include 
> +#include "qemu-common.h"
> +#include "qemu/bitmap.h"
> +#include "qemu/osdep.h"
> +#include "qemu/range.h"
> +#include "qemu/error-report.h"
> +#include "qom/cpu.h"
> +#include "target-arm/cpu.h"
> +#include "hw/acpi/acpi-defs.h"
> +#include "hw/acpi/acpi.h"
> +#include "hw/nvram/fw_cfg.h"
> +#include "hw/acpi/bios-linker-loader.h"
> +#include "hw/loader.h"
> +
> +#include "hw/acpi/acpi-build-utils.h"
> +
> +#include "qapi/qmp/qint.h"
> +#include "qom/qom-qobject.h"
> +#include "exec/ram_addr.h"
> +
> +
> +#define ACPI_BUILD_TABLE_SIZE 0x2
> +
> +/* Reserve RAM space for tables: add another order of magnitude. */
> +#define ACPI_BUILD_TABLE_MAX_SIZE 0x20
> +
> +/* #define DEBUG_ACPI_BUILD */
> +#ifdef DEBUG_ACPI_BUILD
> +#define ACPI_BUILD_DPRINTF(fmt, ...)\
> +do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0)
> +#else
> +#define ACPI_BUILD_DPRINTF(fmt, ...)
> +#endif
> +
> +#define ACPI_BUILD_APPNAME  "Bochs"
> +#define ACPI_BUILD_APPNAME6 "BOCHS "
> +
> +#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
> +#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
> +
> +static inline void *acpi_data_push(GArray *table_data, uint64_t size)
> +{
> +unsigned off = table_data->len;
> +g_array_set_size(table_data, off + size);
> +return table_data->data + off;
> +}
> +
> +static unsigned acpi_data_len(GArray *table)
> +{
> +#if GLIB_CHECK_VERSION(2, 22, 0)
> +assert(g_array_get_element_size(table) == 1);
> +#endif
> +return table->len;
> +}
> +
> +static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
> +{
> +uint32_t offset = cpu_to_le32(table_data->len);
> +g_array_append_val(table_offsets, offset);
> +}
> +
> +/* RSDP */
> +static GArray *
> +build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
> +{
> +return rsdp_table;
> +}
> +
> +/* XSDT */
> +static void
> +build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
> +{
> +}
> +
> +/* MADT */
> +static void
> +build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* GTDT */
> +static void
> +build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* FADT */
> +

Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-25 Thread Shannon Zhao
On 2015/1/25 0:22, Michael S. Tsirkin wrote:
> On Sat, Jan 24, 2015 at 05:21:11PM +0800, Shannon Zhao wrote:
>> > Introduce a preliminary framework in virt-acpi-build.c with the main
>> > ACPI build functions. It exposes the generated ACPI contents to
>> > guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.
>> > 
>> > The minimum required ACPI v5.1 tables for ARM are:
>> > - RSDP: Initial table that points to XSDT
>> > - XSDT: Points to all other tables (except FACS & DSDT)
>> > - FADT: Generic information about the machine
>> > - DSDT: Holds all information about system devices/peripherals
>> > - FACS: Needs to be pointed from FADT
>> > 
>> > Signed-off-by: Shannon Zhao 
>> > ---
>> >  hw/arm/Makefile.objs |1 +
>> >  hw/arm/virt-acpi-build.c |  263 
>> > ++
>> >  include/hw/arm/virt-acpi-build.h |   71 ++
>> >  3 files changed, 335 insertions(+), 0 deletions(-)
>> >  create mode 100644 hw/arm/virt-acpi-build.c
>> >  create mode 100644 include/hw/arm/virt-acpi-build.h
>> > 
>> > diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
>> > index 6088e53..8daf825 100644
>> > --- a/hw/arm/Makefile.objs
>> > +++ b/hw/arm/Makefile.objs
>> > @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
>> >  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
>> >  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
>> >  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
>> > +obj-$(CONFIG_ACPI) += virt-acpi-build.o
>> >  
>> >  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
>> >  obj-$(CONFIG_DIGIC) += digic.o
>> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> > new file mode 100644
>> > index 000..4eed0a3
>> > --- /dev/null
>> > +++ b/hw/arm/virt-acpi-build.c
>> > @@ -0,0 +1,263 @@
>> > +/* Support for generating ACPI tables and passing them to Guests
>> > + *
>> > + * ARM virt ACPI generation
>> > + *
>> > + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
>> > + *
>> > + * Author: Shannon Zhao 
> Since you copied code over, you should append copyright and author
> information from the original file to the new one.
> 

Ok, will fix this :-)

Thanks,
Shannon




Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables

2015-01-24 Thread Michael S. Tsirkin
On Sat, Jan 24, 2015 at 05:21:11PM +0800, Shannon Zhao wrote:
> Introduce a preliminary framework in virt-acpi-build.c with the main
> ACPI build functions. It exposes the generated ACPI contents to
> guest over fw_cfg. Some codes borrowed from hw/i386/acpi-build.c.
> 
> The minimum required ACPI v5.1 tables for ARM are:
> - RSDP: Initial table that points to XSDT
> - XSDT: Points to all other tables (except FACS & DSDT)
> - FADT: Generic information about the machine
> - DSDT: Holds all information about system devices/peripherals
> - FACS: Needs to be pointed from FADT
> 
> Signed-off-by: Shannon Zhao 
> ---
>  hw/arm/Makefile.objs |1 +
>  hw/arm/virt-acpi-build.c |  263 
> ++
>  include/hw/arm/virt-acpi-build.h |   71 ++
>  3 files changed, 335 insertions(+), 0 deletions(-)
>  create mode 100644 hw/arm/virt-acpi-build.c
>  create mode 100644 include/hw/arm/virt-acpi-build.h
> 
> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
> index 6088e53..8daf825 100644
> --- a/hw/arm/Makefile.objs
> +++ b/hw/arm/Makefile.objs
> @@ -3,6 +3,7 @@ obj-$(CONFIG_DIGIC) += digic_boards.o
>  obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
>  obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o
>  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
> +obj-$(CONFIG_ACPI) += virt-acpi-build.o
>  
>  obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
>  obj-$(CONFIG_DIGIC) += digic.o
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> new file mode 100644
> index 000..4eed0a3
> --- /dev/null
> +++ b/hw/arm/virt-acpi-build.c
> @@ -0,0 +1,263 @@
> +/* Support for generating ACPI tables and passing them to Guests
> + *
> + * ARM virt ACPI generation
> + *
> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> + *
> + * Author: Shannon Zhao 

Since you copied code over, you should append copyright and author
information from the original file to the new one.

> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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 .
> + */
> +
> +#include "hw/arm/virt-acpi-build.h"
> +#include 
> +#include 
> +#include "qemu-common.h"
> +#include "qemu/bitmap.h"
> +#include "qemu/osdep.h"
> +#include "qemu/range.h"
> +#include "qemu/error-report.h"
> +#include "qom/cpu.h"
> +#include "target-arm/cpu.h"
> +#include "hw/acpi/acpi-defs.h"
> +#include "hw/acpi/acpi.h"
> +#include "hw/nvram/fw_cfg.h"
> +#include "hw/acpi/bios-linker-loader.h"
> +#include "hw/loader.h"
> +
> +#include "hw/acpi/acpi-build-utils.h"
> +
> +#include "qapi/qmp/qint.h"
> +#include "qom/qom-qobject.h"
> +#include "exec/ram_addr.h"
> +
> +
> +#define ACPI_BUILD_TABLE_SIZE 0x2
> +
> +/* Reserve RAM space for tables: add another order of magnitude. */
> +#define ACPI_BUILD_TABLE_MAX_SIZE 0x20
> +
> +/* #define DEBUG_ACPI_BUILD */
> +#ifdef DEBUG_ACPI_BUILD
> +#define ACPI_BUILD_DPRINTF(fmt, ...)\
> +do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0)
> +#else
> +#define ACPI_BUILD_DPRINTF(fmt, ...)
> +#endif
> +
> +#define ACPI_BUILD_APPNAME  "Bochs"
> +#define ACPI_BUILD_APPNAME6 "BOCHS "
> +
> +#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
> +#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
> +
> +static inline void *acpi_data_push(GArray *table_data, uint64_t size)
> +{
> +unsigned off = table_data->len;
> +g_array_set_size(table_data, off + size);
> +return table_data->data + off;
> +}
> +
> +static unsigned acpi_data_len(GArray *table)
> +{
> +#if GLIB_CHECK_VERSION(2, 22, 0)
> +assert(g_array_get_element_size(table) == 1);
> +#endif
> +return table->len;
> +}
> +
> +static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
> +{
> +uint32_t offset = cpu_to_le32(table_data->len);
> +g_array_append_val(table_offsets, offset);
> +}
> +
> +/* RSDP */
> +static GArray *
> +build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
> +{
> +return rsdp_table;
> +}
> +
> +/* XSDT */
> +static void
> +build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
> +{
> +}
> +
> +/* MADT */
> +static void
> +build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* GTDT */
> +static void
> +build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* FADT */
> +static void
> +build_fadt(GArra