2009-06-29 Robert Millan
* include/grub/i386/qemu/init.h: Include `'.
(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.
* kern/i386/coreboot/init.c [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 2371)
+++ kern/i386/coreboot/init.c (working copy)
@@ -125,6 +125,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 < ARRAY_SIZE (device); 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
Index: include/grub/i386/qemu/init.h
===================================================================
--- include/grub/i386/qemu/init.h (revision 2371)
+++ include/grub/i386/qemu/init.h (working copy)
@@ -1 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that 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 GRUB. If not, see .
+ */
+
+#ifndef GRUB_INIT_I386_QEMU_HEADER
+#define GRUB_INIT_I386_QEMU_HEADER 1
+
+#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
+
+#endif