xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 11 of 19] tools: hvmloader: add bios_config data structure
Date: Tue, 12 Apr 2011 12:29:10 +0100	[thread overview]
Message-ID: <700f2fd3d5fd5733a33a.1302607750@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1302607739@localhost.localdomain>

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# 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@citrix.com>

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@watson.ibm.com
+ * 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:
+ */

  parent reply	other threads:[~2011-04-12 11:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 11:28 [PATCH 00 of 19] tools: SeaBIOS integration Ian Campbell
2011-04-12 11:29 ` [PATCH 01 of 19] tools: hvmloader: move ROMBIOS configuration into tools/firmware/rombios/ Ian Campbell
2011-04-12 11:29 ` [PATCH 02 of 19] tools: hvmloader: split e820 support into its own code module Ian Campbell
2011-04-12 11:29 ` [PATCH 03 of 19] tools: hvmloader: pass ACPI_PHYSICAL_ADDRESS as a runtime parameter Ian Campbell
2011-04-12 11:29 ` [PATCH 04 of 19] tools: hvmloader: pass SMBIOS location " Ian Campbell
2011-04-12 11:29 ` [PATCH 05 of 19] tools: hvmloader: pass option ROM end address around as a parameter Ian Campbell
2011-04-12 11:29 ` [PATCH 06 of 19] tools: hvmloader: split scratch and hypercall addressing from ROMBIOS low heap Ian Campbell
2011-04-12 11:29 ` [PATCH 07 of 19] tools: hvmloader: refactor Makefile to move ROM filenames into variables Ian Campbell
2011-04-12 11:29 ` [PATCH 08 of 19] tools: hvmloader: remove rombios_sz, just use sizeof(rombios) Ian Campbell
2011-04-12 11:29 ` [PATCH 09 of 19] tools: hvmloader: rename roms.h to roms.inc Ian Campbell
2011-04-12 11:29 ` [PATCH 10 of 19] tools: hvmloader: Define $(OBJS) directly instead of via $(SRCS) Ian Campbell
2011-04-12 11:29 ` Ian Campbell [this message]
2011-04-12 11:29 ` [PATCH 12 of 19] tools: hvmloader: Refactor APIC, PCI and SMP setup into struct bios_config Ian Campbell
2011-04-12 11:29 ` [PATCH 13 of 19] tools: hvmloader: refactor highbios and bios_info " Ian Campbell
2011-04-12 11:29 ` [PATCH 14 of 19] tools: hvmloader: Refactor VM86 and E820 " Ian Campbell
2011-04-12 11:29 ` [PATCH 15 of 19] tools: hvmloader: Refactor ACPI table " Ian Campbell
2011-04-12 11:29 ` [PATCH 16 of 19] tools: hvmloader: Refactor MP " Ian Campbell
2011-04-12 11:29 ` [PATCH 17 of 19] tools: libxl: hide selection of device-model, hvmloader and BIOS by default Ian Campbell
2011-04-14 18:09   ` Ian Jackson
2011-04-15  7:53     ` Ian Campbell
2011-04-12 11:29 ` [PATCH 18 of 19] tools: hvmloader: select BIOS through xenstore Ian Campbell
2011-04-12 11:29 ` [PATCH 19 of 19] tools: support SeaBIOS. Use by default when upstream qemu is configured Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=700f2fd3d5fd5733a33a.1302607750@localhost.localdomain \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).