EmbeddedPkg/MmcDxe: Fix coding style

Make the coding style more compliant with the EDK2 coding convention.



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11727 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-06-03 09:10:26 +00:00
parent b9d5fe03e6
commit e8e95df41d
2 changed files with 693 additions and 661 deletions

View File

@ -27,14 +27,19 @@
EFI_STATUS EFI_STATUS
MmcNotifyState ( MmcNotifyState (
MMC_HOST_INSTANCE *MmcHostInstance, IN MMC_HOST_INSTANCE *MmcHostInstance,
MMC_STATE State IN MMC_STATE State
) { )
{
MmcHostInstance->State = State; MmcHostInstance->State = State;
return MmcHostInstance->MmcHost->NotifyState(State); return MmcHostInstance->MmcHost->NotifyState(State);
} }
VOID PrintOCR(UINT32 ocr) { VOID
PrintOCR (
IN UINT32 Ocr
)
{
UINTN minv, maxv, volts; UINTN minv, maxv, volts;
UINTN loop; UINTN loop;
@ -44,95 +49,115 @@ VOID PrintOCR(UINT32 ocr) {
// The MMC register bits [23:8] indicate the working range of the card // The MMC register bits [23:8] indicate the working range of the card
for (loop = 8; loop < 24; loop++) { for (loop = 8; loop < 24; loop++) {
if (ocr & (1 << loop)) { if (Ocr & (1 << loop)) {
if (minv > volts) minv = volts; if (minv > volts) minv = volts;
if (maxv < volts) maxv = volts + 1; if (maxv < volts) maxv = volts + 1;
} }
volts = volts + 1; volts = volts + 1;
} }
DEBUG((EFI_D_ERROR, "- PrintOCR ocr (0x%X)\n",ocr)); DEBUG((EFI_D_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));
DEBUG((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", minv/10, minv % 10, maxv/10, maxv % 10)); DEBUG((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", minv/10, minv % 10, maxv/10, maxv % 10));
if (((ocr >> 29) & 3) == 0) if (((Ocr >> 29) & 3) == 0) {
DEBUG((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n")); DEBUG((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
else } else {
DEBUG((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n",((ocr >> 29) & 3))); DEBUG((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n",((Ocr >> 29) & 3)));
}
if (ocr & MMC_OCR_POWERUP) if (Ocr & MMC_OCR_POWERUP) {
DEBUG((EFI_D_ERROR, "\t- PowerUp\n")); DEBUG((EFI_D_ERROR, "\t- PowerUp\n"));
else } else {
DEBUG((EFI_D_ERROR, "\t- Voltage Not Supported\n")); DEBUG((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
} }
VOID PrintCID(UINT32* cid) {
DEBUG((EFI_D_ERROR, "- PrintCID\n"));
DEBUG((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n",(cid[0] >> 8) & 0xF,(cid[0] >> 12) & 0xFF));
DEBUG((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n",cid[1] & 0xFFFFFF,(cid[0] >> 24) & 0xFF));
DEBUG((EFI_D_ERROR, "\t- Product revision: %d\n",cid[1] >> 24));
//DEBUG((EFI_D_ERROR, "\t- Product name: %s\n",(char*)(cid + 2)));
DEBUG((EFI_D_ERROR, "\t- OEM ID: %c%c\n",(cid[3] >> 8) & 0xFF,(cid[3] >> 16) & 0xFF));
} }
VOID PrintCSD(UINT32* csd) { VOID PrintCID (
UINTN val32; IN UINT32* Cid
)
{
DEBUG((EFI_D_ERROR, "- PrintCID\n"));
DEBUG((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n",(Cid[0] >> 8) & 0xF,(Cid[0] >> 12) & 0xFF));
DEBUG((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n",Cid[1] & 0xFFFFFF,(Cid[0] >> 24) & 0xFF));
DEBUG((EFI_D_ERROR, "\t- Product revision: %d\n",Cid[1] >> 24));
//DEBUG((EFI_D_ERROR, "\t- Product name: %s\n",(char*)(Cid + 2)));
DEBUG((EFI_D_ERROR, "\t- OEM ID: %c%c\n",(Cid[3] >> 8) & 0xFF,(Cid[3] >> 16) & 0xFF));
}
VOID
PrintCSD (
IN UINT32* Csd
)
{
UINTN Value;
CONST CHAR8* str_unit[] = { "100kbit/s","1Mbit/s","10Mbit/s","100MBit/s","Unkbown","Unkbown","Unkbown","Unkbown" }; CONST CHAR8* str_unit[] = { "100kbit/s","1Mbit/s","10Mbit/s","100MBit/s","Unkbown","Unkbown","Unkbown","Unkbown" };
CONST CHAR8* str_value[] = { "1.0","1.2","1.3","1.5","2.0","2.5","3.0","3.5","4.0","4.5","5.0","Unknown","Unknown","Unknown","Unknown" }; CONST CHAR8* str_value[] = { "1.0","1.2","1.3","1.5","2.0","2.5","3.0","3.5","4.0","4.5","5.0","Unknown","Unknown","Unknown","Unknown" };
if (((csd[2] >> 30) & 0x3) == 0) if (((Csd[2] >> 30) & 0x3) == 0) {
DEBUG((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n")); DEBUG((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
else if (((csd[2] >> 30) & 0x3) == 1) } else if (((Csd[2] >> 30) & 0x3) == 1) {
DEBUG((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n")); DEBUG((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
else } else {
DEBUG((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n")); DEBUG((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n"));
}
DEBUG((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n",MMC_CSD_GET_CCC(csd))); DEBUG((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n",MMC_CSD_GET_CCC(Csd)));
DEBUG((EFI_D_ERROR, "\t- Speed: %a %a\n",str_value[(MMC_CSD_GET_TRANSPEED(csd) >> 3) & 0xF],str_unit[MMC_CSD_GET_TRANSPEED(csd) & 7])); DEBUG((EFI_D_ERROR, "\t- Speed: %a %a\n",str_value[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],str_unit[MMC_CSD_GET_TRANSPEED(Csd) & 7]));
DEBUG((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN(csd)-1))); DEBUG((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN(Csd)-1)));
DEBUG((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(csd)-1))); DEBUG((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(Csd)-1)));
if (!MMC_CSD_GET_FILEFORMATGRP(csd)) { if (!MMC_CSD_GET_FILEFORMATGRP(Csd)) {
val32 = MMC_CSD_GET_FILEFORMAT(csd); Value = MMC_CSD_GET_FILEFORMAT(Csd);
if (val32 == 0) DEBUG((EFI_D_ERROR, "\t- Format(0): Hard disk-like file system with partition table\n")); if (Value == 0) DEBUG((EFI_D_ERROR, "\t- Format(0): Hard disk-like file system with partition table\n"));
else if (val32 == 1) DEBUG((EFI_D_ERROR, "\t- Format(1): DOS FAT (floppy-like) with boot sector only (no partition table)\n")); else if (Value == 1) DEBUG((EFI_D_ERROR, "\t- Format(1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));
else if (val32 == 2) DEBUG((EFI_D_ERROR, "\t- Format(2): Universal File Format\n")); else if (Value == 2) DEBUG((EFI_D_ERROR, "\t- Format(2): Universal File Format\n"));
else DEBUG((EFI_D_ERROR, "\t- Format(3): Others/Unknown\n")); else DEBUG((EFI_D_ERROR, "\t- Format(3): Others/Unknown\n"));
} else { } else {
DEBUG((EFI_D_ERROR, "\t- Format: Reserved\n")); DEBUG((EFI_D_ERROR, "\t- Format: Reserved\n"));
} }
} }
VOID PrintRCA(UINT32 rca) { VOID
DEBUG((EFI_D_ERROR, "- PrintRCA: 0x%X\n",rca)); PrintRCA (
DEBUG((EFI_D_ERROR, "\t- Status: 0x%X\n",rca & 0xFFFF)); IN UINT32 Rca
DEBUG((EFI_D_ERROR, "\t- RCA: 0x%X\n",(rca >> 16) & 0xFFFF)); )
{
DEBUG((EFI_D_ERROR, "- PrintRCA: 0x%X\n",Rca));
DEBUG((EFI_D_ERROR, "\t- Status: 0x%X\n",Rca & 0xFFFF));
DEBUG((EFI_D_ERROR, "\t- RCA: 0x%X\n",(Rca >> 16) & 0xFFFF));
} }
VOID PrintResponseR1(UINT32 response) { VOID
DEBUG((EFI_D_INFO, "Response: 0x%X\n",response)); PrintResponseR1 (
if (response & (1 << 8)) DEBUG((EFI_D_INFO, "\t- READY_FOR_DATA\n")); IN UINT32 Response
)
{
DEBUG((EFI_D_INFO, "Response: 0x%X\n",Response));
if (Response & (1 << 8)) DEBUG((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
if (((response >> 9) & 0xF) == 0) DEBUG((EFI_D_INFO, "\t- State: Idle\n")); if (((Response >> 9) & 0xF) == 0) DEBUG((EFI_D_INFO, "\t- State: Idle\n"));
else if (((response >> 9) & 0xF) == 1) DEBUG((EFI_D_INFO, "\t- State: Ready\n")); else if (((Response >> 9) & 0xF) == 1) DEBUG((EFI_D_INFO, "\t- State: Ready\n"));
else if (((response >> 9) & 0xF) == 2) DEBUG((EFI_D_INFO, "\t- State: Ident\n")); else if (((Response >> 9) & 0xF) == 2) DEBUG((EFI_D_INFO, "\t- State: Ident\n"));
else if (((response >> 9) & 0xF) == 3) DEBUG((EFI_D_INFO, "\t- State: StandBy\n")); else if (((Response >> 9) & 0xF) == 3) DEBUG((EFI_D_INFO, "\t- State: StandBy\n"));
else if (((response >> 9) & 0xF) == 4) DEBUG((EFI_D_INFO, "\t- State: Tran\n")); else if (((Response >> 9) & 0xF) == 4) DEBUG((EFI_D_INFO, "\t- State: Tran\n"));
else if (((response >> 9) & 0xF) == 5) DEBUG((EFI_D_INFO, "\t- State: Data\n")); else if (((Response >> 9) & 0xF) == 5) DEBUG((EFI_D_INFO, "\t- State: Data\n"));
else if (((response >> 9) & 0xF) == 6) DEBUG((EFI_D_INFO, "\t- State: Rcv\n")); else if (((Response >> 9) & 0xF) == 6) DEBUG((EFI_D_INFO, "\t- State: Rcv\n"));
else if (((response >> 9) & 0xF) == 7) DEBUG((EFI_D_INFO, "\t- State: Prg\n")); else if (((Response >> 9) & 0xF) == 7) DEBUG((EFI_D_INFO, "\t- State: Prg\n"));
else if (((response >> 9) & 0xF) == 8) DEBUG((EFI_D_INFO, "\t- State: Dis\n")); else if (((Response >> 9) & 0xF) == 8) DEBUG((EFI_D_INFO, "\t- State: Dis\n"));
else DEBUG((EFI_D_INFO, "\t- State: Reserved\n")); else DEBUG((EFI_D_INFO, "\t- State: Reserved\n"));
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
MmcGetCardStatus( MmcGetCardStatus(
MMC_HOST_INSTANCE *MmcHostInstance IN MMC_HOST_INSTANCE *MmcHostInstance
){ )
EFI_STATUS Status=EFI_SUCCESS; {
EFI_STATUS Status;
UINT32 Response[4]; UINT32 Response[4];
UINTN CmdArg; UINTN CmdArg;
EFI_MMC_HOST_PROTOCOL *MmcHost; EFI_MMC_HOST_PROTOCOL *MmcHost;
Status = EFI_SUCCESS;
MmcHost = MmcHostInstance->MmcHost; MmcHost = MmcHostInstance->MmcHost;
CmdArg = 0; CmdArg = 0;
@ -160,19 +185,20 @@ MmcGetCardStatus(
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
MmcIdentificationMode ( MmcIdentificationMode (
MMC_HOST_INSTANCE *MmcHostInstance IN MMC_HOST_INSTANCE *MmcHostInstance
) { )
{
EFI_STATUS Status; EFI_STATUS Status;
UINT32 Response[4]; UINT32 Response[4];
UINTN Timeout; UINTN Timeout;
UINTN CmdArg; UINTN CmdArg;
BOOLEAN bHCS; BOOLEAN IsHCS;
EFI_MMC_HOST_PROTOCOL *MmcHost; EFI_MMC_HOST_PROTOCOL *MmcHost;
UINTN CmdRetryCnt; UINTN CmdRetryCnt;
MmcHost = MmcHostInstance->MmcHost; MmcHost = MmcHostInstance->MmcHost;
CmdArg = 0; CmdArg = 0;
bHCS = FALSE; IsHCS = FALSE;
if (MmcHost == NULL) { if (MmcHost == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -213,7 +239,7 @@ MmcIdentificationMode (
Status = MmcHost->SendCommand(MMC_CMD8, CmdArg); Status = MmcHost->SendCommand(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"));
bHCS = TRUE; IsHCS = TRUE;
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R7,Response); MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R7,Response);
PrintResponseR1(Response[0]); PrintResponseR1(Response[0]);
//check if it is valid response //check if it is valid response
@ -232,7 +258,7 @@ MmcIdentificationMode (
Status = MmcHost->SendCommand(MMC_CMD55, 0); Status = MmcHost->SendCommand(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 (bHCS) { if (IsHCS) {
MmcHostInstance->CardInfo.CardType = SD_CARD_2; MmcHostInstance->CardInfo.CardType = SD_CARD_2;
} else { } else {
MmcHostInstance->CardInfo.CardType = SD_CARD; MmcHostInstance->CardInfo.CardType = SD_CARD;
@ -240,7 +266,7 @@ MmcIdentificationMode (
// Note: The first time CmdArg will be zero // Note: The first time CmdArg will be zero
CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0]; CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0];
if (bHCS) { if (IsHCS) {
CmdArg |= BIT30; CmdArg |= BIT30;
} }
Status = MmcHost->SendCommand(MMC_ACMD41, CmdArg); Status = MmcHost->SendCommand(MMC_ACMD41, CmdArg);
@ -339,7 +365,8 @@ EFIAPI
MmcReset ( MmcReset (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
) { )
{
// Implement me. Either send a CMD0 (could not work for some MMC host) or just turn off/turn // Implement me. Either send a CMD0 (could not work for some MMC host) or just turn off/turn
// on power and restart Identification mode // on power and restart Identification mode
return EFI_SUCCESS; return EFI_SUCCESS;
@ -360,14 +387,16 @@ MmcDetectCard (
#define MMCI0_BLOCKLEN 512 #define MMCI0_BLOCKLEN 512
#define MMCI0_TIMEOUT 10000 #define MMCI0_TIMEOUT 10000
EFI_STATUS MmcIoBlocks ( EFI_STATUS
MmcIoBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINTN Transfer, IN UINTN Transfer,
IN UINT32 MediaId, IN UINT32 MediaId,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) { )
{
UINT32 Response[4]; UINT32 Response[4];
EFI_STATUS Status; EFI_STATUS Status;
UINTN CardSize, NumBlocks, BlockSize, CmdArg; UINTN CardSize, NumBlocks, BlockSize, CmdArg;
@ -598,7 +627,8 @@ MmcReadBlocks (
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
OUT VOID *Buffer OUT VOID *Buffer
) { )
{
return MmcIoBlocks (This, MMC_IOBLOCKS_READ, MediaId, Lba, BufferSize, Buffer); return MmcIoBlocks (This, MMC_IOBLOCKS_READ, MediaId, Lba, BufferSize, Buffer);
} }
@ -610,7 +640,8 @@ MmcWriteBlocks (
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN BufferSize, IN UINTN BufferSize,
IN VOID *Buffer IN VOID *Buffer
) { )
{
return MmcIoBlocks (This, MMC_IOBLOCKS_WRITE, MediaId, Lba, BufferSize, Buffer); return MmcIoBlocks (This, MMC_IOBLOCKS_WRITE, MediaId, Lba, BufferSize, Buffer);
} }
@ -618,7 +649,8 @@ EFI_STATUS
EFIAPI EFIAPI
MmcFlushBlocks ( MmcFlushBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This IN EFI_BLOCK_IO_PROTOCOL *This
) { )
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }