All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM
@ 2015-01-24  9:21 Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 01/11] hw/i386: Move ACPI header definitions in an arch-independent location Shannon Zhao
                   ` (11 more replies)
  0 siblings, 12 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

This patch series generate seven ACPI v5.1 tables for machine virt on ARM.
The set of generated tables are:
- RSDP
- XSDT
- MADT
- GTDT
- FADT
- FACS
- DSDT

These tables are created dynamically using the function of acpi-build-utils.c,
taking into account the needed information passed from the virt machine model.
When the generation is finalized, it use fw_cfg to expose the tables to guest.

This patchset is based on Igor Mammedov's branch which can be found at below
git tree:
 https://github.com/imammedo/qemu/commits/ASL_API_v2

And this patchset refers to Alexander Spyridakis's patches which are sent to
qemu-devel mailing list before.
 http://lists.gnu.org/archive/html/qemu-devel/2014-10/msg03987.html

As UEFI (ArmVirtualizationQemu) doesn't support downloading ACPI tables over
fw_cfg, I just do compile test and start a guest with UEFI. But I contacted
Laszlo Ersek before, he says that if qemu can expose the generated ACPI
tables over fw_cfg, he can quickly add support in UEFI. So just send this
out and make it go forward.

Todo:
1) add GPIO controller in virt and expose it through ACPI
2) add cpu hotplug support

Any comments are welcome.

Thanks,
Shannon

Shannon Zhao (11):
  hw/i386: Move ACPI header definitions in an arch-independent location
  hw/arm/virt-acpi-build: Basic framwork for building ACPI tables
  hw/arm/virt-acpi-build: Generate RSDP table
  hw/arm/virt-acpi-build: Generate XSDT table and add a build_header
    function
  hw/arm/virt-acpi-build: Generate MADT table
  hw/arm/virt-acpi-build: Generate GTDT table
  hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers
  hw/arm/virt-acpi-build: Generate FACS table and update ACPI headers
  hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and
    acpi_extended_irq()
  hw/arm/virt-acpi-build: Generation of DSDT table for virt devices
  hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables

 default-configs/arm-softmmu.mak      |    1 +
 default-configs/i386-softmmu.mak     |    3 +
 default-configs/mips-softmmu.mak     |    3 +
 default-configs/mips64-softmmu.mak   |    3 +
 default-configs/mips64el-softmmu.mak |    3 +
 default-configs/mipsel-softmmu.mak   |    3 +
 default-configs/x86_64-softmmu.mak   |    3 +
 hw/acpi/Makefile.objs                |    5 +-
 hw/acpi/acpi-build-utils.c           |   42 +++
 hw/arm/Makefile.objs                 |    1 +
 hw/arm/virt-acpi-build.c             |  520 ++++++++++++++++++++++++++++++++++
 hw/arm/virt.c                        |   59 ++++-
 hw/i2c/Makefile.objs                 |    2 +-
 hw/i386/acpi-build.c                 |    2 +-
 hw/i386/acpi-defs.h                  |  368 ------------------------
 include/hw/acpi/acpi-build-utils.h   |    2 +
 include/hw/acpi/acpi-defs.h          |  503 ++++++++++++++++++++++++++++++++
 include/hw/arm/virt-acpi-build.h     |   71 +++++
 tests/bios-tables-test.c             |    2 +-
 19 files changed, 1219 insertions(+), 377 deletions(-)
 create mode 100644 hw/arm/virt-acpi-build.c
 delete mode 100644 hw/i386/acpi-defs.h
 create mode 100644 include/hw/acpi/acpi-defs.h
 create mode 100644 include/hw/arm/virt-acpi-build.h

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 01/11] hw/i386: Move ACPI header definitions in an arch-independent location
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

The ACPI related header file acpi-defs.h, includes definitions that
apply on other architectures as well. Move it in `include/hw/acpi/`
to sanely include it from other architectures.

Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/i386/acpi-build.c        |    2 +-
 hw/i386/acpi-defs.h         |  368 -------------------------------------------
 include/hw/acpi/acpi-defs.h |  368 +++++++++++++++++++++++++++++++++++++++++++
 tests/bios-tables-test.c    |    2 +-
 4 files changed, 370 insertions(+), 370 deletions(-)
 delete mode 100644 hw/i386/acpi-defs.h
 create mode 100644 include/hw/acpi/acpi-defs.h

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f66da5d..f22f6d6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -33,7 +33,7 @@
 #include "hw/i386/pc.h"
 #include "target-i386/cpu.h"
 #include "hw/timer/hpet.h"
-#include "hw/i386/acpi-defs.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"
diff --git a/hw/i386/acpi-defs.h b/hw/i386/acpi-defs.h
deleted file mode 100644
index c4468f8..0000000
--- a/hw/i386/acpi-defs.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * 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/>.
- */
-#ifndef QEMU_ACPI_DEFS_H
-#define QEMU_ACPI_DEFS_H
-
-enum {
-    ACPI_FADT_F_WBINVD,
-    ACPI_FADT_F_WBINVD_FLUSH,
-    ACPI_FADT_F_PROC_C1,
-    ACPI_FADT_F_P_LVL2_UP,
-    ACPI_FADT_F_PWR_BUTTON,
-    ACPI_FADT_F_SLP_BUTTON,
-    ACPI_FADT_F_FIX_RTC,
-    ACPI_FADT_F_RTC_S4,
-    ACPI_FADT_F_TMR_VAL_EXT,
-    ACPI_FADT_F_DCK_CAP,
-    ACPI_FADT_F_RESET_REG_SUP,
-    ACPI_FADT_F_SEALED_CASE,
-    ACPI_FADT_F_HEADLESS,
-    ACPI_FADT_F_CPU_SW_SLP,
-    ACPI_FADT_F_PCI_EXP_WAK,
-    ACPI_FADT_F_USE_PLATFORM_CLOCK,
-    ACPI_FADT_F_S4_RTC_STS_VALID,
-    ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE,
-    ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL,
-    ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE,
-    ACPI_FADT_F_HW_REDUCED_ACPI,
-    ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE,
-};
-
-/*
- * ACPI 2.0 Generic Address Space definition.
- */
-struct Acpi20GenericAddress {
-    uint8_t  address_space_id;
-    uint8_t  register_bit_width;
-    uint8_t  register_bit_offset;
-    uint8_t  reserved;
-    uint64_t address;
-} QEMU_PACKED;
-typedef struct Acpi20GenericAddress Acpi20GenericAddress;
-
-struct AcpiRsdpDescriptor {        /* Root System Descriptor Pointer */
-    uint64_t signature;              /* ACPI signature, contains "RSD PTR " */
-    uint8_t  checksum;               /* To make sum of struct == 0 */
-    uint8_t  oem_id [6];             /* OEM identification */
-    uint8_t  revision;               /* Must be 0 for 1.0, 2 for 2.0 */
-    uint32_t rsdt_physical_address;  /* 32-bit physical address of RSDT */
-    uint32_t length;                 /* XSDT Length in bytes including hdr */
-    uint64_t xsdt_physical_address;  /* 64-bit physical address of XSDT */
-    uint8_t  extended_checksum;      /* Checksum of entire table */
-    uint8_t  reserved [3];           /* Reserved field must be 0 */
-} QEMU_PACKED;
-typedef struct AcpiRsdpDescriptor AcpiRsdpDescriptor;
-
-/* Table structure from Linux kernel (the ACPI tables are under the
-   BSD license) */
-
-
-#define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
-    uint32_t signature;          /* ACPI signature (4 ASCII characters) */ \
-    uint32_t length;                 /* Length of table, in bytes, including header */ \
-    uint8_t  revision;               /* ACPI Specification minor version # */ \
-    uint8_t  checksum;               /* To make sum of entire table == 0 */ \
-    uint8_t  oem_id [6];             /* OEM identification */ \
-    uint8_t  oem_table_id [8];       /* OEM table identification */ \
-    uint32_t oem_revision;           /* OEM revision number */ \
-    uint8_t  asl_compiler_id [4];    /* ASL compiler vendor ID */ \
-    uint32_t asl_compiler_revision;  /* ASL compiler revision number */
-
-
-struct AcpiTableHeader         /* ACPI common table header */
-{
-    ACPI_TABLE_HEADER_DEF
-} QEMU_PACKED;
-typedef struct AcpiTableHeader AcpiTableHeader;
-
-/*
- * ACPI 1.0 Fixed ACPI Description Table (FADT)
- */
-struct AcpiFadtDescriptorRev1
-{
-    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
-    uint32_t firmware_ctrl;          /* Physical address of FACS */
-    uint32_t dsdt;                   /* Physical address of DSDT */
-    uint8_t  model;                  /* System Interrupt Model */
-    uint8_t  reserved1;              /* Reserved */
-    uint16_t sci_int;                /* System vector of SCI interrupt */
-    uint32_t smi_cmd;                /* Port address of SMI command port */
-    uint8_t  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
-    uint8_t  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
-    uint8_t  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
-    uint8_t  reserved2;              /* Reserved - must be zero */
-    uint32_t pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
-    uint32_t pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
-    uint32_t pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
-    uint32_t pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
-    uint32_t pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
-    uint32_t pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
-    uint32_t gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
-    uint32_t gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
-    uint8_t  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
-    uint8_t  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
-    uint8_t  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
-    uint8_t  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */
-    uint8_t  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
-    uint8_t  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
-    uint8_t  gpe1_base;              /* Offset in gpe model where gpe1 events start */
-    uint8_t  reserved3;              /* Reserved */
-    uint16_t plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
-    uint16_t plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
-    uint16_t flush_size;             /* Size of area read to flush caches */
-    uint16_t flush_stride;           /* Stride used in flushing caches */
-    uint8_t  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
-    uint8_t  duty_width;             /* Bit width of duty cycle field in p_cnt reg */
-    uint8_t  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
-    uint8_t  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
-    uint8_t  century;                /* Index to century in RTC CMOS RAM */
-    uint8_t  reserved4;              /* Reserved */
-    uint8_t  reserved4a;             /* Reserved */
-    uint8_t  reserved4b;             /* Reserved */
-    uint32_t flags;
-} QEMU_PACKED;
-typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
-
-/*
- * ACPI 1.0 Root System Description Table (RSDT)
- */
-struct AcpiRsdtDescriptorRev1
-{
-    ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
-    uint32_t table_offset_entry[0];  /* Array of pointers to other */
-    /* ACPI tables */
-} QEMU_PACKED;
-typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1;
-
-/*
- * ACPI 1.0 Firmware ACPI Control Structure (FACS)
- */
-struct AcpiFacsDescriptorRev1
-{
-    uint32_t signature;           /* ACPI Signature */
-    uint32_t length;                 /* Length of structure, in bytes */
-    uint32_t hardware_signature;     /* Hardware configuration signature */
-    uint32_t firmware_waking_vector; /* ACPI OS waking vector */
-    uint32_t global_lock;            /* Global Lock */
-    uint32_t flags;
-    uint8_t  resverved3 [40];        /* Reserved - must be zero */
-} QEMU_PACKED;
-typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
-
-/*
- * Differentiated System Description Table (DSDT)
- */
-
-/*
- * MADT values and structures
- */
-
-/* Values for MADT PCATCompat */
-
-#define ACPI_DUAL_PIC                0
-#define ACPI_MULTIPLE_APIC           1
-
-/* Master MADT */
-
-struct AcpiMultipleApicTable
-{
-    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
-    uint32_t local_apic_address;     /* Physical address of local APIC */
-    uint32_t flags;
-} QEMU_PACKED;
-typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;
-
-/* Values for Type in APIC sub-headers */
-
-#define ACPI_APIC_PROCESSOR          0
-#define ACPI_APIC_IO                 1
-#define ACPI_APIC_XRUPT_OVERRIDE     2
-#define ACPI_APIC_NMI                3
-#define ACPI_APIC_LOCAL_NMI          4
-#define ACPI_APIC_ADDRESS_OVERRIDE   5
-#define ACPI_APIC_IO_SAPIC           6
-#define ACPI_APIC_LOCAL_SAPIC        7
-#define ACPI_APIC_XRUPT_SOURCE       8
-#define ACPI_APIC_RESERVED           9           /* 9 and greater are reserved */
-
-/*
- * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
- */
-#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
-    uint8_t  type;                               \
-    uint8_t  length;
-
-/* Sub-structures for MADT */
-
-struct AcpiMadtProcessorApic
-{
-    ACPI_SUB_HEADER_DEF
-    uint8_t  processor_id;           /* ACPI processor id */
-    uint8_t  local_apic_id;          /* Processor's local APIC id */
-    uint32_t flags;
-} QEMU_PACKED;
-typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic;
-
-struct AcpiMadtIoApic
-{
-    ACPI_SUB_HEADER_DEF
-    uint8_t  io_apic_id;             /* I/O APIC ID */
-    uint8_t  reserved;               /* Reserved - must be zero */
-    uint32_t address;                /* APIC physical address */
-    uint32_t interrupt;              /* Global system interrupt where INTI
-                                 * lines start */
-} QEMU_PACKED;
-typedef struct AcpiMadtIoApic AcpiMadtIoApic;
-
-struct AcpiMadtIntsrcovr {
-    ACPI_SUB_HEADER_DEF
-    uint8_t  bus;
-    uint8_t  source;
-    uint32_t gsi;
-    uint16_t flags;
-} QEMU_PACKED;
-typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr;
-
-struct AcpiMadtLocalNmi {
-    ACPI_SUB_HEADER_DEF
-    uint8_t  processor_id;           /* ACPI processor id */
-    uint16_t flags;                  /* MPS INTI flags */
-    uint8_t  lint;                   /* Local APIC LINT# */
-} QEMU_PACKED;
-typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi;
-
-/*
- * HPET Description Table
- */
-struct Acpi20Hpet {
-    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
-    uint32_t           timer_block_id;
-    Acpi20GenericAddress addr;
-    uint8_t            hpet_number;
-    uint16_t           min_tick;
-    uint8_t            page_protect;
-} QEMU_PACKED;
-typedef struct Acpi20Hpet Acpi20Hpet;
-
-/*
- * SRAT (NUMA topology description) table
- */
-
-struct AcpiSystemResourceAffinityTable
-{
-    ACPI_TABLE_HEADER_DEF
-    uint32_t    reserved1;
-    uint32_t    reserved2[2];
-} QEMU_PACKED;
-typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable;
-
-#define ACPI_SRAT_PROCESSOR          0
-#define ACPI_SRAT_MEMORY             1
-
-struct AcpiSratProcessorAffinity
-{
-    ACPI_SUB_HEADER_DEF
-    uint8_t     proximity_lo;
-    uint8_t     local_apic_id;
-    uint32_t    flags;
-    uint8_t     local_sapic_eid;
-    uint8_t     proximity_hi[3];
-    uint32_t    reserved;
-} QEMU_PACKED;
-typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity;
-
-struct AcpiSratMemoryAffinity
-{
-    ACPI_SUB_HEADER_DEF
-    uint8_t     proximity[4];
-    uint16_t    reserved1;
-    uint64_t    base_addr;
-    uint64_t    range_length;
-    uint32_t    reserved2;
-    uint32_t    flags;
-    uint32_t    reserved3[2];
-} QEMU_PACKED;
-typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity;
-
-/* PCI fw r3.0 MCFG table. */
-/* Subtable */
-struct AcpiMcfgAllocation {
-    uint64_t address;                /* Base address, processor-relative */
-    uint16_t pci_segment;            /* PCI segment group number */
-    uint8_t start_bus_number;       /* Starting PCI Bus number */
-    uint8_t end_bus_number;         /* Final PCI Bus number */
-    uint32_t reserved;
-} QEMU_PACKED;
-typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
-
-struct AcpiTableMcfg {
-    ACPI_TABLE_HEADER_DEF;
-    uint8_t reserved[8];
-    AcpiMcfgAllocation allocation[0];
-} QEMU_PACKED;
-typedef struct AcpiTableMcfg AcpiTableMcfg;
-
-/*
- * TCPA Description Table
- */
-struct Acpi20Tcpa {
-    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
-    uint16_t platform_class;
-    uint32_t log_area_minimum_length;
-    uint64_t log_area_start_address;
-} QEMU_PACKED;
-typedef struct Acpi20Tcpa Acpi20Tcpa;
-
-/* DMAR - DMA Remapping table r2.2 */
-struct AcpiTableDmar {
-    ACPI_TABLE_HEADER_DEF
-    uint8_t host_address_width; /* Maximum DMA physical addressability */
-    uint8_t flags;
-    uint8_t reserved[10];
-} QEMU_PACKED;
-typedef struct AcpiTableDmar AcpiTableDmar;
-
-/* Masks for Flags field above */
-#define ACPI_DMAR_INTR_REMAP        1
-#define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
-
-/* Values for sub-structure type for DMAR */
-enum {
-    ACPI_DMAR_TYPE_HARDWARE_UNIT = 0,       /* DRHD */
-    ACPI_DMAR_TYPE_RESERVED_MEMORY = 1,     /* RMRR */
-    ACPI_DMAR_TYPE_ATSR = 2,                /* ATSR */
-    ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,   /* RHSR */
-    ACPI_DMAR_TYPE_ANDD = 4,                /* ANDD */
-    ACPI_DMAR_TYPE_RESERVED = 5             /* Reserved for furture use */
-};
-
-/*
- * Sub-structures for DMAR
- */
-/* Type 0: Hardware Unit Definition */
-struct AcpiDmarHardwareUnit {
-    uint16_t type;
-    uint16_t length;
-    uint8_t flags;
-    uint8_t reserved;
-    uint16_t pci_segment;   /* The PCI Segment associated with this unit */
-    uint64_t address;   /* Base address of remapping hardware register-set */
-} QEMU_PACKED;
-typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit;
-
-/* Masks for Flags field above */
-#define ACPI_DMAR_INCLUDE_PCI_ALL   1
-
-#endif
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
new file mode 100644
index 0000000..c4468f8
--- /dev/null
+++ b/include/hw/acpi/acpi-defs.h
@@ -0,0 +1,368 @@
+/*
+ * 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/>.
+ */
+#ifndef QEMU_ACPI_DEFS_H
+#define QEMU_ACPI_DEFS_H
+
+enum {
+    ACPI_FADT_F_WBINVD,
+    ACPI_FADT_F_WBINVD_FLUSH,
+    ACPI_FADT_F_PROC_C1,
+    ACPI_FADT_F_P_LVL2_UP,
+    ACPI_FADT_F_PWR_BUTTON,
+    ACPI_FADT_F_SLP_BUTTON,
+    ACPI_FADT_F_FIX_RTC,
+    ACPI_FADT_F_RTC_S4,
+    ACPI_FADT_F_TMR_VAL_EXT,
+    ACPI_FADT_F_DCK_CAP,
+    ACPI_FADT_F_RESET_REG_SUP,
+    ACPI_FADT_F_SEALED_CASE,
+    ACPI_FADT_F_HEADLESS,
+    ACPI_FADT_F_CPU_SW_SLP,
+    ACPI_FADT_F_PCI_EXP_WAK,
+    ACPI_FADT_F_USE_PLATFORM_CLOCK,
+    ACPI_FADT_F_S4_RTC_STS_VALID,
+    ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE,
+    ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL,
+    ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE,
+    ACPI_FADT_F_HW_REDUCED_ACPI,
+    ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE,
+};
+
+/*
+ * ACPI 2.0 Generic Address Space definition.
+ */
+struct Acpi20GenericAddress {
+    uint8_t  address_space_id;
+    uint8_t  register_bit_width;
+    uint8_t  register_bit_offset;
+    uint8_t  reserved;
+    uint64_t address;
+} QEMU_PACKED;
+typedef struct Acpi20GenericAddress Acpi20GenericAddress;
+
+struct AcpiRsdpDescriptor {        /* Root System Descriptor Pointer */
+    uint64_t signature;              /* ACPI signature, contains "RSD PTR " */
+    uint8_t  checksum;               /* To make sum of struct == 0 */
+    uint8_t  oem_id [6];             /* OEM identification */
+    uint8_t  revision;               /* Must be 0 for 1.0, 2 for 2.0 */
+    uint32_t rsdt_physical_address;  /* 32-bit physical address of RSDT */
+    uint32_t length;                 /* XSDT Length in bytes including hdr */
+    uint64_t xsdt_physical_address;  /* 64-bit physical address of XSDT */
+    uint8_t  extended_checksum;      /* Checksum of entire table */
+    uint8_t  reserved [3];           /* Reserved field must be 0 */
+} QEMU_PACKED;
+typedef struct AcpiRsdpDescriptor AcpiRsdpDescriptor;
+
+/* Table structure from Linux kernel (the ACPI tables are under the
+   BSD license) */
+
+
+#define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
+    uint32_t signature;          /* ACPI signature (4 ASCII characters) */ \
+    uint32_t length;                 /* Length of table, in bytes, including header */ \
+    uint8_t  revision;               /* ACPI Specification minor version # */ \
+    uint8_t  checksum;               /* To make sum of entire table == 0 */ \
+    uint8_t  oem_id [6];             /* OEM identification */ \
+    uint8_t  oem_table_id [8];       /* OEM table identification */ \
+    uint32_t oem_revision;           /* OEM revision number */ \
+    uint8_t  asl_compiler_id [4];    /* ASL compiler vendor ID */ \
+    uint32_t asl_compiler_revision;  /* ASL compiler revision number */
+
+
+struct AcpiTableHeader         /* ACPI common table header */
+{
+    ACPI_TABLE_HEADER_DEF
+} QEMU_PACKED;
+typedef struct AcpiTableHeader AcpiTableHeader;
+
+/*
+ * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ */
+struct AcpiFadtDescriptorRev1
+{
+    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
+    uint32_t firmware_ctrl;          /* Physical address of FACS */
+    uint32_t dsdt;                   /* Physical address of DSDT */
+    uint8_t  model;                  /* System Interrupt Model */
+    uint8_t  reserved1;              /* Reserved */
+    uint16_t sci_int;                /* System vector of SCI interrupt */
+    uint32_t smi_cmd;                /* Port address of SMI command port */
+    uint8_t  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
+    uint8_t  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
+    uint8_t  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
+    uint8_t  reserved2;              /* Reserved - must be zero */
+    uint32_t pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
+    uint32_t pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
+    uint32_t pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
+    uint32_t pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
+    uint32_t pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
+    uint32_t pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
+    uint32_t gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
+    uint32_t gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
+    uint8_t  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
+    uint8_t  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
+    uint8_t  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
+    uint8_t  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */
+    uint8_t  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
+    uint8_t  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
+    uint8_t  gpe1_base;              /* Offset in gpe model where gpe1 events start */
+    uint8_t  reserved3;              /* Reserved */
+    uint16_t plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
+    uint16_t plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
+    uint16_t flush_size;             /* Size of area read to flush caches */
+    uint16_t flush_stride;           /* Stride used in flushing caches */
+    uint8_t  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
+    uint8_t  duty_width;             /* Bit width of duty cycle field in p_cnt reg */
+    uint8_t  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
+    uint8_t  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
+    uint8_t  century;                /* Index to century in RTC CMOS RAM */
+    uint8_t  reserved4;              /* Reserved */
+    uint8_t  reserved4a;             /* Reserved */
+    uint8_t  reserved4b;             /* Reserved */
+    uint32_t flags;
+} QEMU_PACKED;
+typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
+
+/*
+ * ACPI 1.0 Root System Description Table (RSDT)
+ */
+struct AcpiRsdtDescriptorRev1
+{
+    ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
+    uint32_t table_offset_entry[0];  /* Array of pointers to other */
+    /* ACPI tables */
+} QEMU_PACKED;
+typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1;
+
+/*
+ * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ */
+struct AcpiFacsDescriptorRev1
+{
+    uint32_t signature;           /* ACPI Signature */
+    uint32_t length;                 /* Length of structure, in bytes */
+    uint32_t hardware_signature;     /* Hardware configuration signature */
+    uint32_t firmware_waking_vector; /* ACPI OS waking vector */
+    uint32_t global_lock;            /* Global Lock */
+    uint32_t flags;
+    uint8_t  resverved3 [40];        /* Reserved - must be zero */
+} QEMU_PACKED;
+typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
+
+/*
+ * Differentiated System Description Table (DSDT)
+ */
+
+/*
+ * MADT values and structures
+ */
+
+/* Values for MADT PCATCompat */
+
+#define ACPI_DUAL_PIC                0
+#define ACPI_MULTIPLE_APIC           1
+
+/* Master MADT */
+
+struct AcpiMultipleApicTable
+{
+    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
+    uint32_t local_apic_address;     /* Physical address of local APIC */
+    uint32_t flags;
+} QEMU_PACKED;
+typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;
+
+/* Values for Type in APIC sub-headers */
+
+#define ACPI_APIC_PROCESSOR          0
+#define ACPI_APIC_IO                 1
+#define ACPI_APIC_XRUPT_OVERRIDE     2
+#define ACPI_APIC_NMI                3
+#define ACPI_APIC_LOCAL_NMI          4
+#define ACPI_APIC_ADDRESS_OVERRIDE   5
+#define ACPI_APIC_IO_SAPIC           6
+#define ACPI_APIC_LOCAL_SAPIC        7
+#define ACPI_APIC_XRUPT_SOURCE       8
+#define ACPI_APIC_RESERVED           9           /* 9 and greater are reserved */
+
+/*
+ * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
+ */
+#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
+    uint8_t  type;                               \
+    uint8_t  length;
+
+/* Sub-structures for MADT */
+
+struct AcpiMadtProcessorApic
+{
+    ACPI_SUB_HEADER_DEF
+    uint8_t  processor_id;           /* ACPI processor id */
+    uint8_t  local_apic_id;          /* Processor's local APIC id */
+    uint32_t flags;
+} QEMU_PACKED;
+typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic;
+
+struct AcpiMadtIoApic
+{
+    ACPI_SUB_HEADER_DEF
+    uint8_t  io_apic_id;             /* I/O APIC ID */
+    uint8_t  reserved;               /* Reserved - must be zero */
+    uint32_t address;                /* APIC physical address */
+    uint32_t interrupt;              /* Global system interrupt where INTI
+                                 * lines start */
+} QEMU_PACKED;
+typedef struct AcpiMadtIoApic AcpiMadtIoApic;
+
+struct AcpiMadtIntsrcovr {
+    ACPI_SUB_HEADER_DEF
+    uint8_t  bus;
+    uint8_t  source;
+    uint32_t gsi;
+    uint16_t flags;
+} QEMU_PACKED;
+typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr;
+
+struct AcpiMadtLocalNmi {
+    ACPI_SUB_HEADER_DEF
+    uint8_t  processor_id;           /* ACPI processor id */
+    uint16_t flags;                  /* MPS INTI flags */
+    uint8_t  lint;                   /* Local APIC LINT# */
+} QEMU_PACKED;
+typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi;
+
+/*
+ * HPET Description Table
+ */
+struct Acpi20Hpet {
+    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
+    uint32_t           timer_block_id;
+    Acpi20GenericAddress addr;
+    uint8_t            hpet_number;
+    uint16_t           min_tick;
+    uint8_t            page_protect;
+} QEMU_PACKED;
+typedef struct Acpi20Hpet Acpi20Hpet;
+
+/*
+ * SRAT (NUMA topology description) table
+ */
+
+struct AcpiSystemResourceAffinityTable
+{
+    ACPI_TABLE_HEADER_DEF
+    uint32_t    reserved1;
+    uint32_t    reserved2[2];
+} QEMU_PACKED;
+typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable;
+
+#define ACPI_SRAT_PROCESSOR          0
+#define ACPI_SRAT_MEMORY             1
+
+struct AcpiSratProcessorAffinity
+{
+    ACPI_SUB_HEADER_DEF
+    uint8_t     proximity_lo;
+    uint8_t     local_apic_id;
+    uint32_t    flags;
+    uint8_t     local_sapic_eid;
+    uint8_t     proximity_hi[3];
+    uint32_t    reserved;
+} QEMU_PACKED;
+typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity;
+
+struct AcpiSratMemoryAffinity
+{
+    ACPI_SUB_HEADER_DEF
+    uint8_t     proximity[4];
+    uint16_t    reserved1;
+    uint64_t    base_addr;
+    uint64_t    range_length;
+    uint32_t    reserved2;
+    uint32_t    flags;
+    uint32_t    reserved3[2];
+} QEMU_PACKED;
+typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity;
+
+/* PCI fw r3.0 MCFG table. */
+/* Subtable */
+struct AcpiMcfgAllocation {
+    uint64_t address;                /* Base address, processor-relative */
+    uint16_t pci_segment;            /* PCI segment group number */
+    uint8_t start_bus_number;       /* Starting PCI Bus number */
+    uint8_t end_bus_number;         /* Final PCI Bus number */
+    uint32_t reserved;
+} QEMU_PACKED;
+typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
+
+struct AcpiTableMcfg {
+    ACPI_TABLE_HEADER_DEF;
+    uint8_t reserved[8];
+    AcpiMcfgAllocation allocation[0];
+} QEMU_PACKED;
+typedef struct AcpiTableMcfg AcpiTableMcfg;
+
+/*
+ * TCPA Description Table
+ */
+struct Acpi20Tcpa {
+    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
+    uint16_t platform_class;
+    uint32_t log_area_minimum_length;
+    uint64_t log_area_start_address;
+} QEMU_PACKED;
+typedef struct Acpi20Tcpa Acpi20Tcpa;
+
+/* DMAR - DMA Remapping table r2.2 */
+struct AcpiTableDmar {
+    ACPI_TABLE_HEADER_DEF
+    uint8_t host_address_width; /* Maximum DMA physical addressability */
+    uint8_t flags;
+    uint8_t reserved[10];
+} QEMU_PACKED;
+typedef struct AcpiTableDmar AcpiTableDmar;
+
+/* Masks for Flags field above */
+#define ACPI_DMAR_INTR_REMAP        1
+#define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
+
+/* Values for sub-structure type for DMAR */
+enum {
+    ACPI_DMAR_TYPE_HARDWARE_UNIT = 0,       /* DRHD */
+    ACPI_DMAR_TYPE_RESERVED_MEMORY = 1,     /* RMRR */
+    ACPI_DMAR_TYPE_ATSR = 2,                /* ATSR */
+    ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3,   /* RHSR */
+    ACPI_DMAR_TYPE_ANDD = 4,                /* ANDD */
+    ACPI_DMAR_TYPE_RESERVED = 5             /* Reserved for furture use */
+};
+
+/*
+ * Sub-structures for DMAR
+ */
+/* Type 0: Hardware Unit Definition */
+struct AcpiDmarHardwareUnit {
+    uint16_t type;
+    uint16_t length;
+    uint8_t flags;
+    uint8_t reserved;
+    uint16_t pci_segment;   /* The PCI Segment associated with this unit */
+    uint64_t address;   /* Base address of remapping hardware register-set */
+} QEMU_PACKED;
+typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit;
+
+/* Masks for Flags field above */
+#define ACPI_DMAR_INCLUDE_PCI_ALL   1
+
+#endif
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 2519f7d..e5011c8 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -17,7 +17,7 @@
 #include "qemu-common.h"
 #include "libqtest.h"
 #include "qemu/compiler.h"
-#include "hw/i386/acpi-defs.h"
+#include "hw/acpi/acpi-defs.h"
 #include "hw/i386/smbios.h"
 #include "qemu/bitmap.h"
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 01/11] hw/i386: Move ACPI header definitions in an arch-independent location Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24 16:22   ` Michael S. Tsirkin
                     ` (2 more replies)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
                   ` (9 subsequent siblings)
  11 siblings, 3 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

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 <zhaoshenglong@huawei.com>
---
 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 0000000..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 <zhaoshenglong@huawei.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "hw/arm/virt-acpi-build.h"
