From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MKWle-0008Sr-01 for mharc-grub-devel@gnu.org; Sat, 27 Jun 2009 08:12:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKWlb-0008QB-W6 for grub-devel@gnu.org; Sat, 27 Jun 2009 08:12:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKWlX-0008KO-Rw for grub-devel@gnu.org; Sat, 27 Jun 2009 08:12:23 -0400 Received: from [199.232.76.173] (port=39971 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKWlX-0008KA-NC for grub-devel@gnu.org; Sat, 27 Jun 2009 08:12:19 -0400 Received: from aybabtu.com ([69.60.117.155]:37496) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MKWlX-0004oX-Cl for grub-devel@gnu.org; Sat, 27 Jun 2009 08:12:19 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MKVi5-0007oW-Tv for grub-devel@gnu.org; Sat, 27 Jun 2009 13:04:42 +0200 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1MKWlU-0007Yy-ND for grub-devel@gnu.org; Sat, 27 Jun 2009 14:12:16 +0200 Date: Sat, 27 Jun 2009 14:12:16 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20090627121216.GA29067@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: [PATCH] export -boot parameter as qemu_boot{0,1,2} X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jun 2009 12:12:24 -0000 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch makes GRUB gather the -boot parameter from CMOS and export it as a set of variables (qemu_boot{0,1,2}), which can be observed in grub.cfg scripts. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --FL5UXtIhxfXey3p5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="qemu_boot.diff" 2009-06-27 Robert Millan * kern/i386/coreboot/init.c (QEMU_CMOS_BOOT_DEVICE_01) (QEMU_CMOS_BOOT_DEVICE_2, QEMU_CMOS_BOOT_FLOPPY) (QEMU_CMOS_BOOT_HDD, QEMU_CMOS_BOOT_CDROM) (QEMU_CMOS_BOOT_NETWORK): New macros. [GRUB_MACHINE_QEMU] (grub_machine_init): Initialize `qemu_bootX' variables using the CMOS values corresponding to `-boot' parameter in QEMU command-line. Index: kern/i386/coreboot/init.c =================================================================== --- kern/i386/coreboot/init.c (revision 2367) +++ kern/i386/coreboot/init.c (working copy) @@ -36,6 +36,15 @@ #include #include #include +#include + +#define QEMU_CMOS_BOOT_DEVICE_01 0x3d +#define QEMU_CMOS_BOOT_DEVICE_2 0x38 + +#define QEMU_CMOS_BOOT_FLOPPY 0x01 +#define QEMU_CMOS_BOOT_HDD 0x02 +#define QEMU_CMOS_BOOT_CDROM 0x03 +#define QEMU_CMOS_BOOT_NETWORK 0x04 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT 0x3f2 @@ -125,6 +134,45 @@ grub_machine_init (void) grub_machine_mmap_iterate (heap_init); grub_tsc_init (); + +#ifdef GRUB_MACHINE_QEMU + { + grub_uint8_t device[3]; + unsigned int i, j; + + device[0] = grub_cmos_read (QEMU_CMOS_BOOT_DEVICE_01) & 0x0f; + device[1] = grub_cmos_read (QEMU_CMOS_BOOT_DEVICE_01) >> 4; + device[2] = grub_cmos_read (QEMU_CMOS_BOOT_DEVICE_2) >> 4; + + auto void qemu_boot_ata (int n, int ata); + void qemu_boot_ata (int n, int ata) + { + char ata_device[] = "ataX"; + char qemu_boot[] = "qemu_bootX"; + + qemu_boot[9] = n + '0'; + ata_device[3] = ata + '0'; + + grub_env_set (qemu_boot, ata_device); + } + + j = 0; + for (i = 0; i < sizeof (device) / sizeof (device[0]); i++) + switch (device[i]) + { + case QEMU_CMOS_BOOT_HDD: + qemu_boot_ata (j++, 0); + break; + case QEMU_CMOS_BOOT_CDROM: + qemu_boot_ata (j++, 2); + break; + case QEMU_CMOS_BOOT_FLOPPY: + case QEMU_CMOS_BOOT_NETWORK: + default: + break; + } + } +#endif } void --FL5UXtIhxfXey3p5--