blob: 9ef3bc1c6e8302b0f2d98949c6adba2cf9f0cd80 [file] [log] [blame]
Stefan Reinauerf8ee1802008-01-18 15:08:58 +00001/* For starting coreboot in protected mode */
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00002
3#include <arch/rom_segs.h>
Alexandru Gagniuc5005bb062011-04-11 20:17:22 +00004#include <cpu/x86/post_code.h>
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00005
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00006 .code32
7
Stefan Reinauera6f0e122010-08-14 17:27:27 +00008
Patrick Georgi472efa62012-02-16 20:44:20 +01009 /* 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 Reinauera6f0e122010-08-14 17:27:27 +000011 * c_start.S
12 */
13
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000014 .align 4
15.globl gdtptr
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000016gdt:
17gdtptr:
18 .word gdt_end - gdt -1 /* compute the table limit */
19 .long gdt /* we know the offset */
20 .word 0
21
Li-Ta Lof84926e2004-11-04 18:36:06 +000022 /* selgdt 0x08, flat code segment */
Stefan Reinauer14e22772010-04-27 06:56:47 +000023 .word 0xffff, 0x0000
24 .byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */
Li-Ta Lof84926e2004-11-04 18:36:06 +000025
26 /* selgdt 0x10,flat data segment */
Stefan Reinauer14e22772010-04-27 06:56:47 +000027 .word 0xffff, 0x0000
Yinghai Lu21332b82007-04-06 19:49:05 +000028 .byte 0x00, 0x93, 0xcf, 0x00
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000029
Stefan Reinauere021dea2015-06-18 01:15:27 -070030 /* selgdt 0x18, flat code segment (64-bit) */
31 .word 0xffff, 0x0000
32 .byte 0x00, 0x9b, 0xaf, 0x00
33
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000034gdt_end:
Stefan Reinauer14e22772010-04-27 06:56:47 +000035
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000036
37/*
Stefan Reinauer14e22772010-04-27 06:56:47 +000038 * When we come here we are in protected mode. We expand
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000039 * 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 Reinauer14e22772010-04-27 06:56:47 +000043 * does what is left of the chipset initialization.
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000044 *
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
50protected_start:
51
52 lgdt %cs:gdtptr
53 ljmp $ROM_CODE_SEG, $__protected_start
Stefan Reinauer14e22772010-04-27 06:56:47 +000054
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000055__protected_start:
56 /* Save the BIST value */
57 movl %eax, %ebp
58
Martin Roth14554372015-11-12 14:02:42 -070059#if !IS_ENABLED(CONFIG_NO_EARLY_BOOTBLOCK_POSTCODES)
Alexandru Gagniuc5005bb062011-04-11 20:17:22 +000060 post_code(POST_ENTER_PROTECTED_MODE)
Martin Roth14554372015-11-12 14:02:42 -070061#endif
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000062
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