3 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include "EmmcBlockIoPei.h"
17 // Template for EMMC HC Slot Data.
19 EMMC_PEIM_HC_SLOT gEmmcHcSlotTemplate
= {
20 EMMC_PEIM_SLOT_SIG
, // Signature
108 TRUE
, // SectorAddressing
113 // Template for EMMC HC Private Data.
115 EMMC_PEIM_HC_PRIVATE_DATA gEmmcHcPrivateTemplate
= {
116 EMMC_PEIM_SIG
, // Signature
119 EmmcBlockIoPeimGetDeviceNo
,
120 EmmcBlockIoPeimGetMediaInfo
,
121 EmmcBlockIoPeimReadBlocks
124 EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION
,
125 EmmcBlockIoPeimGetDeviceNo2
,
126 EmmcBlockIoPeimGetMediaInfo2
,
127 EmmcBlockIoPeimReadBlocks2
130 EFI_PEI_PPI_DESCRIPTOR_PPI
,
131 &gEfiPeiVirtualBlockIoPpiGuid
,
135 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
136 &gEfiPeiVirtualBlockIo2PpiGuid
,
139 { // EndOfPeiNotifyList
140 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
141 &gEfiEndOfPeiSignalPpiGuid
,
142 EmmcBlockIoPeimEndOfPei
165 0 // TotalBlkIoDevices
168 Gets the count of block I/O devices that one specific block driver detects.
170 This function is used for getting the count of block I/O devices that one
171 specific block driver detects. To the PEI ATAPI driver, it returns the number
172 of all the detected ATAPI devices it detects during the enumeration process.
173 To the PEI legacy floppy driver, it returns the number of all the legacy
174 devices it finds during its enumeration process. If no device is detected,
175 then the function will return zero.
177 @param[in] PeiServices General-purpose services that are available
179 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI
181 @param[out] NumberBlockDevices The number of block I/O devices discovered.
183 @retval EFI_SUCCESS The operation performed successfully.
188 EmmcBlockIoPeimGetDeviceNo (
189 IN EFI_PEI_SERVICES
**PeiServices
,
190 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
191 OUT UINTN
*NumberBlockDevices
194 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
196 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS (This
);
197 *NumberBlockDevices
= Private
->TotalBlkIoDevices
;
202 Gets a block device's media information.
204 This function will provide the caller with the specified block device's media
205 information. If the media changes, calling this function will update the media
206 information accordingly.
208 @param[in] PeiServices General-purpose services that are available to every
210 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
211 @param[in] DeviceIndex Specifies the block device to which the function wants
212 to talk. Because the driver that implements Block I/O
213 PPIs will manage multiple block devices, the PPIs that
214 want to talk to a single device must specify the
215 device index that was assigned during the enumeration
216 process. This index is a number from one to
218 @param[out] MediaInfo The media information of the specified block media.
219 The caller is responsible for the ownership of this
223 The MediaInfo structure describes an enumeration of possible block device
224 types. This enumeration exists because no device paths are actually passed
225 across interfaces that describe the type or class of hardware that is publishing
226 the block I/O interface. This enumeration will allow for policy decisions
227 in the Recovery PEIM, such as "Try to recover from legacy floppy first,
228 LS-120 second, CD-ROM third." If there are multiple partitions abstracted
229 by a given device type, they should be reported in ascending order; this
230 order also applies to nested partitions, such as legacy MBR, where the
231 outermost partitions would have precedence in the reporting order. The
232 same logic applies to systems such as IDE that have precedence relationships
233 like "Master/Slave" or "Primary/Secondary". The master device should be
234 reported first, the slave second.
236 @retval EFI_SUCCESS Media information about the specified block device
237 was obtained successfully.
238 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
244 EmmcBlockIoPeimGetMediaInfo (
245 IN EFI_PEI_SERVICES
**PeiServices
,
246 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
247 IN UINTN DeviceIndex
,
248 OUT EFI_PEI_BLOCK_IO_MEDIA
*MediaInfo
251 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
258 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS (This
);
260 if ((DeviceIndex
== 0) || (DeviceIndex
> Private
->TotalBlkIoDevices
)) {
261 return EFI_INVALID_PARAMETER
;
266 for (SlotNum
= 0; SlotNum
< Private
->SlotNum
; SlotNum
++) {
267 for (MediaNum
= 0; MediaNum
< Private
->Slot
[SlotNum
].MediaNum
; MediaNum
++) {
269 if (Location
== DeviceIndex
) {
279 MediaInfo
->DeviceType
= EMMC
;
280 MediaInfo
->MediaPresent
= TRUE
;
281 MediaInfo
->LastBlock
= (UINTN
)Private
->Slot
[SlotNum
].Media
[MediaNum
].LastBlock
;
282 MediaInfo
->BlockSize
= Private
->Slot
[SlotNum
].Media
[MediaNum
].BlockSize
;
288 Reads the requested number of blocks from the specified block device.
290 The function reads the requested number of blocks from the device. All the
291 blocks are read, or an error is returned. If there is no media in the device,
292 the function returns EFI_NO_MEDIA.
294 @param[in] PeiServices General-purpose services that are available to
296 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
297 @param[in] DeviceIndex Specifies the block device to which the function wants
298 to talk. Because the driver that implements Block I/O
299 PPIs will manage multiple block devices, PPIs that
300 want to talk to a single device must specify the device
301 index that was assigned during the enumeration process.
302 This index is a number from one to NumberBlockDevices.
303 @param[in] StartLBA The starting logical block address (LBA) to read from
305 @param[in] BufferSize The size of the Buffer in bytes. This number must be
306 a multiple of the intrinsic block size of the device.
307 @param[out] Buffer A pointer to the destination buffer for the data.
308 The caller is responsible for the ownership of the
311 @retval EFI_SUCCESS The data was read correctly from the device.
312 @retval EFI_DEVICE_ERROR The device reported an error while attempting
313 to perform the read operation.
314 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
315 valid, or the buffer is not properly aligned.
316 @retval EFI_NO_MEDIA There is no media in the device.
317 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
318 the intrinsic block size of the device.
323 EmmcBlockIoPeimReadBlocks (
324 IN EFI_PEI_SERVICES
**PeiServices
,
325 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
326 IN UINTN DeviceIndex
,
327 IN EFI_PEI_LBA StartLBA
,
334 UINTN NumberOfBlocks
;
335 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
339 UINT8 PartitionConfig
;
344 Status
= EFI_SUCCESS
;
346 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS (This
);
351 if (Buffer
== NULL
) {
352 return EFI_INVALID_PARAMETER
;
355 if (BufferSize
== 0) {
359 if ((DeviceIndex
== 0) || (DeviceIndex
> Private
->TotalBlkIoDevices
)) {
360 return EFI_INVALID_PARAMETER
;
365 for (SlotNum
= 0; SlotNum
< Private
->SlotNum
; SlotNum
++) {
366 for (MediaNum
= 0; MediaNum
< Private
->Slot
[SlotNum
].MediaNum
; MediaNum
++) {
368 if (Location
== DeviceIndex
) {
378 BlockSize
= Private
->Slot
[SlotNum
].Media
[MediaNum
].BlockSize
;
379 if (BufferSize
% BlockSize
!= 0) {
380 return EFI_BAD_BUFFER_SIZE
;
383 if (StartLBA
> Private
->Slot
[SlotNum
].Media
[MediaNum
].LastBlock
) {
384 return EFI_INVALID_PARAMETER
;
387 NumberOfBlocks
= BufferSize
/ BlockSize
;
390 // Check if needs to switch partition access.
392 PartitionConfig
= Private
->Slot
[SlotNum
].ExtCsd
.PartitionConfig
;
393 if ((PartitionConfig
& 0x7) != Private
->Slot
[SlotNum
].PartitionType
[MediaNum
]) {
394 PartitionConfig
&= (UINT8
)~0x7;
395 PartitionConfig
|= Private
->Slot
[SlotNum
].PartitionType
[MediaNum
];
396 Status
= EmmcPeimSwitch (
397 &Private
->Slot
[SlotNum
],
399 OFFSET_OF (EMMC_EXT_CSD
, PartitionConfig
),
403 if (EFI_ERROR (Status
)) {
406 Private
->Slot
[SlotNum
].ExtCsd
.PartitionConfig
= PartitionConfig
;
409 // Start to execute data transfer. The max block number in single cmd is 65535 blocks.
411 Remaining
= NumberOfBlocks
;
414 while (Remaining
> 0) {
415 if (Remaining
<= MaxBlock
) {
416 NumberOfBlocks
= Remaining
;
418 NumberOfBlocks
= MaxBlock
;
421 Status
= EmmcPeimSetBlkCount (&Private
->Slot
[SlotNum
], (UINT16
)NumberOfBlocks
);
422 if (EFI_ERROR (Status
)) {
426 BufferSize
= NumberOfBlocks
* BlockSize
;
427 Status
= EmmcPeimRwMultiBlocks (&Private
->Slot
[SlotNum
], StartLBA
, BlockSize
, Buffer
, BufferSize
, TRUE
);
428 if (EFI_ERROR (Status
)) {
432 StartLBA
+= NumberOfBlocks
;
433 Buffer
= (UINT8
*)Buffer
+ BufferSize
;
434 Remaining
-= NumberOfBlocks
;
440 Gets the count of block I/O devices that one specific block driver detects.
442 This function is used for getting the count of block I/O devices that one
443 specific block driver detects. To the PEI ATAPI driver, it returns the number
444 of all the detected ATAPI devices it detects during the enumeration process.
445 To the PEI legacy floppy driver, it returns the number of all the legacy
446 devices it finds during its enumeration process. If no device is detected,
447 then the function will return zero.
449 @param[in] PeiServices General-purpose services that are available
451 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
453 @param[out] NumberBlockDevices The number of block I/O devices discovered.
455 @retval EFI_SUCCESS The operation performed successfully.
460 EmmcBlockIoPeimGetDeviceNo2 (
461 IN EFI_PEI_SERVICES
**PeiServices
,
462 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
463 OUT UINTN
*NumberBlockDevices
466 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
468 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This
);
469 *NumberBlockDevices
= Private
->TotalBlkIoDevices
;
475 Gets a block device's media information.
477 This function will provide the caller with the specified block device's media
478 information. If the media changes, calling this function will update the media
479 information accordingly.
481 @param[in] PeiServices General-purpose services that are available to every
483 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
484 @param[in] DeviceIndex Specifies the block device to which the function wants
485 to talk. Because the driver that implements Block I/O
486 PPIs will manage multiple block devices, the PPIs that
487 want to talk to a single device must specify the
488 device index that was assigned during the enumeration
489 process. This index is a number from one to
491 @param[out] MediaInfo The media information of the specified block media.
492 The caller is responsible for the ownership of this
496 The MediaInfo structure describes an enumeration of possible block device
497 types. This enumeration exists because no device paths are actually passed
498 across interfaces that describe the type or class of hardware that is publishing
499 the block I/O interface. This enumeration will allow for policy decisions
500 in the Recovery PEIM, such as "Try to recover from legacy floppy first,
501 LS-120 second, CD-ROM third." If there are multiple partitions abstracted
502 by a given device type, they should be reported in ascending order; this
503 order also applies to nested partitions, such as legacy MBR, where the
504 outermost partitions would have precedence in the reporting order. The
505 same logic applies to systems such as IDE that have precedence relationships
506 like "Master/Slave" or "Primary/Secondary". The master device should be
507 reported first, the slave second.
509 @retval EFI_SUCCESS Media information about the specified block device
510 was obtained successfully.
511 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
517 EmmcBlockIoPeimGetMediaInfo2 (
518 IN EFI_PEI_SERVICES
**PeiServices
,
519 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
520 IN UINTN DeviceIndex
,
521 OUT EFI_PEI_BLOCK_IO2_MEDIA
*MediaInfo
525 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
526 EFI_PEI_BLOCK_IO_MEDIA Media
;
533 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This
);
535 Status
= EmmcBlockIoPeimGetMediaInfo (
541 if (EFI_ERROR (Status
)) {
547 for (SlotNum
= 0; SlotNum
< Private
->SlotNum
; SlotNum
++) {
548 for (MediaNum
= 0; MediaNum
< Private
->Slot
[SlotNum
].MediaNum
; MediaNum
++) {
550 if (Location
== DeviceIndex
) {
560 CopyMem (MediaInfo
, &(Private
->Slot
[SlotNum
].Media
[MediaNum
]), sizeof (EFI_PEI_BLOCK_IO2_MEDIA
));
565 Reads the requested number of blocks from the specified block device.
567 The function reads the requested number of blocks from the device. All the
568 blocks are read, or an error is returned. If there is no media in the device,
569 the function returns EFI_NO_MEDIA.
571 @param[in] PeiServices General-purpose services that are available to
573 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
574 @param[in] DeviceIndex Specifies the block device to which the function wants
575 to talk. Because the driver that implements Block I/O
576 PPIs will manage multiple block devices, PPIs that
577 want to talk to a single device must specify the device
578 index that was assigned during the enumeration process.
579 This index is a number from one to NumberBlockDevices.
580 @param[in] StartLBA The starting logical block address (LBA) to read from
582 @param[in] BufferSize The size of the Buffer in bytes. This number must be
583 a multiple of the intrinsic block size of the device.
584 @param[out] Buffer A pointer to the destination buffer for the data.
585 The caller is responsible for the ownership of the
588 @retval EFI_SUCCESS The data was read correctly from the device.
589 @retval EFI_DEVICE_ERROR The device reported an error while attempting
590 to perform the read operation.
591 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
592 valid, or the buffer is not properly aligned.
593 @retval EFI_NO_MEDIA There is no media in the device.
594 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
595 the intrinsic block size of the device.
600 EmmcBlockIoPeimReadBlocks2 (
601 IN EFI_PEI_SERVICES
**PeiServices
,
602 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
603 IN UINTN DeviceIndex
,
604 IN EFI_PEI_LBA StartLBA
,
610 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
612 Status
= EFI_SUCCESS
;
613 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This
);
615 Status
= EmmcBlockIoPeimReadBlocks (
627 One notified function to cleanup the allocated DMA buffers at the end of PEI.
629 @param[in] PeiServices Pointer to PEI Services Table.
630 @param[in] NotifyDescriptor Pointer to the descriptor for the Notification
631 event that caused this function to execute.
632 @param[in] Ppi Pointer to the PPI data associated with this function.
634 @retval EFI_SUCCESS The function completes successfully
639 EmmcBlockIoPeimEndOfPei (
640 IN EFI_PEI_SERVICES
**PeiServices
,
641 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
645 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
647 Private
= GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor
);
649 if ((Private
->Pool
!= NULL
) && (Private
->Pool
->Head
!= NULL
)) {
650 EmmcPeimFreeMemPool (Private
->Pool
);
657 The user code starts with this function.
659 @param FileHandle Handle of the file being invoked.
660 @param PeiServices Describes the list of possible PEI Services.
662 @retval EFI_SUCCESS The driver is successfully initialized.
663 @retval Others Can't initialize the driver.
668 InitializeEmmcBlockIoPeim (
669 IN EFI_PEI_FILE_HANDLE FileHandle
,
670 IN CONST EFI_PEI_SERVICES
**PeiServices
674 EMMC_PEIM_HC_PRIVATE_DATA
*Private
;
675 EDKII_SD_MMC_HOST_CONTROLLER_PPI
*SdMmcHcPpi
;
677 UINT32 PartitionIndex
;
684 EMMC_EXT_CSD
*ExtCsd
;
685 EMMC_HC_SLOT_CAP Capability
;
686 EMMC_PEIM_HC_SLOT
*Slot
;
691 // Shadow this PEIM to run from memory
693 if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle
))) {
698 // locate Emmc host controller PPI
700 Status
= PeiServicesLocatePpi (
701 &gEdkiiPeiSdMmcHostControllerPpiGuid
,
704 (VOID
**) &SdMmcHcPpi
706 if (EFI_ERROR (Status
)) {
707 return EFI_DEVICE_ERROR
;
715 Status
= SdMmcHcPpi
->GetSdMmcHcMmioBar (SdMmcHcPpi
, Controller
, &MmioBase
, &BarNum
);
717 // When status is error, meant no controller is found
719 if (EFI_ERROR (Status
)) {
728 Private
= AllocateCopyPool (sizeof (EMMC_PEIM_HC_PRIVATE_DATA
), &gEmmcHcPrivateTemplate
);
729 if (Private
== NULL
) {
730 Status
= EFI_OUT_OF_RESOURCES
;
733 Private
->BlkIoPpiList
.Ppi
= (VOID
*)&Private
->BlkIoPpi
;
734 Private
->BlkIo2PpiList
.Ppi
= (VOID
*)&Private
->BlkIo2Ppi
;
736 // Initialize the memory pool which will be used in all transactions.
738 Status
= EmmcPeimInitMemPool (Private
);
739 if (EFI_ERROR (Status
)) {
740 Status
= EFI_OUT_OF_RESOURCES
;
744 for (Index
= 0; Index
< BarNum
; Index
++) {
745 Status
= EmmcPeimHcGetCapability (MmioBase
[Index
], &Capability
);
746 if (EFI_ERROR (Status
)) {
749 if (Capability
.SlotType
!= 0x1) {
750 DEBUG ((EFI_D_INFO
, "The slot at 0x%x is not embedded slot type\n", MmioBase
[Index
]));
751 Status
= EFI_UNSUPPORTED
;
755 Status
= EmmcPeimHcReset (MmioBase
[Index
]);
756 if (EFI_ERROR (Status
)) {
759 Status
= EmmcPeimHcCardDetect (MmioBase
[Index
]);
760 if (EFI_ERROR (Status
)) {
763 Status
= EmmcPeimHcInitHost (MmioBase
[Index
]);
764 if (EFI_ERROR (Status
)) {
768 SlotNum
= Private
->SlotNum
;
769 Slot
= &Private
->Slot
[SlotNum
];
770 CopyMem (Slot
, &gEmmcHcSlotTemplate
, sizeof (EMMC_PEIM_HC_SLOT
));
771 Slot
->Private
= Private
;
772 Slot
->EmmcHcBase
= MmioBase
[Index
];
773 CopyMem (&Slot
->Capability
, &Capability
, sizeof (Capability
));
775 Status
= EmmcPeimIdentification (Slot
);
776 if (EFI_ERROR (Status
)) {
780 ExtCsd
= &Slot
->ExtCsd
;
781 if (ExtCsd
->ExtCsdRev
< 5) {
782 DEBUG ((EFI_D_ERROR
, "The EMMC device version is too low, we don't support!!!\n"));
783 Status
= EFI_UNSUPPORTED
;
786 if ((ExtCsd
->PartitioningSupport
& BIT0
) != BIT0
) {
787 DEBUG ((EFI_D_ERROR
, "The EMMC device doesn't support Partition Feature!!!\n"));
788 Status
= EFI_UNSUPPORTED
;
792 for (PartitionIndex
= 0; PartitionIndex
< EMMC_PEIM_MAX_PARTITIONS
; PartitionIndex
++) {
793 switch (PartitionIndex
) {
794 case EmmcPartitionUserData
:
795 SecCount
= *(UINT32
*)&ExtCsd
->SecCount
;
796 Capacity
= MultU64x32 ((UINT64
)SecCount
, 0x200);
798 case EmmcPartitionBoot1
:
799 case EmmcPartitionBoot2
:
800 Capacity
= ExtCsd
->BootSizeMult
* SIZE_128KB
;
802 case EmmcPartitionRPMB
:
803 Capacity
= ExtCsd
->RpmbSizeMult
* SIZE_128KB
;
805 case EmmcPartitionGP1
:
806 GpSizeMult
= (ExtCsd
->GpSizeMult
[0] | (ExtCsd
->GpSizeMult
[1] << 8) | (ExtCsd
->GpSizeMult
[2] << 16));
807 Capacity
= MultU64x32 (MultU64x32 (MultU64x32 ((UINT64
)GpSizeMult
, ExtCsd
->HcWpGrpSize
), ExtCsd
->HcEraseGrpSize
), SIZE_512KB
);
809 case EmmcPartitionGP2
:
810 GpSizeMult
= (ExtCsd
->GpSizeMult
[3] | (ExtCsd
->GpSizeMult
[4] << 8) | (ExtCsd
->GpSizeMult
[5] << 16));
811 Capacity
= MultU64x32 (MultU64x32 (MultU64x32 ((UINT64
)GpSizeMult
, ExtCsd
->HcWpGrpSize
), ExtCsd
->HcEraseGrpSize
), SIZE_512KB
);
813 case EmmcPartitionGP3
:
814 GpSizeMult
= (ExtCsd
->GpSizeMult
[6] | (ExtCsd
->GpSizeMult
[7] << 8) | (ExtCsd
->GpSizeMult
[8] << 16));
815 Capacity
= MultU64x32 (MultU64x32 (MultU64x32 ((UINT64
)GpSizeMult
, ExtCsd
->HcWpGrpSize
), ExtCsd
->HcEraseGrpSize
), SIZE_512KB
);
817 case EmmcPartitionGP4
:
818 GpSizeMult
= (ExtCsd
->GpSizeMult
[9] | (ExtCsd
->GpSizeMult
[10] << 8) | (ExtCsd
->GpSizeMult
[11] << 16));
819 Capacity
= MultU64x32 (MultU64x32 (MultU64x32 ((UINT64
)GpSizeMult
, ExtCsd
->HcWpGrpSize
), ExtCsd
->HcEraseGrpSize
), SIZE_512KB
);
826 MediaNum
= Slot
->MediaNum
;
828 Slot
->Media
[MediaNum
].LastBlock
= DivU64x32 (Capacity
, Slot
->Media
[MediaNum
].BlockSize
) - 1;
829 Slot
->PartitionType
[MediaNum
] = PartitionIndex
;
830 Private
->TotalBlkIoDevices
++;
838 if (!EFI_ERROR (Status
)) {
839 PeiServicesInstallPpi (&Private
->BlkIoPpiList
);
840 PeiServicesNotifyPpi (&Private
->EndOfPeiNotifyList
);
842 if (Private
->Pool
->Head
!= NULL
) {
843 EmmcPeimFreeMemPool (Private
->Pool
);