[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 11 of 11] tools: hvmloader: build and install hvmloader-seabios



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302013752 -3600
# Node ID e471a31bf22626a5686c3d17141cdb9a6a65abbe
# Parent  c387185f0a254c794b73d71d282fb941d3de5d98
tools: hvmloader: build and install hvmloader-seabios

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r c387185f0a25 -r e471a31bf226 .hgignore
--- a/.hgignore Tue Apr 05 15:29:12 2011 +0100
+++ b/.hgignore Tue Apr 05 15:29:12 2011 +0100
@@ -143,6 +143,7 @@
 ^tools/firmware/hvmloader/acpi/dsdt.*\.c$
 ^tools/firmware/hvmloader/acpi/ssdt_.*\.h$
 ^tools/firmware/hvmloader/hvmloader-rombios$
+^tools/firmware/hvmloader/hvmloader-seabios$
 ^tools/firmware/hvmloader/roms\.h$
 ^tools/firmware/rombios/BIOS-bochs-[^/]*$
 ^tools/firmware/rombios/_rombios[^/]*_\.c$
diff -r c387185f0a25 -r e471a31bf226 Config.mk
--- a/Config.mk Tue Apr 05 15:29:12 2011 +0100
+++ b/Config.mk Tue Apr 05 15:29:12 2011 +0100
@@ -184,6 +184,18 @@ QEMU_TAG := xen-4.1.0-rc6
 # Fri Feb 11 17:54:51 2011 +0000
 # qemu-xen: fix segfault with empty cdroms
 
+# Short answer -- do not enable this unless you know what you are
+# doing and are prepared for some pain.
+
+# SeaBIOS integration is a work in progress. Before enabling this
+# option you must clone git://git.qemu.org/seabios.git/, possibly add
+# some development patches and then build it yourself before pointing
+# this variable to it (using an absolute path).
+#
+# Note that using SeaBIOS requires the use the upstream qemu as the
+# device model.
+SEABIOS_DIR ?= 
+
 # Optional components
 XENSTAT_XENTOP     ?= y
 VTPM_TOOLS         ?= n
diff -r c387185f0a25 -r e471a31bf226 tools/firmware/Makefile
--- a/tools/firmware/Makefile   Tue Apr 05 15:29:12 2011 +0100
+++ b/tools/firmware/Makefile   Tue Apr 05 15:29:12 2011 +0100
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # hvmloader is a 32-bit protected mode binary.
 TARGET_ROMBIOS      := hvmloader/hvmloader-rombios
+TARGET_SEABIOS      := hvmloader/hvmloader-seabios
 INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
 
 SUBDIRS :=
@@ -28,6 +29,7 @@ install: all
        [ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
        [ ! -e $(TARGET_ROMBIOS) ] || $(INSTALL_DATA) $(TARGET_ROMBIOS) 
$(INST_DIR)
        [ ! -e $(TARGET_ROMBIOS) ] || ln -nfs hvmloader-rombios 
$(INST_DIR)/hvmloader
+       [ ! -e $(TARGET_SEABIOS) ] || $(INSTALL_DATA) $(TARGET_SEABIOS) 
$(INST_DIR)
 
 .PHONY: clean
 clean: subdirs-clean
diff -r c387185f0a25 -r e471a31bf226 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Apr 05 15:29:12 2011 +0100
+++ b/tools/firmware/hvmloader/Makefile Tue Apr 05 15:29:12 2011 +0100
@@ -36,6 +36,10 @@ endif
 OBJS  = $(patsubst %.c,%.o,$(SRCS))
 
 TARGETS := hvmloader-rombios
+ifneq ($(SEABIOS_DIR),)
+TARGETS += hvmloader-seabios
+ROM_SEABIOS := $(SEABIOS_DIR)/out/bios.bin
+endif
 
 CIRRUSVGA_DEBUG ?= n
 
@@ -46,6 +50,9 @@ all: subdirs-all
 hvmloader-rombios.o: hvmloader.c roms.h
        $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -DBIOS_ROM_rombios=1 
-DBIOS_ROM_STR=\"ROMBIOS\" -c -o $@ hvmloader.c
 
+hvmloader-seabios.o: hvmloader.c roms.h
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -DBIOS_ROM_seabios=1 
-DBIOS_ROM_STR=\"SeaBIOS\" -c -o $@ hvmloader.c
+
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(shell date +%m/%d/%Y)\""
 
 hvmloader-%: hvmloader-%.o $(OBJS) acpi/acpi.a
@@ -54,13 +61,19 @@ hvmloader-%: hvmloader-%.o $(OBJS) acpi/
        rm -f $@.tmp
 
 roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \
-       ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h
+       ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h 
$(ROM_SEABIOS)
        echo "/* Autogenerated file. DO NOT EDIT */" > roms.h
 
        echo "#ifdef BIOS_ROM_rombios" >> roms.h
        sh ./mkhex biosimg ../rombios/BIOS-bochs-latest >> roms.h
        echo "#endif" >> roms.h
 
+ifneq ($(ROM_SEABIOS),)
+       echo "#ifdef BIOS_ROM_seabios" >> roms.h
+       sh ./mkhex biosimg $(ROM_SEABIOS) >> roms.h
+       echo "#endif" >> roms.h
+endif
+
        sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
 ifeq ($(CIRRUSVGA_DEBUG),y)
        sh ./mkhex vgabios_cirrusvga \
@@ -77,5 +90,6 @@ clean: subdirs-clean
        rm -f roms.h acpi.h
        rm -f hvmloader hvmloader.tmp *.o $(DEPS)
        rm -f hvmloader-rombios hvmloader-rombios.tmp
+       rm -f hvmloader-seabios hvmloader-seabios.tmp
 
 -include $(DEPS)
diff -r c387185f0a25 -r e471a31bf226 tools/firmware/hvmloader/config-seabios.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/config-seabios.h Tue Apr 05 15:29:12 2011 +0100
@@ -0,0 +1,13 @@
+#ifndef __HVMLOADER_CONFIG_SEABIOS_H__
+#define __HVMLOADER_CONFIG_SEABIOS_H__
+
+/* Memory map. */
+#define VGABIOS_PHYSICAL_ADDRESS    0x000C0000
+#define OPTIONROM_PHYSICAL_ADDRESS  0x000C8000
+
+#define OPTIONROM_PHYSICAL_END      0x000E0000
+
+#define BIOS_PHYSICAL_ADDRESS       0x000E0000
+#define BIOS_MAXIMUM_SIZE           (0x00100000 - BIOS_PHYSICAL_ADDRESS)
+
+#endif /* __HVMLOADER_CONFIG_SEABIOS_H__ */
diff -r c387185f0a25 -r e471a31bf226 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Apr 05 15:29:12 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Apr 05 15:29:12 2011 +0100
@@ -36,6 +36,8 @@
 #if defined(BIOS_ROM_rombios)
 #  include "../rombios/config.h"
 #  include "../rombios/e820.h"
+#elif defined(BIOS_ROM_seabios)
+#  include "config-seabios.h"
 #else
 #  error "Building for unknown BIOS"
 #endif
@@ -156,6 +158,7 @@ static void init_hypercalls(void)
     printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion);
 }
 
+#ifdef BIOS_ROM_rombios
 static void apic_setup(void)
 {
     /* Set the IOAPIC ID to the static value used in the MP/ACPI tables. */
@@ -170,7 +173,9 @@ static void apic_setup(void)
     ioapic_write(0x10, APIC_DM_EXTINT);
     ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0)));
 }
+#endif
 
+#ifdef BIOS_ROM_rombios
 static void pci_setup(void)
 {
     uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd, mmio_total = 0;
@@ -380,6 +385,7 @@ static void pci_setup(void)
         pci_writew(devfn, PCI_COMMAND, cmd);
     }
 }
+#endif
 
 /*
  * Scan the list of Option ROMs at @roms for one which supports 
@@ -496,6 +502,7 @@ static int scan_etherboot_nic(uint32_t c
     return rom_size;
 }
 
+#ifdef BIOS_ROM_rombios
 /*
  * Scan the PCI bus for the devices that have an option ROM, and copy
  * the corresponding rom data to rom_phys_addr.
@@ -538,6 +545,7 @@ static int pci_load_option_roms(uint32_t
 
     return rom_phys_addr - rom_base_addr;
 }
+#endif
 
 /* Replace possibly erroneous memory-size CMOS fields with correct values. */
 static void cmos_write_memory_size(void)
