Blob Blame Raw
From 8730a9587670ebd5f7cb14d6bd5e4c7d4003a71d Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Wed, 17 Apr 2013 19:05:57 +0200
Subject: [PATCH 321/364] 	* grub-core/disk/efi/efidisk.c: Detect
 floppies by ACPI ID. 	It improves performance in qemu.

---
 ChangeLog                    |  5 +++++
 grub-core/disk/efi/efidisk.c | 18 ++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 073207a..9d77a7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-04-17  Vladimir Serbinenko  <phcoder@gmail.com>
 
+	* grub-core/disk/efi/efidisk.c: Detect floppies by ACPI ID.
+	It improves performance in qemu.
+
+2013-04-17  Vladimir Serbinenko  <phcoder@gmail.com>
+
 	* build-aux/snippet: Add missing gnulib files.
 
 2013-04-16  Andrey Borzenkov <arvidjaar@gmail.com>
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 0e08d3b..e168d07 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -329,18 +329,28 @@ name_devices (struct grub_efidisk_data *devices)
     {
       grub_efi_device_path_t *dp;
       grub_efi_block_io_media_t *m;
+      int is_floppy = 0;
 
       dp = d->last_device_path;
       if (! dp)
 	continue;
 
       m = d->block_io->media;
-      if (m->logical_partition)
+      if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE
+	  && GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
+	  == GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE)
+	{
+	  grub_efi_acpi_device_path_t *acpi
+	    = (grub_efi_acpi_device_path_t *) dp;
+	  /* Floppy EISA ID.  */ 
+	  if (acpi->hid == 0x60441d0 || acpi->hid == 0x70041d0
+	      || acpi->hid == 0x70141d1)
+	    is_floppy = 1;
+	}
+      if (is_floppy)
 	{
-	  /* Only one partition in a non-media device. Assume that this
-	     is a floppy drive.  */
 #ifdef DEBUG_NAMES
-	  grub_printf ("adding a floppy by guessing: ");
+	  grub_printf ("adding a floppy: ");
 	  grub_efi_print_device_path (d->device_path);
 #endif
 	  add_device (&fd_devices, d);
-- 
1.8.1.4