Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 1 | /* For starting coreboot in protected mode */ |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 2 | |
| 3 | #include <arch/rom_segs.h> |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 4 | #include <cpu/x86/post_code.h> |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 5 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 6 | .code32 |
| 7 | |
Stefan Reinauer | a6f0e12 | 2010-08-14 17:27:27 +0000 | [diff] [blame] | 8 | |
Patrick Georgi | 472efa6 | 2012-02-16 20:44:20 +0100 | [diff] [blame] | 9 | /* This is the GDT for the ROM stage part of coreboot. It |
| 10 | * is different from the RAM stage GDT which is defined in |
Stefan Reinauer | a6f0e12 | 2010-08-14 17:27:27 +0000 | [diff] [blame] | 11 | * c_start.S |
| 12 | */ |
| 13 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 14 | .align 4 |
| 15 | .globl gdtptr |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 16 | gdt: |
| 17 | gdtptr: |
| 18 | .word gdt_end - gdt -1 /* compute the table limit */ |
| 19 | .long gdt /* we know the offset */ |
| 20 | .word 0 |
| 21 | |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 22 | /* selgdt 0x08, flat code segment */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 23 | .word 0xffff, 0x0000 |
| 24 | .byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */ |
Li-Ta Lo | f84926e | 2004-11-04 18:36:06 +0000 | [diff] [blame] | 25 | |
| 26 | /* selgdt 0x10,flat data segment */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 27 | .word 0xffff, 0x0000 |
Yinghai Lu | 21332b8 | 2007-04-06 19:49:05 +0000 | [diff] [blame] | 28 | .byte 0x00, 0x93, 0xcf, 0x00 |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 29 | |
Stefan Reinauer | e021dea | 2015-06-18 01:15:27 -0700 | [diff] [blame] | 30 | /* selgdt 0x18, flat code segment (64-bit) */ |
| 31 | .word 0xffff, 0x0000 |
| 32 | .byte 0x00, 0x9b, 0xaf, 0x00 |
| 33 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 34 | gdt_end: |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 35 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 36 | |
| 37 | /* |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 38 | * When we come here we are in protected mode. We expand |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 39 | * the stack and copies the data segment from ROM to the |
| 40 | * memory. |
| 41 | * |
| 42 | * After that, we call the chipset bootstrap routine that |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 43 | * does what is left of the chipset initialization. |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 44 | * |
| 45 | * NOTE aligned to 4 so that we are sure that the prefetch |
| 46 | * cache will be reloaded. |
| 47 | */ |
| 48 | .align 4 |
| 49 | .globl protected_start |
| 50 | protected_start: |
| 51 | |
| 52 | lgdt %cs:gdtptr |
| 53 | ljmp $ROM_CODE_SEG, $__protected_start |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 54 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 55 | __protected_start: |
| 56 | /* Save the BIST value */ |
| 57 | movl %eax, %ebp |
| 58 | |
Martin Roth | 1455437 | 2015-11-12 14:02:42 -0700 | [diff] [blame] | 59 | #if !IS_ENABLED(CONFIG_NO_EARLY_BOOTBLOCK_POSTCODES) |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 60 | post_code(POST_ENTER_PROTECTED_MODE) |
Martin Roth | 1455437 | 2015-11-12 14:02:42 -0700 | [diff] [blame] | 61 | #endif |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 62 | |
| 63 | movw $ROM_DATA_SEG, %ax |
| 64 | movw %ax, %ds |
| 65 | movw %ax, %es |
| 66 | movw %ax, %ss |
| 67 | movw %ax, %fs |
| 68 | movw %ax, %gs |
| 69 | |
| 70 | /* Restore the BIST value to %eax */ |
| 71 | movl %ebp, %eax |