coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
write_resume_eip.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <acpi/acpi.h>
4 #include <arch/cpu.h>
5 #include <amdblocks/cpu.h>
6 #include <cpu/amd/msr.h>
7 #include <cpu/x86/msr.h>
8 #include <stdint.h>
9 
11 
12 void write_resume_eip(void)
13 {
14  msr_t s3_resume_entry = {
16  .lo = (uintptr_t)bootblock_resume_entry & 0xffffffff,
17  };
18 
19  /*
20  * Writing to the EIP register can only be done once, otherwise a fault is triggered.
21  * When this register is written, it will trigger the microcode to stash the CPU state
22  * (crX , mtrrs, registers, etc) into the CC6 save area. On resume, the state will be
23  * restored and execution will continue at the EIP.
24  */
25  if (!acpi_is_wakeup_s3())
26  wrmsr(S3_RESUME_EIP_MSR, s3_resume_entry);
27 }
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
#define asmlinkage
Definition: cpu.h:8
#define S3_RESUME_EIP_MSR
Definition: msr.h:80
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition: msr.h:157
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17
unsigned int hi
Definition: msr.h:112
void write_resume_eip(void)
asmlinkage void bootblock_resume_entry(void)