blob: a66768c334d6d781d15745bd7fdb2e64d46f2b88 [file] [log] [blame]
Alek Dub7f7baf2008-05-13 16:23:15 +08001/* head.S for bootstub to load protected mode kernel
2 * Copyright (C) 2008 Alek Du <alek.du@intel.com>
3 *
4 * Note. When FW hand-off control to bootstub, the CPU is already in protected
5 * Mode with 1. GDT(8)=4G GDT(10)=4G
6 * 2. CS=8, DS=ES=FS=GS=10
7 * 3. Paging mode disabled
8 * 4. Interrupt ENABLED
9 */
10
11/* When bootstub get control, the memory map in DRAM is like:
12 * ~ ~
13 * 0x102000 | initramfs |
14 *+bzImage size +-----------------------+
15 * | bzImage |
16 * 0x102000 +-----------------------+
17 * | boot stub |
18 * 0x101000 +-----------------------+
19 * | free space |
Alek Dufe0e8ed2008-05-13 17:27:32 +080020 * | used as stack | MIC need to pad this to 0
21 * 0x10010c +-----------------------+
22 * | initramfs offset| MIC need to fill it
23 * 0x100108 +-----------------------+
24 * | initramfs size | MIC need to fill it
25 * 0x100104 +-----------------------+
26 * | cmdline size | MIC need to fill it
Alek Dub7f7baf2008-05-13 16:23:15 +080027 * 0x100100 +-----------------------+
Alek Dufe0e8ed2008-05-13 17:27:32 +080028 * | kernel cmdline | MIC need to fill it
Alek Dub7f7baf2008-05-13 16:23:15 +080029 * 0x100000 +-----------------------+
30*/
31
32#include "bootstub.h"
33
34.text
35
36.section ".text.head","ax",@progbits
37 .globl _start
38
39_start:
40 cld
41 cli
Alek Dub7f7baf2008-05-13 16:23:15 +080042 /* setup stack, because we are heading off to "C" */
43 movl $STACK_OFFSET, %esp
44 /* after call main, GDT was set (0x10 and 0x18) IDT was clear
45 * eax will store 32bit entry of bzImage
46 */
47 calll main
Alek Dufff91f52008-05-14 13:29:27 +080048 /* DS=ES=FS=GS=10 */
49 movl $__BOOT_DS, %ebx
50 movl %ebx, %ds
51 movl %ebx, %es
52 movl %ebx, %fs
53 movl %ebx, %gs
54 movl %ebx, %ss
Alek Dub7f7baf2008-05-13 16:23:15 +080055 ljmp $__BOOT_CS,$1f
561:
57 /* tell kernel where is boot_param */
58 movl $(BOOT_PARAMS_OFFSET), %esi
59 xor %ebp, %ebp
60 xor %edi, %edi
61 xor %ebx, %ebx
62
63 jmpl *%eax # Jump to the 32-bit entrypoint
64