@@ -565,6 +573,7 @@ static void cmos_write_memory_size(void)
     cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
 }
 
+#ifdef BIOS_ROM_rombios
 /*
  * Set up an empty TSS area for virtual 8086 mode to use. 
  * The only important thing is that it musn't have any bits set 
@@ -583,7 +592,9 @@ static void init_vm86_tss(void)
     hypercall_hvm_op(HVMOP_set_param, &p);
     printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
 }
+#endif
 
+#ifdef BIOS_ROM_rombios
 static void dump_e820_table(void)
 {
     struct e820entry *e820 = E820;
@@ -702,18 +713,23 @@ static void build_e820_table(void)
 
     *E820_NR = nr;
 }
+#endif
 
 int main(void)
 {
     int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
-    int smbios_sz;
-    uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr;
+#ifdef BIOS_ROM_rombios
+    int smbios_sz = 0;
+    uint32_t bios32_addr;
     struct bios_info *bios_info;
+#endif
+    uint32_t etherboot_phys_addr, option_rom_phys_addr;
 
     printf("HVM Loader\n");
 
     init_hypercalls();
 
+#ifdef BIOS_ROM_rombios
     printf("CPU speed is %u MHz\n", get_cpu_mhz());
 
     xenbus_setup();
@@ -728,15 +744,22 @@ int main(void)
     smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
                                         SMBIOS_PHYSICAL_ADDRESS,
                                         SMBIOS_MAXIMUM_SIZE);
+#endif
 
     printf("Loading " BIOS_ROM_STR "...\n");
     BUILD_BUG_ON(sizeof(biosimg) > BIOS_MAXIMUM_SIZE);
     memcpy((void *)BIOS_PHYSICAL_ADDRESS, biosimg, sizeof(biosimg));
 
+#ifdef BIOS_ROM_rombios
     bios32_addr = highbios_setup();
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
         create_mp_tables();
+#endif
+
+#ifdef BIOS_ROM_seabios
+    virtual_vga = VGA_cirrus;
+#endif
 
     switch ( virtual_vga )
     {
@@ -763,30 +786,40 @@ int main(void)
     }
 
     etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz;
+#ifdef BIOS_ROM_rombios
     if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS )
         etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS;
+#endif
     etherboot_sz = scan_etherboot_nic(etherboot_phys_addr);
 
     option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
+#ifdef BIOS_ROM_rombios
     option_rom_sz = pci_load_option_roms(option_rom_phys_addr);
+#endif
 
+#ifdef BIOS_ROM_rombios
     if ( hvm_info->acpi_enabled )
+#endif
     {
         struct xen_hvm_param p = {
             .domid = DOMID_SELF,
             .index = HVM_PARAM_ACPI_IOPORTS_LOCATION,
             .value = 1,
         };
+#ifdef BIOS_ROM_rombios
         struct acpi_parameters acpi_params = {
             .phys = ACPI_PHYSICAL_ADDRESS,
         };
 
         printf("Loading ACPI ...\n");
         acpi_build_tables(&acpi_params);
+#endif
         hypercall_hvm_op(HVMOP_set_param, &p);
     }
 
+#ifdef BIOS_ROM_rombios
     init_vm86_tss();
+#endif
 
     cmos_write_memory_size();
 
@@ -803,14 +836,17 @@ int main(void)
         printf(" %05x-%05x: PCI Option ROMs\n",
                option_rom_phys_addr,
                option_rom_phys_addr + option_rom_sz - 1);
+#ifdef BIOS_ROM_rombios
     if ( smbios_sz )
         printf(" %05x-%05x: SMBIOS tables\n",
                SMBIOS_PHYSICAL_ADDRESS,
                SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1);
+#endif
     printf(" %05x-%05x: Main BIOS\n",
            BIOS_PHYSICAL_ADDRESS,
            BIOS_PHYSICAL_ADDRESS + sizeof(biosimg) - 1);
 
+#ifdef BIOS_ROM_rombios
     build_e820_table();
     dump_e820_table();
 
@@ -827,6 +863,7 @@ int main(void)
     bios_info->bios32_entry = bios32_addr;
 
     xenbus_shutdown();
+#endif
 
     printf("Invoking " BIOS_ROM_STR " ...\n");
     return 0;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.