summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorFeng Tian <feng.tian@intel.com>2016-04-29 14:31:36 +0800
committerFeng Tian <feng.tian@intel.com>2016-05-06 16:09:58 +0800
commitc25ddd0134be8756ff249cb5467a917a6a50c307 (patch)
tree1114f0ba0ee74b87f871b950c2d437519208ab20 /MdeModulePkg/Bus
parent36fbc6973cbde855502b6f07fa80207e2bf0536b (diff)
downloadedk2-platforms-c25ddd0134be8756ff249cb5467a917a6a50c307.tar.xz
MdeModulePkg/SdMmcPciHcDxe: break cmd exec if the card isn't identified
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>
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c33
-rw-r--r--MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h1
2 files changed, 29 insertions, 5 deletions
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
index b7240f256c..ed6b557347 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
@@ -51,8 +51,8 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate = {
// Queue
INITIALIZE_LIST_HEAD_VARIABLE (gSdMmcPciHcTemplate.Queue),
{ // Slot
- {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0},
- {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}, {0, UnknownSlot, 0, 0}
+ {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0},
+ {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}
},
{ // Capability
{0},
@@ -247,6 +247,7 @@ SdMmcPciHcEnumerateDevice (
if ((Status == EFI_MEDIA_CHANGED) && !MediaPresent) {
DEBUG ((EFI_D_INFO, "SdMmcPciHcEnumerateDevice: device disconnected at slot %d of pci %p\n", Slot, Private->PciIo));
Private->Slot[Slot].MediaPresent = FALSE;
+ Private->Slot[Slot].Initialized = FALSE;
//
// Signal all async task events at the slot with EFI_NO_MEDIA status.
//
@@ -290,6 +291,7 @@ SdMmcPciHcEnumerateDevice (
}
Private->Slot[Slot].MediaPresent = TRUE;
+ Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
for (Index = 0; Index < RoutineNum; Index++) {
Routine = &mCardTypeDetectRoutineTable[Index];
@@ -300,6 +302,12 @@ SdMmcPciHcEnumerateDevice (
}
}
}
+ //
+ // This card doesn't get initialized correctly.
+ //
+ if (Index == RoutineNum) {
+ Private->Slot[Slot].Initialized = FALSE;
+ }
//
// Notify the upper layer the connect state change through ReinstallProtocolInterface.
@@ -633,6 +641,7 @@ SdMmcPciHcDriverBindingStart (
}
Private->Slot[Slot].MediaPresent = TRUE;
+ Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
for (Index = 0; Index < RoutineNum; Index++) {
Routine = &mCardTypeDetectRoutineTable[Index];
@@ -643,6 +652,12 @@ SdMmcPciHcDriverBindingStart (
}
}
}
+ //
+ // This card doesn't get initialized correctly.
+ //
+ if (Index == RoutineNum) {
+ Private->Slot[Slot].Initialized = FALSE;
+ }
}
//
@@ -927,6 +942,10 @@ SdMmcPassThruPassThru (
return EFI_NO_MEDIA;
}
+ if (!Private->Slot[Slot].Initialized) {
+ return EFI_DEVICE_ERROR;
+ }
+
Trb = SdMmcCreateTrb (Private, Slot, Packet, Event);
if (Trb == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -1244,9 +1263,13 @@ SdMmcPassThruResetDevice (
return EFI_INVALID_PARAMETER;
}
- if (!Private->Slot[Slot].MediaPresent) {
- return EFI_NO_MEDIA;
- }
+ if (!Private->Slot[Slot].MediaPresent) {
+ return EFI_NO_MEDIA;
+ }
+
+ if (!Private->Slot[Slot].Initialized) {
+ return EFI_DEVICE_ERROR;
+ }
//
// Free all async I/O requests in the queue
//
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
index 2cca82383c..6a2a279699 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
@@ -83,6 +83,7 @@ typedef struct {
BOOLEAN Enable;
EFI_SD_MMC_SLOT_TYPE SlotType;
BOOLEAN MediaPresent;
+ BOOLEAN Initialized;
SD_MMC_CARD_TYPE CardType;
} SD_MMC_HC_SLOT;