From patchwork Sun Aug 9 01:43:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Justen X-Patchwork-Id: 31009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 180F0B7B60 for ; Sun, 9 Aug 2009 11:44:36 +1000 (EST) Received: from localhost ([127.0.0.1]:35507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZxSb-0003kF-3y for incoming@patchwork.ozlabs.org; Sat, 08 Aug 2009 21:44:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MZxS9-0003iN-8S for qemu-devel@nongnu.org; Sat, 08 Aug 2009 21:44:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MZxS4-0003f5-OO for qemu-devel@nongnu.org; Sat, 08 Aug 2009 21:44:04 -0400 Received: from [199.232.76.173] (port=58275 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZxS4-0003f2-IY for qemu-devel@nongnu.org; Sat, 08 Aug 2009 21:44:00 -0400 Received: from rv-out-0708.google.com ([209.85.198.241]:13038) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MZxS3-0004ne-Vo for qemu-devel@nongnu.org; Sat, 08 Aug 2009 21:44:00 -0400 Received: by rv-out-0708.google.com with SMTP id b17so589688rvf.22 for ; Sat, 08 Aug 2009 18:43:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=Ja8gklpKmsIQHtC8pInt1LORacOR06Pm9RKF+RGsuRQ=; b=SoOzY2rk0M2DLbyMsj9u2BXZE7DrNnjebuBIMxtOO9Z9Yg/9Di/fmiKKGljZ9WwynA JvZOBtFrnPZSnxD5Ry+oq1sljQH8LAt3in3PvfkBg7ZbbKjMSrFYGwsZyOuoN7kd+h0f IsXHzyL4EYM9mYspAYOBHdWRUkA2e2sozA0qw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=SuY7jDMEBQ8cqO7R2OJJG0gvfhjQQY1aQNce8MSwL20/f0J3RTt7Y6jRXHCkX1td8z Wj8N729VWTYOjhkc02gm41RA+4GRO5zdj9Rr8NwQUsMztPUEJOIFicuOwbNVuJFqo2+z 31D7UGfiGnA/25oGH44JxNXCFAFzWnJwmPUu0= Received: by 10.140.201.17 with SMTP id y17mr37411rvf.84.1249782238455; Sat, 08 Aug 2009 18:43:58 -0700 (PDT) Received: from localhost.localdomain (pool-71-245-101-248.ptldor.fios.verizon.net [71.245.101.248]) by mx.google.com with ESMTPS id k41sm12882079rvb.8.2009.08.08.18.43.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 08 Aug 2009 18:43:57 -0700 (PDT) From: Jordan Justen To: qemu-devel@nongnu.org Date: Sat, 8 Aug 2009 18:43:42 -0700 Message-Id: <1249782222-6724-1-git-send-email-jljusten@gmail.com> X-Mailer: git-send-email 1.6.0.4 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Jordan Justen Subject: [Qemu-devel] [PATCH] pc.c: Add UEFI IA32 & X64 machine types. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org For i386, this change adds a 'uefi' machine type. For x86_64, this change adds 'uefi' and 'uefi32' machine types. These machine types will load different bios and video bios images: architecture+machine-type: bios and video bios images --- i386+pc: bios.bin, vgabios-cirrus.bin, vgabios.bin x86_64+pc: bios.bin, vgabios-cirrus.bin, vgabios.bin i386+uefi: uefi-ia32.fd, uefi-ia32-cirrus-gop.rom, uefi-ia32-vga-gop.rom x86_64+uefi32: uefi-ia32.fd, uefi-ia32-cirrus-gop.rom, uefi-ia32-vga-gop.rom x86_64+uefi: uefi-x64.fd, uefi-x64-cirrus-gop.rom, uefi-x64-vga-gop.rom Signed-off-by: Jordan Justen --- hw/pc.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 97 insertions(+), 8 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index bc9e646..aaaf158 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -47,6 +47,14 @@ #define VGABIOS_FILENAME "vgabios.bin" #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin" +#define UEFI_IA32_FIRMWARE_FILENAME "uefi-ia32.fd" +#define UEFI_IA32_VGA_GOP_FILENAME "uefi-ia32-vga-gop.rom" +#define UEFI_IA32_CIRRUS_GOP_FILENAME "uefi-ia32-cirrus-gop.rom" + +#define UEFI_X64_FIRMWARE_FILENAME "uefi-x64.fd" +#define UEFI_X64_VGA_GOP_FILENAME "uefi-x64-vga-gop.rom" +#define UEFI_X64_CIRRUS_GOP_FILENAME "uefi-x64-cirrus-gop.rom" + #define PC_MAX_BIOS_SIZE (4 * 1024 * 1024) /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */ @@ -1100,6 +1108,12 @@ static CPUState *pc_new_cpu(const char *cpu_model) return env; } +enum { + NO_UEFI = 0, + UEFI_IA32, + UEFI_X64, +}; + /* PC hardware initialisation */ static void pc_init1(ram_addr_t ram_size, const char *boot_device, @@ -1107,7 +1121,8 @@ static void pc_init1(ram_addr_t ram_size, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, - int pci_enabled) + int pci_enabled, + int uefi_mode) { char *filename; int ret, linux_boot, i; @@ -1125,6 +1140,28 @@ static void pc_init1(ram_addr_t ram_size, BlockDriverState *fd[MAX_FD]; int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled; void *fw_cfg; + const char *default_bios_filename; + const char *default_vga_filename, *default_cirrus_filename; + + switch(uefi_mode) { + case UEFI_IA32: + default_bios_filename = UEFI_IA32_FIRMWARE_FILENAME; + default_vga_filename = UEFI_IA32_VGA_GOP_FILENAME; + default_cirrus_filename = UEFI_IA32_CIRRUS_GOP_FILENAME; + break; + + case UEFI_X64: + default_bios_filename = UEFI_X64_FIRMWARE_FILENAME; + default_vga_filename = UEFI_X64_VGA_GOP_FILENAME; + default_cirrus_filename = UEFI_X64_CIRRUS_GOP_FILENAME; + break; + + default: + default_bios_filename = BIOS_FILENAME; + default_vga_filename = VGABIOS_FILENAME; + default_cirrus_filename = VGABIOS_CIRRUS_FILENAME; + break; + } if (ram_size >= 0xe0000000 ) { above_4g_mem_size = ram_size - 0xe0000000; @@ -1176,10 +1213,10 @@ static void pc_init1(ram_addr_t ram_size, #endif } - /* BIOS load */ - if (bios_name == NULL) - bios_name = BIOS_FILENAME; + if (bios_name == NULL) { + bios_name = default_bios_filename; + } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = get_image_size(filename); @@ -1218,9 +1255,9 @@ static void pc_init1(ram_addr_t ram_size, const char *vgabios_filename; /* VGA BIOS load */ if (cirrus_vga_enabled) { - vgabios_filename = VGABIOS_CIRRUS_FILENAME; + vgabios_filename = default_cirrus_filename; } else { - vgabios_filename = VGABIOS_FILENAME; + vgabios_filename = default_vga_filename; } oprom_area_size = load_option_rom(vgabios_filename, 0xc0000, 0xe0000); } @@ -1446,7 +1483,7 @@ static void pc_init_pci(ram_addr_t ram_size, { pc_init1(ram_size, boot_device, kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 1); + initrd_filename, cpu_model, 1, NO_UEFI); } static void pc_init_isa(ram_addr_t ram_size, @@ -1458,8 +1495,34 @@ static void pc_init_isa(ram_addr_t ram_size, { pc_init1(ram_size, boot_device, kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 0); + initrd_filename, cpu_model, 0, NO_UEFI); +} + +static void uefi_ia32_pc_init(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + pc_init1(ram_size, boot_device, + kernel_filename, kernel_cmdline, + initrd_filename, cpu_model, 1, UEFI_IA32); +} + +#ifdef TARGET_X86_64 +static void uefi_x64_pc_init(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + pc_init1(ram_size, boot_device, + kernel_filename, kernel_cmdline, + initrd_filename, cpu_model, 1, UEFI_X64); } +#endif /* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE) BIOS will read it and start S3 resume at POST Entry */ @@ -1508,11 +1571,37 @@ static QEMUMachine isapc_machine = { .max_cpus = 1, }; +static QEMUMachine uefi_machine = { + .name = "uefi", +#ifndef TARGET_X86_64 + .desc = "UEFI IA32 PC", + .init = uefi_ia32_pc_init, +#else + .desc = "UEFI X64 PC", + .init = uefi_x64_pc_init, +#endif + .max_cpus = 255, +}; + +#ifdef TARGET_X86_64 +static QEMUMachine uefi_ia32_machine = { + .name = "uefi32", + .desc = "UEFI IA32 PC", + .init = uefi_ia32_pc_init, + .max_cpus = 255, +}; +#endif + static void pc_machine_init(void) { qemu_register_machine(&pc_machine); qemu_register_machine(&pc_machine_v0_10); qemu_register_machine(&isapc_machine); + + qemu_register_machine(&uefi_machine); +#ifdef TARGET_X86_64 + qemu_register_machine(&uefi_ia32_machine); +#endif } machine_init(pc_machine_init);