]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Enforce disabling of firmware disk drivers when native drivers kick in.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:16:46 +0000 (12:16 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:16:46 +0000 (12:16 +0200)
ChangeLog
grub-core/bus/usb/ehci.c
grub-core/bus/usb/ohci.c
grub-core/bus/usb/uhci.c
grub-core/disk/ahci.c
grub-core/disk/efi/efidisk.c
grub-core/disk/ieee1275/ofdisk.c
grub-core/disk/pata.c
include/grub/disk.h

index 1ba588d3293db93edaeedb9339095e38f25a31be..1dea1aa8d1854c022c55437763783652a4150ddd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Enforce disabling of firmware disk drivers when native drivers kick in.
+
 2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/commands/nativedisk.c: Customize the list of modules on
index d18a87f8e371e2df3d40006ce210d3d451acbaec..9294445d3efdcc771a8d18a4c194d665d1cb1795 100644 (file)
@@ -28,6 +28,7 @@
 #include <grub/time.h>
 #include <grub/loader.h>
 #include <grub/cs5536.h>
+#include <grub/disk.h>
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
@@ -1909,6 +1910,9 @@ GRUB_MOD_INIT (ehci)
 {
   COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_td) == 64);
   COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);
+
+  grub_stop_disk_firmware ();
+
   grub_boot_time ("Initing EHCI hardware");
   grub_ehci_inithw ();
   grub_boot_time ("Registering EHCI driver");
index 2f3fd91fbab1bd4782441b77025db4af923db453..3be5c8d739f23c87bcf8e8d870cf3068a3d04695 100644 (file)
@@ -28,6 +28,7 @@
 #include <grub/time.h>
 #include <grub/cs5536.h>
 #include <grub/loader.h>
+#include <grub/disk.h>
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
@@ -1442,6 +1443,9 @@ GRUB_MOD_INIT(ohci)
 {
   COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
   COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
+
+  grub_stop_disk_firmware ();
+
   grub_ohci_inithw ();
   grub_usb_controller_dev_register (&usb_controller);
   fini_hnd = grub_loader_register_preboot_hook (grub_ohci_fini_hw,
index a3146373516290221e8c62592c751db6fd658f5a..c2e2e7efee7cdf2ce9a359f673108a998ed372d1 100644 (file)
@@ -866,6 +866,8 @@ static struct grub_usb_controller_dev usb_controller =
 
 GRUB_MOD_INIT(uhci)
 {
+  grub_stop_disk_firmware ();
+
   grub_uhci_inithw ();
   grub_usb_controller_dev_register (&usb_controller);
   grub_dprintf ("uhci", "registered\n");
index e6170426ea505eb3e72038e04b80c6bcaf961fba..554fcc55f0c6ac5752b2c4527ca34504fb274ea9 100644 (file)
@@ -183,11 +183,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
   if (class >> 8 != 0x010601)
     return 0;
 
-#ifdef GRUB_MACHINE_QEMU
-  addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
-  grub_pci_write_word (addr, 0x107);
-#endif
-
   addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG5);
 
 #ifdef GRUB_MACHINE_QEMU
@@ -1102,13 +1097,7 @@ static struct grub_preboot *fini_hnd;
 
 GRUB_MOD_INIT(ahci)
 {
-  /* To prevent two drivers operating on the same disks.  */
-  grub_disk_firmware_is_tainted = 1;
-  if (grub_disk_firmware_fini)
-    {
-      grub_disk_firmware_fini ();
-      grub_disk_firmware_fini = NULL;
-    }
+  grub_stop_disk_firmware ();
 
   /* AHCI initialization.  */
   grub_ahci_initialize ();
index e168d07fa8b52fb83f436b225d0437cc2c67ce53..ebd906e7c9ac17bad8229e9cc53219da6539d6c5 100644 (file)
@@ -623,22 +623,27 @@ static struct grub_disk_dev grub_efidisk_dev =
     .next = 0
   };
 
-void
-grub_efidisk_init (void)
-{
-  enumerate_disks ();
-  grub_disk_dev_register (&grub_efidisk_dev);
-}
-
 void
 grub_efidisk_fini (void)
 {
   free_devices (fd_devices);
   free_devices (hd_devices);
   free_devices (cd_devices);
+  fd_devices = 0;
+  hd_devices = 0;
+  cd_devices = 0;
   grub_disk_dev_unregister (&grub_efidisk_dev);
 }
 
+void
+grub_efidisk_init (void)
+{
+  grub_disk_firmware_fini = grub_efidisk_fini;
+
+  enumerate_disks ();
+  grub_disk_dev_register (&grub_efidisk_dev);
+}
+
 /* Some utility functions to map GRUB devices with EFI devices.  */
 grub_efi_handle_t
 grub_efidisk_get_device_handle (grub_disk_t disk)
index ec92c4d108eae49cfbc713059561094257850df1..2a31ecdb1c0f5716ec22948fd6fea51469c7aec9 100644 (file)
@@ -549,14 +549,6 @@ insert_bootpath (void)
   grub_free (bootpath);
 }
 
-void
-grub_ofdisk_init (void)
-{
-  insert_bootpath ();
-
-  grub_disk_dev_register (&grub_ofdisk_dev);
-}
-
 void
 grub_ofdisk_fini (void)
 {
@@ -568,6 +560,16 @@ grub_ofdisk_fini (void)
   grub_disk_dev_unregister (&grub_ofdisk_dev);
 }
 
+void
+grub_ofdisk_init (void)
+{
+  grub_disk_firmware_fini = grub_ofdisk_fini;
+
+  insert_bootpath ();
+
+  grub_disk_dev_register (&grub_ofdisk_dev);
+}
+
 grub_err_t
 grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
 {
index 75e5deb618836099ef2e2d75b0412fbb7f740f25..8c4b27b7e98c0da91b3be4796b0838f1527a4228 100644 (file)
@@ -530,13 +530,7 @@ static struct grub_ata_dev grub_pata_dev =
 
 GRUB_MOD_INIT(ata_pthru)
 {
-  /* To prevent two drivers operating on the same disks.  */
-  grub_disk_firmware_is_tainted = 1;
-  if (grub_disk_firmware_fini)
-    {
-      grub_disk_firmware_fini ();
-      grub_disk_firmware_fini = NULL;
-    }
+  grub_stop_disk_firmware ();
 
   /* ATA initialization.  */
   grub_pata_initialize ();
index d19b1ac962f0ac679e9c234d22e515be0e348867..8fa09a6dfdd1ce16b3f5ac8f9a7f26ebc8cc40ff 100644 (file)
@@ -25,6 +25,8 @@
 #include <grub/err.h>
 #include <grub/types.h>
 #include <grub/device.h>
+/* For NULL.  */
+#include <grub/mm.h>
 
 /* These are used to set a device id. When you add a new disk device,
    you must define a new id for it here.  */
@@ -205,6 +207,18 @@ EXPORT_FUNC(grub_disk_cache_get_performance) (unsigned long *hits, unsigned long
 extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
 extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
 
+static inline void
+grub_stop_disk_firmware (void)
+{
+  /* To prevent two drivers operating on the same disks.  */
+  grub_disk_firmware_is_tainted = 1;
+  if (grub_disk_firmware_fini)
+    {
+      grub_disk_firmware_fini ();
+      grub_disk_firmware_fini = NULL;
+    }
+}
+
 #if defined (GRUB_UTIL)
 void grub_lvm_init (void);
 void grub_ldm_init (void);