+#include <stddef.h>
+#include <glib.h>
+#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             0x20000
+
+/* Reserve RAM space for tables: add another order of magnitude. */
+#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
+
+/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
+{
+}
+
+/* FACS */
+static void
+build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
+{
+}
+
+/* DSDT */
+static void
+build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
+{
+}
+
+typedef
+struct AcpiBuildTables {
+    AcpiAml table_data;
+    GArray *rsdp;
+    GArray *tcpalog;
+    GArray *linker;
+} AcpiBuildTables;
+
+static inline void acpi_build_tables_init(AcpiBuildTables *tables)
+{
+    tables->rsdp = g_array_new(false, true /* clear */, 1);
+    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
+    tables->tcpalog = g_array_new(false, true /* clear */, 1);
+    tables->linker = bios_linker_loader_init();
+    tables->table_data.linker = tables->linker;
+}
+
+static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
+{
+    void *linker_data = bios_linker_loader_cleanup(tables->linker);
+    g_free(linker_data);
+    g_array_free(tables->rsdp, mfre);
+    g_array_free(tables->table_data.buf, true);
+    g_array_free(tables->tcpalog, mfre);
+}
+
+typedef
+struct AcpiBuildState {
+    /* Copy of table in RAM (for patching). */
+    ram_addr_t table_ram;
+    uint32_t table_size;
+    /* Is table patched? */
+    uint8_t patched;
+    VirtGuestInfo *guest_info;
+} AcpiBuildState;
+
+static
+void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
+{
+    GArray *table_offsets;
+    unsigned facs, dsdt, xsdt;
+
+    table_offsets = g_array_new(false, true /* clear */,
+                                        sizeof(uint32_t));
+    ACPI_BUILD_DPRINTF("init ACPI tables\n");
+
+    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
+                             64 /* Ensure FACS is aligned */,
+                             false /* high memory */);
+
+    /*
+     * FACS is pointed to by FADT.
+     * We place it first since it's the only table that has alignment
+     * requirements.
+     */
+    facs = tables->table_data.buf->len;
+    build_facs(tables->table_data.buf, tables->linker, guest_info);
+
+    /* DSDT is pointed to by FADT */
+    dsdt = tables->table_data.buf->len;
+    build_dsdt(&tables->table_data, tables->linker, guest_info);
+
+    /* ACPI tables pointed to by XSDT */
+    acpi_add_table(table_offsets, tables->table_data.buf);
+    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
+
+    acpi_add_table(table_offsets, tables->table_data.buf);
+    build_madt(tables->table_data.buf, tables->linker, guest_info);
+
+    acpi_add_table(table_offsets, tables->table_data.buf);
+    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
+
+    /* XSDT is pointed to by RSDP */
+    xsdt = tables->table_data.buf->len;
+    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
+
+    /* RSDP is in FSEG memory, so allocate it separately */
+    build_rsdp(tables->rsdp, tables->linker, xsdt);
+
+    /* Cleanup memory that's no longer used. */
+    g_array_free(table_offsets, true);
+}
+
+static ram_addr_t 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, NULL, build_state);
+}
+
+void virt_acpi_setup(VirtGuestInfo *guest_info)
+{
+    AcpiBuildTables tables;
+    AcpiBuildState *build_state;
+
+    if (!guest_info->fw_cfg) {
+        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
+        return;
+    }
+
+    if (!acpi_enabled) {
+        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
+        return;
+    }
+
+    build_state = g_malloc0(sizeof *build_state);
+    build_state->guest_info = guest_info;
+
+    acpi_build_tables_init(&tables);
+    acpi_build(build_state->guest_info, &tables);
+
+    /* Now expose it all to Guest */
+    build_state->table_ram = acpi_add_rom_blob(build_state,
+                                               tables.table_data.buf,
+                                               ACPI_BUILD_TABLE_FILE,
+                                               ACPI_BUILD_TABLE_MAX_SIZE);
+    assert(build_state->table_ram != RAM_ADDR_MAX);
+    build_state->table_size = acpi_data_len(tables.table_data.buf);
+
+    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
+
+    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
+                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
+
+    /*
+     * RSDP is small so it's easy to keep it immutable, no need to
+     * bother with ROM blobs.
+     */
+    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
+                    tables.rsdp->data, acpi_data_len(tables.rsdp));
+
+    /* Cleanup tables but don't free the memory: we track it
+     * in build_state.
+     */
+    acpi_build_tables_cleanup(&tables, false);
+}
diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
new file mode 100644
index 0000000..7a09c34
--- /dev/null
+++ b/include/hw/arm/virt-acpi-build.h
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * Author: Shannon Zhao <zhaoshenglong@huawei.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef QEMU_VIRT_ACPI_BUILD_H
+#define QEMU_VIRT_ACPI_BUILD_H
+
+#include "qemu-common.h"
+#include "hw/acpi/acpi-defs.h"
+
+
+#define ACPI_VIRT_QEMU_STR_4 "QEMU"
+#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
+#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
+
+struct acpi_gtdt_info {
+    uint32_t timer_virt;
+    uint32_t timer_s_el1;
+    uint32_t timer_ns_el1;
+    uint32_t timer_ns_el2;
+};
+
+struct acpi_madt_info {
+    const hwaddr *gic_cpu_base_addr;
+    const hwaddr *gic_dist_base_addr;
+};
+
+struct acpi_dsdt_info {
+    const hwaddr *uart_addr;
+    const int *uart_irq;
+    const hwaddr *virtio_mmio_addr;
+    const int *virtio_mmio_irq;
+    int virtio_mmio_num;
+    const hwaddr *rtc_addr;
+    const int *rtc_irq;
+    const hwaddr *flash_addr;
+};
+
+typedef struct VirtGuestInfo {
+    int nb_cpus;
+    int max_cpus;
+    FWCfgState *fw_cfg;
+    const struct acpi_madt_info *madt_info;
+    const struct acpi_dsdt_info *dsdt_info;
+    const struct acpi_gtdt_info *gtdt_info;
+} VirtGuestInfo;
+
+
+typedef struct VirtGuestInfoState {
+    VirtGuestInfo info;
+    Notifier machine_done;
+} VirtGuestInfoState;
+
+void virt_acpi_setup(VirtGuestInfo *guest_info);
+
+#endif
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 01/11] hw/i386: Move ACPI header definitions in an arch-independent location Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-26 10:22   ` Igor Mammedov
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function Shannon Zhao
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

RSDP points to XSDT which in turn points to other tables.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 4eed0a3..9c3971a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -86,6 +86,28 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
 static GArray *
 build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
 {
+    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
+
+    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
+                             true /* fseg memory */);
+
+    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
+    memcpy(rsdp->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(rsdp->oem_id));
+    rsdp->length = cpu_to_le32(sizeof(*rsdp));
+    rsdp->revision = 0x02;
+
+    /* Point to XSDT */
+    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
+    /* Address to be filled by Guest linker */
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   rsdp_table, &rsdp->xsdt_physical_address,
+                                   sizeof rsdp->xsdt_physical_address);
+    rsdp->checksum = 0;
+    /* Checksum to be filled by Guest linker */
+    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
+                                    rsdp, rsdp, sizeof *rsdp, &rsdp->checksum);
+
     return rsdp_table;
 }
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (2 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24 22:04   ` Laszlo Ersek
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 05/11] hw/arm/virt-acpi-build: Generate MADT table Shannon Zhao
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

XDST points to other tables except FACS & DSDT.
Implement a common header helper functions for generating ACPI tables.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c    |   34 ++++++++++++++++++++++++++++++++++
 include/hw/acpi/acpi-defs.h |    9 +++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 9c3971a..446947a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -61,6 +61,22 @@
 #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
 #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
 
+static void
+build_header(GArray *linker, GArray *table_data,
+             AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
+{
+    memcpy(&h->signature, sig, sizeof(h->signature));
+    h->length = cpu_to_le32(len);
+    h->revision = rev;
+    memcpy(h->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(h->oem_id));
+    memcpy(h->oem_table_id, ACPI_VIRT_MACH_STR_8, sizeof(h->oem_table_id));
+    h->oem_revision = cpu_to_le32(1);
+    h->checksum = 0;
+    /* Checksum to be filled in by Guest linker */
+    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+                                    table_data->data, h, len, &h->checksum);
+}
+
 static inline void *acpi_data_push(GArray *table_data, uint64_t size)
 {
     unsigned off = table_data->len;
@@ -115,6 +131,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
 static void
 build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
 {
+    AcpiXsdtDescriptor *xsdt;
+    size_t xsdt_len;
+    int i;
+
+    xsdt_len = sizeof(*xsdt) + sizeof(uint64_t) * table_offsets->len;
+    xsdt = acpi_data_push(table_data, xsdt_len);
+    memcpy(xsdt->table_offset_entry, table_offsets->data,
+           sizeof(uint64_t) * table_offsets->len);
+    for (i = 0; i < table_offsets->len; ++i) {
+        /* rsdt->table_offset_entry to be filled by Guest linker */
+        bios_linker_loader_add_pointer(linker,
+                                       ACPI_BUILD_TABLE_FILE,
+                                       ACPI_BUILD_TABLE_FILE,
+                                       table_data, &xsdt->table_offset_entry[i],
+                                       sizeof(uint64_t));
+    }
+    build_header(linker, table_data,
+                 (void *)xsdt, "XSDT", xsdt_len, 1);
 }
 
 /* MADT */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index c4468f8..779f872 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -88,6 +88,15 @@ struct AcpiTableHeader         /* ACPI common table header */
 typedef struct AcpiTableHeader AcpiTableHeader;
 
 /*
+ * Extended System Description Table (XSDT)
+ */
+struct AcpiXsdtDescriptor {
+    ACPI_TABLE_HEADER_DEF
+    uint64_t table_offset_entry[1]; /* Array of pointers to ACPI tables */
+} QEMU_PACKED;
+typedef struct AcpiXsdtDescriptor AcpiXsdtDescriptor;
+
+/*
  * ACPI 1.0 Fixed ACPI Description Table (FADT)
  */
 struct AcpiFadtDescriptorRev1
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 05/11] hw/arm/virt-acpi-build: Generate MADT table
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (3 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 06/11] hw/arm/virt-acpi-build: Generate GTDT table Shannon Zhao
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

MADT describes GIC enabled ARM platforms. The GICC and GICD
subtables are used to define the GIC regions.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c    |   30 ++++++++++++++++++++++++++++++
 include/hw/acpi/acpi-defs.h |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 446947a..4f55408 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -155,6 +155,36 @@ build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
 static void
 build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 {
+    int madt_start = table_data->len;
+    const struct acpi_madt_info *info = guest_info->madt_info;
+    AcpiMultipleApicTable *madt;
+    AcpiMadtGenericDistributor *gicd;
+    int i;
+
+    madt = acpi_data_push(table_data, sizeof *madt);
+    madt->local_apic_address = *info->gic_cpu_base_addr;
+    madt->flags = cpu_to_le32(1);
+
+    for (i = 0; i < guest_info->max_cpus; i++) {
+        AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data,
+                                                     sizeof *gicc);
+        gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
+        gicc->length = sizeof(*gicc);
+        gicc->base_address = *info->gic_cpu_base_addr;
+        gicc->cpu_interface_number = i;
+        gicc->arm_mpidr = i;
+        gicc->uid = i;
+        gicc->flags = i < guest_info->nb_cpus ? cpu_to_le32(1) : cpu_to_le32(0);
+    }
+
+    gicd = acpi_data_push(table_data, sizeof *gicd);
+    gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
+    gicd->length = sizeof(*gicd);
+    gicd->base_address = *info->gic_dist_base_addr;
+
+    build_header(linker, table_data,
+                 (void *)(table_data->data + madt_start), "APIC",
+                 table_data->len - madt_start, 1);
 }
 
 /* GTDT */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 779f872..b81926d 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -204,7 +204,14 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable;
 #define ACPI_APIC_IO_SAPIC           6
 #define ACPI_APIC_LOCAL_SAPIC        7
 #define ACPI_APIC_XRUPT_SOURCE       8
-#define ACPI_APIC_RESERVED           9           /* 9 and greater are reserved */
+#define ACPI_APIC_LOCAL_X2APIC       9
+#define ACPI_APIC_LOCAL_X2APIC_NMI      10
+#define ACPI_APIC_GENERIC_INTERRUPT     11
+#define ACPI_APIC_GENERIC_DISTRIBUTOR   12
+#define ACPI_APIC_GENERIC_MSI_FRAME     13
+#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
+#define ACPI_APIC_RESERVED              15   /* 15 and greater are reserved */
+
 
 /*
  * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
@@ -252,6 +259,34 @@ struct AcpiMadtLocalNmi {
 } QEMU_PACKED;
 typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi;
 
+struct AcpiMadtGenericInterrupt {
+    ACPI_SUB_HEADER_DEF
+    uint16_t reserved;
+    uint32_t cpu_interface_number;
+    uint32_t uid;
+    uint32_t flags;
+    uint32_t parking_version;
+    uint32_t performance_interrupt;
+    uint64_t parked_address;
+    uint64_t base_address;
+    uint64_t gicv_base_address;
+    uint64_t gich_base_address;
+    uint32_t vgic_interrupt;
+    uint64_t gicr_base_address;
+    uint64_t arm_mpidr;
+} QEMU_PACKED;
+typedef struct AcpiMadtGenericInterrupt AcpiMadtGenericInterrupt;
+
+struct AcpiMadtGenericDistributor {
+    ACPI_SUB_HEADER_DEF
+    uint16_t reserved;
+    uint32_t gic_id;
+    uint64_t base_address;
+    uint32_t global_irq_base;
+    uint32_t reserved2;
+} QEMU_PACKED;
+typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor;
+
 /*
  * HPET Description Table
  */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 06/11] hw/arm/virt-acpi-build: Generate GTDT table
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (4 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 05/11] hw/arm/virt-acpi-build: Generate MADT table Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

