soc/intel/common/block: fix storage size of HEST log address
[coreboot.git] / src / arch / x86 / wakeup.S
blobae2efe00edf388db2625c9158e4c4fa794dc0f2e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #define WAKEUP_BASE             0x600
4 #define RELOCATED(x)    (x - __wakeup + WAKEUP_BASE)
6 /* CR0 bits */
7 #define PE              (1 << 0)
9 #ifdef __x86_64__
10         .code64
11 #else
12         .code32
13 #endif
15         .globl __wakeup
16 __wakeup:
17 #ifdef __x86_64__
18         xor     %rax,%rax
19         mov     %ss, %ax
20         push    %rax
21         mov     %rsp, %rax
22         add     $8, %rax
23         push    %rax
24         pushfq
25         push    $0x10
26         lea     3(%rip), %rax
27         push    %rax
28         iretq
30         .code32
32         /* disable paging */
33         mov     %cr0, %eax
34         btc     $31, %eax
35         mov     %eax, %cr0
37         /* disable long mode */
38         mov     $0xC0000080, %ecx
39         rdmsr
40         btc     $8, %eax
41         wrmsr
42 #endif
43         /* First prepare the jmp to the resume vector */
44         mov     0x4(%esp), %eax /* vector */
45         /* last 4 bits of linear addr are taken as offset */
46         andw    $0x0f, %ax
47         movw    %ax, (__wakeup_offset)
48         mov     0x4(%esp), %eax
49         /* the rest is taken as segment */
50         shr     $4, %eax
51         movw    %ax, (__wakeup_segment)
53         /* Activate the right segment descriptor real mode. */
54         ljmp    $0x28, $RELOCATED(1f)
56 .code16
57         /* 16 bit code from here on... */
59         /* Load the segment registers w/ properly configured
60          * segment descriptors. They will retain these
61          * configurations (limits, writability, etc.) once
62          * protected mode is turned off.
63          */
64         mov     $0x30, %ax
65         mov     %ax, %ds
66         mov     %ax, %es
67         mov     %ax, %fs
68         mov     %ax, %gs
69         mov     %ax, %ss
71         /* Turn off protection */
72         movl    %cr0, %eax
73         andl    $~PE, %eax
74         movl    %eax, %cr0
76         /* Now really going into real mode */
77         ljmp    $0, $RELOCATED(1f)
79         movw    $0x0, %ax
80         movw    %ax, %ds
81         movw    %ax, %es
82         movw    %ax, %ss
83         movw    %ax, %fs
84         movw    %ax, %gs
86         /* This is a FAR JMP to the OS waking vector. The C code changed
87          * the address to be correct.
88          */
89         .byte 0xea
91 __wakeup_offset = RELOCATED(.)
92         .word 0x0000
94 __wakeup_segment = RELOCATED(.)
95         .word 0x0000
97         .globl __wakeup_size
98 __wakeup_size:
99         .long . - __wakeup