Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 1 | /* |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
| 3 | * |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
Martin Roth | cfc80c2 | 2016-02-02 06:14:44 -0700 | [diff] [blame] | 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Martin Roth | 20bbd81 | 2019-08-30 21:09:37 -0600 | [diff] [blame] | 13 | * |
| 14 | * This is the modern bootblock. It is used by platforms which select |
| 15 | * C_ENVIRONMENT_BOOTBLOCK, and it prepares the system for C environment runtime |
| 16 | * setup. The actual setup is done by hardware-specific code. |
| 17 | * |
| 18 | * It provides a bootflow similar to other architectures, and thus is considered |
| 19 | * to be the modern approach. |
| 20 | * |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 21 | */ |
| 22 | |
Furquan Shaikh | b3ee03c | 2016-04-13 17:15:36 -0700 | [diff] [blame] | 23 | #include <cpu/x86/cr.h> |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Include the old code for reset vector and protected mode entry. That code has |
| 27 | * withstood the test of time. |
| 28 | */ |
| 29 | #include <arch/x86/prologue.inc> |
| 30 | #include <cpu/x86/16bit/entry16.inc> |
| 31 | #include <cpu/x86/16bit/reset16.inc> |
| 32 | #include <cpu/x86/32bit/entry32.inc> |
| 33 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 34 | #if CONFIG(BOOTBLOCK_DEBUG_SPINLOOP) |
Lee Leahy | fdc8c8b | 2016-06-07 08:45:17 -0700 | [diff] [blame] | 35 | |
| 36 | /* Wait for a JTAG debugger to break in and set EBX non-zero */ |
| 37 | xor %ebx, %ebx |
| 38 | |
| 39 | debug_spinloop: |
| 40 | cmp $0, %ebx |
| 41 | jz debug_spinloop |
| 42 | #endif |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 43 | |
| 44 | bootblock_protected_mode_entry: |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 45 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 46 | #if !CONFIG(USE_MARCH_586) |
Kyösti Mälkki | 87efe24 | 2018-12-23 07:22:44 +0200 | [diff] [blame] | 47 | /* MMX registers required here */ |
| 48 | |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 49 | /* BIST result in eax */ |
| 50 | movl %eax, %ebx |
| 51 | |
| 52 | /* Get an early timestamp */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 53 | rdtsc |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 54 | movd %ebx, %mm0 |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 55 | movd %eax, %mm1 |
| 56 | movd %edx, %mm2 |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 57 | #endif |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 58 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 59 | #if CONFIG(SSE) |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 60 | enable_sse: |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 61 | mov %cr4, %eax |
Lee Leahy | 3892597 | 2016-06-08 07:11:48 -0700 | [diff] [blame] | 62 | or $CR4_OSFXSR, %ax |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 63 | mov %eax, %cr4 |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 64 | #endif /* CONFIG(SSE) */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 65 | |
| 66 | /* We're done. Now it's up to platform-specific code */ |
| 67 | jmp bootblock_pre_c_entry |