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