Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3032)

Unified Diff: disk/efi/efidisk.c

Issue 2113004: Add variables to grub2 for Chrome OS bringup workarounds. (Closed) Base URL: ssh://git@chromiumos-git//grub2.git
Patch Set: respond to feedback Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: disk/efi/efidisk.c
diff --git a/disk/efi/efidisk.c b/disk/efi/efidisk.c
index de848594a1861f400c9a0609cbb63be378b3d20d..6a2c3b00a938450b60cdf921f445327bd8dd8008 100644
--- a/disk/efi/efidisk.c
+++ b/disk/efi/efidisk.c
@@ -26,6 +26,7 @@
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/efi/disk.h>
+#include <grub/env.h>
struct grub_efidisk_data
{
@@ -814,6 +815,48 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
return 0;
}
+ {
+ // This block is a temporary workaround used by Chrome OS. We set
+ // some variables that we can use in the grub.cfg file to ensure that
+ // we get the kernel and rootfs from the boot device, regardless of
+ // which device that is.
+ char *tmpbuf = grub_malloc (grub_strlen (parent->name) + 5);
+ if (! tmpbuf)
+ {
+ grub_free (device_name);
+ grub_free (partition_name);
+ grub_disk_close (parent);
+ return 0;
+ }
+
+ grub_sprintf (tmpbuf, "(%s,3)", parent->name);
+ grub_env_set ("grubpartA", tmpbuf);
+ grub_env_export ("grubpartA");
+ grub_sprintf (tmpbuf, "(%s,5)", parent->name);
+ grub_env_set ("grubpartB", tmpbuf);
+ grub_env_export ("grubpartB");
+ grub_free (tmpbuf);
+
+ // Translate hd0 to sda, hd1 to sdb, etc. parent->name is always
+ // either "fdN", "hdN", or "cdN". This trick won't work if N is > 9.
+ int index = parent->name[2] - '0';
+ // The Chrome OS BIOS doesn't enumerate the hard disk in recovery
+ // mode, so the first removable drive is hd0, not hd1. Linux always
+ // sees it though.
+ struct grub_efidisk_data *d = parent->data;
+ if (d->block_io->media->removable_media)
+ index++;
+
+ char devname[] = "sdXN";
+ devname[2] = 'a' + index;
+ devname[3] = '3';
+ grub_env_set ("linuxpartA", devname);
+ grub_env_export ("linuxpartA");
+ devname[3] = '5';
+ grub_env_set ("linuxpartB", devname);
+ grub_env_export ("linuxpartB");
+ }
+
grub_sprintf (device_name, "%s,%s", parent->name, partition_name);
grub_free (partition_name);
grub_disk_close (parent);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698