[SeaBIOS] [PATCH 2/6] acpi: move s3/s4/s5 to build_ssdt
Paolo Bonzini
pbonzini at redhat.com
Tue Jul 31 11:52:09 CEST 2012
Move the _S3/_S4/_S5 packages out of ssdt-pcihp.dsl and into a separate
file. Correspondingly, move the patching from build_pcihp to build_ssdt.
Place this part at the beginning of the SSDT. Offset computation is a
bit simpler, and anyway the packages do not need to be inside Scope(_SB).
Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
Makefile | 2 +-
src/acpi.c | 41 ++++++++++++++++++++++++-----------------
src/ssdt-pcihp.dsl | 36 ------------------------------------
src/ssdt-susp.dsl | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 66 insertions(+), 54 deletions(-)
create mode 100644 src/ssdt-susp.dsl
diff --git a/Makefile b/Makefile
index fe974f7..2ccf05b 100644
--- a/Makefile
+++ b/Makefile
@@ -228,7 +228,7 @@ $(OUT)%.hex: src/%.dsl ./tools/acpi_extract_preprocess.py ./tools/acpi_extract.p
$(Q)$(PYTHON) ./tools/acpi_extract.py $(OUT)$*.lst > $(OUT)$*.off
$(Q)cat $(OUT)$*.off > $@
-$(OUT)ccode32flat.o: $(OUT)acpi-dsdt.hex $(OUT)ssdt-proc.hex $(OUT)ssdt-pcihp.hex
+$(OUT)ccode32flat.o: $(OUT)acpi-dsdt.hex $(OUT)ssdt-proc.hex $(OUT)ssdt-pcihp.hex $(OUT)ssdt-susp.hex
################ Kconfig rules
diff --git a/src/acpi.c b/src/acpi.c
index 55e4607..e6a7ef5 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -407,26 +407,46 @@ encodeLen(u8 *ssdt_ptr, int length, int bytes)
#define SSDT_SIGNATURE 0x54445353 // SSDT
+#define SSDT_HEADER_LENGTH 36
+
+#include "ssdt-susp.hex"
+
static void*
build_ssdt(void)
{
int acpi_cpus = MaxCountCPUs > 0xff ? 0xff : MaxCountCPUs;
// length = ScopeOp + procs + NTYF method + CPON package
- int length = ((1+3+4)
+ int length = (sizeof(ssdp_susp_aml)
+ + (1+3+4)
+ (acpi_cpus * SD_SIZEOF)
+ (1+2+5+(12*acpi_cpus))
+ (6+2+1+(1*acpi_cpus))
+ 17);
- u8 *ssdt = malloc_high(sizeof(struct acpi_table_header) + length);
+ u8 *ssdt = malloc_high(length);
if (! ssdt) {
warn_noalloc();
return NULL;
}
- u8 *ssdt_ptr = ssdt + sizeof(struct acpi_table_header);
+ u8 *ssdt_ptr = ssdt;
+
+ // Copy header and encode fwcfg values in the S3_ / S4_ / S5_ packages
+ int sys_state_size;
+ char *sys_states = romfile_loadfile("etc/system-states", &sys_state_size);
+ if (!sys_states || sys_state_size != 6)
+ sys_states = (char[]){128, 0, 0, 129, 128, 128};
+
+ memcpy(ssdt_ptr, ssdp_susp_aml, sizeof(ssdp_susp_aml));
+ if (!(sys_states[3] & 128))
+ ssdt_ptr[acpi_s3_name[0]] = 'X';
+ if (!(sys_states[4] & 128))
+ ssdt_ptr[acpi_s4_name[0]] = 'X';
+ else
+ ssdt_ptr[acpi_s4_pkg[0] + 1] = ssdt[acpi_s4_pkg[0] + 3] = sys_states[4] & 127;
+ ssdt_ptr += sizeof(ssdp_susp_aml);
// build Scope(_SB_) header
*(ssdt_ptr++) = 0x10; // ScopeOp
- ssdt_ptr = encodeLen(ssdt_ptr, length-1, 3);
+ ssdt_ptr = encodeLen(ssdt_ptr, length - (ssdt_ptr - ssdt), 3);
*(ssdt_ptr++) = '_';
*(ssdt_ptr++) = 'S';
*(ssdt_ptr++) = 'B';
@@ -518,8 +538,6 @@ extern void link_time_assertion(void);
static void* build_pcihp(void)
{
- char *sys_states;
- int sys_state_size;
u32 rmvc_pcrm;
int i;
@@ -551,19 +569,8 @@ static void* build_pcihp(void)
}
}
- sys_states = romfile_loadfile("etc/system-states", &sys_state_size);
- if (!sys_states || sys_state_size != 6)
- sys_states = (char[]){128, 0, 0, 129, 128, 128};
-
- if (!(sys_states[3] & 128))
- ssdt[acpi_s3_name[0]] = 'X';
- if (!(sys_states[4] & 128))
- ssdt[acpi_s4_name[0]] = 'X';
- else
- ssdt[acpi_s4_pkg[0] + 1] = ssdt[acpi_s4_pkg[0] + 3] = sys_states[4] & 127;
((struct acpi_table_header*)ssdt)->checksum = 0;
((struct acpi_table_header*)ssdt)->checksum -= checksum(ssdt, sizeof(ssdp_pcihp_aml));
-
return ssdt;
}
diff --git a/src/ssdt-pcihp.dsl b/src/ssdt-pcihp.dsl
index 81c57b3..fd9c0bb 100644
--- a/src/ssdt-pcihp.dsl
+++ b/src/ssdt-pcihp.dsl
@@ -58,40 +58,4 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1)
hotplug_slot(1e)
hotplug_slot(1f)
}
-
- Scope(\) {
-/****************************************************************
- * Suspend
- ****************************************************************/
-
- /*
- * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
- * must match piix4 emulation.
- */
-
- ACPI_EXTRACT_NAME_STRING acpi_s3_name
- Name (_S3, Package (0x04)
- {
- One, /* PM1a_CNT.SLP_TYP */
- One, /* PM1b_CNT.SLP_TYP */
- Zero, /* reserved */
- Zero /* reserved */
- })
- ACPI_EXTRACT_NAME_STRING acpi_s4_name
- ACPI_EXTRACT_PKG_START acpi_s4_pkg
- Name (_S4, Package (0x04)
- {
- 0x2, /* PM1a_CNT.SLP_TYP */
- 0x2, /* PM1b_CNT.SLP_TYP */
- Zero, /* reserved */
- Zero /* reserved */
- })
- Name (_S5, Package (0x04)
- {
- Zero, /* PM1a_CNT.SLP_TYP */
- Zero, /* PM1b_CNT.SLP_TYP */
- Zero, /* reserved */
- Zero /* reserved */
- })
- }
}
diff --git a/src/ssdt-susp.dsl b/src/ssdt-susp.dsl
new file mode 100644
index 0000000..0b3fa08
--- /dev/null
+++ b/src/ssdt-susp.dsl
@@ -0,0 +1,41 @@
+ACPI_EXTRACT_ALL_CODE ssdp_susp_aml
+
+DefinitionBlock ("ssdt-susp.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
+{
+
+/****************************************************************
+ * Suspend
+ ****************************************************************/
+
+ Scope(\) {
+ /*
+ * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
+ * must match piix4 emulation.
+ */
+
+ ACPI_EXTRACT_NAME_STRING acpi_s3_name
+ Name (_S3, Package (0x04)
+ {
+ One, /* PM1a_CNT.SLP_TYP */
+ One, /* PM1b_CNT.SLP_TYP */
+ Zero, /* reserved */
+ Zero /* reserved */
+ })
+ ACPI_EXTRACT_NAME_STRING acpi_s4_name
+ ACPI_EXTRACT_PKG_START acpi_s4_pkg
+ Name (_S4, Package (0x04)
+ {
+ 0x2, /* PM1a_CNT.SLP_TYP */
+ 0x2, /* PM1b_CNT.SLP_TYP */
+ Zero, /* reserved */
+ Zero /* reserved */
+ })
+ Name (_S5, Package (0x04)
+ {
+ Zero, /* PM1a_CNT.SLP_TYP */
+ Zero, /* PM1b_CNT.SLP_TYP */
+ Zero, /* reserved */
+ Zero /* reserved */
+ })
+ }
+}
--
1.7.10.4
More information about the SeaBIOS
mailing list