Revision: 13932
          http://edk2.svn.sourceforge.net/edk2/?rev=13932&view=rev
Author:   erictian
Date:     2012-11-09 06:39:56 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
MdeModulePkg/AtaAtapiPassThru: valid ports transverse algo of AHCI controller 
is updated to handle inconsecutive case

Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
    trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h

Modified: trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 2012-11-08 
03:15:20 UTC (rev 13931)
+++ trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c 2012-11-09 
06:39:56 UTC (rev 13932)
@@ -2202,8 +2202,19 @@
     return EFI_OUT_OF_RESOURCES;
   }
 
-  for (Port = 0; Port < MaxPortNumber; Port ++) {
+  for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port ++) {
     if ((PortImplementBitMap & (BIT0 << Port)) != 0) {
+      //
+      // According to AHCI spec, MaxPortNumber should be equal or greater than 
the number of implemented ports.
+      //
+      if ((MaxPortNumber--) == 0) {
+        //
+        // Should never be here.
+        //
+        ASSERT (FALSE);
+        return EFI_SUCCESS;
+      }
+
       IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelEnumeration, Port);
 
       //

Modified: trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h 2012-11-08 
03:15:20 UTC (rev 13931)
+++ trunk/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h 2012-11-09 
06:39:56 UTC (rev 13932)
@@ -26,6 +26,8 @@
 #define EFI_AHCI_IS_OFFSET                     0x0008
 #define EFI_AHCI_PI_OFFSET                     0x000C
 
+#define EFI_AHCI_MAX_PORTS                     32
+
 typedef struct {
   UINT32  Lower32;
   UINT32  Upper32;

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


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to