2 ; This is the assembly code for transferring to control to OS S3 waking vector
5 ; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
7 ; SPDX-License-Identifier: BSD-2-Clause-Patent
11 extern ASM_PFX(mOriginalHandler)
12 extern ASM_PFX(PageFaultHandler)
17 global ASM_PFX(AsmFixAddress16)
18 global ASM_PFX(AsmJmpAddr32)
20 global ASM_PFX(AsmTransferControl)
21 ASM_PFX(AsmTransferControl):
22 ; rcx S3WakingVector :DWORD
23 ; rdx AcpiLowMemoryBase :DWORD
31 mov [@jmp_addr + 1], ebx
43 and eax, ((~ 0x80000001) & 0xffffffff)
54 global ASM_PFX(AsmTransferControl32)
55 ASM_PFX(AsmTransferControl32):
57 ; S3WakingVector :DWORD
58 ; AcpiLowMemoryBase :DWORD
61 DB 0x8d, 0x5 ; lea eax, AsmTransferControl16
62 ASM_PFX(AsmFixAddress16): DD 0
67 global ASM_PFX(AsmTransferControl16)
68 ASM_PFX(AsmTransferControl16):
76 mov eax, cr0 ; Get control register 0
77 and eax, 0fffffffeh ; Clear PE bit (bit #0)
78 mov cr0, eax ; Activate real mode
79 DB 0xea ; jmp far AsmJmpAddr32
80 ASM_PFX(AsmJmpAddr32): DD 0
82 global ASM_PFX(PageFaultHandlerHook)
83 ASM_PFX(PageFaultHandlerHook):
85 push rax ; save all volatile registers
92 ; save volatile fp registers
95 movdqa [rsp + 0x0], xmm0
96 movdqa [rsp + 0x10], xmm1
97 movdqa [rsp + 0x20], xmm2
98 movdqa [rsp + 0x30], xmm3
99 movdqa [rsp + 0x40], xmm4
100 movdqa [rsp + 0x50], xmm5
103 call ASM_PFX(PageFaultHandler)
106 ; load volatile fp registers
108 movdqa xmm0, [rsp + 0x0]
109 movdqa xmm1, [rsp + 0x10]
110 movdqa xmm2, [rsp + 0x20]
111 movdqa xmm3, [rsp + 0x30]
112 movdqa xmm4, [rsp + 0x40]
113 movdqa xmm5, [rsp + 0x50]
124 pop rax ; restore all volatile registers
126 jmp qword [ASM_PFX(mOriginalHandler)]
128 add rsp, 0x8 ; skip error code for PF