740ea47bc7739099a4ef4e7b698c329c12db7a7c
[coreboot.git] / src / cpu / x86 / 32bit / entry32.inc
1 /* For starting coreboot in protected mode */
2
3 #include <arch/rom_segs.h>
4 #include <cpu/x86/post_code.h>
5
6         .code32
7
8
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 
11          * c_start.S
12          */
13
14         .align  4
15 .globl gdtptr
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
22         /* selgdt 0x08, flat code segment */
23         .word   0xffff, 0x0000
24         .byte   0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */
25
26         /* selgdt 0x10,flat data segment */
27         .word   0xffff, 0x0000
28         .byte   0x00, 0x93, 0xcf, 0x00
29
30 gdt_end:
31
32
33 /*
34  *      When we come here we are in protected mode. We expand
35  *      the stack and copies the data segment from ROM to the
36  *      memory.
37  *
38  *      After that, we call the chipset bootstrap routine that
39  *      does what is left of the chipset initialization.
40  *
41  *      NOTE aligned to 4 so that we are sure that the prefetch
42  *      cache will be reloaded.
43  */
44         .align  4
45 .globl protected_start
46 protected_start:
47
48         lgdt    %cs:gdtptr
49         ljmp    $ROM_CODE_SEG, $__protected_start
50
51 __protected_start:
52         /* Save the BIST value */
53         movl    %eax, %ebp
54
55         post_code(POST_ENTER_PROTECTED_MODE)
56
57         movw    $ROM_DATA_SEG, %ax
58         movw    %ax, %ds
59         movw    %ax, %es
60         movw    %ax, %ss
61         movw    %ax, %fs
62         movw    %ax, %gs
63
64         /* Restore the BIST value to %eax */
65         movl    %ebp, %eax
66