[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/26] hw: acpi: reduced: Add shutdown support
From: |
Samuel Ortiz |
Subject: |
[Qemu-devel] [PATCH 22/26] hw: acpi: reduced: Add shutdown support |
Date: |
Mon, 22 Oct 2018 20:36:52 +0200 |
From: Jing Liu <address@hidden>
Hardware-reduced ACPI uses SLEEP_CONTROL_REG to enter S5 sleep state.
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Igor Mammedov <address@hidden>
Signed-off-by: Jing Liu <address@hidden>
---
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, const
AcpiFadtData *f,
}
/* 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);
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, AcpiConfiguration
*conf)
conf->ged_events, conf->ged_events_size);
}
+static void acpi_dsdt_add_sleep_state(Aml *scope)
+{
+ Aml *pkg = 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);
/* copy AML table into ACPI tables blob and patch header there */
@@ -120,6 +132,9 @@ static void build_fadt_reduced(GArray *table_data,
BIOSLinker *linker,
.dsdt_tbl_offset = &dsdt_tbl_offset,
.xdsdt_tbl_offset = &dsdt_tbl_offset,
.arm_boot_arch = 0,
+ .sleep_control_reg = { .space_id = AML_AS_SYSTEM_IO,
+ .bit_width = 8, .bit_offset = 0,
+ .address = ACPI_REDUCED_SLEEP_CONTROL_IOPORT },
};
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;
#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
+#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;
typedef enum {
--
2.17.2
- Re: [Qemu-devel] [PATCH 17/26] hw: i386: Convert PC machine type to firmware build methods, (continued)
- [Qemu-devel] [PATCH 19/26] hw: acpi: reduced: Add MCFG support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 18/26] hw: acpi: Initial hardware-reduced support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 20/26] hw: acpi: reduced: Generic Event Device support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 21/26] hw: acpi: reduced: Add memory hotplug support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 24/26] hw: acpi: reduced: Add SRAT table, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 23/26] hw: acpi: reduced: Add reboot support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 25/26] hw: acpi: reduced: Add NFIT support, Samuel Ortiz, 2018/10/22
- [Qemu-devel] [PATCH 22/26] hw: acpi: reduced: Add shutdown support,
Samuel Ortiz <=
- [Qemu-devel] [PATCH 26/26] hw: acpi: reduced: Add PCI hotplug support, Samuel Ortiz, 2018/10/22
- Re: [Qemu-devel] [PATCH 00/27] ACPI hardware-reduced support, Michael S. Tsirkin, 2018/10/22
- Re: [Qemu-devel] [PATCH 00/27] ACPI hardware-reduced support, Peter Maydell, 2018/10/23
- Re: [Qemu-devel] [PATCH 00/27] ACPI hardware-reduced support, Paolo Bonzini, 2018/10/23