]> Git Repo - J-u-boot.git/blame - arch/x86/cpu/start16.S
common: Drop asm/global_data.h from common header
[J-u-boot.git] / arch / x86 / cpu / start16.S
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
2262cfee 2/*
fea1c47f 3 * U-Boot - x86 Startup Code
2262cfee 4 *
dbf7115a
GR
5 * (C) Copyright 2008-2011
6 * Graeme Russ, <[email protected]>
7 *
8 * (C) Copyright 2002,2003
fa82f871 9 * Daniel Engström, Omicron Ceti AB, <[email protected]>
2262cfee
WD
10 */
11
0c24c9cc 12#include <asm/processor-flags.h>
2262cfee
WD
13
14#define BOOT_SEG 0xffff0000 /* linear segment of boot code */
2262cfee
WD
15
16.section .start16, "ax"
17.code16
18.globl start16
8bde7f77 19start16:
f67cd51e
SG
20 /* Save BIST */
21 movl %eax, %ecx
22
3c00695e 23 xorl %eax, %eax
fea1c47f 24 movl %eax, %cr3 /* Invalidate TLB */
3c00695e 25
85d87328 26 /* Turn off cache (this might require a 486-class CPU) */
53677ef1 27 movl %cr0, %eax
7b3d5380 28 orl $(X86_CR0_NW | X86_CR0_CD), %eax
53677ef1 29 movl %eax, %cr0
fa97ca16 30 wbinvd
8bde7f77 31
c14a3669 32 /* load the temporary Global Descriptor Table */
0d915a9a
MY
33data32 cs lidt idt_ptr
34data32 cs lgdt gdt_ptr
2262cfee 35
2262cfee 36 /* Now, we enter protected mode */
53677ef1 37 movl %cr0, %eax
0c24c9cc 38 orl $X86_CR0_PE, %eax
53677ef1 39 movl %eax, %cr0
8bde7f77 40
2262cfee 41 /* Flush the prefetch queue */
53677ef1 42 jmp ff
2262cfee 43ff:
f67cd51e 44
fea1c47f 45 /* Finally restore BIST and jump to the 32-bit initialization code */
f67cd51e 46 movl %ecx, %eax
90ab311a 47data32 cs ljmp *code32start
2262cfee
WD
48
49 /* 48-bit far pointer */
50code32start:
53677ef1
WD
51 .long _start /* offset */
52 .word 0x10 /* segment */
2262cfee 53
797960fd
GR
54idt_ptr:
55 .word 0 /* limit */
56 .long 0 /* base */
57
fea1c47f
BM
58 /*
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
62 */
2262cfee 63gdt_ptr:
35d4fed3 64 .word 0x1f /* limit (31 bytes = 4 GDT entries - 1) */
002610f6 65 .long BOOT_SEG + gdt_rom /* base */
2262cfee 66
fea1c47f
BM
67 /* Some CPUs are picky about GDT alignment... */
68 .align 16
002610f6
BM
69.globl gdt_rom
70gdt_rom:
58c7a675
GR
71 /*
72 * The GDT table ...
2262cfee 73 *
53677ef1
WD
74 * Selector Type
75 * 0x00 NULL
76 * 0x08 Unused
8bde7f77 77 * 0x10 32bit code
2262cfee 78 * 0x18 32bit data/stack
2262cfee 79 */
58c7a675
GR
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 */
2262cfee 87
58c7a675
GR
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 */
53677ef1 95
58c7a675
GR
96 /*
97 * The Code Segment Descriptor:
98 * - Base = 0x00000000
99 * - Size = 4GB
100 * - Access = Present, Ring 0, Exec (Code), Readable
101 * - Flags = 4kB Granularity, 32-bit
102 */
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 */
53677ef1 109
58c7a675
GR
110 /*
111 * The Data Segment Descriptor:
112 * - Base = 0x00000000
113 * - Size = 4GB
114 * - Access = Present, Ring 0, Non-Exec (Data), Writable
115 * - Flags = 4kB Granularity, 32-bit
116 */
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 */
This page took 0.500158 seconds and 4 git commands to generate.