]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.asm
OvmfPkg: Support GCC47 toolchain
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / BootScriptExecutorDxe / X64 / S3Asm.asm
CommitLineData
be46cd5f 1;; @file\r
2; This is the assembly code for transferring to control to OS S3 waking vector\r
3; for X64 platform\r
4;\r
5; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
6;\r
7; This program and the accompanying materials\r
8; are licensed and made available under the terms and conditions of the BSD License\r
9; which accompanies this distribution. The full text of the license may be found at\r
10; http://opensource.org/licenses/bsd-license.php\r
11;\r
12; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14;\r
15;;\r
16\r
17 .code\r
18 \r
19EXTERNDEF AsmFixAddress16:DWORD\r
20EXTERNDEF AsmJmpAddr32:DWORD\r
21 \r
22AsmTransferControl PROC\r
23 ; rcx S3WakingVector :DWORD\r
24 ; rdx AcpiLowMemoryBase :DWORD\r
25 lea eax, @F\r
26 mov r8, 2800000000h\r
27 or rax, r8\r
28 push rax\r
29 shrd ebx, ecx, 20\r
30 and ecx, 0fh \r
31 mov bx, cx \r
32 mov @jmp_addr, ebx\r
33 retf\r
34@@:\r
35 DB 0b8h, 30h, 0 ; mov ax, 30h as selector\r
36 mov ds, eax\r
37 mov es, eax\r
38 mov fs, eax\r
39 mov gs, eax\r
40 mov ss, eax\r
41 mov rax, cr0\r
42 mov rbx, cr4 \r
43 DB 66h\r
44 and eax, ((NOT 080000001h) AND 0ffffffffh)\r
45 and bl, NOT (1 SHL 5)\r
46 mov cr0, rax\r
47 DB 66h\r
48 mov ecx, 0c0000080h\r
49 rdmsr\r
50 and ah, NOT 1\r
51 wrmsr\r
52 mov cr4, rbx\r
53 DB 0eah ; jmp far @jmp_addr\r
54@jmp_addr DD ?\r
55AsmTransferControl ENDP\r
56\r
57AsmTransferControl32 PROC\r
58 ; S3WakingVector :DWORD\r
59 ; AcpiLowMemoryBase :DWORD\r
60 push rbp\r
61 mov ebp, esp \r
62 DB 8dh, 05h ; lea eax, AsmTransferControl16\r
63AsmFixAddress16 DD ?\r
64 push 28h ; CS\r
65 push rax\r
66 retf\r
67AsmTransferControl32 ENDP\r
68\r
69AsmTransferControl16 PROC\r
70 DB 0b8h, 30h, 0 ; mov ax, 30h as selector\r
71 mov ds, ax\r
72 mov es, ax\r
73 mov fs, ax\r
74 mov gs, ax\r
75 mov ss, ax\r
76 mov rax, cr0 ; Get control register 0 \r
77 DB 66h\r
78 DB 83h, 0e0h, 0feh ; and eax, 0fffffffeh ; Clear PE bit (bit #0)\r
79 DB 0fh, 22h, 0c0h ; mov cr0, eax ; Activate real mode\r
80 DB 0eah ; jmp far AsmJmpAddr32\r
81AsmJmpAddr32 DD ?\r
82AsmTransferControl16 ENDP\r
83\r
84 END\r