ACPI v5.1 defines GTDT for ARM devices as a place to describe timer
related information in the system. The Arch Timer interrupts must
be provided for GTDT

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c    |   21 +++++++++++++++++++++
 include/hw/acpi/acpi-defs.h |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 4f55408..2872dff 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -191,6 +191,27 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 static void
 build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 {
+    int gtdt_start = table_data->len;
+    const struct acpi_gtdt_info *info = guest_info->gtdt_info;
+    AcpiGenericTimerTable *gtdt;
+
+    gtdt = acpi_data_push(table_data, sizeof *gtdt);
+    /* The interrupt values are the same with the device tree when adding 16 */
+    gtdt->secure_el1_interrupt = info->timer_s_el1;
+    gtdt->secure_el1_flags = ACPI_EDGE_SENSITIVE;
+
+    gtdt->non_secure_el1_interrupt = info->timer_ns_el1;
+    gtdt->non_secure_el1_flags = ACPI_EDGE_SENSITIVE;
+
+    gtdt->virtual_timer_interrupt = info->timer_virt;
+    gtdt->virtual_timer_flags = ACPI_EDGE_SENSITIVE;
+
+    gtdt->non_secure_el2_interrupt = info->timer_ns_el2;
+    gtdt->non_secure_el2_flags = ACPI_EDGE_SENSITIVE;
+
+    build_header(linker, table_data,
+                 (void *)(table_data->data + gtdt_start), "GTDT",
+                 table_data->len - gtdt_start, 1);
 }
 
 /* FADT */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index b81926d..5633e04 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -288,6 +288,43 @@ struct AcpiMadtGenericDistributor {
 typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor;
 
 /*
+ * Generic Timer Description Table (GTDT)
+ */
+
+#define ACPI_GTDT_INTERRUPT_MODE        (1)
+#define ACPI_GTDT_INTERRUPT_POLARITY    (1<<1)
+#define ACPI_GTDT_ALWAYS_ON             (1<<2)
+
+/* Triggering */
+
+#define ACPI_LEVEL_SENSITIVE            (uint8_t) 0x00
+#define ACPI_EDGE_SENSITIVE             (uint8_t) 0x01
+
+/* Polarity */
+
+#define ACPI_ACTIVE_HIGH                (uint8_t) 0x00
+#define ACPI_ACTIVE_LOW                 (uint8_t) 0x01
+#define ACPI_ACTIVE_BOTH                (uint8_t) 0x02
+
+struct AcpiGenericTimerTable {
+    ACPI_TABLE_HEADER_DEF
+    uint64_t counter_block_addresss;
+    uint32_t reserved;
+    uint32_t secure_el1_interrupt;
+    uint32_t secure_el1_flags;
+    uint32_t non_secure_el1_interrupt;
+    uint32_t non_secure_el1_flags;
+    uint32_t virtual_timer_interrupt;
+    uint32_t virtual_timer_flags;
+    uint32_t non_secure_el2_interrupt;
+    uint32_t non_secure_el2_flags;
+    uint64_t counter_read_block_address;
+    uint32_t platform_timer_count;
+    uint32_t platform_timer_offset;
+} QEMU_PACKED;
+typedef struct AcpiGenericTimerTable AcpiGenericTimerTable;
+
+/*
  * HPET Description Table
  */
 struct Acpi20Hpet {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (5 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 06/11] hw/arm/virt-acpi-build: Generate GTDT table Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24 22:05   ` Laszlo Ersek
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 08/11] hw/arm/virt-acpi-build: Generate FACS " Shannon Zhao
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

FADT points to FACS and DSDT, in the case of mach virt, it is also used
to set the Hardware Reduced bit and enable PSCI SMP booting through HVC.

Update the header definitions for FADT taking into account the new
additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h`

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c    |   26 ++++++++++
 include/hw/acpi/acpi-defs.h |  114 +++++++++++++++++++++++++++++--------------
 2 files changed, 103 insertions(+), 37 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 2872dff..e3c708d 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -218,6 +218,32 @@ build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 static void
 build_fadt(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
 {
+    AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
+
+    /* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */
+    fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
+    fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
+                                       (1 << ACPI_FADT_ARM_PSCI_USE_HVC));
+
+    /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
+    fadt->minor_revision = 0x1;
+
+    fadt->Xfacs = cpu_to_le64(facs);
+    /* FACS address to be filled by Guest linker */
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data, &fadt->Xfacs,
+                                   sizeof fadt->Xfacs);
+
+    fadt->Xdsdt = cpu_to_le64(dsdt);
+    /* DSDT address to be filled by Guest linker */
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data, &fadt->Xdsdt,
+                                   sizeof fadt->Xdsdt);
+
+    build_header(linker, table_data,
+                 (void *)fadt, "FACP", sizeof(*fadt), 5);
 }
 
 /* FACS */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 5633e04..c1255fa 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -97,46 +97,49 @@ struct AcpiXsdtDescriptor {
 typedef struct AcpiXsdtDescriptor AcpiXsdtDescriptor;
 
 /*
- * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ * ACPI Fixed ACPI Description Table (FADT)
  */
+#define ACPI_FADT_COMMON_DEF         /* FADT common definition */ \
+    ACPI_TABLE_HEADER_DEF            /* ACPI common table header */ \
+    uint32_t firmware_ctrl;          /* Physical address of FACS */ \
+    uint32_t dsdt;                   /* Physical address of DSDT */ \
+    uint8_t  model;                  /* System Interrupt Model */ \
+    uint8_t  reserved1;              /* Reserved */ \
+    uint16_t sci_int;                /* System vector of SCI interrupt */ \
+    uint32_t smi_cmd;                /* Port address of SMI command port */ \
+    uint8_t  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */ \
+    uint8_t  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */ \
+    uint8_t  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */ \
+    uint8_t  reserved2;              /* Reserved - must be zero */ \
+    uint32_t pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */ \
+    uint32_t pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */ \
+    uint32_t pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */ \
+    uint32_t pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */ \
+    uint32_t pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */ \
+    uint32_t pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */ \
+    uint32_t gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */ \
+    uint32_t gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */ \
+    uint8_t  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */ \
+    uint8_t  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */ \
+    uint8_t  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */ \
+    uint8_t  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */ \
+    uint8_t  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */ \
+    uint8_t  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */ \
+    uint8_t  gpe1_base;              /* Offset in gpe model where gpe1 events start */ \
+    uint8_t  reserved3;              /* Reserved */ \
+    uint16_t plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */ \
+    uint16_t plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */ \
+    uint16_t flush_size;             /* Size of area read to flush caches */ \
+    uint16_t flush_stride;           /* Stride used in flushing caches */ \
+    uint8_t  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */ \
+    uint8_t  duty_width;             /* Bit width of duty cycle field in p_cnt reg */ \
+    uint8_t  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */ \
+    uint8_t  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */ \
+    uint8_t  century;                /* Index to century in RTC CMOS RAM */
+
 struct AcpiFadtDescriptorRev1
 {
-    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
-    uint32_t firmware_ctrl;          /* Physical address of FACS */
-    uint32_t dsdt;                   /* Physical address of DSDT */
-    uint8_t  model;                  /* System Interrupt Model */
-    uint8_t  reserved1;              /* Reserved */
-    uint16_t sci_int;                /* System vector of SCI interrupt */
-    uint32_t smi_cmd;                /* Port address of SMI command port */
-    uint8_t  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
-    uint8_t  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
-    uint8_t  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
-    uint8_t  reserved2;              /* Reserved - must be zero */
-    uint32_t pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
-    uint32_t pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
-    uint32_t pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
-    uint32_t pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
-    uint32_t pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
-    uint32_t pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
-    uint32_t gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
-    uint32_t gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
-    uint8_t  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
-    uint8_t  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
-    uint8_t  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
-    uint8_t  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */
-    uint8_t  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
-    uint8_t  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
-    uint8_t  gpe1_base;              /* Offset in gpe model where gpe1 events start */
-    uint8_t  reserved3;              /* Reserved */
-    uint16_t plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
-    uint16_t plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
-    uint16_t flush_size;             /* Size of area read to flush caches */
-    uint16_t flush_stride;           /* Stride used in flushing caches */
-    uint8_t  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
-    uint8_t  duty_width;             /* Bit width of duty cycle field in p_cnt reg */
-    uint8_t  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
-    uint8_t  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
-    uint8_t  century;                /* Index to century in RTC CMOS RAM */
+    ACPI_FADT_COMMON_DEF
     uint8_t  reserved4;              /* Reserved */
     uint8_t  reserved4a;             /* Reserved */
     uint8_t  reserved4b;             /* Reserved */
@@ -144,6 +147,43 @@ struct AcpiFadtDescriptorRev1
 } QEMU_PACKED;
 typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
 
+struct acpi_generic_address {
+    uint8_t space_id;        /* Address space where struct or register exists */
+    uint8_t bit_width;       /* Size in bits of given register */
+    uint8_t bit_offset;      /* Bit offset within the register */
+    uint8_t access_width;    /* Minimum Access size (ACPI 3.0) */
+    uint64_t address;        /* 64-bit address of struct or register */
+} QEMU_PACKED;
+
+struct AcpiFadtDescriptorRev5_1 {
+    ACPI_FADT_COMMON_DEF
+    uint16_t boot_flags;     /* IA-PC Boot Architecture Flags (see below for individual flags) */
+    uint8_t reserved;        /* Reserved, must be zero */
+    uint32_t flags;      /* Miscellaneous flag bits (see below for individual flags) */
+    struct acpi_generic_address reset_register; /* 64-bit address of the Reset register */
+    uint8_t reset_value;     /* Value to write to the reset_register port to reset the system */
+    uint16_t arm_boot_flags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
+    uint8_t minor_revision;  /* FADT Minor Revision (ACPI 5.1) */
+    uint64_t Xfacs;      /* 64-bit physical address of FACS */
+    uint64_t Xdsdt;      /* 64-bit physical address of DSDT */
+    struct acpi_generic_address xpm1a_event_block;  /* 64-bit Extended Power Mgt 1a Event Reg Blk address */
+    struct acpi_generic_address xpm1b_event_block;  /* 64-bit Extended Power Mgt 1b Event Reg Blk address */
+    struct acpi_generic_address xpm1a_control_block;    /* 64-bit Extended Power Mgt 1a Control Reg Blk address */
+    struct acpi_generic_address xpm1b_control_block;    /* 64-bit Extended Power Mgt 1b Control Reg Blk address */
+    struct acpi_generic_address xpm2_control_block; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */
+    struct acpi_generic_address xpm_timer_block;    /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */
+    struct acpi_generic_address xgpe0_block;    /* 64-bit Extended General Purpose Event 0 Reg Blk address */
+    struct acpi_generic_address xgpe1_block;    /* 64-bit Extended General Purpose Event 1 Reg Blk address */
+    struct acpi_generic_address sleep_control;  /* 64-bit Sleep Control register (ACPI 5.0) */
+    struct acpi_generic_address sleep_status;   /* 64-bit Sleep Status register (ACPI 5.0) */
+} QEMU_PACKED;
+typedef struct AcpiFadtDescriptorRev5_1 AcpiFadtDescriptorRev5_1;
+
+enum {
+    ACPI_FADT_ARM_USE_PSCI_G_0_2,
+    ACPI_FADT_ARM_PSCI_USE_HVC,
+};
+
 /*
  * ACPI 1.0 Root System Description Table (RSDT)
  */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 08/11] hw/arm/virt-acpi-build: Generate FACS table and update ACPI headers
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (6 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq() Shannon Zhao
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

FACS table is created as a mockup, as with the Hardware Reduced bit
set it will not be used.

Update the header definitions for FACS taking into account the new
additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h`

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c    |    4 ++++
 include/hw/acpi/acpi-defs.h |   28 +++++++++++++++++++++-------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e3c708d..de1f307 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -250,6 +250,10 @@ build_fadt(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
 static void
 build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 {
+    AcpiFacsDescriptorRev5_1 *facs = acpi_data_push(table_data, sizeof *facs);
+    memcpy(&facs->signature, "FACS", sizeof(facs->signature));
+    facs->length = cpu_to_le32(sizeof(*facs));
+    facs->version = 0x02;
 }
 
 /* DSDT */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index c1255fa..91b3520 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -196,20 +196,34 @@ struct AcpiRsdtDescriptorRev1
 typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1;
 
 /*
- * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ * ACPI Firmware ACPI Control Structure (FACS)
  */
+#define ACPI_FACS_COMMON_DEF /* FACS common definition */ \
+    uint32_t signature;           /* ACPI Signature */ \
+    uint32_t length;                 /* Length of structure, in bytes */ \
+    uint32_t hardware_signature;     /* Hardware configuration signature */ \
+    uint32_t firmware_waking_vector; /* ACPI OS waking vector */ \
+    uint32_t global_lock;            /* Global Lock */ \
+    uint32_t flags;
+
 struct AcpiFacsDescriptorRev1
 {
-    uint32_t signature;           /* ACPI Signature */
-    uint32_t length;                 /* Length of structure, in bytes */
-    uint32_t hardware_signature;     /* Hardware configuration signature */
-    uint32_t firmware_waking_vector; /* ACPI OS waking vector */
-    uint32_t global_lock;            /* Global Lock */
-    uint32_t flags;
+    ACPI_FACS_COMMON_DEF
     uint8_t  resverved3 [40];        /* Reserved - must be zero */
 } QEMU_PACKED;
 typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
 
+struct AcpiFacsDescriptorRev5_1 {
+    ACPI_FACS_COMMON_DEF
+    /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */
+    uint64_t xfirmware_waking_vector;
+    uint8_t version;     /* Version of this table (ACPI 2.0+) */
+    uint8_t reserved[3];     /* Reserved, must be zero */
+    uint32_t ospm_flags;     /* Flags to be set by OSPM (ACPI 4.0) */
+    uint8_t reserved1[24];   /* Reserved, must be zero */
+} QEMU_PACKED;
+typedef struct AcpiFacsDescriptorRev5_1 AcpiFacsDescriptorRev5_1;
+
 /*
  * Differentiated System Description Table (DSDT)
  */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq()
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (7 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 08/11] hw/arm/virt-acpi-build: Generate FACS " Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-25  8:39   ` Michael S. Tsirkin
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

Add acpi_fixed_memory32() for describing device mmio region in resource template.
Add acpi_extended_irq() for describing device interrupt in resource template.
These can be used to generating DSDT table for ACPI on ARM.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/acpi/acpi-build-utils.c         |   42 ++++++++++++++++++++++++++++++++++++
 include/hw/acpi/acpi-build-utils.h |    2 +
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
index 59873e3..211c4d3 100644
--- a/hw/acpi/acpi-build-utils.c
+++ b/hw/acpi/acpi-build-utils.c
@@ -493,6 +493,48 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
 }
 
 /*
+ * ACPI 5.1: 19.5.80 Memory32Fixed (Memory Resource Descriptor Macro)
+ *           6.4.2 Small Resource Data Type
+ */
+AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag)
+{
+    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+    build_append_byte(var.buf, 0x86); /* Extended irq descriptor */
+    build_append_byte(var.buf, 9);
+    build_append_byte(var.buf, 0);
+    build_append_byte(var.buf, rw_flag);
+    build_append_byte(var.buf, addr & 0xff);
+    build_append_byte(var.buf, (addr >> 8) & 0xff);
+    build_append_byte(var.buf, (addr >> 16) & 0xff);
+    build_append_byte(var.buf, (addr >> 24) & 0xff);
+
+    build_append_byte(var.buf, size & 0xff);
+    build_append_byte(var.buf, (size >> 8) & 0xff);
+    build_append_byte(var.buf, (size >> 16) & 0xff);
+    build_append_byte(var.buf, (size >> 24) & 0xff);
+    return var;
+}
+
+/*
+ * ACPI 5.1: 19.5.61 Interrupt (Interrupt Resource Descriptor Macro)
+ *           6.4.2 Small Resource Data Type
+ */
+AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq)
+{
+    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+    build_append_byte(var.buf, 0x89); /* Extended irq descriptor */
+    build_append_byte(var.buf, 6);
+    build_append_byte(var.buf, 0);
+    build_append_byte(var.buf, irq_flags);
+    build_append_byte(var.buf, 0x01);
+    build_append_byte(var.buf, irq & 0xff);
+    build_append_byte(var.buf, (irq >> 8) & 0xff);
+    build_append_byte(var.buf, (irq >> 16) & 0xff);
+    build_append_byte(var.buf, (irq >> 24) & 0xff);
+    return var;
+}
+
+/*
  * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
  *           6.4.2 Small Resource Data Type
 */
diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
index d39b5b1..bfed546 100644
--- a/include/hw/acpi/acpi-build-utils.h
+++ b/include/hw/acpi/acpi-build-utils.h
@@ -115,6 +115,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
                    AcpiAml arg3);
 AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
                    AcpiAml arg3, AcpiAml arg4);
+AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag);
+AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq);
 AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
                 uint8_t aln, uint8_t len);
 AcpiAml acpi_iqr_no_flags(uint8_t irq);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (8 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq() Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-26 10:40   ` Igor Mammedov
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
  2015-01-24 23:31 ` [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Laszlo Ersek
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

DSDT consists of the usual common table header plus a definition
block in AML encoding which describes all devices in the platform.

After initializing DSDT with header information the namespace is
created which is followed by the device encodings. The devices are
described using the Resource Template for the 32-Bit Fixed Memory
Range and the Extended Interrupt Descriptors.

The following devices are included in the DSDT:
- CPUs
- UART
- RTC
- NAND Flash
- virtio-mmio

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 hw/arm/virt-acpi-build.c |  120 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 120 insertions(+), 0 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index de1f307..5c76ca2 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -98,6 +98,111 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
     g_array_append_val(table_offsets, offset);
 }
 
+static void acpi_dsdt_add_cpus(AcpiAml *scope, int smp_cpus)
+{
+    AcpiAml dev, crs;
+    int i;
+    char name[5];
+    for (i = 0; i < smp_cpus; i++) {
+        snprintf(name, 5, "CPU%u", i);
+        dev = acpi_device("%s", name);
+        aml_append(&dev, acpi_name_decl("_HID", acpi_string("ACPI007")));
+        aml_append(&dev, acpi_name_decl("_UID", acpi_int(i)));
+        crs = acpi_resource_template();
+        aml_append(&dev, acpi_name_decl("_CRS", crs));
+        aml_append(scope, dev);
+    }
+}
+
+static void acpi_dsdt_add_uart(AcpiAml *scope, const hwaddr *uart_addr,
+                                               const int *uart_irq)
+{
+    AcpiAml dev, crs;
+
+    dev = acpi_device("COM0");
+    aml_append(&dev, acpi_name_decl("_HID", acpi_string("ARMH0011")));
+    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
+
+    crs = acpi_resource_template();
+    aml_append(&crs,
+               acpi_fixed_memory32(uart_addr[0], uart_addr[1], 0x01));
+    aml_append(&crs,
+               acpi_extended_irq(0x01, *uart_irq + 32));
+    aml_append(&dev, acpi_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+}
+
+static void acpi_dsdt_add_rtc(AcpiAml *scope, const hwaddr *rtc_addr,
+                                              const int *rtc_irq)
+{
+    AcpiAml dev, crs;
+
+    dev = acpi_device("RTC0");
+    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0013")));
+    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
+
+    crs = acpi_resource_template();
+    aml_append(&crs,
+               acpi_fixed_memory32(rtc_addr[0], rtc_addr[1], 0x01));
+    aml_append(&crs,
+               acpi_extended_irq(0x01, *rtc_irq + 32));
+    aml_append(&dev, acpi_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+}
+
+static void acpi_dsdt_add_flash(AcpiAml *scope, const hwaddr *flash_addr)
+{
+    AcpiAml dev, crs;
+    hwaddr base = flash_addr[0];
+    hwaddr size = flash_addr[1];
+
+    dev = acpi_device("FLS0");
+    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0015")));
+    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
+
+    crs = acpi_resource_template();
+    aml_append(&crs,
+               acpi_fixed_memory32(base, size, 0x01));
+    aml_append(&dev, acpi_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+
+    dev = acpi_device("FLS1");
+    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0015")));
+    aml_append(&dev, acpi_name_decl("_UID", acpi_int(1)));
+    crs = acpi_resource_template();
+    aml_append(&crs,
+               acpi_fixed_memory32(base + size, size, 0x01));
+    aml_append(&dev, acpi_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+}
+
+static void acpi_dsdt_add_virtio(AcpiAml *scope, const hwaddr *mmio_addrs,
+                                                 const int *mmio_irq, int num)
+{
+    AcpiAml dev, crs;
+    hwaddr base = mmio_addrs[0];
+    hwaddr size = mmio_addrs[1];
+    int irq = *mmio_irq + 32;
+    int i;
+    char name[5];
+
+    for (i = 0; i < num; i++) {
+        snprintf(name, 5, "VR%02u", i);
+        dev = acpi_device("%s", name);
+        aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0005")));
+        aml_append(&dev, acpi_name_decl("_UID", acpi_int(i)));
+
+        crs = acpi_resource_template();
+        aml_append(&crs,
+                   acpi_fixed_memory32(base, size, 0x01));
+        aml_append(&crs,
+                   acpi_extended_irq(0x01, irq + i));
+        aml_append(&dev, acpi_name_decl("_CRS", crs));
+        aml_append(scope, dev);
+        base += size;
+    }
+}
+
 /* RSDP */
 static GArray *
 build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
@@ -260,6 +365,21 @@ build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
 static void
 build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
 {
+    AcpiAml scope, dsdt;
+    const struct acpi_dsdt_info *info = guest_info->dsdt_info;
+
+    dsdt = acpi_def_block("DSDT", 1, ACPI_VIRT_QEMU_STR_4,
+                                     ACPI_VIRT_MACH_STR_8, 1);
+    scope = acpi_scope("\\_SB");
+    acpi_dsdt_add_cpus(&scope, guest_info->nb_cpus);
+    acpi_dsdt_add_uart(&scope, info->uart_addr, info->uart_irq);
+    acpi_dsdt_add_rtc(&scope, info->rtc_addr, info->rtc_irq);
+    acpi_dsdt_add_flash(&scope, info->flash_addr);
+    acpi_dsdt_add_virtio(&scope, info->virtio_mmio_addr,
+             info->virtio_mmio_irq, info->virtio_mmio_num);
+
+    aml_append(&dsdt, scope);
+    aml_append(table_aml, dsdt);
 }
 
 typedef
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (9 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
@ 2015-01-24  9:21 ` Shannon Zhao
  2015-01-24 18:56   ` Laszlo Ersek
  2015-01-24 23:31 ` [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Laszlo Ersek
  11 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-24  9:21 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, pbonzini, christoffer.dall,
	a.spyridakis, claudio.fontana, imammedo, hanjun.guo, mst, lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng, zhaoshenglong

Expose the needed device information to the table generation
insfrastructure and register a machine_init_done notify to
call virt_acpi_build().

Add CONFIG_ACPI to arm-softmmu.mak, but there is compile error.
Don't include unnecessary file for ARM. Maybe this way is not
right, fix me please.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
---
 default-configs/arm-softmmu.mak      |    1 +
 default-configs/i386-softmmu.mak     |    3 ++
 default-configs/mips-softmmu.mak     |    3 ++
 default-configs/mips64-softmmu.mak   |    3 ++
 default-configs/mips64el-softmmu.mak |    3 ++
 default-configs/mipsel-softmmu.mak   |    3 ++
 default-configs/x86_64-softmmu.mak   |    3 ++
 hw/acpi/Makefile.objs                |    5 ++-
 hw/arm/virt.c                        |   59 +++++++++++++++++++++++++++++++--
 hw/i2c/Makefile.objs                 |    2 +-
 10 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index f3513fa..3c89f53 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -88,3 +88,4 @@ CONFIG_INTEGRATOR_DEBUG=y
 CONFIG_ALLWINNER_A10_PIT=y
 CONFIG_ALLWINNER_A10_PIC=y
 CONFIG_ALLWINNER_A10=y
+CONFIG_ACPI=y
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 8e08841..3a5fe74 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_IDE_ISA=y
diff --git a/default-configs/mips-softmmu.mak b/default-configs/mips-softmmu.mak
index 2a80b04..d37ada7 100644
--- a/default-configs/mips-softmmu.mak
+++ b/default-configs/mips-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_PIIX4=y
diff --git a/default-configs/mips64-softmmu.mak b/default-configs/mips64-softmmu.mak
index f1f933b..b15d6c0 100644
--- a/default-configs/mips64-softmmu.mak
+++ b/default-configs/mips64-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_PIIX4=y
diff --git a/default-configs/mips64el-softmmu.mak b/default-configs/mips64el-softmmu.mak
index 317b151..494a7e7 100644
--- a/default-configs/mips64el-softmmu.mak
+++ b/default-configs/mips64el-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_PIIX4=y
diff --git a/default-configs/mipsel-softmmu.mak b/default-configs/mipsel-softmmu.mak
index 7708185..0d2173b 100644
--- a/default-configs/mipsel-softmmu.mak
+++ b/default-configs/mipsel-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_PIIX4=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 66557ac..79eb980 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -17,6 +17,9 @@ CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
+CONFIG_ACPI_CORE=y
+CONFIG_ACPI_MEMORY_HOTPLUG=y
+CONFIG_ACPI_CPU_HOTPLUG=y
 CONFIG_APM=y
 CONFIG_I8257=y
 CONFIG_IDE_ISA=y
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index cad0355..4e3f15f 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,5 +1,6 @@
-common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
-common-obj-$(CONFIG_ACPI) += memory_hotplug.o
+common-obj-$(CONFIG_ACPI_CORE) += core.o piix4.o ich9.o pcihp.o
+common-obj-$(CONFIG_ACPI_HOTPLUG) += cpu_hotplug.o
+common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI) += acpi_interface.o
 common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
 common-obj-$(CONFIG_ACPI) += acpi-build-utils.o
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2353440..63ee9b3 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -42,6 +42,7 @@
 #include "exec/address-spaces.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
+#include "hw/arm/virt-acpi-build.h"
 
 #define NUM_VIRTIO_TRANSPORTS 32
 
@@ -59,6 +60,11 @@
 #define GIC_FDT_IRQ_PPI_CPU_START 8
 #define GIC_FDT_IRQ_PPI_CPU_WIDTH 8
 
+#define ARCH_TIMER_VIRT_IRQ   11
+#define ARCH_TIMER_S_EL1_IRQ  13
+#define ARCH_TIMER_NS_EL1_IRQ 14
+#define ARCH_TIMER_NS_EL2_IRQ 10
+
 enum {
     VIRT_FLASH,
     VIRT_MEM,
@@ -139,6 +145,29 @@ static const int a15irqmap[] = {
     [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
 };
 
+static const struct acpi_madt_info madt_info = {
+    &a15memmap[VIRT_GIC_CPU].base,
+    &a15memmap[VIRT_GIC_DIST].base
+};
+
+static const struct acpi_dsdt_info dsdt_info = {
+    .uart_addr = &a15memmap[VIRT_UART].base,
+    .uart_irq = &a15irqmap[VIRT_UART],
+    .virtio_mmio_addr = &a15memmap[VIRT_MMIO].base,
+    .virtio_mmio_irq = &a15irqmap[VIRT_MMIO],
+    .virtio_mmio_num = NUM_VIRTIO_TRANSPORTS,
+    .rtc_addr = &a15memmap[VIRT_RTC].base,
+    .rtc_irq = &a15irqmap[VIRT_RTC],
+    .flash_addr = &a15memmap[VIRT_FLASH].base,
+};
+
+static const struct acpi_gtdt_info gtdt_info = {
+    ARCH_TIMER_VIRT_IRQ + 16,
+    ARCH_TIMER_S_EL1_IRQ + 16,
+    ARCH_TIMER_NS_EL1_IRQ + 16,
+    ARCH_TIMER_NS_EL2_IRQ + 16
+};
+
 static VirtBoardInfo machines[] = {
     {
         .cpu_model = "cortex-a15",
@@ -279,10 +308,10 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi)
                                 "arm,armv7-timer");
     }
     qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts",
-                               GIC_FDT_IRQ_TYPE_PPI, 13, irqflags,
-                               GIC_FDT_IRQ_TYPE_PPI, 14, irqflags,
-                               GIC_FDT_IRQ_TYPE_PPI, 11, irqflags,
-                               GIC_FDT_IRQ_TYPE_PPI, 10, irqflags);
+                       GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags,
+                       GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags,
+                       GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags,
+                       GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
 }
 
 static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
@@ -564,6 +593,15 @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
     return board->fdt;
 }
 
+static
+void virt_guest_info_machine_done(Notifier *notifier, void *data)
+{
+    VirtGuestInfoState *guest_info_state = container_of(notifier,
+                                                      VirtGuestInfoState,
+                                                      machine_done);
+    virt_acpi_setup(&guest_info_state->info);
+}
+
 static void machvirt_init(MachineState *machine)
 {
     VirtMachineState *vms = VIRT_MACHINE(machine);
@@ -573,6 +611,8 @@ static void machvirt_init(MachineState *machine)
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     const char *cpu_model = machine->cpu_model;
     VirtBoardInfo *vbi;
+    VirtGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
+    VirtGuestInfo *guest_info = &guest_info_state->info;
 
     if (!cpu_model) {
         cpu_model = "cortex-a15";
@@ -647,6 +687,7 @@ static void machvirt_init(MachineState *machine)
     create_virtio_devices(vbi, pic);
 
     create_fw_cfg(vbi);
+    rom_set_fw(fw_cfg_find());
 
     vbi->bootinfo.ram_size = machine->ram_size;
     vbi->bootinfo.kernel_filename = machine->kernel_filename;
@@ -657,6 +698,16 @@ static void machvirt_init(MachineState *machine)
     vbi->bootinfo.loader_start = vbi->memmap[VIRT_MEM].base;
     vbi->bootinfo.get_dtb = machvirt_dtb;
     vbi->bootinfo.firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
+
+    guest_info->nb_cpus = smp_cpus;
+    guest_info->max_cpus = max_cpus;
+    guest_info->fw_cfg = fw_cfg_find();
+    guest_info->madt_info = &madt_info;
+    guest_info->dsdt_info = &dsdt_info;
+    guest_info->gtdt_info = &gtdt_info;
+    guest_info_state->machine_done.notify = virt_guest_info_machine_done;
+    qemu_add_machine_init_done_notifier(&guest_info_state->machine_done);
+
     arm_load_kernel(ARM_CPU(first_cpu), &vbi->bootinfo);
 }
 
diff --git a/hw/i2c/Makefile.objs b/hw/i2c/Makefile.objs
index 648278e..c94e6e6 100644
--- a/hw/i2c/Makefile.objs
+++ b/hw/i2c/Makefile.objs
@@ -1,6 +1,6 @@
 common-obj-y += core.o smbus.o smbus_eeprom.o
 common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o
-common-obj-$(CONFIG_ACPI) += smbus_ich9.o
+common-obj-$(CONFIG_ACPI_CORE) += smbus_ich9.o
 common-obj-$(CONFIG_APM) += pm_smbus.o
 common-obj-$(CONFIG_BITBANG_I2C) += bitbang_i2c.o
 common-obj-$(CONFIG_EXYNOS4) += exynos4210_i2c.o
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
@ 2015-01-24 16:22   ` Michael S. Tsirkin
  2015-01-26  2:37     ` Shannon Zhao
  2015-01-26 10:19   ` Igor Mammedov
  2015-01-27 12:12   ` Hanjun Guo
  2 siblings, 1 reply; 36+ messages in thread
From: Michael S. Tsirkin @ 2015-01-24 16:22 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, lersek, christoffer.dall

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 <zhaoshenglong@huawei.com>
> ---
>  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 0000000..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 <zhaoshenglong@huawei.com>

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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "hw/arm/virt-acpi-build.h"
> +#include <stddef.h>
> +#include <glib.h>
> +#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             0x20000
> +
> +/* Reserve RAM space for tables: add another order of magnitude. */
> +#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
> +
> +/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
> +{
> +}
> +
> +/* FACS */
> +static void
> +build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* DSDT */
> +static void
> +build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +typedef
> +struct AcpiBuildTables {
> +    AcpiAml table_data;
> +    GArray *rsdp;
> +    GArray *tcpalog;
> +    GArray *linker;
> +} AcpiBuildTables;
> +
> +static inline void acpi_build_tables_init(AcpiBuildTables *tables)
> +{
> +    tables->rsdp = g_array_new(false, true /* clear */, 1);
> +    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
> +    tables->tcpalog = g_array_new(false, true /* clear */, 1);
> +    tables->linker = bios_linker_loader_init();
> +    tables->table_data.linker = tables->linker;
> +}
> +
> +static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
> +{
> +    void *linker_data = bios_linker_loader_cleanup(tables->linker);
> +    g_free(linker_data);
> +    g_array_free(tables->rsdp, mfre);
> +    g_array_free(tables->table_data.buf, true);
> +    g_array_free(tables->tcpalog, mfre);
> +}
> +
> +typedef
> +struct AcpiBuildState {
> +    /* Copy of table in RAM (for patching). */
> +    ram_addr_t table_ram;
> +    uint32_t table_size;
> +    /* Is table patched? */
> +    uint8_t patched;
> +    VirtGuestInfo *guest_info;
> +} AcpiBuildState;
> +
> +static
> +void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
> +{
> +    GArray *table_offsets;
> +    unsigned facs, dsdt, xsdt;
> +
> +    table_offsets = g_array_new(false, true /* clear */,
> +                                        sizeof(uint32_t));
> +    ACPI_BUILD_DPRINTF("init ACPI tables\n");
> +
> +    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
> +                             64 /* Ensure FACS is aligned */,
> +                             false /* high memory */);
> +
> +    /*
> +     * FACS is pointed to by FADT.
> +     * We place it first since it's the only table that has alignment
> +     * requirements.
> +     */
> +    facs = tables->table_data.buf->len;
> +    build_facs(tables->table_data.buf, tables->linker, guest_info);
> +
> +    /* DSDT is pointed to by FADT */
> +    dsdt = tables->table_data.buf->len;
> +    build_dsdt(&tables->table_data, tables->linker, guest_info);
> +
> +    /* ACPI tables pointed to by XSDT */
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
> +
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_madt(tables->table_data.buf, tables->linker, guest_info);
> +
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
> +
> +    /* XSDT is pointed to by RSDP */
> +    xsdt = tables->table_data.buf->len;
> +    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
> +
> +    /* RSDP is in FSEG memory, so allocate it separately */
> +    build_rsdp(tables->rsdp, tables->linker, xsdt);
> +
> +    /* Cleanup memory that's no longer used. */
> +    g_array_free(table_offsets, true);
> +}
> +
> +static ram_addr_t 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, NULL, build_state);
> +}
> +
> +void virt_acpi_setup(VirtGuestInfo *guest_info)
> +{
> +    AcpiBuildTables tables;
> +    AcpiBuildState *build_state;
> +
> +    if (!guest_info->fw_cfg) {
> +        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
> +        return;
> +    }
> +
> +    if (!acpi_enabled) {
> +        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
> +        return;
> +    }
> +
> +    build_state = g_malloc0(sizeof *build_state);
> +    build_state->guest_info = guest_info;
> +
> +    acpi_build_tables_init(&tables);
> +    acpi_build(build_state->guest_info, &tables);
> +
> +    /* Now expose it all to Guest */
> +    build_state->table_ram = acpi_add_rom_blob(build_state,
> +                                               tables.table_data.buf,
> +                                               ACPI_BUILD_TABLE_FILE,
> +                                               ACPI_BUILD_TABLE_MAX_SIZE);
> +    assert(build_state->table_ram != RAM_ADDR_MAX);
> +    build_state->table_size = acpi_data_len(tables.table_data.buf);
> +
> +    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
> +
> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
> +                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
> +
> +    /*
> +     * RSDP is small so it's easy to keep it immutable, no need to
> +     * bother with ROM blobs.
> +     */
> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
> +                    tables.rsdp->data, acpi_data_len(tables.rsdp));
> +
> +    /* Cleanup tables but don't free the memory: we track it
> +     * in build_state.
> +     */
> +    acpi_build_tables_cleanup(&tables, false);
> +}
> diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
> new file mode 100644
> index 0000000..7a09c34
> --- /dev/null
> +++ b/include/hw/arm/virt-acpi-build.h
> @@ -0,0 +1,71 @@
> +/*
> + *
> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> + *
> + * Author: Shannon Zhao <zhaoshenglong@huawei.com>
> + *
> + * 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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef QEMU_VIRT_ACPI_BUILD_H
> +#define QEMU_VIRT_ACPI_BUILD_H
> +
> +#include "qemu-common.h"
> +#include "hw/acpi/acpi-defs.h"
> +
> +
> +#define ACPI_VIRT_QEMU_STR_4 "QEMU"
> +#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
> +#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
> +
> +struct acpi_gtdt_info {
> +    uint32_t timer_virt;
> +    uint32_t timer_s_el1;
> +    uint32_t timer_ns_el1;
> +    uint32_t timer_ns_el2;
> +};
> +
> +struct acpi_madt_info {
> +    const hwaddr *gic_cpu_base_addr;
> +    const hwaddr *gic_dist_base_addr;
> +};
> +
> +struct acpi_dsdt_info {
> +    const hwaddr *uart_addr;
> +    const int *uart_irq;
> +    const hwaddr *virtio_mmio_addr;
> +    const int *virtio_mmio_irq;
> +    int virtio_mmio_num;
> +    const hwaddr *rtc_addr;
> +    const int *rtc_irq;
> +    const hwaddr *flash_addr;
> +};
> +
> +typedef struct VirtGuestInfo {
> +    int nb_cpus;
> +    int max_cpus;
> +    FWCfgState *fw_cfg;
> +    const struct acpi_madt_info *madt_info;
> +    const struct acpi_dsdt_info *dsdt_info;
> +    const struct acpi_gtdt_info *gtdt_info;
> +} VirtGuestInfo;
> +
> +
> +typedef struct VirtGuestInfoState {
> +    VirtGuestInfo info;
> +    Notifier machine_done;
> +} VirtGuestInfoState;
> +
> +void virt_acpi_setup(VirtGuestInfo *guest_info);
> +
> +#endif
> -- 
> 1.7.1
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
@ 2015-01-24 18:56   ` Laszlo Ersek
  2015-01-26  1:59     ` Shannon Zhao
  0 siblings, 1 reply; 36+ messages in thread
From: Laszlo Ersek @ 2015-01-24 18:56 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

On 01/24/15 10:21, Shannon Zhao wrote:
> Expose the needed device information to the table generation
> insfrastructure and register a machine_init_done notify to
> call virt_acpi_build().
> 
> Add CONFIG_ACPI to arm-softmmu.mak, but there is compile error.
> Don't include unnecessary file for ARM. Maybe this way is not
> right, fix me please.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  default-configs/arm-softmmu.mak      |    1 +
>  default-configs/i386-softmmu.mak     |    3 ++
>  default-configs/mips-softmmu.mak     |    3 ++
>  default-configs/mips64-softmmu.mak   |    3 ++
>  default-configs/mips64el-softmmu.mak |    3 ++
>  default-configs/mipsel-softmmu.mak   |    3 ++
>  default-configs/x86_64-softmmu.mak   |    3 ++
>  hw/acpi/Makefile.objs                |    5 ++-
>  hw/arm/virt.c                        |   59 +++++++++++++++++++++++++++++++--
>  hw/i2c/Makefile.objs                 |    2 +-
>  10 files changed, 78 insertions(+), 7 deletions(-)

> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index cad0355..4e3f15f 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -1,5 +1,6 @@
> -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
> -common-obj-$(CONFIG_ACPI) += memory_hotplug.o
> +common-obj-$(CONFIG_ACPI_CORE) += core.o piix4.o ich9.o pcihp.o
> +common-obj-$(CONFIG_ACPI_HOTPLUG) += cpu_hotplug.o

This line has a typo and it breaks the linking of qemu-system-x86_64.
You need to say

  CONFIG_ACPI_CPU_HOTPLUG

here, not

  CONFIG_ACPI_HOTPLUG

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function Shannon Zhao
@ 2015-01-24 22:04   ` Laszlo Ersek
  2015-01-26  1:45     ` Shannon Zhao
  0 siblings, 1 reply; 36+ messages in thread
From: Laszlo Ersek @ 2015-01-24 22:04 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

[-- Attachment #1: Type: text/plain, Size: 2494 bytes --]

comments below, fix attached

On 01/24/15 10:21, Shannon Zhao wrote:
> XDST points to other tables except FACS & DSDT.
> Implement a common header helper functions for generating ACPI tables.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/arm/virt-acpi-build.c    |   34 ++++++++++++++++++++++++++++++++++
>  include/hw/acpi/acpi-defs.h |    9 +++++++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 9c3971a..446947a 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -61,6 +61,22 @@
>  #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
>  #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
>  
> +static void
> +build_header(GArray *linker, GArray *table_data,
> +             AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
> +{
> +    memcpy(&h->signature, sig, sizeof(h->signature));
> +    h->length = cpu_to_le32(len);
> +    h->revision = rev;
> +    memcpy(h->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(h->oem_id));
> +    memcpy(h->oem_table_id, ACPI_VIRT_MACH_STR_8, sizeof(h->oem_table_id));
> +    h->oem_revision = cpu_to_le32(1);
> +    h->checksum = 0;
> +    /* Checksum to be filled in by Guest linker */
> +    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
> +                                    table_data->data, h, len, &h->checksum);
> +}
> +
>  static inline void *acpi_data_push(GArray *table_data, uint64_t size)
>  {
>      unsigned off = table_data->len;
> @@ -115,6 +131,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
>  static void
>  build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
>  {
> +    AcpiXsdtDescriptor *xsdt;
> +    size_t xsdt_len;
> +    int i;
> +
> +    xsdt_len = sizeof(*xsdt) + sizeof(uint64_t) * table_offsets->len;
> +    xsdt = acpi_data_push(table_data, xsdt_len);
> +    memcpy(xsdt->table_offset_entry, table_offsets->data,
> +           sizeof(uint64_t) * table_offsets->len);

This is a bug, but it's not introduced here. The bug is introduced in:

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

I'm attaching the fix.

Please do not squash the fix into this patch; you have to split it up.
The code fixes go into 02/11, and the typo fix goes:

> +    for (i = 0; i < table_offsets->len; ++i) {
> +        /* rsdt->table_offset_entry to be filled by Guest linker */

here.

Thanks,
Laszlo

[-- Attachment #2: 0001-virt-acpi-build-internal-representation-for-XSDT-ent.patch --]
[-- Type: text/x-patch, Size: 3453 bytes --]

>From 899ed2c6329c33520f5bad143dd50508012f1f27 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Sat, 24 Jan 2015 20:43:48 +0100
Subject: [PATCH] virt-acpi-build: internal representation for XSDT entries
 must be uint64_t

The build_xsdt() function copies the data contents of the gradually built
"table_offsets" GArray directly into the XSDT, with memcpy(), using an
element type of uint64_t.

For this to work, the element type of the source array, "table_offsets",
must also be uint64_t.

Otherwise, the XSDT entries will be filled with garbage, pointing outside
of the target blob. edk2's linker/loader catches & rejects the first
pointer:

   Loading driver at 0x000BEE36000 EntryPoint=0x000BEE362B0 AcpiPlatformDxe.efi
   InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BB7BCE98
   ProcessCmdAllocate: File="etc/acpi/rsdp" Alignment=0x10 Zone=2 Size=0x24 Address=0xB7048000
   ProcessCmdAllocate: File="etc/acpi/tables" Alignment=0x40 Zone=1 Size=0xB4E Address=0xB7047000
   ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x49 Start=0x40 Length=0x8CE
   ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x992 PointerSize=8
   ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x99A PointerSize=8
   ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x917 Start=0x90E Length=0x10C
   ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xA23 Start=0xA1A Length=0x90
   ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xAB3 Start=0xAAA Length=0x60
-> ProcessCmdAddPointer: invalid pointer value in "etc/acpi/tables"
   InstallAllQemuLinkedTables: freeing "etc/acpi/rsdp"
   InstallAllQemuLinkedTables: freeing "etc/acpi/tables"
   Error: Image at 000BEE36000 start failed: Protocol Error

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/arm/virt-acpi-build.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 5c76ca2..904fc33 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -94,7 +94,7 @@ static unsigned acpi_data_len(GArray *table)
 
 static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
 {
-    uint32_t offset = cpu_to_le32(table_data->len);
+    uint64_t offset = cpu_to_le64(table_data->len);
     g_array_append_val(table_offsets, offset);
 }
 
@@ -245,7 +245,7 @@ build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
     memcpy(xsdt->table_offset_entry, table_offsets->data,
            sizeof(uint64_t) * table_offsets->len);
     for (i = 0; i < table_offsets->len; ++i) {
-        /* rsdt->table_offset_entry to be filled by Guest linker */
+        /* xsdt->table_offset_entry to be filled by Guest linker */
         bios_linker_loader_add_pointer(linker,
                                        ACPI_BUILD_TABLE_FILE,
                                        ACPI_BUILD_TABLE_FILE,
@@ -425,7 +425,7 @@ void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
     unsigned facs, dsdt, xsdt;
 
     table_offsets = g_array_new(false, true /* clear */,
-                                        sizeof(uint32_t));
+                                        sizeof(uint64_t));
     ACPI_BUILD_DPRINTF("init ACPI tables\n");
 
     bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
@ 2015-01-24 22:05   ` Laszlo Ersek
  2015-01-26  1:48     ` Shannon Zhao
  0 siblings, 1 reply; 36+ messages in thread
From: Laszlo Ersek @ 2015-01-24 22:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

comments below

On 01/24/15 10:21, Shannon Zhao wrote:
> FADT points to FACS and DSDT, in the case of mach virt, it is also used
> to set the Hardware Reduced bit and enable PSCI SMP booting through HVC.
> 
> Update the header definitions for FADT taking into account the new
> additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h`
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/arm/virt-acpi-build.c    |   26 ++++++++++
>  include/hw/acpi/acpi-defs.h |  114 +++++++++++++++++++++++++++++--------------
>  2 files changed, 103 insertions(+), 37 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 2872dff..e3c708d 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -218,6 +218,32 @@ build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
>  static void
>  build_fadt(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
>  {
> +    AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
> +
> +    /* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */

You set "Hardware Reduced" here.

> +    fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
> +    fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
> +                                       (1 << ACPI_FADT_ARM_PSCI_USE_HVC));
> +
> +    /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
> +    fadt->minor_revision = 0x1;
> +
> +    fadt->Xfacs = cpu_to_le64(facs);

But you also set up a FACS table.

Hardware Reduced mode makes Linux ignore the FACS table. Please see
upstream kernel commit

commit 22e5b40ab21fcac21db0ff25fbb844ffecc73a4a
Author: Bob Moore <robert.moore@intel.com>
Date:   Wed Nov 16 10:57:28 2011 +0800

    ACPI 5.0: Implement hardware-reduced option

You can probably drop the generation of the FACS, unless you intend to
disable HW reduced mode.

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM
  2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
                   ` (10 preceding siblings ...)
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
@ 2015-01-24 23:31 ` Laszlo Ersek
  2015-01-26  2:34   ` Shannon Zhao
  11 siblings, 1 reply; 36+ messages in thread
From: Laszlo Ersek @ 2015-01-24 23:31 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

[-- Attachment #1: Type: text/plain, Size: 6115 bytes --]

On 01/24/15 10:21, Shannon Zhao wrote:
> This patch series generate seven ACPI v5.1 tables for machine virt on
> ARM.
> The set of generated tables are:
> - RSDP
> - XSDT
> - MADT
> - GTDT
> - FADT
> - FACS
> - DSDT
>
> These tables are created dynamically using the function of
> acpi-build-utils.c, taking into account the needed information passed
> from the virt machine model. When the generation is finalized, it use
> fw_cfg to expose the tables to guest.
>
> This patchset is based on Igor Mammedov's branch which can be found at
> below git tree:
>  https://github.com/imammedo/qemu/commits/ASL_API_v2

Awesome! I didn't know you had been coordinating with Igor. This is the
best (or, put differently, "only" :)) possible way forward. Great!

> And this patchset refers to Alexander Spyridakis's patches which are
> sent to qemu-devel mailing list before.
>  http://lists.gnu.org/archive/html/qemu-devel/2014-10/msg03987.html
>
> As UEFI (ArmVirtualizationQemu) doesn't support downloading ACPI
> tables over fw_cfg, I just do compile test and start a guest with
> UEFI. But I contacted Laszlo Ersek before, he says that if qemu can
> expose the generated ACPI tables over fw_cfg, he can quickly add
> support in UEFI. So just send this out and make it go forward.

I hope I was quick enough:
- patches: http://thread.gmane.org/gmane.comp.bios.tianocore.devel/12158
- branch: https://github.com/lersek/edk2/commits/armvirt_acpi
- binary: http://people.redhat.com/~lersek/armvirt_acpi/QEMU_EFI.fd

>
> Todo:
> 1) add GPIO controller in virt and expose it through ACPI
> 2) add cpu hotplug support
>
> Any comments are welcome.

I answered with a couple of notes and fixes in the thread. I found those
via testing. I won't offer a code review; I hope you don't mind.

For testing on your end (and for further development) before the edk2
series is applied, you can fetch my patches from github, or even use the
binary I built for you.

Note: the binary includes a very small patch that is not upstream. (Well
it includes some other patches too, but they are not relevant.) This is
it:

> --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
> @@ -87,7 +87,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|FALSE
>
>  [PcdsFixedAtBuild.common]
> -  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8040004F
>
>    gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"QEMU"

It enables the EFI_D_VERBOSE loglevel. The ACPI code logs quite a bit of
info on this loglevel, so if you build an image yourself, be sure to
enable EFI_D_VERBOSE manually. Otherwise you'll only see a part of this
log fragment:

> Loading driver at 0x000BEE66000 EntryPoint=0x000BEE662B0 AcpiPlatformDxe.efi
> InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BB7BBE98
> ProcessCmdAllocate: File="etc/acpi/rsdp" Alignment=0x10 Zone=2 Size=0x24 Address=0xB7048000
> ProcessCmdAllocate: File="etc/acpi/tables" Alignment=0x40 Zone=1 Size=0xBC0 Address=0xB7047000
> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x49 Start=0x40 Length=0x8F4
> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x9B8 PointerSize=8
> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x9C0 PointerSize=8
> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x93D Start=0x934 Length=0x10C
> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xA49 Start=0xA40 Length=0xDC
> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xB25 Start=0xB1C Length=0x60
> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBA0 PointerSize=8
> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBA8 PointerSize=8
> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBB0 PointerSize=8
> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xB85 Start=0xB7C Length=0x44
> ProcessCmdAddPointer: PointerFile="etc/acpi/rsdp" PointeeFile="etc/acpi/tables" PointerOffset=0x18 PointerSize=8
> ProcessCmdAddChecksum: File="etc/acpi/rsdp" ResultOffset=0x8 Start=0x0 Length=0x24
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047000 (remaining: 0xBC0): found "FACS" size 0x40
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047040 (remaining: 0xB80): found "DSDT" size 0x8F4
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047934 (remaining: 0x28C): found "FACP" size 0x10C
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047A40 (remaining: 0x180): found "APIC" size 0xDC
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047B1C (remaining: 0xA4): found "GTDT" size 0x60
> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047B7C (remaining: 0x44): found "XSDT" size 0x44
> InstallAllQemuLinkedTables: installed 5 tables
> InstallAllQemuLinkedTables: freeing "etc/acpi/rsdp"
> InstallAllQemuLinkedTables: freeing "etc/acpi/tables"

Before you ask:
- The fact that RSDP is not listed in the log above is not a problem;
  it's intentional.
- The fact that XSDT (and RSDT, if it were there) is not installed,
  despite being listed, it's intentional too.
- Yes, your code is correct, and you should continue generating those
  things; I need them.
The short explanation is that UEFI handles these tables automatically in
"some place", but I still need them "elsewhere".

So that's why 5 tables are installed for OSPM: FACS, DSDT, FACP, ACPI,
GTDT.

Also, I decompiled those tables that were visible under
/sys/firmware/acpi/tables/ inside the guest. Please find them attached.
The FACS won't be there, but I explained that in another email -- the
kernel ignores the FACS because it sees the hw-reduced mode.

Yay! :)

Thanks
Laszlo

[-- Attachment #2: APIC.dsl --]
[-- Type: text/x-dsl, Size: 4582 bytes --]

/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20140926-64 [Sep 29 2014]
 * Copyright (c) 2000 - 2014 Intel Corporation
 * 
 * Disassembly of APIC, Sat Jan 24 23:58:20 2015
 *
 * ACPI Data Table [APIC]
 *
 * Format: [HexOffset DecimalOffset ByteLength]  FieldName : FieldValue
 */

[000h 0000   4]                    Signature : "APIC"    [Multiple APIC Description Table (MADT)]
[004h 0004   4]                 Table Length : 000000DC
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 34
[00Ah 0010   6]                       Oem ID : "QEMU  "
[010h 0016   8]                 Oem Table ID : "MACHVIRT"
[018h 0024   4]                 Oem Revision : 00000001
[01Ch 0028   4]              Asl Compiler ID : ""
[020h 0032   4]        Asl Compiler Revision : 00000000

[024h 0036   4]           Local Apic Address : 08010000
[028h 0040   4]        Flags (decoded below) : 00000001
                         PC-AT Compatibility : 1

[02Ch 0044   1]                Subtable Type : 0B [Generic Interrupt Controller]
[02Dh 0045   1]                       Length : 4C
[02Eh 0046   2]                     Reserved : 0000
[030h 0048   4]         CPU Interface Number : 00000000
[034h 0052   4]                Processor UID : 00000000
[038h 0056   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1
          Performance Interrupt Trigger Mode : 0
          Virtual GIC Interrupt Trigger Mode : 0
[03Ch 0060   4]     Parking Protocol Version : 00000000
[040h 0064   4]        Performance Interrupt : 00000000
[044h 0068   8]               Parked Address : 0000000000000000
[04Ch 0076   8]                 Base Address : 0000000008010000
[054h 0084   8]     Virtual GIC Base Address : 0000000000000000
[05Ch 0092   8]  Hypervisor GIC Base Address : 0000000000000000
[064h 0100   4]        Virtual GIC Interrupt : 00000000
[068h 0104   8]   Redistributor Base Address : 0000000000000000
[070h 0112   8]                    ARM MPIDR : 0000000000000000

[078h 0120   1]                Subtable Type : 0B [Generic Interrupt Controller]
[079h 0121   1]                       Length : 4C
[07Ah 0122   2]                     Reserved : 0000
[07Ch 0124   4]         CPU Interface Number : 00000001
[080h 0128   4]                Processor UID : 00000001
[084h 0132   4]        Flags (decoded below) : 00000001
                           Processor Enabled : 1
          Performance Interrupt Trigger Mode : 0
          Virtual GIC Interrupt Trigger Mode : 0
[088h 0136   4]     Parking Protocol Version : 00000000
[08Ch 0140   4]        Performance Interrupt : 00000000
[090h 0144   8]               Parked Address : 0000000000000000
[098h 0152   8]                 Base Address : 0000000008010000
[0A0h 0160   8]     Virtual GIC Base Address : 0000000000000000
[0A8h 0168   8]  Hypervisor GIC Base Address : 0000000000000000
[0B0h 0176   4]        Virtual GIC Interrupt : 00000000
[0B4h 0180   8]   Redistributor Base Address : 0000000000000000
[0BCh 0188   8]                    ARM MPIDR : 0000000000000001

[0C4h 0196   1]                Subtable Type : 0C [Generic Interrupt Distributor]
[0C5h 0197   1]                       Length : 18
[0C6h 0198   2]                     Reserved : 0000
[0C8h 0200   4]        Local GIC Hardware ID : 00000000
[0CCh 0204   8]                 Base Address : 0000000008000000
[0D4h 0212   4]               Interrupt Base : 00000000
[0D8h 0216   4]                     Reserved : 00000000

Raw Table Data: Length 220 (0xDC)

  0000: 41 50 49 43 DC 00 00 00 01 34 51 45 4D 55 20 20  APIC.....4QEMU  
  0010: 4D 41 43 48 56 49 52 54 01 00 00 00 00 00 00 00  MACHVIRT........
  0020: 00 00 00 00 00 00 01 08 01 00 00 00 0B 4C 00 00  .............L..
  0030: 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
  0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 08  ................
  0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0070: 00 00 00 00 00 00 00 00 0B 4C 00 00 01 00 00 00  .........L......
  0080: 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
  0090: 00 00 00 00 00 00 00 00 00 00 01 08 00 00 00 00  ................
  00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00B0: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00  ................
  00C0: 00 00 00 00 0C 18 00 00 00 00 00 00 00 00 00 08  ................
  00D0: 00 00 00 00 00 00 00 00 00 00 00 00              ............

[-- Attachment #3: DSDT.dsl --]
[-- Type: text/x-dsl, Size: 22000 bytes --]

/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20140926-64 [Sep 29 2014]
 * Copyright (c) 2000 - 2014 Intel Corporation
 * 
 * Disassembly of DSDT, Sat Jan 24 23:58:20 2015
 *
 * Original Table Header:
 *     Signature        "DSDT"
 *     Length           0x000008F4 (2292)
 *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
 *     Checksum         0xFE
 *     OEM ID           "QEMU"
 *     OEM Table ID     "MACHVIRT"
 *     OEM Revision     0x00000001 (1)
 *     Compiler ID      "BXPC"
 *     Compiler Version 0x00000001 (1)
 */
DefinitionBlock ("DSDT.aml", "DSDT", 1, "QEMU", "MACHVIRT", 0x00000001)
{
    Scope (\_SB)
    {
        Device (CPU0)
        {
            Name (_HID, "ACPI007")  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
            })
        }

        Device (CPU1)
        {
            Name (_HID, "ACPI007")  // _HID: Hardware ID
            Name (_UID, One)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
            })
        }

        Device (COM0)
        {
            Name (_HID, "ARMH0011")  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x09000000,         // Address Base
                    0x00001000,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000021,
                }
            })
        }

        Device (RTC0)
        {
            Name (_HID, "LNRO0013")  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x09010000,         // Address Base
                    0x00001000,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000022,
                }
            })
        }

        Device (FLS0)
        {
            Name (_HID, "LNRO0015")  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x00000000,         // Address Base
                    0x08000000,         // Address Length
                    )
            })
        }

        Device (FLS1)
        {
            Name (_HID, "LNRO0015")  // _HID: Hardware ID
            Name (_UID, One)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x08000000,         // Address Base
                    0x08000000,         // Address Length
                    )
            })
        }

        Device (VR00)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, Zero)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000000,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000030,
                }
            })
        }

        Device (VR01)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, One)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000200,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000031,
                }
            })
        }

        Device (VR02)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x02)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000400,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000032,
                }
            })
        }

        Device (VR03)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x03)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000600,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000033,
                }
            })
        }

        Device (VR04)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x04)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000800,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000034,
                }
            })
        }

        Device (VR05)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x05)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000A00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000035,
                }
            })
        }

        Device (VR06)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x06)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000C00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000036,
                }
            })
        }

        Device (VR07)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x07)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A000E00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000037,
                }
            })
        }

        Device (VR08)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x08)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001000,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000038,
                }
            })
        }

        Device (VR09)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x09)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001200,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000039,
                }
            })
        }

        Device (VR10)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0A)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001400,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003A,
                }
            })
        }

        Device (VR11)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0B)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001600,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003B,
                }
            })
        }

        Device (VR12)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0C)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001800,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003C,
                }
            })
        }

        Device (VR13)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0D)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001A00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003D,
                }
            })
        }

        Device (VR14)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0E)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001C00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003E,
                }
            })
        }

        Device (VR15)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x0F)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A001E00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000003F,
                }
            })
        }

        Device (VR16)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x10)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002000,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000040,
                }
            })
        }

        Device (VR17)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x11)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002200,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000041,
                }
            })
        }

        Device (VR18)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x12)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002400,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000042,
                }
            })
        }

        Device (VR19)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x13)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002600,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000043,
                }
            })
        }

        Device (VR20)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x14)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002800,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000044,
                }
            })
        }

        Device (VR21)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x15)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002A00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000045,
                }
            })
        }

        Device (VR22)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x16)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002C00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000046,
                }
            })
        }

        Device (VR23)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x17)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A002E00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000047,
                }
            })
        }

        Device (VR24)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x18)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003000,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000048,
                }
            })
        }

        Device (VR25)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x19)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003200,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x00000049,
                }
            })
        }

        Device (VR26)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1A)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003400,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004A,
                }
            })
        }

        Device (VR27)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1B)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003600,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004B,
                }
            })
        }

        Device (VR28)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1C)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003800,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004C,
                }
            })
        }

        Device (VR29)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1D)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003A00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004D,
                }
            })
        }

        Device (VR30)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1E)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003C00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004E,
                }
            })
        }

        Device (VR31)
        {
            Name (_HID, "LNRO0005")  // _HID: Hardware ID
            Name (_UID, 0x1F)  // _UID: Unique ID
            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
            {
                Memory32Fixed (ReadWrite,
                    0x0A003E00,         // Address Base
                    0x00000200,         // Address Length
                    )
                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                {
                    0x0000004F,
                }
            })
        }
    }
}


[-- Attachment #4: FACP.dsl --]
[-- Type: text/x-dsl, Size: 9987 bytes --]

/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20140926-64 [Sep 29 2014]
 * Copyright (c) 2000 - 2014 Intel Corporation
 * 
 * Disassembly of FACP, Sat Jan 24 23:58:20 2015
 *
 * ACPI Data Table [FACP]
 *
 * Format: [HexOffset DecimalOffset ByteLength]  FieldName : FieldValue
 */

[000h 0000   4]                    Signature : "FACP"    [Fixed ACPI Description Table (FADT)]
[004h 0004   4]                 Table Length : 0000010C
[008h 0008   1]                     Revision : 05
[009h 0009   1]                     Checksum : B8
[00Ah 0010   6]                       Oem ID : "QEMU  "
[010h 0016   8]                 Oem Table ID : "MACHVIRT"
[018h 0024   4]                 Oem Revision : 00000001
[01Ch 0028   4]              Asl Compiler ID : ""
[020h 0032   4]        Asl Compiler Revision : 00000000

[024h 0036   4]                 FACS Address : B7046000
[028h 0040   4]                 DSDT Address : B7045000
[02Ch 0044   1]                        Model : 00
[02Dh 0045   1]                   PM Profile : 00 [Unspecified]
[02Eh 0046   2]                SCI Interrupt : 0000
[030h 0048   4]             SMI Command Port : 00000000
[034h 0052   1]            ACPI Enable Value : 00
[035h 0053   1]           ACPI Disable Value : 00
[036h 0054   1]               S4BIOS Command : 00
[037h 0055   1]              P-State Control : 00
[038h 0056   4]     PM1A Event Block Address : 00000000
[03Ch 0060   4]     PM1B Event Block Address : 00000000
[040h 0064   4]   PM1A Control Block Address : 00000000
[044h 0068   4]   PM1B Control Block Address : 00000000
[048h 0072   4]    PM2 Control Block Address : 00000000
[04Ch 0076   4]       PM Timer Block Address : 00000000
[050h 0080   4]           GPE0 Block Address : 00000000
[054h 0084   4]           GPE1 Block Address : 00000000
[058h 0088   1]       PM1 Event Block Length : 00
[059h 0089   1]     PM1 Control Block Length : 00
[05Ah 0090   1]     PM2 Control Block Length : 00
[05Bh 0091   1]        PM Timer Block Length : 00
[05Ch 0092   1]            GPE0 Block Length : 00
[05Dh 0093   1]            GPE1 Block Length : 00
[05Eh 0094   1]             GPE1 Base Offset : 00
[05Fh 0095   1]                 _CST Support : 00
[060h 0096   2]                   C2 Latency : 0000
[062h 0098   2]                   C3 Latency : 0000
[064h 0100   2]               CPU Cache Size : 0000
[066h 0102   2]           Cache Flush Stride : 0000
[068h 0104   1]            Duty Cycle Offset : 00
[069h 0105   1]             Duty Cycle Width : 00
[06Ah 0106   1]          RTC Day Alarm Index : 00
[06Bh 0107   1]        RTC Month Alarm Index : 00
[06Ch 0108   1]            RTC Century Index : 00
[06Dh 0109   2]   Boot Flags (decoded below) : 0000
               Legacy Devices Supported (V2) : 0
            8042 Present on ports 60/64 (V2) : 0
                        VGA Not Present (V4) : 0
                      MSI Not Supported (V4) : 0
                PCIe ASPM Not Supported (V4) : 0
                   CMOS RTC Not Present (V5) : 0
[06Fh 0111   1]                     Reserved : 00
[070h 0112   4]        Flags (decoded below) : 00100000
      WBINVD instruction is operational (V1) : 0
              WBINVD flushes all caches (V1) : 0
                    All CPUs support C1 (V1) : 0
                  C2 works on MP system (V1) : 0
            Control Method Power Button (V1) : 0
            Control Method Sleep Button (V1) : 0
        RTC wake not in fixed reg space (V1) : 0
            RTC can wake system from S4 (V1) : 0
                        32-bit PM Timer (V1) : 0
                      Docking Supported (V1) : 0
               Reset Register Supported (V2) : 0
                            Sealed Case (V3) : 0
                    Headless - No Video (V3) : 0
        Use native instr after SLP_TYPx (V3) : 0
              PCIEXP_WAK Bits Supported (V4) : 0
                     Use Platform Timer (V4) : 0
               RTC_STS valid on S4 wake (V4) : 0
                Remote Power-on capable (V4) : 0
                 Use APIC Cluster Model (V4) : 0
     Use APIC Physical Destination Mode (V4) : 0
                       Hardware Reduced (V5) : 1
                      Low Power S0 Idle (V5) : 0

[074h 0116  12]               Reset Register : [Generic Address Structure]
[074h 0116   1]                     Space ID : 00 [SystemMemory]
[075h 0117   1]                    Bit Width : 00
[076h 0118   1]                   Bit Offset : 00
[077h 0119   1]         Encoded Access Width : 00 [Undefined/Legacy]
[078h 0120   8]                      Address : 0000000000000000

[080h 0128   1]         Value to cause reset : 00
[081h 0129   2]    ARM Flags (decoded below) : 0003
                              PSCI Compliant : 1
                       Must use HVC for PSCI : 1

[083h 0131   1]          FADT Minor Revision : 01
[084h 0132   8]                 FACS Address : 0000000000000000
[08Ch 0140   8]                 DSDT Address : 00000000B7045000
[094h 0148  12]             PM1A Event Block : [Generic Address Structure]
[094h 0148   1]                     Space ID : 00 [SystemMemory]
[095h 0149   1]                    Bit Width : 00
[096h 0150   1]                   Bit Offset : 00
[097h 0151   1]         Encoded Access Width : 00 [Undefined/Legacy]
[098h 0152   8]                      Address : 0000000000000000

[0A0h 0160  12]             PM1B Event Block : [Generic Address Structure]
[0A0h 0160   1]                     Space ID : 00 [SystemMemory]
[0A1h 0161   1]                    Bit Width : 00
[0A2h 0162   1]                   Bit Offset : 00
[0A3h 0163   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0A4h 0164   8]                      Address : 0000000000000000

[0ACh 0172  12]           PM1A Control Block : [Generic Address Structure]
[0ACh 0172   1]                     Space ID : 00 [SystemMemory]
[0ADh 0173   1]                    Bit Width : 00
[0AEh 0174   1]                   Bit Offset : 00
[0AFh 0175   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0B0h 0176   8]                      Address : 0000000000000000

[0B8h 0184  12]           PM1B Control Block : [Generic Address Structure]
[0B8h 0184   1]                     Space ID : 00 [SystemMemory]
[0B9h 0185   1]                    Bit Width : 00
[0BAh 0186   1]                   Bit Offset : 00
[0BBh 0187   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0BCh 0188   8]                      Address : 0000000000000000

[0C4h 0196  12]            PM2 Control Block : [Generic Address Structure]
[0C4h 0196   1]                     Space ID : 00 [SystemMemory]
[0C5h 0197   1]                    Bit Width : 00
[0C6h 0198   1]                   Bit Offset : 00
[0C7h 0199   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0C8h 0200   8]                      Address : 0000000000000000

[0D0h 0208  12]               PM Timer Block : [Generic Address Structure]
[0D0h 0208   1]                     Space ID : 00 [SystemMemory]
[0D1h 0209   1]                    Bit Width : 00
[0D2h 0210   1]                   Bit Offset : 00
[0D3h 0211   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0D4h 0212   8]                      Address : 0000000000000000

[0DCh 0220  12]                   GPE0 Block : [Generic Address Structure]
[0DCh 0220   1]                     Space ID : 00 [SystemMemory]
[0DDh 0221   1]                    Bit Width : 00
[0DEh 0222   1]                   Bit Offset : 00
[0DFh 0223   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0E0h 0224   8]                      Address : 0000000000000000

[0E8h 0232  12]                   GPE1 Block : [Generic Address Structure]
[0E8h 0232   1]                     Space ID : 00 [SystemMemory]
[0E9h 0233   1]                    Bit Width : 00
[0EAh 0234   1]                   Bit Offset : 00
[0EBh 0235   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0ECh 0236   8]                      Address : 0000000000000000


[0F4h 0244  12]       Sleep Control Register : [Generic Address Structure]
[0F4h 0244   1]                     Space ID : 00 [SystemMemory]
[0F5h 0245   1]                    Bit Width : 00
[0F6h 0246   1]                   Bit Offset : 00
[0F7h 0247   1]         Encoded Access Width : 00 [Undefined/Legacy]
[0F8h 0248   8]                      Address : 0000000000000000

[100h 0256  12]        Sleep Status Register : [Generic Address Structure]
[100h 0256   1]                     Space ID : 00 [SystemMemory]
[101h 0257   1]                    Bit Width : 00
[102h 0258   1]                   Bit Offset : 00
[103h 0259   1]         Encoded Access Width : 00 [Undefined/Legacy]
[104h 0260   8]                      Address : 0000000000000000


Raw Table Data: Length 268 (0x10C)

  0000: 46 41 43 50 0C 01 00 00 05 B8 51 45 4D 55 20 20  FACP......QEMU  
  0010: 4D 41 43 48 56 49 52 54 01 00 00 00 00 00 00 00  MACHVIRT........
  0020: 00 00 00 00 00 60 04 B7 00 50 04 B7 00 00 00 00  .....`...P......
  0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0070: 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0080: 00 03 00 01 00 00 00 00 00 00 00 00 00 50 04 B7  .............P..
  0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0100: 00 00 00 00 00 00 00 00 00 00 00 00              ............

[-- Attachment #5: GTDT.dsl --]
[-- Type: text/x-dsl, Size: 2643 bytes --]

/*
 * Intel ACPI Component Architecture
 * AML Disassembler version 20140926-64 [Sep 29 2014]
 * Copyright (c) 2000 - 2014 Intel Corporation
 * 
 * Disassembly of GTDT, Sat Jan 24 23:58:20 2015
 *
 * ACPI Data Table [GTDT]
 *
 * Format: [HexOffset DecimalOffset ByteLength]  FieldName : FieldValue
 */

[000h 0000   4]                    Signature : "GTDT"    [Generic Timer Description Table]
[004h 0004   4]                 Table Length : 00000060
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 21
[00Ah 0010   6]                       Oem ID : "QEMU  "
[010h 0016   8]                 Oem Table ID : "MACHVIRT"
[018h 0024   4]                 Oem Revision : 00000001
[01Ch 0028   4]              Asl Compiler ID : ""
[020h 0032   4]        Asl Compiler Revision : 00000000

[024h 0036   8]        Counter Block Address : 0000000000000000
[02Ch 0044   4]                     Reserved : 00000000

[030h 0048   4]         Secure EL1 Interrupt : 0000001D
[034h 0052   4]    EL1 Flags (decoded below) : 00000001
                                Trigger Mode : 1
                                    Polarity : 0
                                   Always On : 0

[038h 0056   4]     Non-Secure EL1 Interrupt : 0000001E
[03Ch 0060   4]   NEL1 Flags (decoded below) : 00000001
                                Trigger Mode : 1
                                    Polarity : 0
                                   Always On : 0

[040h 0064   4]      Virtual Timer Interrupt : 0000001B
[044h 0068   4]     VT Flags (decoded below) : 00000001
                                Trigger Mode : 1
                                    Polarity : 0
                                   Always On : 0

[048h 0072   4]     Non-Secure EL2 Interrupt : 0000001A
[04Ch 0076   4]   NEL2 Flags (decoded below) : 00000001
                                Trigger Mode : 1
                                    Polarity : 0
                                   Always On : 0
[050h 0080   8]   Counter Read Block Address : 0000000000000000

[058h 0088   4]         Platform Timer Count : 00000000
[05Ch 0092   4]        Platform Timer Offset : 00000000

Raw Table Data: Length 96 (0x60)

  0000: 47 54 44 54 60 00 00 00 01 21 51 45 4D 55 20 20  GTDT`....!QEMU  
  0010: 4D 41 43 48 56 49 52 54 01 00 00 00 00 00 00 00  MACHVIRT........
  0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  0030: 1D 00 00 00 01 00 00 00 1E 00 00 00 01 00 00 00  ................
  0040: 1B 00 00 00 01 00 00 00 1A 00 00 00 01 00 00 00  ................
  0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq()
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq() Shannon Zhao
@ 2015-01-25  8:39   ` Michael S. Tsirkin
  2015-01-26  1:58     ` Shannon Zhao
  2015-01-26 10:46     ` Igor Mammedov
  0 siblings, 2 replies; 36+ messages in thread
From: Michael S. Tsirkin @ 2015-01-25  8:39 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, lersek, christoffer.dall

On Sat, Jan 24, 2015 at 05:21:18PM +0800, Shannon Zhao wrote:
> Add acpi_fixed_memory32() for describing device mmio region in resource template.
> Add acpi_extended_irq() for describing device interrupt in resource template.
> These can be used to generating DSDT table for ACPI on ARM.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/acpi/acpi-build-utils.c         |   42 ++++++++++++++++++++++++++++++++++++
>  include/hw/acpi/acpi-build-utils.h |    2 +
>  2 files changed, 44 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
> index 59873e3..211c4d3 100644
> --- a/hw/acpi/acpi-build-utils.c
> +++ b/hw/acpi/acpi-build-utils.c
> @@ -493,6 +493,48 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>  }
>  
>  /*
> + * ACPI 5.1: 19.5.80 Memory32Fixed (Memory Resource Descriptor Macro)

Pls document the first spec which includes a feature, not the last one.

> + *           6.4.2 Small Resource Data Type

So add API for small resource data type?

> + */
> +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag)

so name it memory32_fixed?

> +{
> +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> +    build_append_byte(var.buf, 0x86); /* Extended irq descriptor */
> +    build_append_byte(var.buf, 9);
> +    build_append_byte(var.buf, 0);
> +    build_append_byte(var.buf, rw_flag);
> +    build_append_byte(var.buf, addr & 0xff);
> +    build_append_byte(var.buf, (addr >> 8) & 0xff);
> +    build_append_byte(var.buf, (addr >> 16) & 0xff);
> +    build_append_byte(var.buf, (addr >> 24) & 0xff);
> +
> +    build_append_byte(var.buf, size & 0xff);
> +    build_append_byte(var.buf, (size >> 8) & 0xff);
> +    build_append_byte(var.buf, (size >> 16) & 0xff);
> +    build_append_byte(var.buf, (size >> 24) & 0xff);
> +    return var;
> +}
> +
> +/*
> + * ACPI 5.1: 19.5.61 Interrupt (Interrupt Resource Descriptor Macro)
> + *           6.4.2 Small Resource Data Type
> + */
> +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq)

So acpi_interrupt?

> +{
> +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> +    build_append_byte(var.buf, 0x89); /* Extended irq descriptor */
> +    build_append_byte(var.buf, 6);
> +    build_append_byte(var.buf, 0);
> +    build_append_byte(var.buf, irq_flags);
> +    build_append_byte(var.buf, 0x01);
> +    build_append_byte(var.buf, irq & 0xff);
> +    build_append_byte(var.buf, (irq >> 8) & 0xff);
> +    build_append_byte(var.buf, (irq >> 16) & 0xff);
> +    build_append_byte(var.buf, (irq >> 24) & 0xff);
> +    return var;


Pls add comments to document opcode constants.

> +}
> +
> +/*
>   * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
>   *           6.4.2 Small Resource Data Type
>  */
> diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
> index d39b5b1..bfed546 100644
> --- a/include/hw/acpi/acpi-build-utils.h
> +++ b/include/hw/acpi/acpi-build-utils.h
> @@ -115,6 +115,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
>                     AcpiAml arg3);
>  AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>                     AcpiAml arg3, AcpiAml arg4);
> +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag);
> +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq);
>  AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
>                  uint8_t aln, uint8_t len);
>  AcpiAml acpi_iqr_no_flags(uint8_t irq);
> -- 
> 1.7.1
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function
  2015-01-24 22:04   ` Laszlo Ersek
@ 2015-01-26  1:45     ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  1:45 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

On 2015/1/25 6:04, Laszlo Ersek wrote:
> comments below, fix attached
> 
> On 01/24/15 10:21, Shannon Zhao wrote:
>> XDST points to other tables except FACS & DSDT.
>> Implement a common header helper functions for generating ACPI tables.
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> ---
>>  hw/arm/virt-acpi-build.c    |   34 ++++++++++++++++++++++++++++++++++
>>  include/hw/acpi/acpi-defs.h |    9 +++++++++
>>  2 files changed, 43 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index 9c3971a..446947a 100644
>> --- a/hw/arm/virt-acpi-build.c
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -61,6 +61,22 @@
>>  #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
>>  #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
>>  
>> +static void
>> +build_header(GArray *linker, GArray *table_data,
>> +             AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
>> +{
>> +    memcpy(&h->signature, sig, sizeof(h->signature));
>> +    h->length = cpu_to_le32(len);
>> +    h->revision = rev;
>> +    memcpy(h->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(h->oem_id));
>> +    memcpy(h->oem_table_id, ACPI_VIRT_MACH_STR_8, sizeof(h->oem_table_id));
>> +    h->oem_revision = cpu_to_le32(1);
>> +    h->checksum = 0;
>> +    /* Checksum to be filled in by Guest linker */
>> +    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
>> +                                    table_data->data, h, len, &h->checksum);
>> +}
>> +
>>  static inline void *acpi_data_push(GArray *table_data, uint64_t size)
>>  {
>>      unsigned off = table_data->len;
>> @@ -115,6 +131,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
>>  static void
>>  build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
>>  {
>> +    AcpiXsdtDescriptor *xsdt;
>> +    size_t xsdt_len;
>> +    int i;
>> +
>> +    xsdt_len = sizeof(*xsdt) + sizeof(uint64_t) * table_offsets->len;
>> +    xsdt = acpi_data_push(table_data, xsdt_len);
>> +    memcpy(xsdt->table_offset_entry, table_offsets->data,
>> +           sizeof(uint64_t) * table_offsets->len);
> 
> This is a bug, but it's not introduced here. The bug is introduced in:
> 
>   [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for
>                     building ACPI tables
> 
> I'm attaching the fix.
> 

Greate, thanks. Will fix this at next version.

> Please do not squash the fix into this patch; you have to split it up.
> The code fixes go into 02/11, and the typo fix goes:
> 
>> +    for (i = 0; i < table_offsets->len; ++i) {
>> +        /* rsdt->table_offset_entry to be filled by Guest linker */
> 
> here.
> 
Ok

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers
  2015-01-24 22:05   ` Laszlo Ersek
