]> git.sur5r.net Git - u-boot/blob - arch/i386/cpu/start16.S
x86: Dont clobber %eax after getting memory size
[u-boot] / arch / i386 / cpu / start16.S
1 /*
2  *  U-boot - i386 Startup Code
3  *
4  *  Copyright (c) 2002, 2003 Omicron Ceti AB, Daniel Engström <denaiel@omicron.se>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24
25
26 #define BOOT_SEG        0xffff0000      /* linear segment of boot code */
27 #define a32             .byte 0x67;
28 #define o32             .byte 0x66;
29
30 .section .start16, "ax"
31 .code16
32 .globl start16
33 start16:
34         /*
35          * First we let the BSP do some early initialization
36          * this code have to map the flash to its final position
37          */
38         jmp     board_init16
39 .globl board_init16_ret
40 board_init16_ret:
41
42         /* Turn of cache (this might require a 486-class CPU) */
43         movl    %cr0, %eax
44         orl     $0x60000000, %eax
45         movl    %eax, %cr0
46         wbinvd
47
48         /* load the temporary Global Descriptor Table */
49 o32 cs  lidt    idt_ptr
50 o32 cs  lgdt    gdt_ptr
51
52         /* Now, we enter protected mode */
53         movl    %cr0, %eax
54         orl     $1, %eax
55         movl    %eax, %cr0
56
57         /* Flush the prefetch queue */
58         jmp     ff
59 ff:
60         /* Tell 32-bit code it is being entered from hard-reset */
61         movw    $0x0001, %bx
62
63         /* Finally jump to the 32bit initialization code */
64         movw    $code32start, %ax
65         movw    %ax, %bp
66 o32 cs  ljmp    *(%bp)
67
68         /* 48-bit far pointer */
69 code32start:
70         .long   _start          /* offset */
71         .word   0x10            /* segment */
72
73 idt_ptr:
74         .word   0               /* limit */
75         .long   0               /* base */
76
77 /*
78  * The following Global Descriptor Table is just enough to get us into
79  * 'Flat Protected Mode' - It will be discarded as soon as the final
80  * GDT is setup in a safe location in RAM
81  */
82 gdt_ptr:
83         .word   0x20            /* limit (32 bytes = 4 GDT entries) */
84         .long   BOOT_SEG + gdt  /* base */
85
86         /* The GDT table ...
87          *
88          *       Selector       Type
89          *       0x00           NULL
90          *       0x08           Unused
91          *       0x10           32bit code
92          *       0x18           32bit data/stack
93          */
94
95 gdt:
96         .word   0, 0, 0, 0      /* NULL  */
97         .word   0, 0, 0, 0      /* unused */
98
99         .word   0xFFFF          /* 4Gb - (0x100000*0x1000 = 4Gb) */
100         .word   0               /* base address = 0 */
101         .word   0x9B00          /* code read/exec */
102         .word   0x00CF          /* granularity = 4096, 386 (+5th nibble of limit) */
103
104         .word   0xFFFF          /* 4Gb - (0x100000*0x1000 = 4Gb) */
105         .word   0x0             /* base address = 0 */
106         .word   0x9300          /* data read/write */
107         .word   0x00CF          /* granularity = 4096, 386 (+5th nibble of limit) */