]>
Commit | Line | Data |
---|---|---|
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 are\r | |
8 | # 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 | ASM_GLOBAL ASM_PFX(AsmTransferControl)\r | |
18 | ASM_PFX(AsmTransferControl):\r | |
19 | # rcx S3WakingVector :DWORD\r | |
20 | # rdx AcpiLowMemoryBase :DWORD\r | |
21 | lea _AsmTransferControl_al_0000, %eax \r | |
22 | movq $0x2800000000, %r8 \r | |
23 | orq %r8, %rax\r | |
24 | pushq %rax\r | |
25 | shrd $20, %ecx, %ebx\r | |
26 | andl $0x0f, %ecx \r | |
27 | movw %cx, %bx\r | |
28 | movl %ebx, jmp_addr \r | |
29 | lret\r | |
30 | _AsmTransferControl_al_0000:\r | |
31 | .byte 0x0b8, 0x30, 0 # mov ax, 30h as selector\r | |
32 | movl %eax, %ds\r | |
33 | movl %eax, %es\r | |
34 | movl %eax, %fs\r | |
35 | movl %eax, %gs\r | |
36 | movl %eax, %ss\r | |
37 | movq %cr0, %rax\r | |
38 | movq %cr4, %rbx\r | |
39 | .byte 0x66\r | |
40 | andl $0x7ffffffe, %eax \r | |
41 | andb $0xdf, %bl \r | |
42 | movq %rax, %cr0\r | |
43 | .byte 0x66\r | |
44 | movl $0x0c0000080, %ecx \r | |
45 | rdmsr\r | |
46 | andb $0xfe, %ah \r | |
47 | wrmsr\r | |
48 | movq %rbx, %cr4\r | |
49 | .byte 0x0ea # jmp far jmp_addr\r | |
50 | jmp_addr:\r | |
51 | .long 0\r | |
52 | \r | |
53 | ASM_GLOBAL ASM_PFX(AsmTransferControl32)\r | |
54 | ASM_PFX(AsmTransferControl32):\r | |
55 | # S3WakingVector :DWORD\r | |
56 | # AcpiLowMemoryBase :DWORD\r | |
57 | pushq %rbp\r | |
58 | movl %esp,%ebp\r | |
59 | .byte 0x8d, 0x05 # lea eax, AsmTransferControl16\r | |
60 | ASM_GLOBAL ASM_PFX(AsmFixAddress16)\r | |
61 | ASM_PFX(AsmFixAddress16):\r | |
62 | .long 0\r | |
63 | pushq $0x28 # CS\r | |
64 | pushq %rax\r | |
65 | lret\r | |
66 | \r | |
67 | ASM_GLOBAL ASM_PFX(AsmTransferControl16)\r | |
68 | ASM_PFX(AsmTransferControl16):\r | |
69 | .byte 0xb8,0x30,0 # mov ax, 30h as selector\r | |
70 | movw %ax,%ds\r | |
71 | movw %ax,%es\r | |
72 | movw %ax,%fs\r | |
73 | movw %ax,%gs\r | |
74 | movw %ax,%ss\r | |
75 | movq %cr0, %rax # Get control register 0 \r | |
76 | .byte 0x66\r | |
77 | .byte 0x83,0xe0,0xfe # and eax, 0fffffffeh ; Clear PE bit (bit #0)\r | |
78 | .byte 0xf,0x22,0xc0 # mov cr0, eax ; Activate real mode\r | |
79 | .byte 0xea # jmp far AsmJmpAddr32\r | |
80 | ASM_GLOBAL ASM_PFX(AsmJmpAddr32)\r | |
81 | ASM_PFX(AsmJmpAddr32):\r | |
82 | .long 0\r |