summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Universal
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 22:53:54 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 22:53:54 +0000
commit11c20f4e06d252feaa65aa5e526686baf015762d (patch)
tree21e5fd65e293cf086cec4ccc73075d585a2ebd50 /EmbeddedPkg/Universal
parent5439ccda50acf4f6e2c1cbd256a30ba555da3eda (diff)
downloadedk2-11c20f4e06d252feaa65aa5e526686baf015762d.tar.gz
edk2-11c20f4e06d252feaa65aa5e526686baf015762d.tar.bz2
edk2-11c20f4e06d252feaa65aa5e526686baf015762d.zip
Arm Packages: Fixed coding style/Line endings to follow EDK2 coding convention
Arm Packages: Fixed mispelling Arm Packages: Reduced warnings all over the code git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12407 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg/Universal')
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Diagnostics.c323
1 files changed, 174 insertions, 149 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
index a477135684..516c832bb5 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
+++ b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
@@ -25,121 +25,146 @@
CHAR16* mLogBuffer = NULL;
UINTN mLogRemainChar = 0;
-CHAR16* DiagnosticInitLog(UINTN MaxBufferChar) {
- mLogRemainChar = MaxBufferChar;
- mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof(CHAR16));
- return mLogBuffer;
+CHAR16*
+DiagnosticInitLog (
+ UINTN MaxBufferChar
+ )
+{
+ mLogRemainChar = MaxBufferChar;
+ mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof(CHAR16));
+ return mLogBuffer;
}
-UINTN DiagnosticLog(CONST CHAR16* Str) {
- UINTN len = StrLen (Str);
- if (len <= mLogRemainChar) {
- mLogRemainChar -= len;
- StrCpy (mLogBuffer, Str);
- mLogBuffer += len;
- return len;
- } else {
- return 0;
- }
+UINTN
+DiagnosticLog (
+ CONST CHAR16* Str
+ )
+{
+ UINTN len = StrLen (Str);
+ if (len <= mLogRemainChar) {
+ mLogRemainChar -= len;
+ StrCpy (mLogBuffer, Str);
+ mLogBuffer += len;
+ return len;
+ } else {
+ return 0;
+ }
}
-VOID GenerateRandomBuffer(VOID* Buffer, UINTN BufferSize) {
- UINT64 i;
- UINT64* Buffer64 = (UINT64*)Buffer;
+VOID
+GenerateRandomBuffer (
+ VOID* Buffer,
+ UINTN BufferSize
+ )
+{
+ UINT64 i;
+ UINT64* Buffer64 = (UINT64*)Buffer;
- for (i = 0; i < (BufferSize >> 3); i++) {
- *Buffer64 = i | (~i << 32);
- Buffer64++;
- }
+ for (i = 0; i < (BufferSize >> 3); i++) {
+ *Buffer64 = i | (~i << 32);
+ Buffer64++;
+ }
}
-BOOLEAN CompareBuffer(VOID *BufferA, VOID *BufferB, UINTN BufferSize) {
- UINTN i;
- UINT64* BufferA64 = (UINT64*)BufferA;
- UINT64* BufferB64 = (UINT64*)BufferB;
-
- for (i = 0; i < (BufferSize >> 3); i++) {
- if (*BufferA64 != *BufferB64) {
- DEBUG((EFI_D_ERROR, "CompareBuffer: Error at %i", i));
- DEBUG((EFI_D_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
- return FALSE;
- }
- BufferA64++;
- BufferB64++;
+BOOLEAN
+CompareBuffer (
+ VOID *BufferA,
+ VOID *BufferB,
+ UINTN BufferSize
+ )
+{
+ UINTN i;
+ UINT64* BufferA64 = (UINT64*)BufferA;
+ UINT64* BufferB64 = (UINT64*)BufferB;
+
+ for (i = 0; i < (BufferSize >> 3); i++) {
+ if (*BufferA64 != *BufferB64) {
+ DEBUG((EFI_D_ERROR, "CompareBuffer: Error at %i", i));
+ DEBUG((EFI_D_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
+ return FALSE;
}
- return TRUE;
+ BufferA64++;
+ BufferB64++;
+ }
+ return TRUE;
}
-EFI_STATUS MmcReadWriteDataTest(MMC_HOST_INSTANCE *MmcHostInstance, EFI_LBA Lba, UINTN BufferSize) {
- VOID *BackBuffer;
- VOID *WriteBuffer;
- VOID *ReadBuffer;
- EFI_STATUS Status;
-
- // Check if a Media is Present
- if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
- DiagnosticLog(L"ERROR: No Media Present\n");
- return EFI_NO_MEDIA;
- }
-
- if (MmcHostInstance->State != MmcTransferState) {
- DiagnosticLog(L"ERROR: Not ready for Transfer state\n");
- return EFI_NOT_READY;
- }
-
- BackBuffer = AllocatePool(BufferSize);
- WriteBuffer = AllocatePool(BufferSize);
- ReadBuffer = AllocatePool(BufferSize);
-
- // Read (and save) buffer at a specific location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog(L"ERROR: Fail to Read Block (1)\n");
- return Status;
- }
-
- // Write buffer at the same location
- GenerateRandomBuffer(WriteBuffer,BufferSize);
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,WriteBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog(L"ERROR: Fail to Write Block (1)\n");
- return Status;
- }
-
- // Read the buffer at the same location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog(L"ERROR: Fail to Read Block (2)\n");
- return Status;
- }
+EFI_STATUS
+MmcReadWriteDataTest (
+ MMC_HOST_INSTANCE *MmcHostInstance,
+ EFI_LBA Lba,
+ UINTN BufferSize
+ )
+{
+ VOID *BackBuffer;
+ VOID *WriteBuffer;
+ VOID *ReadBuffer;
+ EFI_STATUS Status;
+
+ // Check if a Media is Present
+ if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
+ DiagnosticLog (L"ERROR: No Media Present\n");
+ return EFI_NO_MEDIA;
+ }
+
+ if (MmcHostInstance->State != MmcTransferState) {
+ DiagnosticLog (L"ERROR: Not ready for Transfer state\n");
+ return EFI_NOT_READY;
+ }
+
+ BackBuffer = AllocatePool (BufferSize);
+ WriteBuffer = AllocatePool (BufferSize);
+ ReadBuffer = AllocatePool (BufferSize);
+
+ // Read (and save) buffer at a specific location
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
+ if (Status != EFI_SUCCESS) {
+ DiagnosticLog (L"ERROR: Fail to Read Block (1)\n");
+ return Status;
+ }
- // Check that is conform
- if (!CompareBuffer(ReadBuffer,WriteBuffer,BufferSize)) {
- DiagnosticLog(L"ERROR: Fail to Read/Write Block (1)\n");
- return EFI_INVALID_PARAMETER;
- }
+ // Write buffer at the same location
+ GenerateRandomBuffer (WriteBuffer,BufferSize);
+ Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,WriteBuffer);
+ if (Status != EFI_SUCCESS) {
+ DiagnosticLog (L"ERROR: Fail to Write Block (1)\n");
+ return Status;
+ }
- // Restore content at the original location
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog(L"ERROR: Fail to Write Block (2)\n");
- return Status;
- }
+ // Read the buffer at the same location
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
+ if (Status != EFI_SUCCESS) {
+ DiagnosticLog (L"ERROR: Fail to Read Block (2)\n");
+ return Status;
+ }
+
+ // Check that is conform
+ if (!CompareBuffer (ReadBuffer,WriteBuffer,BufferSize)) {
+ DiagnosticLog (L"ERROR: Fail to Read/Write Block (1)\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Restore content at the original location
+ Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
+ if (Status != EFI_SUCCESS) {
+ DiagnosticLog (L"ERROR: Fail to Write Block (2)\n");
+ return Status;
+ }
- // Read the restored content
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog(L"ERROR: Fail to Read Block (3)\n");
- return Status;
- }
+ // Read the restored content
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
+ if (Status != EFI_SUCCESS) {
+ DiagnosticLog (L"ERROR: Fail to Read Block (3)\n");
+ return Status;
+ }
- // Check the content is correct
- if (!CompareBuffer(ReadBuffer,BackBuffer,BufferSize)) {
- DiagnosticLog(L"ERROR: Fail to Read/Write Block (2)\n");
- return EFI_INVALID_PARAMETER;
- }
+ // Check the content is correct
+ if (!CompareBuffer (ReadBuffer,BackBuffer,BufferSize)) {
+ DiagnosticLog (L"ERROR: Fail to Read/Write Block (2)\n");
+ return EFI_INVALID_PARAMETER;
+ }
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
EFI_STATUS
@@ -155,55 +180,55 @@ MmcDriverDiagnosticsRunDiagnostics (
OUT CHAR16 **Buffer
)
{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
-
- if (Language == NULL ||
- ErrorType == NULL ||
- Buffer == NULL ||
- ControllerHandle == NULL ||
- BufferSize == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_SUCCESS;
- *ErrorType = NULL;
- *BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
- *Buffer = DiagnosticInitLog(DIAGNOSTIC_LOGBUFFER_MAXCHAR);
-
- DiagnosticLog(L"MMC Driver Diagnostics\n");
-
- // For each MMC instance
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
-
- // LBA=1 Size=BlockSize
- DiagnosticLog(L"MMC Driver Diagnostics - Test: First Block\n");
- Status = MmcReadWriteDataTest(MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=2 Size=BlockSize
- DiagnosticLog(L"MMC Driver Diagnostics - Test: Second Block\n");
- Status = MmcReadWriteDataTest(MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=10 Size=BlockSize
- DiagnosticLog(L"MMC Driver Diagnostics - Test: Any Block\n");
- Status = MmcReadWriteDataTest(MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=LastBlock Size=BlockSize
- DiagnosticLog(L"MMC Driver Diagnostics - Test: Last Block\n");
- Status = MmcReadWriteDataTest(MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=1 Size=2*BlockSize
- DiagnosticLog(L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");
- Status = MmcReadWriteDataTest(MmcHostInstance, 1, 2*MmcHostInstance->BlockIo.Media->BlockSize);
-
- CurrentLink = CurrentLink->ForwardLink;
- }
-
- return Status;
+ LIST_ENTRY *CurrentLink;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_STATUS Status;
+
+ if ((Language == NULL) ||
+ (ErrorType == NULL) ||
+ (Buffer == NULL) ||
+ (ControllerHandle == NULL) ||
+ (BufferSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_SUCCESS;
+ *ErrorType = NULL;
+ *BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
+ *Buffer = DiagnosticInitLog (DIAGNOSTIC_LOGBUFFER_MAXCHAR);
+
+ DiagnosticLog (L"MMC Driver Diagnostics\n");
+
+ // For each MMC instance
+ CurrentLink = mMmcHostPool.ForwardLink;
+ while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
+ ASSERT(MmcHostInstance != NULL);
+
+ // LBA=1 Size=BlockSize
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
+ Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);
+
+ // LBA=2 Size=BlockSize
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n");
+ Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);
+
+ // LBA=10 Size=BlockSize
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");
+ Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize);
+
+ // LBA=LastBlock Size=BlockSize
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
+ Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize);
+
+ // LBA=1 Size=2*BlockSize
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");
+ Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2*MmcHostInstance->BlockIo.Media->BlockSize);
+
+ CurrentLink = CurrentLink->ForwardLink;
+ }
+
+ return Status;
}
//