]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SdMmcPciHcDxe: break cmd exec if the card isn't identified
authorFeng Tian <feng.tian@intel.com>
Fri, 29 Apr 2016 06:31:36 +0000 (14:31 +0800)
committerFeng Tian <feng.tian@intel.com>
Fri, 6 May 2016 08:09:58 +0000 (16:09 +0800)
Check if the card is identified/initialized correctly. if not, break
the following cmd execution through PassThru()/ResetDevice().

Cc: Wu, Hao A <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h

index b7240f256c8d425e36fb1588e552a751dcb316b0..ed6b557347ead7fe7735eeabb92a829f521bb469 100644 (file)
@@ -51,8 +51,8 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate = {
                                     // Queue\r
   INITIALIZE_LIST_HEAD_VARIABLE (gSdMmcPciHcTemplate.Queue),\r
   {                                 // Slot\r
-    {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0},\r
-    {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}\r
+    {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0},\r
+    {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}\r
   },\r
   {                                 // Capability\r
     {0},\r
@@ -247,6 +247,7 @@ SdMmcPciHcEnumerateDevice (
       if ((Status == EFI_MEDIA_CHANGED) && !MediaPresent) {\r
         DEBUG ((EFI_D_INFO, "SdMmcPciHcEnumerateDevice: device disconnected at slot %d of pci %p\n", Slot, Private->PciIo));\r
         Private->Slot[Slot].MediaPresent = FALSE;\r
+        Private->Slot[Slot].Initialized  = FALSE;\r
         //\r
         // Signal all async task events at the slot with EFI_NO_MEDIA status.\r
         //\r
@@ -290,6 +291,7 @@ SdMmcPciHcEnumerateDevice (
         }\r
 \r
         Private->Slot[Slot].MediaPresent = TRUE;\r
+        Private->Slot[Slot].Initialized  = TRUE;\r
         RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);\r
         for (Index = 0; Index < RoutineNum; Index++) {\r
           Routine = &mCardTypeDetectRoutineTable[Index];\r
@@ -300,6 +302,12 @@ SdMmcPciHcEnumerateDevice (
             }\r
           }\r
         }\r
+        //\r
+        // This card doesn't get initialized correctly.\r
+        //\r
+        if (Index == RoutineNum) {\r
+          Private->Slot[Slot].Initialized = FALSE;\r
+        }\r
 \r
         //\r
         // Notify the upper layer the connect state change through ReinstallProtocolInterface.\r
@@ -633,6 +641,7 @@ SdMmcPciHcDriverBindingStart (
     }\r
 \r
     Private->Slot[Slot].MediaPresent = TRUE;\r
+    Private->Slot[Slot].Initialized  = TRUE;\r
     RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);\r
     for (Index = 0; Index < RoutineNum; Index++) {\r
       Routine = &mCardTypeDetectRoutineTable[Index];\r
@@ -643,6 +652,12 @@ SdMmcPciHcDriverBindingStart (
         }\r
       }\r
     }\r
+    //\r
+    // This card doesn't get initialized correctly.\r
+    //\r
+    if (Index == RoutineNum) {\r
+      Private->Slot[Slot].Initialized = FALSE;\r
+    }\r
   }\r
 \r
   //\r
@@ -927,6 +942,10 @@ SdMmcPassThruPassThru (
     return EFI_NO_MEDIA;\r
   }\r
 \r
+  if (!Private->Slot[Slot].Initialized) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   Trb = SdMmcCreateTrb (Private, Slot, Packet, Event);\r
   if (Trb == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -1244,9 +1263,13 @@ SdMmcPassThruResetDevice (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-    if (!Private->Slot[Slot].MediaPresent) {\r
-      return EFI_NO_MEDIA;\r
-    }\r
+  if (!Private->Slot[Slot].MediaPresent) {\r
+    return EFI_NO_MEDIA;\r
+  }\r
+\r
+  if (!Private->Slot[Slot].Initialized) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
   //\r
   // Free all async I/O requests in the queue\r
   //\r
index 2cca82383c1203eb746590a4a0b9c56badb0d0d2..6a2a27969936e665ed4653c916dc2a95a108bb8b 100644 (file)
@@ -83,6 +83,7 @@ typedef struct {
   BOOLEAN                           Enable;\r
   EFI_SD_MMC_SLOT_TYPE              SlotType;\r
   BOOLEAN                           MediaPresent;\r
+  BOOLEAN                           Initialized;\r
   SD_MMC_CARD_TYPE                  CardType;\r
 } SD_MMC_HC_SLOT;\r
 \r