WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 11 of 19] tools: hvmloader: add bios_config data stru

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 11 of 19] tools: hvmloader: add bios_config data structure
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 12 Apr 2011 12:29:10 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Tue, 12 Apr 2011 04:48:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1302607739@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1302607739@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302601994 -3600
# Node ID 700f2fd3d5fd5733a33aa038d090ffb8a6561294
# Parent  a25b909fed618dc7e8b95921a59a0db552d60612
tools: hvmloader: add bios_config data structure

For now abstract away the actual ROM bits themselves and the various
load addresses.

Create a rombios.c to contain the ROMBIOS specific parts. ROMBIOS is
still statically selected for the time being.

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

diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Apr 12 10:49:01 2011 +0100
+++ b/tools/firmware/hvmloader/Makefile Tue Apr 12 10:53:14 2011 +0100
@@ -37,7 +37,11 @@ endif
 
 CIRRUSVGA_DEBUG ?= n
 
-ROMBIOS_ROM   := ../rombios/BIOS-bochs-latest
+ROMBIOS_DIR := ../rombios
+ifneq ($(ROMBIOS_DIR),)
+OBJS += rombios.o
+ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
+endif
 
 STDVGA_ROM    := ../vgabios/VGABIOS-lgpl-latest.bin
 ifeq ($(CIRRUSVGA_DEBUG),y)
@@ -62,17 +66,25 @@ roms.inc: $(ROMBIOS_ROM) $(STDVGA_ROM) $
        echo "/* Autogenerated file. DO NOT EDIT */" > roms.inc
 
 ifneq ($(ROMBIOS_ROM),)
+       echo "#ifdef ROM_INCLUDE_ROMBIOS" >> roms.inc
        sh ./mkhex rombios $(ROMBIOS_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 
 ifneq ($(STDVGA_ROM),)
+       echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc
        sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 ifneq ($(CIRRUSVGA_ROM),)
+       echo "#ifdef ROM_INCLUDE_VGABIOS" >> roms.inc
        sh ./mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> roms.inc
+       echo "#endif" >> roms.inc
 endif
 
+       echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> roms.inc
        cat ../etherboot/eb-roms.h >> roms.inc
+       echo "#endif" >> roms.inc
 
 .PHONY: clean
 clean: subdirs-clean
diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Tue Apr 12 10:49:01 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Tue Apr 12 10:53:14 2011 +0100
@@ -3,6 +3,28 @@
 
 #include <stdint.h>
 
+struct bios_config {
+    const char *name;
+
+    /* BIOS ROM image bits */
+    void *image;
+    unsigned int image_size;
+
+    /* Physical address to load at */
+    unsigned int bios_address;
+
+    /* SMBIOS */
+    unsigned int smbios_start, smbios_end;
+
+    /* Option ROMs */
+    unsigned int optionrom_start, optionrom_end;
+
+    /* ACPI tables */
+    unsigned int acpi_start;
+};
+
+extern struct bios_config rombios_config;
+
 #define PAGE_SHIFT 12
 #define PAGE_SIZE  (1ul << PAGE_SHIFT)
 
@@ -39,3 +61,13 @@ extern unsigned long pci_mem_start, pci_
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 
 #endif /* __HVMLOADER_CONFIG_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 10:49:01 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Apr 12 10:53:14 2011 +0100
@@ -32,6 +32,8 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
+#define ROM_INCLUDE_VGABIOS
+#define ROM_INCLUDE_ETHERBOOT
 #include "roms.inc"
 
 asm (
@@ -583,10 +585,15 @@ static void init_vm86_tss(void)
     printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
 }
 
+static const struct bios_config *detect_bios(void)
+{
+    return &rombios_config;
+}
+
 int main(void)
 {
-    int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
-    int smbios_sz;
+    const struct bios_config *bios;
+    int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0, smbios_sz = 0;
     uint32_t etherboot_phys_addr, option_rom_phys_addr, bios32_addr;
     struct bios_info *bios_info;
 
@@ -594,9 +601,13 @@ int main(void)
 
     init_hypercalls();
 
+    xenbus_setup();
+
+    bios = detect_bios();
+    printf("System requested %s\n", bios->name);
+
     printf("CPU speed is %u MHz\n", get_cpu_mhz());
 
-    xenbus_setup();
     apic_setup();
     pci_setup();
 
@@ -604,13 +615,16 @@ int main(void)
 
     perform_tests();
 
-    printf("Writing SMBIOS tables ...\n");
-    smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
-                                        SMBIOS_PHYSICAL_ADDRESS,
-                                        SMBIOS_PHYSICAL_END);
+    if (bios->smbios_start) {
+        printf("Writing SMBIOS tables ...\n");
+        smbios_sz = hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
+                                            bios->smbios_start,
+                                            bios->smbios_end);
+    }
 