@ 2015-01-26  1:48     ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  1:48 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

On 2015/1/25 6:05, Laszlo Ersek wrote:
> comments below
> 
> On 01/24/15 10:21, Shannon Zhao wrote:
>> FADT points to FACS and DSDT, in the case of mach virt, it is also used
>> to set the Hardware Reduced bit and enable PSCI SMP booting through HVC.
>>
>> Update the header definitions for FADT taking into account the new
>> additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h`
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> ---
>>  hw/arm/virt-acpi-build.c    |   26 ++++++++++
>>  include/hw/acpi/acpi-defs.h |  114 +++++++++++++++++++++++++++++--------------
>>  2 files changed, 103 insertions(+), 37 deletions(-)
>>
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index 2872dff..e3c708d 100644
>> --- a/hw/arm/virt-acpi-build.c
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -218,6 +218,32 @@ build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
>>  static void
>>  build_fadt(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
>>  {
>> +    AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
>> +
>> +    /* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */
> 
> You set "Hardware Reduced" here.
> 
>> +    fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
>> +    fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
>> +                                       (1 << ACPI_FADT_ARM_PSCI_USE_HVC));
>> +
>> +    /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
>> +    fadt->minor_revision = 0x1;
>> +
>> +    fadt->Xfacs = cpu_to_le64(facs);
> 
> But you also set up a FACS table.
> 
> Hardware Reduced mode makes Linux ignore the FACS table. Please see
> upstream kernel commit
> 
> commit 22e5b40ab21fcac21db0ff25fbb844ffecc73a4a
> Author: Bob Moore <robert.moore@intel.com>
> Date:   Wed Nov 16 10:57:28 2011 +0800
> 
>     ACPI 5.0: Implement hardware-reduced option
> 
> You can probably drop the generation of the FACS, unless you intend to
> disable HW reduced mode.
> 

Ok, Thanks for pointing this out :-)
I think we should drop the FACS to make it simple.

Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq()
  2015-01-25  8:39   ` Michael S. Tsirkin
