Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 1 | /* 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 Du | fe0e8ed | 2008-05-13 17:27:32 +0800 | [diff] [blame] | 20 | * | 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 Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 27 | * 0x100100 +-----------------------+ |
Alek Du | fe0e8ed | 2008-05-13 17:27:32 +0800 | [diff] [blame] | 28 | * | kernel cmdline | MIC need to fill it |
Alek Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 29 | * 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 Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 42 | /* 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 Du | fff91f5 | 2008-05-14 13:29:27 +0800 | [diff] [blame] | 48 | /* 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 Du | b7f7baf | 2008-05-13 16:23:15 +0800 | [diff] [blame] | 55 | ljmp $__BOOT_CS,$1f |
| 56 | 1: |
| 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 | |