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, write to the Free Software
16 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Copyright Novell Inc, 2009
19 * Authors: Alexander Graf <agraf@suse.de>
22 #define NO_QEMU_PROTOS
23 #include "../../hw/fw_cfg.h"
25 #define BIOS_CFG_IOPORT_CFG 0x510
26 #define BIOS_CFG_IOPORT_DATA 0x511
28 #define MULTIBOOT_MAGIC 0x2badb002
30 /* Read a variable from the fw_cfg device.
35 mov $BIOS_CFG_IOPORT_CFG, %dx
37 mov $BIOS_CFG_IOPORT_DATA, %dx
53 .byte 1 /* (_end - _start) / 512 */
57 /* setup ds so we can access the IVT */
63 mov %eax, %cs:old_int19
65 /* install our int 19 handler */
66 movw $int19_handler, (0x19*4)
88 /* fix the gdt descriptor to be PC relative */
89 mov (gdt_desc+2), %ebx
91 mov %ebx, (gdt_desc+2)
93 /* fix the prot mode indirect jump to be PC relative */
98 /* FS = bootinfo_struct */
99 read_fw FW_CFG_INITRD_ADDR
104 read_fw FW_CFG_INITRD_SIZE
108 /* Initialize multiboot mmap structs using int 0x15(e820) */
110 /* mmap start after first size */
114 /* entry size (mmap struct) & max buffer size (int15) */
116 /* store entry size */
117 movl %ecx, %es:-4(%edi)
119 movl $0x0000e820, %eax
121 movl $0x534d4150, %edx
125 /* last entry? then we're done */
129 /* valid entry, so let's loop on */
132 /* %ax = entry_number * 24 */
137 /* %di = 4 + (entry_number * 24) */
143 /* Load the GDT before going into protected mode */
145 data32 lgdt %cs:gdt_desc
147 /* get us to protected mode now */
151 /* the LJMP sets CS for us and gets us to 32-bit */
153 data32 ljmp *%cs:prot_jump
158 /* initialize all other segments */
166 /* Jump off to the kernel */
167 read_fw FW_CFG_KERNEL_ADDR
170 /* EBX contains a pointer to the bootinfo struct */
171 read_fw FW_CFG_INITRD_ADDR
174 /* EAX has to contain the magic */
175 movl $MULTIBOOT_MAGIC, %eax
183 prot_jump: .long prot_mode
189 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
191 /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */
192 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
194 /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */
195 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
197 /* 0x18: code segment (base=0, limit=0x0ffff, type=16bit code exec/read/conf, DPL=0, 1b) */
198 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00
200 /* 0x20: data segment (base=0, limit=0x0ffff, type=16bit data read/write, DPL=0, 1b) */
201 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00