EmbeddedPkg/MmcDxe: Add 'This' pointer attribute to protocol function

This attribute allows the EFI_MMC_HOST_PROTOCOL interface to manage
multiple instances in one driver.


EmbeddedPkg/MmcDxe: Add Revision attribute to the EFI_MMC_HOST_PROTOCOL


Note: The ARM PL180 and Omap35xx MMC host drivers has been updated.




git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12255 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-09-01 17:08:41 +00:00
parent 66f47f9fc0
commit 16d88c2d20
6 changed files with 141 additions and 88 deletions

View File

@ -46,7 +46,7 @@ MciInitialize (
BOOLEAN BOOLEAN
MciIsCardPresent ( MciIsCardPresent (
VOID IN EFI_MMC_HOST_PROTOCOL *This
) )
{ {
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 1); return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 1);
@ -54,7 +54,7 @@ MciIsCardPresent (
BOOLEAN BOOLEAN
MciIsReadOnly ( MciIsReadOnly (
VOID IN EFI_MMC_HOST_PROTOCOL *This
) )
{ {
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 2); return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 2);
@ -92,22 +92,23 @@ MciPrepareDataPath (
) )
{ {
// Set Data Length & Data Timer // Set Data Length & Data Timer
MmioWrite32(MCI_DATA_TIMER_REG,0xFFFFFFF); MmioWrite32 (MCI_DATA_TIMER_REG,0xFFFFFFF);
MmioWrite32(MCI_DATA_LENGTH_REG,MMCI0_BLOCKLEN); MmioWrite32 (MCI_DATA_LENGTH_REG,MMCI0_BLOCKLEN);
#ifndef USE_STREAM #ifndef USE_STREAM
//Note: we are using a hardcoded BlockLen (=512). If we decide to use a variable size, we could //Note: we are using a hardcoded BlockLen (=512). If we decide to use a variable size, we could
// compute the pow2 of BlockLen with the above function GetPow2BlockLen() // compute the pow2 of BlockLen with the above function GetPow2BlockLen()
MmioWrite32(MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | (MMCI0_POW2_BLOCKLEN << 4)); MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | (MMCI0_POW2_BLOCKLEN << 4));
#else #else
MmioWrite32(MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | MCI_DATACTL_STREAM_TRANS); MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | MCI_DATACTL_STREAM_TRANS);
#endif #endif
} }
EFI_STATUS EFI_STATUS
MciSendCommand ( MciSendCommand (
IN MMC_CMD MmcCmd, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINT32 Argument IN MMC_CMD MmcCmd,
IN UINT32 Argument
) )
{ {
UINT32 Status; UINT32 Status;
@ -190,7 +191,7 @@ MciSendCommand (
} }
Exit: Exit:
//Disable Command Path // Disable Command Path
CmdCtrlReg = MmioRead32(MCI_COMMAND_REG); CmdCtrlReg = MmioRead32(MCI_COMMAND_REG);
MmioWrite32(MCI_COMMAND_REG, (CmdCtrlReg & ~MCI_CPSM_ENABLED)); MmioWrite32(MCI_COMMAND_REG, (CmdCtrlReg & ~MCI_CPSM_ENABLED));
return RetVal; return RetVal;
@ -198,8 +199,9 @@ Exit:
EFI_STATUS EFI_STATUS
MciReceiveResponse ( MciReceiveResponse (
IN MMC_RESPONSE_TYPE Type, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINT32* Buffer IN MMC_RESPONSE_TYPE Type,
IN UINT32* Buffer
) )
{ {
if (Buffer == NULL) { if (Buffer == NULL) {
@ -223,9 +225,10 @@ MciReceiveResponse (
EFI_STATUS EFI_STATUS
MciReadBlockData ( MciReadBlockData (
IN EFI_LBA Lba, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINTN Length, IN EFI_LBA Lba,
IN UINT32* Buffer IN UINTN Length,
IN UINT32* Buffer
) )
{ {
UINTN Loop; UINTN Loop;
@ -298,9 +301,10 @@ MciReadBlockData (
EFI_STATUS EFI_STATUS
MciWriteBlockData ( MciWriteBlockData (
IN EFI_LBA Lba, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINTN Length, IN EFI_LBA Lba,
IN UINT32* Buffer IN UINTN Length,
IN UINT32* Buffer
) )
{ {
UINTN Loop; UINTN Loop;
@ -396,7 +400,8 @@ Exit:
EFI_STATUS EFI_STATUS
MciNotifyState ( MciNotifyState (
IN MMC_STATE State IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_STATE State
) )
{ {
UINT32 Data32; UINT32 Data32;
@ -490,7 +495,8 @@ EFI_GUID mPL180MciDevicePathGuid = EFI_CALLER_ID_GUID;
EFI_STATUS EFI_STATUS
MciBuildDevicePath ( MciBuildDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
) )
{ {
EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode; EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
@ -503,6 +509,7 @@ MciBuildDevicePath (
} }
EFI_MMC_HOST_PROTOCOL gMciHost = { EFI_MMC_HOST_PROTOCOL gMciHost = {
MMC_HOST_PROTOCOL_REVISION,
MciIsCardPresent, MciIsCardPresent,
MciIsReadOnly, MciIsReadOnly,
MciBuildDevicePath, MciBuildDevicePath,

View File

@ -78,36 +78,75 @@ typedef enum _MMC_STATE {
MmcDisconnectState, MmcDisconnectState,
} MMC_STATE; } MMC_STATE;
typedef BOOLEAN (*MMC_ISCARDPRESENT)(); ///
/// Forward declaration for EFI_MMC_HOST_PROTOCOL
///
typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
typedef BOOLEAN (*MMC_ISREADONLY)(); typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT) (
IN EFI_MMC_HOST_PROTOCOL *This
);
typedef EFI_STATUS (*MMC_BUILDDEVICEPATH)(EFI_DEVICE_PATH_PROTOCOL **DevicePath); typedef BOOLEAN (EFIAPI *MMC_ISREADONLY) (
IN EFI_MMC_HOST_PROTOCOL *This
);
typedef EFI_STATUS (*MMC_NOTIFYSTATE)(MMC_STATE State); typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH) (
IN EFI_MMC_HOST_PROTOCOL *This,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
typedef EFI_STATUS (*MMC_SENDCOMMAND)(MMC_CMD Cmd, UINT32 Argument); typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE) (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_STATE State
);
typedef EFI_STATUS (*MMC_RECEIVERESPONSE)(MMC_RESPONSE_TYPE Type, UINT32* Buffer); typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND) (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_CMD Cmd,
IN UINT32 Argument
);
typedef EFI_STATUS (*MMC_READBLOCKDATA)(EFI_LBA Lba, UINTN Length, UINT32* Buffer); typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE) (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_RESPONSE_TYPE Type,
IN UINT32 *Buffer
);
typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA) (
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
OUT UINT32 *Buffer
);
typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA) (
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
IN UINT32 *Buffer
);
typedef EFI_STATUS (*MMC_WRITEBLOCKDATA)(EFI_LBA Lba, UINTN Length, UINT32* Buffer);
typedef struct _EFI_MMC_HOST_PROTOCOL { typedef struct _EFI_MMC_HOST_PROTOCOL {
MMC_ISCARDPRESENT IsCardPresent;
MMC_ISREADONLY IsReadOnly;
MMC_BUILDDEVICEPATH BuildDevicePath;
MMC_NOTIFYSTATE NotifyState; UINT32 Revision;
MMC_ISCARDPRESENT IsCardPresent;
MMC_ISREADONLY IsReadOnly;
MMC_BUILDDEVICEPATH BuildDevicePath;
MMC_SENDCOMMAND SendCommand; MMC_NOTIFYSTATE NotifyState;
MMC_RECEIVERESPONSE ReceiveResponse;
MMC_SENDCOMMAND SendCommand;
MMC_RECEIVERESPONSE ReceiveResponse;
MMC_READBLOCKDATA ReadBlockData;
MMC_WRITEBLOCKDATA WriteBlockData;
MMC_READBLOCKDATA ReadBlockData;
MMC_WRITEBLOCKDATA WriteBlockData;
} EFI_MMC_HOST_PROTOCOL; } EFI_MMC_HOST_PROTOCOL;
#define MMC_HOST_PROTOCOL_REVISION 0x00010001 // 1.1
extern EFI_GUID gEfiMmcHostProtocolGuid; extern EFI_GUID gEfiMmcHostProtocolGuid;
#endif #endif

View File

@ -116,7 +116,7 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
MmcHostInstance->MmcHost = MmcHost; MmcHostInstance->MmcHost = MmcHost;
// Create DevicePath for the new MMC Host // Create DevicePath for the new MMC Host
Status = MmcHost->BuildDevicePath(&NewDevicePathNode); Status = MmcHost->BuildDevicePath (MmcHost, &NewDevicePathNode);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FREE_MEDIA; goto FREE_MEDIA;
} }
@ -364,13 +364,13 @@ CheckCardsCallback (
MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink); MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
ASSERT(MmcHostInstance != NULL); ASSERT(MmcHostInstance != NULL);
if (MmcHostInstance->MmcHost->IsCardPresent() == !MmcHostInstance->Initialized) { if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
MmcHostInstance->State = MmcHwInitializationState; MmcHostInstance->State = MmcHwInitializationState;
MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized; MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
MmcHostInstance->Initialized = !MmcHostInstance->Initialized; MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
if(MmcHostInstance->BlockIo.Media->MediaPresent) { if (MmcHostInstance->BlockIo.Media->MediaPresent) {
InitializeMmcDevice(MmcHostInstance); InitializeMmcDevice (MmcHostInstance);
} }
Status = gBS->ReinstallProtocolInterface ( Status = gBS->ReinstallProtocolInterface (

View File

@ -288,7 +288,7 @@ MmcFlushBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This IN EFI_BLOCK_IO_PROTOCOL *This
); );
EFI_STATUS InitializeMmcDevice( EFI_STATUS InitializeMmcDevice (
IN MMC_HOST_INSTANCE *MmcHost IN MMC_HOST_INSTANCE *MmcHost
); );

View File

@ -32,7 +32,7 @@ MmcNotifyState (
) )
{ {
MmcHostInstance->State = State; MmcHostInstance->State = State;
return MmcHostInstance->MmcHost->NotifyState(State); return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
} }
VOID VOID
@ -169,14 +169,14 @@ MmcGetCardStatus(
if(MmcHostInstance->State != MmcHwInitializationState){ if(MmcHostInstance->State != MmcHwInitializationState){
//Get the Status of the card. //Get the Status of the card.
CmdArg = MmcHostInstance->CardInfo.RCA << 16; CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status)); DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
return Status; return Status;
} }
//Read Response //Read Response
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
PrintResponseR1(Response[0]); PrintResponseR1(Response[0]);
} }
@ -214,7 +214,7 @@ MmcIdentificationMode (
} }
} else { } else {
//Note: Could even be used in all cases. But it looks this command could put the state machine into inactive for some cards //Note: Could even be used in all cases. But it looks this command could put the state machine into inactive for some cards
Status = MmcHost->SendCommand(MMC_CMD0, 0); Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n")); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
return Status; return Status;
@ -228,7 +228,7 @@ MmcIdentificationMode (
} }
// Are we using SDIO ? // Are we using SDIO ?
Status = MmcHost->SendCommand(MMC_CMD5, 0); Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n")); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -236,11 +236,11 @@ MmcIdentificationMode (
// Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1) // Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1)
CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0); CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
Status = MmcHost->SendCommand(MMC_CMD8, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n")); DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
IsHCS = TRUE; IsHCS = TRUE;
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R7,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7,Response);
PrintResponseR1(Response[0]); PrintResponseR1(Response[0]);
//check if it is valid response //check if it is valid response
if(Response[0] != CmdArg){ if(Response[0] != CmdArg){
@ -255,7 +255,7 @@ MmcIdentificationMode (
Timeout = MAX_RETRY_COUNT; Timeout = MAX_RETRY_COUNT;
while (Timeout > 0) { while (Timeout > 0) {
// SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command // SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
Status = MmcHost->SendCommand(MMC_CMD55, 0); Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, 0);
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
DEBUG ((EFI_D_INFO, "Card should be SD\n")); DEBUG ((EFI_D_INFO, "Card should be SD\n"));
if (IsHCS) { if (IsHCS) {
@ -269,18 +269,18 @@ MmcIdentificationMode (
if (IsHCS) { if (IsHCS) {
CmdArg |= BIT30; CmdArg |= BIT30;
} }
Status = MmcHost->SendCommand(MMC_ACMD41, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_OCR,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0]; ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
} }
} else { } else {
DEBUG ((EFI_D_INFO, "Card should be MMC\n")); DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
MmcHostInstance->CardInfo.CardType = MMC_CARD; MmcHostInstance->CardInfo.CardType = MMC_CARD;
Status = MmcHost->SendCommand(MMC_CMD1, 0x800000); Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_OCR,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0]; ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
} }
} }
@ -315,12 +315,12 @@ MmcIdentificationMode (
return Status; return Status;
} }
Status = MmcHost->SendCommand(MMC_CMD2, 0); Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n")); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
return Status; return Status;
} }
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CID,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID,Response);
PrintCID(Response); PrintCID(Response);
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState); Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
@ -335,13 +335,13 @@ MmcIdentificationMode (
// The status returned for this CMD3 will be 2 - identification // The status returned for this CMD3 will be 2 - identification
// //
CmdArg = 1; CmdArg = 1;
Status = MmcHost->SendCommand(MMC_CMD3, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n")); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
return Status; return Status;
} }
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_RCA,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA,Response);
PrintRCA(Response[0]); PrintRCA(Response[0]);
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card // For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
@ -360,7 +360,7 @@ MmcIdentificationMode (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS InitializeMmcDevice( EFI_STATUS InitializeMmcDevice (
IN MMC_HOST_INSTANCE *MmcHostInstance IN MMC_HOST_INSTANCE *MmcHostInstance
) )
{ {
@ -376,13 +376,13 @@ EFI_STATUS InitializeMmcDevice(
//Send a command to get Card specific data //Send a command to get Card specific data
CmdArg = MmcHostInstance->CardInfo.RCA << 16; CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD9, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status)); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
return Status; return Status;
} }
//Read Response //Read Response
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CSD,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD,Response);
PrintCSD(Response); PrintCSD(Response);
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) { if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
@ -403,12 +403,12 @@ EFI_STATUS InitializeMmcDevice(
MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1); MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
MmcHostInstance->BlockIo.Media->BlockSize = BlockSize; MmcHostInstance->BlockIo.Media->BlockSize = BlockSize;
MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly(); MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost);
MmcHostInstance->BlockIo.Media->MediaPresent = TRUE; MmcHostInstance->BlockIo.Media->MediaPresent = TRUE;
MmcHostInstance->BlockIo.Media->MediaId++; MmcHostInstance->BlockIo.Media->MediaId++;
CmdArg = MmcHostInstance->CardInfo.RCA << 16; CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD7, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status)); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
return Status; return Status;
@ -421,7 +421,7 @@ EFI_STATUS InitializeMmcDevice(
} }
// Set Block Length // Set Block Length
Status = MmcHost->SendCommand(MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize); Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status)); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status));
return Status; return Status;
@ -429,7 +429,7 @@ EFI_STATUS InitializeMmcDevice(
// Block Count (not used). Could return an error for SD card // Block Count (not used). Could return an error for SD card
if (MmcHostInstance->CardInfo.CardType == MMC_CARD) { if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
MmcHost->SendCommand(MMC_CMD23, BlockCount); MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -452,7 +452,7 @@ MmcReset (
} }
// If a card is not present then clear all media settings // If a card is not present then clear all media settings
if (!MmcHostInstance->MmcHost->IsCardPresent()) { if (!MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost)) {
MmcHostInstance->BlockIo.Media->MediaPresent = FALSE; MmcHostInstance->BlockIo.Media->MediaPresent = FALSE;
MmcHostInstance->BlockIo.Media->LastBlock = 0; MmcHostInstance->BlockIo.Media->LastBlock = 0;
MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo
@ -474,7 +474,7 @@ MmcDetectCard (
EFI_MMC_HOST_PROTOCOL *MmcHost EFI_MMC_HOST_PROTOCOL *MmcHost
) )
{ {
if (!MmcHost->IsCardPresent()) { if (!MmcHost->IsCardPresent (MmcHost)) {
return EFI_NO_MEDIA; return EFI_NO_MEDIA;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -544,9 +544,9 @@ MmcIoBlocks (
Response[0] = 0; Response[0] = 0;
Timeout = 20; Timeout = 20;
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) { while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
} }
} }
@ -577,7 +577,7 @@ MmcIoBlocks (
//TODO: Should we support write stream (MMC_CMD20) //TODO: Should we support write stream (MMC_CMD20)
#endif #endif
} }
Status = MmcHost->SendCommand(Cmd, CmdArg); Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status)); DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status));
return Status; return Status;
@ -586,7 +586,7 @@ MmcIoBlocks (
if (Transfer == MMC_IOBLOCKS_READ) { if (Transfer == MMC_IOBLOCKS_READ) {
#ifndef USE_STREAM #ifndef USE_STREAM
// Read one block of Data // Read one block of Data
Status = MmcHost->ReadBlockData(Lba,This->Media->BlockSize,Buffer); Status = MmcHost->ReadBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status)); DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status));
return Status; return Status;
@ -603,7 +603,7 @@ MmcIoBlocks (
} else { } else {
#ifndef USE_STREAM #ifndef USE_STREAM
// Write one block of Data // Write one block of Data
Status = MmcHost->WriteBlockData(Lba,This->Media->BlockSize,Buffer); Status = MmcHost->WriteBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status)); DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status));
return Status; return Status;
@ -615,9 +615,9 @@ MmcIoBlocks (
} }
// Command 12 - Stop transmission (ends read) // Command 12 - Stop transmission (ends read)
Status = MmcHost->SendCommand(MMC_CMD12, 0); Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1b,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b,Response);
} }
// Command 13 - Read status and wait for programming to complete (return to tran) // Command 13 - Read status and wait for programming to complete (return to tran)
@ -625,9 +625,9 @@ MmcIoBlocks (
CmdArg = MmcHostInstance->CardInfo.RCA << 16; CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0; Response[0] = 0;
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) { while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg); Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response); MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
} }
NanoSecondDelay(100); NanoSecondDelay(100);
Timeout--; Timeout--;

