diff options
author | Alexander Graf <agraf@suse.de> | 2009-11-12 21:53:13 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-11-17 10:39:03 -0600 |
commit | dd4b2659cda69cee6808ce4fcf4e2f3eeebd0b08 (patch) | |
tree | 3f2e2c9e0625404d8026f645256675f41992d681 | |
parent | Convert multiboot to fw_cfg backed data storage (diff) | |
download | qemu-kvm-dd4b2659cda69cee6808ce4fcf4e2f3eeebd0b08.tar.gz qemu-kvm-dd4b2659cda69cee6808ce4fcf4e2f3eeebd0b08.tar.bz2 qemu-kvm-dd4b2659cda69cee6808ce4fcf4e2f3eeebd0b08.zip |
Move common option rom code to header file
We will have a linux boot option rom soon, so let's take all functionality
that might be useful for both to a header file that both roms can include.
That way we only have to write fw_cfg access code once.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | pc-bios/optionrom/multiboot.S | 79 | ||||
-rw-r--r-- | pc-bios/optionrom/optionrom.h | 107 |
2 files changed, 110 insertions, 76 deletions
diff --git a/pc-bios/optionrom/multiboot.S b/pc-bios/optionrom/multiboot.S index dafac7392..be5c9fcf3 100644 --- a/pc-bios/optionrom/multiboot.S +++ b/pc-bios/optionrom/multiboot.S @@ -18,86 +18,15 @@ * Authors: Alexander Graf <agraf@suse.de> */ -#define NO_QEMU_PROTOS -#include "../../hw/fw_cfg.h" - -#define BIOS_CFG_IOPORT_CFG 0x510 -#define BIOS_CFG_IOPORT_DATA 0x511 +#include "optionrom.h" #define MULTIBOOT_MAGIC 0x2badb002 #define GS_PROT_JUMP 0 #define GS_GDT_DESC 6 -/* Break the translation block flow so -d cpu shows us values */ -#define DEBUG_HERE \ - jmp 1f; \ - 1: - -/* Read a variable from the fw_cfg device. - Clobbers: %edx - Out: %eax */ -.macro read_fw VAR - mov $\VAR, %ax - mov $BIOS_CFG_IOPORT_CFG, %dx - outw %ax, (%dx) - mov $BIOS_CFG_IOPORT_DATA, %dx - inb (%dx), %al - shl $8, %eax - inb (%dx), %al - shl $8, %eax - inb (%dx), %al - shl $8, %eax - inb (%dx), %al - bswap %eax -.endm -/* - * Read a blob from the fw_cfg device. - * Requires _ADDR, _SIZE and _DATA values for the parameter. - * - * Clobbers: %eax, %edx, %es, %ecx, %edi - */ -#define read_fw_blob(var) \ - read_fw var ## _ADDR; \ - mov %eax, %edi; \ - read_fw var ## _SIZE; \ - mov %eax, %ecx; \ - mov $var ## _DATA, %ax; \ - mov $BIOS_CFG_IOPORT_CFG, %edx; \ - outw %ax, (%dx); \ - mov $BIOS_CFG_IOPORT_DATA, %dx; \ - cld; \ - DEBUG_HERE \ - rep insb (%dx), %es:(%edi); - -.code16 -.text - .global _start -_start: - .short 0xaa55 - .byte (_end - _start) / 512 - push %eax - push %ds - - /* setup ds so we can access the IVT */ - xor %ax, %ax - mov %ax, %ds - - /* install our int 19 handler */ - movw $int19_handler, (0x19*4) - mov %cs, (0x19*4+2) - - pop %ds - pop %eax - lret - -int19_handler: - /* DS = CS */ - movw %cs, %ax - movw %ax, %ds - - /* fall through */ +BOOT_ROM_START run_multiboot: @@ -249,6 +178,4 @@ gdt_desc: .short (5 * 8) - 1 .long gdt -.align 512, 0 -_end: - +BOOT_ROM_END diff --git a/pc-bios/optionrom/optionrom.h b/pc-bios/optionrom/optionrom.h new file mode 100644 index 000000000..34d69af89 --- /dev/null +++ b/pc-bios/optionrom/optionrom.h @@ -0,0 +1,107 @@ +/* + * Common Option ROM Functions + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + * + * Copyright Novell Inc, 2009 + * Authors: Alexander Graf <agraf@suse.de> + */ + + +#define NO_QEMU_PROTOS +#include "../../hw/fw_cfg.h" + +#define BIOS_CFG_IOPORT_CFG 0x510 +#define BIOS_CFG_IOPORT_DATA 0x511 + +/* Break the translation block flow so -d cpu shows us values */ +#define DEBUG_HERE \ + jmp 1f; \ + 1: + +/* + * Read a variable from the fw_cfg device. + * Clobbers: %edx + * Out: %eax + */ +.macro read_fw VAR + mov $\VAR, %ax + mov $BIOS_CFG_IOPORT_CFG, %dx + outw %ax, (%dx) + mov $BIOS_CFG_IOPORT_DATA, %dx + inb (%dx), %al + shl $8, %eax + inb (%dx), %al + shl $8, %eax + inb (%dx), %al + shl $8, %eax + inb (%dx), %al + bswap %eax +.endm + +/* + * Read a blob from the fw_cfg device. + * Requires _ADDR, _SIZE and _DATA values for the parameter. + * + * Clobbers: %eax, %edx, %es, %ecx, %edi + */ +#define read_fw_blob(var) \ + read_fw var ## _ADDR; \ + mov %eax, %edi; \ + read_fw var ## _SIZE; \ + mov %eax, %ecx; \ + mov $var ## _DATA, %ax; \ + mov $BIOS_CFG_IOPORT_CFG, %edx; \ + outw %ax, (%dx); \ + mov $BIOS_CFG_IOPORT_DATA, %dx; \ + cld; \ + rep insb (%dx), %es:(%edi); + +#define OPTION_ROM_START \ + .code16; \ + .text; \ + .global _start; \ + _start:; \ + .short 0xaa55; \ + .byte (_end - _start) / 512; + +#define BOOT_ROM_START \ + OPTION_ROM_START \ + push %eax; \ + push %ds; \ + \ + /* setup ds so we can access the IVT */ \ + xor %ax, %ax; \ + mov %ax, %ds; \ + \ + /* install our int 19 handler */ \ + movw $int19_handler, (0x19*4); \ + mov %cs, (0x19*4+2); \ + \ + pop %ds; \ + pop %eax; \ + lret; \ + \ + int19_handler:; \ + /* DS = CS */ \ + movw %cs, %ax; \ + movw %ax, %ds; + +#define OPTION_ROM_END \ + .align 512, 0; \ + _end: + +#define BOOT_ROM_END \ + OPTION_ROM_END + |