blob: 3e9065b707d37afb8baed6f5f01deb873a98aecb [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älkki03083132020-11-22 00:34:13 +020013.section .init, "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/reset16.inc>
20#include <cpu/x86/32bit/entry32.inc>
21
Julius Wernercd49cce2019-03-05 16:53:33 -080022#if CONFIG(BOOTBLOCK_DEBUG_SPINLOOP)
Lee Leahyfdc8c8b2016-06-07 08:45:17 -070023
24 /* Wait for a JTAG debugger to break in and set EBX non-zero */
25 xor %ebx, %ebx
26
27debug_spinloop:
28 cmp $0, %ebx
29 jz debug_spinloop
30#endif
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080031
32bootblock_protected_mode_entry:
Lee Leahy2030d252016-06-05 18:41:00 -070033
Julius Wernercd49cce2019-03-05 16:53:33 -080034#if !CONFIG(USE_MARCH_586)
Kyösti Mälkki87efe242018-12-23 07:22:44 +020035 /* MMX registers required here */
36
Lee Leahy2030d252016-06-05 18:41:00 -070037 /* BIST result in eax */
Himanshu Sahdev aka CunningLearner2b840082019-09-08 12:29:27 +053038 movd %eax, %mm0
Lee Leahy2030d252016-06-05 18:41:00 -070039
40 /* Get an early timestamp */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080041 rdtsc
42 movd %eax, %mm1
43 movd %edx, %mm2
Lee Leahy2030d252016-06-05 18:41:00 -070044#endif
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080045
Julius Wernercd49cce2019-03-05 16:53:33 -080046#if CONFIG(SSE)
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080047enable_sse:
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080048 mov %cr4, %eax
Lee Leahy38925972016-06-08 07:11:48 -070049 or $CR4_OSFXSR, %ax
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080050 mov %eax, %cr4
Julius Wernercd49cce2019-03-05 16:53:33 -080051#endif /* CONFIG(SSE) */
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -080052
53 /* We're done. Now it's up to platform-specific code */
54 jmp bootblock_pre_c_entry