View File

@ -280,7 +280,7 @@ InitializeMMCHS (
BOOLEAN BOOLEAN
MMCIsCardPresent ( MMCIsCardPresent (
VOID IN EFI_MMC_HOST_PROTOCOL *This
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -299,7 +299,7 @@ MMCIsCardPresent (
BOOLEAN BOOLEAN
MMCIsReadOnly ( MMCIsReadOnly (
VOID IN EFI_MMC_HOST_PROTOCOL *This
) )
{ {
/* Note: /* Note:
@ -318,7 +318,8 @@ EFI_GUID mPL180MciDevicePathGuid = EFI_CALLER_ID_GUID;
EFI_STATUS EFI_STATUS
MMCBuildDevicePath ( MMCBuildDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
) )
{ {
EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode; EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
@ -331,8 +332,9 @@ MMCBuildDevicePath (
EFI_STATUS EFI_STATUS
MMCSendCommand ( MMCSendCommand (
IN MMC_CMD MmcCmd, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINT32 Argument IN MMC_CMD MmcCmd,
IN UINT32 Argument
) )
{ {
UINTN MmcStatus; UINTN MmcStatus;
@ -403,7 +405,8 @@ MMCSendCommand (
EFI_STATUS EFI_STATUS
MMCNotifyState ( MMCNotifyState (
IN MMC_STATE State IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_STATE State
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -526,8 +529,9 @@ MMCNotifyState (
EFI_STATUS EFI_STATUS
MMCReceiveResponse ( MMCReceiveResponse (
IN MMC_RESPONSE_TYPE Type, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINT32* Buffer IN MMC_RESPONSE_TYPE Type,
IN UINT32* Buffer
) )
{ {
if (Buffer == NULL) { if (Buffer == NULL) {
@ -554,9 +558,10 @@ MMCReceiveResponse (
EFI_STATUS EFI_STATUS
MMCReadBlockData ( MMCReadBlockData (
IN EFI_LBA Lba, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINTN Length, IN EFI_LBA Lba,
IN UINT32* Buffer IN UINTN Length,
IN UINT32* Buffer
) )
{ {
UINTN MmcStatus; UINTN MmcStatus;
@ -595,9 +600,10 @@ MMCReadBlockData (
EFI_STATUS EFI_STATUS
MMCWriteBlockData ( MMCWriteBlockData (
IN EFI_LBA Lba, IN EFI_MMC_HOST_PROTOCOL *This,
IN UINTN Length, IN EFI_LBA Lba,
IN UINT32* Buffer IN UINTN Length,
IN UINT32* Buffer
) )
{ {
UINTN MmcStatus; UINTN MmcStatus;
@ -635,6 +641,7 @@ MMCWriteBlockData (
} }
EFI_MMC_HOST_PROTOCOL gMMCHost = { EFI_MMC_HOST_PROTOCOL gMMCHost = {
MMC_HOST_PROTOCOL_REVISION,
MMCIsCardPresent, MMCIsCardPresent,
MMCIsReadOnly, MMCIsReadOnly,
MMCBuildDevicePath, MMCBuildDevicePath,