summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Universal
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2013-08-30 11:51:51 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-08-30 11:51:51 +0000
commit4ca3c688a4f9042a954e5303f017893de7214d09 (patch)
tree942928ff48eeaadae6e4e9b4a39fbf4168ad7bae /EmbeddedPkg/Universal
parent55b0a24ad29eb027eefe1ddd4c9aa466fded0b93 (diff)
downloadedk2-4ca3c688a4f9042a954e5303f017893de7214d09.tar.gz
edk2-4ca3c688a4f9042a954e5303f017893de7214d09.tar.bz2
edk2-4ca3c688a4f9042a954e5303f017893de7214d09.zip
EmbeddedPkg/MmcDxe: Moved all the 'Print*()' functions to MmcDebug.c
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@14612 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg/Universal')
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.c4
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.h28
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c124
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcDebug.c168
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf3
5 files changed, 199 insertions, 128 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.c b/EmbeddedPkg/Universal/MmcDxe/Mmc.c
index b4f7a78a55..9327bd6337 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.c
+++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.c
@@ -1,7 +1,7 @@
/** @file
Main file of the MMC Dxe driver. The driver entrypoint is defined into this file.
- Copyright (c) 2011, ARM Limited. All rights reserved.
+ Copyright (c) 2011-2013, ARM Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -14,14 +14,12 @@
**/
#include <Protocol/DevicePath.h>
-#include <Protocol/MmcHost.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
-#include <Library/DebugLib.h>
#include "Mmc.h"
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
index 0c51428e9e..9104f60ae0 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
+++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
@@ -1,7 +1,7 @@
/** @file
Main Header file for the MMC DXE driver
- Copyright (c) 2011, ARM Limited. All rights reserved.
+ Copyright (c) 2011-2013, ARM Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -24,6 +24,7 @@
#include <Protocol/MmcHost.h>
#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
#define MMC_TRACE(txt) DEBUG((EFI_D_BLKIO, "MMC: " txt "\n"))
@@ -299,4 +300,29 @@ CheckCardsCallback (
IN VOID *Context
);
+VOID
+PrintCSD (
+ IN UINT32* Csd
+ );
+
+VOID
+PrintRCA (
+ IN UINT32 Rca
+ );
+
+VOID
+PrintOCR (
+ IN UINT32 Ocr
+ );
+
+VOID
+PrintResponseR1 (
+ IN UINT32 Response
+ );
+
+VOID
+PrintCID (
+ IN UINT32* Cid
+ );
+
#endif
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index 82ec5a7a2d..4b9b64e46f 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -12,8 +12,6 @@
*
**/
-#include <Protocol/MmcHost.h>
-#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
@@ -32,130 +30,10 @@ MmcNotifyState (
return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
}
-VOID
-PrintOCR (
- IN UINT32 Ocr
- )
-{
- UINTN MinV;
- UINTN MaxV;
- UINTN Volts;
- UINTN Loop;
-
- MinV = 36; // 3.6
- MaxV = 20; // 2.0
- Volts = 20; // 2.0
-
- // The MMC register bits [23:8] indicate the working range of the card
- for (Loop = 8; Loop < 24; Loop++) {
- if (Ocr & (1 << Loop)) {
- if (MinV > Volts) MinV = Volts;
- if (MaxV < Volts) MaxV = Volts + 1;
- }
- Volts = Volts + 1;
- }
-
- 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));
- if (((Ocr >> 29) & 3) == 0) {
- DEBUG ((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));
- }
-
- if (Ocr & MMC_OCR_POWERUP) {
- DEBUG ((EFI_D_ERROR, "\t- PowerUp\n"));
- } else {
- DEBUG ((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
- }
-}
-
-VOID PrintCID (
- 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));
-}
-
-#if !defined(MDEPKG_NDEBUG)
-CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
- "Unknown", "Unknown", "Unknown", "Unknown" };
-CONST CHAR8* mStrValue[] = { "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" };
-#endif
-
-VOID
-PrintCSD (
- IN UINT32* Csd
- )
-{
- UINTN Value;
-
- if (((Csd[2] >> 30) & 0x3) == 0) {
- DEBUG ((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
- } else if (((Csd[2] >> 30) & 0x3) == 1) {
- DEBUG ((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
- } else {
- 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- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],mStrUnit[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 Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(Csd)-1)));
-
- if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {
- Value = MMC_CSD_GET_FILEFORMAT (Csd);
- if (Value == 0) DEBUG ((EFI_D_ERROR, "\t- Format (0): Hard disk-like file system with 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 (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: Reserved\n"));
- }
-}
-
-VOID
-PrintRCA (
- IN UINT32 Rca
- )
-{
- 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 (
- IN UINT32 Response
- )
-{
- DEBUG ((EFI_D_INFO, "Response: 0x%X\n", Response));
- if (Response & MMC_R0_READY_FOR_DATA) {
- DEBUG ((EFI_D_INFO, "\t- READY_FOR_DATA\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) == 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) == 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) == 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) == 8) DEBUG ((EFI_D_INFO, "\t- State: Dis\n"));
- else DEBUG ((EFI_D_INFO, "\t- State: Reserved\n"));
-}
-
EFI_STATUS
EFIAPI
MmcGetCardStatus (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
EFI_STATUS Status;
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c b/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
new file mode 100644
index 0000000000..a5d3b63124
--- /dev/null
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
@@ -0,0 +1,168 @@
+/** @file
+*
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include "Mmc.h"
+
+#if !defined(MDEPKG_NDEBUG)
+CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
+ "Unknown", "Unknown", "Unknown", "Unknown" };
+CONST CHAR8* mStrValue[] = { "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" };
+#endif
+
+VOID
+PrintCID (
+ 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;
+
+ if (((Csd[2] >> 30) & 0x3) == 0) {
+ DEBUG ((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
+ } else if (((Csd[2] >> 30) & 0x3) == 1) {
+ DEBUG ((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
+ } else {
+ 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- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF],mStrUnit[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 Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN (Csd)-1)));
+
+ if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {
+ Value = MMC_CSD_GET_FILEFORMAT (Csd);
+ if (Value == 0) {
+ DEBUG ((EFI_D_ERROR, "\t- Format (0): Hard disk-like file system with 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 (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: Reserved\n"));
+ }
+}
+
+VOID
+PrintRCA (
+ IN UINT32 Rca
+ )
+{
+ 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
+PrintOCR (
+ IN UINT32 Ocr
+ )
+{
+ UINTN MinV;
+ UINTN MaxV;
+ UINTN Volts;
+ UINTN Loop;
+
+ MinV = 36; // 3.6
+ MaxV = 20; // 2.0
+ Volts = 20; // 2.0
+
+ // The MMC register bits [23:8] indicate the working range of the card
+ for (Loop = 8; Loop < 24; Loop++) {
+ if (Ocr & (1 << Loop)) {
+ if (MinV > Volts) {
+ MinV = Volts;
+ }
+ if (MaxV < Volts) {
+ MaxV = Volts + 1;
+ }
+ }
+ Volts++;
+ }
+
+ 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));
+ if (((Ocr >> 29) & 3) == 0) {
+ DEBUG ((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
+ } else {
+ DEBUG ((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));
+ }
+
+ if (Ocr & MMC_OCR_POWERUP) {
+ DEBUG ((EFI_D_ERROR, "\t- PowerUp\n"));
+ } else {
+ DEBUG ((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
+ }
+}
+
+VOID
+PrintResponseR1 (
+ IN UINT32 Response
+ )
+{
+ DEBUG ((EFI_D_INFO, "Response: 0x%X\n", Response));
+ if (Response & MMC_R0_READY_FOR_DATA) {
+ DEBUG ((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
+ }
+
+ switch ((Response >> 9) & 0xF) {
+ case 0:
+ DEBUG ((EFI_D_INFO, "\t- State: Idle\n"));
+ break;
+ case 1:
+ DEBUG ((EFI_D_INFO, "\t- State: Ready\n"));
+ break;
+ case 2:
+ DEBUG ((EFI_D_INFO, "\t- State: Ident\n"));
+ break;
+ case 3:
+ DEBUG ((EFI_D_INFO, "\t- State: StandBy\n"));
+ break;
+ case 4:
+ DEBUG ((EFI_D_INFO, "\t- State: Tran\n"));
+ break;
+ case 5:
+ DEBUG ((EFI_D_INFO, "\t- State: Data\n"));
+ break;
+ case 6:
+ DEBUG ((EFI_D_INFO, "\t- State: Rcv\n"));
+ break;
+ case 7:
+ DEBUG ((EFI_D_INFO, "\t- State: Prg\n"));
+ break;
+ case 8:
+ DEBUG ((EFI_D_INFO, "\t- State: Dis\n"));
+ break;
+ default:
+ DEBUG ((EFI_D_INFO, "\t- State: Reserved\n"));
+ break;
+ }
+}
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf b/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
index 9deceea9c1..80e15bb850 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
@@ -1,7 +1,7 @@
#/** @file
# Build file for the MMC DXE driver
#
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -26,6 +26,7 @@
ComponentName.c
Mmc.c
MmcBlockIo.c
+ MmcDebug.c
Diagnostics.c
[Packages]