Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 2 | /* |
Arthur Heymans | c05b1a6 | 2019-11-22 21:01:30 +0100 | [diff] [blame] | 3 | * This is the modern bootblock. It prepares the system for C environment runtime |
Martin Roth | 20bbd81 | 2019-08-30 21:09:37 -0600 | [diff] [blame] | 4 | * 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 Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 9 | */ |
| 10 | |
Furquan Shaikh | b3ee03c | 2016-04-13 17:15:36 -0700 | [diff] [blame] | 11 | #include <cpu/x86/cr.h> |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 12 | |
Kyösti Mälkki | 7522a8f | 2020-11-20 16:47:38 +0200 | [diff] [blame] | 13 | .section .init._start, "ax", @progbits |
Kyösti Mälkki | df771c1 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 14 | |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 15 | /* |
| 16 | * Include the old code for reset vector and protected mode entry. That code has |
| 17 | * withstood the test of time. |
| 18 | */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 19 | #include <cpu/x86/16bit/entry16.inc> |
| 20 | #include <cpu/x86/16bit/reset16.inc> |
| 21 | #include <cpu/x86/32bit/entry32.inc> |
| 22 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 23 | #if CONFIG(BOOTBLOCK_DEBUG_SPINLOOP) |
Lee Leahy | fdc8c8b | 2016-06-07 08:45:17 -0700 | [diff] [blame] | 24 | |
| 25 | /* Wait for a JTAG debugger to break in and set EBX non-zero */ |
| 26 | xor %ebx, %ebx |
| 27 | |
| 28 | debug_spinloop: |
| 29 | cmp $0, %ebx |
| 30 | jz debug_spinloop |
| 31 | #endif |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 32 | |
| 33 | bootblock_protected_mode_entry: |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 34 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 35 | #if !CONFIG(USE_MARCH_586) |
Kyösti Mälkki | 87efe24 | 2018-12-23 07:22:44 +0200 | [diff] [blame] | 36 | /* MMX registers required here */ |
| 37 | |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 38 | /* BIST result in eax */ |
Himanshu Sahdev aka CunningLearner | 2b84008 | 2019-09-08 12:29:27 +0530 | [diff] [blame] | 39 | movd %eax, %mm0 |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 40 | |
| 41 | /* Get an early timestamp */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 42 | rdtsc |
| 43 | movd %eax, %mm1 |
| 44 | movd %edx, %mm2 |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 45 | #endif |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 46 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 47 | #if CONFIG(SSE) |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 48 | enable_sse: |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 49 | mov %cr4, %eax |
Lee Leahy | 3892597 | 2016-06-08 07:11:48 -0700 | [diff] [blame] | 50 | or $CR4_OSFXSR, %ax |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 51 | mov %eax, %cr4 |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 52 | #endif /* CONFIG(SSE) */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 53 | |
| 54 | /* We're done. Now it's up to platform-specific code */ |
| 55 | jmp bootblock_pre_c_entry |