@ 2015-01-26  1:58     ` Shannon Zhao
  2015-01-26 10:46     ` Igor Mammedov
  1 sibling, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  1:58 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: peter.maydell, hangaohuai, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, lersek, christoffer.dall

Hi MST,

Thanks for your review :-)  Reply below.

On 2015/1/25 16:39, Michael S. Tsirkin wrote:
> On Sat, Jan 24, 2015 at 05:21:18PM +0800, Shannon Zhao wrote:
>> Add acpi_fixed_memory32() for describing device mmio region in resource template.
>> Add acpi_extended_irq() for describing device interrupt in resource template.
>> These can be used to generating DSDT table for ACPI on ARM.
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> ---
>>  hw/acpi/acpi-build-utils.c         |   42 ++++++++++++++++++++++++++++++++++++
>>  include/hw/acpi/acpi-build-utils.h |    2 +
>>  2 files changed, 44 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
>> index 59873e3..211c4d3 100644
>> --- a/hw/acpi/acpi-build-utils.c
>> +++ b/hw/acpi/acpi-build-utils.c
>> @@ -493,6 +493,48 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>>  }
>>  
>>  /*
>> + * ACPI 5.1: 19.5.80 Memory32Fixed (Memory Resource Descriptor Macro)
> 
> Pls document the first spec which includes a feature, not the last one.
> 

Ok, thanks, will fix :-)

>> + *           6.4.2 Small Resource Data Type
> 
> So add API for small resource data type?
> 

Will fix.

>> + */
>> +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag)
> 
> so name it memory32_fixed?
> 

Good idea

>> +{
>> +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
>> +    build_append_byte(var.buf, 0x86); /* Extended irq descriptor */
>> +    build_append_byte(var.buf, 9);
>> +    build_append_byte(var.buf, 0);
>> +    build_append_byte(var.buf, rw_flag);
>> +    build_append_byte(var.buf, addr & 0xff);
>> +    build_append_byte(var.buf, (addr >> 8) & 0xff);
>> +    build_append_byte(var.buf, (addr >> 16) & 0xff);
>> +    build_append_byte(var.buf, (addr >> 24) & 0xff);
>> +
>> +    build_append_byte(var.buf, size & 0xff);
>> +    build_append_byte(var.buf, (size >> 8) & 0xff);
>> +    build_append_byte(var.buf, (size >> 16) & 0xff);
>> +    build_append_byte(var.buf, (size >> 24) & 0xff);
>> +    return var;
>> +}
>> +
>> +/*
>> + * ACPI 5.1: 19.5.61 Interrupt (Interrupt Resource Descriptor Macro)
>> + *           6.4.2 Small Resource Data Type
>> + */
>> +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq)
> 
> So acpi_interrupt?
> 

Ok

>> +{
>> +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
>> +    build_append_byte(var.buf, 0x89); /* Extended irq descriptor */
>> +    build_append_byte(var.buf, 6);
>> +    build_append_byte(var.buf, 0);
>> +    build_append_byte(var.buf, irq_flags);
>> +    build_append_byte(var.buf, 0x01);
>> +    build_append_byte(var.buf, irq & 0xff);
>> +    build_append_byte(var.buf, (irq >> 8) & 0xff);
>> +    build_append_byte(var.buf, (irq >> 16) & 0xff);
>> +    build_append_byte(var.buf, (irq >> 24) & 0xff);
>> +    return var;
> 
> 
> Pls add comments to document opcode constants.
> 

Will add next version.

>> +}
>> +
>> +/*
>>   * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
>>   *           6.4.2 Small Resource Data Type
>>  */
>> diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
>> index d39b5b1..bfed546 100644
>> --- a/include/hw/acpi/acpi-build-utils.h
>> +++ b/include/hw/acpi/acpi-build-utils.h
>> @@ -115,6 +115,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
>>                     AcpiAml arg3);
>>  AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>>                     AcpiAml arg3, AcpiAml arg4);
>> +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag);
>> +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq);
>>  AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
>>                  uint8_t aln, uint8_t len);
>>  AcpiAml acpi_iqr_no_flags(uint8_t irq);
>> -- 
>> 1.7.1
>>
> 
> .
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables
  2015-01-24 18:56   ` Laszlo Ersek
@ 2015-01-26  1:59     ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  1:59 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

On 2015/1/25 2:56, Laszlo Ersek wrote:
> On 01/24/15 10:21, Shannon Zhao wrote:
>> Expose the needed device information to the table generation
>> insfrastructure and register a machine_init_done notify to
>> call virt_acpi_build().
>>
>> Add CONFIG_ACPI to arm-softmmu.mak, but there is compile error.
>> Don't include unnecessary file for ARM. Maybe this way is not
>> right, fix me please.
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> ---
>>  default-configs/arm-softmmu.mak      |    1 +
>>  default-configs/i386-softmmu.mak     |    3 ++
>>  default-configs/mips-softmmu.mak     |    3 ++
>>  default-configs/mips64-softmmu.mak   |    3 ++
>>  default-configs/mips64el-softmmu.mak |    3 ++
>>  default-configs/mipsel-softmmu.mak   |    3 ++
>>  default-configs/x86_64-softmmu.mak   |    3 ++
>>  hw/acpi/Makefile.objs                |    5 ++-
>>  hw/arm/virt.c                        |   59 +++++++++++++++++++++++++++++++--
>>  hw/i2c/Makefile.objs                 |    2 +-
>>  10 files changed, 78 insertions(+), 7 deletions(-)
> 
>> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
>> index cad0355..4e3f15f 100644
>> --- a/hw/acpi/Makefile.objs
>> +++ b/hw/acpi/Makefile.objs
>> @@ -1,5 +1,6 @@
>> -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
>> -common-obj-$(CONFIG_ACPI) += memory_hotplug.o
>> +common-obj-$(CONFIG_ACPI_CORE) += core.o piix4.o ich9.o pcihp.o
>> +common-obj-$(CONFIG_ACPI_HOTPLUG) += cpu_hotplug.o
> 
> This line has a typo and it breaks the linking of qemu-system-x86_64.
> You need to say
> 
>   CONFIG_ACPI_CPU_HOTPLUG
> 
> here, not
> 
>   CONFIG_ACPI_HOTPLUG
> 

Laszlo, Thanks. Will fix this.
Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM
  2015-01-24 23:31 ` [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Laszlo Ersek
@ 2015-01-26  2:34   ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  2:34 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, christoffer.dall

On 2015/1/25 7:31, Laszlo Ersek wrote:
> On 01/24/15 10:21, Shannon Zhao wrote:
>> This patch series generate seven ACPI v5.1 tables for machine virt on
>> ARM.
>> The set of generated tables are:
>> - RSDP
>> - XSDT
>> - MADT
>> - GTDT
>> - FADT
>> - FACS
>> - DSDT
>>
>> These tables are created dynamically using the function of
>> acpi-build-utils.c, taking into account the needed information passed
>> from the virt machine model. When the generation is finalized, it use
>> fw_cfg to expose the tables to guest.
>>
>> This patchset is based on Igor Mammedov's branch which can be found at
>> below git tree:
>>  https://github.com/imammedo/qemu/commits/ASL_API_v2
> 
> Awesome! I didn't know you had been coordinating with Igor. This is the
> best (or, put differently, "only" :)) possible way forward. Great!
> 

Thanks, Laszlo. Igor Mammedov's work is awesome and make the ACPI generation simpler.

>> And this patchset refers to Alexander Spyridakis's patches which are
>> sent to qemu-devel mailing list before.
>>  http://lists.gnu.org/archive/html/qemu-devel/2014-10/msg03987.html
>>
>> As UEFI (ArmVirtualizationQemu) doesn't support downloading ACPI
>> tables over fw_cfg, I just do compile test and start a guest with
>> UEFI. But I contacted Laszlo Ersek before, he says that if qemu can
>> expose the generated ACPI tables over fw_cfg, he can quickly add
>> support in UEFI. So just send this out and make it go forward.
> 
> I hope I was quick enough:
> - patches: http://thread.gmane.org/gmane.comp.bios.tianocore.devel/12158
> - branch: https://github.com/lersek/edk2/commits/armvirt_acpi
> - binary: http://people.redhat.com/~lersek/armvirt_acpi/QEMU_EFI.fd
> 

Great work!

>>
>> Todo:
>> 1) add GPIO controller in virt and expose it through ACPI
>> 2) add cpu hotplug support
>>
>> Any comments are welcome.
> 
> I answered with a couple of notes and fixes in the thread. I found those
> via testing. I won't offer a code review; I hope you don't mind.
> 
> For testing on your end (and for further development) before the edk2
> series is applied, you can fetch my patches from github, or even use the
> binary I built for you.
> 

Ok, thanks.

> Note: the binary includes a very small patch that is not upstream. (Well
> it includes some other patches too, but they are not relevant.) This is
> it:
> 
>> --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
>> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
>> @@ -87,7 +87,7 @@
>>    gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|FALSE
>>
>>  [PcdsFixedAtBuild.common]
>> -  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
>> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8040004F
>>
>>    gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"QEMU"
> 
> It enables the EFI_D_VERBOSE loglevel. The ACPI code logs quite a bit of
> info on this loglevel, so if you build an image yourself, be sure to
> enable EFI_D_VERBOSE manually. Otherwise you'll only see a part of this
> log fragment:
> 

Ok, I see.


>> Loading driver at 0x000BEE66000 EntryPoint=0x000BEE662B0 AcpiPlatformDxe.efi
>> InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BB7BBE98
>> ProcessCmdAllocate: File="etc/acpi/rsdp" Alignment=0x10 Zone=2 Size=0x24 Address=0xB7048000
>> ProcessCmdAllocate: File="etc/acpi/tables" Alignment=0x40 Zone=1 Size=0xBC0 Address=0xB7047000
>> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x49 Start=0x40 Length=0x8F4
>> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x9B8 PointerSize=8
>> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0x9C0 PointerSize=8
>> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0x93D Start=0x934 Length=0x10C
>> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xA49 Start=0xA40 Length=0xDC
>> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xB25 Start=0xB1C Length=0x60
>> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBA0 PointerSize=8
>> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBA8 PointerSize=8
>> ProcessCmdAddPointer: PointerFile="etc/acpi/tables" PointeeFile="etc/acpi/tables" PointerOffset=0xBB0 PointerSize=8
>> ProcessCmdAddChecksum: File="etc/acpi/tables" ResultOffset=0xB85 Start=0xB7C Length=0x44
>> ProcessCmdAddPointer: PointerFile="etc/acpi/rsdp" PointeeFile="etc/acpi/tables" PointerOffset=0x18 PointerSize=8
>> ProcessCmdAddChecksum: File="etc/acpi/rsdp" ResultOffset=0x8 Start=0x0 Length=0x24
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047000 (remaining: 0xBC0): found "FACS" size 0x40
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047040 (remaining: 0xB80): found "DSDT" size 0x8F4
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047934 (remaining: 0x28C): found "FACP" size 0x10C
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047A40 (remaining: 0x180): found "APIC" size 0xDC
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047B1C (remaining: 0xA4): found "GTDT" size 0x60
>> Process2ndPassCmdAddPointer: checking for ACPI header in "etc/acpi/tables" at 0xB7047B7C (remaining: 0x44): found "XSDT" size 0x44
>> InstallAllQemuLinkedTables: installed 5 tables
>> InstallAllQemuLinkedTables: freeing "etc/acpi/rsdp"
>> InstallAllQemuLinkedTables: freeing "etc/acpi/tables"
> 
> Before you ask:
> - The fact that RSDP is not listed in the log above is not a problem;
>   it's intentional.
> - The fact that XSDT (and RSDT, if it were there) is not installed,
>   despite being listed, it's intentional too.
> - Yes, your code is correct, and you should continue generating those
>   things; I need them.
> The short explanation is that UEFI handles these tables automatically in
> "some place", but I still need them "elsewhere".
> 
> So that's why 5 tables are installed for OSPM: FACS, DSDT, FACP, ACPI,
> GTDT.
> 
> Also, I decompiled those tables that were visible under
> /sys/firmware/acpi/tables/ inside the guest. Please find them attached.
> The FACS won't be there, but I explained that in another email -- the
> kernel ignores the FACS because it sees the hw-reduced mode.
> 

Thanks for your explanation and great support.
Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-24 16:22   ` Michael S. Tsirkin
@ 2015-01-26  2:37     ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-26  2:37 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: peter.maydell, hangaohuai, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	imammedo, pbonzini, lersek, christoffer.dall

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 <zhaoshenglong@huawei.com>
>> > ---
>> >  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 0000000..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 <zhaoshenglong@huawei.com>
> 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

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
  2015-01-24 16:22   ` Michael S. Tsirkin
@ 2015-01-26 10:19   ` Igor Mammedov
  2015-01-27  6:47     ` Shannon Zhao
  2015-01-27 12:12   ` Hanjun Guo
  2 siblings, 1 reply; 36+ messages in thread
From: Igor Mammedov @ 2015-01-26 10:19 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On Sat, 24 Jan 2015 17:21:11 +0800
Shannon Zhao <zhaoshenglong@huawei.com> 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 <zhaoshenglong@huawei.com>
> ---
>  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 0000000..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 <zhaoshenglong@huawei.com>
> + *
> + * 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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "hw/arm/virt-acpi-build.h"
> +#include <stddef.h>
> +#include <glib.h>
> +#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             0x20000
> +
> +/* Reserve RAM space for tables: add another order of magnitude. */
> +#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
> +
> +/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
> +{
> +}
> +
> +/* FACS */
> +static void
> +build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +/* DSDT */
> +static void
> +build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
> +{
> +}
> +
> +typedef
> +struct AcpiBuildTables {
> +    AcpiAml table_data;
> +    GArray *rsdp;
> +    GArray *tcpalog;
> +    GArray *linker;
> +} AcpiBuildTables;
> +
> +static inline void acpi_build_tables_init(AcpiBuildTables *tables)
> +{
> +    tables->rsdp = g_array_new(false, true /* clear */, 1);
> +    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
> +    tables->tcpalog = g_array_new(false, true /* clear */, 1);
> +    tables->linker = bios_linker_loader_init();
> +    tables->table_data.linker = tables->linker;
> +}
> +
> +static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
> +{
> +    void *linker_data = bios_linker_loader_cleanup(tables->linker);
> +    g_free(linker_data);
> +    g_array_free(tables->rsdp, mfre);
> +    g_array_free(tables->table_data.buf, true);
> +    g_array_free(tables->tcpalog, mfre);
> +}
> +
> +typedef
> +struct AcpiBuildState {
> +    /* Copy of table in RAM (for patching). */
> +    ram_addr_t table_ram;
> +    uint32_t table_size;
> +    /* Is table patched? */
> +    uint8_t patched;
> +    VirtGuestInfo *guest_info;
> +} AcpiBuildState;
> +
> +static
> +void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
> +{
> +    GArray *table_offsets;
> +    unsigned facs, dsdt, xsdt;
> +
> +    table_offsets = g_array_new(false, true /* clear */,
> +                                        sizeof(uint32_t));
> +    ACPI_BUILD_DPRINTF("init ACPI tables\n");
use tracing infrastructure instead of DPRINTFs

> +
> +    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
> +                             64 /* Ensure FACS is aligned */,
> +                             false /* high memory */);
> +
> +    /*
> +     * FACS is pointed to by FADT.
> +     * We place it first since it's the only table that has alignment
> +     * requirements.
> +     */
> +    facs = tables->table_data.buf->len;
> +    build_facs(tables->table_data.buf, tables->linker, guest_info);
> +
> +    /* DSDT is pointed to by FADT */
> +    dsdt = tables->table_data.buf->len;
> +    build_dsdt(&tables->table_data, tables->linker, guest_info);
> +
> +    /* ACPI tables pointed to by XSDT */
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
> +
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_madt(tables->table_data.buf, tables->linker, guest_info);
> +
> +    acpi_add_table(table_offsets, tables->table_data.buf);
> +    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
> +
> +    /* XSDT is pointed to by RSDP */
> +    xsdt = tables->table_data.buf->len;
> +    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
> +
> +    /* RSDP is in FSEG memory, so allocate it separately */
> +    build_rsdp(tables->rsdp, tables->linker, xsdt);
> +
> +    /* Cleanup memory that's no longer used. */
> +    g_array_free(table_offsets, true);
> +}
> +
> +static ram_addr_t 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, NULL, build_state);
> +}
> +
> +void virt_acpi_setup(VirtGuestInfo *guest_info)
> +{
> +    AcpiBuildTables tables;
> +    AcpiBuildState *build_state;
> +
> +    if (!guest_info->fw_cfg) {
> +        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
> +        return;
> +    }
> +
> +    if (!acpi_enabled) {
> +        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
> +        return;
> +    }
> +
> +    build_state = g_malloc0(sizeof *build_state);
> +    build_state->guest_info = guest_info;
> +
> +    acpi_build_tables_init(&tables);
> +    acpi_build(build_state->guest_info, &tables);
> +
> +    /* Now expose it all to Guest */
> +    build_state->table_ram = acpi_add_rom_blob(build_state,
> +                                               tables.table_data.buf,
> +                                               ACPI_BUILD_TABLE_FILE,
> +                                               ACPI_BUILD_TABLE_MAX_SIZE);
> +    assert(build_state->table_ram != RAM_ADDR_MAX);
> +    build_state->table_size = acpi_data_len(tables.table_data.buf);
> +
> +    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
> +
> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
> +                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
> +
> +    /*
> +     * RSDP is small so it's easy to keep it immutable, no need to
> +     * bother with ROM blobs.
> +     */
> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
> +                    tables.rsdp->data, acpi_data_len(tables.rsdp));
that's broken since position of RSDT could change on reboot and initial RSDP
would point to a wrong offset afterwards. Ith should be rom_blob as well
which is re-creatable on reboot as ACPI_BUILD_TABLE_FILE.


> +
> +    /* Cleanup tables but don't free the memory: we track it
> +     * in build_state.
> +     */
> +    acpi_build_tables_cleanup(&tables, false);
> +}
> diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
> new file mode 100644
> index 0000000..7a09c34
> --- /dev/null
> +++ b/include/hw/arm/virt-acpi-build.h
> @@ -0,0 +1,71 @@
> +/*
> + *
> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> + *
> + * Author: Shannon Zhao <zhaoshenglong@huawei.com>
> + *
> + * 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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef QEMU_VIRT_ACPI_BUILD_H
> +#define QEMU_VIRT_ACPI_BUILD_H
> +
> +#include "qemu-common.h"
> +#include "hw/acpi/acpi-defs.h"
> +
> +
> +#define ACPI_VIRT_QEMU_STR_4 "QEMU"
> +#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
> +#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
> +
> +struct acpi_gtdt_info {
> +    uint32_t timer_virt;
> +    uint32_t timer_s_el1;
> +    uint32_t timer_ns_el1;
> +    uint32_t timer_ns_el2;
> +};
> +
> +struct acpi_madt_info {
> +    const hwaddr *gic_cpu_base_addr;
> +    const hwaddr *gic_dist_base_addr;
> +};
> +
> +struct acpi_dsdt_info {
> +    const hwaddr *uart_addr;
> +    const int *uart_irq;
> +    const hwaddr *virtio_mmio_addr;
> +    const int *virtio_mmio_irq;
> +    int virtio_mmio_num;
> +    const hwaddr *rtc_addr;
> +    const int *rtc_irq;
> +    const hwaddr *flash_addr;
> +};
> +
> +typedef struct VirtGuestInfo {
> +    int nb_cpus;
> +    int max_cpus;
> +    FWCfgState *fw_cfg;
> +    const struct acpi_madt_info *madt_info;
> +    const struct acpi_dsdt_info *dsdt_info;
> +    const struct acpi_gtdt_info *gtdt_info;
> +} VirtGuestInfo;
> +
> +
> +typedef struct VirtGuestInfoState {
> +    VirtGuestInfo info;
> +    Notifier machine_done;
> +} VirtGuestInfoState;
> +
> +void virt_acpi_setup(VirtGuestInfo *guest_info);
> +
> +#endif

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
@ 2015-01-26 10:22   ` Igor Mammedov
  2015-01-27  6:50     ` Shannon Zhao
  2015-01-27  9:36     ` Shannon Zhao
  0 siblings, 2 replies; 36+ messages in thread
From: Igor Mammedov @ 2015-01-26 10:22 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On Sat, 24 Jan 2015 17:21:12 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> RSDP points to XSDT which in turn points to other tables.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/arm/virt-acpi-build.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 4eed0a3..9c3971a 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -86,6 +86,28 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>  static GArray *
>  build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
>  {
> +    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
> +
> +    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
> +                             true /* fseg memory */);
> +
> +    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
> +    memcpy(rsdp->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(rsdp->oem_id));
> +    rsdp->length = cpu_to_le32(sizeof(*rsdp));
> +    rsdp->revision = 0x02;
> +
> +    /* Point to XSDT */
> +    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
RSDP should be created after XSDT so XSDT pointer would be correct,
perhaps it's wrong patch ordering

