2 Main file for NULL named library for debug1 profile shell command functions.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellDebug1CommandsLib.h"
17 STATIC CONST CHAR16 mFileName
[] = L
"Debug1Commands";
18 EFI_HANDLE gShellDebug1HiiHandle
= NULL
;
19 CONST EFI_GUID gShellDebug1HiiGuid
= \
21 0x25f200aa, 0xd3cb, 0x470a, { 0xbf, 0x51, 0xe7, 0xd1, 0x62, 0xd2, 0x2e, 0x6f } \
26 ShellCommandGetManFileNameDebug1 (
34 Constructor for the Shell Debug1 Commands library.
36 @param ImageHandle the image handle of the process
37 @param SystemTable the EFI System Table pointer
39 @retval EFI_SUCCESS the shell command handlers were installed sucessfully
40 @retval EFI_UNSUPPORTED the shell level required was not found.
44 UefiShellDebug1CommandsLibConstructor (
45 IN EFI_HANDLE ImageHandle
,
46 IN EFI_SYSTEM_TABLE
*SystemTable
50 // check our bit of the profiles mask
52 if ((PcdGet8(PcdShellProfileMask
) & BIT1
) == 0) {
53 return (EFI_UNSUPPORTED
);
57 // install the HII stuff.
59 gShellDebug1HiiHandle
= HiiAddPackages (&gShellDebug1HiiGuid
, gImageHandle
, UefiShellDebug1CommandsLibStrings
, NULL
);
60 if (gShellDebug1HiiHandle
== NULL
) {
61 return (EFI_DEVICE_ERROR
);
65 // install our shell command handlers that are always installed
67 ShellCommandRegisterCommandName(L
"SetSize", ShellCommandRunSetSize
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_SETSIZE
) );
68 ShellCommandRegisterCommandName(L
"comp", ShellCommandRunComp
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_COMP
) );
69 ShellCommandRegisterCommandName(L
"mode", ShellCommandRunMode
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_MODE
) );
70 ShellCommandRegisterCommandName(L
"memmap", ShellCommandRunMemMap
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_MEMMAP
) );
71 ShellCommandRegisterCommandName(L
"eficompress", ShellCommandRunEfiCompress
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS
) );
72 ShellCommandRegisterCommandName(L
"efidecompress", ShellCommandRunEfiDecompress
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS
) );
73 ShellCommandRegisterCommandName(L
"dmem", ShellCommandRunDmem
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_DMEM
) );
74 ShellCommandRegisterCommandName(L
"LoadPciRom", ShellCommandRunLoadPciRom
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM
) );
75 ShellCommandRegisterCommandName(L
"mm", ShellCommandRunMm
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_MM
) );
76 ShellCommandRegisterCommandName(L
"SetVar", ShellCommandRunSetVar
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_SETVAR
) );
77 ShellCommandRegisterCommandName(L
"SerMode", ShellCommandRunSerMode
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_SERMODE
) );
78 ShellCommandRegisterCommandName(L
"Pci", ShellCommandRunPci
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_PCI
) );
79 ShellCommandRegisterCommandName(L
"smbiosview", ShellCommandRunSmbiosView
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW
) );
80 ShellCommandRegisterCommandName(L
"dmpstore", ShellCommandRunDmpStore
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_DMPSTORE
) );
81 ShellCommandRegisterCommandName(L
"dblk", ShellCommandRunDblk
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_DBLK
) );
84 // check install profile bit of the profiles mask is set
86 if ((PcdGet8(PcdShellProfileMask
) & BIT2
) == 0) {
87 ShellCommandRegisterCommandName(L
"bcfg", ShellCommandRunBcfg
, ShellCommandGetManFileNameDebug1
, 0, L
"Debug1", TRUE
, gShellDebug1HiiHandle
, STRING_TOKEN(STR_GET_HELP_BCFG
) );
91 ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT );
92 ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) );
95 ShellCommandRegisterAlias(L
"dmem", L
"mem");
101 Destructor for the library. free any resources.
105 UefiShellDebug1CommandsLibDestructor (
106 IN EFI_HANDLE ImageHandle
,
107 IN EFI_SYSTEM_TABLE
*SystemTable
110 if (gShellDebug1HiiHandle
!= NULL
) {
111 HiiRemovePackages(gShellDebug1HiiHandle
);
113 return (EFI_SUCCESS
);
116 STATIC CONST CHAR8 Hex
[] = {
154 ASSERT (UserData
!= NULL
);
157 while (DataSize
!= 0) {
159 if (Size
> DataSize
) {
163 for (Index
= 0; Index
< Size
; Index
+= 1) {
165 Val
[Index
* 3 + 0] = Hex
[c
>> 4];
166 Val
[Index
* 3 + 1] = Hex
[c
& 0xF];
167 Val
[Index
* 3 + 2] = (CHAR8
) ((Index
== 7) ? '-' : ' ');
168 Str
[Index
] = (CHAR8
) ((c
< ' ' || c
> 'z') ? '.' : c
);
173 ShellPrintEx(-1, -1, L
"%*a%02X: %-.48a *%a*\r\n", Indent
, "", Offset
, Val
, Str
);
182 Convert a Unicode character to upper case only if
183 it maps to a valid small-case ASCII character.
185 This internal function only deal with Unicode character
186 which maps to a valid small-case ASCII character, i.e.
187 L'a' to L'z'. For other Unicode character, the input character
188 is returned directly.
190 @param Char The character to convert.
192 @retval LowerCharacter If the Char is with range L'a' to L'z'.
193 @retval Unchanged Otherwise.
196 //Stolen from MdePkg Baselib
204 if (Char
>= L
'a' && Char
<= L
'z') {
205 return (CHAR16
) (Char
- (L
'a' - L
'A'));
212 Function returns a system configuration table that is stored in the
213 EFI System Table based on the provided GUID.
215 @param[in] TableGuid A pointer to the table's GUID type.
216 @param[out] Table On exit, a pointer to a system configuration table.
218 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
219 @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.
223 GetSystemConfigurationTable (
224 IN EFI_GUID
*TableGuid
,
229 ASSERT (Table
!= NULL
);
231 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
232 if (CompareGuid (TableGuid
, &(gST
->ConfigurationTable
[Index
].VendorGuid
)) == 0) {
233 *Table
= gST
->ConfigurationTable
[Index
].VendorTable
;
238 return EFI_NOT_FOUND
;
242 Convert a Unicode character to numerical value.
244 This internal function only deal with Unicode character
245 which maps to a valid hexadecimal ASII character, i.e.
246 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
247 Unicode character, the value returned does not make sense.
249 @param Char The character to convert.
251 @return The numerical value converted.
260 if (Char
>= L
'0' && Char
<= L
'9') {
264 return (UINTN
) (10 + CharToUpper (Char
) - L
'A');
269 ConvertStringToGuid (
270 IN CONST CHAR16
*StringGuid
,
271 IN OUT EFI_GUID
*Guid
274 if (StrLen(StringGuid
) != 35) {
275 return (EFI_INVALID_PARAMETER
);
277 Guid
->Data1
= (UINT32
)StrHexToUintn(StringGuid
);
279 Guid
->Data2
= (UINT16
)StrHexToUintn(StringGuid
);
281 Guid
->Data3
= (UINT16
)StrHexToUintn(StringGuid
);
283 Guid
->Data4
[0] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
284 Guid
->Data4
[0] = (UINT8
)(Guid
->Data4
[0]+ (UINT8
)HexCharToUintn(StringGuid
[1]));
286 Guid
->Data4
[1] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
287 Guid
->Data4
[1] = (UINT8
)(Guid
->Data4
[1] + (UINT8
)HexCharToUintn(StringGuid
[1]));
289 Guid
->Data4
[2] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
290 Guid
->Data4
[2] = (UINT8
)(Guid
->Data4
[2] + (UINT8
)HexCharToUintn(StringGuid
[1]));
292 Guid
->Data4
[3] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
293 Guid
->Data4
[3] = (UINT8
)(Guid
->Data4
[3] + (UINT8
)HexCharToUintn(StringGuid
[1]));
295 Guid
->Data4
[4] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
296 Guid
->Data4
[4] = (UINT8
)(Guid
->Data4
[4] + (UINT8
)HexCharToUintn(StringGuid
[1]));
298 Guid
->Data4
[5] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
299 Guid
->Data4
[5] = (UINT8
)(Guid
->Data4
[5] + (UINT8
)HexCharToUintn(StringGuid
[1]));
301 Guid
->Data4
[6] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
302 Guid
->Data4
[6] = (UINT8
)(Guid
->Data4
[6] + (UINT8
)HexCharToUintn(StringGuid
[1]));
304 Guid
->Data4
[7] = (UINT8
)(HexCharToUintn(StringGuid
[0]) * 16);
305 Guid
->Data4
[7] = (UINT8
)(Guid
->Data4
[7] = (UINT8
)HexCharToUintn(StringGuid
[1]));
306 return (EFI_SUCCESS
);