Revision: 13953
          http://edk2.svn.sourceforge.net/edk2/?rev=13953&view=rev
Author:   li-elvin
Date:     2012-11-20 00:59:17 +0000 (Tue, 20 Nov 2012)
Log Message:
-----------
If IDE controller is not in IDE mode, we should not clear IO bar.

Signed-off-by: Li Elvin <[email protected]>
Reviewed-by: Yao Jiewen <[email protected]>

Modified Paths:
--------------
    trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
    trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c

Modified: 
trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h  
2012-11-19 02:15:46 UTC (rev 13952)
+++ trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h  
2012-11-20 00:59:17 UTC (rev 13953)
@@ -18,6 +18,7 @@
 
 
 #include <FrameworkDxe.h>
+#include <IndustryStandard\Pci.h>
 
 #include <Guid/SmBios.h>
 #include <Guid/Acpi.h>
@@ -134,6 +135,9 @@
 
 #define BDA_VIDEO_MODE      0x49
 
+#define IDE_PI_REGISTER_PNE     BIT0
+#define IDE_PI_REGISTER_SNE     BIT2
+
 typedef struct {
   UINTN   PciSegment;
   UINTN   PciBus;

Modified: trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c    
2012-11-19 02:15:46 UTC (rev 13952)
+++ trunk/edk2/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyIde.c    
2012-11-20 00:59:17 UTC (rev 13953)
@@ -268,9 +268,9 @@
   )
 {
   EFI_PCI_IO_PROTOCOL               *PciIo;
-  UINT8                             Pi;
   UINT32                            IOBarClear;
   EFI_STATUS                        Status;
+  PCI_TYPE00                        PciData;
 
   //
   // If the IDE channel is in compatibility (legacy) mode, remove all
@@ -279,22 +279,39 @@
   // and has PCI I/O resources allocated
   //
   Status = gBS->HandleProtocol (
-                  IdeController,
-                  &gEfiPciIoProtocolGuid,
-                  (VOID **) &PciIo
+                  IdeController, 
+                  &gEfiPciIoProtocolGuid, 
+                  &PciIo
                   );
-  if (!EFI_ERROR (Status)) {
-    IOBarClear = 0x00;
-    PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 1, &Pi);
-    if ((Pi & 0x01) == 0) {
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);
-    }
-    if ((Pi & 0x04) == 0) {
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);
-      PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);
-    }
+  if (EFI_ERROR (Status)) {
+    return ;
   }
 
+  Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (PciData), 
&PciData);
+  if (EFI_ERROR (Status)) {
+    return ;
+  }
+
+  //
+  // Check whether this is IDE
+  //
+  if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||
+      (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {
+    return ;
+  }
+
+  //
+  // Clear bar for legacy IDE
+  //
+  IOBarClear = 0x00;
+  if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_PNE) == 0) {
+    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);
+    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);
+  }
+  if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {
+    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);
+    PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);
+  }
+
   return ;
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to