-    printf("Loading ROMBIOS ...\n");
-    memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
+    printf("Loading %s ...\n", bios->name);
+    memcpy((void *)bios->bios_address, bios->image,
+           bios->image_size);
     bios32_addr = highbios_setup();
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
@@ -641,13 +655,13 @@ int main(void)
     }
 
     etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz;
-    if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS )
-        etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS;
-    etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
+    if ( etherboot_phys_addr < bios->optionrom_start )
+        etherboot_phys_addr = bios->optionrom_start;
+    etherboot_sz = scan_etherboot_nic(bios->optionrom_end,
                                       etherboot_phys_addr);
 
     option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
-    option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
+    option_rom_sz = pci_load_option_roms(bios->optionrom_end,
                                          option_rom_phys_addr);
 
     if ( hvm_info->acpi_enabled )
@@ -659,7 +673,7 @@ int main(void)
         };
 
         printf("Loading ACPI ...\n");
-        acpi_build_tables(ACPI_PHYSICAL_ADDRESS);
+        acpi_build_tables(bios->acpi_start);
         hypercall_hvm_op(HVMOP_set_param, &p);
     }
 
@@ -682,11 +696,11 @@ int main(void)
                option_rom_phys_addr + option_rom_sz - 1);
     if ( smbios_sz )
         printf(" %05x-%05x: SMBIOS tables\n",
-               SMBIOS_PHYSICAL_ADDRESS,
-               SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1);
+               bios->smbios_start,
+               bios->smbios_start + smbios_sz - 1);
     printf(" %05x-%05x: Main BIOS\n",
-           ROMBIOS_PHYSICAL_ADDRESS,
-           ROMBIOS_PHYSICAL_ADDRESS + sizeof(rombios) - 1);
+           bios->bios_address,
+           bios->bios_address + bios->image_size - 1);
 
     *E820_NR = build_e820_table(E820);
     dump_e820_table(E820, *E820_NR);
@@ -705,7 +719,7 @@ int main(void)
 
     xenbus_shutdown();
 
-    printf("Invoking ROMBIOS ...\n");
+    printf("Invoking %s ...\n", bios->name);
     return 0;
 }
 
diff -r a25b909fed61 -r 700f2fd3d5fd tools/firmware/hvmloader/rombios.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/rombios.c        Tue Apr 12 10:53:14 2011 +0100
@@ -0,0 +1,58 @@
+/*
+ * HVM ROMBIOS support.
+ *
+ * Leendert van Doorn, leendert@xxxxxxxxxxxxxx
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2006, Keir Fraser, XenSource Inc.
+ * Copyright (c) 2011, Citrix Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "config.h"
+
+#include "../rombios/config.h"
+
+#define ROM_INCLUDE_ROMBIOS
+#include "roms.inc"
+
+//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));
+
+struct bios_config rombios_config =  {
+    .name = "ROMBIOS",
+
+    .image = rombios,
+    .image_size = sizeof(rombios),
+
+    .bios_address = ROMBIOS_PHYSICAL_ADDRESS,
+
+    .smbios_start = SMBIOS_PHYSICAL_ADDRESS,
+    .smbios_end = SMBIOS_PHYSICAL_END,
+
+    .optionrom_start = OPTIONROM_PHYSICAL_ADDRESS,
+    .optionrom_end = OPTIONROM_PHYSICAL_END,
+
+    .acpi_start = ACPI_PHYSICAL_ADDRESS,
+
+};
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

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

<Prev in Thread] Current Thread [Next in Thread>