+ if ((Device->ExtCsd.SecFeatureSupport & BIT4) == 0) {\r
+ //\r
+ // If the Trim operation is not supported by the device, handle the erase\r
+ // of blocks that do not form a complete erase group separately.\r
+ //\r
+ EraseGroupSize = This->EraseLengthGranularity;\r
+\r
+ DivU64x32Remainder (FirstLba, EraseGroupSize, &Remainder);\r
+ StartGroupLba = (Remainder == 0) ? FirstLba : (FirstLba + EraseGroupSize - Remainder);\r
+\r
+ DivU64x32Remainder (LastLba + 1, EraseGroupSize, &Remainder);\r
+ EndGroupLba = LastLba + 1 - Remainder;\r
+\r
+ //\r
+ // If the size to erase is smaller than the erase group size, the whole\r
+ // erase operation is performed by writting zeros.\r
+ //\r
+ if (BlockNum < EraseGroupSize) {\r
+ Status = EmmcWriteZeros (Partition, FirstLba, Size);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "EmmcEraseBlocks(): Lba 0x%x BlkNo 0x%x Event %p with %r\n",\r
+ Lba,\r
+ BlockNum,\r
+ (Token != NULL) ? Token->Event : NULL,\r
+ Status\r
+ ));\r
+\r
+ if ((Token != NULL) && (Token->Event != NULL)) {\r
+ Token->TransactionStatus = EFI_SUCCESS;\r
+ gBS->SignalEvent (Token->Event);\r
+ }\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ //\r
+ // If the starting LBA to erase is not aligned with the start of an erase\r
+ // group, write zeros to erase the data from starting LBA to the end of the\r
+ // current erase group.\r
+ //\r
+ if (StartGroupLba > FirstLba) {\r
+ WriteZeroSize = (UINTN)(StartGroupLba - FirstLba) * BlockSize;\r
+ Status = EmmcWriteZeros (Partition, FirstLba, WriteZeroSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ //\r
+ // If the ending LBA to erase is not aligned with the end of an erase\r
+ // group, write zeros to erase the data from the start of the erase group\r
+ // to the ending LBA.\r
+ //\r
+ if (EndGroupLba <= LastLba) {\r
+ WriteZeroSize = (UINTN)(LastLba + 1 - EndGroupLba) * BlockSize;\r
+ Status = EmmcWriteZeros (Partition, EndGroupLba, WriteZeroSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Check whether there is erase group to erase.\r
+ //\r
+ if (EndGroupLba <= StartGroupLba) {\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "EmmcEraseBlocks(): Lba 0x%x BlkNo 0x%x Event %p with %r\n",\r
+ Lba,\r
+ BlockNum,\r
+ (Token != NULL) ? Token->Event : NULL,\r
+ Status\r
+ ));\r
+\r
+ if ((Token != NULL) && (Token->Event != NULL)) {\r
+ Token->TransactionStatus = EFI_SUCCESS;\r
+ gBS->SignalEvent (Token->Event);\r
+ }\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ FirstLba = StartGroupLba;\r
+ LastLba = EndGroupLba - 1;\r
+ }\r
+\r
+ Status = EmmcEraseBlockStart (Partition, FirstLba, (EFI_BLOCK_IO2_TOKEN*)Token, FALSE);\r