1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * U-Boot - x86 Startup Code
5 * (C) Copyright 2008-2011
6 * Graeme Russ, <graeme.russ@gmail.com>
8 * (C) Copyright 2002,2003
9 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
12 #include <asm/processor-flags.h>
14 #define BOOT_SEG 0xffff0000 /* linear segment of boot code */
16 .section .start16, "ax"
24 movl %eax, %cr3 /* Invalidate TLB */
26 /* Turn off cache (this might require a 486-class CPU) */
28 orl $(X86_CR0_NW | X86_CR0_CD), %eax
32 /* load the temporary Global Descriptor Table */
33 data32 cs lidt idt_ptr
34 data32 cs lgdt gdt_ptr
36 /* Now, we enter protected mode */
41 /* Flush the prefetch queue */
45 /* Finally restore BIST and jump to the 32-bit initialization code */
47 data32 cs ljmp *code32start
49 /* 48-bit far pointer */
51 .long _start /* offset */
52 .word 0x10 /* segment */
59 * The following Global Descriptor Table is just enough to get us into
60 * 'Flat Protected Mode' - It will be discarded as soon as the final
61 * GDT is setup in a safe location in RAM
64 .word 0x1f /* limit (31 bytes = 4 GDT entries - 1) */
65 .long BOOT_SEG + gdt_rom /* base */
67 /* Some CPUs are picky about GDT alignment... */
78 * 0x18 32bit data/stack
80 /* The NULL Desciptor - Mandatory */
81 .word 0x0000 /* limit_low */
82 .word 0x0000 /* base_low */
83 .byte 0x00 /* base_middle */
84 .byte 0x00 /* access */
85 .byte 0x00 /* flags + limit_high */
86 .byte 0x00 /* base_high */
88 /* Unused Desciptor - (matches Linux) */
89 .word 0x0000 /* limit_low */
90 .word 0x0000 /* base_low */
91 .byte 0x00 /* base_middle */
92 .byte 0x00 /* access */
93 .byte 0x00 /* flags + limit_high */
94 .byte 0x00 /* base_high */
97 * The Code Segment Descriptor:
100 * - Access = Present, Ring 0, Exec (Code), Readable
101 * - Flags = 4kB Granularity, 32-bit
103 .word 0xffff /* limit_low */
104 .word 0x0000 /* base_low */
105 .byte 0x00 /* base_middle */
106 .byte 0x9b /* access */
107 .byte 0xcf /* flags + limit_high */
108 .byte 0x00 /* base_high */
111 * The Data Segment Descriptor:
112 * - Base = 0x00000000
114 * - Access = Present, Ring 0, Non-Exec (Data), Writable
115 * - Flags = 4kB Granularity, 32-bit
117 .word 0xffff /* limit_low */
118 .word 0x0000 /* base_low */
119 .byte 0x00 /* base_middle */
120 .byte 0x93 /* access */
121 .byte 0xcf /* flags + limit_high */
122 .byte 0x00 /* base_high */