Remove address from GPLv2 headers
[coreboot.git] / src / cpu / x86 / smm / backup_default_smm.c
blobfa8b11d20d782f3175e8c6d4f5e0945168926373
1 /*
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
9 * the License.
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
18 * Foundation, Inc.
21 #include <string.h>
22 #include <arch/acpi.h>
23 #include <console/console.h>
24 #include <cbmem.h>
25 #include <cpu/x86/smm.h>
27 void *backup_default_smm_area(void)
29 void *save_area;
30 const void *default_smm = (void *)SMM_DEFAULT_BASE;
32 if (!IS_ENABLED(CONFIG_HAVE_ACPI_RESUME))
33 return NULL;
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");
44 return NULL;
47 /* Only back up the area on S3 resume. */
48 if (acpi_is_wakeup_s3()) {
49 memcpy(save_area, default_smm, SMM_DEFAULT_SIZE);
50 return save_area;
54 * Not the S3 resume path. No need to restore memory contents after
55 * SMM relocation.
57 return NULL;
60 void restore_default_smm_area(void *smm_save_area)
62 void *default_smm = (void *)SMM_DEFAULT_BASE;
64 if (smm_save_area == NULL)
65 return;
67 memcpy(default_smm, smm_save_area, SMM_DEFAULT_SIZE);