Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 2 | |
| 3 | /* For starting coreboot in protected mode */ |
| 4 | |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 5 | /* |
Arthur Heymans | c05b1a6 | 2019-11-22 21:01:30 +0100 | [diff] [blame] | 6 | * 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] | 7 | * setup. The actual setup is done by hardware-specific code. |
| 8 | * |
| 9 | * It provides a bootflow similar to other architectures, and thus is considered |
| 10 | * to be the modern approach. |
| 11 | * |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 12 | */ |
| 13 | |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 14 | #include <arch/rom_segs.h> |
Furquan Shaikh | b3ee03c | 2016-04-13 17:15:36 -0700 | [diff] [blame] | 15 | #include <cpu/x86/cr.h> |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 16 | #include <cpu/x86/post_code.h> |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 17 | |
Kyösti Mälkki | 0308313 | 2020-11-22 00:34:13 +0200 | [diff] [blame] | 18 | .section .init, "ax", @progbits |
Kyösti Mälkki | df771c1 | 2019-12-21 10:17:56 +0200 | [diff] [blame] | 19 | |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 20 | .code32 |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 21 | /* |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 22 | * When we come here we are in protected mode. |
| 23 | * NOTE aligned to 4 so that we are sure that the prefetch |
| 24 | * cache will be reloaded. |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 25 | */ |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 26 | .align 4 |
| 27 | |
Kyösti Mälkki | 6c7441f | 2020-12-05 08:39:57 +0200 | [diff] [blame] | 28 | .globl bootblock_protected_mode_entry |
| 29 | bootblock_protected_mode_entry: |
| 30 | |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 31 | /* Save the BIST value */ |
| 32 | movl %eax, %ebp |
| 33 | |
lilacious | 40cb3fe | 2023-06-21 23:24:14 +0200 | [diff] [blame^] | 34 | post_code(POSTCODE_ENTER_PROTECTED_MODE) |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 35 | |
| 36 | movw $ROM_DATA_SEG, %ax |
| 37 | movw %ax, %ds |
| 38 | movw %ax, %es |
| 39 | movw %ax, %ss |
Raul E Rangel | ea5c311 | 2021-09-21 10:17:24 -0600 | [diff] [blame] | 40 | xor %ax, %ax /* zero out the gs and fs segment index */ |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 41 | movw %ax, %fs |
Raul E Rangel | ea5c311 | 2021-09-21 10:17:24 -0600 | [diff] [blame] | 42 | movw %ax, %gs /* Will be used for cpu_info */ |
Kyösti Mälkki | 47d58e5 | 2020-11-22 00:55:31 +0200 | [diff] [blame] | 43 | |
| 44 | /* Restore the BIST value to %eax */ |
| 45 | movl %ebp, %eax |
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(BOOTBLOCK_DEBUG_SPINLOOP) |
Lee Leahy | fdc8c8b | 2016-06-07 08:45:17 -0700 | [diff] [blame] | 48 | |
| 49 | /* Wait for a JTAG debugger to break in and set EBX non-zero */ |
| 50 | xor %ebx, %ebx |
| 51 | |
| 52 | debug_spinloop: |
| 53 | cmp $0, %ebx |
| 54 | jz debug_spinloop |
| 55 | #endif |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 56 | |
Kyösti Mälkki | 87efe24 | 2018-12-23 07:22:44 +0200 | [diff] [blame] | 57 | /* MMX registers required here */ |
| 58 | |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 59 | /* BIST result in eax */ |
Himanshu Sahdev aka CunningLearner | 2b84008 | 2019-09-08 12:29:27 +0530 | [diff] [blame] | 60 | movd %eax, %mm0 |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 61 | |
Kyösti Mälkki | 6c7441f | 2020-12-05 08:39:57 +0200 | [diff] [blame] | 62 | __timestamp: |
| 63 | |
Lee Leahy | 2030d25 | 2016-06-05 18:41:00 -0700 | [diff] [blame] | 64 | /* Get an early timestamp */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 65 | rdtsc |
| 66 | movd %eax, %mm1 |
| 67 | movd %edx, %mm2 |
| 68 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 69 | #if CONFIG(SSE) |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 70 | enable_sse: |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 71 | mov %cr4, %eax |
Lee Leahy | 3892597 | 2016-06-08 07:11:48 -0700 | [diff] [blame] | 72 | or $CR4_OSFXSR, %ax |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 73 | mov %eax, %cr4 |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 74 | #endif /* CONFIG(SSE) */ |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 75 | |
| 76 | /* We're done. Now it's up to platform-specific code */ |
| 77 | jmp bootblock_pre_c_entry |