blob: 387920e38affdf997ffc70fd8133af4cd833b469 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -08002/*
Arthur Heymansc05b1a62019-11-22 21:01:30 +01003 * This is the modern bootblock. It prepares the system for C environment runtime
Martin Roth20bbd812019-08-30 21:09:37 -06004 * setup. The actual setup is done by hardware-specific code.
5 *
6 * It provides a bootflow similar to other architectures, and thus is considered
7 * to be the modern approach.
8 *
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -08009 */
10
Furquan Shaikhb3ee03c2016-04-13 17:15:36 -070011#include <cpu/x86/cr.h>
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080012
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +020013.section .init._start, "ax", @progbits
Kyösti Mälkkidf771c12019-12-21 10:17:56 +020014
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080015/*
16 * Include the old code for reset vector and protected mode entry. That code has
17 * withstood the test of time.
18 */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080019#include <cpu/x86/16bit/entry16.inc>
20#include <cpu/x86/16bit/reset16.inc>
21#include <cpu/x86/32bit/entry32.inc>
22
Julius Wernercd49cce2019-03-05 16:53:33 -080023#if CONFIG(BOOTBLOCK_DEBUG_SPINLOOP)
Lee Leahyfdc8c8b2016-06-07 08:45:17 -070024
25 /* Wait for a JTAG debugger to break in and set EBX non-zero */
26 xor %ebx, %ebx
27
28debug_spinloop:
29 cmp $0, %ebx
30 jz debug_spinloop
31#endif
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080032
33bootblock_protected_mode_entry:
Lee Leahy2030d252016-06-05 18:41:00 -070034
Julius Wernercd49cce2019-03-05 16:53:33 -080035#if !CONFIG(USE_MARCH_586)
Kyösti Mälkki87efe242018-12-23 07:22:44 +020036 /* MMX registers required here */
37
Lee Leahy2030d252016-06-05 18:41:00 -070038 /* BIST result in eax */
Himanshu Sahdev aka CunningLearner2b840082019-09-08 12:29:27 +053039 movd %eax, %mm0
Lee Leahy2030d252016-06-05 18:41:00 -070040
41 /* Get an early timestamp */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080042 rdtsc
43 movd %eax, %mm1
44 movd %edx, %mm2
Lee Leahy2030d252016-06-05 18:41:00 -070045#endif
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080046
Julius Wernercd49cce2019-03-05 16:53:33 -080047#if CONFIG(SSE)
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080048enable_sse:
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080049 mov %cr4, %eax
Lee Leahy38925972016-06-08 07:11:48 -070050 or $CR4_OSFXSR, %ax
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080051 mov %eax, %cr4
Julius Wernercd49cce2019-03-05 16:53:33 -080052#endif /* CONFIG(SSE) */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080053
54 /* We're done. Now it's up to platform-specific code */
55 jmp bootblock_pre_c_entry