ACPI: Allocate S3 resume backup in CBMEM earlier

These allocations are not really part of write_tables() and the move
opens possibilities to use CBMEM instead of SPI Flash to restore some
parts of system state after S3 resume.

Change-Id: I0c36bcee3f1da525af077fc1d18677ee85097e4d
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/7097
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
diff --git a/src/arch/x86/boot/acpi.c b/src/arch/x86/boot/acpi.c
index 3859bc1..c3c946d 100644
--- a/src/arch/x86/boot/acpi.c
+++ b/src/arch/x86/boot/acpi.c
@@ -878,6 +878,23 @@
 		acpi_slp_type = 0;
 }
 
+void acpi_prepare_resume_backup(void)
+{
+	if (!acpi_s3_resume_allowed())
+		return;
+
+	/* Let's prepare the ACPI S3 Resume area now already, so we can rely on
+	 * it being there during reboot time. We don't need the pointer, nor
+	 * the result right now. If it fails, ACPI resume will be disabled.
+	 */
+
+	if (HIGH_MEMORY_SAVE)
+		cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
+
+	if (HIGH_MEMORY_SCRATCH)
+		cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH);
+}
+
 static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
 {
 	if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0)