Alek Du | b379eef | 2008-05-21 13:37:04 +0800 | [diff] [blame] | 1 | /* |
| 2 | * head.S for bootstub to load protected mode kernel |
Alek Du | f21b9a3 | 2010-05-27 14:23:43 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2008-2010 Intel Corporation. |
| 5 | * Author: Alek Du <alek.du@intel.com> |
Alek Du | b379eef | 2008-05-21 13:37:04 +0800 | [diff] [blame] | 6 | * |
| 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 Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 24 | * 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 Du | b379eef | 2008-05-21 13:37:04 +0800 | [diff] [blame] | 29 | * |
| 30 | * When bootstub get control, the memory map in DRAM is like: |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 31 | * ~ ~ |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 32 | * 0x1102000 | initrd | initrd will move to highest memory otherwise |
Alek Du | 0fdceca | 2008-05-14 17:36:34 +0800 | [diff] [blame] | 33 | *+bzImage size +-----------------------+ bzImage uncompressing will destory it |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 34 | * | bzImage | |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 35 | * 0x1102000 +-----------------------+ |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 36 | * | boot stub | |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 37 | * 0x1101000 +-----------------------+ |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 38 | * | free space | |
Alek Du | 0fdceca | 2008-05-14 17:36:34 +0800 | [diff] [blame] | 39 | * | used as stack | |
Alek Du | a8cef7f | 2009-06-04 15:02:03 +0800 | [diff] [blame] | 40 | * 0x1100110 +-----------------------+ |
| 41 | * | SPI0 or SPI1 | MIC need to fill it: |
| 42 | * | | 0x0: SPI0, 0x1: SPI1 |
| 43 | * 0x110010c +-----------------------+ |
Alek Du | c8496d1 | 2008-07-10 14:46:17 +0800 | [diff] [blame] | 44 | * | boot stub spi uart | MIC need to fill it: |
| 45 | * | suppression flag | 0x1 suppression, 0x0 default |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 46 | * 0x1100108 +-----------------------+ |
Alek Du | c8496d1 | 2008-07-10 14:46:17 +0800 | [diff] [blame] | 47 | * | initrd size | MIC need to fill it: initrd file size |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 48 | * 0x1100104 +-----------------------+ |
Alek Du | c8496d1 | 2008-07-10 14:46:17 +0800 | [diff] [blame] | 49 | * | bzImage size | MIC need to fill it: bzImage file size |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 50 | * 0x1100100 +-----------------------+ |
Alek Du | fe0e8ed | 2008-05-13 17:27:32 +0800 | [diff] [blame] | 51 | * | kernel cmdline | MIC need to fill it |
Alek Du | 56ce5ad | 2008-08-27 12:43:56 +0800 | [diff] [blame] | 52 | * 0x1100000 +-----------------------+ |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 53 | */ |
| 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 Kalugin | 8e8bf00 | 2013-10-24 11:21:07 +0300 | [diff] [blame] | 65 | /* 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 Du | fff91f5 | 2008-05-14 13:29:27 +0800 | [diff] [blame] | 71 | 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 Kalugin | 8e8bf00 | 2013-10-24 11:21:07 +0300 | [diff] [blame] | 77 | ljmp $__BOOT_CS,$1f |
| 78 | 1: |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 79 | /* tell kernel where is boot_param */ |
| 80 | movl $(BOOT_PARAMS_OFFSET), %esi |
| 81 | xor %ebp, %ebp |
| 82 | xor %edi, %edi |
Evgeny Kalugin | 8e8bf00 | 2013-10-24 11:21:07 +0300 | [diff] [blame] | 83 | mov %eax, %ecx |
| 84 | mov mb_magic, %eax |
| 85 | mov mb_info, %ebx |
Bin Gao | 923fa8d | 2013-03-30 00:27:10 -0700 | [diff] [blame] | 86 | |
Evgeny Kalugin | 8e8bf00 | 2013-10-24 11:21:07 +0300 | [diff] [blame] | 87 | jmpl *%ecx # Jump to the 32-bit entrypoint |