From patchwork Thu Oct 30 17:48:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Spyridakis X-Patchwork-Id: 405395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CAAF6140076 for ; Sat, 1 Nov 2014 03:49:51 +1100 (AEDT) Received: from localhost ([::1]:39287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFOY-0007gh-0e for incoming@patchwork.ozlabs.org; Fri, 31 Oct 2014 12:49:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkEFi-0005vA-Sr for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:37:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjtpn-0006G9-2u for qemu-devel@nongnu.org; Thu, 30 Oct 2014 13:48:37 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:61144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjtpm-0006G1-Qk for qemu-devel@nongnu.org; Thu, 30 Oct 2014 13:48:31 -0400 Received: by mail-wi0-f174.google.com with SMTP id d1so5239932wiv.1 for ; Thu, 30 Oct 2014 10:48:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7hFI9b5iHAXHEP2TYBBjUftQX/GsHhGpySvKz5LkEn4=; b=lJoCx+3iHkGX+O9FeHuUA5xRhk5w8+Qjy1MM6mR8ZVJkz56UKzD8or8i90LLVVtwZq ikvN1OxWmCGAtZwtf0SSfX4AgmcW6HU5n9A6rieuUSrFN5h1q7p6A/YoOfBv2mfzuKXm o3cOmalUrSFOBcfFy3vaiuXCAucpbY349nXwHPA2xBeQFWeH/vS9ENOLDFCYaCn7qnUE elDG5Kt5hk+af0832Z7g2bQeyKRUrnd9E0xOWOEMPsIdmTQUTBeDjoC+r4oLK3FmScmI nmOxNSAQVg1QcU/drvAWDBbExMqklk4AwrT7TxnoPVW1SQi1QfMifiyFgLz4B4fGSveA hbFQ== X-Gm-Message-State: ALoCoQnq35a3JgloC4tYhL8NGQIozltuHbHF63gWgpCx8+6y2YvlkWpqf0nxj6mxpSgUCsiiZIX+ X-Received: by 10.180.88.162 with SMTP id bh2mr21792750wib.77.1414691309794; Thu, 30 Oct 2014 10:48:29 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-656-01-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by mx.google.com with ESMTPSA id v10sm9751352wiy.23.2014.10.30.10.48.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Oct 2014 10:48:28 -0700 (PDT) From: Alexander Spyridakis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Thu, 30 Oct 2014 18:48:28 +0100 Message-Id: <1414691308-5155-1-git-send-email-a.spyridakis@virtualopensystems.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.174 Cc: tech@virtualopensystems.com, linaro-acpi@lists.linaro.org Subject: [Qemu-devel] [RFC PATCH 4/7] hw/arm/virt-acpi: Generate FACS and FADT, update ACPI headers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org FADT points to FACS and DSDT and additionally, in the case of mach virt, it is also used to set the Hardware Reduced bit and enable PSCI SMP booting through HVC. For FACS the table is created as a mockup, as with the Hardware Reduced bit set it will not be used. Update the header definitions for FADT and FACS taking into account the new additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h` Signed-off-by: Alexander Spyridakis Signed-off-by: Alvise Rigo --- hw/arm/virt-acpi.c | 41 +++++++++++-- include/hw/acpi/acpi-defs.h | 141 ++++++++++++++++++++++++++++++-------------- 2 files changed, 134 insertions(+), 48 deletions(-) diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index 0d7bb99..aca0434 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -133,14 +133,47 @@ static void acpi_create_gtdt(const struct acpi_gtdt_info *irqs) static void acpi_create_fadt(void) { - acpi_table[FADT] = NULL; - acpi_size[FADT] = 0; + AcpiFacpDescriptorRev5_1 *fadt; + hwaddr facs_offset; + int i; + + fadt = g_malloc0(sizeof(*fadt)); + acpi_fill_common_header_data(fadt, "FACP", 5, 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; + + acpi_size[FADT] = fadt->length; + + /* Calculate FACS and DSDT table offsets */ + for (i = RSDP, facs_offset = 0; i < FACS; ++i) { + facs_offset += acpi_size[i]; + } + fadt->Xfacs = cpu_to_le64(ACPI_BASE_ADDRESS + facs_offset); + fadt->Xdsdt = cpu_to_le64(fadt->Xfacs + acpi_size[FACS]); + + acpi_do_checksum(fadt, fadt->length, &fadt->checksum); + + acpi_table[FADT] = (void *)fadt; } static void acpi_create_facs(void) { - acpi_table[FACS] = NULL; - acpi_size[FACS] = 0; + AcpiFacsDescriptorRev5_1 *facs; + + facs = g_malloc0(sizeof(*facs)); + + memcpy(&facs->signature, "FACS", sizeof(facs->signature)); + facs->length = cpu_to_le32(sizeof(*facs)); + facs->version = 0x02; + + acpi_table[FACS] = (void *)facs; + acpi_size[FACS] = facs->length; } static void acpi_create_dsdt(int smp_cpus, const struct acpi_dsdt_info *info) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 779f872..ebbd2d0 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 AcpiFacpDescriptorRev5_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 AcpiFacpDescriptorRev5_1 AcpiFacpDescriptorRev5_1; + +enum { + ACPI_FADT_ARM_USE_PSCI_G_0_2, + ACPI_FADT_ARM_PSCI_USE_HVC, +}; + /* * ACPI 1.0 Root System Description Table (RSDT) */ @@ -156,20 +196,33 @@ 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 + uint64_t xfirmware_waking_vector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ + 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) */