BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmbeddedPkg / Universal / MmcDxe / MmcDebug.c
CommitLineData
4ca3c688
OM
1/** @file\r
2*\r
3* Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include "Mmc.h"\r
16\r
17#if !defined(MDEPKG_NDEBUG)\r
18CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",\r
19 "Unknown", "Unknown", "Unknown", "Unknown" };\r
20CONST CHAR8* mStrValue[] = { "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0",\r
21 "Unknown", "Unknown", "Unknown", "Unknown" };\r
22#endif\r
23\r
24VOID\r
25PrintCID (\r
26 IN UINT32* Cid\r
27 )\r
28{\r
29 DEBUG ((EFI_D_ERROR, "- PrintCID\n"));\r
30 DEBUG ((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n", (Cid[0] >> 8) & 0xF, (Cid[0] >> 12) & 0xFF));\r
31 DEBUG ((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n", Cid[1] & 0xFFFFFF, (Cid[0] >> 24) & 0xFF));\r
32 DEBUG ((EFI_D_ERROR, "\t- Product revision: %d\n", Cid[1] >> 24));\r
33 //DEBUG ((EFI_D_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));\r
34 DEBUG ((EFI_D_ERROR, "\t- OEM ID: %c%c\n", (Cid[3] >> 8) & 0xFF, (Cid[3] >> 16) & 0xFF));\r
35}\r
36\r
37\r
38VOID\r
39PrintCSD (\r
40 IN UINT32* Csd\r
41 )\r
42{\r
43 UINTN Value;\r
44\r
45 if (((Csd[2] >> 30) & 0x3) == 0) {\r
46 DEBUG ((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));\r
47 } else if (((Csd[2] >> 30) & 0x3) == 1) {\r
48 DEBUG ((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));\r
49 } else {\r
50 DEBUG ((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n"));\r
51 }\r
52\r
53 DEBUG ((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n", MMC_CSD_GET_CCC (Csd)));\r
54 DEBUG ((EFI_D_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED (Csd) & 7]));\r
55 DEBUG ((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN (Csd)-1)));\r
56 DEBUG ((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN (Csd)-1)));\r
57\r
58 if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {\r
59 Value = MMC_CSD_GET_FILEFORMAT (Csd);\r
60 if (Value == 0) {\r
61 DEBUG ((EFI_D_ERROR, "\t- Format (0): Hard disk-like file system with partition table\n"));\r
62 } else if (Value == 1) {\r
63 DEBUG ((EFI_D_ERROR, "\t- Format (1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));\r
64 } else if (Value == 2) {\r
65 DEBUG ((EFI_D_ERROR, "\t- Format (2): Universal File Format\n"));\r
66 } else {\r
67 DEBUG ((EFI_D_ERROR, "\t- Format (3): Others/Unknown\n"));\r
68 }\r
69 } else {\r
70 DEBUG ((EFI_D_ERROR, "\t- Format: Reserved\n"));\r
71 }\r
72}\r
73\r
74VOID\r
75PrintRCA (\r
76 IN UINT32 Rca\r
77 )\r
78{\r
79 DEBUG ((EFI_D_ERROR, "- PrintRCA: 0x%X\n", Rca));\r
80 DEBUG ((EFI_D_ERROR, "\t- Status: 0x%X\n", Rca & 0xFFFF));\r
81 DEBUG ((EFI_D_ERROR, "\t- RCA: 0x%X\n", (Rca >> 16) & 0xFFFF));\r
82}\r
83\r
84VOID\r
85PrintOCR (\r
86 IN UINT32 Ocr\r
87 )\r
88{\r
89 UINTN MinV;\r
90 UINTN MaxV;\r
91 UINTN Volts;\r
92 UINTN Loop;\r
93\r
94 MinV = 36; // 3.6\r
95 MaxV = 20; // 2.0\r
96 Volts = 20; // 2.0\r
97\r
98 // The MMC register bits [23:8] indicate the working range of the card\r
99 for (Loop = 8; Loop < 24; Loop++) {\r
100 if (Ocr & (1 << Loop)) {\r
101 if (MinV > Volts) {\r
102 MinV = Volts;\r
103 }\r
104 if (MaxV < Volts) {\r
105 MaxV = Volts + 1;\r
106 }\r
107 }\r
108 Volts++;\r
109 }\r
110\r
111 DEBUG ((EFI_D_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));\r
112 DEBUG ((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", MinV/10, MinV % 10, MaxV/10, MaxV % 10));\r
113 if (((Ocr >> 29) & 3) == 0) {\r
114 DEBUG ((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));\r
115 } else {\r
116 DEBUG ((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));\r
117 }\r
118\r
119 if (Ocr & MMC_OCR_POWERUP) {\r
120 DEBUG ((EFI_D_ERROR, "\t- PowerUp\n"));\r
121 } else {\r
122 DEBUG ((EFI_D_ERROR, "\t- Voltage Not Supported\n"));\r
123 }\r
124}\r
125\r
126VOID\r
127PrintResponseR1 (\r
128 IN UINT32 Response\r
129 )\r
130{\r
131 DEBUG ((EFI_D_INFO, "Response: 0x%X\n", Response));\r
132 if (Response & MMC_R0_READY_FOR_DATA) {\r
133 DEBUG ((EFI_D_INFO, "\t- READY_FOR_DATA\n"));\r
134 }\r
135\r
136 switch ((Response >> 9) & 0xF) {\r
137 case 0:\r
138 DEBUG ((EFI_D_INFO, "\t- State: Idle\n"));\r
139 break;\r
140 case 1:\r
141 DEBUG ((EFI_D_INFO, "\t- State: Ready\n"));\r
142 break;\r
143 case 2:\r
144 DEBUG ((EFI_D_INFO, "\t- State: Ident\n"));\r
145 break;\r
146 case 3:\r
147 DEBUG ((EFI_D_INFO, "\t- State: StandBy\n"));\r
148 break;\r
149 case 4:\r
150 DEBUG ((EFI_D_INFO, "\t- State: Tran\n"));\r
151 break;\r
152 case 5:\r
153 DEBUG ((EFI_D_INFO, "\t- State: Data\n"));\r
154 break;\r
155 case 6:\r
156 DEBUG ((EFI_D_INFO, "\t- State: Rcv\n"));\r
157 break;\r
158 case 7:\r
159 DEBUG ((EFI_D_INFO, "\t- State: Prg\n"));\r
160 break;\r
161 case 8:\r
162 DEBUG ((EFI_D_INFO, "\t- State: Dis\n"));\r
163 break;\r
164 default:\r
165 DEBUG ((EFI_D_INFO, "\t- State: Reserved\n"));\r
166 break;\r
167 }\r
168}\r