blob: 197e0fd8e89eb1fd036e9bbe95731db565c54fe0 [file] [log] [blame]
Angel Ponsf23ae0b2020-04-02 23:48:12 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Rudolph1af89232018-11-11 12:50:51 +01002
Patrick Rudolph1af89232018-11-11 12:50:51 +01003#include <cpu/x86/post_code.h>
4
5.global bootblock_pre_c_entry
6bootblock_pre_c_entry:
7
8cache_as_ram:
9 post_code(0x20)
10 /*
11 * Nothing to do here on qemu, RAM works just fine without any
12 * initialization.
13 */
14
Patrick Rudolph1af89232018-11-11 12:50:51 +010015 /* Clear the cache memory region. This will also clear CAR GLOBAL */
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030016 movl $_car_region_start, %edi
Patrick Rudolph1af89232018-11-11 12:50:51 +010017 movl $_car_region_end, %ecx
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030018 sub %edi, %ecx
Patrick Rudolph1af89232018-11-11 12:50:51 +010019 shr $2, %ecx
20 xorl %eax, %eax
21 rep stosl
22
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030023 post_code(0x21)
24
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010025 movl $_ecar_stack, %esp
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030026
27 /* Align the stack and keep aligned for call to bootblock_c_entry() */
28 and $0xfffffff0, %esp
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030029
Patrick Rudolphdc2f0e32019-11-15 12:31:18 +010030 /* entry64.inc preserves ebx. */
31#include <cpu/x86/64bit/entry64.inc>
32
Patrick Rudolph1af89232018-11-11 12:50:51 +010033 /* Restore the BIST result and timestamps. */
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020034#if defined(__x86_64__)
Patrick Rudolph98c987a2020-07-02 08:08:37 +020035 movd %mm2, %rdi
Patrick Rudolph7a042222020-09-29 13:32:06 +020036 shlq $32, %rdi
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020037 movd %mm1, %rsi
38 or %rsi, %rdi
Patrick Rudolph98c987a2020-07-02 08:08:37 +020039
40 movd %mm0, %rsi
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020041#else
42 sub $4, %esp
43
Patrick Rudolph1af89232018-11-11 12:50:51 +010044 movd %mm0, %ebx
45 movd %mm1, %eax
46 movd %mm2, %edx
47
48 pushl %ebx
49 pushl %edx
50 pushl %eax
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020051#endif
Patrick Rudolph1af89232018-11-11 12:50:51 +010052
53before_c_entry:
54 post_code(0x29)
55 call bootblock_c_entry_bist
56 /* Never returns */
57.Lhlt:
58 post_code(POST_DEAD_CODE)
59 hlt
60 jmp .Lhlt