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
MciIsCardPresent (
VOID
IN EFI_MMC_HOST_PROTOCOL *This
)
{
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 1);
@ -54,7 +54,7 @@ MciIsCardPresent (
BOOLEAN
MciIsReadOnly (
VOID
IN EFI_MMC_HOST_PROTOCOL *This
)
{
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 2);
@ -106,6 +106,7 @@ MciPrepareDataPath (
EFI_STATUS
MciSendCommand (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_CMD MmcCmd,
IN UINT32 Argument
)
@ -198,6 +199,7 @@ Exit:
EFI_STATUS
MciReceiveResponse (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_RESPONSE_TYPE Type,
IN UINT32* Buffer
)
@ -223,6 +225,7 @@ MciReceiveResponse (
EFI_STATUS
MciReadBlockData (
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
IN UINT32* Buffer
@ -298,6 +301,7 @@ MciReadBlockData (
EFI_STATUS
MciWriteBlockData (
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
IN UINT32* Buffer
@ -396,6 +400,7 @@ Exit:
EFI_STATUS
MciNotifyState (
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_STATE State
)
{
@ -490,6 +495,7 @@ EFI_GUID mPL180MciDevicePathGuid = EFI_CALLER_ID_GUID;
EFI_STATUS
MciBuildDevicePath (
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
@ -503,6 +509,7 @@ MciBuildDevicePath (
}
EFI_MMC_HOST_PROTOCOL gMciHost = {
MMC_HOST_PROTOCOL_REVISION,
MciIsCardPresent,
MciIsReadOnly,
MciBuildDevicePath,

View File

@ -78,23 +78,59 @@ typedef enum _MMC_STATE {
MmcDisconnectState,
} 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 {
UINT32 Revision;
MMC_ISCARDPRESENT IsCardPresent;
MMC_ISREADONLY IsReadOnly;
MMC_BUILDDEVICEPATH BuildDevicePath;
@ -106,8 +142,11 @@ typedef struct _EFI_MMC_HOST_PROTOCOL {
MMC_READBLOCKDATA ReadBlockData;
MMC_WRITEBLOCKDATA WriteBlockData;
} EFI_MMC_HOST_PROTOCOL;
#define MMC_HOST_PROTOCOL_REVISION 0x00010001 // 1.1
extern EFI_GUID gEfiMmcHostProtocolGuid;
#endif

View File

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

View File

@ -32,7 +32,7 @@ MmcNotifyState (
)
{
MmcHostInstance->State = State;
return MmcHostInstance->MmcHost->NotifyState(State);
return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
}
VOID
@ -169,14 +169,14 @@ MmcGetCardStatus(
if(MmcHostInstance->State != MmcHwInitializationState){
//Get the Status of the card.
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
return Status;
}
//Read Response
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
PrintResponseR1(Response[0]);
}
@ -214,7 +214,7 @@ MmcIdentificationMode (
}
} else {
//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)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
return Status;
@ -228,7 +228,7 @@ MmcIdentificationMode (
}
// Are we using SDIO ?
Status = MmcHost->SendCommand(MMC_CMD5, 0);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
if (Status == EFI_SUCCESS) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
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)
CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
Status = MmcHost->SendCommand(MMC_CMD8, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
if (Status == EFI_SUCCESS) {
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
IsHCS = TRUE;
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R7,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7,Response);
PrintResponseR1(Response[0]);
//check if it is valid response
if(Response[0] != CmdArg){
@ -255,7 +255,7 @@ MmcIdentificationMode (
Timeout = MAX_RETRY_COUNT;
while (Timeout > 0) {
// 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) {
DEBUG ((EFI_D_INFO, "Card should be SD\n"));
if (IsHCS) {
@ -269,18 +269,18 @@ MmcIdentificationMode (
if (IsHCS) {
CmdArg |= BIT30;
}
Status = MmcHost->SendCommand(MMC_ACMD41, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
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];
}
} else {
DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
MmcHostInstance->CardInfo.CardType = MMC_CARD;
Status = MmcHost->SendCommand(MMC_CMD1, 0x800000);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
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];
}
}
@ -315,12 +315,12 @@ MmcIdentificationMode (
return Status;
}
Status = MmcHost->SendCommand(MMC_CMD2, 0);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
return Status;
}
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CID,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID,Response);
PrintCID(Response);
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
@ -335,13 +335,13 @@ MmcIdentificationMode (
// The status returned for this CMD3 will be 2 - identification
//
CmdArg = 1;
Status = MmcHost->SendCommand(MMC_CMD3, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
return Status;
}
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_RCA,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA,Response);
PrintRCA(Response[0]);
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
@ -376,13 +376,13 @@ EFI_STATUS InitializeMmcDevice(
//Send a command to get Card specific data
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD9, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
return Status;
}
//Read Response
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CSD,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD,Response);
PrintCSD(Response);
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
@ -403,12 +403,12 @@ EFI_STATUS InitializeMmcDevice(
MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
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->MediaId++;
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand(MMC_CMD7, CmdArg);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
return Status;
@ -421,7 +421,7 @@ EFI_STATUS InitializeMmcDevice(
}
// 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)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status));
return Status;
@ -429,7 +429,7 @@ EFI_STATUS InitializeMmcDevice(
// Block Count (not used). Could return an error for SD card
if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
MmcHost->SendCommand(MMC_CMD23, BlockCount);
MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
}
return EFI_SUCCESS;
@ -452,7 +452,7 @@ MmcReset (
}
// 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->LastBlock = 0;
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
)
{
if (!MmcHost->IsCardPresent()) {
if (!MmcHost->IsCardPresent (MmcHost)) {
return EFI_NO_MEDIA;
} else {
return EFI_SUCCESS;
@ -544,9 +544,9 @@ MmcIoBlocks (
Response[0] = 0;
Timeout = 20;
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)) {
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)
#endif
}
Status = MmcHost->SendCommand(Cmd, CmdArg);
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status));
return Status;
@ -586,7 +586,7 @@ MmcIoBlocks (
if (Transfer == MMC_IOBLOCKS_READ) {
#ifndef USE_STREAM
// 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)) {
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status));
return Status;
@ -603,7 +603,7 @@ MmcIoBlocks (
} else {
#ifndef USE_STREAM
// 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)) {
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status));
return Status;
@ -615,9 +615,9 @@ MmcIoBlocks (
}
// Command 12 - Stop transmission (ends read)
Status = MmcHost->SendCommand(MMC_CMD12, 0);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
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)
@ -625,9 +625,9 @@ MmcIoBlocks (
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
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)) {
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response);
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
}
NanoSecondDelay(100);
Timeout--;

View File

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