mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/MmcDxe: Update Mmc code to conform to coding standard
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14524 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e7e50d6b19
commit
842b02d87f
|
@ -19,9 +19,6 @@
|
|||
|
||||
#include "Mmc.h"
|
||||
|
||||
// Untested ...
|
||||
//#define USE_STREAM
|
||||
|
||||
#define MAX_RETRY_COUNT 1000
|
||||
#define CMD_RETRY_COUNT 20
|
||||
|
||||
|
@ -374,8 +371,9 @@ EFI_STATUS InitializeMmcDevice (
|
|||
EFI_STATUS Status;
|
||||
UINTN CardSize, NumBlocks, BlockSize, CmdArg;
|
||||
EFI_MMC_HOST_PROTOCOL *MmcHost;
|
||||
UINTN BlockCount = 1;
|
||||
UINTN BlockCount;
|
||||
|
||||
BlockCount = 1;
|
||||
MmcHost = MmcHostInstance->MmcHost;
|
||||
|
||||
MmcIdentificationMode (MmcHostInstance);
|
||||
|
@ -384,7 +382,7 @@ EFI_STATUS InitializeMmcDevice (
|
|||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
|
||||
DEBUG((EFI_D_ERROR, "InitializeMmcDevice(MMC_CMD9): Error, Status=%r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
//Read Response
|
||||
|
@ -416,20 +414,21 @@ EFI_STATUS InitializeMmcDevice (
|
|||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
|
||||
DEBUG((EFI_D_ERROR, "InitializeMmcDevice(MMC_CMD7): Error and Status = %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcTransferState\n"));
|
||||
DEBUG((EFI_D_ERROR, "InitializeMmcDevice(): Error MmcTransferState\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Set Block Length
|
||||
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));
|
||||
DEBUG((EFI_D_ERROR, "InitializeMmcDevice(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
|
||||
MmcHostInstance->BlockIo.Media->BlockSize, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -508,10 +507,11 @@ MmcIoBlocks (
|
|||
MMC_HOST_INSTANCE *MmcHostInstance;
|
||||
EFI_MMC_HOST_PROTOCOL *MmcHost;
|
||||
UINTN BytesRemainingToBeTransfered;
|
||||
UINTN BlockCount = 1;
|
||||
UINTN BlockCount;
|
||||
|
||||
BlockCount = 1;
|
||||
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
|
||||
ASSERT (MmcHostInstance != 0);
|
||||
ASSERT (MmcHostInstance != NULL);
|
||||
MmcHost = MmcHostInstance->MmcHost;
|
||||
ASSERT (MmcHost);
|
||||
|
||||
|
@ -519,7 +519,7 @@ MmcIoBlocks (
|
|||
return EFI_MEDIA_CHANGED;
|
||||
}
|
||||
|
||||
if ((MmcHost == 0)|| (Buffer == NULL)) {
|
||||
if ((MmcHost == NULL) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -581,19 +581,11 @@ MmcIoBlocks (
|
|||
}
|
||||
|
||||
if (Transfer == MMC_IOBLOCKS_READ) {
|
||||
#ifndef USE_STREAM
|
||||
// Read a single block
|
||||
Cmd = MMC_CMD17;
|
||||
#else
|
||||
//TODO: Should we support read stream (MMC_CMD11)
|
||||
#endif
|
||||
} else {
|
||||
#ifndef USE_STREAM
|
||||
// Write a single block
|
||||
Cmd = MMC_CMD24;
|
||||
#else
|
||||
//TODO: Should we support write stream (MMC_CMD20)
|
||||
#endif
|
||||
}
|
||||
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@ -602,34 +594,24 @@ MmcIoBlocks (
|
|||
}
|
||||
|
||||
if (Transfer == MMC_IOBLOCKS_READ) {
|
||||
#ifndef USE_STREAM
|
||||
// Read one block of Data
|
||||
Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
#else
|
||||
//TODO: Read a stream
|
||||
ASSERT (0);
|
||||
#endif
|
||||
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
#ifndef USE_STREAM
|
||||
// Write one block of Data
|
||||
Status = MmcHost->WriteBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
#else
|
||||
//TODO: Write a stream
|
||||
ASSERT (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Command 12 - Stop transmission (ends read)
|
||||
|
|
Loading…
Reference in New Issue