From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] export -boot parameter as qemu_boot{0,1,2}
Date: Sat, 27 Jun 2009 14:12:16 +0200 [thread overview]
Message-ID: <20090627121216.GA29067@thorin> (raw)
[-- Attachment #1: Type: text/plain, Size: 396 bytes --]
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."
[-- Attachment #2: qemu_boot.diff --]
[-- Type: text/x-diff, Size: 2018 bytes --]
2009-06-27 Robert Millan <rmh.grub@aybabtu.com>
* 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 <grub/cpu/io.h>
#include <grub/cpu/kernel.h>
#include <grub/cpu/tsc.h>
+#include <grub/cpu/cmos.h>
+
+#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
next reply other threads:[~2009-06-27 12:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-27 12:12 Robert Millan [this message]
2009-06-29 4:09 ` [PATCH] export -boot parameter as qemu_boot{0,1,2} Pavel Roskin
2009-06-29 13:49 ` Robert Millan
2009-06-29 20:18 ` Vladimir 'phcoder' Serbinenko
2009-06-29 22:31 ` Pavel Roskin
2009-06-29 22:59 ` Pavel Roskin
2009-07-01 12:58 ` Robert Millan
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=20090627121216.GA29067@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.