blob: afd84d0c6b5df4d2ee018a5ffdbd14ec0a3e4c19 [file] [log] [blame]
Alek Dub379eef2008-05-21 13:37:04 +08001/*
2 * head.S for bootstub to load protected mode kernel
Alek Duf21b9a32010-05-27 14:23:43 +08003 *
4 * Copyright (C) 2008-2010 Intel Corporation.
5 * Author: Alek Du <alek.du@intel.com>
Alek Dub379eef2008-05-21 13:37:04 +08006 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22/*
23 *
Alek Dub7f7baf2008-05-13 16:23:15 +080024 * Note. When FW hand-off control to bootstub, the CPU is already in protected
25 * Mode with 1. GDT(8)=4G GDT(10)=4G
26 * 2. CS=8, DS=ES=FS=GS=10
27 * 3. Paging mode disabled
28 * 4. Interrupt ENABLED
Alek Dub379eef2008-05-21 13:37:04 +080029 *
30 * When bootstub get control, the memory map in DRAM is like:
Alek Dub7f7baf2008-05-13 16:23:15 +080031 * ~ ~
Alek Du56ce5ad2008-08-27 12:43:56 +080032 * 0x1102000 | initrd | initrd will move to highest memory otherwise
Alek Du0fdceca2008-05-14 17:36:34 +080033 *+bzImage size +-----------------------+ bzImage uncompressing will destory it
Alek Dub7f7baf2008-05-13 16:23:15 +080034 * | bzImage |
Alek Du56ce5ad2008-08-27 12:43:56 +080035 * 0x1102000 +-----------------------+
Alek Dub7f7baf2008-05-13 16:23:15 +080036 * | boot stub |
Alek Du56ce5ad2008-08-27 12:43:56 +080037 * 0x1101000 +-----------------------+
Alek Dub7f7baf2008-05-13 16:23:15 +080038 * | free space |
Alek Du0fdceca2008-05-14 17:36:34 +080039 * | used as stack |
Alek Dua8cef7f2009-06-04 15:02:03 +080040 * 0x1100110 +-----------------------+
41 * | SPI0 or SPI1 | MIC need to fill it:
42 * | | 0x0: SPI0, 0x1: SPI1
43 * 0x110010c +-----------------------+
Alek Duc8496d12008-07-10 14:46:17 +080044 * | boot stub spi uart | MIC need to fill it:
45 * | suppression flag | 0x1 suppression, 0x0 default
Alek Du56ce5ad2008-08-27 12:43:56 +080046 * 0x1100108 +-----------------------+
Alek Duc8496d12008-07-10 14:46:17 +080047 * | initrd size | MIC need to fill it: initrd file size
Alek Du56ce5ad2008-08-27 12:43:56 +080048 * 0x1100104 +-----------------------+
Alek Duc8496d12008-07-10 14:46:17 +080049 * | bzImage size | MIC need to fill it: bzImage file size
Alek Du56ce5ad2008-08-27 12:43:56 +080050 * 0x1100100 +-----------------------+
Alek Dufe0e8ed2008-05-13 17:27:32 +080051 * | kernel cmdline | MIC need to fill it
Alek Du56ce5ad2008-08-27 12:43:56 +080052 * 0x1100000 +-----------------------+
Alek Dub7f7baf2008-05-13 16:23:15 +080053*/
54
55#include "bootstub.h"
56
57.text
58
59.section ".text.head","ax",@progbits
60 .globl _start
61
62_start:
63 cld
64 cli
Evgeny Kalugin8e8bf002013-10-24 11:21:07 +030065 /* setup stack, because we are heading off to "C" */
66 movl $STACK_OFFSET, %esp
67 calll bootstub
68 /* after call bootstub, GDT is set, IDT is clear
69 * eax contains 32-bit entry of bzImage
70 */
Alek Dufff91f52008-05-14 13:29:27 +080071 movl $__BOOT_DS, %ebx
72 movl %ebx, %ds
73 movl %ebx, %es
74 movl %ebx, %fs
75 movl %ebx, %gs
76 movl %ebx, %ss
Evgeny Kalugin8e8bf002013-10-24 11:21:07 +030077 ljmp $__BOOT_CS,$1f
781:
Alek Dub7f7baf2008-05-13 16:23:15 +080079 /* tell kernel where is boot_param */
80 movl $(BOOT_PARAMS_OFFSET), %esi
81 xor %ebp, %ebp
82 xor %edi, %edi
Evgeny Kalugin8e8bf002013-10-24 11:21:07 +030083 mov %eax, %ecx
84 mov mb_magic, %eax
85 mov mb_info, %ebx
Bin Gao923fa8d2013-03-30 00:27:10 -070086
Evgeny Kalugin8e8bf002013-10-24 11:21:07 +030087 jmpl *%ecx # Jump to the 32-bit entrypoint