> +    /* Address to be filled by Guest linker */
> +    bios_linker_loader_add_pointer(linker, ACPI_BUILD_RSDP_FILE,
> +                                   ACPI_BUILD_TABLE_FILE,
> +                                   rsdp_table, &rsdp->xsdt_physical_address,
> +                                   sizeof rsdp->xsdt_physical_address);
> +    rsdp->checksum = 0;
> +    /* Checksum to be filled by Guest linker */
> +    bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
> +                                    rsdp, rsdp, sizeof *rsdp, &rsdp->checksum);
> +
>      return rsdp_table;
>  }
>  

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
@ 2015-01-26 10:40   ` Igor Mammedov
  2015-01-27  7:19     ` Shannon Zhao
  0 siblings, 1 reply; 36+ messages in thread
From: Igor Mammedov @ 2015-01-26 10:40 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On Sat, 24 Jan 2015 17:21:19 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> DSDT consists of the usual common table header plus a definition
> block in AML encoding which describes all devices in the platform.
> 
> After initializing DSDT with header information the namespace is
> created which is followed by the device encodings. The devices are
> described using the Resource Template for the 32-Bit Fixed Memory
> Range and the Extended Interrupt Descriptors.
> 
> The following devices are included in the DSDT:
> - CPUs
> - UART
> - RTC
> - NAND Flash
> - virtio-mmio
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/arm/virt-acpi-build.c |  120 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 120 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index de1f307..5c76ca2 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -98,6 +98,111 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>      g_array_append_val(table_offsets, offset);
>  }
>  
> +static void acpi_dsdt_add_cpus(AcpiAml *scope, int smp_cpus)
> +{
> +    AcpiAml dev, crs;
> +    int i;
> +    char name[5];
> +    for (i = 0; i < smp_cpus; i++) {
I'm not sure about ARM butm shouldn't not present but possble CPUs
also described here?

PS:
One more thing about CPU hotplug, I'd like current (x86) bitmap based
QEMU<->APCI interface (which scales only upto 256 CPU) have redone
to a one similar to memory hotplug first.
So that ARM wouldn't have to support compatibility mode for it in the future.


> +        snprintf(name, 5, "CPU%u", i);
> +        dev = acpi_device("%s", name);
> +        aml_append(&dev, acpi_name_decl("_HID", acpi_string("ACPI007")));
> +        aml_append(&dev, acpi_name_decl("_UID", acpi_int(i)));
> +        crs = acpi_resource_template();
> +        aml_append(&dev, acpi_name_decl("_CRS", crs));
> +        aml_append(scope, dev);
> +    }
> +}
> +
> +static void acpi_dsdt_add_uart(AcpiAml *scope, const hwaddr *uart_addr,
> +                                               const int *uart_irq)
> +{
> +    AcpiAml dev, crs;
> +
> +    dev = acpi_device("COM0");
> +    aml_append(&dev, acpi_name_decl("_HID", acpi_string("ARMH0011")));
> +    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
> +
> +    crs = acpi_resource_template();
> +    aml_append(&crs,
> +               acpi_fixed_memory32(uart_addr[0], uart_addr[1], 0x01));
> +    aml_append(&crs,
> +               acpi_extended_irq(0x01, *uart_irq + 32));
> +    aml_append(&dev, acpi_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +}
> +
> +static void acpi_dsdt_add_rtc(AcpiAml *scope, const hwaddr *rtc_addr,
> +                                              const int *rtc_irq)
> +{
> +    AcpiAml dev, crs;
> +
> +    dev = acpi_device("RTC0");
> +    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0013")));
> +    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
> +
> +    crs = acpi_resource_template();
> +    aml_append(&crs,
> +               acpi_fixed_memory32(rtc_addr[0], rtc_addr[1], 0x01));
> +    aml_append(&crs,
> +               acpi_extended_irq(0x01, *rtc_irq + 32));
> +    aml_append(&dev, acpi_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +}
> +
> +static void acpi_dsdt_add_flash(AcpiAml *scope, const hwaddr *flash_addr)
> +{
> +    AcpiAml dev, crs;
> +    hwaddr base = flash_addr[0];
> +    hwaddr size = flash_addr[1];
> +
> +    dev = acpi_device("FLS0");
> +    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0015")));
> +    aml_append(&dev, acpi_name_decl("_UID", acpi_int(0)));
> +
> +    crs = acpi_resource_template();
> +    aml_append(&crs,
> +               acpi_fixed_memory32(base, size, 0x01));
> +    aml_append(&dev, acpi_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +
> +    dev = acpi_device("FLS1");
> +    aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0015")));
> +    aml_append(&dev, acpi_name_decl("_UID", acpi_int(1)));
> +    crs = acpi_resource_template();
> +    aml_append(&crs,
> +               acpi_fixed_memory32(base + size, size, 0x01));
> +    aml_append(&dev, acpi_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +}
> +
> +static void acpi_dsdt_add_virtio(AcpiAml *scope, const hwaddr *mmio_addrs,
> +                                                 const int *mmio_irq, int num)
> +{
> +    AcpiAml dev, crs;
> +    hwaddr base = mmio_addrs[0];
> +    hwaddr size = mmio_addrs[1];
> +    int irq = *mmio_irq + 32;
> +    int i;
> +    char name[5];
> +
> +    for (i = 0; i < num; i++) {
> +        snprintf(name, 5, "VR%02u", i);
> +        dev = acpi_device("%s", name);
> +        aml_append(&dev, acpi_name_decl("_HID", acpi_string("LNRO0005")));
> +        aml_append(&dev, acpi_name_decl("_UID", acpi_int(i)));
> +
> +        crs = acpi_resource_template();
> +        aml_append(&crs,
> +                   acpi_fixed_memory32(base, size, 0x01));
> +        aml_append(&crs,
> +                   acpi_extended_irq(0x01, irq + i));
> +        aml_append(&dev, acpi_name_decl("_CRS", crs));
> +        aml_append(scope, dev);
> +        base += size;
> +    }
> +}
> +
>  /* RSDP */
>  static GArray *
>  build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
> @@ -260,6 +365,21 @@ build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
>  static void
>  build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
>  {
> +    AcpiAml scope, dsdt;
> +    const struct acpi_dsdt_info *info = guest_info->dsdt_info;
> +
> +    dsdt = acpi_def_block("DSDT", 1, ACPI_VIRT_QEMU_STR_4,
> +                                     ACPI_VIRT_MACH_STR_8, 1);
> +    scope = acpi_scope("\\_SB");
> +    acpi_dsdt_add_cpus(&scope, guest_info->nb_cpus);
> +    acpi_dsdt_add_uart(&scope, info->uart_addr, info->uart_irq);
> +    acpi_dsdt_add_rtc(&scope, info->rtc_addr, info->rtc_irq);
> +    acpi_dsdt_add_flash(&scope, info->flash_addr);
> +    acpi_dsdt_add_virtio(&scope, info->virtio_mmio_addr,
> +             info->virtio_mmio_irq, info->virtio_mmio_num);
> +
> +    aml_append(&dsdt, scope);
> +    aml_append(table_aml, dsdt);
>  }
>  
>  typedef

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq()
  2015-01-25  8:39   ` Michael S. Tsirkin
  2015-01-26  1:58     ` Shannon Zhao
@ 2015-01-26 10:46     ` Igor Mammedov
  1 sibling, 0 replies; 36+ messages in thread
From: Igor Mammedov @ 2015-01-26 10:46 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: peter.maydell, hangaohuai, a.spyridakis, claudio.fontana,
	qemu-devel, wanghaibin.wang, peter.huangpeng, hanjun.guo,
	Shannon Zhao, pbonzini, lersek, christoffer.dall

On Sun, 25 Jan 2015 10:39:21 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Sat, Jan 24, 2015 at 05:21:18PM +0800, Shannon Zhao wrote:
> > Add acpi_fixed_memory32() for describing device mmio region in resource template.
> > Add acpi_extended_irq() for describing device interrupt in resource template.
> > These can be used to generating DSDT table for ACPI on ARM.
> > 
> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> > ---
> >  hw/acpi/acpi-build-utils.c         |   42 ++++++++++++++++++++++++++++++++++++
> >  include/hw/acpi/acpi-build-utils.h |    2 +
> >  2 files changed, 44 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
> > index 59873e3..211c4d3 100644
> > --- a/hw/acpi/acpi-build-utils.c
> > +++ b/hw/acpi/acpi-build-utils.c
> > @@ -493,6 +493,48 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
> >  }
> >  
> >  /*
> > + * ACPI 5.1: 19.5.80 Memory32Fixed (Memory Resource Descriptor Macro)
> 
> Pls document the first spec which includes a feature, not the last one.
> 
> > + *           6.4.2 Small Resource Data Type
> 
> So add API for small resource data type?
Probably not worth it, I'll take a closer look at it since
I add quite a bit of resources in initial series, so
helper to compose header might save some LOCs.

But it shouldn't be externally available API since it's
lowlevel concept basically reflecting header format
with variable amount of bytes after it depending on type.

> 
> > + */
> > +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag)
> 
> so name it memory32_fixed?
> 
> > +{
> > +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> > +    build_append_byte(var.buf, 0x86); /* Extended irq descriptor */
> > +    build_append_byte(var.buf, 9);
> > +    build_append_byte(var.buf, 0);
> > +    build_append_byte(var.buf, rw_flag);
> > +    build_append_byte(var.buf, addr & 0xff);
> > +    build_append_byte(var.buf, (addr >> 8) & 0xff);
> > +    build_append_byte(var.buf, (addr >> 16) & 0xff);
> > +    build_append_byte(var.buf, (addr >> 24) & 0xff);
> > +
> > +    build_append_byte(var.buf, size & 0xff);
> > +    build_append_byte(var.buf, (size >> 8) & 0xff);
> > +    build_append_byte(var.buf, (size >> 16) & 0xff);
> > +    build_append_byte(var.buf, (size >> 24) & 0xff);
> > +    return var;
> > +}
> > +
> > +/*
> > + * ACPI 5.1: 19.5.61 Interrupt (Interrupt Resource Descriptor Macro)
> > + *           6.4.2 Small Resource Data Type
> > + */
> > +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq)
> 
> So acpi_interrupt?
> 
> > +{
> > +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> > +    build_append_byte(var.buf, 0x89); /* Extended irq descriptor */
> > +    build_append_byte(var.buf, 6);
> > +    build_append_byte(var.buf, 0);
> > +    build_append_byte(var.buf, irq_flags);
> > +    build_append_byte(var.buf, 0x01);
> > +    build_append_byte(var.buf, irq & 0xff);
> > +    build_append_byte(var.buf, (irq >> 8) & 0xff);
> > +    build_append_byte(var.buf, (irq >> 16) & 0xff);
> > +    build_append_byte(var.buf, (irq >> 24) & 0xff);
> > +    return var;
> 
> 
> Pls add comments to document opcode constants.
> 
> > +}
> > +
> > +/*
> >   * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
> >   *           6.4.2 Small Resource Data Type
> >  */
> > diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
> > index d39b5b1..bfed546 100644
> > --- a/include/hw/acpi/acpi-build-utils.h
> > +++ b/include/hw/acpi/acpi-build-utils.h
> > @@ -115,6 +115,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
> >                     AcpiAml arg3);
> >  AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
> >                     AcpiAml arg3, AcpiAml arg4);
> > +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag);
> > +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq);
> >  AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
> >                  uint8_t aln, uint8_t len);
> >  AcpiAml acpi_iqr_no_flags(uint8_t irq);
> > -- 
> > 1.7.1
> > 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-26 10:19   ` Igor Mammedov
@ 2015-01-27  6:47     ` Shannon Zhao
  2015-01-27 10:30       ` Igor Mammedov
  0 siblings, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-27  6:47 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On 2015/1/26 18:19, Igor Mammedov wrote:
> On Sat, 24 Jan 2015 17:21:11 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> 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 <zhaoshenglong@huawei.com>
>> ---
>>  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 0000000..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 <zhaoshenglong@huawei.com>
>> + *
>> + * 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 <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include "hw/arm/virt-acpi-build.h"
>> +#include <stddef.h>
>> +#include <glib.h>
>> +#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             0x20000
>> +
>> +/* Reserve RAM space for tables: add another order of magnitude. */
>> +#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
>> +
>> +/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
>> +{
>> +}
>> +
>> +/* FACS */
>> +static void
>> +build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
>> +{
>> +}
>> +
>> +/* DSDT */
>> +static void
>> +build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
>> +{
>> +}
>> +
>> +typedef
>> +struct AcpiBuildTables {
>> +    AcpiAml table_data;
>> +    GArray *rsdp;
>> +    GArray *tcpalog;
>> +    GArray *linker;
>> +} AcpiBuildTables;
>> +
>> +static inline void acpi_build_tables_init(AcpiBuildTables *tables)
>> +{
>> +    tables->rsdp = g_array_new(false, true /* clear */, 1);
>> +    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
>> +    tables->tcpalog = g_array_new(false, true /* clear */, 1);
>> +    tables->linker = bios_linker_loader_init();
>> +    tables->table_data.linker = tables->linker;
>> +}
>> +
>> +static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
>> +{
>> +    void *linker_data = bios_linker_loader_cleanup(tables->linker);
>> +    g_free(linker_data);
>> +    g_array_free(tables->rsdp, mfre);
>> +    g_array_free(tables->table_data.buf, true);
>> +    g_array_free(tables->tcpalog, mfre);
>> +}
>> +
>> +typedef
>> +struct AcpiBuildState {
>> +    /* Copy of table in RAM (for patching). */
>> +    ram_addr_t table_ram;
>> +    uint32_t table_size;
>> +    /* Is table patched? */
>> +    uint8_t patched;
>> +    VirtGuestInfo *guest_info;
>> +} AcpiBuildState;
>> +
>> +static
>> +void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
>> +{
>> +    GArray *table_offsets;
>> +    unsigned facs, dsdt, xsdt;
>> +
>> +    table_offsets = g_array_new(false, true /* clear */,
>> +                                        sizeof(uint32_t));
>> +    ACPI_BUILD_DPRINTF("init ACPI tables\n");
> use tracing infrastructure instead of DPRINTFs
> 
>> +
>> +    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
>> +                             64 /* Ensure FACS is aligned */,
>> +                             false /* high memory */);
>> +
>> +    /*
>> +     * FACS is pointed to by FADT.
>> +     * We place it first since it's the only table that has alignment
>> +     * requirements.
>> +     */
>> +    facs = tables->table_data.buf->len;
>> +    build_facs(tables->table_data.buf, tables->linker, guest_info);
>> +
>> +    /* DSDT is pointed to by FADT */
>> +    dsdt = tables->table_data.buf->len;
>> +    build_dsdt(&tables->table_data, tables->linker, guest_info);
>> +
>> +    /* ACPI tables pointed to by XSDT */
>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>> +    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
>> +
>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>> +    build_madt(tables->table_data.buf, tables->linker, guest_info);
>> +
>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>> +    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
>> +
>> +    /* XSDT is pointed to by RSDP */
>> +    xsdt = tables->table_data.buf->len;
>> +    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
>> +
>> +    /* RSDP is in FSEG memory, so allocate it separately */
>> +    build_rsdp(tables->rsdp, tables->linker, xsdt);
>> +
>> +    /* Cleanup memory that's no longer used. */
>> +    g_array_free(table_offsets, true);
>> +}
>> +
>> +static ram_addr_t 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, NULL, build_state);
>> +}
>> +
>> +void virt_acpi_setup(VirtGuestInfo *guest_info)
>> +{
>> +    AcpiBuildTables tables;
>> +    AcpiBuildState *build_state;
>> +
>> +    if (!guest_info->fw_cfg) {
>> +        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
>> +        return;
>> +    }
>> +
>> +    if (!acpi_enabled) {
>> +        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
>> +        return;
>> +    }
>> +
>> +    build_state = g_malloc0(sizeof *build_state);
>> +    build_state->guest_info = guest_info;
>> +
>> +    acpi_build_tables_init(&tables);
>> +    acpi_build(build_state->guest_info, &tables);
>> +
>> +    /* Now expose it all to Guest */
>> +    build_state->table_ram = acpi_add_rom_blob(build_state,
>> +                                               tables.table_data.buf,
>> +                                               ACPI_BUILD_TABLE_FILE,
>> +                                               ACPI_BUILD_TABLE_MAX_SIZE);
>> +    assert(build_state->table_ram != RAM_ADDR_MAX);
>> +    build_state->table_size = acpi_data_len(tables.table_data.buf);
>> +
>> +    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
>> +
>> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
>> +                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
>> +
>> +    /*
>> +     * RSDP is small so it's easy to keep it immutable, no need to
>> +     * bother with ROM blobs.
>> +     */
>> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
>> +                    tables.rsdp->data, acpi_data_len(tables.rsdp));
> that's broken since position of RSDT could change on reboot and initial RSDP
> would point to a wrong offset afterwards. Ith should be rom_blob as well
> which is re-creatable on reboot as ACPI_BUILD_TABLE_FILE.
> 
> 

Sorry, I'm not clear about your comment. I did inside reboot and outside reset, it looks well.

>> +
>> +    /* Cleanup tables but don't free the memory: we track it
>> +     * in build_state.
>> +     */
>> +    acpi_build_tables_cleanup(&tables, false);
>> +}
>> diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
>> new file mode 100644
>> index 0000000..7a09c34
>> --- /dev/null
>> +++ b/include/hw/arm/virt-acpi-build.h
>> @@ -0,0 +1,71 @@
>> +/*
>> + *
>> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
>> + *
>> + * Author: Shannon Zhao <zhaoshenglong@huawei.com>
>> + *
>> + * 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 <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#ifndef QEMU_VIRT_ACPI_BUILD_H
>> +#define QEMU_VIRT_ACPI_BUILD_H
>> +
>> +#include "qemu-common.h"
>> +#include "hw/acpi/acpi-defs.h"
>> +
>> +
>> +#define ACPI_VIRT_QEMU_STR_4 "QEMU"
>> +#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
>> +#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
>> +
>> +struct acpi_gtdt_info {
>> +    uint32_t timer_virt;
>> +    uint32_t timer_s_el1;
>> +    uint32_t timer_ns_el1;
>> +    uint32_t timer_ns_el2;
>> +};
>> +
>> +struct acpi_madt_info {
>> +    const hwaddr *gic_cpu_base_addr;
>> +    const hwaddr *gic_dist_base_addr;
>> +};
>> +
>> +struct acpi_dsdt_info {
>> +    const hwaddr *uart_addr;
>> +    const int *uart_irq;
>> +    const hwaddr *virtio_mmio_addr;
>> +    const int *virtio_mmio_irq;
>> +    int virtio_mmio_num;
>> +    const hwaddr *rtc_addr;
>> +    const int *rtc_irq;
>> +    const hwaddr *flash_addr;
>> +};
>> +
>> +typedef struct VirtGuestInfo {
>> +    int nb_cpus;
>> +    int max_cpus;
>> +    FWCfgState *fw_cfg;
>> +    const struct acpi_madt_info *madt_info;
>> +    const struct acpi_dsdt_info *dsdt_info;
>> +    const struct acpi_gtdt_info *gtdt_info;
>> +} VirtGuestInfo;
>> +
>> +
>> +typedef struct VirtGuestInfoState {
>> +    VirtGuestInfo info;
>> +    Notifier machine_done;
>> +} VirtGuestInfoState;
>> +
>> +void virt_acpi_setup(VirtGuestInfo *guest_info);
>> +
>> +#endif
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table
  2015-01-26 10:22   ` Igor Mammedov
@ 2015-01-27  6:50     ` Shannon Zhao
  2015-01-27  9:36     ` Shannon Zhao
  1 sibling, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-27  6:50 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On 2015/1/26 18:22, Igor Mammedov wrote:
> On Sat, 24 Jan 2015 17:21:12 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> 
>> > RSDP points to XSDT which in turn points to other tables.
>> > 
>> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> > ---
>> >  hw/arm/virt-acpi-build.c |   22 ++++++++++++++++++++++
>> >  1 files changed, 22 insertions(+), 0 deletions(-)
>> > 
>> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> > index 4eed0a3..9c3971a 100644
>> > --- a/hw/arm/virt-acpi-build.c
>> > +++ b/hw/arm/virt-acpi-build.c
>> > @@ -86,6 +86,28 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>> >  static GArray *
>> >  build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
>> >  {
>> > +    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
>> > +
>> > +    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
>> > +                             true /* fseg memory */);
>> > +
>> > +    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
>> > +    memcpy(rsdp->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(rsdp->oem_id));
>> > +    rsdp->length = cpu_to_le32(sizeof(*rsdp));
>> > +    rsdp->revision = 0x02;
>> > +
>> > +    /* Point to XSDT */
>> > +    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
> RSDP should be created after XSDT so XSDT pointer would be correct,
> perhaps it's wrong patch ordering
> 

Thanks for pointing this out. Will fix it.

Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices
  2015-01-26 10:40   ` Igor Mammedov
@ 2015-01-27  7:19     ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-27  7:19 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On 2015/1/26 18:40, Igor Mammedov wrote:
> On Sat, 24 Jan 2015 17:21:19 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> 
>> > DSDT consists of the usual common table header plus a definition
>> > block in AML encoding which describes all devices in the platform.
>> > 
>> > After initializing DSDT with header information the namespace is
>> > created which is followed by the device encodings. The devices are
>> > described using the Resource Template for the 32-Bit Fixed Memory
>> > Range and the Extended Interrupt Descriptors.
>> > 
>> > The following devices are included in the DSDT:
>> > - CPUs
>> > - UART
>> > - RTC
>> > - NAND Flash
>> > - virtio-mmio
>> > 
>> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> > ---
>> >  hw/arm/virt-acpi-build.c |  120 ++++++++++++++++++++++++++++++++++++++++++++++
>> >  1 files changed, 120 insertions(+), 0 deletions(-)
>> > 
>> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> > index de1f307..5c76ca2 100644
>> > --- a/hw/arm/virt-acpi-build.c
>> > +++ b/hw/arm/virt-acpi-build.c
>> > @@ -98,6 +98,111 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>> >      g_array_append_val(table_offsets, offset);
>> >  }
>> >  
>> > +static void acpi_dsdt_add_cpus(AcpiAml *scope, int smp_cpus)
>> > +{
>> > +    AcpiAml dev, crs;
>> > +    int i;
>> > +    char name[5];
>> > +    for (i = 0; i < smp_cpus; i++) {
> I'm not sure about ARM butm shouldn't not present but possble CPUs
> also described here?
> 

In struct VirtGuestInfo there are nb_cpus and max_cpus. nb_cpus stands present CPUs while
max_cpus stands possible CPUs. We can use them to create bitmap.

> PS:
> One more thing about CPU hotplug, I'd like current (x86) bitmap based
> QEMU<->APCI interface (which scales only upto 256 CPU) have redone
> to a one similar to memory hotplug first.
> So that ARM wouldn't have to support compatibility mode for it in the future.
> 

Good idea :-)

Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table
  2015-01-26 10:22   ` Igor Mammedov
  2015-01-27  6:50     ` Shannon Zhao
@ 2015-01-27  9:36     ` Shannon Zhao
  2015-01-27  9:42       ` Igor Mammedov
  1 sibling, 1 reply; 36+ messages in thread
From: Shannon Zhao @ 2015-01-27  9:36 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, wanghaibin.wang,
	pbonzini, lersek, christoffer.dall

On 2015/1/26 18:22, Igor Mammedov wrote:
> On Sat, 24 Jan 2015 17:21:12 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> 
>> > RSDP points to XSDT which in turn points to other tables.
>> > 
>> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> > ---
>> >  hw/arm/virt-acpi-build.c |   22 ++++++++++++++++++++++
>> >  1 files changed, 22 insertions(+), 0 deletions(-)
>> > 
>> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> > index 4eed0a3..9c3971a 100644
>> > --- a/hw/arm/virt-acpi-build.c
>> > +++ b/hw/arm/virt-acpi-build.c
>> > @@ -86,6 +86,28 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
>> >  static GArray *
>> >  build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
>> >  {
>> > +    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
>> > +
>> > +    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
>> > +                             true /* fseg memory */);
>> > +
>> > +    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
>> > +    memcpy(rsdp->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(rsdp->oem_id));
>> > +    rsdp->length = cpu_to_le32(sizeof(*rsdp));
>> > +    rsdp->revision = 0x02;
>> > +
>> > +    /* Point to XSDT */
>> > +    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
> RSDP should be created after XSDT so XSDT pointer would be correct,
> perhaps it's wrong patch ordering
> 
Hi,

About this I think the patch order is not wrong because at the moment we don't enable ACPI.
So this code shouldn't execute. When all tables are generated OK, we could enable CONFIG_ACPI.


Thanks,
Shannon

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table
  2015-01-27  9:36     ` Shannon Zhao
