]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance IdeBusDxe to check the class code for IDE mode only.
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Dec 2010 02:45:29 +0000 (02:45 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Dec 2010 02:45:29 +0000 (02:45 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11147 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c

index 7ed004d15045732ebc8bd6d87effd2e99692da15..a38611304f75a1ae8ee4493e9713d6075de8f108 100644 (file)
@@ -148,6 +148,8 @@ IDEBusDriverBindingSupported (
   EFI_DEVICE_PATH_PROTOCOL          *ParentDevicePath;\r
   EFI_DEV_PATH                      *Node;\r
   EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeInit;\r
+  EFI_PCI_IO_PROTOCOL               *PciIo;\r
+  PCI_TYPE00                        PciData;\r
 \r
   if (RemainingDevicePath != NULL) {\r
     Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
@@ -171,10 +173,6 @@ IDEBusDriverBindingSupported (
   //\r
   // Verify the Ide Controller Init Protocol, which installed by the\r
   // IdeController module.\r
-  // Note 1: PciIo protocol has been opened BY_DRIVER by ide_init, so We can't\r
-  //         open BY_DRIVER here) That's why we don't check pciio protocol\r
-  // Note 2: ide_init driver check ide controller's pci config space, so we dont\r
-  //         check here any more to save code size\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -228,6 +226,45 @@ IDEBusDriverBindingSupported (
         Controller\r
         );\r
 \r
+  //\r
+  // Get the EfiPciIoProtocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID **) &PciIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  //\r
+  // Now further check the PCI header: Base class (offset 0x0B) and\r
+  // Sub Class (offset 0x0A). This controller should be an IDE controller\r
+  //\r
+  Status = PciIo->Pci.Read (\r
+                        PciIo,\r
+                        EfiPciIoWidthUint8,\r
+                        0,\r
+                        sizeof (PciData),\r
+                        &PciData\r
+                        );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Examine if it is IDE mode by class code\r
+    //\r
+    if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) || (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE)) {     \r
+      Status = EFI_UNSUPPORTED;\r
+    } else {    \r
+      Status = EFI_SUCCESS;\r
+    } \r
+  }\r
+\r
   return Status;\r
 }\r
 \r