blob: e3a26b0699dad1573d54c1f5de05a09bb93a7584 [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
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +02005.section .init, "ax", @progbits
6
Patrick Rudolph1af89232018-11-11 12:50:51 +01007.global bootblock_pre_c_entry
8bootblock_pre_c_entry:
9
10cache_as_ram:
11 post_code(0x20)
12 /*
13 * Nothing to do here on qemu, RAM works just fine without any
14 * initialization.
15 */
16
Patrick Rudolph1af89232018-11-11 12:50:51 +010017 /* Clear the cache memory region. This will also clear CAR GLOBAL */
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030018 movl $_car_region_start, %edi
Patrick Rudolph1af89232018-11-11 12:50:51 +010019 movl $_car_region_end, %ecx
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030020 sub %edi, %ecx
Patrick Rudolph1af89232018-11-11 12:50:51 +010021 shr $2, %ecx
22 xorl %eax, %eax
23 rep stosl
24
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030025 post_code(0x21)
26
Arthur Heymansdf9cdcf2019-11-09 06:50:20 +010027 movl $_ecar_stack, %esp
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030028
29 /* Align the stack and keep aligned for call to bootblock_c_entry() */
30 and $0xfffffff0, %esp
Kyösti Mälkkia7cac0a2019-08-18 08:30:30 +030031
Patrick Rudolphdc2f0e32019-11-15 12:31:18 +010032 /* entry64.inc preserves ebx. */
33#include <cpu/x86/64bit/entry64.inc>
34
Patrick Rudolph1af89232018-11-11 12:50:51 +010035 /* Restore the BIST result and timestamps. */
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020036#if defined(__x86_64__)
Patrick Rudolph98c987a2020-07-02 08:08:37 +020037 movd %mm2, %rdi
Patrick Rudolph7a042222020-09-29 13:32:06 +020038 shlq $32, %rdi
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020039 movd %mm1, %rsi
40 or %rsi, %rdi
Patrick Rudolph98c987a2020-07-02 08:08:37 +020041
42 movd %mm0, %rsi
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020043#else
44 sub $4, %esp
45
Patrick Rudolph1af89232018-11-11 12:50:51 +010046 movd %mm0, %ebx
47 movd %mm1, %eax
48 movd %mm2, %edx
49
50 pushl %ebx
51 pushl %edx
52 pushl %eax
Patrick Rudolphb1ef7252019-09-28 17:44:01 +020053#endif
Patrick Rudolph1af89232018-11-11 12:50:51 +010054
55before_c_entry:
56 post_code(0x29)
57 call bootblock_c_entry_bist
58 /* Never returns */
59.Lhlt:
60 post_code(POST_DEAD_CODE)
61 hlt
62 jmp .Lhlt