2 * Linux Boot Option ROM
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>
20 * Based on code in hw/pc.c.
23 #include "optionrom.h"
35 read_fw FW_CFG_SETUP_ADDR
40 /* All segments contain real_addr */
47 /* CX = CS we want to jump to */
51 /* SP = cmdline_addr-real_addr-16 */
52 read_fw FW_CFG_CMDLINE_ADDR
54 read_fw FW_CFG_SETUP_ADDR
59 /* Build indirect lret descriptor */
62 pushw %ax /* IP = 0 */
78 /* We need to load the kernel into memory we can't access in 16 bit
79 mode, so let's get into 32 bit mode, write the kernel and jump
82 /* Reserve space on the stack for our GDT descriptor. */
86 /* Now create the GDT descriptor */
87 movw $((3 * 8) - 1), -16(%bp)
94 /* And load the GDT */
98 /* Get us to protected mode now */
102 /* So we can set ES to a 32-bit segment */
106 /* We're now running in 16-bit CS, but 32-bit ES! */
108 /* Load kernel and initrd */
109 read_fw_blob_addr32(FW_CFG_KERNEL)
110 read_fw_blob_addr32(FW_CFG_INITRD)
111 read_fw_blob_addr32(FW_CFG_CMDLINE)
112 read_fw_blob_addr32(FW_CFG_SETUP)
114 /* And now jump into Linux! */
129 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
131 /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
132 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
134 /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
135 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00