]>
Commit | Line | Data |
---|---|---|
5d73d92f | 1 | /** @file\r |
2 | Main file for NULL named library for debug1 profile shell command functions.\r | |
3 | \r | |
4 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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 "UefiShellDebug1CommandsLib.h"\r | |
16 | \r | |
17 | STATIC CONST CHAR16 mFileName[] = L"Debug1Commands";\r | |
18 | EFI_HANDLE gShellDebug1HiiHandle = NULL;\r | |
19 | CONST EFI_GUID gShellDebug1HiiGuid = \\r | |
20 | { \\r | |
21 | 0x25f200aa, 0xd3cb, 0x470a, { 0xbf, 0x51, 0xe7, 0xd1, 0x62, 0xd2, 0x2e, 0x6f } \\r | |
22 | };\r | |
23 | \r | |
24 | CONST CHAR16*\r | |
25 | EFIAPI\r | |
26 | ShellCommandGetManFileNameDebug1 (\r | |
27 | VOID\r | |
28 | )\r | |
29 | {\r | |
30 | return (mFileName);\r | |
31 | }\r | |
32 | \r | |
33 | /**\r | |
34 | Constructor for the Shell Debug1 Commands library.\r | |
35 | \r | |
36 | @param ImageHandle the image handle of the process\r | |
37 | @param SystemTable the EFI System Table pointer\r | |
38 | \r | |
39 | @retval EFI_SUCCESS the shell command handlers were installed sucessfully\r | |
40 | @retval EFI_UNSUPPORTED the shell level required was not found.\r | |
41 | **/\r | |
42 | EFI_STATUS\r | |
43 | EFIAPI\r | |
44 | UefiShellDebug1CommandsLibConstructor (\r | |
45 | IN EFI_HANDLE ImageHandle,\r | |
46 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
47 | )\r | |
48 | {\r | |
49 | //\r | |
50 | // check our bit of the profiles mask\r | |
51 | //\r | |
52 | if ((PcdGet8(PcdShellProfileMask) & BIT1) == 0) {\r | |
53 | return (EFI_UNSUPPORTED);\r | |
54 | }\r | |
55 | \r | |
56 | //\r | |
57 | // install the HII stuff.\r | |
58 | //\r | |
59 | gShellDebug1HiiHandle = HiiAddPackages (&gShellDebug1HiiGuid, gImageHandle, UefiShellDebug1CommandsLibStrings, NULL);\r | |
60 | if (gShellDebug1HiiHandle == NULL) {\r | |
61 | return (EFI_DEVICE_ERROR);\r | |
62 | }\r | |
63 | \r | |
64 | //\r | |
65 | // install our shell command handlers that are always installed\r | |
66 | //\r | |
67 | ShellCommandRegisterCommandName(L"SetSize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) );\r | |
68 | ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) );\r | |
69 | ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) );\r | |
70 | ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) );\r | |
71 | ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) );\r | |
72 | ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) );\r | |
73 | ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) );\r | |
74 | ShellCommandRegisterCommandName(L"LoadPciRom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) );\r | |
75 | ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) );\r | |
76 | ShellCommandRegisterCommandName(L"SetVar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) );\r | |
77 | ShellCommandRegisterCommandName(L"SerMode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) );\r | |
78 | ShellCommandRegisterCommandName(L"Pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) );\r | |
79 | ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) );\r | |
80 | ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) );\r | |
81 | ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) );\r | |
82 | \r | |
83 | //\r | |
84 | // check install profile bit of the profiles mask is set\r | |
85 | //\r | |
86 | if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {\r | |
87 | ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfg , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG) );\r | |
88 | }\r | |
89 | \r | |
90 | /*\r | |
91 | ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT );\r | |
92 | ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) );\r | |
93 | */\r | |
94 | \r | |
95 | ShellCommandRegisterAlias(L"dmem", L"mem");\r | |
96 | \r | |
97 | return (EFI_SUCCESS);\r | |
98 | }\r | |
99 | \r | |
100 | /**\r | |
101 | Destructor for the library. free any resources.\r | |
102 | **/\r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | UefiShellDebug1CommandsLibDestructor (\r | |
106 | IN EFI_HANDLE ImageHandle,\r | |
107 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
108 | )\r | |
109 | {\r | |
110 | if (gShellDebug1HiiHandle != NULL) {\r | |
111 | HiiRemovePackages(gShellDebug1HiiHandle);\r | |
112 | }\r | |
113 | return (EFI_SUCCESS);\r | |
114 | }\r | |
115 | \r | |
116 | STATIC CONST CHAR8 Hex[] = {\r | |
117 | '0',\r | |
118 | '1',\r | |
119 | '2',\r | |
120 | '3',\r | |
121 | '4',\r | |
122 | '5',\r | |
123 | '6',\r | |
124 | '7',\r | |
125 | '8',\r | |
126 | '9',\r | |
127 | 'A',\r | |
128 | 'B',\r | |
129 | 'C',\r | |
130 | 'D',\r | |
131 | 'E',\r | |
132 | 'F'\r | |
133 | };\r | |
134 | \r | |
135 | VOID\r | |
136 | EFIAPI\r | |
137 | DumpHex (\r | |
138 | IN UINTN Indent,\r | |
139 | IN UINTN Offset,\r | |
140 | IN UINTN DataSize,\r | |
141 | IN VOID *UserData\r | |
142 | )\r | |
143 | {\r | |
144 | UINT8 *Data;\r | |
145 | \r | |
146 | CHAR8 Val[50];\r | |
147 | \r | |
148 | CHAR8 Str[20];\r | |
149 | \r | |
150 | UINT8 c;\r | |
151 | UINTN Size;\r | |
152 | UINTN Index;\r | |
153 | \r | |
154 | ASSERT (UserData != NULL);\r | |
155 | \r | |
156 | Data = UserData;\r | |
157 | while (DataSize != 0) {\r | |
158 | Size = 16;\r | |
159 | if (Size > DataSize) {\r | |
160 | Size = DataSize;\r | |
161 | }\r | |
162 | \r | |
163 | for (Index = 0; Index < Size; Index += 1) {\r | |
164 | c = Data[Index];\r | |
165 | Val[Index * 3 + 0] = Hex[c >> 4];\r | |
166 | Val[Index * 3 + 1] = Hex[c & 0xF];\r | |
167 | Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');\r | |
168 | Str[Index] = (CHAR8) ((c < ' ' || c > 'z') ? '.' : c);\r | |
169 | }\r | |
170 | \r | |
171 | Val[Index * 3] = 0;\r | |
172 | Str[Index] = 0;\r | |
173 | ShellPrintEx(-1, -1, L"%*a%02X: %-.48a *%a*\r\n", Indent, "", Offset, Val, Str);\r | |
174 | \r | |
175 | Data += Size;\r | |
176 | Offset += Size;\r | |
177 | DataSize -= Size;\r | |
178 | }\r | |
179 | }\r | |
180 | \r | |
181 | /**\r | |
182 | Convert a Unicode character to upper case only if\r | |
183 | it maps to a valid small-case ASCII character.\r | |
184 | \r | |
185 | This internal function only deal with Unicode character\r | |
186 | which maps to a valid small-case ASCII character, i.e.\r | |
187 | L'a' to L'z'. For other Unicode character, the input character\r | |
188 | is returned directly.\r | |
189 | \r | |
190 | @param Char The character to convert.\r | |
191 | \r | |
192 | @retval LowerCharacter If the Char is with range L'a' to L'z'.\r | |
193 | @retval Unchanged Otherwise.\r | |
194 | \r | |
195 | \r | |
196 | //Stolen from MdePkg Baselib\r | |
197 | **/\r | |
198 | CHAR16\r | |
199 | EFIAPI\r | |
200 | CharToUpper (\r | |
201 | IN CHAR16 Char\r | |
202 | )\r | |
203 | {\r | |
204 | if (Char >= L'a' && Char <= L'z') {\r | |
205 | return (CHAR16) (Char - (L'a' - L'A'));\r | |
206 | }\r | |
207 | \r | |
208 | return Char;\r | |
209 | }\r | |
210 | \r | |
211 | /**\r | |
212 | Function returns a system configuration table that is stored in the\r | |
213 | EFI System Table based on the provided GUID.\r | |
214 | \r | |
215 | @param[in] TableGuid A pointer to the table's GUID type.\r | |
216 | @param[out] Table On exit, a pointer to a system configuration table.\r | |
217 | \r | |
218 | @retval EFI_SUCCESS A configuration table matching TableGuid was found.\r | |
219 | @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.\r | |
220 | **/\r | |
221 | EFI_STATUS\r | |
222 | EFIAPI\r | |
223 | GetSystemConfigurationTable (\r | |
224 | IN EFI_GUID *TableGuid,\r | |
225 | IN OUT VOID **Table\r | |
226 | )\r | |
227 | {\r | |
228 | UINTN Index;\r | |
229 | ASSERT (Table != NULL);\r | |
230 | \r | |
231 | for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r | |
232 | if (CompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid)) == 0) {\r | |
233 | *Table = gST->ConfigurationTable[Index].VendorTable;\r | |
234 | return EFI_SUCCESS;\r | |
235 | }\r | |
236 | }\r | |
237 | \r | |
238 | return EFI_NOT_FOUND;\r | |
239 | }\r | |
240 | \r | |
241 | /**\r | |
242 | Convert a Unicode character to numerical value.\r | |
243 | \r | |
244 | This internal function only deal with Unicode character\r | |
245 | which maps to a valid hexadecimal ASII character, i.e.\r | |
246 | L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other\r | |
247 | Unicode character, the value returned does not make sense.\r | |
248 | \r | |
249 | @param Char The character to convert.\r | |
250 | \r | |
251 | @return The numerical value converted.\r | |
252 | \r | |
253 | **/\r | |
254 | UINTN\r | |
255 | EFIAPI\r | |
256 | HexCharToUintn (\r | |
257 | IN CHAR16 Char\r | |
258 | )\r | |
259 | {\r | |
260 | if (Char >= L'0' && Char <= L'9') {\r | |
261 | return Char - L'0';\r | |
262 | }\r | |
263 | \r | |
264 | return (UINTN) (10 + CharToUpper (Char) - L'A');\r | |
265 | }\r | |
266 | \r | |
267 | EFI_STATUS\r | |
268 | EFIAPI\r | |
269 | ConvertStringToGuid (\r | |
270 | IN CONST CHAR16 *StringGuid,\r | |
271 | IN OUT EFI_GUID *Guid\r | |
272 | )\r | |
273 | {\r | |
274 | if (StrLen(StringGuid) != 35) {\r | |
275 | return (EFI_INVALID_PARAMETER);\r | |
276 | } else {\r | |
277 | Guid->Data1 = (UINT32)StrHexToUintn(StringGuid);\r | |
278 | StringGuid += 9;\r | |
279 | Guid->Data2 = (UINT16)StrHexToUintn(StringGuid);\r | |
280 | StringGuid += 5;\r | |
281 | Guid->Data3 = (UINT16)StrHexToUintn(StringGuid);\r | |
282 | StringGuid += 5;\r | |
283 | Guid->Data4[0] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
284 | Guid->Data4[0] = (UINT8)(Guid->Data4[0]+ (UINT8)HexCharToUintn(StringGuid[1]));\r | |
285 | StringGuid += 2;\r | |
286 | Guid->Data4[1] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
287 | Guid->Data4[1] = (UINT8)(Guid->Data4[1] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
288 | StringGuid += 2;\r | |
289 | Guid->Data4[2] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
290 | Guid->Data4[2] = (UINT8)(Guid->Data4[2] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
291 | StringGuid += 2;\r | |
292 | Guid->Data4[3] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
293 | Guid->Data4[3] = (UINT8)(Guid->Data4[3] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
294 | StringGuid += 2;\r | |
295 | Guid->Data4[4] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
296 | Guid->Data4[4] = (UINT8)(Guid->Data4[4] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
297 | StringGuid += 2;\r | |
298 | Guid->Data4[5] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
299 | Guid->Data4[5] = (UINT8)(Guid->Data4[5] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
300 | StringGuid += 2;\r | |
301 | Guid->Data4[6] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
302 | Guid->Data4[6] = (UINT8)(Guid->Data4[6] + (UINT8)HexCharToUintn(StringGuid[1]));\r | |
303 | StringGuid += 2;\r | |
304 | Guid->Data4[7] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16);\r | |
305 | Guid->Data4[7] = (UINT8)(Guid->Data4[7] = (UINT8)HexCharToUintn(StringGuid[1]));\r | |
306 | return (EFI_SUCCESS);\r | |
307 | }\r | |
308 | }\r | |
309 | \r |