2 * This file is part of the coreboot project.
4 * Copyright (C) 2014 Google Inc
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
22 #include <arch/acpi.h>
23 #include <console/console.h>
25 #include <cpu/x86/smm.h>
27 void *backup_default_smm_area(void)
30 const void *default_smm
= (void *)SMM_DEFAULT_BASE
;
32 if (!IS_ENABLED(CONFIG_HAVE_ACPI_RESUME
))
36 * The buffer needs to be preallocated regardless. In the non-resume
37 * path it will be allocated for handling resume. Note that cbmem_add()
38 * does a find before the addition.
40 save_area
= cbmem_add(CBMEM_ID_SMM_SAVE_SPACE
, SMM_DEFAULT_SIZE
);
42 if (save_area
== NULL
) {
43 printk(BIOS_DEBUG
, "SMM save area not added.\n");
47 /* Only back up the area on S3 resume. */
48 if (acpi_is_wakeup_s3()) {
49 memcpy(save_area
, default_smm
, SMM_DEFAULT_SIZE
);
54 * Not the S3 resume path. No need to restore memory contents after
60 void restore_default_smm_area(void *smm_save_area
)
62 void *default_smm
= (void *)SMM_DEFAULT_BASE
;
64 if (smm_save_area
== NULL
)
67 memcpy(default_smm
, smm_save_area
, SMM_DEFAULT_SIZE
);