4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Copyright Novell Inc, 2009
18 * Authors: Alexander Graf <agraf@suse.de>
21 #include "optionrom.h"
23 #define MULTIBOOT_MAGIC 0x2badb002
25 #define GS_PROT_JUMP 0
39 /* set up a long jump descriptor that is PC relative */
41 /* move stack memory to %gs */
51 /* now push the indirect jump decriptor there */
54 movl %ebx, %gs:GS_PROT_JUMP
56 movw %bx, %gs:GS_PROT_JUMP + 4
58 /* fix the gdt descriptor to be PC relative */
60 movw %bx, %gs:GS_GDT_DESC
61 movl (gdt_desc+2), %ebx
63 movl %ebx, %gs:GS_GDT_DESC + 2
68 /* Read the bootinfo struct into RAM */
69 read_fw_blob(FW_CFG_INITRD)
71 /* FS = bootinfo_struct */
72 read_fw FW_CFG_INITRD_ADDR
81 /* Initialize multiboot mmap structs using int 0x15(e820) */
83 /* mmap start after first size */
87 /* entry size (mmap struct) & max buffer size (int15) */
89 /* store entry size */
90 /* old as(1) doesn't like this insn so emit the bytes instead:
91 movl %ecx, %es:-4(%edi)
93 .dc.b 0x26,0x67,0x66,0x89,0x4f,0xfc
95 movl $0x0000e820, %eax
97 movl $0x534d4150, %edx
101 /* last entry? then we're done */
105 /* valid entry, so let's loop on */
108 /* %ax = entry_number * 24 */
113 /* %di = 4 + (entry_number * 24) */
119 /* Load the GDT before going into protected mode */
121 data32 lgdt %gs:GS_GDT_DESC
123 /* get us to protected mode now */
127 /* the LJMP sets CS for us and gets us to 32-bit */
129 data32 ljmp *%gs:GS_PROT_JUMP
134 /* initialize all other segments */
142 /* Read the kernel and modules into RAM */
143 read_fw_blob(FW_CFG_KERNEL)
145 /* Jump off to the kernel */
146 read_fw FW_CFG_KERNEL_ENTRY
149 /* EBX contains a pointer to the bootinfo struct */
150 read_fw FW_CFG_INITRD_ADDR
153 /* EAX has to contain the magic */
154 movl $MULTIBOOT_MAGIC, %eax
160 prot_jump: .long prot_mode
166 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
168 /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
169 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
171 /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
172 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
174 /* 0x18: code segment (base=0, limit=0x0ffff, type=16bit code exec/read/conf, DPL=0, 1b) */
175 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00
177 /* 0x20: data segment (base=0, limit=0x0ffff, type=16bit data read/write, DPL=0, 1b) */
178 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00