@ 2015-01-27  9:42       ` Igor Mammedov
  0 siblings, 0 replies; 36+ messages in thread
From: Igor Mammedov @ 2015-01-27  9:42 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, pbonzini,
	wanghaibin.wang, lersek, christoffer.dall

On Tue, 27 Jan 2015 17:36:29 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> On 2015/1/26 18:22, Igor Mammedov wrote:
> > On Sat, 24 Jan 2015 17:21:12 +0800
> > Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> > 
> >> > RSDP points to XSDT which in turn points to other tables.
> >> > 
> >> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> >> > ---
> >> >  hw/arm/virt-acpi-build.c |   22 ++++++++++++++++++++++
> >> >  1 files changed, 22 insertions(+), 0 deletions(-)
> >> > 
> >> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> >> > index 4eed0a3..9c3971a 100644
> >> > --- a/hw/arm/virt-acpi-build.c
> >> > +++ b/hw/arm/virt-acpi-build.c
> >> > @@ -86,6 +86,28 @@ static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
> >> >  static GArray *
> >> >  build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t xsdt)
> >> >  {
> >> > +    AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
> >> > +
> >> > +    bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 16,
> >> > +                             true /* fseg memory */);
> >> > +
> >> > +    memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
> >> > +    memcpy(rsdp->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(rsdp->oem_id));
> >> > +    rsdp->length = cpu_to_le32(sizeof(*rsdp));
> >> > +    rsdp->revision = 0x02;
> >> > +
> >> > +    /* Point to XSDT */
> >> > +    rsdp->xsdt_physical_address = cpu_to_le64(xsdt);
> > RSDP should be created after XSDT so XSDT pointer would be correct,
> > perhaps it's wrong patch ordering
> > 
> Hi,
> 
> About this I think the patch order is not wrong because at the moment we don't enable ACPI.
Yes would work, but it still more clear when tables are created in order
in which they are used not backwards.

> So this code shouldn't execute. When all tables are generated OK, we could enable CONFIG_ACPI.
> 
> 
> Thanks,
> Shannon
> 
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-27  6:47     ` Shannon Zhao
@ 2015-01-27 10:30       ` Igor Mammedov
  2015-01-28  6:28         ` Shannon Zhao
  0 siblings, 1 reply; 36+ messages in thread
From: Igor Mammedov @ 2015-01-27 10:30 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, pbonzini,
	wanghaibin.wang, lersek, christoffer.dall

On Tue, 27 Jan 2015 14:47:44 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> On 2015/1/26 18:19, Igor Mammedov wrote:
> > On Sat, 24 Jan 2015 17:21:11 +0800
> > Shannon Zhao <zhaoshenglong@huawei.com> 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 <zhaoshenglong@huawei.com>
> >> ---
> >>  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 0000000..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 <zhaoshenglong@huawei.com>
> >> + *
> >> + * 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 <http://www.gnu.org/licenses/>.
> >> + */
> >> +
> >> +#include "hw/arm/virt-acpi-build.h"
> >> +#include <stddef.h>
> >> +#include <glib.h>
> >> +#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             0x20000
> >> +
> >> +/* Reserve RAM space for tables: add another order of magnitude. */
> >> +#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
> >> +
> >> +/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
> >> +{
> >> +}
> >> +
> >> +/* FACS */
> >> +static void
> >> +build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> >> +{
> >> +}
> >> +
> >> +/* DSDT */
> >> +static void
> >> +build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
> >> +{
> >> +}
Instead of adding empty place holders please add complete functions
in respective patches.

> >> +
> >> +typedef
> >> +struct AcpiBuildTables {
> >> +    AcpiAml table_data;
> >> +    GArray *rsdp;
> >> +    GArray *tcpalog;
> >> +    GArray *linker;
> >> +} AcpiBuildTables;
> >> +
> >> +static inline void acpi_build_tables_init(AcpiBuildTables *tables)
> >> +{
> >> +    tables->rsdp = g_array_new(false, true /* clear */, 1);
> >> +    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
> >> +    tables->tcpalog = g_array_new(false, true /* clear */, 1);
> >> +    tables->linker = bios_linker_loader_init();
> >> +    tables->table_data.linker = tables->linker;
> >> +}
> >> +
> >> +static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
> >> +{
> >> +    void *linker_data = bios_linker_loader_cleanup(tables->linker);
> >> +    g_free(linker_data);
> >> +    g_array_free(tables->rsdp, mfre);
> >> +    g_array_free(tables->table_data.buf, true);
> >> +    g_array_free(tables->tcpalog, mfre);
> >> +}
> >> +
> >> +typedef
> >> +struct AcpiBuildState {
> >> +    /* Copy of table in RAM (for patching). */
> >> +    ram_addr_t table_ram;
> >> +    uint32_t table_size;
> >> +    /* Is table patched? */
> >> +    uint8_t patched;
> >> +    VirtGuestInfo *guest_info;
> >> +} AcpiBuildState;
> >> +
> >> +static
> >> +void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
> >> +{
> >> +    GArray *table_offsets;
> >> +    unsigned facs, dsdt, xsdt;
> >> +
> >> +    table_offsets = g_array_new(false, true /* clear */,
> >> +                                        sizeof(uint32_t));
> >> +    ACPI_BUILD_DPRINTF("init ACPI tables\n");
> > use tracing infrastructure instead of DPRINTFs
> > 
> >> +
> >> +    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
> >> +                             64 /* Ensure FACS is aligned */,
> >> +                             false /* high memory */);
> >> +
> >> +    /*
> >> +     * FACS is pointed to by FADT.
> >> +     * We place it first since it's the only table that has alignment
> >> +     * requirements.
> >> +     */
> >> +    facs = tables->table_data.buf->len;
> >> +    build_facs(tables->table_data.buf, tables->linker, guest_info);
> >> +
> >> +    /* DSDT is pointed to by FADT */
> >> +    dsdt = tables->table_data.buf->len;
> >> +    build_dsdt(&tables->table_data, tables->linker, guest_info);
> >> +
> >> +    /* ACPI tables pointed to by XSDT */
> >> +    acpi_add_table(table_offsets, tables->table_data.buf);
> >> +    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
> >> +
> >> +    acpi_add_table(table_offsets, tables->table_data.buf);
> >> +    build_madt(tables->table_data.buf, tables->linker, guest_info);
> >> +
> >> +    acpi_add_table(table_offsets, tables->table_data.buf);
> >> +    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
> >> +
> >> +    /* XSDT is pointed to by RSDP */
> >> +    xsdt = tables->table_data.buf->len;
> >> +    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
> >> +
> >> +    /* RSDP is in FSEG memory, so allocate it separately */
> >> +    build_rsdp(tables->rsdp, tables->linker, xsdt);
> >> +
> >> +    /* Cleanup memory that's no longer used. */
> >> +    g_array_free(table_offsets, true);
> >> +}
> >> +
> >> +static ram_addr_t 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, NULL, build_state);
> >> +}
> >> +
> >> +void virt_acpi_setup(VirtGuestInfo *guest_info)
> >> +{
> >> +    AcpiBuildTables tables;
> >> +    AcpiBuildState *build_state;
> >> +
> >> +    if (!guest_info->fw_cfg) {
> >> +        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
> >> +        return;
> >> +    }
> >> +
> >> +    if (!acpi_enabled) {
> >> +        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
> >> +        return;
> >> +    }
> >> +
> >> +    build_state = g_malloc0(sizeof *build_state);
> >> +    build_state->guest_info = guest_info;
> >> +
> >> +    acpi_build_tables_init(&tables);
> >> +    acpi_build(build_state->guest_info, &tables);
> >> +
> >> +    /* Now expose it all to Guest */
> >> +    build_state->table_ram = acpi_add_rom_blob(build_state,
> >> +                                               tables.table_data.buf,
> >> +                                               ACPI_BUILD_TABLE_FILE,
> >> +                                               ACPI_BUILD_TABLE_MAX_SIZE);
> >> +    assert(build_state->table_ram != RAM_ADDR_MAX);
> >> +    build_state->table_size = acpi_data_len(tables.table_data.buf);
> >> +
> >> +    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
> >> +
> >> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
> >> +                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
> >> +
> >> +    /*
> >> +     * RSDP is small so it's easy to keep it immutable, no need to
> >> +     * bother with ROM blobs.
> >> +     */
> >> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
> >> +                    tables.rsdp->data, acpi_data_len(tables.rsdp));
> > that's broken since position of RSDT could change on reboot and initial RSDP
> > would point to a wrong offset afterwards. Ith should be rom_blob as well
> > which is re-creatable on reboot as ACPI_BUILD_TABLE_FILE.
> > 
> > 
> 
> Sorry, I'm not clear about your comment. I did inside reboot and outside reset, it looks well.
In gist the issue is if any table between xsdt changes its size across
reboots (i.e. XSDT moves) static RSDP will point to wrong offset and
firmware will corrupt tables by patching blob at wrong offset.

For x86 fix we agreed that RSDP will be made dynamic
(which is sufficient to fix issue).

see for example http://lists.gnu.org/archive/html/qemu-devel/2014-12/msg01699.html

> 
> >> +
> >> +    /* Cleanup tables but don't free the memory: we track it
> >> +     * in build_state.
> >> +     */
> >> +    acpi_build_tables_cleanup(&tables, false);
> >> +}
> >> diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
> >> new file mode 100644
> >> index 0000000..7a09c34
> >> --- /dev/null
> >> +++ b/include/hw/arm/virt-acpi-build.h
> >> @@ -0,0 +1,71 @@
> >> +/*
> >> + *
> >> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
> >> + *
> >> + * Author: Shannon Zhao <zhaoshenglong@huawei.com>
> >> + *
> >> + * 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 <http://www.gnu.org/licenses/>.
> >> + */
> >> +
> >> +#ifndef QEMU_VIRT_ACPI_BUILD_H
> >> +#define QEMU_VIRT_ACPI_BUILD_H
> >> +
> >> +#include "qemu-common.h"
> >> +#include "hw/acpi/acpi-defs.h"
> >> +
> >> +
> >> +#define ACPI_VIRT_QEMU_STR_4 "QEMU"
> >> +#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
> >> +#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
> >> +
> >> +struct acpi_gtdt_info {
> >> +    uint32_t timer_virt;
> >> +    uint32_t timer_s_el1;
> >> +    uint32_t timer_ns_el1;
> >> +    uint32_t timer_ns_el2;
> >> +};
> >> +
> >> +struct acpi_madt_info {
> >> +    const hwaddr *gic_cpu_base_addr;
> >> +    const hwaddr *gic_dist_base_addr;
> >> +};
> >> +
> >> +struct acpi_dsdt_info {
> >> +    const hwaddr *uart_addr;
> >> +    const int *uart_irq;
> >> +    const hwaddr *virtio_mmio_addr;
> >> +    const int *virtio_mmio_irq;
> >> +    int virtio_mmio_num;
> >> +    const hwaddr *rtc_addr;
> >> +    const int *rtc_irq;
> >> +    const hwaddr *flash_addr;
> >> +};
> >> +
> >> +typedef struct VirtGuestInfo {
> >> +    int nb_cpus;
> >> +    int max_cpus;
> >> +    FWCfgState *fw_cfg;
> >> +    const struct acpi_madt_info *madt_info;
> >> +    const struct acpi_dsdt_info *dsdt_info;
> >> +    const struct acpi_gtdt_info *gtdt_info;
> >> +} VirtGuestInfo;
> >> +
> >> +
> >> +typedef struct VirtGuestInfoState {
> >> +    VirtGuestInfo info;
> >> +    Notifier machine_done;
> >> +} VirtGuestInfoState;
> >> +
> >> +void virt_acpi_setup(VirtGuestInfo *guest_info);
> >> +
> >> +#endif
> > 
> > 
> > .
> > 
> 
> 
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
  2015-01-24 16:22   ` Michael S. Tsirkin
  2015-01-26 10:19   ` Igor Mammedov
@ 2015-01-27 12:12   ` Hanjun Guo
  2 siblings, 0 replies; 36+ messages in thread
From: Hanjun Guo @ 2015-01-27 12:12 UTC (permalink / raw)
  To: Shannon Zhao, qemu-devel, peter.maydell, pbonzini,
	christoffer.dall, a.spyridakis, claudio.fontana, imammedo, mst,
	lersek
  Cc: wanghaibin.wang, hangaohuai, peter.huangpeng

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

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables
  2015-01-27 10:30       ` Igor Mammedov
@ 2015-01-28  6:28         ` Shannon Zhao
  0 siblings, 0 replies; 36+ messages in thread
From: Shannon Zhao @ 2015-01-28  6:28 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, hangaohuai, mst, a.spyridakis, claudio.fontana,
	qemu-devel, peter.huangpeng, hanjun.guo, pbonzini,
	wanghaibin.wang, lersek, christoffer.dall

On 2015/1/27 18:30, Igor Mammedov wrote:
> On Tue, 27 Jan 2015 14:47:44 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> 
>> On 2015/1/26 18:19, Igor Mammedov wrote:
>>> On Sat, 24 Jan 2015 17:21:11 +0800
>>> Shannon Zhao <zhaoshenglong@huawei.com> 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 <zhaoshenglong@huawei.com>
>>>> ---
>>>>  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 0000000..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 <zhaoshenglong@huawei.com>
>>>> + *
>>>> + * 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 <http://www.gnu.org/licenses/>.
>>>> + */
>>>> +
>>>> +#include "hw/arm/virt-acpi-build.h"
>>>> +#include <stddef.h>
>>>> +#include <glib.h>
>>>> +#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             0x20000
>>>> +
>>>> +/* Reserve RAM space for tables: add another order of magnitude. */
>>>> +#define ACPI_BUILD_TABLE_MAX_SIZE         0x200000
>>>> +
>>>> +/* #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(GArray *table_data, GArray *linker, uint64_t facs, uint64_t dsdt)
>>>> +{
>>>> +}
>>>> +
>>>> +/* FACS */
>>>> +static void
>>>> +build_facs(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
>>>> +{
>>>> +}
>>>> +
>>>> +/* DSDT */
>>>> +static void
>>>> +build_dsdt(AcpiAml *table_aml, GArray *linker, VirtGuestInfo *guest_info)
>>>> +{
>>>> +}
> Instead of adding empty place holders please add complete functions
> in respective patches.
> 

Will fix it.

>>>> +
>>>> +typedef
>>>> +struct AcpiBuildTables {
>>>> +    AcpiAml table_data;
>>>> +    GArray *rsdp;
>>>> +    GArray *tcpalog;
>>>> +    GArray *linker;
>>>> +} AcpiBuildTables;
>>>> +
>>>> +static inline void acpi_build_tables_init(AcpiBuildTables *tables)
>>>> +{
>>>> +    tables->rsdp = g_array_new(false, true /* clear */, 1);
>>>> +    tables->table_data.buf = g_array_new(false, true /* clear */, 1);
>>>> +    tables->tcpalog = g_array_new(false, true /* clear */, 1);
>>>> +    tables->linker = bios_linker_loader_init();
>>>> +    tables->table_data.linker = tables->linker;
>>>> +}
>>>> +
>>>> +static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
>>>> +{
>>>> +    void *linker_data = bios_linker_loader_cleanup(tables->linker);
>>>> +    g_free(linker_data);
>>>> +    g_array_free(tables->rsdp, mfre);
>>>> +    g_array_free(tables->table_data.buf, true);
>>>> +    g_array_free(tables->tcpalog, mfre);
>>>> +}
>>>> +
>>>> +typedef
>>>> +struct AcpiBuildState {
>>>> +    /* Copy of table in RAM (for patching). */
>>>> +    ram_addr_t table_ram;
>>>> +    uint32_t table_size;
>>>> +    /* Is table patched? */
>>>> +    uint8_t patched;
>>>> +    VirtGuestInfo *guest_info;
>>>> +} AcpiBuildState;
>>>> +
>>>> +static
>>>> +void acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
>>>> +{
>>>> +    GArray *table_offsets;
>>>> +    unsigned facs, dsdt, xsdt;
>>>> +
>>>> +    table_offsets = g_array_new(false, true /* clear */,
>>>> +                                        sizeof(uint32_t));
>>>> +    ACPI_BUILD_DPRINTF("init ACPI tables\n");
>>> use tracing infrastructure instead of DPRINTFs
>>>
>>>> +
>>>> +    bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
>>>> +                             64 /* Ensure FACS is aligned */,
>>>> +                             false /* high memory */);
>>>> +
>>>> +    /*
>>>> +     * FACS is pointed to by FADT.
>>>> +     * We place it first since it's the only table that has alignment
>>>> +     * requirements.
>>>> +     */
>>>> +    facs = tables->table_data.buf->len;
>>>> +    build_facs(tables->table_data.buf, tables->linker, guest_info);
>>>> +
>>>> +    /* DSDT is pointed to by FADT */
>>>> +    dsdt = tables->table_data.buf->len;
>>>> +    build_dsdt(&tables->table_data, tables->linker, guest_info);
>>>> +
>>>> +    /* ACPI tables pointed to by XSDT */
>>>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>>>> +    build_fadt(tables->table_data.buf, tables->linker, facs, dsdt);
>>>> +
>>>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>>>> +    build_madt(tables->table_data.buf, tables->linker, guest_info);
>>>> +
>>>> +    acpi_add_table(table_offsets, tables->table_data.buf);
>>>> +    build_gtdt(tables->table_data.buf, tables->linker, guest_info);
>>>> +
>>>> +    /* XSDT is pointed to by RSDP */
>>>> +    xsdt = tables->table_data.buf->len;
>>>> +    build_xsdt(tables->table_data.buf, tables->linker, table_offsets);
>>>> +
>>>> +    /* RSDP is in FSEG memory, so allocate it separately */
>>>> +    build_rsdp(tables->rsdp, tables->linker, xsdt);
>>>> +
>>>> +    /* Cleanup memory that's no longer used. */
>>>> +    g_array_free(table_offsets, true);
>>>> +}
>>>> +
>>>> +static ram_addr_t 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, NULL, build_state);
>>>> +}
>>>> +
>>>> +void virt_acpi_setup(VirtGuestInfo *guest_info)
>>>> +{
>>>> +    AcpiBuildTables tables;
>>>> +    AcpiBuildState *build_state;
>>>> +
>>>> +    if (!guest_info->fw_cfg) {
>>>> +        ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
>>>> +        return;
>>>> +    }
>>>> +
>>>> +    if (!acpi_enabled) {
>>>> +        ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
>>>> +        return;
>>>> +    }
>>>> +
>>>> +    build_state = g_malloc0(sizeof *build_state);
>>>> +    build_state->guest_info = guest_info;
>>>> +
>>>> +    acpi_build_tables_init(&tables);
>>>> +    acpi_build(build_state->guest_info, &tables);
>>>> +
>>>> +    /* Now expose it all to Guest */
>>>> +    build_state->table_ram = acpi_add_rom_blob(build_state,
>>>> +                                               tables.table_data.buf,
>>>> +                                               ACPI_BUILD_TABLE_FILE,
>>>> +                                               ACPI_BUILD_TABLE_MAX_SIZE);
>>>> +    assert(build_state->table_ram != RAM_ADDR_MAX);
>>>> +    build_state->table_size = acpi_data_len(tables.table_data.buf);
>>>> +
>>>> +    acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader", 0);
>>>> +
>>>> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
>>>> +                    tables.tcpalog->data, acpi_data_len(tables.tcpalog));
>>>> +
>>>> +    /*
>>>> +     * RSDP is small so it's easy to keep it immutable, no need to
>>>> +     * bother with ROM blobs.
>>>> +     */
>>>> +    fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
>>>> +                    tables.rsdp->data, acpi_data_len(tables.rsdp));
>>> that's broken since position of RSDT could change on reboot and initial RSDP
>>> would point to a wrong offset afterwards. Ith should be rom_blob as well
>>> which is re-creatable on reboot as ACPI_BUILD_TABLE_FILE.
>>>
>>>
>>
>> Sorry, I'm not clear about your comment. I did inside reboot and outside reset, it looks well.
> In gist the issue is if any table between xsdt changes its size across
> reboots (i.e. XSDT moves) static RSDP will point to wrong offset and
> firmware will corrupt tables by patching blob at wrong offset.
> 
> For x86 fix we agreed that RSDP will be made dynamic
> (which is sufficient to fix issue).
> 
> see for example http://lists.gnu.org/archive/html/qemu-devel/2014-12/msg01699.html
> 

Thanks, more clear

>>
>>>> +
>>>> +    /* Cleanup tables but don't free the memory: we track it
>>>> +     * in build_state.
>>>> +     */
>>>> +    acpi_build_tables_cleanup(&tables, false);
>>>> +}
>>>> diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
>>>> new file mode 100644
>>>> index 0000000..7a09c34
>>>> --- /dev/null
>>>> +++ b/include/hw/arm/virt-acpi-build.h
>>>> @@ -0,0 +1,71 @@
>>>> +/*
>>>> + *
>>>> + * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
>>>> + *
>>>> + * Author: Shannon Zhao <zhaoshenglong@huawei.com>
>>>> + *
>>>> + * 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 <http://www.gnu.org/licenses/>.
>>>> + */
>>>> +
>>>> +#ifndef QEMU_VIRT_ACPI_BUILD_H
>>>> +#define QEMU_VIRT_ACPI_BUILD_H
>>>> +
>>>> +#include "qemu-common.h"
>>>> +#include "hw/acpi/acpi-defs.h"
>>>> +
>>>> +
>>>> +#define ACPI_VIRT_QEMU_STR_4 "QEMU"
>>>> +#define ACPI_VIRT_QEMU_STR_6 "QEMU  "
>>>> +#define ACPI_VIRT_MACH_STR_8 "MACHVIRT"
>>>> +
>>>> +struct acpi_gtdt_info {
>>>> +    uint32_t timer_virt;
>>>> +    uint32_t timer_s_el1;
>>>> +    uint32_t timer_ns_el1;
>>>> +    uint32_t timer_ns_el2;
>>>> +};
>>>> +
>>>> +struct acpi_madt_info {
>>>> +    const hwaddr *gic_cpu_base_addr;
>>>> +    const hwaddr *gic_dist_base_addr;
>>>> +};
>>>> +
>>>> +struct acpi_dsdt_info {
>>>> +    const hwaddr *uart_addr;
>>>> +    const int *uart_irq;
>>>> +    const hwaddr *virtio_mmio_addr;
>>>> +    const int *virtio_mmio_irq;
>>>> +    int virtio_mmio_num;
>>>> +    const hwaddr *rtc_addr;
>>>> +    const int *rtc_irq;
>>>> +    const hwaddr *flash_addr;
>>>> +};
>>>> +
>>>> +typedef struct VirtGuestInfo {
>>>> +    int nb_cpus;
>>>> +    int max_cpus;
>>>> +    FWCfgState *fw_cfg;
>>>> +    const struct acpi_madt_info *madt_info;
>>>> +    const struct acpi_dsdt_info *dsdt_info;
>>>> +    const struct acpi_gtdt_info *gtdt_info;
>>>> +} VirtGuestInfo;
>>>> +
>>>> +
>>>> +typedef struct VirtGuestInfoState {
>>>> +    VirtGuestInfo info;
>>>> +    Notifier machine_done;
>>>> +} VirtGuestInfoState;
>>>> +
>>>> +void virt_acpi_setup(VirtGuestInfo *guest_info);
>>>> +
>>>> +#endif
>>>
>>>
>>> .
>>>
>>
>>
>>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2015-01-28  6:29 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-24  9:21 [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 01/11] hw/i386: Move ACPI header definitions in an arch-independent location Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 02/11] hw/arm/virt-acpi-build: Basic framework for building ACPI tables Shannon Zhao
2015-01-24 16:22   ` Michael S. Tsirkin
2015-01-26  2:37     ` Shannon Zhao
2015-01-26 10:19   ` Igor Mammedov
2015-01-27  6:47     ` Shannon Zhao
2015-01-27 10:30       ` Igor Mammedov
2015-01-28  6:28         ` Shannon Zhao
2015-01-27 12:12   ` Hanjun Guo
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
2015-01-26 10:22   ` Igor Mammedov
2015-01-27  6:50     ` Shannon Zhao
2015-01-27  9:36     ` Shannon Zhao
2015-01-27  9:42       ` Igor Mammedov
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function Shannon Zhao
2015-01-24 22:04   ` Laszlo Ersek
2015-01-26  1:45     ` Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 05/11] hw/arm/virt-acpi-build: Generate MADT table Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 06/11] hw/arm/virt-acpi-build: Generate GTDT table Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 07/11] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
2015-01-24 22:05   ` Laszlo Ersek
2015-01-26  1:48     ` Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 08/11] hw/arm/virt-acpi-build: Generate FACS " Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq() Shannon Zhao
2015-01-25  8:39   ` Michael S. Tsirkin
2015-01-26  1:58     ` Shannon Zhao
2015-01-26 10:46     ` Igor Mammedov
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
2015-01-26 10:40   ` Igor Mammedov
2015-01-27  7:19     ` Shannon Zhao
2015-01-24  9:21 ` [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
2015-01-24 18:56   ` Laszlo Ersek
2015-01-26  1:59     ` Shannon Zhao
2015-01-24 23:31 ` [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM Laszlo Ersek
2015-01-26  2:34   ` Shannon Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.