From nobody Thu Nov 6 10:13:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540234574090828.0991858010576; Mon, 22 Oct 2018 11:56:14 -0700 (PDT) Received: from localhost ([::1]:36696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEfN7-0007pN-1a for importer@patchew.org; Mon, 22 Oct 2018 14:56:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEf73-0001ZS-IV for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEf6y-0005at-C4 for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:36 -0400 Received: from mga01.intel.com ([192.55.52.88]:7878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEf6u-0004Je-JS for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:30 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 11:38:54 -0700 Received: from omccarth-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.18.99]) by FMSMGA003.fm.intel.com with ESMTP; 22 Oct 2018 11:38:52 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="90378074" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 20:36:52 +0200 Message-Id: <20181022183656.4902-23-sameo@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181022183656.4902-1-sameo@linux.intel.com> References: <20181022183656.4902-1-sameo@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [PATCH 22/26] hw: acpi: reduced: Add shutdown support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , Jing Liu , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jing Liu Hardware-reduced ACPI uses SLEEP_CONTROL_REG to enter S5 sleep state. Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Signed-off-by: Jing Liu --- hw/acpi/aml-build.c | 2 +- hw/acpi/reduced.c | 15 +++++++++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/acpi/reduced.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index f462bb8313..752642a67a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2922,7 +2922,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, } =20 /* SLEEP_CONTROL_REG */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->sleep_control_reg); /* SLEEP_STATUS_REG */ build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); =20 diff --git a/hw/acpi/reduced.c b/hw/acpi/reduced.c index 33d413a255..329d5112ca 100644 --- a/hw/acpi/reduced.c +++ b/hw/acpi/reduced.c @@ -80,6 +80,17 @@ static void acpi_dsdt_add_ged(Aml *scope, AcpiConfigurat= ion *conf) conf->ged_events, conf->ged_events_size); } =20 +static void acpi_dsdt_add_sleep_state(Aml *scope) +{ + Aml *pkg =3D aml_package(4); + + aml_append(pkg, aml_int(ACPI_REDUCED_SLEEP_LEVEL)); + aml_append(pkg, aml_int(0)); + aml_append(pkg, aml_int(0)); + aml_append(pkg, aml_int(0)); + aml_append(scope, aml_name_decl("_S5", pkg)); +} + /* DSDT */ static void build_dsdt(MachineState *ms, GArray *table_data, BIOSLinker *linker, @@ -98,6 +109,7 @@ static void build_dsdt(MachineState *ms, acpi_dsdt_add_memory_hotplug(ms, dsdt); acpi_dsdt_add_cpus(ms, dsdt, scope, smp_cpus, conf); acpi_dsdt_add_ged(dsdt, conf); + acpi_dsdt_add_sleep_state(scope); aml_append(dsdt, scope); =20 /* copy AML table into ACPI tables blob and patch header there */ @@ -120,6 +132,9 @@ static void build_fadt_reduced(GArray *table_data, BIOS= Linker *linker, .dsdt_tbl_offset =3D &dsdt_tbl_offset, .xdsdt_tbl_offset =3D &dsdt_tbl_offset, .arm_boot_arch =3D 0, + .sleep_control_reg =3D { .space_id =3D AML_AS_SYSTEM_IO, + .bit_width =3D 8, .bit_offset =3D 0, + .address =3D ACPI_REDUCED_SLEEP_CONTROL_IOPO= RT }, }; =20 build_fadt(table_data, linker, &fadt, NULL, NULL); diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 6e1726e0a2..10b7bf9c98 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -112,6 +112,7 @@ typedef struct AcpiFadtData { unsigned *facs_tbl_offset; /* FACS offset in */ unsigned *dsdt_tbl_offset; unsigned *xdsdt_tbl_offset; + struct AcpiGenericAddress sleep_control_reg; /* SLEEP_CONTROL_REG */ } AcpiFadtData; =20 #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) diff --git a/include/hw/acpi/reduced.h b/include/hw/acpi/reduced.h index b326af9bad..3d3c003353 100644 --- a/include/hw/acpi/reduced.h +++ b/include/hw/acpi/reduced.h @@ -19,6 +19,10 @@ #ifndef HW_ACPI_REDUCED_H #define HW_ACPI_REDUCED_H =20 +#define ACPI_REDUCED_SLEEP_LEVEL 5 +#define ACPI_REDUCED_SLEEP_ENABLE (1 << 5) /* SLP_EN */ +#define ACPI_REDUCED_SLEEP_CONTROL_IOPORT 0x3B0 + typedef struct Aml Aml; =20 typedef enum { --=20 2.17.2