summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2017-08-02 09:54:47 +0800
committerGuo Mang <mang.guo@intel.com>2017-09-05 19:45:08 +0800
commit6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8 (patch)
tree444372d92a0ae8991fe4d15eb3937df43690dfda /ShellPkg/Library
parentb207c6434d7a5a4502975d322312e07017e8a8cb (diff)
downloadedk2-platforms-6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8.tar.xz
Remove core packages since we can get them from edk2 repository
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiDpLib/Dp.c319
-rw-r--r--ShellPkg/Library/UefiDpLib/Dp.h98
-rw-r--r--ShellPkg/Library/UefiDpLib/DpInternal.h341
-rw-r--r--ShellPkg/Library/UefiDpLib/DpProfile.c101
-rw-r--r--ShellPkg/Library/UefiDpLib/DpTrace.c829
-rw-r--r--ShellPkg/Library/UefiDpLib/DpUtilities.c393
-rw-r--r--ShellPkg/Library/UefiDpLib/Literals.c23
-rw-r--r--ShellPkg/Library/UefiDpLib/Literals.h26
-rw-r--r--ShellPkg/Library/UefiDpLib/PerformanceTokens.h28
-rw-r--r--ShellPkg/Library/UefiDpLib/Readme.txt2
-rw-r--r--ShellPkg/Library/UefiDpLib/UefiDpLib.c101
-rw-r--r--ShellPkg/Library/UefiDpLib/UefiDpLib.h59
-rw-r--r--ShellPkg/Library/UefiDpLib/UefiDpLib.inf75
-rw-r--r--ShellPkg/Library/UefiDpLib/UefiDpLib.unibin17466 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c2288
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h180
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf200
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.unibin32404 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c1548
-rw-r--r--ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf46
-rw-r--r--ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.unibin18414 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c99
-rw-r--r--ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf44
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c1545
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c1672
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h69
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf69
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c277
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c1417
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h40
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c201
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c233
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c769
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Edit.c162
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c3371
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.h263
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c1935
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.h77
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.c92
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.h52
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.unibin11484 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditor.h32
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditorTypes.h102
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c323
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.h91
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c196
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.h125
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c237
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.h109
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c210
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.h77
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c158
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c180
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c2484
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h277
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c112
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.h69
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c420
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.h95
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c403
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.h83
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c277
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditor.h41
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h126
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.unibin13156 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c2318
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.h76
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c345
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.h92
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c262
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.h93
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c470
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c312
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c647
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c128
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c5922
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h463
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c372
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c110
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c302
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c412
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h117
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c373
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h159
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c3227
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h423
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c4380
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h782
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c1013
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.h136
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.unibin109944 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c644
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h436
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf137
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.unibin140676 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c551
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c277
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c270
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c984
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c189
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c321
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c1407
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c455
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c217
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c99
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c104
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h226
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf73
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.unibin70806 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c149
-rw-r--r--ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c59
-rw-r--r--ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf51
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c97
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c748
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c105
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c1099
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c64
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c84
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c310
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h211
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf58
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.unibin43930 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c277
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c255
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c768
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c281
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c754
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c1257
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c129
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c770
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c459
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c132
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c380
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c170
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c976
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c350
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h374
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf84
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.unibin109570 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c314
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c182
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c133
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c121
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c97
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c476
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c107
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c294
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c328
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c101
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h162
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf74
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.unibin44956 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c147
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c4322
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.h96
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.inf69
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c1388
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c1579
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c90
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.h77
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf67
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.unibin21094 -> 0 bytes
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c1002
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c97
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h62
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf61
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.unibin8856 -> 0 bytes
167 files changed, 0 insertions, 76492 deletions
diff --git a/ShellPkg/Library/UefiDpLib/Dp.c b/ShellPkg/Library/UefiDpLib/Dp.c
deleted file mode 100644
index 82701723c8..0000000000
--- a/ShellPkg/Library/UefiDpLib/Dp.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/** @file
- Shell command for Displaying Performance Metrics.
-
- The Dp command reads performance data and presents it in several
- different formats depending upon the needs of the user. Both
- Trace and Measured Profiling information is processed and presented.
-
- Dp uses the "PerformanceLib" to read the measurement records.
- The "TimerLib" provides information about the timer, such as frequency,
- beginning, and ending counter values.
- Measurement records contain identifying information (Handle, Token, Module)
- and start and end time values.
- Dp uses this information to group records in different ways. It also uses
- timer information to calculate elapsed time for each measurement.
-
- Copyright (c) 2009 - 2013, Intel Corporation. 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 "UefiDpLib.h"
-#include <Guid/GlobalVariable.h>
-#include <Library/PrintLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/DevicePathLib.h>
-
-#include <Library/ShellLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/TimerLib.h>
-#include <Library/UefiLib.h>
-
-#include <Guid/Performance.h>
-
-#include "PerformanceTokens.h"
-#include "Dp.h"
-#include "Literals.h"
-#include "DpInternal.h"
-
-//
-/// Module-Global Variables
-///@{
-CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
-CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
-UINT64 mInterestThreshold;
-BOOLEAN mShowId = FALSE;
-
-PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO.
-
-/// Timer Specific Information.
-TIMER_INFO TimerInfo;
-
-/// Items for which to gather cumulative statistics.
-PERF_CUM_DATA CumData[] = {
- PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),
- PERF_INIT_CUM_DATA (START_IMAGE_TOK),
- PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),
- PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)
-};
-
-/// Number of items for which we are gathering cumulative statistics.
-UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-v", TypeFlag}, // -v Verbose Mode
- {L"-A", TypeFlag}, // -A All, Cooked
- {L"-R", TypeFlag}, // -R RAW All
- {L"-s", TypeFlag}, // -s Summary
-#if PROFILING_IMPLEMENTED
- {L"-P", TypeFlag}, // -P Dump Profile Data
- {L"-T", TypeFlag}, // -T Dump Trace Data
-#endif // PROFILING_IMPLEMENTED
- {L"-x", TypeFlag}, // -x eXclude Cumulative Items
- {L"-i", TypeFlag}, // -i Display Identifier
- {L"-n", TypeValue}, // -n # Number of records to display for A and R
- {L"-t", TypeValue}, // -t # Threshold of interest
- {NULL, TypeMax}
- };
-
-///@}
-
-/**
- Display the trailing Verbose information.
-**/
-VOID
-DumpStatistics( void )
-{
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), gDpHiiHandle, SummaryData.NumTrace);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), gDpHiiHandle, SummaryData.NumIncomplete);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), gDpHiiHandle, SummaryData.NumSummary);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), gDpHiiHandle, SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), gDpHiiHandle, SummaryData.NumPEIMs);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), gDpHiiHandle, SummaryData.NumGlobal);
-#if PROFILING_IMPLEMENTED
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), gDpHiiHandle, SummaryData.NumProfile);
-#endif // PROFILING_IMPLEMENTED
- SHELL_FREE_NON_NULL (StringPtr);
- SHELL_FREE_NON_NULL (StringPtrUnknown);
-}
-
-/**
- Dump performance data.
-
- @param[in] ImageHandle The image handle.
- @param[in] SystemTable The system table.
-
- @retval EFI_SUCCESS Command completed successfully.
- @retval EFI_INVALID_PARAMETER Command usage error.
- @retval value Unknown error.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *CmdLineArg;
- EFI_STATUS Status;
-
- UINT64 Freq;
- UINT64 Ticker;
- UINTN Number2Display;
-
- EFI_STRING StringPtr;
- BOOLEAN SummaryMode;
- BOOLEAN VerboseMode;
- BOOLEAN AllMode;
- BOOLEAN RawMode;
- BOOLEAN TraceMode;
- BOOLEAN ProfileMode;
- BOOLEAN ExcludeMode;
-
- StringPtr = NULL;
- SummaryMode = FALSE;
- VerboseMode = FALSE;
- AllMode = FALSE;
- RawMode = FALSE;
- TraceMode = FALSE;
- ProfileMode = FALSE;
- ExcludeMode = FALSE;
-
- // Get DP's entry time as soon as possible.
- // This is used as the Shell-Phase end time.
- //
- Ticker = GetPerformanceCounter ();
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // Process Command Line arguments
- //
- Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), gDpHiiHandle);
- return SHELL_INVALID_PARAMETER;
- }
-
- //
- // Boolean options
- //
- VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
- SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
- AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A");
- RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
-#if PROFILING_IMPLEMENTED
- TraceMode = ShellCommandLineGetFlag (ParamPackage, L"-T");
- ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");
-#endif // PROFILING_IMPLEMENTED
- ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
- mShowId = ShellCommandLineGetFlag (ParamPackage, L"-i");
-
- // Options with Values
- CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-n");
- if (CmdLineArg == NULL) {
- Number2Display = DEFAULT_DISPLAYCOUNT;
- } else {
- Number2Display = StrDecimalToUintn(CmdLineArg);
- if (Number2Display == 0) {
- Number2Display = MAXIMUM_DISPLAYCOUNT;
- }
- }
-
- CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-t");
- if (CmdLineArg == NULL) {
- mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us
- } else {
- mInterestThreshold = StrDecimalToUint64(CmdLineArg);
- }
-
- // Handle Flag combinations and default behaviors
- // If both TraceMode and ProfileMode are FALSE, set them both to TRUE
- if ((! TraceMode) && (! ProfileMode)) {
- TraceMode = TRUE;
-#if PROFILING_IMPLEMENTED
- ProfileMode = TRUE;
-#endif // PROFILING_IMPLEMENTED
- }
-
- //
- // Timer specific processing
- //
- // Get the Performance counter characteristics:
- // Freq = Frequency in Hz
- // StartCount = Value loaded into the counter when it starts counting
- // EndCount = Value counter counts to before it needs to be reset
- //
- Freq = GetPerformanceCounterProperties (&TimerInfo.StartCount, &TimerInfo.EndCount);
-
- // Convert the Frequency from Hz to KHz
- TimerInfo.Frequency = (UINT32)DivU64x32 (Freq, 1000);
-
- // Determine in which direction the performance counter counts.
- TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);
-
- //
- // Print header
- //
- // print DP's build version
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), gDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
-
- // print performance timer characteristics
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), gDpHiiHandle, TimerInfo.Frequency);
-
- if (VerboseMode && !RawMode) {
- StringPtr = HiiGetString (gDpHiiHandle,
- (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
- ASSERT (StringPtr != NULL);
- // Print Timer count range and direction
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), gDpHiiHandle,
- StringPtr,
- TimerInfo.StartCount,
- TimerInfo.EndCount
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), gDpHiiHandle, mInterestThreshold);
- }
-
-/****************************************************************************
-**** Print Sections based on command line options
-****
-**** Option modes have the following priority:
-**** v Verbose -- Valid in combination with any other options
-**** t Threshold -- Modifies All, Raw, and Cooked output
-**** Default is 0 for All and Raw mode
-**** Default is DEFAULT_THRESHOLD for "Cooked" mode
-**** n Number2Display Used by All and Raw mode. Otherwise ignored.
-**** A All -- R and S options are ignored
-**** R Raw -- S option is ignored
-**** s Summary -- Modifies "Cooked" output only
-**** Cooked (Default)
-****
-**** The All, Raw, and Cooked modes are modified by the Trace and Profile
-**** options.
-**** !T && !P := (0) Default, Both are displayed
-**** T && !P := (1) Only Trace records are displayed
-**** !T && P := (2) Only Profile records are displayed
-**** T && P := (3) Same as Default, both are displayed
-****************************************************************************/
- GatherStatistics();
- if (AllMode) {
- if (TraceMode) {
- DumpAllTrace( Number2Display, ExcludeMode);
- }
- if (ProfileMode) {
- DumpAllProfile( Number2Display, ExcludeMode);
- }
- } else if (RawMode) {
- if (TraceMode) {
- DumpRawTrace( Number2Display, ExcludeMode);
- }
- if (ProfileMode) {
- DumpRawProfile( Number2Display, ExcludeMode);
- }
- } else {
- //------------- Begin Cooked Mode Processing
- if (TraceMode) {
- ProcessPhases ( Ticker );
- if ( ! SummaryMode) {
- Status = ProcessHandles ( ExcludeMode);
- if ( ! EFI_ERROR( Status)) {
- ProcessPeims ();
- ProcessGlobal ();
- ProcessCumulative ();
- }
- }
- }
- if (ProfileMode) {
- DumpAllProfile( Number2Display, ExcludeMode);
- }
- } //------------- End of Cooked Mode Processing
- if ( VerboseMode || SummaryMode) {
- DumpStatistics();
- }
-
- SHELL_FREE_NON_NULL (StringPtr);
-
- return SHELL_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiDpLib/Dp.h b/ShellPkg/Library/UefiDpLib/Dp.h
deleted file mode 100644
index 72e2c3ba18..0000000000
--- a/ShellPkg/Library/UefiDpLib/Dp.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/** @file
- Common declarations for the Dp Performance Reporting Utility.
-
- Copyright (c) 2009 - 2013, Intel Corporation. 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.
-**/
-
-#ifndef _EFI_APP_DP_H_
-#define _EFI_APP_DP_H_
-
-#include <Library/ShellLib.h>
-#include <ShellBase.h>
-
-#define DP_MAJOR_VERSION 2
-#define DP_MINOR_VERSION 4
-
-/**
- * The value assigned to DP_DEBUG controls which debug output
- * is generated. Set it to ZERO to disable.
-**/
-#define DP_DEBUG 0
-
-/**
- * Set to 1 once Profiling has been implemented in order to enable
- * profiling related options and report output.
-**/
-#define PROFILING_IMPLEMENTED 0
-
-#define DEFAULT_THRESHOLD 1000 ///< One millisecond.
-#define DEFAULT_DISPLAYCOUNT 50
-#define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
-
-#define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
-
-/// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
-#define WITHIN_LIMIT( C, L) ( ((L) == 0) || ((C) < (L)) )
-
-/// Structure for storing Timer specific information.
-typedef struct {
- UINT64 StartCount; ///< Value timer is initialized with.
- UINT64 EndCount; ///< Value timer has just before it wraps.
- UINT32 Frequency; ///< Timer count frequency in KHz.
- BOOLEAN CountUp; ///< TRUE if the counter counts up.
-} TIMER_INFO;
-
-/** Initialize one PERF_CUM_DATA structure instance for token t.
- *
- * This parameterized macro takes a single argument, t, which is expected
- * to resolve to a pointer to an ASCII string literal. This parameter may
- * take any one of the following forms:
- * - PERF_INIT_CUM_DATA("Token") A string literal
- * - PERF_INIT_CUM_DATA(pointer) A pointer -- CHAR8 *pointer;
- * - PERF_INIT_CUM_DATA(array) Address of an array -- CHAR8 array[N];
-**/
-#define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
-
-typedef struct {
- UINT64 Duration; ///< Cumulative duration for this item.
- UINT64 MinDur; ///< Smallest duration encountered.
- UINT64 MaxDur; ///< Largest duration encountered.
- CHAR8 *Name; ///< ASCII name of this item.
- UINT32 Count; ///< Total number of measurements accumulated.
-} PERF_CUM_DATA;
-
-typedef struct {
- UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
- UINT32 NumProfile; ///< Number of recorded PROFILE performance measurements.
- UINT32 NumIncomplete; ///< Number of measurements with no END value.
- UINT32 NumSummary; ///< Number of summary section measurements.
- UINT32 NumHandles; ///< Number of measurements with handles.
- UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
- UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
-} PERF_SUMMARY_DATA;
-
-typedef struct {
- CONST VOID *Handle;
- CONST CHAR8 *Token; ///< Measured token string name.
- CONST CHAR8 *Module; ///< Module string name.
- UINT64 StartTimeStamp; ///< Start time point.
- UINT64 EndTimeStamp; ///< End time point.
- UINT32 Identifier; ///< Identifier.
-} MEASUREMENT_RECORD;
-
-typedef struct {
- CHAR8 *Name; ///< Measured token string name.
- UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
- UINT64 MinTime; ///< Minimum Elapsed Time.
- UINT64 MaxTime; ///< Maximum Elapsed Time.
- UINT32 Count; ///< Number of measurements accumulated.
-} PROFILE_RECORD;
-
-#endif // _EFI_APP_DP_H_
diff --git a/ShellPkg/Library/UefiDpLib/DpInternal.h b/ShellPkg/Library/UefiDpLib/DpInternal.h
deleted file mode 100644
index 9b8163aaa0..0000000000
--- a/ShellPkg/Library/UefiDpLib/DpInternal.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/** @file
- Declarations of objects defined internally to the Dp Application.
-
- Declarations of data and functions which are private to the Dp application.
- This file should never be referenced by anything other than components of the
- Dp application. In addition to global data, function declarations for
- DpUtilities.c, DpTrace.c, and DpProfile.c are included here.
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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.
-**/
-#ifndef _DP_INTELNAL_H_
-#define _DP_INTELNAL_H_
-
-#define DP_GAUGE_STRING_LENGTH 36
-
-//
-/// Module-Global Variables
-///@{
-extern EFI_HII_HANDLE gDpHiiHandle;
-extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
-extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
-extern UINT64 mInterestThreshold;
-extern BOOLEAN mShowId;
-
-extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.
-
-/// Timer Specific Information.
-extern TIMER_INFO TimerInfo;
-
-/// Items for which to gather cumulative statistics.
-extern PERF_CUM_DATA CumData[];
-
-/// Number of items for which we are gathering cumulative statistics.
-extern UINT32 const NumCum;
-
-///@}
-
-/**
- Calculate an event's duration in timer ticks.
-
- Given the count direction and the event's start and end timer values,
- calculate the duration of the event in timer ticks. Information for
- the current measurement is pointed to by the parameter.
-
- If the measurement's start time is 1, it indicates that the developer
- is indicating that the measurement began at the release of reset.
- The start time is adjusted to the timer's starting count before performing
- the elapsed time calculation.
-
- The calculated duration, in ticks, is the absolute difference between
- the measurement's ending and starting counts.
-
- @param Measurement Pointer to a MEASUREMENT_RECORD structure containing
- data for the current measurement.
-
- @return The 64-bit duration of the event.
-**/
-UINT64
-GetDuration (
- IN OUT MEASUREMENT_RECORD *Measurement
- );
-
-/**
- Determine whether the Measurement record is for an EFI Phase.
-
- The Token and Module members of the measurement record are checked.
- Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.
-
- @param[in] Measurement A pointer to the Measurement record to test.
-
- @retval TRUE The measurement record is for an EFI Phase.
- @retval FALSE The measurement record is NOT for an EFI Phase.
-**/
-BOOLEAN
-IsPhase(
- IN MEASUREMENT_RECORD *Measurement
- );
-
-/**
- Get the file name portion of the Pdb File Name.
-
- The portion of the Pdb File Name between the last backslash and
- either a following period or the end of the string is converted
- to Unicode and copied into UnicodeBuffer. The name is truncated,
- if necessary, to ensure that UnicodeBuffer is not overrun.
-
- @param[in] PdbFileName Pdb file name.
- @param[out] UnicodeBuffer The resultant Unicode File Name.
-
-**/
-VOID
-DpGetShortPdbFileName (
- IN CHAR8 *PdbFileName,
- OUT CHAR16 *UnicodeBuffer
- );
-
-/**
- Get a human readable name for an image handle.
- The following methods will be tried orderly:
- 1. Image PDB
- 2. ComponentName2 protocol
- 3. FFS UI section
- 4. Image GUID
- 5. Image DevicePath
- 6. Unknown Driver Name
-
- @param[in] Handle
-
- @post The resulting Unicode name string is stored in the
- mGaugeString global array.
-
-**/
-VOID
-DpGetNameFromHandle (
- IN EFI_HANDLE Handle
- );
-
-/**
- Calculate the Duration in microseconds.
-
- Duration is multiplied by 1000, instead of Frequency being divided by 1000 or
- multiplying the result by 1000, in order to maintain precision. Since Duration is
- a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.
-
- The time is calculated as (Duration * 1000) / Timer_Frequency.
-
- @param[in] Duration The event duration in timer ticks.
-
- @return A 64-bit value which is the Elapsed time in microseconds.
-**/
-UINT64
-DurationInMicroSeconds (
- IN UINT64 Duration
- );
-
-/**
- Get index of Measurement Record's match in the CumData array.
-
- If the Measurement's Token value matches a Token in one of the CumData
- records, the index of the matching record is returned. The returned
- index is a signed value so that negative values can indicate that
- the Measurement didn't match any entry in the CumData array.
-
- @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.
-
- @retval <0 Token is not in the CumData array.
- @retval >=0 Return value is the index into CumData where Token is found.
-**/
-INTN
-GetCumulativeItem(
- IN MEASUREMENT_RECORD *Measurement
- );
-
-/**
- Collect verbose statistics about the logged performance measurements.
-
- General Summary information for all Trace measurements is gathered and
- stored within the SummaryData structure. This information is both
- used internally by subsequent reporting functions, and displayed
- at the end of verbose reports.
-
- @pre The SummaryData and CumData structures must be initialized
- prior to calling this function.
-
- @post The SummaryData and CumData structures contain statistics for the
- current performance logs.
-**/
-VOID
-GatherStatistics(
- VOID
- );
-
-/**
- Gather and print ALL Trace Records.
-
- Displays all "interesting" Trace measurements in order.<BR>
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
- The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
- They must not be in use by a calling function.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpAllTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- );
-
-/**
- Gather and print Raw Trace Records.
-
- All Trace measurements with a duration greater than or equal to
- mInterestThreshold are printed without interpretation.
-
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpRawTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- );
-
-/**
- Gather and print Major Phase metrics.
-
- @param[in] Ticker The timer value for the END of Shell phase
-
-**/
-VOID
-ProcessPhases(
- IN UINT64 Ticker
- );
-
-
-/**
- Gather and print Handle data.
-
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
- @return Status from a call to gBS->LocateHandle().
-**/
-EFI_STATUS
-ProcessHandles(
- IN BOOLEAN ExcludeFlag
- );
-
-
-/**
- Gather and print PEIM data.
-
- Only prints complete PEIM records
-
-**/
-VOID
-ProcessPeims(
- VOID
- );
-
-/**
- Gather and print global data.
-
- Strips out incomplete or "Execution Phase" records
- Only prints records where Handle is NULL
- Increment TIndex for every record, even skipped ones, so that we have an
- indication of every measurement record taken.
-
-**/
-VOID
-ProcessGlobal(
- VOID
- );
-
-/**
- Gather and print cumulative data.
-
- Traverse the measurement records and:<BR>
- For each record with a Token listed in the CumData array:<BR>
- - Update the instance count and the total, minimum, and maximum durations.
- Finally, print the gathered cumulative statistics.
-
-**/
-VOID
-ProcessCumulative(
- VOID
- );
-
-/**
- Gather and print ALL Profiling Records.
-
- Displays all "interesting" Profile measurements in order.
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
- The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
- They must not be in use by a calling function.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpAllProfile(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- );
-
-/**
- Gather and print Raw Profile Records.
-
- All Profile measurements with a duration greater than or equal to
- mInterestThreshold are printed without interpretation.
-
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpRawProfile(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiDpLib/DpProfile.c b/ShellPkg/Library/UefiDpLib/DpProfile.c
deleted file mode 100644
index 64583988c1..0000000000
--- a/ShellPkg/Library/UefiDpLib/DpProfile.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file
- Measured Profiling reporting for the Dp utility.
-
- Copyright (c) 2009 - 2013, Intel Corporation. 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 <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HiiLib.h>
-#include <Library/PcdLib.h>
-
-#include <Guid/Performance.h>
-
-#include "Dp.h"
-#include "Literals.h"
-#include "DpInternal.h"
-
-/**
- Gather and print ALL Profiling Records.
-
- Displays all "interesting" Profile measurements in order.
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
- The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
- They must not be in use by a calling function.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpAllProfile(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- )
-{
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-}
-
-/**
- Gather and print Raw Profile Records.
-
- All Profile measurements with a duration greater than or equal to
- mInterestThreshold are printed without interpretation.
-
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpRawProfile(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- )
-{
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-}
diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c b/ShellPkg/Library/UefiDpLib/DpTrace.c
deleted file mode 100644
index cf8200c6f1..0000000000
--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
+++ /dev/null
@@ -1,829 +0,0 @@
-/** @file
- Trace reporting for the Dp utility.
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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 <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HiiLib.h>
-#include <Library/PcdLib.h>
-
-#include <Guid/Performance.h>
-
-#include "Dp.h"
-#include "Literals.h"
-#include "DpInternal.h"
-
-/**
- Collect verbose statistics about the logged performance measurements.
-
- General Summary information for all Trace measurements is gathered and
- stored within the SummaryData structure. This information is both
- used internally by subsequent reporting functions, and displayed
- at the end of verbose reports.
-
- @pre The SummaryData and CumData structures must be initialized
- prior to calling this function.
-
- @post The SummaryData and CumData structures contain statistics for the
- current performance logs.
-**/
-VOID
-GatherStatistics(
- VOID
-)
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINTN LogEntryKey;
- INTN TIndex;
-
- LogEntryKey = 0;
- while ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- {
- ++SummaryData.NumTrace; // Count the number of TRACE Measurement records
- if (Measurement.EndTimeStamp == 0) {
- ++SummaryData.NumIncomplete; // Count the incomplete records
- continue;
- }
-
- if (Measurement.Handle != NULL) {
- ++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles
- }
-
- if (IsPhase( &Measurement)) {
- ++SummaryData.NumSummary; // Count the number of major phases
- }
- else { // !IsPhase(...
- if(Measurement.Handle == NULL) {
- ++SummaryData.NumGlobal;
- }
- }
-
- if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {
- ++SummaryData.NumPEIMs; // Count PEIM measurements
- }
-
- Duration = GetDuration (&Measurement);
- TIndex = GetCumulativeItem (&Measurement);
- if (TIndex >= 0) {
- CumData[TIndex].Duration += Duration;
- CumData[TIndex].Count++;
- if ( Duration < CumData[TIndex].MinDur ) {
- CumData[TIndex].MinDur = Duration;
- }
- if ( Duration > CumData[TIndex].MaxDur ) {
- CumData[TIndex].MaxDur = Duration;
- }
- }
- }
-}
-
-/**
- Gather and print ALL Trace Records.
-
- Displays all "interesting" Trace measurements in order.<BR>
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
- The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
- They must not be in use by a calling function.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpAllTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- )
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- CHAR16 *IncFlag;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN Index;
- UINTN TIndex;
-
- EFI_HANDLE *HandleBuffer;
- UINTN Size;
- EFI_HANDLE TempHandle;
- EFI_STATUS Status;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
- FreePool (StringPtrUnknown);
-
- // Get Handle information
- //
- Size = 0;
- HandleBuffer = &TempHandle;
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocatePool (Size);
- ASSERT (HandleBuffer != NULL);
- if (HandleBuffer == NULL) {
- return;
- }
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
- }
- else {
- // We have successfully populated the HandleBuffer
- // Display ALL Measurement Records
- // Up to Limit lines displayed
- // Display only records with Elapsed times >= mInterestThreshold
- // Display driver names in Module field for records with Handles.
- //
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), gDpHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
- }
-
- LogEntryKey = 0;
- Count = 0;
- Index = 0;
- while ( WITHIN_LIMIT(Count, Limit) &&
- ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- )
- {
- ++Index; // Count every record. First record is 1.
- ElapsedTime = 0;
- SHELL_FREE_NON_NULL (IncFlag);
- if (Measurement.EndTimeStamp != 0) {
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
- IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
- }
- else {
- IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
- }
- if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or excluded records
- continue;
- }
- ++Count; // Count the number of records printed
-
- // If Handle is non-zero, see if we can determine a name for the driver
- AsciiStrToUnicodeStr (Measurement.Module, mGaugeString); // Use Module by default
- AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
- if (Measurement.Handle != NULL) {
- // See if the Handle is in the HandleBuffer
- for (TIndex = 0; TIndex < (Size / sizeof(HandleBuffer[0])); TIndex++) {
- if (Measurement.Handle == HandleBuffer[TIndex]) {
- DpGetNameFromHandle (HandleBuffer[TIndex]);
- break;
- }
- }
- }
-
- if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {
- UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);
- }
-
- // Ensure that the argument strings are not too long.
- mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- mUnicodeToken[13] = 0;
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), gDpHiiHandle,
- Index, // 1 based, Which measurement record is being printed
- IncFlag,
- Measurement.Handle,
- mGaugeString,
- mUnicodeToken,
- ElapsedTime,
- Measurement.Identifier
- );
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), gDpHiiHandle,
- Index, // 1 based, Which measurement record is being printed
- IncFlag,
- Measurement.Handle,
- mGaugeString,
- mUnicodeToken,
- ElapsedTime
- );
- }
- }
- }
- if (HandleBuffer != &TempHandle) {
- FreePool (HandleBuffer);
- }
- SHELL_FREE_NON_NULL (IncFlag);
-}
-
-/**
- Gather and print Raw Trace Records.
-
- All Trace measurements with a duration greater than or equal to
- mInterestThreshold are printed without interpretation.
-
- The number of records displayed is controlled by:
- - records with a duration less than mInterestThreshold microseconds are not displayed.
- - No more than Limit records are displayed. A Limit of zero will not limit the output.
- - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
- displayed.
-
- @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
-
- @param[in] Limit The number of records to print. Zero is ALL.
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpRawTrace(
- IN UINTN Limit,
- IN BOOLEAN ExcludeFlag
- )
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN Index;
-
- EFI_STRING StringPtr;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), gDpHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), gDpHiiHandle);
- }
-
- LogEntryKey = 0;
- Count = 0;
- Index = 0;
- while ( WITHIN_LIMIT(Count, Limit) &&
- ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- )
- {
- ++Index; // Count every record. First record is 1.
- ElapsedTime = 0;
- if (Measurement.EndTimeStamp != 0) {
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
- }
- if ((ElapsedTime < mInterestThreshold) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or Excluded records
- continue;
- }
- ++Count; // Count the number of records printed
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), gDpHiiHandle,
- Index, // 1 based, Which measurement record is being printed
- Measurement.Handle,
- Measurement.StartTimeStamp,
- Measurement.EndTimeStamp,
- Measurement.Token,
- Measurement.Module,
- Measurement.Identifier
- );
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), gDpHiiHandle,
- Index, // 1 based, Which measurement record is being printed
- Measurement.Handle,
- Measurement.StartTimeStamp,
- Measurement.EndTimeStamp,
- Measurement.Token,
- Measurement.Module
- );
- }
- }
-}
-
-/**
- Gather and print Major Phase metrics.
-
- @param[in] Ticker The timer value for the END of Shell phase
-
-**/
-VOID
-ProcessPhases(
- IN UINT64 Ticker
- )
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 BdsTimeoutValue;
- UINT64 SecTime;
- UINT64 PeiTime;
- UINT64 DxeTime;
- UINT64 BdsTime;
- UINT64 ShellTime;
- UINT64 ElapsedTime;
- UINT64 Duration;
- UINT64 Total;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- EFI_STRING StringPtrUnknown;
-
- BdsTimeoutValue = 0;
- SecTime = 0;
- PeiTime = 0;
- DxeTime = 0;
- BdsTime = 0;
- ShellTime = 0;
- //
- // Get Execution Phase Statistics
- //
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- LogEntryKey = 0;
- while ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- {
- if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) {
- Measurement.EndTimeStamp = Ticker;
- }
- if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
- continue;
- }
- Duration = GetDuration (&Measurement);
- if ( Measurement.Handle != NULL
- && (AsciiStrnCmp (Measurement.Token, ALit_BdsTO, PERF_TOKEN_LENGTH) == 0)
- )
- {
- BdsTimeoutValue = Duration;
- } else if (AsciiStrnCmp (Measurement.Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0) {
- SecTime = Duration;
- } else if (AsciiStrnCmp (Measurement.Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0) {
- PeiTime = Duration;
- } else if (AsciiStrnCmp (Measurement.Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0) {
- DxeTime = Duration;
- } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0) {
- BdsTime = Duration;
- } else if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) {
- ShellTime = Duration;
- }
- }
-
- Total = 0;
-
- // print SEC phase duration time
- //
- if (SecTime > 0) {
- ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds
- Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), gDpHiiHandle, ElapsedTime);
- }
-
- // print PEI phase duration time
- //
- if (PeiTime > 0) {
- ElapsedTime = DivU64x32 (
- PeiTime,
- (UINT32)TimerInfo.Frequency
- );
- Total += ElapsedTime;
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_PEI, ElapsedTime);
- }
-
- // print DXE phase duration time
- //
- if (DxeTime > 0) {
- ElapsedTime = DivU64x32 (
- DxeTime,
- (UINT32)TimerInfo.Frequency
- );
- Total += ElapsedTime;
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_DXE, ElapsedTime);
- }
-
- // print BDS phase duration time
- //
- if (BdsTime > 0) {
- ElapsedTime = DivU64x32 (
- BdsTime,
- (UINT32)TimerInfo.Frequency
- );
- Total += ElapsedTime;
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_BDS, ElapsedTime);
- }
-
- if (BdsTimeoutValue > 0) {
- ElapsedTime = DivU64x32 (
- BdsTimeoutValue,
- (UINT32)TimerInfo.Frequency
- );
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), gDpHiiHandle, ALit_BdsTO, ElapsedTime);
- }
-
- // print SHELL phase duration time
- //
- if (ShellTime > 0) {
- ElapsedTime = DivU64x32 (
- ShellTime,
- (UINT32)TimerInfo.Frequency
- );
- Total += ElapsedTime;
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_SHELL, ElapsedTime);
- }
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), gDpHiiHandle, Total);
-}
-
-/**
- Gather and print Handle data.
-
- @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
-
- @return Status from a call to gBS->LocateHandle().
-**/
-EFI_STATUS
-ProcessHandles(
- IN BOOLEAN ExcludeFlag
- )
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 ElapsedTime;
- UINT64 Duration;
- EFI_HANDLE *HandleBuffer;
- EFI_STRING StringPtr;
- UINTN Index;
- UINTN LogEntryKey;
- UINTN Count;
- UINTN Size;
- EFI_HANDLE TempHandle;
- EFI_STATUS Status;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- Size = 0;
- HandleBuffer = &TempHandle;
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocatePool (Size);
- ASSERT (HandleBuffer != NULL);
- if (HandleBuffer == NULL) {
- return Status;
- }
- Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
- }
- else {
-#if DP_DEBUG == 2
- Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));
-#endif
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), gDpHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), gDpHiiHandle);
- }
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
-
- LogEntryKey = 0;
- Count = 0;
- while ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- {
- Count++;
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
- if ((ElapsedTime < mInterestThreshold) ||
- (Measurement.EndTimeStamp == 0) ||
- (Measurement.Handle == NULL) ||
- ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
- ) { // Ignore "uninteresting" or excluded records
- continue;
- }
- mGaugeString[0] = 0; // Empty driver name by default
- AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
- // See if the Handle is in the HandleBuffer
- for (Index = 0; Index < (Size / sizeof(HandleBuffer[0])); Index++) {
- if (Measurement.Handle == HandleBuffer[Index]) {
- DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString
- break;
- }
- }
- // Ensure that the argument strings are not too long.
- mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- mUnicodeToken[11] = 0;
- if (mGaugeString[0] != 0) {
- // Display the record if it has a valid handle.
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), gDpHiiHandle,
- Count, // 1 based, Which measurement record is being printed
- Index + 1, // 1 based, Which handle is being printed
- mGaugeString,
- mUnicodeToken,
- ElapsedTime,
- Measurement.Identifier
- );
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), gDpHiiHandle,
- Count, // 1 based, Which measurement record is being printed
- Index + 1, // 1 based, Which handle is being printed
- mGaugeString,
- mUnicodeToken,
- ElapsedTime
- );
- }
- }
- }
- }
- if (HandleBuffer != &TempHandle) {
- FreePool (HandleBuffer);
- }
- return Status;
-}
-
-/**
- Gather and print PEIM data.
-
- Only prints complete PEIM records
-
-**/
-VOID
-ProcessPeims(
- VOID
-)
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINT64 ElapsedTime;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- UINTN TIndex;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), gDpHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), gDpHiiHandle);
- }
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
- TIndex = 0;
- LogEntryKey = 0;
- while ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- {
- TIndex++;
- if ((Measurement.EndTimeStamp == 0) ||
- (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) != 0)
- ) {
- continue;
- }
-
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds
- if (ElapsedTime >= mInterestThreshold) {
- // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), gDpHiiHandle,
- TIndex, // 1 based, Which measurement record is being printed
- Measurement.Handle, // base address
- Measurement.Handle, // file guid
- ElapsedTime,
- Measurement.Identifier
- );
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), gDpHiiHandle,
- TIndex, // 1 based, Which measurement record is being printed
- Measurement.Handle, // base address
- Measurement.Handle, // file guid
- ElapsedTime
- );
- }
- }
- }
-}
-
-/**
- Gather and print global data.
-
- Strips out incomplete or "Execution Phase" records
- Only prints records where Handle is NULL
- Increment TIndex for every record, even skipped ones, so that we have an
- indication of every measurement record taken.
-
-**/
-VOID
-ProcessGlobal(
- VOID
-)
-{
- MEASUREMENT_RECORD Measurement;
- UINT64 Duration;
- UINT64 ElapsedTime;
- EFI_STRING StringPtr;
- UINTN LogEntryKey;
- UINTN Index; // Index, or number, of the measurement record being processed
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), gDpHiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), gDpHiiHandle);
- }
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
-
- Index = 1;
- LogEntryKey = 0;
-
- while ((LogEntryKey = GetPerformanceMeasurementEx (
- LogEntryKey,
- &Measurement.Handle,
- &Measurement.Token,
- &Measurement.Module,
- &Measurement.StartTimeStamp,
- &Measurement.EndTimeStamp,
- &Measurement.Identifier)) != 0)
- {
- AsciiStrToUnicodeStr (Measurement.Module, mGaugeString);
- AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);
- mGaugeString[25] = 0;
- mUnicodeToken[31] = 0;
- if ( ! ( IsPhase( &Measurement) ||
- (Measurement.Handle != NULL) ||
- (Measurement.EndTimeStamp == 0)
- ))
- {
- Duration = GetDuration (&Measurement);
- ElapsedTime = DurationInMicroSeconds ( Duration );
- if (ElapsedTime >= mInterestThreshold) {
- if (mShowId) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), gDpHiiHandle,
- Index,
- mGaugeString,
- mUnicodeToken,
- ElapsedTime,
- Measurement.Identifier
- );
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), gDpHiiHandle,
- Index,
- mGaugeString,
- mUnicodeToken,
- ElapsedTime
- );
- }
- }
- }
- Index++;
- }
-}
-
-/**
- Gather and print cumulative data.
-
- Traverse the measurement records and:<BR>
- For each record with a Token listed in the CumData array:<BR>
- - Update the instance count and the total, minimum, and maximum durations.
- Finally, print the gathered cumulative statistics.
-
-**/
-VOID
-ProcessCumulative(
- VOID
-)
-{
- UINT64 AvgDur; // the computed average duration
- UINT64 Dur;
- UINT64 MinDur;
- UINT64 MaxDur;
- EFI_STRING StringPtr;
- UINTN TIndex;
- EFI_STRING StringPtrUnknown;
-
- StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
- (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
- FreePool (StringPtr);
- FreePool (StringPtrUnknown);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), gDpHiiHandle);
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
-
- for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
- if (CumData[TIndex].Count != 0) {
- AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
- AvgDur = DurationInMicroSeconds(AvgDur);
- Dur = DurationInMicroSeconds(CumData[TIndex].Duration);
- MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
- MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,
- CumData[TIndex].Name,
- CumData[TIndex].Count,
- Dur,
- AvgDur,
- MinDur,
- MaxDur
- );
- }
- }
-}
diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/Library/UefiDpLib/DpUtilities.c
deleted file mode 100644
index 5237459e5b..0000000000
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/** @file
- Utility functions used by the Dp application.
-
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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 <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HiiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/HandleParsingLib.h>
-
-#include <Pi/PiFirmwareFile.h>
-#include <Library/DxeServicesLib.h>
-
-#include <Protocol/LoadedImage.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/DevicePath.h>
-
-#include <Guid/Performance.h>
-
-#include "Dp.h"
-#include "Literals.h"
-#include "DpInternal.h"
-
-/**
- Calculate an event's duration in timer ticks.
-
- Given the count direction and the event's start and end timer values,
- calculate the duration of the event in timer ticks. Information for
- the current measurement is pointed to by the parameter.
-
- If the measurement's start time is 1, it indicates that the developer
- is indicating that the measurement began at the release of reset.
- The start time is adjusted to the timer's starting count before performing
- the elapsed time calculation.
-
- The calculated duration, in ticks, is the absolute difference between
- the measurement's ending and starting counts.
-
- @param Measurement Pointer to a MEASUREMENT_RECORD structure containing
- data for the current measurement.
-
- @return The 64-bit duration of the event.
-**/
-UINT64
-GetDuration (
- IN OUT MEASUREMENT_RECORD *Measurement
- )
-{
- UINT64 Duration;
- BOOLEAN Error;
-
- // PERF_START macros are called with a value of 1 to indicate
- // the beginning of time. So, adjust the start ticker value
- // to the real beginning of time.
- // Assumes no wraparound. Even then, there is a very low probability
- // of having a valid StartTicker value of 1.
- if (Measurement->StartTimeStamp == 1) {
- Measurement->StartTimeStamp = TimerInfo.StartCount;
- }
- if (TimerInfo.CountUp) {
- Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;
- Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);
- }
- else {
- Duration = Measurement->StartTimeStamp - Measurement->EndTimeStamp;
- Error = (BOOLEAN)(Duration > Measurement->StartTimeStamp);
- }
-
- if (Error) {
- DEBUG ((EFI_D_ERROR, ALit_TimerLibError));
- Duration = 0;
- }
- return Duration;
-}
-
-/**
- Determine whether the Measurement record is for an EFI Phase.
-
- The Token and Module members of the measurement record are checked.
- Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.
-
- @param[in] Measurement A pointer to the Measurement record to test.
-
- @retval TRUE The measurement record is for an EFI Phase.
- @retval FALSE The measurement record is NOT for an EFI Phase.
-**/
-BOOLEAN
-IsPhase(
- IN MEASUREMENT_RECORD *Measurement
- )
-{
- BOOLEAN RetVal;
-
- RetVal = (BOOLEAN)( ( *Measurement->Module == '\0') &&
- ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0) ||
- (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0) ||
- (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0) ||
- (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0))
- );
- return RetVal;
-}
-
-/**
- Get the file name portion of the Pdb File Name.
-
- The portion of the Pdb File Name between the last backslash and
- either a following period or the end of the string is converted
- to Unicode and copied into UnicodeBuffer. The name is truncated,
- if necessary, to ensure that UnicodeBuffer is not overrun.
-
- @param[in] PdbFileName Pdb file name.
- @param[out] UnicodeBuffer The resultant Unicode File Name.
-
-**/
-VOID
-DpGetShortPdbFileName (
- IN CHAR8 *PdbFileName,
- OUT CHAR16 *UnicodeBuffer
- )
-{
- UINTN IndexA; // Current work location within an ASCII string.
- UINTN IndexU; // Current work location within a Unicode string.
- UINTN StartIndex;
- UINTN EndIndex;
-
- ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));
-
- if (PdbFileName == NULL) {
- StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);
- } else {
- StartIndex = 0;
- for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
- ;
- for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
- if (PdbFileName[IndexA] == '\\') {
- StartIndex = IndexA + 1;
- }
-
- if (PdbFileName[IndexA] == '.') {
- EndIndex = IndexA;
- }
- }
-
- IndexU = 0;
- for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {
- UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];
- IndexU++;
- if (IndexU >= DXE_PERFORMANCE_STRING_LENGTH) {
- UnicodeBuffer[DXE_PERFORMANCE_STRING_LENGTH] = 0;
- break;
- }
- }
- }
-}
-
-/**
- Get a human readable name for an image handle.
- The following methods will be tried orderly:
- 1. Image PDB
- 2. ComponentName2 protocol
- 3. FFS UI section
- 4. Image GUID
- 5. Image DevicePath
- 6. Unknown Driver Name
-
- @param[in] Handle
-
- @post The resulting Unicode name string is stored in the
- mGaugeString global array.
-
-**/
-VOID
-DpGetNameFromHandle (
- IN EFI_HANDLE Handle
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *Image;
- CHAR8 *PdbFileName;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_STRING StringPtr;
- EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_GUID *NameGuid;
- CHAR16 *NameString;
- UINTN StringSize;
- CHAR8 *PlatformLanguage;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
-
- //
- // Method 1: Get the name string from image PDB
- //
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &Image
- );
-
- if (EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- Handle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->HandleProtocol (
- DriverBinding->ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &Image
- );
- }
- }
-
- if (!EFI_ERROR (Status)) {
- PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
-
- if (PdbFileName != NULL) {
- DpGetShortPdbFileName (PdbFileName, mGaugeString);
- return;
- }
- }
-
- //
- // Method 2: Get the name string from ComponentName2 protocol
- //
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
- );
- if (!EFI_ERROR (Status)) {
- //
- // Get the current platform language setting
- //
- PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE);
- Status = ComponentName2->GetDriverName (
- ComponentName2,
- PlatformLanguage != NULL ? PlatformLanguage : "en-US",
- &StringPtr
- );
- if (!EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (PlatformLanguage);
- StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
- mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- return;
- }
- }
-
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiLoadedImageDevicePathProtocolGuid,
- (VOID **) &LoadedImageDevicePath
- );
- if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {
- DevicePath = LoadedImageDevicePath;
-
- //
- // Try to get image GUID from LoadedImageDevicePath protocol
- //
- NameGuid = NULL;
- while (!IsDevicePathEndType (DevicePath)) {
- NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
- if (NameGuid != NULL) {
- break;
- }
- DevicePath = NextDevicePathNode (DevicePath);
- }
-
- if (NameGuid != NULL) {
- //
- // Try to get the image's FFS UI section by image GUID
- //
- NameString = NULL;
- StringSize = 0;
- Status = GetSectionFromAnyFv (
- NameGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **) &NameString,
- &StringSize
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Method 3. Get the name string from FFS UI section
- //
- StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);
- mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- FreePool (NameString);
- } else {
- //
- // Method 4: Get the name string from image GUID
- //
- UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);
- }
- return;
- } else {
- //
- // Method 5: Get the name string from image DevicePath
- //
- NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE);
- if (NameString != NULL) {
- StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);
- mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
- FreePool (NameString);
- return;
- }
- }
- }
-
- //
- // Method 6: Unknown Driver Name
- //
- StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);
- ASSERT (StringPtr != NULL);
- StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
- FreePool (StringPtr);
-}
-
-/**
- Calculate the Duration in microseconds.
-
- Duration is multiplied by 1000, instead of Frequency being divided by 1000 or
- multiplying the result by 1000, in order to maintain precision. Since Duration is
- a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.
-
- The time is calculated as (Duration * 1000) / Timer_Frequency.
-
- @param[in] Duration The event duration in timer ticks.
-
- @return A 64-bit value which is the Elapsed time in microseconds.
-**/
-UINT64
-DurationInMicroSeconds (
- IN UINT64 Duration
- )
-{
- UINT64 Temp;
-
- Temp = MultU64x32 (Duration, 1000);
- return DivU64x32 (Temp, TimerInfo.Frequency);
-}
-
-/**
- Get index of Measurement Record's match in the CumData array.
-
- If the Measurement's Token value matches a Token in one of the CumData
- records, the index of the matching record is returned. The returned
- index is a signed value so that negative values can indicate that
- the Measurement didn't match any entry in the CumData array.
-
- @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.
-
- @retval <0 Token is not in the CumData array.
- @retval >=0 Return value is the index into CumData where Token is found.
-**/
-INTN
-GetCumulativeItem(
- IN MEASUREMENT_RECORD *Measurement
- )
-{
- INTN Index;
-
- for( Index = 0; Index < (INTN)NumCum; ++Index) {
- if (AsciiStrnCmp (Measurement->Token, CumData[Index].Name, PERF_TOKEN_LENGTH) == 0) {
- return Index; // Exit, we found a match
- }
- }
- // If the for loop exits, Token was not found.
- return -1; // Indicate failure
-}
diff --git a/ShellPkg/Library/UefiDpLib/Literals.c b/ShellPkg/Library/UefiDpLib/Literals.c
deleted file mode 100644
index 68de0fbc9e..0000000000
--- a/ShellPkg/Library/UefiDpLib/Literals.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/** @file
- Definitions of ASCII string literals used by DP.
-
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 <PerformanceTokens.h>
-
-// ASCII String literals which probably don't need translation
-CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";
-CHAR8 const ALit_SEC[] = SEC_TOK;
-CHAR8 const ALit_DXE[] = DXE_TOK;
-CHAR8 const ALit_SHELL[] = SHELL_TOK;
-CHAR8 const ALit_PEI[] = PEI_TOK;
-CHAR8 const ALit_BDS[] = BDS_TOK;
-CHAR8 const ALit_BdsTO[] = "BdsTimeOut";
-CHAR8 const ALit_PEIM[] = "PEIM";
diff --git a/ShellPkg/Library/UefiDpLib/Literals.h b/ShellPkg/Library/UefiDpLib/Literals.h
deleted file mode 100644
index 8aec09c024..0000000000
--- a/ShellPkg/Library/UefiDpLib/Literals.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file
- Declarations of ASCII string literals used by DP.
-
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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.
-**/
-#ifndef _LITERALS_H_
-#define _LITERALS_H_
-
-// ASCII String literals which probably don't need translation
-extern CHAR8 const ALit_TimerLibError[];
-extern CHAR8 const ALit_SEC[];
-extern CHAR8 const ALit_DXE[];
-extern CHAR8 const ALit_SHELL[];
-extern CHAR8 const ALit_PEI[];
-extern CHAR8 const ALit_BDS[];
-extern CHAR8 const ALit_BdsTO[];
-extern CHAR8 const ALit_PEIM[];
-
-#endif // _LITERALS_H_
diff --git a/ShellPkg/Library/UefiDpLib/PerformanceTokens.h b/ShellPkg/Library/UefiDpLib/PerformanceTokens.h
deleted file mode 100644
index bbbc48d776..0000000000
--- a/ShellPkg/Library/UefiDpLib/PerformanceTokens.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- ASCII String Literals with special meaning to Performance measurement and the Dp utility.
-
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef __PERFORMANCE_TOKENS_H__
-#define __PERFORMANCE_TOKENS_H__
-
-#define SEC_TOK "SEC" ///< SEC Phase
-#define DXE_TOK "DXE" ///< DEC Phase
-#define SHELL_TOK "SHELL" ///< Shell Phase
-#define PEI_TOK "PEI" ///< PEI Phase
-#define BDS_TOK "BDS" ///< BDS Phase
-#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Binding Start() function call
-#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Binding Support() function call
-#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a dispatched module
-#define START_IMAGE_TOK "StartImage:" ///< Dispatched Modules Entry Point execution
-
-#endif // __PERFORMANCE_TOKENS_H__
diff --git a/ShellPkg/Library/UefiDpLib/Readme.txt b/ShellPkg/Library/UefiDpLib/Readme.txt
deleted file mode 100644
index 849efa4360..0000000000
--- a/ShellPkg/Library/UefiDpLib/Readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-from PerformancePkg\Dp_App
-SVN 13406
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.c b/ShellPkg/Library/UefiDpLib/UefiDpLib.c
deleted file mode 100644
index f3ecfeac7f..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file
- Main file for NULL named library for install1 shell command functions.
-
- Copyright (c) 2010 - 2013, Intel Corporation. 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 "UefiDpLib.h"
-
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
-EFI_HANDLE gDpHiiHandle = NULL;
-
-#define DP_HII_GUID \
- { \
- 0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9 } \
- }
-
-EFI_GUID gDpHiiGuid = DP_HII_GUID;
-
-/**
- Function to get the filename with help context if HII will not be used.
-
- @return The filename with help text in it.
-**/
-CONST CHAR16*
-EFIAPI
-UefiDpLibGetManFileName (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Level 1 Commands library.
-
- Install the handlers for level 1 UEFI Shell 2.0 commands.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-UefiDpLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
- return (EFI_SUCCESS);
- }
-
- //
- // 3rd parameter 'HII strings array' must be name of .uni strings file followed by 'Strings', e.g. mycommands.uni must be
- // specified as 'mycommandsStrings' because the build Autogen process defines this as a string array for the strings in your
- // .uni file. Examine your Build folder under your package's DEBUG folder and you will find it defined in a xxxStrDefs.h file.
- //
- gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle, UefiDpLibStrings, NULL);
- if (gDpHiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp , UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle, STRING_TOKEN(STR_GET_HELP_DP));
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-UefiDpLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gDpHiiHandle != NULL) {
- HiiRemovePackages(gDpHiiHandle);
- }
- return (EFI_SUCCESS);
-}
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.h b/ShellPkg/Library/UefiDpLib/UefiDpLib.h
deleted file mode 100644
index d16f55fe02..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file
- Main file for NULL named library for dp command functions.
-
- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_DP_LIB_H_
-#define _UEFI_DP_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-extern EFI_GUID gDpHiiGuid;
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-
-extern EFI_HANDLE gDpHiiHandle;
-
-/**
- Function for 'dp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf b/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
deleted file mode 100644
index 70d2163d2b..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
+++ /dev/null
@@ -1,75 +0,0 @@
-## @file
-# Display Performance Application, Module information file.
-#
-# Copyright (c) 2009 - 2015, Intel Corporation. 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiDpLib
- FILE_GUID = 9DF262F7-CF81-4294-B5A5-B2E3CAFE5618
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = UefiDpLibConstructor
- DESTRUCTOR = UefiDpLibDestructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- PerformanceTokens.h
- UefiDpLib.c
- UefiDpLib.h
- UefiDpLib.uni
- Dp.c
- Dp.h
- Literals.h
- Literals.c
- DpInternal.h
- DpUtilities.c
- DpTrace.c
- DpProfile.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- TimerLib
- PerformanceLib
- DxeServicesLib
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
- DevicePathLib
-
-[Protocols]
- gEfiLoadedImageProtocolGuid ## CONSUMES
- gEfiDriverBindingProtocolGuid ## SOMETIMES_CONSUMES
- gEfiComponentName2ProtocolGuid ## SOMETIMES_CONSUMES
- gEfiLoadedImageDevicePathProtocolGuid ## SOMETIMES_CONSUMES
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize ## UNDEFINED
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni b/ShellPkg/Library/UefiDpLib/UefiDpLib.uni
deleted file mode 100644
index 1e5c26ac94..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
deleted file mode 100644
index b6ce509af3..0000000000
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ /dev/null
@@ -1,2288 +0,0 @@
-/** @file
- Provides interface to advanced shell functionality for parsing both handle and protocol database.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiHandleParsingLib.h"
-#include "IndustryStandard/Acpi10.h"
-
-EFI_HANDLE mHandleParsingHiiHandle = NULL;
-HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
-GUID_INFO_BLOCK *GuidList;
-UINTN GuidListCount;
-/**
- Function to translate the EFI_MEMORY_TYPE into a string.
-
- @param[in] Memory The memory type.
-
- @retval A string representation of the type allocated from BS Pool.
-**/
-CHAR16*
-EFIAPI
-ConvertMemoryType (
- IN CONST EFI_MEMORY_TYPE Memory
- )
-{
- CHAR16 *RetVal;
- RetVal = NULL;
-
- switch (Memory) {
- case EfiReservedMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0); break;
- case EfiLoaderCode: StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0); break;
- case EfiLoaderData: StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0); break;
- case EfiBootServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0); break;
- case EfiBootServicesData: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0); break;
- case EfiRuntimeServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0); break;
- case EfiRuntimeServicesData: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0); break;
- case EfiConventionalMemory: StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0); break;
- case EfiUnusableMemory: StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0); break;
- case EfiACPIReclaimMemory: StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0); break;
- case EfiACPIMemoryNVS: StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0); break;
- case EfiMemoryMappedIO: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0); break;
- case EfiMemoryMappedIOPortSpace: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0); break;
- case EfiPalCode: StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0); break;
- case EfiMaxMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0); break;
- default: ASSERT(FALSE);
- }
- return (RetVal);
-}
-
-/**
- Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.
-
- @param[in] Fmt The format type.
-
- @retval A string representation of the type allocated from BS Pool.
-**/
-CHAR16*
-EFIAPI
-ConvertPixelFormat (
- IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt
- )
-{
- CHAR16 *RetVal;
- RetVal = NULL;
-
- switch (Fmt) {
- case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0); break;
- case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0); break;
- case PixelBitMask: StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0); break;
- case PixelBltOnly: StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0); break;
- case PixelFormatMax: StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0); break;
- default: ASSERT(FALSE);
- }
- return (RetVal);
-}
-
-/**
- Constructor for the library.
-
- @param[in] ImageHandle Ignored.
- @param[in] SystemTable Ignored.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HandleParsingLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- GuidListCount = 0;
- GuidList = NULL;
-
- //
- // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.
- //
- return (EFI_SUCCESS);
-}
-
-/**
- Initialization function for HII packages.
-
-**/
-VOID
-HandleParsingHiiInit (VOID)
-{
- if (mHandleParsingHiiHandle == NULL) {
- mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL);
- ASSERT (mHandleParsingHiiHandle != NULL);
- }
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param[in] ImageHandle Ignored.
- @param[in] SystemTable Ignored.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HandleParsingLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINTN LoopCount;
-
- for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {
- SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);
- }
-
- SHELL_FREE_NON_NULL(GuidList);
- if (mHandleParsingHiiHandle != NULL) {
- HiiRemovePackages(mHandleParsingHiiHandle);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Function to dump information about LoadedImage.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has LoadedImage installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-LoadedImageProtocolDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- CHAR16 *Temp;
- CHAR16 *CodeType;
- CHAR16 *DataType;
-
- if (!Verbose) {
- return (CatSPrint(NULL, L"LoadedImage"));
- }
-
- HandleParsingHiiInit();
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);
- RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
- if (Temp == NULL || RetVal == NULL) {
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (Temp);
- SHELL_FREE_NON_NULL (RetVal);
- return NULL;
- }
-
- DataType = ConvertMemoryType(LoadedImage->ImageDataType);
- CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);
-
- RetVal = CatSPrint(RetVal,
- Temp,
- LoadedImage->Revision,
- LoadedImage->ParentHandle,
- LoadedImage->SystemTable,
- LoadedImage->DeviceHandle,
- LoadedImage->FilePath,
- LoadedImage->LoadOptionsSize,
- LoadedImage->LoadOptions,
- LoadedImage->ImageBase,
- LoadedImage->ImageSize,
- CodeType,
- DataType,
- LoadedImage->Unload);
-
-
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(CodeType);
- SHELL_FREE_NON_NULL(DataType);
-
- return RetVal;
-}
-
-/**
- Function to dump information about GOP.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has LoadedImage installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-GraphicsOutputProtocolDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- CHAR16 *Temp;
- CHAR16 *Fmt;
-
- if (!Verbose) {
- return (CatSPrint(NULL, L"GraphicsOutput"));
- }
-
- HandleParsingHiiInit();
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL);
- RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
- if (Temp == NULL || RetVal == NULL) {
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (Temp);
- SHELL_FREE_NON_NULL (RetVal);
- return NULL;
- }
-
- Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat);
-
- RetVal = CatSPrint(RetVal,
- Temp,
- GraphicsOutput->Mode->MaxMode,
- GraphicsOutput->Mode->Mode,
- GraphicsOutput->Mode->FrameBufferBase,
- (UINT64)GraphicsOutput->Mode->FrameBufferSize,
- (UINT64)GraphicsOutput->Mode->SizeOfInfo,
- GraphicsOutput->Mode->Info->Version,
- GraphicsOutput->Mode->Info->HorizontalResolution,
- GraphicsOutput->Mode->Info->VerticalResolution,
- Fmt,
- GraphicsOutput->Mode->Info->PixelsPerScanLine,
- GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask,
- GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask,
- GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask
- );
-
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(Fmt);
-
- return RetVal;
-}
-
-/**
- Function to dump information about PciRootBridgeIo.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has PciRootBridgeIo installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-PciRootBridgeIoDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;
- UINT64 Supports;
- UINT64 Attributes;
- CHAR16 *Temp;
- CHAR16 *Temp2;
- CHAR16 *RetVal;
- EFI_STATUS Status;
-
- RetVal = NULL;
-
- if (!Verbose) {
- return (CatSPrint(NULL, L"PciRootBridgeIo"));
- }
-
- HandleParsingHiiInit();
-
- Status = gBS->HandleProtocol(
- TheHandle,
- &gEfiPciRootBridgeIoProtocolGuid,
- (VOID**)&PciRootBridgeIo);
-
- if (EFI_ERROR(Status)) {
- return NULL;
- }
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_PH), NULL);
- if (Temp == NULL) {
- return NULL;
- }
- Temp2 = CatSPrint(L"\r\n", Temp, PciRootBridgeIo->ParentHandle);
- FreePool(Temp);
- RetVal = Temp2;
- Temp2 = NULL;
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SEG), NULL);
- if (Temp == NULL) {
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
- Temp2 = CatSPrint(RetVal, Temp, PciRootBridgeIo->SegmentNumber);
- FreePool(Temp);
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
-
- Supports = 0;
- Attributes = 0;
- Status = PciRootBridgeIo->GetAttributes (PciRootBridgeIo, &Supports, &Attributes);
- if (!EFI_ERROR(Status)) {
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_ATT), NULL);
- if (Temp == NULL) {
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
- Temp2 = CatSPrint(RetVal, Temp, Attributes);
- FreePool(Temp);
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS), NULL);
- if (Temp == NULL) {
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
- Temp2 = CatSPrint(RetVal, Temp, Supports);
- FreePool(Temp);
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
- }
-
- Configuration = NULL;
- Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Configuration);
- if (!EFI_ERROR(Status) && Configuration != NULL) {
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_TITLE), NULL);
- if (Temp == NULL) {
- SHELL_FREE_NON_NULL(RetVal);
- return NULL;
- }
- Temp2 = CatSPrint(RetVal, Temp, Supports);
- FreePool(Temp);
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
- while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
- Temp = NULL;
- switch (Configuration->ResType) {
- case ACPI_ADDRESS_SPACE_TYPE_MEM:
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_MEM), NULL);
- break;
- case ACPI_ADDRESS_SPACE_TYPE_IO:
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_IO), NULL);
- break;
- case ACPI_ADDRESS_SPACE_TYPE_BUS:
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_BUS), NULL);
- break;
- }
- if (Temp != NULL) {
- Temp2 = CatSPrint(RetVal, L"%s", Temp);
- FreePool(Temp);
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
- }
-
- Temp2 = CatSPrint(RetVal,
- L"%H%02x %016lx %016lx %02x%N\r\n",
- Configuration->SpecificFlag,
- Configuration->AddrRangeMin,
- Configuration->AddrRangeMax,
- Configuration->AddrSpaceGranularity
- );
- FreePool(RetVal);
- RetVal = Temp2;
- Temp2 = NULL;
- Configuration++;
- }
- }
- return (RetVal);
-}
-
-/**
- Function to dump information about SimpleTextOut.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has SimpleTextOut installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-TxtOutProtocolDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Dev;
- INTN Index;
- UINTN Col;
- UINTN Row;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- UINTN Size;
- CHAR16 *Temp;
- UINTN NewSize;
-
- if (!Verbose) {
- return (NULL);
- }
-
- HandleParsingHiiInit();
-
- RetVal = NULL;
- Size = 0;
-
- Status = gBS->HandleProtocol(
- TheHandle,
- &gEfiSimpleTextOutProtocolGuid,
- (VOID**)&Dev);
-
- ASSERT_EFI_ERROR(Status);
- ASSERT (Dev != NULL && Dev->Mode != NULL);
-
- Size = (Dev->Mode->MaxMode + 1) * 80;
- RetVal = AllocateZeroPool(Size);
-
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER), NULL);
- if (Temp != NULL) {
- UnicodeSPrint(RetVal, Size, Temp, Dev, Dev->Mode->Attribute);
- FreePool(Temp);
- }
-
- //
- // Dump TextOut Info
- //
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE), NULL);
- for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {
- Status = Dev->QueryMode (Dev, Index, &Col, &Row);
- NewSize = Size - StrSize(RetVal);
- UnicodeSPrint(
- RetVal + StrLen(RetVal),
- NewSize,
- Temp == NULL?L"":Temp,
- Index == Dev->Mode->Mode ? L'*' : L' ',
- Index,
- !EFI_ERROR(Status)?(INTN)Col:-1,
- !EFI_ERROR(Status)?(INTN)Row:-1
- );
- }
- FreePool(Temp);
- return (RetVal);
-}
-
-STATIC CONST UINTN VersionStringSize = 60;
-
-/**
- Function to dump information about EfiDriverSupportedEfiVersion protocol.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has the protocol installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-DriverEfiVersionProtocolDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;
- EFI_STATUS Status;
- CHAR16 *RetVal;
-
- Status = gBS->HandleProtocol(
- TheHandle,
- &gEfiDriverSupportedEfiVersionProtocolGuid,
- (VOID**)&DriverEfiVersion);
-
- ASSERT_EFI_ERROR(Status);
-
- RetVal = AllocateZeroPool(VersionStringSize);
- ASSERT(RetVal != NULL);
- UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
- return (RetVal);
-}
-
-/**
- Function to dump information about DevicePath protocol.
-
- This will allocate the return buffer from boot services pool.
-
- @param[in] TheHandle The handle that has the protocol installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A poitner to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-DevicePathProtocolDumpInformation(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- CHAR16 *Temp;
- CHAR16 *Temp2;
- EFI_STATUS Status;
- Temp = NULL;
-
- Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- //
- // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
- //
- Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);
- gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);
- }
- if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {
- Temp2 = NULL;
- Temp2 = StrnCatGrow(&Temp2, NULL, Temp+(StrLen(Temp) - 30), 30);
- FreePool(Temp);
- Temp = Temp2;
- }
- return (Temp);
-}
-
-/**
- Function to dump information about EfiAdapterInformation Protocol.
-
- @param[in] TheHandle The handle that has the protocol installed.
- @param[in] Verbose TRUE for additional information, FALSE otherwise.
-
- @retval A pointer to a string containing the information.
-**/
-CHAR16*
-EFIAPI
-AdapterInformationDumpInformation (
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- )
-{
- EFI_STATUS Status;
- EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol;
- UINTN InfoTypesBufferCount;
- UINTN GuidIndex;
- EFI_GUID *InfoTypesBuffer;
- CHAR16 *GuidStr;
- CHAR16 *TempStr;
- CHAR16 *RetVal;
- VOID *InformationBlock;
- UINTN InformationBlockSize;
-
- if (!Verbose) {
- return (CatSPrint(NULL, L"AdapterInfo"));
- }
-
- InfoTypesBuffer = NULL;
- InformationBlock = NULL;
-
- //
- // Allocate print buffer to store data
- //
- RetVal = AllocateZeroPool (PcdGet16(PcdShellPrintBufferSize));
- if (RetVal == NULL) {
- return NULL;
- }
-
- Status = gBS->OpenProtocol (
- (EFI_HANDLE) (TheHandle),
- &gEfiAdapterInformationProtocolGuid,
- (VOID **) &EfiAdptrInfoProtocol,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (RetVal);
- return NULL;
- }
-
- //
- // Get a list of supported information types for this instance of the protocol.
- //
- Status = EfiAdptrInfoProtocol->GetSupportedTypes (
- EfiAdptrInfoProtocol,
- &InfoTypesBuffer,
- &InfoTypesBufferCount
- );
- if (EFI_ERROR (Status)) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);
- if (TempStr != NULL) {
- RetVal = CatSPrint (RetVal, TempStr, Status);
- } else {
- goto ERROR_EXIT;
- }
- } else {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (RetVal, TempStr);
- SHELL_FREE_NON_NULL (TempStr);
-
- for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), InfoTypesBuffer[GuidIndex]);
- SHELL_FREE_NON_NULL (TempStr);
-
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
-
- if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {
- RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");
- } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {
- RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");
- } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {
- RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");
- } else {
-
- GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);
-
- if (GuidStr != NULL) {
- if (StrCmp(GuidStr, L"UnknownDevice") == 0) {
- RetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");
-
- SHELL_FREE_NON_NULL (TempStr);
- SHELL_FREE_NON_NULL(GuidStr);
- //
- // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
- //
- continue;
- } else {
- RetVal = CatSPrint (RetVal, TempStr, GuidStr);
- SHELL_FREE_NON_NULL(GuidStr);
- }
- }
- }
-
- SHELL_FREE_NON_NULL (TempStr);
-
- Status = EfiAdptrInfoProtocol->GetInformation (
- EfiAdptrInfoProtocol,
- &InfoTypesBuffer[GuidIndex],
- &InformationBlock,
- &InformationBlockSize
- );
-
- if (EFI_ERROR (Status)) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (RetVal, TempStr, Status);
- } else {
- if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (
- RetVal,
- TempStr,
- ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,
- ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState
- );
- } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (
- RetVal,
- TempStr,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,
- ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot
- );
- } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (
- RetVal,
- TempStr,
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0],
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1],
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3],
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4],
- ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]
- );
- } else {
- TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);
- if (TempStr == NULL) {
- goto ERROR_EXIT;
- }
- RetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);
- }
- }
- SHELL_FREE_NON_NULL (TempStr);
- SHELL_FREE_NON_NULL (InformationBlock);
- }
- }
-
- SHELL_FREE_NON_NULL (InfoTypesBuffer);
- return RetVal;
-
-ERROR_EXIT:
- SHELL_FREE_NON_NULL (RetVal);
- SHELL_FREE_NON_NULL (InfoTypesBuffer);
- SHELL_FREE_NON_NULL (InformationBlock);
- return NULL;
-}
-//
-// Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
-//
-#define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
- { \
- 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
- }
-
-#define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
- { \
- 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
- }
-
-#define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
- { \
- 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
- }
-STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;
-STATIC CONST EFI_GUID WinNtIoProtocolGuid = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;
-STATIC CONST EFI_GUID WinNtSerialPortGuid = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID;
-
-//
-// Deprecated protocols we dont want to link from IntelFrameworkModulePkg
-//
-#define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \
- { \
- 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
- }
-#define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \
- { \
- 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \
- }
-STATIC CONST EFI_GUID EfiIsaIoProtocolGuid = LOCAL_EFI_ISA_IO_PROTOCOL_GUID;
-STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid = LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID;
-
-
-STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
- {STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL},
- {STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_WINNT_SERIAL_PORT), (EFI_GUID*)&WinNtSerialPortGuid, NULL},
- {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},
-};
-
-STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
- {STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation},
- {STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
- {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
- {STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_TXT), &gEfiDevicePathToTextProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_FTXT), &gEfiDevicePathFromTextProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_PC), &gEfiPcAnsiGuid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_VT100), &gEfiVT100Guid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_VT100P), &gEfiVT100PlusGuid, NULL},
- {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8), &gEfiVTUTF8Guid, NULL},
- {STRING_TOKEN(STR_DRIVER_BINDING), &gEfiDriverBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_PLATFORM_OVERRIDE), &gEfiPlatformDriverOverrideProtocolGuid, NULL},
- {STRING_TOKEN(STR_BUS_OVERRIDE), &gEfiBusSpecificDriverOverrideProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_DIAG), &gEfiDriverDiagnosticsProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_DIAG2), &gEfiDriverDiagnostics2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_CN), &gEfiComponentNameProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_CN2), &gEfiComponentName2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_PLAT_DRV_CFG), &gEfiPlatformToDriverConfigurationProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_VERSION), &gEfiDriverSupportedEfiVersionProtocolGuid, DriverEfiVersionProtocolDumpInformation},
- {STRING_TOKEN(STR_TXT_IN), &gEfiSimpleTextInProtocolGuid, NULL},
- {STRING_TOKEN(STR_TXT_IN_EX), &gEfiSimpleTextInputExProtocolGuid, NULL},
- {STRING_TOKEN(STR_TXT_OUT), &gEfiSimpleTextOutProtocolGuid, TxtOutProtocolDumpInformation},
- {STRING_TOKEN(STR_SIM_POINTER), &gEfiSimplePointerProtocolGuid, NULL},
- {STRING_TOKEN(STR_ABS_POINTER), &gEfiAbsolutePointerProtocolGuid, NULL},
- {STRING_TOKEN(STR_SERIAL_IO), &gEfiSerialIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_GRAPHICS_OUTPUT), &gEfiGraphicsOutputProtocolGuid, GraphicsOutputProtocolDumpInformation},
- {STRING_TOKEN(STR_EDID_DISCOVERED), &gEfiEdidDiscoveredProtocolGuid, NULL},
- {STRING_TOKEN(STR_EDID_ACTIVE), &gEfiEdidActiveProtocolGuid, NULL},
- {STRING_TOKEN(STR_EDID_OVERRIDE), &gEfiEdidOverrideProtocolGuid, NULL},
- {STRING_TOKEN(STR_CON_IN), &gEfiConsoleInDeviceGuid, NULL},
- {STRING_TOKEN(STR_CON_OUT), &gEfiConsoleOutDeviceGuid, NULL},
- {STRING_TOKEN(STR_STD_ERR), &gEfiStandardErrorDeviceGuid, NULL},
- {STRING_TOKEN(STR_LOAD_FILE), &gEfiLoadFileProtocolGuid, NULL},
- {STRING_TOKEN(STR_LOAD_FILE2), &gEfiLoadFile2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_SIMPLE_FILE_SYS), &gEfiSimpleFileSystemProtocolGuid, NULL},
- {STRING_TOKEN(STR_TAPE_IO), &gEfiTapeIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_DISK_IO), &gEfiDiskIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_BLK_IO), &gEfiBlockIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_UC), &gEfiUnicodeCollationProtocolGuid, NULL},
- {STRING_TOKEN(STR_UC2), &gEfiUnicodeCollation2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_PCIRB_IO), &gEfiPciRootBridgeIoProtocolGuid, PciRootBridgeIoDumpInformation},
- {STRING_TOKEN(STR_PCI_IO), &gEfiPciIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_SCSI_PT), &gEfiScsiPassThruProtocolGuid, NULL},
- {STRING_TOKEN(STR_SCSI_IO), &gEfiScsiIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_SCSI_PT_EXT), &gEfiExtScsiPassThruProtocolGuid, NULL},
- {STRING_TOKEN(STR_ISCSI), &gEfiIScsiInitiatorNameProtocolGuid, NULL},
- {STRING_TOKEN(STR_USB_IO), &gEfiUsbIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_USB_HC), &gEfiUsbHcProtocolGuid, NULL},
- {STRING_TOKEN(STR_USB_HC2), &gEfiUsb2HcProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEBUG_PORT), &gEfiDebugPortProtocolGuid, NULL},
- {STRING_TOKEN(STR_DECOMPRESS), &gEfiDecompressProtocolGuid, NULL},
- {STRING_TOKEN(STR_ACPI_TABLE), &gEfiAcpiTableProtocolGuid, NULL},
- {STRING_TOKEN(STR_EBC_INTERPRETER), &gEfiEbcProtocolGuid, NULL},
- {STRING_TOKEN(STR_SNP), &gEfiSimpleNetworkProtocolGuid, NULL},
- {STRING_TOKEN(STR_NII), &gEfiNetworkInterfaceIdentifierProtocolGuid, NULL},
- {STRING_TOKEN(STR_NII_31), &gEfiNetworkInterfaceIdentifierProtocolGuid_31, NULL},
- {STRING_TOKEN(STR_PXE_BC), &gEfiPxeBaseCodeProtocolGuid, NULL},
- {STRING_TOKEN(STR_PXE_CB), &gEfiPxeBaseCodeCallbackProtocolGuid, NULL},
- {STRING_TOKEN(STR_BIS), &gEfiBisProtocolGuid, NULL},
- {STRING_TOKEN(STR_MNP_SB), &gEfiManagedNetworkServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_MNP), &gEfiManagedNetworkProtocolGuid, NULL},
- {STRING_TOKEN(STR_ARP_SB), &gEfiArpServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_ARP), &gEfiArpProtocolGuid, NULL},
- {STRING_TOKEN(STR_DHCPV4_SB), &gEfiDhcp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_DHCPV4), &gEfiDhcp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_TCPV4_SB), &gEfiTcp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_TCPV4), &gEfiTcp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_IPV4_SB), &gEfiIp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_IPV4), &gEfiIp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_IPV4_CFG), &gEfiIp4ConfigProtocolGuid, NULL},
- {STRING_TOKEN(STR_IPV4_CFG2), &gEfiIp4Config2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_UDPV4_SB), &gEfiUdp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_UDPV4), &gEfiUdp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_MTFTPV4_SB), &gEfiMtftp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_MTFTPV4), &gEfiMtftp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_AUTH_INFO), &gEfiAuthenticationInfoProtocolGuid, NULL},
- {STRING_TOKEN(STR_HASH_SB), &gEfiHashServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_HASH), &gEfiHashProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_FONT), &gEfiHiiFontProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_STRING), &gEfiHiiStringProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_IMAGE), &gEfiHiiImageProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_DATABASE), &gEfiHiiDatabaseProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_CONFIG_ROUT), &gEfiHiiConfigRoutingProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_CONFIG_ACC), &gEfiHiiConfigAccessProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_FORM_BROWSER2), &gEfiFormBrowser2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE), &gEfiDriverFamilyOverrideProtocolGuid, NULL},
- {STRING_TOKEN(STR_PCD), &gPcdProtocolGuid, NULL},
- {STRING_TOKEN(STR_TCG), &gEfiTcgProtocolGuid, NULL},
- {STRING_TOKEN(STR_HII_PACKAGE_LIST), &gEfiHiiPackageListProtocolGuid, NULL},
-
-//
-// the ones under this are deprecated by the current UEFI Spec, but may be found anyways...
-//
- {STRING_TOKEN(STR_SHELL_INTERFACE), &gEfiShellInterfaceGuid, NULL},
- {STRING_TOKEN(STR_SHELL_ENV2), &gEfiShellEnvironment2Guid, NULL},
- {STRING_TOKEN(STR_SHELL_ENV), &gEfiShellEnvironment2Guid, NULL},
- {STRING_TOKEN(STR_DEVICE_IO), &gEfiDeviceIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_UGA_DRAW), &gEfiUgaDrawProtocolGuid, NULL},
- {STRING_TOKEN(STR_UGA_IO), &gEfiUgaIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_ESP), &gEfiPartTypeSystemPartGuid, NULL},
- {STRING_TOKEN(STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL},
- {STRING_TOKEN(STR_DRIVER_CONFIG2), &gEfiDriverConfiguration2ProtocolGuid, NULL},
-
-//
-// these are using local (non-global) definitions to reduce package dependancy.
-//
- {STRING_TOKEN(STR_ISA_IO), (EFI_GUID*)&EfiIsaIoProtocolGuid, NULL},
- {STRING_TOKEN(STR_ISA_ACPI), (EFI_GUID*)&EfiIsaAcpiProtocolGuid, NULL},
-
-//
-// the ones under this are GUID identified structs, not protocols
-//
- {STRING_TOKEN(STR_FILE_INFO), &gEfiFileInfoGuid, NULL},
- {STRING_TOKEN(STR_FILE_SYS_INFO), &gEfiFileSystemInfoGuid, NULL},
-
-//
-// the ones under this are misc GUIDS.
-//
- {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE), &gEfiGlobalVariableGuid, NULL},
-
-//
-// UEFI 2.2
-//
- {STRING_TOKEN(STR_IP6_SB), &gEfiIp6ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_IP6), &gEfiIp6ProtocolGuid, NULL},
- {STRING_TOKEN(STR_IP6_CONFIG), &gEfiIp6ConfigProtocolGuid, NULL},
- {STRING_TOKEN(STR_MTFTP6_SB), &gEfiMtftp6ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_MTFTP6), &gEfiMtftp6ProtocolGuid, NULL},
- {STRING_TOKEN(STR_DHCP6_SB), &gEfiDhcp6ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_DHCP6), &gEfiDhcp6ProtocolGuid, NULL},
- {STRING_TOKEN(STR_UDP6_SB), &gEfiUdp6ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_UDP6), &gEfiUdp6ProtocolGuid, NULL},
- {STRING_TOKEN(STR_TCP6_SB), &gEfiTcp6ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_TCP6), &gEfiTcp6ProtocolGuid, NULL},
- {STRING_TOKEN(STR_VLAN_CONFIG), &gEfiVlanConfigProtocolGuid, NULL},
- {STRING_TOKEN(STR_EAP), &gEfiEapProtocolGuid, NULL},
- {STRING_TOKEN(STR_EAP_MGMT), &gEfiEapManagementProtocolGuid, NULL},
- {STRING_TOKEN(STR_FTP4_SB), &gEfiFtp4ServiceBindingProtocolGuid, NULL},
- {STRING_TOKEN(STR_FTP4), &gEfiFtp4ProtocolGuid, NULL},
- {STRING_TOKEN(STR_IP_SEC_CONFIG), &gEfiIpSecConfigProtocolGuid, NULL},
- {STRING_TOKEN(STR_DH), &gEfiDriverHealthProtocolGuid, NULL},
- {STRING_TOKEN(STR_DEF_IMG_LOAD), &gEfiDeferredImageLoadProtocolGuid, NULL},
- {STRING_TOKEN(STR_USER_CRED), &gEfiUserCredentialProtocolGuid, NULL},
- {STRING_TOKEN(STR_USER_MNGR), &gEfiUserManagerProtocolGuid, NULL},
- {STRING_TOKEN(STR_ATA_PASS_THRU), &gEfiAtaPassThruProtocolGuid, NULL},
-
-//
-// UEFI 2.3
-//
- {STRING_TOKEN(STR_FW_MGMT), &gEfiFirmwareManagementProtocolGuid, NULL},
- {STRING_TOKEN(STR_IP_SEC), &gEfiIpSecProtocolGuid, NULL},
- {STRING_TOKEN(STR_IP_SEC2), &gEfiIpSec2ProtocolGuid, NULL},
-
-//
-// UEFI 2.3.1
-//
- {STRING_TOKEN(STR_KMS), &gEfiKmsProtocolGuid, NULL},
- {STRING_TOKEN(STR_BLK_IO2), &gEfiBlockIo2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_SSC), &gEfiStorageSecurityCommandProtocolGuid, NULL},
- {STRING_TOKEN(STR_UCRED2), &gEfiUserCredential2ProtocolGuid, NULL},
-
-//
-// UEFI 2.4
-//
- {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL},
- {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation},
-
-//
-// PI Spec ones
-//
- {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL},
- {STRING_TOKEN(STR_DISK_INFO), &gEfiDiskInfoProtocolGuid, NULL},
-
-//
-// UEFI Shell Spec 2.0
-//
- {STRING_TOKEN(STR_SHELL_PARAMETERS), &gEfiShellParametersProtocolGuid, NULL},
- {STRING_TOKEN(STR_SHELL), &gEfiShellProtocolGuid, NULL},
-
-//
-// UEFI Shell Spec 2.1
-//
- {STRING_TOKEN(STR_SHELL_DYNAMIC), &gEfiShellDynamicCommandProtocolGuid, NULL},
-
-//
-// terminator
-//
- {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},
-};
-
-/**
- Function to get the node for a protocol or struct from it's GUID.
-
- if Guid is NULL, then ASSERT.
-
- @param[in] Guid The GUID to look for the name of.
-
- @return The node.
-**/
-CONST GUID_INFO_BLOCK *
-EFIAPI
-InternalShellGetNodeFromGuid(
- IN CONST EFI_GUID* Guid
- )
-{
- CONST GUID_INFO_BLOCK *ListWalker;
- UINTN LoopCount;
-
- ASSERT(Guid != NULL);
-
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
- if (CompareGuid(ListWalker->GuidId, Guid)) {
- return (ListWalker);
- }
- }
-
- if (PcdGetBool(PcdShellIncludeNtGuids)) {
- for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
- if (CompareGuid(ListWalker->GuidId, Guid)) {
- return (ListWalker);
- }
- }
- }
- for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
- if (CompareGuid(ListWalker->GuidId, Guid)) {
- return (ListWalker);
- }
- }
- return (NULL);
-}
-
-/**
-Function to add a new GUID/Name mapping.
-
-@param[in] Guid The Guid
-@param[in] NameID The STRING id of the HII string to use
-@param[in] DumpFunc The pointer to the dump function
-
-
-@retval EFI_SUCCESS The operation was sucessful
-@retval EFI_OUT_OF_RESOURCES A memory allocation failed
-@retval EFI_INVALID_PARAMETER Guid NameId was invalid
-**/
-EFI_STATUS
-EFIAPI
-InsertNewGuidNameMapping(
- IN CONST EFI_GUID *Guid,
- IN CONST EFI_STRING_ID NameID,
- IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL
- )
-{
- ASSERT(Guid != NULL);
- ASSERT(NameID != 0);
-
- GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);
- if (GuidList == NULL) {
- GuidListCount = 0;
- return (EFI_OUT_OF_RESOURCES);
- }
- GuidListCount++;
-
- GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);
- GuidList[GuidListCount - 1].StringId = NameID;
- GuidList[GuidListCount - 1].DumpInfo = DumpFunc;
-
- if (GuidList[GuidListCount - 1].GuidId == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to add a new GUID/Name mapping.
-
- This cannot overwrite an existing mapping.
-
- @param[in] Guid The Guid
- @param[in] TheName The Guid's name
- @param[in] Lang RFC4646 language code list or NULL
-
- @retval EFI_SUCCESS The operation was sucessful
- @retval EFI_ACCESS_DENIED There was a duplicate
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed
- @retval EFI_INVALID_PARAMETER Guid or TheName was NULL
-**/
-EFI_STATUS
-EFIAPI
-AddNewGuidNameMapping(
- IN CONST EFI_GUID *Guid,
- IN CONST CHAR16 *TheName,
- IN CONST CHAR8 *Lang OPTIONAL
- )
-{
- EFI_STRING_ID NameID;
-
- HandleParsingHiiInit();
-
- if (Guid == NULL || TheName == NULL){
- return (EFI_INVALID_PARAMETER);
- }
-
- if ((InternalShellGetNodeFromGuid(Guid)) != NULL) {
- return (EFI_ACCESS_DENIED);
- }
-
- NameID = HiiSetString(mHandleParsingHiiHandle, 0, (CHAR16*)TheName, Lang);
- if (NameID == 0) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- return (InsertNewGuidNameMapping(Guid, NameID, NULL));
-}
-
-/**
- Function to get the name of a protocol or struct from it's GUID.
-
- if Guid is NULL, then ASSERT.
-
- @param[in] Guid The GUID to look for the name of.
- @param[in] Lang The language to use.
-
- @return pointer to string of the name. The caller
- is responsible to free this memory.
-**/
-CHAR16*
-EFIAPI
-GetStringNameFromGuid(
- IN CONST EFI_GUID *Guid,
- IN CONST CHAR8 *Lang OPTIONAL
- )
-{
- CONST GUID_INFO_BLOCK *Id;
-
- HandleParsingHiiInit();
-
- Id = InternalShellGetNodeFromGuid(Guid);
- return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));
-}
-
-/**
- Function to dump protocol information from a handle.
-
- This function will return a allocated string buffer containing the
- information. The caller is responsible for freeing the memory.
-
- If Guid is NULL, ASSERT().
- If TheHandle is NULL, ASSERT().
-
- @param[in] TheHandle The handle to dump information from.
- @param[in] Guid The GUID of the protocol to dump.
- @param[in] Verbose TRUE for extra info. FALSE otherwise.
-
- @return The pointer to string.
- @retval NULL An error was encountered.
-**/
-CHAR16*
-EFIAPI
-GetProtocolInformationDump(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST EFI_GUID *Guid,
- IN CONST BOOLEAN Verbose
- )
-{
- CONST GUID_INFO_BLOCK *Id;
-
- ASSERT(TheHandle != NULL);
- ASSERT(Guid != NULL);
-
- if (TheHandle == NULL || Guid == NULL) {
- return (NULL);
- }
-
- Id = InternalShellGetNodeFromGuid(Guid);
- if (Id != NULL && Id->DumpInfo != NULL) {
- return (Id->DumpInfo(TheHandle, Verbose));
- }
- return (NULL);
-}
-
-/**
- Function to get the Guid for a protocol or struct based on it's string name.
-
- do not modify the returned Guid.
-
- @param[in] Name The pointer to the string name.
- @param[in] Lang The pointer to the language code.
- @param[out] Guid The pointer to the Guid.
-
- @retval EFI_SUCCESS The operation was sucessful.
-**/
-EFI_STATUS
-EFIAPI
-GetGuidFromStringName(
- IN CONST CHAR16 *Name,
- IN CONST CHAR8 *Lang OPTIONAL,
- OUT EFI_GUID **Guid
- )
-{
- CONST GUID_INFO_BLOCK *ListWalker;
- CHAR16 *String;
- UINTN LoopCount;
-
- HandleParsingHiiInit();
-
- ASSERT(Guid != NULL);
- if (Guid == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- *Guid = NULL;
-
- if (PcdGetBool(PcdShellIncludeNtGuids)) {
- for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
- String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
- if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
- *Guid = ListWalker->GuidId;
- }
- SHELL_FREE_NON_NULL(String);
- if (*Guid != NULL) {
- return (EFI_SUCCESS);
- }
- }
- }
- for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
- String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
- if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
- *Guid = ListWalker->GuidId;
- }
- SHELL_FREE_NON_NULL(String);
- if (*Guid != NULL) {
- return (EFI_SUCCESS);
- }
- }
-
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
- String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
- if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
- *Guid = ListWalker->GuidId;
- }
- SHELL_FREE_NON_NULL(String);
- if (*Guid != NULL) {
- return (EFI_SUCCESS);
- }
- }
-
- return (EFI_NOT_FOUND);
-}
-
-/**
- Get best support language for this driver.
-
- First base on the user input language to search, second base on the current
- platform used language to search, third get the first language from the
- support language list. The caller need to free the buffer of the best language.
-
- @param[in] SupportedLanguages The support languages for this driver.
- @param[in] InputLanguage The user input language.
- @param[in] Iso639Language Whether get language for ISO639.
-
- @return The best support language for this driver.
-**/
-CHAR8 *
-EFIAPI
-GetBestLanguageForDriver (
- IN CONST CHAR8 *SupportedLanguages,
- IN CONST CHAR8 *InputLanguage,
- IN BOOLEAN Iso639Language
- )
-{
- CHAR8 *LanguageVariable;
- CHAR8 *BestLanguage;
-
- GetVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&LanguageVariable, NULL);
-
- BestLanguage = GetBestLanguage(
- SupportedLanguages,
- Iso639Language,
- (InputLanguage != NULL) ? InputLanguage : "",
- (LanguageVariable != NULL) ? LanguageVariable : "",
- SupportedLanguages,
- NULL
- );
-
- if (LanguageVariable != NULL) {
- FreePool (LanguageVariable);
- }
-
- return BestLanguage;
-}
-
-/**
- Function to retrieve the driver name (if possible) from the ComponentName or
- ComponentName2 protocol
-
- @param[in] TheHandle The driver handle to get the name of.
- @param[in] Language The language to use.
-
- @retval NULL The name could not be found.
- @return A pointer to the string name. Do not de-allocate the memory.
-**/
-CONST CHAR16*
-EFIAPI
-GetStringNameFromHandle(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST CHAR8 *Language
- )
-{
- EFI_COMPONENT_NAME2_PROTOCOL *CompNameStruct;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- CHAR8 *BestLang;
-
- BestLang = NULL;
-
- Status = gBS->OpenProtocol(
- TheHandle,
- &gEfiComponentName2ProtocolGuid,
- (VOID**)&CompNameStruct,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
- Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
- if (BestLang != NULL) {
- FreePool (BestLang);
- BestLang = NULL;
- }
- if (!EFI_ERROR(Status)) {
- return (RetVal);
- }
- }
- Status = gBS->OpenProtocol(
- TheHandle,
- &gEfiComponentNameProtocolGuid,
- (VOID**)&CompNameStruct,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
- Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
- if (BestLang != NULL) {
- FreePool (BestLang);
- }
- if (!EFI_ERROR(Status)) {
- return (RetVal);
- }
- }
- return (NULL);
-}
-
-/**
- Function to initialize the file global mHandleList object for use in
- vonverting handles to index and index to handle.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellInitHandleList(
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- HANDLE_LIST *ListWalker;
-
- if (mHandleList.NextIndex != 0) {
- return EFI_SUCCESS;
- }
- InitializeListHead(&mHandleList.List.Link);
- mHandleList.NextIndex = 1;
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) {
- return (Status);
- }
- for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){
- ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
- ASSERT(ListWalker != NULL);
- ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];
- ListWalker->TheIndex = mHandleList.NextIndex;
- InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
- }
- FreePool(HandleBuffer);
- return (EFI_SUCCESS);
-}
-
-/**
- Function to retrieve the human-friendly index of a given handle. If the handle
- does not have a index one will be automatically assigned. The index value is valid
- until the termination of the shell application.
-
- @param[in] TheHandle The handle to retrieve an index for.
-
- @retval 0 A memory allocation failed.
- @return The index of the handle.
-
-**/
-UINTN
-EFIAPI
-ConvertHandleToHandleIndex(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- EFI_GUID **ProtocolBuffer;
- UINTN ProtocolCount;
- HANDLE_LIST *ListWalker;
-
- if (TheHandle == NULL) {
- return 0;
- }
-
- InternalShellInitHandleList();
-
- for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
- ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
- ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
- ){
- if (ListWalker->TheHandle == TheHandle) {
- //
- // Verify that TheHandle is still present in the Handle Database
- //
- Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
- if (EFI_ERROR (Status)) {
- //
- // TheHandle is not present in the Handle Database, so delete from the handle list
- //
- RemoveEntryList (&ListWalker->Link);
- return 0;
- }
- FreePool (ProtocolBuffer);
- return (ListWalker->TheIndex);
- }
- }
-
- //
- // Verify that TheHandle is valid handle
- //
- Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
- if (EFI_ERROR (Status)) {
- //
- // TheHandle is not valid, so do not add to handle list
- //
- return 0;
- }
- FreePool (ProtocolBuffer);
-
- ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
- ASSERT(ListWalker != NULL);
- ListWalker->TheHandle = TheHandle;
- ListWalker->TheIndex = mHandleList.NextIndex++;
- InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
- return (ListWalker->TheIndex);
-}
-
-
-
-/**
- Function to retrieve the EFI_HANDLE from the human-friendly index.
-
- @param[in] TheIndex The index to retrieve the EFI_HANDLE for.
-
- @retval NULL The index was invalid.
- @return The EFI_HANDLE that index represents.
-
-**/
-EFI_HANDLE
-EFIAPI
-ConvertHandleIndexToHandle(
- IN CONST UINTN TheIndex
- )
-{
- EFI_STATUS Status;
- EFI_GUID **ProtocolBuffer;
- UINTN ProtocolCount;
- HANDLE_LIST *ListWalker;
-
- InternalShellInitHandleList();
-
- if (TheIndex >= mHandleList.NextIndex) {
- return NULL;
- }
-
- for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
- ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
- ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
- ){
- if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {
- //
- // Verify that LinkWalker->TheHandle is valid handle
- //
- Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);
- if (EFI_ERROR (Status)) {
- //
- // TheHandle is not valid, so do not add to handle list
- //
- ListWalker->TheHandle = NULL;
- }
- return (ListWalker->TheHandle);
- }
- }
- return NULL;
-}
-
-/**
- Gets all the related EFI_HANDLEs based on the mask supplied.
-
- This function scans all EFI_HANDLES in the UEFI environment's handle database
- and returns the ones with the specified relationship (Mask) to the specified
- controller handle.
-
- If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
- If MatchingHandleCount is NULL, then ASSERT.
-
- If MatchingHandleBuffer is not NULL upon a successful return the memory must be
- caller freed.
-
- @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.
- @param[in] ControllerHandle The handle with Device Path protocol on it.
- @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in
- MatchingHandleBuffer.
- @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount
- EFI_HANDLEs with a terminating NULL EFI_HANDLE.
- @param[out] HandleType An array of type information.
-
- @retval EFI_SUCCESS The operation was successful, and any related handles
- are in MatchingHandleBuffer.
- @retval EFI_NOT_FOUND No matching handles were found.
- @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
-**/
-EFI_STATUS
-EFIAPI
-ParseHandleDatabaseByRelationshipWithType (
- IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
- IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
- IN UINTN *HandleCount,
- OUT EFI_HANDLE **HandleBuffer,
- OUT UINTN **HandleType
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
- UINTN OpenInfoCount;
- UINTN OpenInfoIndex;
- UINTN ChildIndex;
- INTN DriverBindingHandleIndex;
-
- ASSERT(HandleCount != NULL);
- ASSERT(HandleBuffer != NULL);
- ASSERT(HandleType != NULL);
- ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);
-
- *HandleCount = 0;
- *HandleBuffer = NULL;
- *HandleType = NULL;
-
- //
- // Retrieve the list of all handles from the handle database
- //
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- HandleCount,
- HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return (Status);
- }
-
- *HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
- ASSERT(*HandleType != NULL);
-
- DriverBindingHandleIndex = -1;
- for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
- if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {
- DriverBindingHandleIndex = (INTN)HandleIndex;
- }
- }
-
- for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
- //
- // Retrieve the list of all the protocols on each handle
- //
- Status = gBS->ProtocolsPerHandle (
- (*HandleBuffer)[HandleIndex],
- &ProtocolGuidArray,
- &ArrayCount
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
-
- //
- // Set the bit describing what this handle has
- //
- if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_IMAGE_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_BINDING_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= (UINTN)HR_DEVICE_HANDLE;
- } else {
- DEBUG_CODE_BEGIN();
- ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
- DEBUG_CODE_END();
- }
- //
- // Retrieve the list of agents that have opened each protocol
- //
- Status = gBS->OpenProtocolInformation (
- (*HandleBuffer)[HandleIndex],
- ProtocolGuidArray[ProtocolIndex],
- &OpenInfo,
- &OpenInfoCount
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (ControllerHandle == NULL) {
- //
- // ControllerHandle == NULL and DriverBindingHandle != NULL.
- // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
- //
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
- if (DriverBindingHandleIndex != -1) {
- (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;
- }
- }
- if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
- if (DriverBindingHandleIndex != -1) {
- (*HandleType)[DriverBindingHandleIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
- }
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
- }
- }
- }
- }
- }
- if (DriverBindingHandle == NULL && ControllerHandle != NULL) {
- if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)HR_DEVICE_DRIVER;
- }
- }
- }
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
- }
- if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
- }
- }
- }
- }
- } else {
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
- }
- }
- }
- }
- }
- if (DriverBindingHandle != NULL && ControllerHandle != NULL) {
- if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
- if (DriverBindingHandleIndex != -1) {
- (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;
- }
- }
- }
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
- }
- }
- }
-
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
- (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);
- }
- }
- }
- }
- } else {
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
- (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
- }
- }
- }
- }
- }
- FreePool (OpenInfo);
- }
- FreePool (ProtocolGuidArray);
- }
- return EFI_SUCCESS;
-}
-
-/**
- Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask
- supplied.
-
- This function will scan all EFI_HANDLES in the UEFI environment's handle database
- and return all the ones with the specified relationship (Mask) to the specified
- controller handle.
-
- If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.
- If MatchingHandleCount is NULL, then ASSERT.
-
- If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be
- caller freed.
-
- @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol
- on it.
- @param[in] ControllerHandle Handle to a device with Device Path protocol on it.
- @param[in] Mask Mask of what relationship(s) is desired.
- @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in
- MatchingHandleBuffer.
- @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount
- EFI_HANDLEs and a terminating NULL EFI_HANDLE.
-
- @retval EFI_SUCCESS The operation was sucessful and any related handles
- are in MatchingHandleBuffer;
- @retval EFI_NOT_FOUND No matching handles were found.
- @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.
-**/
-EFI_STATUS
-EFIAPI
-ParseHandleDatabaseByRelationship (
- IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,
- IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
- IN CONST UINTN Mask,
- IN UINTN *MatchingHandleCount,
- OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN *HandleType;
- UINTN HandleIndex;
-
- ASSERT(MatchingHandleCount != NULL);
- ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);
-
- if ((Mask & HR_VALID_MASK) != Mask) {
- return (EFI_INVALID_PARAMETER);
- }
-
- if ((Mask & HR_CHILD_HANDLE) != 0 && DriverBindingHandle == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- *MatchingHandleCount = 0;
- if (MatchingHandleBuffer != NULL) {
- *MatchingHandleBuffer = NULL;
- }
-
- HandleBuffer = NULL;
- HandleType = NULL;
-
- Status = ParseHandleDatabaseByRelationshipWithType (
- DriverBindingHandle,
- ControllerHandle,
- &HandleCount,
- &HandleBuffer,
- &HandleType
- );
- if (!EFI_ERROR (Status)) {
- //
- // Count the number of handles that match the attributes in Mask
- //
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- if ((HandleType[HandleIndex] & Mask) == Mask) {
- (*MatchingHandleCount)++;
- }
- }
- //
- // If no handles match the attributes in Mask then return EFI_NOT_FOUND
- //
- if (*MatchingHandleCount == 0) {
- Status = EFI_NOT_FOUND;
- } else {
-
- if (MatchingHandleBuffer == NULL) {
- //
- // Someone just wanted the count...
- //
- Status = EFI_SUCCESS;
- } else {
- //
- // Allocate a handle buffer for the number of handles that matched the attributes in Mask
- //
- *MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));
- ASSERT(*MatchingHandleBuffer != NULL);
-
- for (HandleIndex = 0,*MatchingHandleCount = 0
- ; HandleIndex < HandleCount
- ; HandleIndex++
- ){
- //
- // Fill the allocated buffer with the handles that matched the attributes in Mask
- //
- if ((HandleType[HandleIndex] & Mask) == Mask) {
- (*MatchingHandleBuffer)[(*MatchingHandleCount)++] = HandleBuffer[HandleIndex];
- }
- }
-
- //
- // Make the last one NULL
- //
- (*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;
-
- Status = EFI_SUCCESS;
- } // MacthingHandleBuffer == NULL (ELSE)
- } // *MatchingHandleCount == 0 (ELSE)
- } // no error on ParseHandleDatabaseByRelationshipWithType
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- if (HandleType != NULL) {
- FreePool (HandleType);
- }
-
- return Status;
-}
-
-/**
- Gets handles for any child controllers of the passed in controller.
-
- @param[in] ControllerHandle The handle of the "parent controller"
- @param[in] MatchingHandleCount Pointer to the number of handles in
- MatchingHandleBuffer on return.
- @param[out] MatchingHandleBuffer Buffer containing handles on a successful
- return.
-
-
- @retval EFI_SUCCESS The operation was sucessful.
-**/
-EFI_STATUS
-EFIAPI
-ParseHandleDatabaseForChildControllers(
- IN CONST EFI_HANDLE ControllerHandle,
- IN UINTN *MatchingHandleCount,
- OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- UINTN DriverBindingHandleCount;
- EFI_HANDLE *DriverBindingHandleBuffer;
- UINTN DriverBindingHandleIndex;
- UINTN ChildControllerHandleCount;
- EFI_HANDLE *ChildControllerHandleBuffer;
- UINTN ChildControllerHandleIndex;
- EFI_HANDLE *HandleBufferForReturn;
-
- if (MatchingHandleCount == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- *MatchingHandleCount = 0;
-
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
- ControllerHandle,
- &DriverBindingHandleCount,
- &DriverBindingHandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get a buffer big enough for all the controllers.
- //
- HandleBufferForReturn = GetHandleListByProtocol(NULL);
- if (HandleBufferForReturn == NULL) {
- FreePool (DriverBindingHandleBuffer);
- return (EFI_NOT_FOUND);
- }
-
- for (DriverBindingHandleIndex = 0; DriverBindingHandleIndex < DriverBindingHandleCount; DriverBindingHandleIndex++) {
- Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
- DriverBindingHandleBuffer[DriverBindingHandleIndex],
- ControllerHandle,
- &ChildControllerHandleCount,
- &ChildControllerHandleBuffer
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- for (ChildControllerHandleIndex = 0;
- ChildControllerHandleIndex < ChildControllerHandleCount;
- ChildControllerHandleIndex++
- ) {
- for (HandleIndex = 0; HandleIndex < *MatchingHandleCount; HandleIndex++) {
- if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
- break;
- }
- }
- if (HandleIndex >= *MatchingHandleCount) {
- HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
- }
- }
-
- FreePool (ChildControllerHandleBuffer);
- }
-
- FreePool (DriverBindingHandleBuffer);
-
- if (MatchingHandleBuffer != NULL) {
- *MatchingHandleBuffer = HandleBufferForReturn;
- } else {
- FreePool(HandleBufferForReturn);
- }
-
- return (EFI_SUCCESS);
-}
-
-/**
- Appends 1 buffer to another buffer. This will re-allocate the destination buffer
- if necessary to fit all of the data.
-
- If DestinationBuffer is NULL, then ASSERT().
-
- @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.
- @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.
- @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.
- @param[in] SourceSize The number of bytes of SourceBuffer to append.
-
- @retval NULL A memory allocation failed.
- @retval NULL A parameter was invalid.
- @return A pointer to (*DestinationBuffer).
-**/
-VOID*
-EFIAPI
-BuffernCatGrow (
- IN OUT VOID **DestinationBuffer,
- IN OUT UINTN *DestinationSize,
- IN VOID *SourceBuffer,
- IN UINTN SourceSize
- )
-{
- UINTN LocalDestinationSize;
- UINTN LocalDestinationFinalSize;
-
- ASSERT(DestinationBuffer != NULL);
-
- if (SourceSize == 0 || SourceBuffer == NULL) {
- return (*DestinationBuffer);
- }
-
- if (DestinationSize == NULL) {
- LocalDestinationSize = 0;
- } else {
- LocalDestinationSize = *DestinationSize;
- }
-
- LocalDestinationFinalSize = LocalDestinationSize + SourceSize;
-
- if (DestinationSize != NULL) {
- *DestinationSize = LocalDestinationSize;
- }
-
- if (LocalDestinationSize == 0) {
- // allcoate
- *DestinationBuffer = AllocateZeroPool(LocalDestinationFinalSize);
- } else {
- // reallocate
- *DestinationBuffer = ReallocatePool(LocalDestinationSize, LocalDestinationFinalSize, *DestinationBuffer);
- }
-
- ASSERT(*DestinationBuffer != NULL);
-
- // copy
- return (CopyMem(((UINT8*)(*DestinationBuffer)) + LocalDestinationSize, SourceBuffer, SourceSize));
-}
-
-/**
- Gets handles for any child devices produced by the passed in driver.
-
- @param[in] DriverHandle The handle of the driver.
- @param[in] MatchingHandleCount Pointer to the number of handles in
- MatchingHandleBuffer on return.
- @param[out] MatchingHandleBuffer Buffer containing handles on a successful
- return.
- @retval EFI_SUCCESS The operation was sucessful.
- @sa ParseHandleDatabaseByRelationship
-**/
-EFI_STATUS
-EFIAPI
-ParseHandleDatabaseForChildDevices(
- IN CONST EFI_HANDLE DriverHandle,
- IN UINTN *MatchingHandleCount,
- OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL
- )
-{
- EFI_HANDLE *Buffer;
- EFI_HANDLE *Buffer2;
- UINTN Count1;
- UINTN Count2;
- UINTN HandleIndex;
- EFI_STATUS Status;
- UINTN HandleBufferSize;
-
- ASSERT(MatchingHandleCount != NULL);
-
- HandleBufferSize = 0;
- Buffer = NULL;
- Buffer2 = NULL;
- *MatchingHandleCount = 0;
-
- Status = PARSE_HANDLE_DATABASE_DEVICES (
- DriverHandle,
- &Count1,
- &Buffer
- );
- if (!EFI_ERROR (Status)) {
- for (HandleIndex = 0; HandleIndex < Count1; HandleIndex++) {
- //
- // now find the children
- //
- Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
- DriverHandle,
- Buffer[HandleIndex],
- &Count2,
- &Buffer2
- );
- if (EFI_ERROR(Status)) {
- break;
- }
- //
- // save out required and optional data elements
- //
- *MatchingHandleCount += Count2;
- if (MatchingHandleBuffer != NULL) {
- *MatchingHandleBuffer = BuffernCatGrow((VOID**)MatchingHandleBuffer, &HandleBufferSize, Buffer2, Count2 * sizeof(Buffer2[0]));
- }
-
- //
- // free the memory
- //
- if (Buffer2 != NULL) {
- FreePool(Buffer2);
- }
- }
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
- return (Status);
-}
-
-/**
- Function to get all handles that support a given protocol or all handles.
-
- @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL
- then the function will return all handles.
-
- @retval NULL A memory allocation failed.
- @return A NULL terminated list of handles.
-**/
-EFI_HANDLE*
-EFIAPI
-GetHandleListByProtocol (
- IN CONST EFI_GUID *ProtocolGuid OPTIONAL
- )
-{
- EFI_HANDLE *HandleList;
- UINTN Size;
- EFI_STATUS Status;
-
- Size = 0;
- HandleList = NULL;
-
- //
- // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!
- //
- if (ProtocolGuid == NULL) {
- Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));
- if (HandleList == NULL) {
- return (NULL);
- }
- Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);
- HandleList[Size/sizeof(EFI_HANDLE)] = NULL;
- }
- } else {
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));
- if (HandleList == NULL) {
- return (NULL);
- }
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);
- HandleList[Size/sizeof(EFI_HANDLE)] = NULL;
- }
- }
- if (EFI_ERROR(Status)) {
- if (HandleList != NULL) {
- FreePool(HandleList);
- }
- return (NULL);
- }
- return (HandleList);
-}
-
-/**
- Function to get all handles that support some protocols.
-
- @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.
-
- @retval NULL A memory allocation failed.
- @retval NULL ProtocolGuids was NULL.
- @return A NULL terminated list of EFI_HANDLEs.
-**/
-EFI_HANDLE*
-EFIAPI
-GetHandleListByProtocolList (
- IN CONST EFI_GUID **ProtocolGuids
- )
-{
- EFI_HANDLE *HandleList;
- UINTN Size;
- UINTN TotalSize;
- UINTN TempSize;
- EFI_STATUS Status;
- CONST EFI_GUID **GuidWalker;
- EFI_HANDLE *HandleWalker1;
- EFI_HANDLE *HandleWalker2;
-
- Size = 0;
- HandleList = NULL;
- TotalSize = sizeof(EFI_HANDLE);
-
- for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++,Size = 0){
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &Size, NULL);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- TotalSize += Size;
- }
- }
-
- //
- // No handles were found...
- //
- if (TotalSize == sizeof(EFI_HANDLE)) {
- return (NULL);
- }
-
- HandleList = AllocateZeroPool(TotalSize);
- if (HandleList == NULL) {
- return (NULL);
- }
-
- Size = 0;
- for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){
- TempSize = TotalSize - Size;
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+(Size/sizeof(EFI_HANDLE)));
-
- //
- // Allow for missing protocols... Only update the 'used' size upon success.
- //
- if (!EFI_ERROR(Status)) {
- Size += TempSize;
- }
- }
- ASSERT(HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] == NULL);
-
- for (HandleWalker1 = HandleList ; HandleWalker1 != NULL && *HandleWalker1 != NULL ; HandleWalker1++) {
- for (HandleWalker2 = HandleWalker1 + 1; HandleWalker2 != NULL && *HandleWalker2 != NULL ; HandleWalker2++) {
- if (*HandleWalker1 == *HandleWalker2) {
- //
- // copy memory back 1 handle width.
- //
- CopyMem(HandleWalker2, HandleWalker2 + 1, TotalSize - ((HandleWalker2-HandleList+1)*sizeof(EFI_HANDLE)));
- }
- }
- }
-
- return (HandleList);
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
deleted file mode 100644
index b9141fa44b..0000000000
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/** @file
- Provides interface to advanced shell functionality for parsing both handle and protocol database.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_HANDLE_PARSING_LIB_INTERNAL_H_
-#define _UEFI_HANDLE_PARSING_LIB_INTERNAL_H_
-
-#include <Uefi.h>
-
-#include <Guid/FileInfo.h>
-#include <Guid/ConsoleInDevice.h>
-#include <Guid/ConsoleOutDevice.h>
-#include <Guid/StandardErrorDevice.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/Gpt.h>
-#include <Guid/FileSystemInfo.h>
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/EfiShellInterface.h>
-#include <Protocol/EfiShellEnvironment2.h>
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePathToText.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/DriverConfiguration2.h>
-#include <Protocol/DriverConfiguration.h>
-#include <Protocol/DriverDiagnostics2.h>
-#include <Protocol/DriverDiagnostics.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/PlatformDriverOverride.h>
-#include <Protocol/DevicePathUtilities.h>
-#include <Protocol/DevicePathFromText.h>
-#include <Protocol/BusSpecificDriverOverride.h>
-#include <Protocol/PlatformToDriverConfiguration.h>
-#include <Protocol/DriverSupportedEfiVersion.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/SimplePointer.h>
-#include <Protocol/SerialIo.h>
-#include <Protocol/AbsolutePointer.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/EdidDiscovered.h>
-#include <Protocol/EdidActive.h>
-#include <Protocol/EdidOverride.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/LoadFile2.h>
-#include <Protocol/TapeIo.h>
-#include <Protocol/DiskIo.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/ScsiPassThru.h>
-#include <Protocol/ScsiPassThruExt.h>
-#include <Protocol/ScsiIo.h>
-#include <Protocol/IScsiInitiatorName.h>
-#include <Protocol/UsbIo.h>
-#include <Protocol/UsbHostController.h>
-#include <Protocol/Usb2HostController.h>
-#include <Protocol/DebugSupport.h>
-#include <Protocol/DebugPort.h>
-#include <Protocol/Decompress.h>
-#include <Protocol/AcpiTable.h>
-#include <Protocol/Ebc.h>
-#include <Protocol/SimpleNetwork.h>
-#include <Protocol/NetworkInterfaceIdentifier.h>
-#include <Protocol/PxeBaseCode.h>
-#include <Protocol/PxeBaseCodeCallBack.h>
-#include <Protocol/Bis.h>
-#include <Protocol/ManagedNetwork.h>
-#include <Protocol/Arp.h>
-#include <Protocol/Dhcp4.h>
-#include <Protocol/Tcp4.h>
-#include <Protocol/Ip4.h>
-#include <Protocol/Ip4Config.h>
-#include <Protocol/Ip4Config2.h>
-#include <Protocol/Udp4.h>
-#include <Protocol/Mtftp4.h>
-#include <Protocol/AuthenticationInfo.h>
-#include <Protocol/Hash.h>
-#include <Protocol/HiiFont.h>
-#include <Protocol/HiiString.h>
-#include <Protocol/HiiImage.h>
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/HiiConfigRouting.h>
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/FormBrowser2.h>
-#include <Protocol/DeviceIo.h>
-#include <Protocol/UgaDraw.h>
-#include <Protocol/UgaIo.h>
-#include <Protocol/DriverConfiguration.h>
-#include <Protocol/DriverConfiguration2.h>
-#include <Protocol/DevicePathUtilities.h>
-//#include <Protocol/FirmwareVolume.h>
-//#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/DriverFamilyOverride.h>
-#include <Protocol/Pcd.h>
-#include <Protocol/TcgService.h>
-#include <Protocol/HiiPackageList.h>
-#include <Protocol/Ip6.h>
-#include <Protocol/Ip6Config.h>
-#include <Protocol/Mtftp6.h>
-#include <Protocol/Dhcp6.h>
-#include <Protocol/Udp6.h>
-#include <Protocol/Tcp6.h>
-#include <Protocol/VlanConfig.h>
-#include <Protocol/Eap.h>
-#include <Protocol/EapManagement.h>
-#include <Protocol/Ftp4.h>
-#include <Protocol/IpSecConfig.h>
-#include <Protocol/DriverHealth.h>
-#include <Protocol/DeferredImageLoad.h>
-#include <Protocol/UserCredential.h>
-#include <Protocol/UserManager.h>
-#include <Protocol/AtaPassThru.h>
-#include <Protocol/FirmwareManagement.h>
-#include <Protocol/IpSec.h>
-#include <Protocol/Kms.h>
-#include <Protocol/BlockIo2.h>
-#include <Protocol/StorageSecurityCommand.h>
-#include <Protocol/UserCredential2.h>
-#include <Protocol/IdeControllerInit.h>
-#include <Protocol/DiskIo2.h>
-#include <Protocol/AdapterInformation.h>
-#include <Protocol/EfiShellDynamicCommand.h>
-#include <Protocol/DiskInfo.h>
-
-#include <Library/HandleParsingLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiLib.h>
-#include <Library/HiiLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-
-typedef struct {
- LIST_ENTRY Link;
- EFI_HANDLE TheHandle;
- UINTN TheIndex;
-}HANDLE_LIST;
-
-typedef struct {
- HANDLE_LIST List;
- UINTN NextIndex;
-} HANDLE_INDEX_LIST;
-
-typedef
-CHAR16 *
-(EFIAPI *DUMP_PROTOCOL_INFO)(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose
- );
-
-typedef struct _GUID_INFO_BLOCK{
- EFI_STRING_ID StringId;
- EFI_GUID *GuidId;
- DUMP_PROTOCOL_INFO DumpInfo;
-} GUID_INFO_BLOCK;
-
-#endif
-
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
deleted file mode 100644
index 4cd81f59ed..0000000000
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ /dev/null
@@ -1,200 +0,0 @@
-## @file
-# Provides interface to advanced shell functionality for parsing both handle and protocol database.
-# (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiHandleParsingLib
- FILE_GUID = 3CDC7177-CC2A-4678-BA8F-1A936A093FA4
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = HandleParsingLib|UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER
- CONSTRUCTOR = HandleParsingLibConstructor
- DESTRUCTOR = HandleParsingLibDestructor
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- UefiHandleParsingLib.c
- UefiHandleParsingLib.h
- UefiHandleParsingLib.uni
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- MemoryAllocationLib
- DevicePathLib
- BaseLib
- BaseMemoryLib
- DebugLib
- FileHandleLib
- PrintLib
- UefiLib
- HiiLib
- SortLib
-
-[Protocols]
- gEfiSimpleFileSystemProtocolGuid ## CONSUMES
-
- # shell 2.0
- gEfiShellProtocolGuid ## SOMETIMES_CONSUMES
- gEfiShellParametersProtocolGuid ## SOMETIMES_CONSUMES
-
- # 'old' shell
- gEfiShellEnvironment2Guid ## SOMETIMES_CONSUMES
- gEfiShellInterfaceGuid ## SOMETIMES_CONSUMES
-
- gEfiUnicodeCollation2ProtocolGuid ## CONSUMES
- gEfiDevicePathToTextProtocolGuid ## CONSUMES
- gEfiBusSpecificDriverOverrideProtocolGuid ## CONSUMES
- gEfiDevicePathUtilitiesProtocolGuid ## CONSUMES
- gEfiDevicePathFromTextProtocolGuid ## CONSUMES
- gEfiPlatformDriverOverrideProtocolGuid ## CONSUMES
- gEfiSimpleTextInProtocolGuid ## CONSUMES
- gEfiPlatformToDriverConfigurationProtocolGuid ## CONSUMES
- gEfiDriverSupportedEfiVersionProtocolGuid ## CONSUMES
- gEfiLoadedImageProtocolGuid ## CONSUMES
- gEfiDevicePathProtocolGuid ## CONSUMES
- gEfiLoadedImageDevicePathProtocolGuid ## CONSUMES
- gEfiSimpleTextOutProtocolGuid ## UNDEFINED
- gEfiSimplePointerProtocolGuid ## UNDEFINED
- gEfiAbsolutePointerProtocolGuid ## UNDEFINED
- gEfiSerialIoProtocolGuid ## UNDEFINED
- gEfiEdidDiscoveredProtocolGuid ## UNDEFINED
- gEfiEdidActiveProtocolGuid ## UNDEFINED
- gEfiEdidOverrideProtocolGuid ## UNDEFINED
- gEfiLoadFileProtocolGuid ## UNDEFINED
- gEfiLoadFile2ProtocolGuid ## UNDEFINED
- gEfiTapeIoProtocolGuid ## UNDEFINED
- gEfiDiskIoProtocolGuid ## UNDEFINED
- gEfiBlockIoProtocolGuid ## UNDEFINED
- gEfiUnicodeCollationProtocolGuid ## UNDEFINED
- gEfiPciRootBridgeIoProtocolGuid ## UNDEFINED
- gEfiPciIoProtocolGuid ## UNDEFINED
- gEfiScsiPassThruProtocolGuid ## UNDEFINED
- gEfiScsiIoProtocolGuid ## UNDEFINED
- gEfiExtScsiPassThruProtocolGuid ## UNDEFINED
- gEfiIScsiInitiatorNameProtocolGuid ## UNDEFINED
- gEfiUsbIoProtocolGuid ## UNDEFINED
- gEfiUsbHcProtocolGuid ## UNDEFINED
- gEfiUsb2HcProtocolGuid ## UNDEFINED
- gEfiDebugSupportProtocolGuid ## UNDEFINED
- gEfiDebugPortProtocolGuid ## UNDEFINED
- gEfiDecompressProtocolGuid ## UNDEFINED
- gEfiAcpiTableProtocolGuid ## UNDEFINED
- gEfiEbcProtocolGuid ## UNDEFINED
- gEfiSimpleNetworkProtocolGuid ## UNDEFINED
- gEfiNetworkInterfaceIdentifierProtocolGuid ## UNDEFINED
- gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## UNDEFINED
- gEfiPxeBaseCodeProtocolGuid ## UNDEFINED
- gEfiPxeBaseCodeCallbackProtocolGuid ## UNDEFINED
- gEfiBisProtocolGuid ## UNDEFINED
- gEfiManagedNetworkServiceBindingProtocolGuid ## UNDEFINED
- gEfiManagedNetworkProtocolGuid ## UNDEFINED
- gEfiArpServiceBindingProtocolGuid ## UNDEFINED
- gEfiArpProtocolGuid ## UNDEFINED
- gEfiDhcp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiDhcp4ProtocolGuid ## UNDEFINED
- gEfiTcp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiTcp4ProtocolGuid ## UNDEFINED
- gEfiIp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiIp4ProtocolGuid ## UNDEFINED
- gEfiIp4ConfigProtocolGuid ## UNDEFINED
- gEfiIp4Config2ProtocolGuid ## UNDEFINED
- gEfiUdp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiUdp4ProtocolGuid ## UNDEFINED
- gEfiMtftp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiMtftp4ProtocolGuid ## UNDEFINED
- gEfiAuthenticationInfoProtocolGuid ## UNDEFINED
- gEfiHashServiceBindingProtocolGuid ## UNDEFINED
- gEfiHashProtocolGuid ## UNDEFINED
- gEfiHiiFontProtocolGuid ## UNDEFINED
- gEfiHiiStringProtocolGuid ## UNDEFINED
- gEfiHiiImageProtocolGuid ## UNDEFINED
- gEfiHiiConfigRoutingProtocolGuid ## UNDEFINED
- gEfiHiiConfigAccessProtocolGuid ## UNDEFINED
- gEfiFormBrowser2ProtocolGuid ## UNDEFINED
- gEfiDeviceIoProtocolGuid ## UNDEFINED
- gEfiUgaDrawProtocolGuid ## UNDEFINED
- gEfiUgaIoProtocolGuid ## UNDEFINED
- gEfiDriverConfigurationProtocolGuid ## UNDEFINED
- gEfiDriverConfiguration2ProtocolGuid ## UNDEFINED
- gEfiSimpleTextInputExProtocolGuid ## UNDEFINED
- gEfiIp6ServiceBindingProtocolGuid ## UNDEFINED
- gEfiIp6ProtocolGuid ## UNDEFINED
- gEfiIp6ConfigProtocolGuid ## UNDEFINED
- gEfiMtftp6ServiceBindingProtocolGuid ## UNDEFINED
- gEfiMtftp6ProtocolGuid ## UNDEFINED
- gEfiDhcp6ServiceBindingProtocolGuid ## UNDEFINED
- gEfiDhcp6ProtocolGuid ## UNDEFINED
- gEfiUdp6ServiceBindingProtocolGuid ## UNDEFINED
- gEfiUdp6ProtocolGuid ## UNDEFINED
- gEfiTcp6ServiceBindingProtocolGuid ## UNDEFINED
- gEfiTcp6ProtocolGuid ## UNDEFINED
- gEfiVlanConfigProtocolGuid ## UNDEFINED
- gEfiEapProtocolGuid ## UNDEFINED
- gEfiEapManagementProtocolGuid ## UNDEFINED
- gEfiFtp4ServiceBindingProtocolGuid ## UNDEFINED
- gEfiFtp4ProtocolGuid ## UNDEFINED
- gEfiIpSecConfigProtocolGuid ## UNDEFINED
- gEfiDriverHealthProtocolGuid ## UNDEFINED
- gEfiDeferredImageLoadProtocolGuid ## UNDEFINED
- gEfiUserCredentialProtocolGuid ## UNDEFINED
- gEfiUserManagerProtocolGuid ## UNDEFINED
- gEfiAtaPassThruProtocolGuid ## UNDEFINED
- gEfiFirmwareManagementProtocolGuid ## UNDEFINED
- gEfiIpSecProtocolGuid ## UNDEFINED
- gEfiIpSec2ProtocolGuid ## UNDEFINED
- gEfiKmsProtocolGuid ## UNDEFINED
- gEfiBlockIo2ProtocolGuid ## UNDEFINED
- gEfiStorageSecurityCommandProtocolGuid ## UNDEFINED
- gEfiUserCredential2ProtocolGuid ## UNDEFINED
- gPcdProtocolGuid ## UNDEFINED
- gEfiTcgProtocolGuid ## UNDEFINED
- gEfiHiiPackageListProtocolGuid ## UNDEFINED
- gEfiDriverFamilyOverrideProtocolGuid ## UNDEFINED
- gEfiIdeControllerInitProtocolGuid ## UNDEFINED
- gEfiDiskIo2ProtocolGuid ## UNDEFINED
- gEfiAdapterInformationProtocolGuid ## UNDEFINED
- gEfiShellDynamicCommandProtocolGuid ## UNDEFINED
- gEfiDiskInfoProtocolGuid ## UNDEFINED
-
-[Guids]
- gEfiFileInfoGuid ## CONSUMES ## GUID
- gEfiShellEnvironment2ExtGuid ## CONSUMES ## GUID
- gEfiPcAnsiGuid ## UNDEFINED
- gEfiVT100Guid ## UNDEFINED
- gEfiVT100PlusGuid ## UNDEFINED
- gEfiVTUTF8Guid ## UNDEFINED
- gEfiStandardErrorDeviceGuid ## UNDEFINED
- gEfiConsoleInDeviceGuid ## UNDEFINED
- gEfiConsoleOutDeviceGuid ## UNDEFINED
- gEfiFileSystemInfoGuid ## UNDEFINED
- gEfiGlobalVariableGuid ## UNDEFINED
- gEfiPartTypeSystemPartGuid ## UNDEFINED
- gEfiPartTypeLegacyMbrGuid ## UNDEFINED
- gHandleParsingHiiGuid ## UNDEFINED
- gEfiAdapterInfoMediaStateGuid ## SOMETIMES_CONSUMES ## GUID
- gEfiAdapterInfoNetworkBootGuid ## SOMETIMES_CONSUMES ## GUID
- gEfiAdapterInfoSanMacAddressGuid ## SOMETIMES_CONSUMES ## GUID
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellIncludeNtGuids ## CONSUMES \ No newline at end of file
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
deleted file mode 100644
index d8e45d0496..0000000000
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
deleted file mode 100644
index eeee055cdb..0000000000
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ /dev/null
@@ -1,1548 +0,0 @@
-/** @file
- Main file for BCFG command.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/GlobalVariable.h>
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/DevicePathLib.h>
-
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
-STATIC EFI_HANDLE gShellBcfgHiiHandle = NULL;
-
-typedef enum {
- BcfgTargetBootOrder = 0,
- BcfgTargetDriverOrder = 1,
- BcfgTargetMax = 2
-} BCFG_OPERATION_TARGET;
-
-typedef enum {
- BcfgTypeDump = 0,
- BcfgTypeAdd = 1,
- BcfgTypeAddp = 2,
- BcfgTypeAddh = 3,
- BcfgTypeRm = 4,
- BcfgTypeMv = 5,
- BcfgTypeOpt = 6,
- BcfgTypeMax = 7
-} BCFG_OPERATION_TYPE;
-
-typedef struct {
- BCFG_OPERATION_TARGET Target;
- BCFG_OPERATION_TYPE Type;
- UINT16 Number1;
- UINT16 Number2;
- UINTN HandleIndex;
- CHAR16 *FileName;
- CHAR16 *Description;
- UINT16 *Order;
- CONST CHAR16 *OptData;
-} BGFG_OPERATION;
-
-/**
- Update the optional data for a boot or driver option.
-
- If optional data exists it will be changed.
-
- @param[in] Index The boot or driver option index update.
- @param[in] DataSize The size in bytes of Data.
- @param[in] Data The buffer for the optioanl data.
- @param[in] Target The target of the operation.
-
- @retval EFI_SUCCESS The data was sucessfully updated.
- @retval other A error occured.
-**/
-EFI_STATUS
-EFIAPI
-UpdateOptionalData(
- UINT16 Index,
- UINTN DataSize,
- UINT8 *Data,
- IN CONST BCFG_OPERATION_TARGET Target
- )
-{
- EFI_STATUS Status;
- CHAR16 VariableName[12];
- UINTN OriginalSize;
- UINT8 *OriginalData;
- UINTN NewSize;
- UINT8 *NewData;
- UINTN OriginalOptionDataSize;
-
- UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", Index);
-
- OriginalSize = 0;
- OriginalData = NULL;
- NewData = NULL;
- NewSize = 0;
-
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &OriginalSize,
- OriginalData);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- OriginalData = AllocateZeroPool(OriginalSize);
- if (OriginalData == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &OriginalSize,
- OriginalData);
- }
-
- if (!EFI_ERROR(Status)) {
- //
- // Allocate new struct and discard old optional data.
- //
- ASSERT (OriginalData != NULL);
- OriginalOptionDataSize = sizeof(UINT32) + sizeof(UINT16) + StrSize(((CHAR16*)(OriginalData + sizeof(UINT32) + sizeof(UINT16))));
- OriginalOptionDataSize += (*(UINT16*)(OriginalData + sizeof(UINT32)));
- OriginalOptionDataSize -= OriginalSize;
- NewSize = OriginalSize - OriginalOptionDataSize + DataSize;
- NewData = AllocateCopyPool(NewSize, OriginalData);
- if (NewData == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- CopyMem(NewData + OriginalSize - OriginalOptionDataSize, Data, DataSize);
- }
- }
-
- if (!EFI_ERROR(Status)) {
- //
- // put the data back under the variable
- //
- Status = gRT->SetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- NewSize,
- NewData);
- }
-
- SHELL_FREE_NON_NULL(OriginalData);
- SHELL_FREE_NON_NULL(NewData);
- return (Status);
-}
-
-/**
- This function will get a CRC for a boot option.
-
- @param[in, out] Crc The CRC value to return.
- @param[in] BootIndex The boot option index to CRC.
-
- @retval EFI_SUCCESS The CRC was sucessfully returned.
- @retval other A error occured.
-**/
-EFI_STATUS
-EFIAPI
-GetBootOptionCrc(
- UINT32 *Crc,
- UINT16 BootIndex
- )
-{
- CHAR16 VariableName[12];
- EFI_STATUS Status;
- UINT8 *Buffer;
- UINTN BufferSize;
-
- Buffer = NULL;
- BufferSize = 0;
-
- //
- // Get the data Buffer
- //
- UnicodeSPrint(VariableName, sizeof(VariableName), L"%Boot%04x", BootIndex);
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &BufferSize,
- NULL);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocateZeroPool(BufferSize);
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &BufferSize,
- Buffer);
- }
-
- //
- // Get the CRC computed
- //
- if (!EFI_ERROR(Status)) {
- Status = gBS->CalculateCrc32 (Buffer, BufferSize, Crc);
- }
-
- SHELL_FREE_NON_NULL(Buffer);
- return EFI_SUCCESS;
-}
-
-/**
- This function will populate the device path protocol parameter based on TheHandle.
-
- @param[in] TheHandle Driver handle.
- @param[in, out] FilePath On a sucessful return the device path to the handle.
-
- @retval EFI_SUCCESS The device path was sucessfully returned.
- @retval other A error from gBS->HandleProtocol.
-
- @sa HandleProtocol
-**/
-EFI_STATUS
-EFIAPI
-GetDevicePathForDriverHandle (
- IN EFI_HANDLE TheHandle,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&ImageDevicePath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
-// *DevPath = DuplicateDevicePath (ImageDevicePath);
-// *FilePath = DuplicateDevicePath (LoadedImage->FilePath);
- *FilePath = AppendDevicePath(ImageDevicePath,LoadedImage->FilePath);
- gBS->CloseProtocol(
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- gImageHandle,
- NULL);
- }
- gBS->CloseProtocol(
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- gImageHandle,
- NULL);
- }
- return (Status);
-}
-
-/**
- Function to add a option.
-
- @param[in] Position The position to add Target at.
- @param[in] File The file to make the target.
- @param[in] Desc The description text.
- @param[in] CurrentOrder The pointer to the current order of items.
- @param[in] OrderCount The number if items in CurrentOrder.
- @param[in] Target The info on the option to add.
- @param[in] UseHandle TRUE to use HandleNumber, FALSE to use File and Desc.
- @param[in] UsePath TRUE to convert to devicepath.
- @param[in] HandleNumber The handle number to add.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
-**/
-SHELL_STATUS
-EFIAPI
-BcfgAdd(
- IN UINTN Position,
- IN CONST CHAR16 *File,
- IN CONST CHAR16 *Desc,
- IN CONST UINT16 *CurrentOrder,
- IN CONST UINTN OrderCount,
- IN CONST BCFG_OPERATION_TARGET Target,
- IN CONST BOOLEAN UseHandle,
- IN CONST BOOLEAN UsePath,
- IN CONST UINTN HandleNumber
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- CHAR16 *Str;
- UINT8 *TempByteBuffer;
- UINT8 *TempByteStart;
- EFI_SHELL_FILE_INFO *Arg;
- EFI_SHELL_FILE_INFO *FileList;
- CHAR16 OptionStr[40];
- UINTN DescSize, FilePathSize;
- BOOLEAN Found;
- UINTN TargetLocation;
- UINTN Index;
- EFI_HANDLE *Handles;
- EFI_HANDLE CurHandle;
- UINTN DriverBindingHandleCount;
- UINTN ParentControllerHandleCount;
- UINTN ChildControllerHandleCount;
- SHELL_STATUS ShellStatus;
- UINT16 *NewOrder;
-
- if (!UseHandle) {
- if (File == NULL || Desc == NULL) {
- return (SHELL_INVALID_PARAMETER);
- }
- } else {
- if (HandleNumber == 0) {
- return (SHELL_INVALID_PARAMETER);
- }
- }
-
- if (Position > OrderCount) {
- Position = OrderCount;
- }
-
- Str = NULL;
- FilePath = NULL;
- FileList = NULL;
- Handles = NULL;
- ShellStatus = SHELL_SUCCESS;
- TargetLocation = 0xFFFF;
-
- if (UseHandle) {
- CurHandle = ConvertHandleIndexToHandle(HandleNumber);
- if (CurHandle == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Handle Number");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (Target == BcfgTargetBootOrder) {
- //
- //Make sure that the handle should point to a real controller
- //
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
- CurHandle,
- &DriverBindingHandleCount,
- NULL);
-
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- CurHandle,
- &ParentControllerHandleCount,
- NULL);
-
- Status = ParseHandleDatabaseForChildControllers (
- CurHandle,
- &ChildControllerHandleCount,
- NULL);
-
- if (DriverBindingHandleCount > 0
- || ParentControllerHandleCount > 0
- || ChildControllerHandleCount > 0) {
- FilePath = NULL;
- Status = gBS->HandleProtocol (
- CurHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&FilePath);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellBcfgHiiHandle, L"bcfg", HandleNumber);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- //
- //Make sure that the handle should point to driver, not a controller.
- //
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
- CurHandle,
- &DriverBindingHandleCount,
- NULL);
-
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- CurHandle,
- &ParentControllerHandleCount,
- NULL);
-
- Status = ParseHandleDatabaseForChildControllers (
- CurHandle,
- &ChildControllerHandleCount,
- NULL);
-
- Status = gBS->HandleProtocol (
- CurHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&FilePath);
-
- if (DriverBindingHandleCount > 0
- || ParentControllerHandleCount > 0
- || ChildControllerHandleCount > 0
- || !EFI_ERROR(Status) ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Handle Number");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Get the DevicePath from the loaded image information.
- //
- Status = GetDevicePathForDriverHandle(CurHandle, &FilePath);
- }
- }
- }
- } else {
- //
- // Get file info
- //
- ShellOpenFileMetaArg ((CHAR16*)File, EFI_FILE_MODE_READ, &FileList);
-
- if (FileList == NULL) {
- //
- // If filename matched nothing fail
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellBcfgHiiHandle, L"bcfg", File);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (FileList->Link.ForwardLink != FileList->Link.BackLink) {
- //
- // If filename expanded to multiple names, fail
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE), gShellBcfgHiiHandle, L"bcfg", File);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Arg = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link);
- if (EFI_ERROR(Arg->Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_OPEN), gShellBcfgHiiHandle, L"bcfg", File);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Build FilePath to the filename
- //
-
- //
- // get the device path
- //
- DevicePath = gEfiShellProtocol->GetDevicePathFromFilePath(Arg->FullName);
- if (DevicePath == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellBcfgHiiHandle, L"bcfg", Arg->FullName);
- ShellStatus = SHELL_UNSUPPORTED;
- } else {
-/*
- if (UsePath) {
- DevPath = DevicePath;
- while (!IsDevicePathEnd(DevPath)) {
- if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {
-
- //
- // If we find it use it instead
- //
- DevicePath = DevPath;
- break;
- }
- DevPath = NextDevicePathNode(DevPath);
- }
- //
- // append the file
- //
- for(StringWalker=Arg->FullName; *StringWalker != CHAR_NULL && *StringWalker != ':'; StringWalker++);
- FileNode = FileDevicePath(NULL, StringWalker+1);
- FilePath = AppendDevicePath(DevicePath, FileNode);
- FreePool(FileNode);
- } else {
-*/
- FilePath = DuplicateDevicePath(DevicePath);
-/*
- }
-*/
- FreePool(DevicePath);
- }
- }
- }
- }
-
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Find a free target ,a brute force implementation
- //
- Found = FALSE;
- for (TargetLocation=0; TargetLocation < 0xFFFF; TargetLocation++) {
- Found = TRUE;
- for (Index=0; Index < OrderCount; Index++) {
- if (CurrentOrder[Index] == TargetLocation) {
- Found = FALSE;
- break;
- }
- }
-
- if (Found) {
- break;
- }
- }
-
- if (TargetLocation == 0xFFFF) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET_NF), gShellBcfgHiiHandle, L"bcfg");
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET), gShellBcfgHiiHandle, TargetLocation);
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Add the option
- //
- DescSize = StrSize(Desc);
- FilePathSize = GetDevicePathSize (FilePath);
-
- TempByteBuffer = AllocateZeroPool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize);
- if (TempByteBuffer != NULL) {
- TempByteStart = TempByteBuffer;
- *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes
- TempByteBuffer += sizeof (UINT32);
-
- *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength
- TempByteBuffer += sizeof (UINT16);
-
- CopyMem (TempByteBuffer, Desc, DescSize);
- TempByteBuffer += DescSize;
- ASSERT (FilePath != NULL);
- CopyMem (TempByteBuffer, FilePath, FilePathSize);
-
- UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);
- Status = gRT->SetVariable (
- OptionStr,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,
- TempByteStart
- );
-
- FreePool(TempByteStart);
- } else {
- Status = EFI_OUT_OF_RESOURCES;
- }
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", OptionStr);
- } else {
- NewOrder = AllocateZeroPool((OrderCount+1)*sizeof(NewOrder[0]));
- ASSERT(NewOrder != NULL);
- CopyMem(NewOrder, CurrentOrder, (OrderCount)*sizeof(NewOrder[0]));
-
- //
- // Insert target into order list
- //
- for (Index=OrderCount; Index > Position; Index--) {
- NewOrder[Index] = NewOrder[Index-1];
- }
-
- NewOrder[Position] = (UINT16) TargetLocation;
- Status = gRT->SetVariable (
- Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- (OrderCount+1) * sizeof(UINT16),
- NewOrder
- );
-
- FreePool(NewOrder);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Print (L"bcfg: Add %s as %x\n", OptionStr, Position);
- }
- }
- }
-
-//
-//If always Free FilePath, will free devicepath in system when use "addh"
-//
- if (FilePath!=NULL && !UseHandle) {
- FreePool (FilePath);
- }
-
- if (Str != NULL) {
- FreePool(Str);
- }
-
- if (Handles != NULL) {
- FreePool (Handles);
- }
-
- if (FileList != NULL) {
- ShellCloseFileMetaArg (&FileList);
- }
-
- return (ShellStatus);
-}
-
-/**
- Funciton to remove an item.
-
- @param[in] Target The target item to move.
- @param[in] CurrentOrder The pointer to the current order of items.
- @param[in] OrderCount The number if items in CurrentOrder.
- @param[in] Location The current location of the Target.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
-**/
-SHELL_STATUS
-EFIAPI
-BcfgRemove(
- IN CONST BCFG_OPERATION_TARGET Target,
- IN CONST UINT16 *CurrentOrder,
- IN CONST UINTN OrderCount,
- IN CONST UINT16 Location
- )
-{
- CHAR16 VariableName[12];
- UINT16 *NewOrder;
- EFI_STATUS Status;
- UINTN NewCount;
-
- UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", CurrentOrder[Location]);
- Status = gRT->SetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- 0,
- NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
- return (SHELL_INVALID_PARAMETER);
- }
- NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0]));
- if (NewOrder != NULL) {
- NewCount = OrderCount;
- CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));
- CopyMem(NewOrder+Location, NewOrder+Location+1, (OrderCount - Location - 1)*sizeof(CurrentOrder[0]));
- NewCount--;
-
- Status = gRT->SetVariable(
- Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- NewCount*sizeof(NewOrder[0]),
- NewOrder);
- FreePool(NewOrder);
- } else {
- Status = EFI_OUT_OF_RESOURCES;
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder");
- return (SHELL_INVALID_PARAMETER);
- }
- return (SHELL_SUCCESS);
-}
-
-/**
- Funciton to move a item to another location.
-
- @param[in] Target The target item to move.
- @param[in] CurrentOrder The pointer to the current order of items.
- @param[in] OrderCount The number if items in CurrentOrder.
- @param[in] OldLocation The current location of the Target.
- @param[in] NewLocation The desired location of the Target.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
-**/
-SHELL_STATUS
-EFIAPI
-BcfgMove(
- IN CONST BCFG_OPERATION_TARGET Target,
- IN CONST UINT16 *CurrentOrder,
- IN CONST UINTN OrderCount,
- IN CONST UINT16 OldLocation,
- IN UINT16 NewLocation
- )
-{
- UINT16 *NewOrder;
- EFI_STATUS Status;
- UINT16 Temp;
-
- NewOrder = AllocateCopyPool(OrderCount*sizeof(CurrentOrder[0]), CurrentOrder);
- if (NewOrder == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- //
- // correct the new location
- //
- if (NewLocation >= OrderCount) {
- if (OrderCount > 0) {
- NewLocation = (UINT16)OrderCount - 1;
- } else {
- NewLocation = 0;
- }
- }
-
- Temp = CurrentOrder[OldLocation];
- CopyMem(NewOrder+OldLocation, NewOrder+OldLocation+1, (OrderCount - OldLocation - 1)*sizeof(CurrentOrder[0]));
- CopyMem(NewOrder+NewLocation+1, NewOrder+NewLocation, (OrderCount - NewLocation - 1)*sizeof(CurrentOrder[0]));
- NewOrder[NewLocation] = Temp;
-
- Status = gRT->SetVariable(
- Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- OrderCount*sizeof(CurrentOrder[0]),
- NewOrder);
-
- FreePool(NewOrder);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellBcfgHiiHandle, L"bcfg", Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder");
- return (SHELL_INVALID_PARAMETER);
- }
- return (SHELL_SUCCESS);
-}
-
-/**
- Function to add optional data to an option.
-
- @param[in] OptData The optional data to add.
- @param[in] CurrentOrder The pointer to the current order of items.
- @param[in] OrderCount The number if items in CurrentOrder.
- @param[in] Target The target of the operation.
-
- @retval SHELL_SUCCESS The operation was succesful.
-**/
-SHELL_STATUS
-EFIAPI
-BcfgAddOpt(
- IN CONST CHAR16 *OptData,
- IN CONST UINT16 *CurrentOrder,
- IN CONST UINTN OrderCount,
- IN CONST BCFG_OPERATION_TARGET Target
- )
-{
- EFI_KEY_OPTION NewKeyOption;
- EFI_KEY_OPTION *KeyOptionBuffer;
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- UINT16 OptionIndex;
- UINT16 LoopCounter;
- UINT64 Intermediate;
- CONST CHAR16 *Temp;
- CONST CHAR16 *Walker;
- CHAR16 *FileName;
- CHAR16 *Temp2;
- CHAR16 *Data;
- UINT32 KeyIndex;
- CHAR16 VariableName[12];
- VOID *VariableData;
-
- SHELL_FILE_HANDLE FileHandle;
-
- Status = EFI_SUCCESS;
- ShellStatus = SHELL_SUCCESS;
- Walker = OptData;
- FileName = NULL;
- Data = NULL;
- KeyOptionBuffer = NULL;
- VariableData = NULL;
-
- ZeroMem(&NewKeyOption, sizeof(EFI_KEY_OPTION));
- ZeroMem(VariableName, sizeof(VariableName));
-
- while(Walker[0] == L' ') {
- Walker++;
- }
-
- //
- // Get the index of the variable we are changing.
- //
- Status = ShellConvertStringToUint64(Walker, &Intermediate, FALSE, TRUE);
- if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL || ((UINT16)Intermediate) > ((UINT16)OrderCount)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Option Index");
- ShellStatus = SHELL_INVALID_PARAMETER;
- return (ShellStatus);
- }
- OptionIndex = (UINT16)Intermediate;
-
- Temp = StrStr(Walker, L" ");
- if (Temp != NULL) {
- Walker = Temp;
- }
- while(Walker[0] == L' ') {
- Walker++;
- }
-
- //
- // determine whether we have file with data, quote delimited information, or a hot-key
- //
- if (Walker[0] == L'\"') {
- //
- // quoted filename or quoted information.
- //
- Temp = StrStr(Walker+1, L"\"");
- if (Temp == NULL || StrLen(Temp) != 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- FileName = StrnCatGrow(&FileName, NULL, Walker+1, 0);
- if (FileName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- return (ShellStatus);
- }
- Temp2 = StrStr(FileName, L"\"");
- ASSERT(Temp2 != NULL);
- Temp2[0] = CHAR_NULL;
- Temp2++;
- if (StrLen(Temp2)>0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- if (EFI_ERROR(ShellFileExists(Walker))) {
- //
- // Not a file. must be misc information.
- //
- Data = FileName;
- FileName = NULL;
- } else {
- FileName = StrnCatGrow(&FileName, NULL, Walker, 0);
- }
- }
- } else {
- //
- // filename or hot key information.
- //
- if (StrStr(Walker, L" ") == NULL) {
- //
- // filename
- //
- if (EFI_ERROR(ShellFileExists(Walker))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- FileName = StrnCatGrow(&FileName, NULL, Walker, 0);
- }
- } else {
- if (Target != BcfgTargetBootOrder) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_BOOT_ONLY), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Get hot key information
- //
- Status = ShellConvertStringToUint64(Walker, &Intermediate, FALSE, TRUE);
- if (EFI_ERROR(Status) || (((UINT32)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate;
- Temp = StrStr(Walker, L" ");
- if (Temp != NULL) {
- Walker = Temp;
- }
- while(Walker[0] == L' ') {
- Walker++;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct.
- // Re-allocate with the added information.
- //
- KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount), &NewKeyOption);
- if (KeyOptionBuffer == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- }
- }
- for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
- //
- // ScanCode
- //
- Status = ShellConvertStringToUint64(Walker, &Intermediate, FALSE, TRUE);
- if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ((EFI_INPUT_KEY*)(((UINT8*)KeyOptionBuffer) + sizeof(EFI_KEY_OPTION)))[LoopCounter].ScanCode = (UINT16)Intermediate;
- Temp = StrStr(Walker, L" ");
- if (Temp != NULL) {
- Walker = Temp;
- }
- while(Walker[0] == L' ') {
- Walker++;
- }
-
- //
- // UnicodeChar
- //
- Status = ShellConvertStringToUint64(Walker, &Intermediate, FALSE, TRUE);
- if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", Walker);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ((EFI_INPUT_KEY*)(((UINT8*)KeyOptionBuffer) + sizeof(EFI_KEY_OPTION)))[LoopCounter].UnicodeChar = (UINT16)Intermediate;
- Temp = StrStr(Walker, L" ");
- if (Temp != NULL) {
- Walker = Temp;
- }
- while(Walker[0] == L' ') {
- Walker++;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Now do the BootOption / BootOptionCrc
- //
- ASSERT (OptionIndex <= OrderCount);
- KeyOptionBuffer->BootOption = CurrentOrder[OptionIndex];
- Status = GetBootOptionCrc(&(KeyOptionBuffer->BootOptionCrc), KeyOptionBuffer->BootOption);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Option Index");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- for (Temp2 = NULL, KeyIndex = 0 ; KeyIndex <= 0xFFFF ; KeyIndex++) {
- UnicodeSPrint(VariableName, sizeof(VariableName), L"Key%04x", KeyIndex);
- Status = GetEfiGlobalVariable2 (VariableName, &VariableData, NULL);
- if (Status == EFI_NOT_FOUND) {
- break;
- }
- if (!EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(VariableData);
- }
- }
- if (KeyIndex <= 0xFFFF) {
- Status = gRT->SetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
- KeyOptionBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_VAR_NO_NUM), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ASSERT(FileName == NULL && Data == NULL);
- }
- }
- }
-
- //
- // Shouldn't be possible to have have both. Neither is ok though.
- //
- ASSERT(FileName == NULL || Data == NULL);
-
- if (ShellStatus == SHELL_SUCCESS && (FileName != NULL || Data != NULL)) {
- if (FileName != NULL) {
- //
- // Open the file and populate the data buffer.
- //
- Status = ShellOpenFileByName(
- FileName,
- &FileHandle,
- EFI_FILE_MODE_READ,
- 0);
- if (!EFI_ERROR(Status)) {
- Status = ShellGetFileSize(FileHandle, &Intermediate);
- }
- Data = AllocateZeroPool((UINTN)Intermediate);
- if (Data == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- }
- if (!EFI_ERROR(Status)) {
- Status = ShellReadFile(FileHandle, (UINTN *)&Intermediate, Data);
- }
- } else {
- Intermediate = StrSize(Data);
- }
-
- if (!EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS && Data != NULL) {
- Status = UpdateOptionalData(CurrentOrder[OptionIndex], (UINTN)Intermediate, (UINT8*)Data, Target);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
-
- SHELL_FREE_NON_NULL(Data);
- SHELL_FREE_NON_NULL(KeyOptionBuffer);
- SHELL_FREE_NON_NULL(FileName);
- return ShellStatus;
-}
-
-/**
- Function to dump the Bcfg information.
-
- @param[in] Op The operation.
- @param[in] OrderCount How many to dump.
- @param[in] CurrentOrder The pointer to the current order of items.
- @param[in] VerboseOutput TRUE for extra output. FALSE otherwise.
-
- @retval SHELL_SUCCESS The dump was successful.
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
-**/
-SHELL_STATUS
-EFIAPI
-BcfgDisplayDump(
- IN CONST CHAR16 *Op,
- IN CONST UINTN OrderCount,
- IN CONST UINT16 *CurrentOrder,
- IN CONST BOOLEAN VerboseOutput
- )
-{
- EFI_STATUS Status;
- UINT8 *Buffer;
- UINTN BufferSize;
- CHAR16 VariableName[12];
- UINTN LoopVar;
- UINTN LoopVar2;
- CHAR16 *DevPathString;
- VOID *DevPath;
-
- if (OrderCount == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_BCFG_NONE), gShellBcfgHiiHandle, L"bcfg");
- return (SHELL_SUCCESS);
- }
-
- for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) {
- Buffer = NULL;
- BufferSize = 0;
- UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, CurrentOrder[LoopVar]);
-
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &BufferSize,
- Buffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocateZeroPool(BufferSize);
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &BufferSize,
- Buffer);
- }
-
- if (EFI_ERROR(Status) || Buffer == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_READ_FAIL), gShellBcfgHiiHandle, L"bcfg", VariableName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- if ((*(UINT16*)(Buffer+4)) != 0) {
- DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));
- if (DevPath == NULL) {
- DevPathString = NULL;
- } else {
- CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));
- DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
- }
- } else {
- DevPath = NULL;
- DevPathString = NULL;
- }
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_BCFG_LOAD_OPTIONS),
- gShellBcfgHiiHandle,
- LoopVar,
- VariableName,
- (CHAR16*)(Buffer+6),
- DevPathString,
- (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6) <= BufferSize?L'N':L'Y');
- if (VerboseOutput) {
- for (LoopVar2 = (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6);LoopVar2<BufferSize;LoopVar2++){
- ShellPrintEx(
- -1,
- -1,
- NULL,
- L"%02x",
- Buffer[LoopVar2]);
- }
- ShellPrintEx(
- -1,
- -1,
- NULL,
- L"\r\n");
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
- if (DevPath != NULL) {
- FreePool(DevPath);
- }
- if (DevPathString != NULL) {
- FreePool(DevPathString);
- }
- }
- return (SHELL_SUCCESS);
-}
-
-/**
- Function to initialize the BCFG operation structure.
-
- @param[in] Struct The stuct to initialize.
-**/
-VOID
-EFIAPI
-InitBcfgStruct(
- IN BGFG_OPERATION *Struct
- )
-{
- ASSERT(Struct != NULL);
- Struct->Target = BcfgTargetMax;
- Struct->Type = BcfgTypeMax;
- Struct->Number1 = 0;
- Struct->Number2 = 0;
- Struct->HandleIndex = 0;
- Struct->FileName = NULL;
- Struct->Description = NULL;
- Struct->Order = NULL;
- Struct->OptData = NULL;
-}
-
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-v", TypeFlag},
- {L"-opt", TypeMaxValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'bcfg' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunBcfg (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamNumber;
- CONST CHAR16 *CurrentParam;
- BGFG_OPERATION CurrentOperation;
- UINTN Length;
- UINT64 Intermediate;
- UINT16 Count;
-
- Length = 0;
- ProblemParam = NULL;
- Package = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- InitBcfgStruct(&CurrentOperation);
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellBcfgHiiHandle, L"bcfg", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // Read in if we are doing -OPT
- //
- if (ShellCommandLineGetFlag(Package, L"-opt")) {
- CurrentOperation.OptData = ShellCommandLineGetValue(Package, L"-opt");
- if (CurrentOperation.OptData == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellBcfgHiiHandle, L"bcfg", L"-opt");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeOpt;
- }
-
- //
- // small block to read the target of the operation
- //
- if ((ShellCommandLineGetCount(Package) < 3 && CurrentOperation.Type != BcfgTypeOpt) ||
- (ShellCommandLineGetCount(Package) < 2 && CurrentOperation.Type == BcfgTypeOpt)
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"driver") == 0) {
- CurrentOperation.Target = BcfgTargetDriverOrder;
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"boot") == 0) {
- CurrentOperation.Target = BcfgTargetBootOrder;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_DRIVER_BOOT), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
-
-
- //
- // Read in the boot or driver order environment variable (not needed for opt)
- //
- if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
- Length = 0;
- Status = gRT->GetVariable(
- CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &Length,
- CurrentOperation.Order);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- CurrentOperation.Order = AllocateZeroPool(Length+(4*sizeof(CurrentOperation.Order[0])));
- if (CurrentOperation.Order == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- Status = gRT->GetVariable(
- CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &Length,
- CurrentOperation.Order);
- }
- }
- }
-
- Count = (UINT16) (Length / sizeof(CurrentOperation.Order[0]));
-
- //
- // large block to read the type of operation and verify parameter types for the info.
- //
- if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
- for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) {
- CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber);
- if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0) {
- CurrentOperation.Type = BcfgTypeDump;
- } else if (ShellCommandLineGetFlag(Package, L"-v")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"add") == 0) {
- if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeAdd;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number1 = (UINT16)Intermediate;
- ASSERT(CurrentOperation.FileName == NULL);
- CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);
- ASSERT(CurrentOperation.Description == NULL);
- CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);
- }
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addp") == 0) {
- if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeAddp;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number1 = (UINT16)Intermediate;
- ASSERT(CurrentOperation.FileName == NULL);
- CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);
- ASSERT(CurrentOperation.Description == NULL);
- CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);
- }
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addh") == 0) {
- if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeAddh;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number1 = (UINT16)Intermediate;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.HandleIndex = (UINT16)Intermediate;
- ASSERT(CurrentOperation.Description == NULL);
- CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);
- }
- }
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"rm") == 0) {
- if ((ParamNumber + 1) >= ShellCommandLineGetCount(Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeRm;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number1 = (UINT16)Intermediate;
- if (CurrentOperation.Number1 >= Count){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellBcfgHiiHandle, L"bcfg", Count);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"mv") == 0) {
- if ((ParamNumber + 2) >= ShellCommandLineGetCount(Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellBcfgHiiHandle, L"bcfg");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- CurrentOperation.Type = BcfgTypeMv;
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number1 = (UINT16)Intermediate;
- if (CurrentOperation.Number1 >= Count){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), L"bcfg", gShellBcfgHiiHandle, Count);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);
- if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);
- CurrentOperation.Number2 = (UINT16)Intermediate;
- }
- if (CurrentOperation.Number2 == CurrentOperation.Number1
- ||CurrentOperation.Number2 >= Count
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellBcfgHiiHandle, L"bcfg", Count);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", CurrentParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type < BcfgTypeMax) {
- //
- // we have all the info. Do the work
- //
- switch (CurrentOperation.Type) {
- case BcfgTypeDump:
- ShellStatus = BcfgDisplayDump(
- CurrentOperation.Target == BcfgTargetBootOrder?L"Boot":L"Driver",
- Count,
- CurrentOperation.Order,
- ShellCommandLineGetFlag(Package, L"-v"));
- break;
- case BcfgTypeMv:
- ShellStatus = BcfgMove(
- CurrentOperation.Target,
- CurrentOperation.Order,
- Count,
- CurrentOperation.Number1,
- CurrentOperation.Number2);
- break;
- case BcfgTypeRm:
- ShellStatus = BcfgRemove(
- CurrentOperation.Target,
- CurrentOperation.Order,
- Count,
- CurrentOperation.Number1);
- break;
- case BcfgTypeAdd:
- case BcfgTypeAddp:
- case BcfgTypeAddh:
- ShellStatus = BcfgAdd(
- CurrentOperation.Number1,
- CurrentOperation.FileName,
- CurrentOperation.Description==NULL?L"":CurrentOperation.Description,
- CurrentOperation.Order,
- Count,
- CurrentOperation.Target,
- (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddh),
- (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddp),
- CurrentOperation.HandleIndex);
- break;
- case BcfgTypeOpt:
- ShellStatus = BcfgAddOpt(
- CurrentOperation.OptData,
- CurrentOperation.Order,
- Count,
- CurrentOperation.Target);
- break;
- default:
- ASSERT(FALSE);
- }
- }
- }
-
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- if (CurrentOperation.FileName != NULL) {
- FreePool(CurrentOperation.FileName);
- }
- if (CurrentOperation.Description != NULL) {
- FreePool(CurrentOperation.Description);
- }
- if (CurrentOperation.Order != NULL) {
- FreePool(CurrentOperation.Order);
- }
-
- return (ShellStatus);
-}
-
-
-/**
- Function to get the filename with help context if HII will not be used.
-
- @return The filename with help text in it.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameBcfg (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- "Constructor" for the library.
-
- This will register the handler for the bcfg command.
-
- @param[in] ImageHandle the image handle of the process
- @param[in] SystemTable the EFI System Table pointer
- @param[in] Name the profile name to use
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-BcfgLibraryRegisterBcfgCommand (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN CONST CHAR16 *Name
- )
-{
- if (gShellBcfgHiiHandle != NULL) {
- return (EFI_SUCCESS);
- }
-
- gShellBcfgHiiHandle = HiiAddPackages (&gShellBcfgHiiGuid, gImageHandle, UefiShellBcfgCommandLibStrings, NULL);
- if (gShellBcfgHiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handler
- //
- ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfg , ShellCommandGetManFileNameBcfg, 0, Name, FALSE, gShellBcfgHiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG));
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-BcfgLibraryUnregisterBcfgCommand (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellBcfgHiiHandle != NULL) {
- HiiRemovePackages(gShellBcfgHiiHandle);
- }
- gShellBcfgHiiHandle = NULL;
- return (EFI_SUCCESS);
-}
-
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
deleted file mode 100644
index bacaeec1cd..0000000000
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+++ /dev/null
@@ -1,46 +0,0 @@
-## @file
-# Provides shell install1 functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellBcfgCommandLib
- FILE_GUID = F6A3BF5D-4095-4E4F-9670-408770C2DBDF
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = BcfgCommandLib|UEFI_APPLICATION UEFI_DRIVER
-
-[Sources.common]
- UefiShellBcfgCommandLib.c
- UefiShellBcfgCommandLib.uni
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
-
-[Guids]
- gShellBcfgHiiGuid ## SOMETIMES_CONSUMES ## HII
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
deleted file mode 100644
index d34f314f50..0000000000
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
deleted file mode 100644
index 525c1f14cf..0000000000
--- a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/** @file
- Provides application point extension for "C" style main funciton
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
- 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 <Base.h>
-
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/EfiShellInterface.h>
-#include <Protocol/EfiShellParameters.h>
-
-#include <Library/ShellCEntryLib.h>
-#include <Library/DebugLib.h>
-
-/**
- UEFI entry point for an application that will in turn call the
- ShellAppMain function which has parameters similar to a standard C
- main function.
-
- An application that uses UefiShellCEntryLib must have a ShellAppMain
- function as prototyped in Include/Library/ShellCEntryLib.h.
-
- Note that the Shell uses POSITIVE integers for error values, while UEFI
- uses NEGATIVE values. If the application is to be used within a script,
- it needs to return one of the SHELL_STATUS values defined in ShellBase.h.
-
- @param ImageHandle The image handle of the UEFI Application.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The application exited normally.
- @retval Other An error occurred.
-
-**/
-EFI_STATUS
-EFIAPI
-ShellCEntryLib (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- INTN ReturnFromMain;
- EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
- EFI_SHELL_INTERFACE *EfiShellInterface;
- EFI_STATUS Status;
-
- ReturnFromMain = -1;
- EfiShellParametersProtocol = NULL;
- EfiShellInterface = NULL;
-
- Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID **)&EfiShellParametersProtocol,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR(Status)) {
- //
- // use shell 2.0 interface
- //
- ReturnFromMain = ShellAppMain (
- EfiShellParametersProtocol->Argc,
- EfiShellParametersProtocol->Argv
- );
- } else {
- //
- // try to get shell 1.0 interface instead.
- //
- Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
- &gEfiShellInterfaceGuid,
- (VOID **)&EfiShellInterface,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR(Status)) {
- //
- // use shell 1.0 interface
- //
- ReturnFromMain = ShellAppMain (
- EfiShellInterface->Argc,
- EfiShellInterface->Argv
- );
- } else {
- ASSERT(FALSE);
- }
- }
- return ReturnFromMain;
-}
diff --git a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
deleted file mode 100644
index 500b1663ca..0000000000
--- a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file
-# Provides interface to shell functionality for shell commands and applications.
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellCEntryLib
- FILE_GUID = 0e205c8a-8586-4dec-9f5c-4f9e394aefe8
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ShellCEntryLib|UEFI_APPLICATION UEFI_DRIVER
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- UefiShellCEntryLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- UefiApplicationEntryPoint
- DebugLib
-
-
-[Protocols]
- gEfiShellParametersProtocolGuid ## CONSUMES
- gEfiShellInterfaceGuid ## SOMETIMES_CONSUMES
-
-
diff --git a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
deleted file mode 100644
index 9bd7b2cedd..0000000000
--- a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
+++ /dev/null
@@ -1,1545 +0,0 @@
-/** @file
- Main file for support of shell consist mapping.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellCommandLib.h"
-#include <Library/DevicePathLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Protocol/UsbIo.h>
-
-typedef enum {
- MTDTypeUnknown,
- MTDTypeFloppy,
- MTDTypeHardDisk,
- MTDTypeCDRom,
- MTDTypeEnd
-} MTD_TYPE;
-
-typedef struct {
- CHAR16 *Str;
- UINTN Len;
-} POOL_PRINT;
-
-typedef struct {
- UINTN Hi;
- MTD_TYPE Mtd;
- POOL_PRINT Csd;
- BOOLEAN Digital;
-} DEVICE_CONSIST_MAPPING_INFO;
-
-typedef struct {
- MTD_TYPE MTDType;
- CHAR16 *Name;
-} MTD_NAME;
-
-/**
- Serial Decode function.
-
- @param DevPath The Device path info.
- @param MapInfo The map info.
- @param OrigDevPath The original device path protocol.
-
-**/
-typedef
-VOID
-(EFIAPI *SERIAL_DECODE_FUNCTION) (
- EFI_DEVICE_PATH_PROTOCOL *DevPath,
- DEVICE_CONSIST_MAPPING_INFO *MapInfo,
- EFI_DEVICE_PATH_PROTOCOL *OrigDevPath
- );
-
-typedef struct {
- UINT8 Type;
- UINT8 SubType;
- SERIAL_DECODE_FUNCTION SerialFun;
- INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);
-} DEV_PATH_CONSIST_MAPPING_TABLE;
-
-
-/**
- Concatenates a formatted unicode string to allocated pool.
- The caller must free the resulting buffer.
-
- @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
- @param Fmt The format string
- @param ... The data will be printed.
-
- @return Allocated buffer with the formatted string printed in it.
- The caller must free the allocated buffer.
- The buffer allocation is not packed.
-
-**/
-CHAR16 *
-EFIAPI
-CatPrint (
- IN OUT POOL_PRINT *Str,
- IN CHAR16 *Fmt,
- ...
- )
-{
- UINT16 *AppendStr;
- VA_LIST Args;
- UINTN StringSize;
-
- AppendStr = AllocateZeroPool (0x1000);
- if (AppendStr == NULL) {
- ASSERT(FALSE);
- return Str->Str;
- }
-
- VA_START (Args, Fmt);
- UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);
- VA_END (Args);
- if (NULL == Str->Str) {
- StringSize = StrSize (AppendStr);
- Str->Str = AllocateZeroPool (StringSize);
- ASSERT (Str->Str != NULL);
- } else {
- StringSize = StrSize (AppendStr);
- StringSize += (StrSize (Str->Str) - sizeof (UINT16));
-
- Str->Str = ReallocatePool (
- StrSize (Str->Str),
- StringSize,
- Str->Str
- );
- ASSERT (Str->Str != NULL);
- }
-
- StrCatS (Str->Str, StringSize/sizeof(CHAR16), AppendStr);
- Str->Len = StringSize;
-
- FreePool (AppendStr);
- return Str->Str;
-}
-
-MTD_NAME mMTDName[] = {
- {
- MTDTypeUnknown,
- L"F"
- },
- {
- MTDTypeFloppy,
- L"FP"
- },
- {
- MTDTypeHardDisk,
- L"HD"
- },
- {
- MTDTypeCDRom,
- L"CD"
- },
- {
- MTDTypeEnd,
- NULL
- }
-};
-
-/**
- Function to append a 64 bit number / 25 onto the string.
-
- @param[in, out] Str The string so append onto.
- @param[in] Num The number to divide and append.
-
- @retval EFI_INVALID_PARAMETER A parameter was NULL.
- @retval EFI_SUCCESS The appending was successful.
-**/
-EFI_STATUS
-EFIAPI
-AppendCSDNum2 (
- IN OUT POOL_PRINT *Str,
- IN UINT64 Num
- )
-{
- UINT64 Result;
- UINT32 Rem;
-
- if (Str == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- Result = DivU64x32Remainder (Num, 25, &Rem);
- if (Result > 0) {
- AppendCSDNum2 (Str, Result);
- }
-
- CatPrint (Str, L"%c", Rem + 'a');
- return (EFI_SUCCESS);
-}
-
-/**
- Function to append a 64 bit number onto the mapping info.
-
- @param[in, out] MappingItem The mapping info object to append onto.
- @param[in] Num The info to append.
-
- @retval EFI_INVALID_PARAMETER A parameter was NULL.
- @retval EFI_SUCCESS The appending was successful.
-**/
-EFI_STATUS
-EFIAPI
-AppendCSDNum (
- IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN UINT64 Num
- )
-{
- if (MappingItem == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (MappingItem->Digital) {
- CatPrint (&MappingItem->Csd, L"%ld", Num);
- } else {
- AppendCSDNum2 (&MappingItem->Csd, Num);
- }
-
- MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to append string into the mapping info.
-
- @param[in, out] MappingItem The mapping info object to append onto.
- @param[in] Str The info to append.
-
- @retval EFI_INVALID_PARAMETER A parameter was NULL.
- @retval EFI_SUCCESS The appending was successful.
-**/
-EFI_STATUS
-EFIAPI
-AppendCSDStr (
- IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN CHAR16 *Str
- )
-{
- CHAR16 *Index;
-
- if (Str == NULL || MappingItem == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- if (MappingItem->Digital) {
- //
- // To aVOID mult-meaning, the mapping is:
- // 0 1 2 3 4 5 6 7 8 9 a b c d e f
- // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- //
- for (Index = Str; *Index != 0; Index++) {
- switch (*Index) {
- case '0':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- CatPrint (&MappingItem->Csd, L"%c", *Index);
- break;
-
- case '1':
- CatPrint (&MappingItem->Csd, L"16");
- break;
-
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- CatPrint (&MappingItem->Csd, L"1%c", *Index - 'a' + '0');
- break;
-
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- CatPrint (&MappingItem->Csd, L"1%c", *Index - 'A' + '0');
- break;
- }
- }
- } else {
- for (Index = Str; *Index != 0; Index++) {
- //
- // The mapping is:
- // 0 1 2 3 4 5 6 7 8 9 a b c d e f
- // a b c d e f g h i j k l m n o p
- //
- if (*Index >= '0' && *Index <= '9') {
- CatPrint (&MappingItem->Csd, L"%c", *Index - '0' + 'a');
- } else if (*Index >= 'a' && *Index <= 'f') {
- CatPrint (&MappingItem->Csd, L"%c", *Index - 'a' + 'k');
- } else if (*Index >= 'A' && *Index <= 'F') {
- CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');
- }
- }
- }
-
- MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to append a Guid to the mapping item.
-
- @param[in, out] MappingItem The item to append onto.
- @param[in] Guid The guid to append.
-
- @retval EFI_SUCCESS The appending operation was successful.
- @retval EFI_INVALID_PARAMETER A parameter was NULL.
-**/
-EFI_STATUS
-EFIAPI
-AppendCSDGuid (
- DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- EFI_GUID *Guid
- )
-{
- CHAR16 Buffer[64];
-
- if (Guid == NULL || MappingItem == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- UnicodeSPrint (
- Buffer,
- 0,
- L"%g",
- Guid
- );
-
- AppendCSDStr (MappingItem, Buffer);
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to compare 2 APCI device paths.
-
- @param[in] DevicePath1 The first device path to compare.
- @param[in] DevicePath2 The second device path to compare.
-
- @retval 0 The device paths represent the same device.
- @return Non zero if the devices are different, zero otherwise.
-**/
-INTN
-EFIAPI
-DevPathCompareAcpi (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
- )
-{
- ACPI_HID_DEVICE_PATH *Acpi1;
- ACPI_HID_DEVICE_PATH *Acpi2;
-
- if (DevicePath1 == NULL || DevicePath2 == NULL) {
- return (-2);
- }
-
- Acpi1 = (ACPI_HID_DEVICE_PATH *) DevicePath1;
- Acpi2 = (ACPI_HID_DEVICE_PATH *) DevicePath2;
- if (Acpi1->HID > Acpi2->HID || (Acpi1->HID == Acpi2->HID && Acpi1->UID > Acpi2->UID)) {
- return 1;
- }
-
- if (Acpi1->HID == Acpi2->HID && Acpi1->UID == Acpi2->UID) {
- return 0;
- }
-
- return -1;
-}
-
-/**
- Function to compare 2 PCI device paths.
-
- @param[in] DevicePath1 The first device path to compare.
- @param[in] DevicePath2 The second device path to compare.
-
- @retval 0 The device paths represent the same device.
- @return Non zero if the devices are different, zero otherwise.
-**/
-INTN
-EFIAPI
-DevPathComparePci (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
- )
-{
- PCI_DEVICE_PATH *Pci1;
- PCI_DEVICE_PATH *Pci2;
-
- ASSERT(DevicePath1 != NULL);
- ASSERT(DevicePath2 != NULL);
-
- Pci1 = (PCI_DEVICE_PATH *) DevicePath1;
- Pci2 = (PCI_DEVICE_PATH *) DevicePath2;
- if (Pci1->Device > Pci2->Device || (Pci1->Device == Pci2->Device && Pci1->Function > Pci2->Function)) {
- return 1;
- }
-
- if (Pci1->Device == Pci2->Device && Pci1->Function == Pci2->Function) {
- return 0;
- }
-
- return -1;
-}
-
-/**
- Do a comparison on 2 device paths.
-
- @param[in] DevicePath1 The first device path.
- @param[in] DevicePath2 The second device path.
-
- @retval 0 The 2 device paths are the same.
- @retval <0 DevicePath2 is greater than DevicePath1.
- @retval >0 DevicePath1 is greater than DevicePath2.
-**/
-INTN
-EFIAPI
-DevPathCompareDefault (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
- )
-{
- UINTN DevPathSize1;
- UINTN DevPathSize2;
-
- ASSERT(DevicePath1 != NULL);
- ASSERT(DevicePath2 != NULL);
-
- DevPathSize1 = DevicePathNodeLength (DevicePath1);
- DevPathSize2 = DevicePathNodeLength (DevicePath2);
- if (DevPathSize1 > DevPathSize2) {
- return 1;
- } else if (DevPathSize1 < DevPathSize2) {
- return -1;
- } else {
- return CompareMem (DevicePath1, DevicePath2, DevPathSize1);
- }
-}
-
-/**
- DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialHardDrive (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- HARDDRIVE_DEVICE_PATH *Hd;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Hd = (HARDDRIVE_DEVICE_PATH *) DevicePathNode;
- if (MappingItem->Mtd == MTDTypeUnknown) {
- MappingItem->Mtd = MTDTypeHardDisk;
- }
-
- AppendCSDNum (MappingItem, Hd->PartitionNumber);
-}
-
-/**
- DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialAtapi (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- ATAPI_DEVICE_PATH *Atapi;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Atapi = (ATAPI_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster));
-}
-
-/**
- DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialCdRom (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- CDROM_DEVICE_PATH *Cd;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Cd = (CDROM_DEVICE_PATH *) DevicePathNode;
- MappingItem->Mtd = MTDTypeCDRom;
- AppendCSDNum (MappingItem, Cd->BootEntry);
-}
-
-/**
- DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialFibre (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- FIBRECHANNEL_DEVICE_PATH *Fibre;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Fibre = (FIBRECHANNEL_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Fibre->WWN);
- AppendCSDNum (MappingItem, Fibre->Lun);
-}
-
-/**
- DevicePathNode must be SerialUart type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialUart (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- UART_DEVICE_PATH *Uart;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Uart = (UART_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Uart->BaudRate);
- AppendCSDNum (MappingItem, Uart->DataBits);
- AppendCSDNum (MappingItem, Uart->Parity);
- AppendCSDNum (MappingItem, Uart->StopBits);
-}
-
-/**
- DevicePathNode must be SerialUSB type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialUsb (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- USB_DEVICE_PATH *Usb;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_HANDLE TempHandle;
- EFI_STATUS Status;
- USB_INTERFACE_DESCRIPTOR InterfaceDesc;
-
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Usb = (USB_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Usb->ParentPortNumber);
- AppendCSDNum (MappingItem, Usb->InterfaceNumber);
-
- if (PcdGetBool(PcdUsbExtendedDecode)) {
- Status = gBS->LocateDevicePath( &gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle );
- UsbIo = NULL;
- if (!EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol(TempHandle, &gEfiUsbIoProtocolGuid, (VOID**)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- }
-
- if (!EFI_ERROR(Status)) {
- ASSERT(UsbIo != NULL);
- Status = UsbIo->UsbGetInterfaceDescriptor(UsbIo, &InterfaceDesc);
- if (!EFI_ERROR(Status)) {
- if (InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS && MappingItem->Mtd == MTDTypeUnknown) {
- switch (InterfaceDesc.InterfaceSubClass){
- case USB_MASS_STORE_SCSI:
- MappingItem->Mtd = MTDTypeHardDisk;
- break;
- case USB_MASS_STORE_8070I:
- case USB_MASS_STORE_UFI:
- MappingItem->Mtd = MTDTypeFloppy;
- break;
- case USB_MASS_STORE_8020I:
- MappingItem->Mtd = MTDTypeCDRom;
- break;
- }
- }
- }
- }
- }
-}
-
-/**
- DevicePathNode must be SerialVendor type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-
-**/
-VOID
-EFIAPI
-DevPathSerialVendor (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- VENDOR_DEVICE_PATH *Vendor;
- SAS_DEVICE_PATH *Sas;
- UINTN TargetNameLength;
- UINTN Index;
- CHAR16 *Buffer;
-
- if (DevicePathNode == NULL || MappingItem == NULL) {
- return;
- }
-
- Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode;
- AppendCSDGuid (MappingItem, &Vendor->Guid);
-
- if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) {
- Sas = (SAS_DEVICE_PATH *) Vendor;
- AppendCSDNum (MappingItem, Sas->SasAddress);
- AppendCSDNum (MappingItem, Sas->Lun);
- AppendCSDNum (MappingItem, Sas->DeviceTopology);
- AppendCSDNum (MappingItem, Sas->RelativeTargetPort);
- } else {
- TargetNameLength = MIN(DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32(PcdShellVendorExtendedDecode));
- if (TargetNameLength != 0) {
- //
- // String is 2 chars per data byte, plus NULL terminator
- //
- Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof(CHAR16));
- ASSERT(Buffer != NULL);
- if (Buffer == NULL) {
- return;
- }
-
- //
- // Build the string data
- //
- for (Index = 0; Index < TargetNameLength; Index++) {
- Buffer = CatSPrint (Buffer, L"%02x", *((UINT8*)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index));
-}
-
- //
- // Append the new data block
- //
- AppendCSDStr (MappingItem, Buffer);
-
- FreePool(Buffer);
- }
- }
-}
-
-/**
- DevicePathNode must be SerialLun type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialLun (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Lun->Lun);
-}
-
-/**
- DevicePathNode must be SerialSata type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialSata (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- SATA_DEVICE_PATH *Sata;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Sata = (SATA_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Sata->HBAPortNumber);
- AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);
- AppendCSDNum (MappingItem, Sata->Lun);
-}
-
-/**
- DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialIScsi (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- ISCSI_DEVICE_PATH *IScsi;
- UINT8 *IScsiTargetName;
- CHAR16 *TargetName;
- UINTN TargetNameLength;
- UINTN Index;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- if (PcdGetBool(PcdShellDecodeIScsiMapNames)) {
- IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, IScsi->NetworkProtocol);
- AppendCSDNum (MappingItem, IScsi->LoginOption);
- AppendCSDNum (MappingItem, IScsi->Lun);
- AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
- TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
- if (TargetNameLength > 0) {
- TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
- if (TargetName != NULL) {
- IScsiTargetName = (UINT8 *) (IScsi + 1);
- for (Index = 0; Index < TargetNameLength; Index++) {
- TargetName[Index] = (CHAR16) IScsiTargetName[Index];
- }
- AppendCSDStr (MappingItem, TargetName);
- FreePool (TargetName);
- }
- }
- }
-}
-
-/**
- DevicePathNode must be SerialI20 type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialI2O (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- I2O_DEVICE_PATH *DevicePath_I20;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- DevicePath_I20 = (I2O_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, DevicePath_I20->Tid);
-}
-
-/**
- DevicePathNode must be Mac Address type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialMacAddr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- MAC_ADDR_DEVICE_PATH *Mac;
- UINTN HwAddressSize;
- UINTN Index;
- CHAR16 Buffer[64];
- CHAR16 *PBuffer;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Mac = (MAC_ADDR_DEVICE_PATH *) DevicePathNode;
-
- HwAddressSize = sizeof (EFI_MAC_ADDRESS);
- if (Mac->IfType == 0x01 || Mac->IfType == 0x00) {
- HwAddressSize = 6;
- }
-
- for (Index = 0, PBuffer = Buffer; Index < HwAddressSize; Index++, PBuffer += 2) {
- UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Mac->MacAddress.Addr[Index]);
- }
-
- AppendCSDStr (MappingItem, Buffer);
-}
-
-/**
- DevicePathNode must be InfiniBand type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialInfiniBand (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- INFINIBAND_DEVICE_PATH *InfiniBand;
- UINTN Index;
- CHAR16 Buffer[64];
- CHAR16 *PBuffer;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- InfiniBand = (INFINIBAND_DEVICE_PATH *) DevicePathNode;
- for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
- UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) InfiniBand->PortGid[Index]);
- }
-
- AppendCSDStr (MappingItem, Buffer);
- AppendCSDNum (MappingItem, InfiniBand->ServiceId);
- AppendCSDNum (MappingItem, InfiniBand->TargetPortId);
- AppendCSDNum (MappingItem, InfiniBand->DeviceId);
-}
-
-/**
- DevicePathNode must be IPv4 type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialIPv4 (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- IPv4_DEVICE_PATH *Ip;
- CHAR16 Buffer[10];
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Ip = (IPv4_DEVICE_PATH *) DevicePathNode;
- UnicodeSPrint (
- Buffer,
- 0,
- L"%02x%02x%02x%02x",
- (UINTN) Ip->LocalIpAddress.Addr[0],
- (UINTN) Ip->LocalIpAddress.Addr[1],
- (UINTN) Ip->LocalIpAddress.Addr[2],
- (UINTN) Ip->LocalIpAddress.Addr[3]
- );
- AppendCSDStr (MappingItem, Buffer);
- AppendCSDNum (MappingItem, Ip->LocalPort);
- UnicodeSPrint (
- Buffer,
- 0,
- L"%02x%02x%02x%02x",
- (UINTN) Ip->RemoteIpAddress.Addr[0],
- (UINTN) Ip->RemoteIpAddress.Addr[1],
- (UINTN) Ip->RemoteIpAddress.Addr[2],
- (UINTN) Ip->RemoteIpAddress.Addr[3]
- );
- AppendCSDStr (MappingItem, Buffer);
- AppendCSDNum (MappingItem, Ip->RemotePort);
-}
-
-/**
- DevicePathNode must be IPv6 type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-
-**/
-VOID
-EFIAPI
-DevPathSerialIPv6 (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- IPv6_DEVICE_PATH *Ip;
- UINTN Index;
- CHAR16 Buffer[64];
- CHAR16 *PBuffer;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Ip = (IPv6_DEVICE_PATH *) DevicePathNode;
- for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
- UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->LocalIpAddress.Addr[Index]);
- }
-
- AppendCSDStr (MappingItem, Buffer);
- AppendCSDNum (MappingItem, Ip->LocalPort);
- for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
- UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->RemoteIpAddress.Addr[Index]);
- }
-
- AppendCSDStr (MappingItem, Buffer);
- AppendCSDNum (MappingItem, Ip->RemotePort);
-}
-
-/**
- DevicePathNode must be SCSI type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-
-**/
-VOID
-EFIAPI
-DevPathSerialScsi (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- SCSI_DEVICE_PATH *Scsi;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Scsi = (SCSI_DEVICE_PATH *) DevicePathNode;
- AppendCSDNum (MappingItem, Scsi->Pun);
- AppendCSDNum (MappingItem, Scsi->Lun);
-}
-
-/**
- DevicePathNode must be 1394 type and this will populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerial1394 (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- F1394_DEVICE_PATH *DevicePath_F1394;
- CHAR16 Buffer[20];
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- DevicePath_F1394 = (F1394_DEVICE_PATH *) DevicePathNode;
- UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid);
- AppendCSDStr (MappingItem, Buffer);
-}
-
-/**
- If the node is floppy type then populate the MappingItem.
-
- @param[in] DevicePathNode The node to get info on.
- @param[in] MappingItem The info item to populate.
- @param[in] DevicePath Ignored.
-**/
-VOID
-EFIAPI
-DevPathSerialAcpi (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- ACPI_HID_DEVICE_PATH *Acpi;
-
- ASSERT(DevicePathNode != NULL);
- ASSERT(MappingItem != NULL);
-
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;
- if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
- if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
- MappingItem->Mtd = MTDTypeFloppy;
- AppendCSDNum (MappingItem, Acpi->UID);
- }
- }
-}
-
-/**
- Empty function used for unknown devices.
-
- @param[in] DevicePathNode Ignored.
- @param[in] MappingItem Ignored.
- @param[in] DevicePath Ignored.
-
- Does nothing.
-**/
-VOID
-EFIAPI
-DevPathSerialDefault (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- return;
-}
-
-DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable[] = {
- {
- HARDWARE_DEVICE_PATH,
- HW_PCI_DP,
- DevPathSerialDefault,
- DevPathComparePci
- },
- {
- ACPI_DEVICE_PATH,
- ACPI_DP,
- DevPathSerialAcpi,
- DevPathCompareAcpi
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_ATAPI_DP,
- DevPathSerialAtapi,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_SCSI_DP,
- DevPathSerialScsi,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_FIBRECHANNEL_DP,
- DevPathSerialFibre,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_1394_DP,
- DevPathSerial1394,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_USB_DP,
- DevPathSerialUsb,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_I2O_DP,
- DevPathSerialI2O,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_MAC_ADDR_DP,
- DevPathSerialMacAddr,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_IPv4_DP,
- DevPathSerialIPv4,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_IPv6_DP,
- DevPathSerialIPv6,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_INFINIBAND_DP,
- DevPathSerialInfiniBand,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_UART_DP,
- DevPathSerialUart,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- DevPathSerialVendor,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_DEVICE_LOGICAL_UNIT_DP,
- DevPathSerialLun,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_SATA_DP,
- DevPathSerialSata,
- DevPathCompareDefault
- },
- {
- MESSAGING_DEVICE_PATH,
- MSG_ISCSI_DP,
- DevPathSerialIScsi,
- DevPathCompareDefault
- },
- {
- MEDIA_DEVICE_PATH,
- MEDIA_HARDDRIVE_DP,
- DevPathSerialHardDrive,
- DevPathCompareDefault
- },
- {
- MEDIA_DEVICE_PATH,
- MEDIA_CDROM_DP,
- DevPathSerialCdRom,
- DevPathCompareDefault
- },
- {
- MEDIA_DEVICE_PATH,
- MEDIA_VENDOR_DP,
- DevPathSerialVendor,
- DevPathCompareDefault
- },
- {
- 0,
- 0,
- NULL,
- NULL
- }
-};
-
-/**
- Function to determine if a device path node is Hi or not.
-
- @param[in] DevicePathNode The node to check.
-
- @retval TRUE The node is Hi.
- @retval FALSE The node is not Hi.
-**/
-BOOLEAN
-EFIAPI
-IsHIDevicePathNode (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
- )
-{
- ACPI_HID_DEVICE_PATH *Acpi;
-
- ASSERT(DevicePathNode != NULL);
-
- if (DevicePathNode->Type == HARDWARE_DEVICE_PATH) {
- return TRUE;
- }
-
- if (DevicePathNode->Type == ACPI_DEVICE_PATH) {
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;
- switch (EISA_ID_TO_NUM (Acpi->HID)) {
- case 0x0301:
- case 0x0401:
- case 0x0501:
- case 0x0604:
- return FALSE;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Function to convert a standard device path structure into a Hi version.
-
- @param[in] DevicePath The device path to convert.
-
- @return the device path portion that is Hi.
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-EFIAPI
-GetHIDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- UINTN NonHIDevicePathNodeCount;
- UINTN Index;
- EFI_DEV_PATH Node;
- EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
-
- ASSERT(DevicePath != NULL);
-
- NonHIDevicePathNodeCount = 0;
-
- HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
- SetDevicePathEndNode (HIDevicePath);
-
- Node.DevPath.Type = END_DEVICE_PATH_TYPE;
- Node.DevPath.SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
- Node.DevPath.Length[0] = (UINT8)sizeof (EFI_DEVICE_PATH_PROTOCOL);
- Node.DevPath.Length[1] = 0;
-
- while (!IsDevicePathEnd (DevicePath)) {
- if (IsHIDevicePathNode (DevicePath)) {
- for (Index = 0; Index < NonHIDevicePathNodeCount; Index++) {
- TempDevicePath = AppendDevicePathNode (HIDevicePath, &Node.DevPath);
- FreePool (HIDevicePath);
- HIDevicePath = TempDevicePath;
- }
-
- TempDevicePath = AppendDevicePathNode (HIDevicePath, DevicePath);
- FreePool (HIDevicePath);
- HIDevicePath = TempDevicePath;
- } else {
- NonHIDevicePathNodeCount++;
- }
- //
- // Next device path node
- //
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath);
- }
-
- return HIDevicePath;
-}
-
-/**
- Function to walk the device path looking for a dumpable node.
-
- @param[in] MappingItem The Item to fill with data.
- @param[in] DevicePath The path of the item to get data on.
-
- @return EFI_SUCCESS Always returns success.
-**/
-EFI_STATUS
-EFIAPI
-GetDeviceConsistMappingInfo (
- IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- SERIAL_DECODE_FUNCTION SerialFun;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath;
-
- ASSERT(DevicePath != NULL);
- ASSERT(MappingItem != NULL);
-
- SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);
- OriginalDevicePath = DevicePath;
-
- while (!IsDevicePathEnd (DevicePath)) {
- //
- // Find the handler to dump this device path node and
- // initialize with generic function in case nothing is found
- //
- for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
-
- if (DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type &&
- DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType
- ) {
- SerialFun = DevPathConsistMappingTable[Index].SerialFun;
- break;
- }
- }
-
- SerialFun (DevicePath, MappingItem, OriginalDevicePath);
-
- //
- // Next device path node
- //
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to initialize the table for creating consistent map names.
-
- @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
-
- @retval EFI_SUCCESS The table was created successfully.
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandConsistMappingInitialize (
- OUT EFI_DEVICE_PATH_PROTOCOL ***Table
- )
-{
- EFI_HANDLE *HandleBuffer;
- UINTN HandleNum;
- UINTN HandleLoop;
- EFI_DEVICE_PATH_PROTOCOL **TempTable;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
- UINTN Index;
- EFI_STATUS Status;
-
- HandleBuffer = NULL;
-
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleNum,
- &HandleBuffer
- );
- ASSERT_EFI_ERROR(Status);
-
- TempTable = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL *));
- if (TempTable == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (HandleLoop = 0 ; HandleLoop < HandleNum ; HandleLoop++) {
- DevicePath = DevicePathFromHandle (HandleBuffer[HandleLoop]);
- if (DevicePath == NULL) {
- continue;
- }
-
- HIDevicePath = GetHIDevicePath (DevicePath);
- if (HIDevicePath == NULL) {
- continue;
- }
-
- for (Index = 0; TempTable[Index] != NULL; Index++) {
- if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) {
- FreePool (HIDevicePath);
- break;
- }
- }
-
- if (TempTable[Index] == NULL) {
- TempTable[Index] = HIDevicePath;
- }
- }
-
- for (Index = 0; TempTable[Index] != NULL; Index++);
- PerformQuickSort(TempTable, Index, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
- *Table = TempTable;
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to uninitialize the table for creating consistent map names.
-
- The parameter must have been received from ShellCommandConsistMappingInitialize.
-
- @param[out] Table The pointer to pointer to DevicePathProtocol object.
-
- @retval EFI_SUCCESS The table was deleted successfully.
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandConsistMappingUnInitialize (
- EFI_DEVICE_PATH_PROTOCOL **Table
- )
-{
- UINTN Index;
-
- ASSERT(Table != NULL);
-
- for (Index = 0; Table[Index] != NULL; Index++) {
- FreePool (Table[Index]);
- }
-
- FreePool (Table);
- return EFI_SUCCESS;
-}
-
-/**
- Create a consistent mapped name for the device specified by DevicePath
- based on the Table.
-
- This must be called after ShellCommandConsistMappingInitialize() and
- before ShellCommandConsistMappingUnInitialize() is called.
-
- @param[in] DevicePath The pointer to the dev path for the device.
- @param[in] Table The Table of mapping information.
-
- @retval NULL A consistent mapped name could not be created.
- @return A pointer to a string allocated from pool with the device name.
-**/
-CHAR16 *
-EFIAPI
-ShellCommandConsistMappingGenMappingName (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL **Table
- )
-{
- POOL_PRINT Str;
- DEVICE_CONSIST_MAPPING_INFO MappingInfo;
- EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
- UINTN Index;
- UINTN NewSize;
-
- ASSERT(DevicePath != NULL);
- ASSERT(Table != NULL);
-
- HIDevicePath = GetHIDevicePath (DevicePath);
- if (HIDevicePath == NULL) {
- return NULL;
- }
-
- for (Index = 0; Table[Index] != NULL; Index++) {
- if (DevicePathCompare (&Table[Index], &HIDevicePath) == 0) {
- break;
- }
- }
-
- FreePool (HIDevicePath);
- if (Table[Index] == NULL) {
- return NULL;
- }
-
- MappingInfo.Hi = Index;
- MappingInfo.Mtd = MTDTypeUnknown;
- MappingInfo.Digital = FALSE;
-
- GetDeviceConsistMappingInfo (&MappingInfo, DevicePath);
-
- SetMem (&Str, sizeof (Str), 0);
- for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) {
- if (MappingInfo.Mtd == mMTDName[Index].MTDType) {
- break;
- }
- }
-
- if (mMTDName[Index].MTDType != MTDTypeEnd) {
- CatPrint (&Str, L"%s", mMTDName[Index].Name);
- }
-
- CatPrint (&Str, L"%d", (UINTN) MappingInfo.Hi);
- if (MappingInfo.Csd.Str != NULL) {
- CatPrint (&Str, L"%s", MappingInfo.Csd.Str);
- FreePool (MappingInfo.Csd.Str);
- }
-
- if (Str.Str != NULL) {
- CatPrint (&Str, L":");
- }
-
- NewSize = (Str.Len + 1) * sizeof (CHAR16);
- Str.Str = ReallocatePool (Str.Len, NewSize, Str.Str);
- if (Str.Str == NULL) {
- return (NULL);
- }
- Str.Str[Str.Len] = CHAR_NULL;
- return Str.Str;
-}
-
-/**
- Function to search the list of mappings for the node on the list based on the key.
-
- @param[in] MapKey String Key to search for on the map
-
- @return the node on the list.
-**/
-SHELL_MAP_LIST *
-EFIAPI
-ShellCommandFindMapItem (
- IN CONST CHAR16 *MapKey
- )
-{
- SHELL_MAP_LIST *MapListItem;
-
- for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &MapListItem->Link)
- ; MapListItem = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &MapListItem->Link)
- ){
- if (gUnicodeCollation->StriColl(gUnicodeCollation,MapListItem->MapName,(CHAR16*)MapKey) == 0) {
- return (MapListItem);
- }
- }
- return (NULL);
-}
-
-
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
deleted file mode 100644
index 63886690d0..0000000000
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ /dev/null
@@ -1,1672 +0,0 @@
-/** @file
- Provides interface to shell internal functions for shell commands.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellCommandLib.h"
-
-// STATIC local variables
-STATIC SHELL_COMMAND_INTERNAL_LIST_ENTRY mCommandList;
-STATIC SCRIPT_FILE_LIST mScriptList;
-STATIC ALIAS_LIST mAliasList;
-STATIC BOOLEAN mEchoState;
-STATIC BOOLEAN mExitRequested;
-STATIC UINT64 mExitCode;
-STATIC BOOLEAN mExitScript;
-STATIC CHAR16 *mProfileList;
-STATIC UINTN mProfileListSize;
-STATIC UINTN mFsMaxCount = 0;
-STATIC UINTN mBlkMaxCount = 0;
-STATIC BUFFER_LIST mFileHandleList;
-
-// global variables required by library class.
-EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation = NULL;
-SHELL_MAP_LIST gShellMapList;
-SHELL_MAP_LIST *gShellCurDir = NULL;
-
-CONST CHAR16* SupportLevel[] = {
- L"Minimal",
- L"Scripting",
- L"Basic",
- L"Interactive"
-};
-
-/**
- Function to make sure that the global protocol pointers are valid.
- must be called after constructor before accessing the pointers.
-**/
-EFI_STATUS
-EFIAPI
-CommandInit(
- VOID
- )
-{
- EFI_STATUS Status;
- if (gUnicodeCollation == NULL) {
- Status = gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&gUnicodeCollation);
- if (EFI_ERROR(Status)) {
- return (EFI_DEVICE_ERROR);
- }
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Constructor for the Shell Command library.
-
- Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the initialization was complete sucessfully
-**/
-RETURN_STATUS
-EFIAPI
-ShellCommandLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- InitializeListHead(&gShellMapList.Link);
- InitializeListHead(&mCommandList.Link);
- InitializeListHead(&mAliasList.Link);
- InitializeListHead(&mScriptList.Link);
- InitializeListHead(&mFileHandleList.Link);
- mEchoState = TRUE;
-
- mExitRequested = FALSE;
- mExitScript = FALSE;
- mProfileListSize = 0;
- mProfileList = NULL;
-
- if (gUnicodeCollation == NULL) {
- Status = gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&gUnicodeCollation);
- if (EFI_ERROR(Status)) {
- return (EFI_DEVICE_ERROR);
- }
- }
-
- return (RETURN_SUCCESS);
-}
-
-/**
- Frees list of file handles.
-
- @param[in] List The list to free.
-**/
-VOID
-EFIAPI
-FreeFileHandleList (
- IN BUFFER_LIST *List
- )
-{
- BUFFER_LIST *BufferListEntry;
-
- if (List == NULL){
- return;
- }
- //
- // enumerate through the buffer list and free all memory
- //
- for ( BufferListEntry = ( BUFFER_LIST *)GetFirstNode(&List->Link)
- ; !IsListEmpty (&List->Link)
- ; BufferListEntry = (BUFFER_LIST *)GetFirstNode(&List->Link)
- ){
- RemoveEntryList(&BufferListEntry->Link);
- ASSERT(BufferListEntry->Buffer != NULL);
- SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE*)(BufferListEntry->Buffer))->Path);
- SHELL_FREE_NON_NULL(BufferListEntry->Buffer);
- SHELL_FREE_NON_NULL(BufferListEntry);
- }
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval RETURN_SUCCESS this function always returns success
-**/
-RETURN_STATUS
-EFIAPI
-ShellCommandLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
- ALIAS_LIST *Node2;
- SCRIPT_FILE_LIST *Node3;
- SHELL_MAP_LIST *MapNode;
- //
- // enumerate throught the list and free all the memory
- //
- while (!IsListEmpty (&mCommandList.Link)) {
- Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode(&mCommandList.Link);
- RemoveEntryList(&Node->Link);
- SHELL_FREE_NON_NULL(Node->CommandString);
- FreePool(Node);
- DEBUG_CODE(Node = NULL;);
- }
-
- //
- // enumerate through the alias list and free all memory
- //
- while (!IsListEmpty (&mAliasList.Link)) {
- Node2 = (ALIAS_LIST *)GetFirstNode(&mAliasList.Link);
- RemoveEntryList(&Node2->Link);
- SHELL_FREE_NON_NULL(Node2->CommandString);
- SHELL_FREE_NON_NULL(Node2->Alias);
- SHELL_FREE_NON_NULL(Node2);
- DEBUG_CODE(Node2 = NULL;);
- }
-
- //
- // enumerate throught the list and free all the memory
- //
- while (!IsListEmpty (&mScriptList.Link)) {
- Node3 = (SCRIPT_FILE_LIST *)GetFirstNode(&mScriptList.Link);
- RemoveEntryList(&Node3->Link);
- DeleteScriptFileStruct(Node3->Data);
- FreePool(Node3);
- }
-
- //
- // enumerate throught the mappings list and free all the memory
- //
- if (!IsListEmpty(&gShellMapList.Link)) {
- for (MapNode = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsListEmpty (&gShellMapList.Link)
- ; MapNode = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ){
- ASSERT(MapNode != NULL);
- RemoveEntryList(&MapNode->Link);
- SHELL_FREE_NON_NULL(MapNode->DevicePath);
- SHELL_FREE_NON_NULL(MapNode->MapName);
- SHELL_FREE_NON_NULL(MapNode->CurrentDirectoryPath);
- FreePool(MapNode);
- }
- }
- if (!IsListEmpty(&mFileHandleList.Link)){
- FreeFileHandleList(&mFileHandleList);
- }
-
- if (mProfileList != NULL) {
- FreePool(mProfileList);
- }
-
- gUnicodeCollation = NULL;
- gShellCurDir = NULL;
-
- return (RETURN_SUCCESS);
-}
-
-/**
- Find a dynamic command protocol instance given a command name string.
-
- @param CommandString the command name string
-
- @return instance the command protocol instance, if dynamic command instance found
- @retval NULL no dynamic command protocol instance found for name
-**/
-CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *
-EFIAPI
-ShellCommandFindDynamicCommand (
- IN CONST CHAR16 *CommandString
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *CommandHandleList;
- EFI_HANDLE *NextCommand;
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
-
- CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid);
- if (CommandHandleList == NULL) {
- //
- // not found or out of resources
- //
- return NULL;
- }
-
- for (NextCommand = CommandHandleList; *NextCommand != NULL; NextCommand++) {
- Status = gBS->HandleProtocol(
- *NextCommand,
- &gEfiShellDynamicCommandProtocolGuid,
- (VOID **)&DynamicCommand
- );
-
- if (EFI_ERROR(Status)) {
- continue;
- }
-
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandString,
- (CHAR16*)DynamicCommand->CommandName) == 0
- ){
- FreePool(CommandHandleList);
- return (DynamicCommand);
- }
- }
-
- FreePool(CommandHandleList);
- return (NULL);
-}
-
-/**
- Checks if a command exists as a dynamic command protocol instance
-
- @param[in] CommandString The command string to check for on the list.
-**/
-BOOLEAN
-EFIAPI
-ShellCommandDynamicCommandExists (
- IN CONST CHAR16 *CommandString
- )
-{
- return (BOOLEAN) ((ShellCommandFindDynamicCommand(CommandString) != NULL));
-}
-
-/**
- Checks if a command is already on the internal command list.
-
- @param[in] CommandString The command string to check for on the list.
-**/
-BOOLEAN
-EFIAPI
-ShellCommandIsCommandOnInternalList(
- IN CONST CHAR16 *CommandString
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
-
- //
- // assert for NULL parameter
- //
- ASSERT(CommandString != NULL);
-
- //
- // check for the command
- //
- for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode(&mCommandList.Link)
- ; !IsNull(&mCommandList.Link, &Node->Link)
- ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode(&mCommandList.Link, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandString,
- Node->CommandString) == 0
- ){
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Checks if a command exists, either internally or through the dynamic command protocol.
-
- @param[in] CommandString The command string to check for on the list.
-**/
-BOOLEAN
-EFIAPI
-ShellCommandIsCommandOnList(
- IN CONST CHAR16 *CommandString
- )
-{
- if (ShellCommandIsCommandOnInternalList(CommandString)) {
- return TRUE;
- }
-
- return ShellCommandDynamicCommandExists(CommandString);
-}
-
-/**
- Get the help text for a dynamic command.
-
- @param[in] CommandString The command name.
-
- @retval NULL No help text was found.
- @return String of help text. Caller required to free.
-**/
-CHAR16*
-EFIAPI
-ShellCommandGetDynamicCommandHelp(
- IN CONST CHAR16 *CommandString
- )
-{
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
-
- DynamicCommand = (EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *)ShellCommandFindDynamicCommand(CommandString);
- if (DynamicCommand == NULL) {
- return (NULL);
- }
-
- //
- // TODO: how to get proper language?
- //
- return DynamicCommand->GetHelp(DynamicCommand, "en");
-}
-
-/**
- Get the help text for an internal command.
-
- @param[in] CommandString The command name.
-
- @retval NULL No help text was found.
- @return String of help text. Caller reuiqred to free.
-**/
-CHAR16*
-EFIAPI
-ShellCommandGetInternalCommandHelp(
- IN CONST CHAR16 *CommandString
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
-
- //
- // assert for NULL parameter
- //
- ASSERT(CommandString != NULL);
-
- //
- // check for the command
- //
- for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode(&mCommandList.Link)
- ; !IsNull(&mCommandList.Link, &Node->Link)
- ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode(&mCommandList.Link, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandString,
- Node->CommandString) == 0
- ){
- return (HiiGetString(Node->HiiHandle, Node->ManFormatHelp, NULL));
- }
- }
- return (NULL);
-}
-
-/**
- Get the help text for a command.
-
- @param[in] CommandString The command name.
-
- @retval NULL No help text was found.
- @return String of help text.Caller reuiqred to free.
-**/
-CHAR16*
-EFIAPI
-ShellCommandGetCommandHelp (
- IN CONST CHAR16 *CommandString
- )
-{
- CHAR16 *HelpStr;
- HelpStr = ShellCommandGetInternalCommandHelp(CommandString);
-
- if (HelpStr == NULL) {
- HelpStr = ShellCommandGetDynamicCommandHelp(CommandString);
- }
-
- return HelpStr;
-}
-
-
-/**
- Registers handlers of type SHELL_RUN_COMMAND and
- SHELL_GET_MAN_FILENAME for each shell command.
-
- If the ShellSupportLevel is greater than the value of the
- PcdShellSupportLevel then return RETURN_UNSUPPORTED.
-
- Registers the handlers specified by GetHelpInfoHandler and CommandHandler
- with the command specified by CommandString. If the command named by
- CommandString has already been registered, then return
- RETURN_ALREADY_STARTED.
-
- If there are not enough resources available to register the handlers then
- RETURN_OUT_OF_RESOURCES is returned.
-
- If CommandString is NULL, then ASSERT().
- If GetHelpInfoHandler is NULL, then ASSERT().
- If CommandHandler is NULL, then ASSERT().
- If ProfileName is NULL, then ASSERT().
-
- @param[in] CommandString Pointer to the command name. This is the
- name to look for on the command line in
- the shell.
- @param[in] CommandHandler Pointer to a function that runs the
- specified command.
- @param[in] GetManFileName Pointer to a function that provides man
- filename.
- @param[in] ShellMinSupportLevel minimum Shell Support Level which has this
- function.
- @param[in] ProfileName profile name to require for support of this
- function.
- @param[in] CanAffectLE indicates whether this command's return value
- can change the LASTERROR environment variable.
- @param[in] HiiHandle Handle of this command's HII entry.
- @param[in] ManFormatHelp HII locator for the help text.
-
- @retval RETURN_SUCCESS The handlers were registered.
- @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to
- register the shell command.
- @retval RETURN_UNSUPPORTED the ShellMinSupportLevel was higher than the
- currently allowed support level.
- @retval RETURN_ALREADY_STARTED The CommandString represents a command that
- is already registered. Only 1 handler set for
- a given command is allowed.
- @sa SHELL_GET_MAN_FILENAME
- @sa SHELL_RUN_COMMAND
-**/
-RETURN_STATUS
-EFIAPI
-ShellCommandRegisterCommandName (
- IN CONST CHAR16 *CommandString,
- IN SHELL_RUN_COMMAND CommandHandler,
- IN SHELL_GET_MAN_FILENAME GetManFileName,
- IN UINT32 ShellMinSupportLevel,
- IN CONST CHAR16 *ProfileName,
- IN CONST BOOLEAN CanAffectLE,
- IN CONST EFI_HANDLE HiiHandle,
- IN CONST EFI_STRING_ID ManFormatHelp
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Command;
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *PrevCommand;
- INTN LexicalMatchValue;
-
- //
- // Initialize local variables.
- //
- Command = NULL;
- PrevCommand = NULL;
- LexicalMatchValue = 0;
-
- //
- // ASSERTs for NULL parameters
- //
- ASSERT(CommandString != NULL);
- ASSERT(GetManFileName != NULL);
- ASSERT(CommandHandler != NULL);
- ASSERT(ProfileName != NULL);
-
- //
- // check for shell support level
- //
- if (PcdGet8(PcdShellSupportLevel) < ShellMinSupportLevel) {
- return (RETURN_UNSUPPORTED);
- }
-
- //
- // check for already on the list
- //
- if (ShellCommandIsCommandOnList(CommandString)) {
- return (RETURN_ALREADY_STARTED);
- }
-
- //
- // allocate memory for new struct
- //
- Node = AllocateZeroPool(sizeof(SHELL_COMMAND_INTERNAL_LIST_ENTRY));
- ASSERT(Node != NULL);
- Node->CommandString = AllocateCopyPool(StrSize(CommandString), CommandString);
- ASSERT(Node->CommandString != NULL);
-
- Node->GetManFileName = GetManFileName;
- Node->CommandHandler = CommandHandler;
- Node->LastError = CanAffectLE;
- Node->HiiHandle = HiiHandle;
- Node->ManFormatHelp = ManFormatHelp;
-
- if ( StrLen(ProfileName)>0
- && ((mProfileList != NULL
- && StrStr(mProfileList, ProfileName) == NULL) || mProfileList == NULL)
- ){
- ASSERT((mProfileList == NULL && mProfileListSize == 0) || (mProfileList != NULL));
- if (mProfileList == NULL) {
- //
- // If this is the first make a leading ';'
- //
- StrnCatGrow(&mProfileList, &mProfileListSize, L";", 0);
- }
- StrnCatGrow(&mProfileList, &mProfileListSize, ProfileName, 0);
- StrnCatGrow(&mProfileList, &mProfileListSize, L";", 0);
- }
-
- //
- // Insert a new entry on top of the list
- //
- InsertHeadList (&mCommandList.Link, &Node->Link);
-
- //
- // Move a new registered command to its sorted ordered location in the list
- //
- for (Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link),
- PrevCommand = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode (&mCommandList.Link)
- ; !IsNull (&mCommandList.Link, &Command->Link)
- ; Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Command->Link)) {
-
- //
- // Get Lexical Comparison Value between PrevCommand and Command list entry
- //
- LexicalMatchValue = gUnicodeCollation->StriColl (
- gUnicodeCollation,
- PrevCommand->CommandString,
- Command->CommandString
- );
-
- //
- // Swap PrevCommand and Command list entry if PrevCommand list entry
- // is alphabetically greater than Command list entry
- //
- if (LexicalMatchValue > 0){
- Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *) SwapListEntries (&PrevCommand->Link, &Command->Link);
- } else if (LexicalMatchValue < 0) {
- //
- // PrevCommand entry is lexically lower than Command entry
- //
- break;
- }
- }
-
- return (RETURN_SUCCESS);
-}
-
-/**
- Function to get the current Profile string.
-
- @retval NULL There are no installed profiles.
- @return A semi-colon delimited list of profiles.
-**/
-CONST CHAR16 *
-EFIAPI
-ShellCommandGetProfileList (
- VOID
- )
-{
- return (mProfileList);
-}
-
-/**
- Checks if a command string has been registered for CommandString and if so it runs
- the previously registered handler for that command with the command line.
-
- If CommandString is NULL, then ASSERT().
-
- If Sections is specified, then each section name listed will be compared in a casesensitive
- manner, to the section names described in Appendix B UEFI Shell 2.0 spec. If the section exists,
- it will be appended to the returned help text. If the section does not exist, no
- information will be returned. If Sections is NULL, then all help text information
- available will be returned.
-
- @param[in] CommandString Pointer to the command name. This is the name
- found on the command line in the shell.
- @param[in, out] RetVal Pointer to the return vaule from the command handler.
-
- @param[in, out] CanAffectLE indicates whether this command's return value
- needs to be placed into LASTERROR environment variable.
-
- @retval RETURN_SUCCESS The handler was run.
- @retval RETURN_NOT_FOUND The CommandString did not match a registered
- command name.
- @sa SHELL_RUN_COMMAND
-**/
-RETURN_STATUS
-EFIAPI
-ShellCommandRunCommandHandler (
- IN CONST CHAR16 *CommandString,
- IN OUT SHELL_STATUS *RetVal,
- IN OUT BOOLEAN *CanAffectLE OPTIONAL
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
-
- //
- // assert for NULL parameters
- //
- ASSERT(CommandString != NULL);
-
- //
- // check for the command
- //
- for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode(&mCommandList.Link)
- ; !IsNull(&mCommandList.Link, &Node->Link)
- ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode(&mCommandList.Link, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandString,
- Node->CommandString) == 0
- ){
- if (CanAffectLE != NULL) {
- *CanAffectLE = Node->LastError;
- }
- if (RetVal != NULL) {
- *RetVal = Node->CommandHandler(NULL, gST);
- } else {
- Node->CommandHandler(NULL, gST);
- }
- return (RETURN_SUCCESS);
- }
- }
-
- //
- // An internal command was not found, try to find a dynamic command
- //
- DynamicCommand = (EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *)ShellCommandFindDynamicCommand(CommandString);
- if (DynamicCommand != NULL) {
- if (RetVal != NULL) {
- *RetVal = DynamicCommand->Handler(DynamicCommand, gST, gEfiShellParametersProtocol, gEfiShellProtocol);
- } else {
- DynamicCommand->Handler(DynamicCommand, gST, gEfiShellParametersProtocol, gEfiShellProtocol);
- }
- return (RETURN_SUCCESS);
- }
-
- return (RETURN_NOT_FOUND);
-}
-
-/**
- Checks if a command string has been registered for CommandString and if so it
- returns the MAN filename specified for that command.
-
- If CommandString is NULL, then ASSERT().
-
- @param[in] CommandString Pointer to the command name. This is the name
- found on the command line in the shell.\
-
- @retval NULL the commandString was not a registered command.
- @return other the name of the MAN file.
- @sa SHELL_GET_MAN_FILENAME
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameHandler (
- IN CONST CHAR16 *CommandString
- )
-{
- SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node;
-
- //
- // assert for NULL parameters
- //
- ASSERT(CommandString != NULL);
-
- //
- // check for the command
- //
- for ( Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetFirstNode(&mCommandList.Link)
- ; !IsNull(&mCommandList.Link, &Node->Link)
- ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode(&mCommandList.Link, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandString,
- Node->CommandString) == 0
- ){
- return (Node->GetManFileName());
- }
- }
- return (NULL);
-}
-
-/**
- Get the list of all available shell internal commands. This is a linked list
- (via LIST_ENTRY structure). enumerate through it using the BaseLib linked
- list functions. do not modify the values.
-
- @param[in] Sort TRUE to alphabetically sort the values first. FALSE otherwise.
-
- @return a Linked list of all available shell commands.
-**/
-CONST COMMAND_LIST*
-EFIAPI
-ShellCommandGetCommandList (
- IN CONST BOOLEAN Sort
- )
-{
-// if (!Sort) {
-// return ((COMMAND_LIST*)(&mCommandList));
-// }
- return ((COMMAND_LIST*)(&mCommandList));
-}
-
-/**
- Registers aliases to be set as part of the initialization of the shell application.
-
- If Command is NULL, then ASSERT().
- If Alias is NULL, then ASSERT().
-
- @param[in] Command Pointer to the Command
- @param[in] Alias Pointer to Alias
-
- @retval RETURN_SUCCESS The handlers were registered.
- @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to
- register the shell command.
-**/
-RETURN_STATUS
-EFIAPI
-ShellCommandRegisterAlias (
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Alias
- )
-{
- ALIAS_LIST *Node;
- ALIAS_LIST *CommandAlias;
- ALIAS_LIST *PrevCommandAlias;
- INTN LexicalMatchValue;
-
- //
- // Asserts for NULL
- //
- ASSERT(Command != NULL);
- ASSERT(Alias != NULL);
-
- //
- // allocate memory for new struct
- //
- Node = AllocateZeroPool(sizeof(ALIAS_LIST));
- ASSERT(Node != NULL);
- Node->CommandString = AllocateCopyPool(StrSize(Command), Command);
- Node->Alias = AllocateCopyPool(StrSize(Alias), Alias);
- ASSERT(Node->CommandString != NULL);
- ASSERT(Node->Alias != NULL);
-
- InsertHeadList (&mAliasList.Link, &Node->Link);
-
- //
- // Move a new pre-defined registered alias to its sorted ordered location in the list
- //
- for ( CommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link),
- PrevCommandAlias = (ALIAS_LIST *)GetFirstNode (&mAliasList.Link)
- ; !IsNull (&mAliasList.Link, &CommandAlias->Link)
- ; CommandAlias = (ALIAS_LIST *) GetNextNode (&mAliasList.Link, &CommandAlias->Link) ) {
- //
- // Get Lexical comparison value between PrevCommandAlias and CommandAlias List Entry
- //
- LexicalMatchValue = gUnicodeCollation->StriColl (
- gUnicodeCollation,
- PrevCommandAlias->Alias,
- CommandAlias->Alias
- );
-
- //
- // Swap PrevCommandAlias and CommandAlias list entry if PrevCommandAlias list entry
- // is alphabetically greater than CommandAlias list entry
- //
- if (LexicalMatchValue > 0) {
- CommandAlias = (ALIAS_LIST *) SwapListEntries (&PrevCommandAlias->Link, &CommandAlias->Link);
- } else if (LexicalMatchValue < 0) {
- //
- // PrevCommandAlias entry is lexically lower than CommandAlias entry
- //
- break;
- }
- }
-
- return (RETURN_SUCCESS);
-}
-
-/**
- Get the list of all shell alias commands. This is a linked list
- (via LIST_ENTRY structure). enumerate through it using the BaseLib linked
- list functions. do not modify the values.
-
- @return a Linked list of all requested shell alias'.
-**/
-CONST ALIAS_LIST*
-EFIAPI
-ShellCommandGetInitAliasList (
- VOID
- )
-{
- return (&mAliasList);
-}
-
-/**
- Determine if a given alias is on the list of built in alias'.
-
- @param[in] Alias The alias to test for
-
- @retval TRUE The alias is a built in alias
- @retval FALSE The alias is not a built in alias
-**/
-BOOLEAN
-EFIAPI
-ShellCommandIsOnAliasList(
- IN CONST CHAR16 *Alias
- )
-{
- ALIAS_LIST *Node;
-
- //
- // assert for NULL parameter
- //
- ASSERT(Alias != NULL);
-
- //
- // check for the Alias
- //
- for ( Node = (ALIAS_LIST *)GetFirstNode(&mAliasList.Link)
- ; !IsNull(&mAliasList.Link, &Node->Link)
- ; Node = (ALIAS_LIST *)GetNextNode(&mAliasList.Link, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- ASSERT(Node->Alias != NULL);
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)Alias,
- Node->CommandString) == 0
- ){
- return (TRUE);
- }
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)Alias,
- Node->Alias) == 0
- ){
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Function to determine current state of ECHO. Echo determines if lines from scripts
- and ECHO commands are enabled.
-
- @retval TRUE Echo is currently enabled
- @retval FALSE Echo is currently disabled
-**/
-BOOLEAN
-EFIAPI
-ShellCommandGetEchoState(
- VOID
- )
-{
- return (mEchoState);
-}
-
-/**
- Function to set current state of ECHO. Echo determines if lines from scripts
- and ECHO commands are enabled.
-
- If State is TRUE, Echo will be enabled.
- If State is FALSE, Echo will be disabled.
-
- @param[in] State How to set echo.
-**/
-VOID
-EFIAPI
-ShellCommandSetEchoState(
- IN BOOLEAN State
- )
-{
- mEchoState = State;
-}
-
-/**
- Indicate that the current shell or script should exit.
-
- @param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.
- @param[in] ErrorCode The 64 bit error code to return.
-**/
-VOID
-EFIAPI
-ShellCommandRegisterExit (
- IN BOOLEAN ScriptOnly,
- IN CONST UINT64 ErrorCode
- )
-{
- mExitRequested = (BOOLEAN)(!mExitRequested);
- if (mExitRequested) {
- mExitScript = ScriptOnly;
- } else {
- mExitScript = FALSE;
- }
- mExitCode = ErrorCode;
-}
-
-/**
- Retrieve the Exit indicator.
-
- @retval TRUE Exit was indicated.
- @retval FALSE Exis was not indicated.
-**/
-BOOLEAN
-EFIAPI
-ShellCommandGetExit (
- VOID
- )
-{
- return (mExitRequested);
-}
-
-/**
- Retrieve the Exit code.
-
- If ShellCommandGetExit returns FALSE than the return from this is undefined.
-
- @return the value passed into RegisterExit.
-**/
-UINT64
-EFIAPI
-ShellCommandGetExitCode (
- VOID
- )
-{
- return (mExitCode);
-}
-/**
- Retrieve the Exit script indicator.
-
- If ShellCommandGetExit returns FALSE than the return from this is undefined.
-
- @retval TRUE ScriptOnly was indicated.
- @retval FALSE ScriptOnly was not indicated.
-**/
-BOOLEAN
-EFIAPI
-ShellCommandGetScriptExit (
- VOID
- )
-{
- return (mExitScript);
-}
-
-/**
- Function to cleanup all memory from a SCRIPT_FILE structure.
-
- @param[in] Script The pointer to the structure to cleanup.
-**/
-VOID
-EFIAPI
-DeleteScriptFileStruct (
- IN SCRIPT_FILE *Script
- )
-{
- UINT8 LoopVar;
-
- if (Script == NULL) {
- return;
- }
-
- for (LoopVar = 0 ; LoopVar < Script->Argc ; LoopVar++) {
- SHELL_FREE_NON_NULL(Script->Argv[LoopVar]);
- }
- if (Script->Argv != NULL) {
- SHELL_FREE_NON_NULL(Script->Argv);
- }
- Script->CurrentCommand = NULL;
- while (!IsListEmpty (&Script->CommandList)) {
- Script->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetFirstNode(&Script->CommandList);
- if (Script->CurrentCommand != NULL) {
- RemoveEntryList(&Script->CurrentCommand->Link);
- if (Script->CurrentCommand->Cl != NULL) {
- SHELL_FREE_NON_NULL(Script->CurrentCommand->Cl);
- }
- if (Script->CurrentCommand->Data != NULL) {
- SHELL_FREE_NON_NULL(Script->CurrentCommand->Data);
- }
- SHELL_FREE_NON_NULL(Script->CurrentCommand);
- }
- }
- SHELL_FREE_NON_NULL(Script->ScriptName);
- SHELL_FREE_NON_NULL(Script);
-}
-
-/**
- Function to return a pointer to the currently running script file object.
-
- @retval NULL A script file is not currently running.
- @return A pointer to the current script file object.
-**/
-SCRIPT_FILE*
-EFIAPI
-ShellCommandGetCurrentScriptFile (
- VOID
- )
-{
- SCRIPT_FILE_LIST *List;
- if (IsListEmpty (&mScriptList.Link)) {
- return (NULL);
- }
- List = ((SCRIPT_FILE_LIST*)GetFirstNode(&mScriptList.Link));
- return (List->Data);
-}
-
-/**
- Function to set a new script as the currently running one.
-
- This function will correctly stack and unstack nested scripts.
-
- @param[in] Script Pointer to new script information structure. if NULL
- will remove and de-allocate the top-most Script structure.
-
- @return A pointer to the current running script file after this
- change. NULL if removing the final script.
-**/
-SCRIPT_FILE*
-EFIAPI
-ShellCommandSetNewScript (
- IN SCRIPT_FILE *Script OPTIONAL
- )
-{
- SCRIPT_FILE_LIST *Node;
- if (Script == NULL) {
- if (IsListEmpty (&mScriptList.Link)) {
- return (NULL);
- }
- Node = (SCRIPT_FILE_LIST *)GetFirstNode(&mScriptList.Link);
- RemoveEntryList(&Node->Link);
- DeleteScriptFileStruct(Node->Data);
- FreePool(Node);
- } else {
- Node = AllocateZeroPool(sizeof(SCRIPT_FILE_LIST));
- if (Node == NULL) {
- return (NULL);
- }
- Node->Data = Script;
- InsertHeadList(&mScriptList.Link, &Node->Link);
- }
- return (ShellCommandGetCurrentScriptFile());
-}
-
-/**
- Function to generate the next default mapping name.
-
- If the return value is not NULL then it must be callee freed.
-
- @param Type What kind of mapping name to make.
-
- @retval NULL a memory allocation failed.
- @return a new map name string
-**/
-CHAR16*
-EFIAPI
-ShellCommandCreateNewMappingName(
- IN CONST SHELL_MAPPING_TYPE Type
- )
-{
- CHAR16 *String;
- ASSERT(Type < MappingTypeMax);
-
- String = NULL;
-
- String = AllocateZeroPool(PcdGet8(PcdShellMapNameLength) * sizeof(String[0]));
- UnicodeSPrint(
- String,
- PcdGet8(PcdShellMapNameLength) * sizeof(String[0]),
- Type == MappingTypeFileSystem?L"FS%d:":L"BLK%d:",
- Type == MappingTypeFileSystem?mFsMaxCount++:mBlkMaxCount++);
-
- return (String);
-}
-
-/**
- Function to add a map node to the list of map items and update the "path" environment variable (optionally).
-
- If Path is TRUE (during initialization only), the path environment variable will also be updated to include
- default paths on the new map name...
-
- Path should be FALSE when this function is called from the protocol SetMap function.
-
- @param[in] Name The human readable mapped name.
- @param[in] DevicePath The Device Path for this map.
- @param[in] Flags The Flags attribute for this map item.
- @param[in] Path TRUE to update path, FALSE to skip this step (should only be TRUE during initialization).
-
- @retval EFI_SUCCESS The addition was sucessful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandAddMapItemAndUpdatePath(
- IN CONST CHAR16 *Name,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN CONST UINT64 Flags,
- IN CONST BOOLEAN Path
- )
-{
- EFI_STATUS Status;
- SHELL_MAP_LIST *MapListNode;
- CONST CHAR16 *OriginalPath;
- CHAR16 *NewPath;
- UINTN NewPathSize;
-
- NewPathSize = 0;
- NewPath = NULL;
- OriginalPath = NULL;
- Status = EFI_SUCCESS;
-
- MapListNode = AllocateZeroPool(sizeof(SHELL_MAP_LIST));
- if (MapListNode == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- MapListNode->Flags = Flags;
- MapListNode->MapName = AllocateCopyPool(StrSize(Name), Name);
- MapListNode->DevicePath = DuplicateDevicePath(DevicePath);
- if ((MapListNode->MapName == NULL) || (MapListNode->DevicePath == NULL)){
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- InsertTailList(&gShellMapList.Link, &MapListNode->Link);
- }
- }
- if (EFI_ERROR(Status)) {
- if (MapListNode != NULL) {
- if (MapListNode->DevicePath != NULL) {
- FreePool(MapListNode->DevicePath);
- }
- if (MapListNode->MapName != NULL) {
- FreePool(MapListNode->MapName);
- }
- FreePool(MapListNode);
- }
- } else if (Path) {
- //
- // Since there was no error and Path was TRUE
- // Now add the correct path for that mapping
- //
- OriginalPath = gEfiShellProtocol->GetEnv(L"path");
- ASSERT((NewPath == NULL && NewPathSize == 0) || (NewPath != NULL));
- if (OriginalPath != NULL) {
- StrnCatGrow(&NewPath, &NewPathSize, OriginalPath, 0);
- } else {
- StrnCatGrow(&NewPath, &NewPathSize, L".\\", 0);
- }
- StrnCatGrow(&NewPath, &NewPathSize, L";", 0);
- StrnCatGrow(&NewPath, &NewPathSize, Name, 0);
- StrnCatGrow(&NewPath, &NewPathSize, L"\\efi\\tools\\;", 0);
- StrnCatGrow(&NewPath, &NewPathSize, Name, 0);
- StrnCatGrow(&NewPath, &NewPathSize, L"\\efi\\boot\\;", 0);
- StrnCatGrow(&NewPath, &NewPathSize, Name, 0);
- StrnCatGrow(&NewPath, &NewPathSize, L"\\", 0);
-
- Status = gEfiShellProtocol->SetEnv(L"path", NewPath, TRUE);
- ASSERT_EFI_ERROR(Status);
- FreePool(NewPath);
- }
- return (Status);
-}
-
-/**
- Creates the default map names for each device path in the system with
- a protocol depending on the Type.
-
- Creates the consistent map names for each device path in the system with
- a protocol depending on the Type.
-
- Note: This will reset all mappings in the system("map -r").
-
- Also sets up the default path environment variable if Type is FileSystem.
-
- @retval EFI_SUCCESS All map names were created sucessfully.
- @retval EFI_NOT_FOUND No protocols were found in the system.
- @return Error returned from gBS->LocateHandle().
-
- @sa LocateHandle
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandCreateInitialMappingsAndPaths(
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleList;
- UINTN Count;
- EFI_DEVICE_PATH_PROTOCOL **DevicePathList;
- CHAR16 *NewDefaultName;
- CHAR16 *NewConsistName;
- EFI_DEVICE_PATH_PROTOCOL **ConsistMappingTable;
- SHELL_MAP_LIST *MapListNode;
-
- HandleList = NULL;
-
- //
- // Reset the static members back to zero
- //
- mFsMaxCount = 0;
- mBlkMaxCount = 0;
-
- gEfiShellProtocol->SetEnv(L"path", L"", TRUE);
-
- //
- // First empty out the existing list.
- //
- if (!IsListEmpty(&gShellMapList.Link)) {
- for ( MapListNode = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsListEmpty(&gShellMapList.Link)
- ; MapListNode = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ){
- RemoveEntryList(&MapListNode->Link);
- FreePool(MapListNode);
- } // for loop
- }
-
- //
- // Find each handle with Simple File System
- //
- HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);
- if (HandleList != NULL) {
- //
- // Do a count of the handles
- //
- for (Count = 0 ; HandleList[Count] != NULL ; Count++);
-
- //
- // Get all Device Paths
- //
- DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
- ASSERT(DevicePathList != NULL);
-
- for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
- DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);
- }
-
- //
- // Sort all DevicePaths
- //
- PerformQuickSort(DevicePathList, Count, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
-
- ShellCommandConsistMappingInitialize(&ConsistMappingTable);
- //
- // Assign new Mappings to all...
- //
- for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
- //
- // Get default name first
- //
- NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);
- ASSERT(NewDefaultName != NULL);
- Status = ShellCommandAddMapItemAndUpdatePath(NewDefaultName, DevicePathList[Count], 0, TRUE);
- ASSERT_EFI_ERROR(Status);
- FreePool(NewDefaultName);
-
- //
- // Now do consistent name
- //
- NewConsistName = ShellCommandConsistMappingGenMappingName(DevicePathList[Count], ConsistMappingTable);
- if (NewConsistName != NULL) {
- Status = ShellCommandAddMapItemAndUpdatePath(NewConsistName, DevicePathList[Count], 0, FALSE);
- ASSERT_EFI_ERROR(Status);
- FreePool(NewConsistName);
- }
- }
-
- ShellCommandConsistMappingUnInitialize(ConsistMappingTable);
-
- SHELL_FREE_NON_NULL(HandleList);
- SHELL_FREE_NON_NULL(DevicePathList);
-
- HandleList = NULL;
- } else {
- Count = (UINTN)-1;
- }
-
- //
- // Find each handle with Block Io
- //
- HandleList = GetHandleListByProtocol(&gEfiBlockIoProtocolGuid);
- if (HandleList != NULL) {
- for (Count = 0 ; HandleList[Count] != NULL ; Count++);
-
- //
- // Get all Device Paths
- //
- DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
- ASSERT(DevicePathList != NULL);
-
- for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
- DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);
- }
-
- //
- // Sort all DevicePaths
- //
- PerformQuickSort(DevicePathList, Count, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
-
- //
- // Assign new Mappings to all...
- //
- for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
- //
- // Get default name first
- //
- NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeBlockIo);
- ASSERT(NewDefaultName != NULL);
- Status = ShellCommandAddMapItemAndUpdatePath(NewDefaultName, DevicePathList[Count], 0, FALSE);
- ASSERT_EFI_ERROR(Status);
- FreePool(NewDefaultName);
- }
-
- SHELL_FREE_NON_NULL(HandleList);
- SHELL_FREE_NON_NULL(DevicePathList);
- } else if (Count == (UINTN)-1) {
- return (EFI_NOT_FOUND);
- }
-
- return (EFI_SUCCESS);
-}
-
-/**
- Add mappings for any devices without one. Do not change any existing maps.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandUpdateMapping (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleList;
- UINTN Count;
- EFI_DEVICE_PATH_PROTOCOL **DevicePathList;
- CHAR16 *NewDefaultName;
- CHAR16 *NewConsistName;
- EFI_DEVICE_PATH_PROTOCOL **ConsistMappingTable;
-
- HandleList = NULL;
- Status = EFI_SUCCESS;
-
- //
- // remove mappings that represent removed devices.
- //
-
- //
- // Find each handle with Simple File System
- //
- HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);
- if (HandleList != NULL) {
- //
- // Do a count of the handles
- //
- for (Count = 0 ; HandleList[Count] != NULL ; Count++);
-
- //
- // Get all Device Paths
- //
- DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
- if (DevicePathList == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
- DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);
- }
-
- //
- // Sort all DevicePaths
- //
- PerformQuickSort(DevicePathList, Count, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
-
- ShellCommandConsistMappingInitialize(&ConsistMappingTable);
-
- //
- // Assign new Mappings to remainders
- //
- for (Count = 0 ; !EFI_ERROR(Status) && HandleList[Count] != NULL && !EFI_ERROR(Status); Count++) {
- //
- // Skip ones that already have
- //
- if (gEfiShellProtocol->GetMapFromDevicePath(&DevicePathList[Count]) != NULL) {
- continue;
- }
- //
- // Get default name
- //
- NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);
- if (NewDefaultName == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- break;
- }
-
- //
- // Call shell protocol SetMap function now...
- //
- Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewDefaultName);
-
- if (!EFI_ERROR(Status)) {
- //
- // Now do consistent name
- //
- NewConsistName = ShellCommandConsistMappingGenMappingName(DevicePathList[Count], ConsistMappingTable);
- if (NewConsistName != NULL) {
- Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewConsistName);
- FreePool(NewConsistName);
- }
- }
-
- FreePool(NewDefaultName);
- }
- ShellCommandConsistMappingUnInitialize(ConsistMappingTable);
- SHELL_FREE_NON_NULL(HandleList);
- SHELL_FREE_NON_NULL(DevicePathList);
-
- HandleList = NULL;
- } else {
- Count = (UINTN)-1;
- }
- //
- // Do it all over again for gEfiBlockIoProtocolGuid
- //
-
- return (Status);
-}
-
-/**
- Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.
-
- @param[in] Handle The SHELL_FILE_HANDLE to convert.
-
- @return a EFI_FILE_PROTOCOL* representing the same file.
-**/
-EFI_FILE_PROTOCOL*
-EFIAPI
-ConvertShellHandleToEfiFileProtocol(
- IN CONST SHELL_FILE_HANDLE Handle
- )
-{
- return ((EFI_FILE_PROTOCOL*)(Handle));
-}
-
-/**
- Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.
-
- @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.
- @param[in] Path The path to the file for verification.
-
- @return A SHELL_FILE_HANDLE representing the same file.
- @retval NULL There was not enough memory.
-**/
-SHELL_FILE_HANDLE
-EFIAPI
-ConvertEfiFileProtocolToShellHandle(
- IN CONST EFI_FILE_PROTOCOL *Handle,
- IN CONST CHAR16 *Path
- )
-{
- SHELL_COMMAND_FILE_HANDLE *Buffer;
- BUFFER_LIST *NewNode;
-
- if (Path != NULL) {
- Buffer = AllocateZeroPool(sizeof(SHELL_COMMAND_FILE_HANDLE));
- if (Buffer == NULL) {
- return (NULL);
- }
- NewNode = AllocateZeroPool(sizeof(BUFFER_LIST));
- if (NewNode == NULL) {
- SHELL_FREE_NON_NULL(Buffer);
- return (NULL);
- }
- Buffer->FileHandle = (EFI_FILE_PROTOCOL*)Handle;
- Buffer->Path = StrnCatGrow(&Buffer->Path, NULL, Path, 0);
- if (Buffer->Path == NULL) {
- SHELL_FREE_NON_NULL(NewNode);
- SHELL_FREE_NON_NULL(Buffer);
- return (NULL);
- }
- NewNode->Buffer = Buffer;
-
- InsertHeadList(&mFileHandleList.Link, &NewNode->Link);
- }
- return ((SHELL_FILE_HANDLE)(Handle));
-}
-
-/**
- Find the path that was logged with the specified SHELL_FILE_HANDLE.
-
- @param[in] Handle The SHELL_FILE_HANDLE to query on.
-
- @return A pointer to the path for the file.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFileHandleGetPath(
- IN CONST SHELL_FILE_HANDLE Handle
- )
-{
- BUFFER_LIST *Node;
-
- for (Node = (BUFFER_LIST*)GetFirstNode(&mFileHandleList.Link)
- ; !IsNull(&mFileHandleList.Link, &Node->Link)
- ; Node = (BUFFER_LIST*)GetNextNode(&mFileHandleList.Link, &Node->Link)
- ){
- if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)){
- return (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
- }
- }
- return (NULL);
-}
-
-/**
- Remove a SHELL_FILE_HANDLE from the list of SHELL_FILE_HANDLES.
-
- @param[in] Handle The SHELL_FILE_HANDLE to remove.
-
- @retval TRUE The item was removed.
- @retval FALSE The item was not found.
-**/
-BOOLEAN
-EFIAPI
-ShellFileHandleRemove(
- IN CONST SHELL_FILE_HANDLE Handle
- )
-{
- BUFFER_LIST *Node;
-
- for (Node = (BUFFER_LIST*)GetFirstNode(&mFileHandleList.Link)
- ; !IsNull(&mFileHandleList.Link, &Node->Link)
- ; Node = (BUFFER_LIST*)GetNextNode(&mFileHandleList.Link, &Node->Link)
- ){
- if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)){
- RemoveEntryList(&Node->Link);
- SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
- SHELL_FREE_NON_NULL(Node->Buffer);
- SHELL_FREE_NON_NULL(Node);
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Function to determine if a SHELL_FILE_HANDLE is at the end of the file.
-
- This will NOT work on directories.
-
- If Handle is NULL, then ASSERT.
-
- @param[in] Handle the file handle
-
- @retval TRUE the position is at the end of the file
- @retval FALSE the position is not at the end of the file
-**/
-BOOLEAN
-EFIAPI
-ShellFileHandleEof(
- IN SHELL_FILE_HANDLE Handle
- )
-{
- EFI_FILE_INFO *Info;
- UINT64 Pos;
- BOOLEAN RetVal;
-
- //
- // ASSERT if Handle is NULL
- //
- ASSERT(Handle != NULL);
-
- gEfiShellProtocol->GetFilePosition(Handle, &Pos);
- Info = gEfiShellProtocol->GetFileInfo (Handle);
- gEfiShellProtocol->SetFilePosition(Handle, Pos);
-
- if (Info == NULL) {
- return (FALSE);
- }
-
- if (Pos == Info->FileSize) {
- RetVal = TRUE;
- } else {
- RetVal = FALSE;
- }
-
- FreePool (Info);
-
- return (RetVal);
-}
-
-/**
- Frees any BUFFER_LIST defined type.
-
- @param[in] List The BUFFER_LIST object to free.
-**/
-VOID
-EFIAPI
-FreeBufferList (
- IN BUFFER_LIST *List
- )
-{
- BUFFER_LIST *BufferListEntry;
-
- if (List == NULL){
- return;
- }
- //
- // enumerate through the buffer list and free all memory
- //
- for ( BufferListEntry = ( BUFFER_LIST *)GetFirstNode(&List->Link)
- ; !IsListEmpty (&List->Link)
- ; BufferListEntry = (BUFFER_LIST *)GetFirstNode(&List->Link)
- ){
- RemoveEntryList(&BufferListEntry->Link);
- if (BufferListEntry->Buffer != NULL) {
- FreePool(BufferListEntry->Buffer);
- }
- FreePool(BufferListEntry);
- }
-}
-
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
deleted file mode 100644
index 1cfda2cf2d..0000000000
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file
- Provides interface to shell internal functions for shell commands.
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _UEFI_COMMAND_LIB_INTERNAL_HEADER_
-#define _UEFI_COMMAND_LIB_INTERNAL_HEADER_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/FileInfo.h>
-
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/EfiShellInterface.h>
-#include <Protocol/EfiShellEnvironment2.h>
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/EfiShellDynamicCommand.h>
-
-#include <Library/DevicePathLib.h>
-#include <Library/SortLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/PrintLib.h>
-#include <Library/ShellLib.h>
-#include <Library/HiiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-typedef struct{
- LIST_ENTRY Link;
- CHAR16 *CommandString;
- SHELL_GET_MAN_FILENAME GetManFileName;
- SHELL_RUN_COMMAND CommandHandler;
- BOOLEAN LastError;
- EFI_HANDLE HiiHandle;
- EFI_STRING_ID ManFormatHelp;
-} SHELL_COMMAND_INTERNAL_LIST_ENTRY;
-
-typedef struct {
- LIST_ENTRY Link;
- SCRIPT_FILE *Data;
-} SCRIPT_FILE_LIST;
-
-typedef struct {
- EFI_FILE_PROTOCOL *FileHandle;
- CHAR16 *Path;
-} SHELL_COMMAND_FILE_HANDLE;
-
-
-#endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_
-
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
deleted file mode 100644
index 1de52991bf..0000000000
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file
-# Provides interface to shell internal functions for shell commands.
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellCommandLib
- FILE_GUID = 5C12F31F-EBAC-466e-A400-FCA8C9EA3A05
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ShellCommandLib|UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER
- CONSTRUCTOR = ShellCommandLibConstructor
- DESTRUCTOR = ShellCommandLibDestructor
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- UefiShellCommandLib.c
- UefiShellCommandLib.h
- ConsistMapping.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- PrintLib
- UefiBootServicesTableLib
- ShellLib
- HiiLib
- HandleParsingLib
-
-[Protocols]
- gEfiUnicodeCollation2ProtocolGuid ## CONSUMES
- gEfiShellProtocolGuid ## CONSUMES
- gEfiShellParametersProtocolGuid ## CONSUMES
- gEfiShellDynamicCommandProtocolGuid ## SOMETIMES_CONSUMES
- gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES
-
-[Guids]
- gEfiSasDevicePathGuid ## CONSUMES ## GUID
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdUsbExtendedDecode ## SOMETIMES_CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellDecodeIScsiMapNames ## SOMETIMES_CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellVendorExtendedDecode ## SOMETIMES_CONSUMES
-
-[Depex]
- gEfiUnicodeCollation2ProtocolGuid
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c
deleted file mode 100644
index 2ab7dd3a5a..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Main file for Comp shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-
-/**
- Function for 'comp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunComp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN LoopVar;
- SHELL_FILE_HANDLE FileHandle1;
- SHELL_FILE_HANDLE FileHandle2;
- UINT8 ErrorCount;
- UINT64 Size1;
- UINT64 Size2;
- UINT8 DataFromFile1;
- UINT8 DataFromFile2;
- UINT8 ADF_File11;
- UINT8 ADF_File12;
- UINT8 ADF_File13;
- UINT8 ADF_File21;
- UINT8 ADF_File22;
- UINT8 ADF_File23;
- UINTN DataSizeFromFile1;
- UINTN DataSizeFromFile2;
- CHAR16 *FileName1;
- CHAR16 *FileName2;
- CONST CHAR16 *TempParam;
- UINTN ErrorAddress;
-
- ErrorCount = 0;
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- FileName1 = NULL;
- FileName2 = NULL;
- FileHandle1 = NULL;
- FileHandle2 = NULL;
- Size1 = 0;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"comp", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"comp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"comp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TempParam = ShellCommandLineGetRawValue(Package, 1);
- ASSERT(TempParam != NULL);
- FileName1 = ShellFindFilePath(TempParam);
- if (FileName1 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- TempParam = ShellCommandLineGetRawValue(Package, 2);
- ASSERT(TempParam != NULL);
- FileName2 = ShellFindFilePath(TempParam);
- if (FileName2 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"comp", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_HEADER), gShellDebug1HiiHandle, FileName1, FileName2);
- Status = gEfiShellProtocol->GetFileSize(FileHandle1, &Size1);
- ASSERT_EFI_ERROR(Status);
- Status = gEfiShellProtocol->GetFileSize(FileHandle2, &Size2);
- ASSERT_EFI_ERROR(Status);
- if (Size1 != Size2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_SIZE_FAIL), gShellDebug1HiiHandle);
- ErrorCount++;
- ShellStatus = SHELL_NOT_EQUAL;
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- for (LoopVar = 0 ; LoopVar < Size1 && ErrorCount <= 10 ; LoopVar++) {
- DataSizeFromFile1 = 1;
- DataSizeFromFile2 = 1;
- Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &DataFromFile1);
- ASSERT_EFI_ERROR(Status);
- Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &DataFromFile2);
- ASSERT_EFI_ERROR(Status);
- if (DataFromFile1 != DataFromFile2) {
- ErrorAddress = LoopVar;
- ADF_File11 = 0;
- ADF_File12 = 0;
- ADF_File13 = 0;
- ADF_File21 = 0;
- ADF_File22 = 0;
- ADF_File23 = 0;
-
- //
- // Now check the next 3 bytes if possible. This will make output
- // cleaner when there are a sequence of differences.
- //
- if (LoopVar + 1 < Size1) {
- LoopVar++;
- DataSizeFromFile1 = 1;
- DataSizeFromFile2 = 1;
- Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File11);
- ASSERT_EFI_ERROR(Status);
- Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File21);
- ASSERT_EFI_ERROR(Status);
- if (LoopVar + 1 < Size1) {
- LoopVar++;
- DataSizeFromFile1 = 1;
- DataSizeFromFile2 = 1;
- Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File12);
- ASSERT_EFI_ERROR(Status);
- Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File22);
- ASSERT_EFI_ERROR(Status);
- if (LoopVar + 1 < Size1) {
- LoopVar++;
- DataSizeFromFile1 = 1;
- DataSizeFromFile2 = 1;
- Status = gEfiShellProtocol->ReadFile(FileHandle1, &DataSizeFromFile1, &ADF_File13);
- ASSERT_EFI_ERROR(Status);
- Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &ADF_File23);
- ASSERT_EFI_ERROR(Status);
- }
- }
- }
-
- //
- // Print out based on highest of the 4 bytes that are different.
- //
- if (ADF_File13 != ADF_File23) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_COMP_SPOT_FAIL4),
- gShellDebug1HiiHandle,
- ++ErrorCount,
- FileName1,
- ErrorAddress,
- DataFromFile1, ADF_File11, ADF_File12, ADF_File13,
- DataFromFile1, ADF_File11, ADF_File12, ADF_File13,
- FileName2,
- ErrorAddress,
- DataFromFile2, ADF_File21, ADF_File22, ADF_File23,
- DataFromFile2, ADF_File21, ADF_File22, ADF_File23
- );
- } else if (ADF_File12 != ADF_File22) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_COMP_SPOT_FAIL3),
- gShellDebug1HiiHandle,
- ++ErrorCount,
- FileName1,
- ErrorAddress,
- DataFromFile1, ADF_File11, ADF_File12,
- DataFromFile1, ADF_File11, ADF_File12,
- FileName2,
- ErrorAddress,
- DataFromFile2, ADF_File21, ADF_File22,
- DataFromFile2, ADF_File21, ADF_File22
- );
- } else if (ADF_File11 != ADF_File21) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_COMP_SPOT_FAIL2),
- gShellDebug1HiiHandle,
- ++ErrorCount,
- FileName1,
- ErrorAddress,
- DataFromFile1, ADF_File11,
- DataFromFile1, ADF_File11,
- FileName2,
- ErrorAddress,
- DataFromFile2, ADF_File21,
- DataFromFile2, ADF_File21
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_COMP_SPOT_FAIL1),
- gShellDebug1HiiHandle,
- ++ErrorCount,
- FileName1,
- ErrorAddress,
- DataFromFile1,
- DataFromFile1,
- FileName2,
- ErrorAddress,
- DataFromFile2,
- DataFromFile2
- );
- }
- ShellStatus = SHELL_NOT_EQUAL;
- }
- }
- if (ErrorCount == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle);
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- SHELL_FREE_NON_NULL(FileName1);
- SHELL_FREE_NON_NULL(FileName2);
-
- if (FileHandle1 != NULL) {
- gEfiShellProtocol->CloseFile(FileHandle1);
- }
- if (FileHandle2 != NULL) {
- gEfiShellProtocol->CloseFile(FileHandle2);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
deleted file mode 100644
index 2106185798..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
+++ /dev/null
@@ -1,1417 +0,0 @@
-/** @file
- Main file for compression routine.
-
- Compression routine. The compression algorithm is a mixture of
- LZ77 and Huffman coding. LZ77 transforms the source data into a
- sequence of Original Characters and Pointers to repeated strings.
- This sequence is further divided into Blocks and Huffman codings
- are applied to each Block.
-
- Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 <Library/MemoryAllocationLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <ShellBase.h>
-#include <Uefi.h>
-
-//
-// Macro Definitions
-//
-typedef INT16 NODE;
-#define UINT8_MAX 0xff
-#define UINT8_BIT 8
-#define THRESHOLD 3
-#define INIT_CRC 0
-#define WNDBIT 13
-#define WNDSIZ (1U << WNDBIT)
-#define MAXMATCH 256
-#define BLKSIZ (1U << 14) // 16 * 1024U
-#define PERC_FLAG 0x8000U
-#define CODE_BIT 16
-#define NIL 0
-#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)
-#define HASH(LoopVar7, LoopVar5) ((LoopVar7) + ((LoopVar5) << (WNDBIT - 9)) + WNDSIZ * 2)
-#define CRCPOLY 0xA001
-#define UPDATE_CRC(LoopVar5) mCrc = mCrcTable[(mCrc ^ (LoopVar5)) & 0xFF] ^ (mCrc >> UINT8_BIT)
-
-//
-// C: the Char&Len Set; P: the Position Set; T: the exTra Set
-//
-#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)
-#define CBIT 9
-#define NP (WNDBIT + 1)
-#define PBIT 4
-#define NT (CODE_BIT + 3)
-#define TBIT 5
-#if NT > NP
- #define NPT NT
-#else
- #define NPT NP
-#endif
-//
-// Function Prototypes
-//
-
-/**
- Put a dword to output stream
-
- @param[in] Data The dword to put.
-**/
-VOID
-EFIAPI
-PutDword(
- IN UINT32 Data
- );
-
-//
-// Global Variables
-//
-STATIC UINT8 *mSrc;
-STATIC UINT8 *mDst;
-STATIC UINT8 *mSrcUpperLimit;
-STATIC UINT8 *mDstUpperLimit;
-
-STATIC UINT8 *mLevel;
-STATIC UINT8 *mText;
-STATIC UINT8 *mChildCount;
-STATIC UINT8 *mBuf;
-STATIC UINT8 mCLen[NC];
-STATIC UINT8 mPTLen[NPT];
-STATIC UINT8 *mLen;
-STATIC INT16 mHeap[NC + 1];
-STATIC INT32 mRemainder;
-STATIC INT32 mMatchLen;
-STATIC INT32 mBitCount;
-STATIC INT32 mHeapSize;
-STATIC INT32 mTempInt32;
-STATIC UINT32 mBufSiz = 0;
-STATIC UINT32 mOutputPos;
-STATIC UINT32 mOutputMask;
-STATIC UINT32 mSubBitBuf;
-STATIC UINT32 mCrc;
-STATIC UINT32 mCompSize;
-STATIC UINT32 mOrigSize;
-
-STATIC UINT16 *mFreq;
-STATIC UINT16 *mSortPtr;
-STATIC UINT16 mLenCnt[17];
-STATIC UINT16 mLeft[2 * NC - 1];
-STATIC UINT16 mRight[2 * NC - 1];
-STATIC UINT16 mCrcTable[UINT8_MAX + 1];
-STATIC UINT16 mCFreq[2 * NC - 1];
-STATIC UINT16 mCCode[NC];
-STATIC UINT16 mPFreq[2 * NP - 1];
-STATIC UINT16 mPTCode[NPT];
-STATIC UINT16 mTFreq[2 * NT - 1];
-
-STATIC NODE mPos;
-STATIC NODE mMatchPos;
-STATIC NODE mAvail;
-STATIC NODE *mPosition;
-STATIC NODE *mParent;
-STATIC NODE *mPrev;
-STATIC NODE *mNext = NULL;
-INT32 mHuffmanDepth = 0;
-
-/**
- Make a CRC table.
-
-**/
-VOID
-EFIAPI
-MakeCrcTable (
- VOID
- )
-{
- UINT32 LoopVar1;
-
- UINT32 LoopVar2;
-
- UINT32 LoopVar4;
-
- for (LoopVar1 = 0; LoopVar1 <= UINT8_MAX; LoopVar1++) {
- LoopVar4 = LoopVar1;
- for (LoopVar2 = 0; LoopVar2 < UINT8_BIT; LoopVar2++) {
- if ((LoopVar4 & 1) != 0) {
- LoopVar4 = (LoopVar4 >> 1) ^ CRCPOLY;
- } else {
- LoopVar4 >>= 1;
- }
- }
-
- mCrcTable[LoopVar1] = (UINT16) LoopVar4;
- }
-}
-
-/**
- Put a dword to output stream
-
- @param[in] Data The dword to put.
-**/
-VOID
-EFIAPI
-PutDword (
- IN UINT32 Data
- )
-{
- if (mDst < mDstUpperLimit) {
- *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff);
- }
-
- if (mDst < mDstUpperLimit) {
- *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff);
- }
-
- if (mDst < mDstUpperLimit) {
- *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff);
- }
-
- if (mDst < mDstUpperLimit) {
- *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff);
- }
-}
-
-/**
- Allocate memory spaces for data structures used in compression process.
-
- @retval EFI_SUCCESS Memory was allocated successfully.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-AllocateMemory (
- VOID
- )
-{
- mText = AllocateZeroPool (WNDSIZ * 2 + MAXMATCH);
- mLevel = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));
- mChildCount = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));
- mPosition = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));
- mParent = AllocateZeroPool (WNDSIZ * 2 * sizeof (*mParent));
- mPrev = AllocateZeroPool (WNDSIZ * 2 * sizeof (*mPrev));
- mNext = AllocateZeroPool ((MAX_HASH_VAL + 1) * sizeof (*mNext));
-
- mBufSiz = BLKSIZ;
- mBuf = AllocateZeroPool (mBufSiz);
- while (mBuf == NULL) {
- mBufSiz = (mBufSiz / 10U) * 9U;
- if (mBufSiz < 4 * 1024U) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- mBuf = AllocateZeroPool (mBufSiz);
- }
-
- mBuf[0] = 0;
-
- return EFI_SUCCESS;
-}
-
-/**
- Called when compression is completed to free memory previously allocated.
-
-**/
-VOID
-EFIAPI
-FreeMemory (
- VOID
- )
-{
- SHELL_FREE_NON_NULL (mText);
- SHELL_FREE_NON_NULL (mLevel);
- SHELL_FREE_NON_NULL (mChildCount);
- SHELL_FREE_NON_NULL (mPosition);
- SHELL_FREE_NON_NULL (mParent);
- SHELL_FREE_NON_NULL (mPrev);
- SHELL_FREE_NON_NULL (mNext);
- SHELL_FREE_NON_NULL (mBuf);
-}
-
-/**
- Initialize String Info Log data structures.
-**/
-VOID
-EFIAPI
-InitSlide (
- VOID
- )
-{
- NODE LoopVar1;
-
- SetMem (mLevel + WNDSIZ, (UINT8_MAX + 1) * sizeof (UINT8), 1);
- SetMem (mPosition + WNDSIZ, (UINT8_MAX + 1) * sizeof (NODE), 0);
-
- SetMem (mParent + WNDSIZ, WNDSIZ * sizeof (NODE), 0);
-
- mAvail = 1;
- for (LoopVar1 = 1; LoopVar1 < WNDSIZ - 1; LoopVar1++) {
- mNext[LoopVar1] = (NODE) (LoopVar1 + 1);
- }
-
- mNext[WNDSIZ - 1] = NIL;
- SetMem (mNext + WNDSIZ * 2, (MAX_HASH_VAL - WNDSIZ * 2 + 1) * sizeof (NODE), 0);
-}
-
-/**
- Find child node given the parent node and the edge character
-
- @param[in] LoopVar6 The parent node.
- @param[in] LoopVar5 The edge character.
-
- @return The child node.
- @retval NIL(Zero) No child could be found.
-
-**/
-NODE
-EFIAPI
-Child (
- IN NODE LoopVar6,
- IN UINT8 LoopVar5
- )
-{
- NODE LoopVar4;
-
- LoopVar4 = mNext[HASH (LoopVar6, LoopVar5)];
- mParent[NIL] = LoopVar6; /* sentinel */
- while (mParent[LoopVar4] != LoopVar6) {
- LoopVar4 = mNext[LoopVar4];
- }
-
- return LoopVar4;
-}
-
-/**
- Create a new child for a given parent node.
-
- @param[in] LoopVar6 The parent node.
- @param[in] LoopVar5 The edge character.
- @param[in] LoopVar4 The child node.
-**/
-VOID
-EFIAPI
-MakeChild (
- IN NODE LoopVar6,
- IN UINT8 LoopVar5,
- IN NODE LoopVar4
- )
-{
- NODE LoopVar12;
-
- NODE LoopVar10;
-
- LoopVar12 = (NODE) HASH (LoopVar6, LoopVar5);
- LoopVar10 = mNext[LoopVar12];
- mNext[LoopVar12] = LoopVar4;
- mNext[LoopVar4] = LoopVar10;
- mPrev[LoopVar10] = LoopVar4;
- mPrev[LoopVar4] = LoopVar12;
- mParent[LoopVar4] = LoopVar6;
- mChildCount[LoopVar6]++;
-}
-
-/**
- Split a node.
-
- @param[in] Old The node to split.
-**/
-VOID
-EFIAPI
-Split (
- IN NODE Old
- )
-{
- NODE New;
-
- NODE LoopVar10;
-
- New = mAvail;
- mAvail = mNext[New];
- mChildCount[New] = 0;
- LoopVar10 = mPrev[Old];
- mPrev[New] = LoopVar10;
- mNext[LoopVar10] = New;
- LoopVar10 = mNext[Old];
- mNext[New] = LoopVar10;
- mPrev[LoopVar10] = New;
- mParent[New] = mParent[Old];
- mLevel[New] = (UINT8) mMatchLen;
- mPosition[New] = mPos;
- MakeChild (New, mText[mMatchPos + mMatchLen], Old);
- MakeChild (New, mText[mPos + mMatchLen], mPos);
-}
-
-/**
- Insert string info for current position into the String Info Log.
-
-**/
-VOID
-EFIAPI
-InsertNode (
- VOID
- )
-{
- NODE LoopVar6;
-
- NODE LoopVar4;
-
- NODE LoopVar2;
-
- NODE LoopVar10;
- UINT8 LoopVar5;
- UINT8 *TempString3;
- UINT8 *TempString2;
-
- if (mMatchLen >= 4) {
- //
- // We have just got a long match, the target tree
- // can be located by MatchPos + 1. Travese the tree
- // from bottom up to get to a proper starting point.
- // The usage of PERC_FLAG ensures proper node deletion
- // in DeleteNode() later.
- //
- mMatchLen--;
- LoopVar4 = (NODE) ((mMatchPos + 1) | WNDSIZ);
- LoopVar6 = mParent[LoopVar4];
- while (LoopVar6 == NIL) {
- LoopVar4 = mNext[LoopVar4];
- LoopVar6 = mParent[LoopVar4];
- }
-
- while (mLevel[LoopVar6] >= mMatchLen) {
- LoopVar4 = LoopVar6;
- LoopVar6 = mParent[LoopVar6];
- }
-
- LoopVar10 = LoopVar6;
- while (mPosition[LoopVar10] < 0) {
- mPosition[LoopVar10] = mPos;
- LoopVar10 = mParent[LoopVar10];
- }
-
- if (LoopVar10 < WNDSIZ) {
- mPosition[LoopVar10] = (NODE) (mPos | PERC_FLAG);
- }
- } else {
- //
- // Locate the target tree
- //
- LoopVar6 = (NODE) (mText[mPos] + WNDSIZ);
- LoopVar5 = mText[mPos + 1];
- LoopVar4 = Child (LoopVar6, LoopVar5);
- if (LoopVar4 == NIL) {
- MakeChild (LoopVar6, LoopVar5, mPos);
- mMatchLen = 1;
- return ;
- }
-
- mMatchLen = 2;
- }
- //
- // Traverse down the tree to find a match.
- // Update Position value along the route.
- // Node split or creation is involved.
- //
- for (;;) {
- if (LoopVar4 >= WNDSIZ) {
- LoopVar2 = MAXMATCH;
- mMatchPos = LoopVar4;
- } else {
- LoopVar2 = mLevel[LoopVar4];
- mMatchPos = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG);
- }
-
- if (mMatchPos >= mPos) {
- mMatchPos -= WNDSIZ;
- }
-
- TempString3 = &mText[mPos + mMatchLen];
- TempString2 = &mText[mMatchPos + mMatchLen];
- while (mMatchLen < LoopVar2) {
- if (*TempString3 != *TempString2) {
- Split (LoopVar4);
- return ;
- }
-
- mMatchLen++;
- TempString3++;
- TempString2++;
- }
-
- if (mMatchLen >= MAXMATCH) {
- break;
- }
-
- mPosition[LoopVar4] = mPos;
- LoopVar6 = LoopVar4;
- LoopVar4 = Child (LoopVar6, *TempString3);
- if (LoopVar4 == NIL) {
- MakeChild (LoopVar6, *TempString3, mPos);
- return ;
- }
-
- mMatchLen++;
- }
-
- LoopVar10 = mPrev[LoopVar4];
- mPrev[mPos] = LoopVar10;
- mNext[LoopVar10] = mPos;
- LoopVar10 = mNext[LoopVar4];
- mNext[mPos] = LoopVar10;
- mPrev[LoopVar10] = mPos;
- mParent[mPos] = LoopVar6;
- mParent[LoopVar4] = NIL;
-
- //
- // Special usage of 'next'
- //
- mNext[LoopVar4] = mPos;
-
-}
-
-/**
- Delete outdated string info. (The Usage of PERC_FLAG
- ensures a clean deletion).
-
-**/
-VOID
-EFIAPI
-DeleteNode (
- VOID
- )
-{
- NODE LoopVar6;
-
- NODE LoopVar4;
-
- NODE LoopVar11;
-
- NODE LoopVar10;
-
- NODE LoopVar9;
-
- if (mParent[mPos] == NIL) {
- return ;
- }
-
- LoopVar4 = mPrev[mPos];
- LoopVar11 = mNext[mPos];
- mNext[LoopVar4] = LoopVar11;
- mPrev[LoopVar11] = LoopVar4;
- LoopVar4 = mParent[mPos];
- mParent[mPos] = NIL;
- if (LoopVar4 >= WNDSIZ) {
- return ;
- }
-
- mChildCount[LoopVar4]--;
- if (mChildCount[LoopVar4] > 1) {
- return ;
- }
-
- LoopVar10 = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG);
- if (LoopVar10 >= mPos) {
- LoopVar10 -= WNDSIZ;
- }
-
- LoopVar11 = LoopVar10;
- LoopVar6 = mParent[LoopVar4];
- LoopVar9 = mPosition[LoopVar6];
- while ((LoopVar9 & PERC_FLAG) != 0){
- LoopVar9 &= ~PERC_FLAG;
- if (LoopVar9 >= mPos) {
- LoopVar9 -= WNDSIZ;
- }
-
- if (LoopVar9 > LoopVar11) {
- LoopVar11 = LoopVar9;
- }
-
- mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ);
- LoopVar6 = mParent[LoopVar6];
- LoopVar9 = mPosition[LoopVar6];
- }
-
- if (LoopVar6 < WNDSIZ) {
- if (LoopVar9 >= mPos) {
- LoopVar9 -= WNDSIZ;
- }
-
- if (LoopVar9 > LoopVar11) {
- LoopVar11 = LoopVar9;
- }
-
- mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ | PERC_FLAG);
- }
-
- LoopVar11 = Child (LoopVar4, mText[LoopVar10 + mLevel[LoopVar4]]);
- LoopVar10 = mPrev[LoopVar11];
- LoopVar9 = mNext[LoopVar11];
- mNext[LoopVar10] = LoopVar9;
- mPrev[LoopVar9] = LoopVar10;
- LoopVar10 = mPrev[LoopVar4];
- mNext[LoopVar10] = LoopVar11;
- mPrev[LoopVar11] = LoopVar10;
- LoopVar10 = mNext[LoopVar4];
- mPrev[LoopVar10] = LoopVar11;
- mNext[LoopVar11] = LoopVar10;
- mParent[LoopVar11] = mParent[LoopVar4];
- mParent[LoopVar4] = NIL;
- mNext[LoopVar4] = mAvail;
- mAvail = LoopVar4;
-}
-
-/**
- Read in source data
-
- @param[out] LoopVar7 The buffer to hold the data.
- @param[in] LoopVar8 The number of bytes to read.
-
- @return The number of bytes actually read.
-**/
-INT32
-EFIAPI
-FreadCrc (
- OUT UINT8 *LoopVar7,
- IN INT32 LoopVar8
- )
-{
- INT32 LoopVar1;
-
- for (LoopVar1 = 0; mSrc < mSrcUpperLimit && LoopVar1 < LoopVar8; LoopVar1++) {
- *LoopVar7++ = *mSrc++;
- }
-
- LoopVar8 = LoopVar1;
-
- LoopVar7 -= LoopVar8;
- mOrigSize += LoopVar8;
- LoopVar1--;
- while (LoopVar1 >= 0) {
- UPDATE_CRC (*LoopVar7++);
- LoopVar1--;
- }
-
- return LoopVar8;
-}
-
-/**
- Advance the current position (read in new data if needed).
- Delete outdated string info. Find a match string for current position.
-
- @retval TRUE The operation was successful.
- @retval FALSE The operation failed due to insufficient memory.
-**/
-BOOLEAN
-EFIAPI
-GetNextMatch (
- VOID
- )
-{
- INT32 LoopVar8;
- VOID *Temp;
-
- mRemainder--;
- mPos++;
- if (mPos == WNDSIZ * 2) {
- Temp = AllocateZeroPool (WNDSIZ + MAXMATCH);
- if (Temp == NULL) {
- return (FALSE);
- }
- CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH);
- CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH);
- FreePool (Temp);
- LoopVar8 = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ);
- mRemainder += LoopVar8;
- mPos = WNDSIZ;
- }
-
- DeleteNode ();
- InsertNode ();
-
- return (TRUE);
-}
-
-/**
- Send entry LoopVar1 down the queue.
-
- @param[in] LoopVar1 The index of the item to move.
-**/
-VOID
-EFIAPI
-DownHeap (
- IN INT32 i
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar2;
-
- //
- // priority queue: send i-th entry down heap
- //
- LoopVar2 = mHeap[i];
- LoopVar1 = 2 * i;
- while (LoopVar1 <= mHeapSize) {
- if (LoopVar1 < mHeapSize && mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]]) {
- LoopVar1++;
- }
-
- if (mFreq[LoopVar2] <= mFreq[mHeap[LoopVar1]]) {
- break;
- }
-
- mHeap[i] = mHeap[LoopVar1];
- i = LoopVar1;
- LoopVar1 = 2 * i;
- }
-
- mHeap[i] = (INT16) LoopVar2;
-}
-
-/**
- Count the number of each code length for a Huffman tree.
-
- @param[in] LoopVar1 The top node.
-**/
-VOID
-EFIAPI
-CountLen (
- IN INT32 LoopVar1
- )
-{
- if (LoopVar1 < mTempInt32) {
- mLenCnt[(mHuffmanDepth < 16) ? mHuffmanDepth : 16]++;
- } else {
- mHuffmanDepth++;
- CountLen (mLeft[LoopVar1]);
- CountLen (mRight[LoopVar1]);
- mHuffmanDepth--;
- }
-}
-
-/**
- Create code length array for a Huffman tree.
-
- @param[in] Root The root of the tree.
-**/
-VOID
-EFIAPI
-MakeLen (
- IN INT32 Root
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar2;
- UINT32 Cum;
-
- for (LoopVar1 = 0; LoopVar1 <= 16; LoopVar1++) {
- mLenCnt[LoopVar1] = 0;
- }
-
- CountLen (Root);
-
- //
- // Adjust the length count array so that
- // no code will be generated longer than its designated length
- //
- Cum = 0;
- for (LoopVar1 = 16; LoopVar1 > 0; LoopVar1--) {
- Cum += mLenCnt[LoopVar1] << (16 - LoopVar1);
- }
-
- while (Cum != (1U << 16)) {
- mLenCnt[16]--;
- for (LoopVar1 = 15; LoopVar1 > 0; LoopVar1--) {
- if (mLenCnt[LoopVar1] != 0) {
- mLenCnt[LoopVar1]--;
- mLenCnt[LoopVar1 + 1] += 2;
- break;
- }
- }
-
- Cum--;
- }
-
- for (LoopVar1 = 16; LoopVar1 > 0; LoopVar1--) {
- LoopVar2 = mLenCnt[LoopVar1];
- LoopVar2--;
- while (LoopVar2 >= 0) {
- mLen[*mSortPtr++] = (UINT8) LoopVar1;
- LoopVar2--;
- }
- }
-}
-
-/**
- Assign code to each symbol based on the code length array.
-
- @param[in] LoopVar8 The number of symbols.
- @param[in] Len The code length array.
- @param[out] Code The stores codes for each symbol.
-**/
-VOID
-EFIAPI
-MakeCode (
- IN INT32 LoopVar8,
- IN UINT8 Len[ ],
- OUT UINT16 Code[ ]
- )
-{
- INT32 LoopVar1;
- UINT16 Start[18];
-
- Start[1] = 0;
- for (LoopVar1 = 1; LoopVar1 <= 16; LoopVar1++) {
- Start[LoopVar1 + 1] = (UINT16) ((Start[LoopVar1] + mLenCnt[LoopVar1]) << 1);
- }
-
- for (LoopVar1 = 0; LoopVar1 < LoopVar8; LoopVar1++) {
- Code[LoopVar1] = Start[Len[LoopVar1]]++;
- }
-}
-
-/**
- Generates Huffman codes given a frequency distribution of symbols.
-
- @param[in] NParm The number of symbols.
- @param[in] FreqParm The frequency of each symbol.
- @param[out] LenParm The code length for each symbol.
- @param[out] CodeParm The code for each symbol.
-
- @return The root of the Huffman tree.
-**/
-INT32
-EFIAPI
-MakeTree (
- IN INT32 NParm,
- IN UINT16 FreqParm[ ],
- OUT UINT8 LenParm[ ],
- OUT UINT16 CodeParm[ ]
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar2;
-
- INT32 LoopVar3;
-
- INT32 Avail;
-
- //
- // make tree, calculate len[], return root
- //
- mTempInt32 = NParm;
- mFreq = FreqParm;
- mLen = LenParm;
- Avail = mTempInt32;
- mHeapSize = 0;
- mHeap[1] = 0;
- for (LoopVar1 = 0; LoopVar1 < mTempInt32; LoopVar1++) {
- mLen[LoopVar1] = 0;
- if ((mFreq[LoopVar1]) != 0) {
- mHeapSize++;
- mHeap[mHeapSize] = (INT16) LoopVar1;
- }
- }
-
- if (mHeapSize < 2) {
- CodeParm[mHeap[1]] = 0;
- return mHeap[1];
- }
-
- for (LoopVar1 = mHeapSize / 2; LoopVar1 >= 1; LoopVar1--) {
- //
- // make priority queue
- //
- DownHeap (LoopVar1);
- }
-
- mSortPtr = CodeParm;
- do {
- LoopVar1 = mHeap[1];
- if (LoopVar1 < mTempInt32) {
- *mSortPtr++ = (UINT16) LoopVar1;
- }
-
- mHeap[1] = mHeap[mHeapSize--];
- DownHeap (1);
- LoopVar2 = mHeap[1];
- if (LoopVar2 < mTempInt32) {
- *mSortPtr++ = (UINT16) LoopVar2;
- }
-
- LoopVar3 = Avail++;
- mFreq[LoopVar3] = (UINT16) (mFreq[LoopVar1] + mFreq[LoopVar2]);
- mHeap[1] = (INT16) LoopVar3;
- DownHeap (1);
- mLeft[LoopVar3] = (UINT16) LoopVar1;
- mRight[LoopVar3] = (UINT16) LoopVar2;
- } while (mHeapSize > 1);
-
- mSortPtr = CodeParm;
- MakeLen (LoopVar3);
- MakeCode (NParm, LenParm, CodeParm);
-
- //
- // return root
- //
- return LoopVar3;
-}
-
-/**
- Outputs rightmost LoopVar8 bits of x
-
- @param[in] LoopVar8 The rightmost LoopVar8 bits of the data is used.
- @param[in] x The data.
-**/
-VOID
-EFIAPI
-PutBits (
- IN INT32 LoopVar8,
- IN UINT32 x
- )
-{
- UINT8 Temp;
-
- if (LoopVar8 < mBitCount) {
- mSubBitBuf |= x << (mBitCount -= LoopVar8);
- } else {
-
- Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount)));
- if (mDst < mDstUpperLimit) {
- *mDst++ = Temp;
- }
- mCompSize++;
-
- if (LoopVar8 < UINT8_BIT) {
- mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8);
- } else {
-
- Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT));
- if (mDst < mDstUpperLimit) {
- *mDst++ = Temp;
- }
- mCompSize++;
-
- mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - LoopVar8);
- }
- }
-}
-
-/**
- Encode a signed 32 bit number.
-
- @param[in] LoopVar5 The number to encode.
-**/
-VOID
-EFIAPI
-EncodeC (
- IN INT32 LoopVar5
- )
-{
- PutBits (mCLen[LoopVar5], mCCode[LoopVar5]);
-}
-
-/**
- Encode a unsigned 32 bit number.
-
- @param[in] LoopVar7 The number to encode.
-**/
-VOID
-EFIAPI
-EncodeP (
- IN UINT32 LoopVar7
- )
-{
- UINT32 LoopVar5;
-
- UINT32 LoopVar6;
-
- LoopVar5 = 0;
- LoopVar6 = LoopVar7;
- while (LoopVar6 != 0) {
- LoopVar6 >>= 1;
- LoopVar5++;
- }
-
- PutBits (mPTLen[LoopVar5], mPTCode[LoopVar5]);
- if (LoopVar5 > 1) {
- PutBits(LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5)));
- }
-}
-
-/**
- Count the frequencies for the Extra Set.
-
-**/
-VOID
-EFIAPI
-CountTFreq (
- VOID
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar3;
-
- INT32 LoopVar8;
-
- INT32 Count;
-
- for (LoopVar1 = 0; LoopVar1 < NT; LoopVar1++) {
- mTFreq[LoopVar1] = 0;
- }
-
- LoopVar8 = NC;
- while (LoopVar8 > 0 && mCLen[LoopVar8 - 1] == 0) {
- LoopVar8--;
- }
-
- LoopVar1 = 0;
- while (LoopVar1 < LoopVar8) {
- LoopVar3 = mCLen[LoopVar1++];
- if (LoopVar3 == 0) {
- Count = 1;
- while (LoopVar1 < LoopVar8 && mCLen[LoopVar1] == 0) {
- LoopVar1++;
- Count++;
- }
-
- if (Count <= 2) {
- mTFreq[0] = (UINT16) (mTFreq[0] + Count);
- } else if (Count <= 18) {
- mTFreq[1]++;
- } else if (Count == 19) {
- mTFreq[0]++;
- mTFreq[1]++;
- } else {
- mTFreq[2]++;
- }
- } else {
- ASSERT((LoopVar3+2)<(2 * NT - 1));
- mTFreq[LoopVar3 + 2]++;
- }
- }
-}
-
-/**
- Outputs the code length array for the Extra Set or the Position Set.
-
- @param[in] LoopVar8 The number of symbols.
- @param[in] nbit The number of bits needed to represent 'LoopVar8'.
- @param[in] Special The special symbol that needs to be take care of.
-
-**/
-VOID
-EFIAPI
-WritePTLen (
- IN INT32 LoopVar8,
- IN INT32 nbit,
- IN INT32 Special
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar3;
-
- while (LoopVar8 > 0 && mPTLen[LoopVar8 - 1] == 0) {
- LoopVar8--;
- }
-
- PutBits (nbit, LoopVar8);
- LoopVar1 = 0;
- while (LoopVar1 < LoopVar8) {
- LoopVar3 = mPTLen[LoopVar1++];
- if (LoopVar3 <= 6) {
- PutBits (3, LoopVar3);
- } else {
- PutBits (LoopVar3 - 3, (1U << (LoopVar3 - 3)) - 2);
- }
-
- if (LoopVar1 == Special) {
- while (LoopVar1 < 6 && mPTLen[LoopVar1] == 0) {
- LoopVar1++;
- }
-
- PutBits (2, (LoopVar1 - 3) & 3);
- }
- }
-}
-
-/**
- Outputs the code length array for Char&Length Set.
-**/
-VOID
-EFIAPI
-WriteCLen (
- VOID
- )
-{
- INT32 LoopVar1;
-
- INT32 LoopVar3;
-
- INT32 LoopVar8;
-
- INT32 Count;
-
- LoopVar8 = NC;
- while (LoopVar8 > 0 && mCLen[LoopVar8 - 1] == 0) {
- LoopVar8--;
- }
-
- PutBits (CBIT, LoopVar8);
- LoopVar1 = 0;
- while (LoopVar1 < LoopVar8) {
- LoopVar3 = mCLen[LoopVar1++];
- if (LoopVar3 == 0) {
- Count = 1;
- while (LoopVar1 < LoopVar8 && mCLen[LoopVar1] == 0) {
- LoopVar1++;
- Count++;
- }
-
- if (Count <= 2) {
- for (LoopVar3 = 0; LoopVar3 < Count; LoopVar3++) {
- PutBits (mPTLen[0], mPTCode[0]);
- }
- } else if (Count <= 18) {
- PutBits (mPTLen[1], mPTCode[1]);
- PutBits (4, Count - 3);
- } else if (Count == 19) {
- PutBits (mPTLen[0], mPTCode[0]);
- PutBits (mPTLen[1], mPTCode[1]);
- PutBits (4, 15);
- } else {
- PutBits (mPTLen[2], mPTCode[2]);
- PutBits (CBIT, Count - 20);
- }
- } else {
- ASSERT((LoopVar3+2)<NPT);
- PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
- }
- }
-}
-
-/**
- Huffman code the block and output it.
-
-**/
-VOID
-EFIAPI
-SendBlock (
- VOID
- )
-{
- UINT32 LoopVar1;
-
- UINT32 LoopVar3;
-
- UINT32 Flags;
-
- UINT32 Root;
-
- UINT32 Pos;
-
- UINT32 Size;
- Flags = 0;
-
- Root = MakeTree (NC, mCFreq, mCLen, mCCode);
- Size = mCFreq[Root];
- PutBits (16, Size);
- if (Root >= NC) {
- CountTFreq ();
- Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);
- if (Root >= NT) {
- WritePTLen (NT, TBIT, 3);
- } else {
- PutBits (TBIT, 0);
- PutBits (TBIT, Root);
- }
-
- WriteCLen ();
- } else {
- PutBits (TBIT, 0);
- PutBits (TBIT, 0);
- PutBits (CBIT, 0);
- PutBits (CBIT, Root);
- }
-
- Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);
- if (Root >= NP) {
- WritePTLen (NP, PBIT, -1);
- } else {
- PutBits (PBIT, 0);
- PutBits (PBIT, Root);
- }
-
- Pos = 0;
- for (LoopVar1 = 0; LoopVar1 < Size; LoopVar1++) {
- if (LoopVar1 % UINT8_BIT == 0) {
- Flags = mBuf[Pos++];
- } else {
- Flags <<= 1;
- }
- if ((Flags & (1U << (UINT8_BIT - 1))) != 0){
- EncodeC(mBuf[Pos++] + (1U << UINT8_BIT));
- LoopVar3 = mBuf[Pos++] << UINT8_BIT;
- LoopVar3 += mBuf[Pos++];
-
- EncodeP (LoopVar3);
- } else {
- EncodeC (mBuf[Pos++]);
- }
- }
-
- SetMem (mCFreq, NC * sizeof (UINT16), 0);
- SetMem (mPFreq, NP * sizeof (UINT16), 0);
-}
-
-/**
- Start the huffman encoding.
-
-**/
-VOID
-EFIAPI
-HufEncodeStart (
- VOID
- )
-{
- SetMem (mCFreq, NC * sizeof (UINT16), 0);
- SetMem (mPFreq, NP * sizeof (UINT16), 0);
-
- mOutputPos = mOutputMask = 0;
-
- mBitCount = UINT8_BIT;
- mSubBitBuf = 0;
-}
-
-/**
- Outputs an Original Character or a Pointer.
-
- @param[in] LoopVar5 The original character or the 'String Length' element of
- a Pointer.
- @param[in] LoopVar7 The 'Position' field of a Pointer.
-**/
-VOID
-EFIAPI
-CompressOutput (
- IN UINT32 LoopVar5,
- IN UINT32 LoopVar7
- )
-{
- STATIC UINT32 CPos;
-
- if ((mOutputMask >>= 1) == 0) {
- mOutputMask = 1U << (UINT8_BIT - 1);
- if (mOutputPos >= mBufSiz - 3 * UINT8_BIT) {
- SendBlock ();
- mOutputPos = 0;
- }
-
- CPos = mOutputPos++;
- mBuf[CPos] = 0;
- }
- mBuf[mOutputPos++] = (UINT8) LoopVar5;
- mCFreq[LoopVar5]++;
- if (LoopVar5 >= (1U << UINT8_BIT)) {
- mBuf[CPos] = (UINT8)(mBuf[CPos]|mOutputMask);
- mBuf[mOutputPos++] = (UINT8)(LoopVar7 >> UINT8_BIT);
- mBuf[mOutputPos++] = (UINT8) LoopVar7;
- LoopVar5 = 0;
- while (LoopVar7!=0) {
- LoopVar7 >>= 1;
- LoopVar5++;
- }
- mPFreq[LoopVar5]++;
- }
-}
-
-/**
- End the huffman encoding.
-
-**/
-VOID
-EFIAPI
-HufEncodeEnd (
- VOID
- )
-{
- SendBlock ();
-
- //
- // Flush remaining bits
- //
- PutBits (UINT8_BIT - 1, 0);
-}
-
-/**
- The main controlling routine for compression process.
-
- @retval EFI_SUCCESS The compression is successful.
- @retval EFI_OUT_0F_RESOURCES Not enough memory for compression process.
-**/
-EFI_STATUS
-EFIAPI
-Encode (
- VOID
- )
-{
- EFI_STATUS Status;
- INT32 LastMatchLen;
- NODE LastMatchPos;
-
- Status = AllocateMemory ();
- if (EFI_ERROR (Status)) {
- FreeMemory ();
- return Status;
- }
-
- InitSlide ();
-
- HufEncodeStart ();
-
- mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH);
-
- mMatchLen = 0;
- mPos = WNDSIZ;
- InsertNode ();
- if (mMatchLen > mRemainder) {
- mMatchLen = mRemainder;
- }
-
- while (mRemainder > 0) {
- LastMatchLen = mMatchLen;
- LastMatchPos = mMatchPos;
- if (!GetNextMatch ()) {
- Status = EFI_OUT_OF_RESOURCES;
- }
- if (mMatchLen > mRemainder) {
- mMatchLen = mRemainder;
- }
-
- if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {
- //
- // Not enough benefits are gained by outputting a pointer,
- // so just output the original character
- //
- CompressOutput(mText[mPos - 1], 0);
- } else {
- //
- // Outputting a pointer is beneficial enough, do it.
- //
-
- CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
- (mPos - LastMatchPos - 2) & (WNDSIZ - 1));
- LastMatchLen--;
- while (LastMatchLen > 0) {
- if (!GetNextMatch ()) {
- Status = EFI_OUT_OF_RESOURCES;
- }
- LastMatchLen--;
- }
-
- if (mMatchLen > mRemainder) {
- mMatchLen = mRemainder;
- }
- }
- }
-
- HufEncodeEnd ();
- FreeMemory ();
- return (Status);
-}
-
-/**
- The compression routine.
-
- @param[in] SrcBuffer The buffer containing the source data.
- @param[in] SrcSize The number of bytes in SrcBuffer.
- @param[in] DstBuffer The buffer to put the compressed image in.
- @param[in, out] DstSize On input the size (in bytes) of DstBuffer, on
- return the number of bytes placed in DstBuffer.
-
- @retval EFI_SUCCESS The compression was sucessful.
- @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required.
-**/
-EFI_STATUS
-EFIAPI
-Compress (
- IN VOID *SrcBuffer,
- IN UINT64 SrcSize,
- IN VOID *DstBuffer,
- IN OUT UINT64 *DstSize
- )
-{
- EFI_STATUS Status;
-
- //
- // Initializations
- //
- mBufSiz = 0;
- mBuf = NULL;
- mText = NULL;
- mLevel = NULL;
- mChildCount = NULL;
- mPosition = NULL;
- mParent = NULL;
- mPrev = NULL;
- mNext = NULL;
-
- mSrc = SrcBuffer;
- mSrcUpperLimit = mSrc + SrcSize;
- mDst = DstBuffer;
- mDstUpperLimit = mDst +*DstSize;
-
- PutDword (0L);
- PutDword (0L);
-
- MakeCrcTable ();
-
- mOrigSize = mCompSize = 0;
- mCrc = INIT_CRC;
-
- //
- // Compress it
- //
- Status = Encode ();
- if (EFI_ERROR (Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Null terminate the compressed data
- //
- if (mDst < mDstUpperLimit) {
- *mDst++ = 0;
- }
- //
- // Fill in compressed size and original size
- //
- mDst = DstBuffer;
- PutDword (mCompSize + 1);
- PutDword (mOrigSize);
-
- //
- // Return
- //
- if (mCompSize + 1 + 8 > *DstSize) {
- *DstSize = mCompSize + 1 + 8;
- return EFI_BUFFER_TOO_SMALL;
- } else {
- *DstSize = mCompSize + 1 + 8;
- return EFI_SUCCESS;
- }
-
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
deleted file mode 100644
index 39a997178f..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/** @file
- Header file for compression routine.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _EFI_SHELL_COMPRESS_H_
-#define _EFI_SHELL_COMPRESS_H_
-
-/**
- The compression routine.
-
- @param[in] SrcBuffer The buffer containing the source data.
- @param[in] SrcSize Number of bytes in SrcBuffer.
- @param[in] DstBuffer The buffer to put the compressed image in.
- @param[in, out] DstSize On input the size (in bytes) of DstBuffer, on
- return the number of bytes placed in DstBuffer.
-
- @retval EFI_SUCCESS The compression was sucessful.
- @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required.
-**/
-EFI_STATUS
-EFIAPI
-Compress (
- IN VOID *SrcBuffer,
- IN UINT64 SrcSize,
- IN VOID *DstBuffer,
- IN OUT UINT64 *DstSize
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
deleted file mode 100644
index a1fe9d7bef..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/** @file
- Main file for Dblk shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Protocol/BlockIo.h>
-
-/**
- Display blocks to the screen.
-
- @param[in] DevPath The device path to get the blocks from.
- @param[in] Lba The Lba number to start from.
- @param[in] BlockCount How many blocks to display.
-
- @retval SHELL_SUCCESS The display was successful.
-**/
-SHELL_STATUS
-EFIAPI
-DisplayTheBlocks(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,
- IN CONST UINT64 Lba,
- IN CONST UINT8 BlockCount
- )
-{
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_HANDLE BlockIoHandle;
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- UINT8 *Buffer;
- UINTN BufferSize;
-
- ShellStatus = SHELL_SUCCESS;
-
- Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, (EFI_DEVICE_PATH_PROTOCOL **)&DevPath, &BlockIoHandle);
- if (EFI_ERROR(Status)) {
- return (SHELL_NOT_FOUND);
- }
-
- Status = gBS->OpenProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- return (SHELL_NOT_FOUND);
- }
-
- BufferSize = BlockIo->Media->BlockSize * BlockCount;
- if (BufferSize > 0) {
- Buffer = AllocateZeroPool(BufferSize);
- } else {
- ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount);
- Buffer = NULL;
- }
-
- Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer);
- if (!EFI_ERROR(Status) && Buffer != NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DBLK_HEADER),
- gShellDebug1HiiHandle,
- Lba,
- BufferSize,
- BlockIo
- );
-
- DumpHex(2,0,BufferSize,Buffer);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"dblk", L"BlockIo");
- ShellStatus = SHELL_DEVICE_ERROR;
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
-
- gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL);
- return (ShellStatus);
-}
-
-/**
- Function for 'dblk' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDblk (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *BlockName;
- CONST CHAR16 *LbaString;
- CONST CHAR16 *BlockCountString;
- UINT64 Lba;
- UINT64 BlockCount;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dblk", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dblk");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"dblk");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Parse the params
- //
- BlockName = ShellCommandLineGetRawValue(Package, 1);
- LbaString = ShellCommandLineGetRawValue(Package, 2);
- BlockCountString = ShellCommandLineGetRawValue(Package, 3);
-
- if (LbaString == NULL) {
- Lba = 0;
- } else {
- if (!ShellIsHexOrDecimalNumber(LbaString, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", LbaString);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ShellConvertStringToUint64(LbaString, &Lba, TRUE, FALSE);
- }
-
- if (BlockCountString == NULL) {
- BlockCount = 1;
- } else {
- if (!ShellIsHexOrDecimalNumber(BlockCountString, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ShellConvertStringToUint64(BlockCountString, &BlockCount, TRUE, FALSE);
- if (BlockCount > 0x10) {
- BlockCount = 0x10;
- } else if (BlockCount == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockCountString);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // do the work if we have a valid block identifier
- //
- if (gEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dblk", BlockName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- DevPath = (EFI_DEVICE_PATH_PROTOCOL*)gEfiShellProtocol->GetDevicePathFromMap(BlockName);
- if (gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevPath, NULL) == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MAP_PROTOCOL), gShellDebug1HiiHandle, L"dblk", BlockName, L"BlockIo");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = DisplayTheBlocks(gEfiShellProtocol->GetDevicePathFromMap(BlockName), Lba, (UINT8)BlockCount);
- }
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
deleted file mode 100644
index 7693835b88..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/** @file
- Main file for Dmem shell Debug1 function.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Protocol/PciRootBridgeIo.h>
-#include <Guid/Acpi.h>
-#include <Guid/Mps.h>
-#include <Guid/SmBios.h>
-#include <Guid/SalSystemTable.h>
-
-/**
- Make a printable character.
-
- If Char is printable then return it, otherwise return a question mark.
-
- @param[in] Char The character to make printable.
-
- @return A printable character representing Char.
-**/
-CHAR16
-EFIAPI
-MakePrintable(
- IN CONST CHAR16 Char
- )
-{
- if ((Char < 0x20 && Char > 0)||(Char > 126)) {
- return (L'?');
- }
- return (Char);
-}
-
-/**
- Display some Memory-Mapped-IO memory.
-
- @param[in] Address The starting address to display.
- @param[in] Size The length of memory to display.
-**/
-SHELL_STATUS
-EFIAPI
-DisplayMmioMemory(
- IN CONST VOID *Address,
- IN CONST UINTN Size
- )
-{
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRbIo;
- EFI_STATUS Status;
- VOID *Buffer;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
-
- Status = gBS->LocateProtocol(&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRbIo);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"dmem");
- return (SHELL_NOT_FOUND);
- }
- Buffer = AllocateZeroPool(Size);
- ASSERT(Buffer != NULL);
-
- Status = PciRbIo->Mem.Read(PciRbIo, EfiPciWidthUint8, (UINT64)(UINTN)Address, Size, Buffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_ER), gShellDebug1HiiHandle, L"dmem");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_MMIO_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size);
- DumpHex(2, (UINTN)Address, Size, Buffer);
- }
-
- FreePool(Buffer);
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-mmio", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'dmem' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDmem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- VOID *Address;
- UINT64 Size;
- CONST CHAR16 *Temp1;
- UINT64 AcpiTableAddress;
- UINT64 Acpi20TableAddress;
- UINT64 SalTableAddress;
- UINT64 SmbiosTableAddress;
- UINT64 MpsTableAddress;
- UINTN TableWalker;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Address = NULL;
- Size = 0;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmem", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmem");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Temp1 = ShellCommandLineGetRawValue(Package, 1);
- if (Temp1 == NULL) {
- Address = gST;
- Size = 512;
- } else {
- if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- Temp1 = ShellCommandLineGetRawValue(Package, 2);
- if (Temp1 == NULL) {
- Size = 512;
- } else {
- if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, &Size, TRUE, FALSE))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- if (!ShellCommandLineGetFlag(Package, L"-mmio")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)(UINTN)Address, Size);
- DumpHex(2, (UINTN)Address, (UINTN)Size, Address);
- if (Address == (VOID*)gST) {
- Acpi20TableAddress = 0;
- AcpiTableAddress = 0;
- SalTableAddress = 0;
- SmbiosTableAddress = 0;
- MpsTableAddress = 0;
- for (TableWalker = 0 ; TableWalker < gST->NumberOfTableEntries ; TableWalker++) {
- if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi20TableGuid)) {
- Acpi20TableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi10TableGuid)) {
- AcpiTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSalSystemTableGuid)) {
- SalTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbiosTableGuid)) {
- SmbiosTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbios3TableGuid)) {
- SmbiosTableAddress = (UINT64) (UINTN) gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiMpsTableGuid)) {
- MpsTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable;
- continue;
- }
- }
-
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_SYSTEM_TABLE), gShellDebug1HiiHandle,
- (UINT64)(UINTN)Address,
- gST->Hdr.HeaderSize,
- gST->Hdr.Revision,
- (UINT64)(UINTN)gST->ConIn,
- (UINT64)(UINTN)gST->ConOut,
- (UINT64)(UINTN)gST->StdErr,
- (UINT64)(UINTN)gST->RuntimeServices,
- (UINT64)(UINTN)gST->BootServices,
- SalTableAddress,
- AcpiTableAddress,
- Acpi20TableAddress,
- MpsTableAddress,
- SmbiosTableAddress
- );
- }
- } else {
- ShellStatus = DisplayMmioMemory(Address, (UINTN)Size);
- }
- }
-
-
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
deleted file mode 100644
index ac6d0bdb55..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/** @file
- Main file for DmpStore shell Debug1 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-
-typedef enum {
- DmpStoreDisplay,
- DmpStoreDelete,
- DmpStoreSave,
- DmpStoreLoad
-} DMP_STORE_TYPE;
-
-typedef struct {
- UINT32 Signature;
- CHAR16 *Name;
- EFI_GUID Guid;
- UINT32 Attributes;
- UINT32 DataSize;
- UINT8 *Data;
- LIST_ENTRY Link;
-} DMP_STORE_VARIABLE;
-
-#define DMP_STORE_VARIABLE_SIGNATURE SIGNATURE_32 ('_', 'd', 's', 's')
-
-/**
- Base on the input attribute value to return the attribute string.
-
- @param[in] Atts The input attribute value
-
- @retval The attribute string info.
-**/
-CHAR16 *
-EFIAPI
-GetAttrType (
- IN CONST UINT32 Atts
- )
-{
- UINTN BufLen;
- CHAR16 *RetString;
-
- BufLen = 0;
- RetString = NULL;
-
- if ((Atts & EFI_VARIABLE_NON_VOLATILE) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+NV", 0);
- }
- if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0);
- } else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+BS", 0);
- }
- if ((Atts & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+HR", 0);
- }
- if ((Atts & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+AW", 0);
- }
- if ((Atts & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
- StrnCatGrow (&RetString, &BufLen, L"+AT", 0);
- }
-
- if (RetString == NULL) {
- RetString = StrnCatGrow(&RetString, &BufLen, L"Invalid", 0);
- }
-
- if ((RetString != NULL) && (RetString[0] == L'+')) {
- CopyMem(RetString, RetString + 1, StrSize(RetString + 1));
- }
-
- return RetString;
-}
-
-/**
- Load the variable data from file and set to variable data base.
-
- @param[in] FileHandle The file to be read.
- @param[in] Name The name of the variables to be loaded.
- @param[in] Guid The guid of the variables to be loaded.
- @param[out] Found TRUE when at least one variable was loaded and set.
-
- @retval SHELL_DEVICE_ERROR Cannot access the file.
- @retval SHELL_VOLUME_CORRUPTED The file is in bad format.
- @retval SHELL_OUT_OF_RESOURCES There is not enough memory to perform the operation.
- @retval SHELL_SUCCESS Successfully load and set the variables.
-**/
-SHELL_STATUS
-LoadVariablesFromFile (
- IN SHELL_FILE_HANDLE FileHandle,
- IN CONST CHAR16 *Name,
- IN CONST EFI_GUID *Guid,
- OUT BOOLEAN *Found
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- UINT32 NameSize;
- UINT32 DataSize;
- UINTN BufferSize;
- UINTN RemainingSize;
- UINT64 Position;
- UINT64 FileSize;
- LIST_ENTRY List;
- DMP_STORE_VARIABLE *Variable;
- LIST_ENTRY *Link;
- CHAR16 *Attributes;
- UINT8 *Buffer;
- UINT32 Crc32;
-
- Status = ShellGetFileSize (FileHandle, &FileSize);
- if (EFI_ERROR (Status)) {
- return SHELL_DEVICE_ERROR;
- }
-
- ShellStatus = SHELL_SUCCESS;
-
- InitializeListHead (&List);
-
- Position = 0;
- while (Position < FileSize) {
- //
- // NameSize
- //
- BufferSize = sizeof (NameSize);
- Status = ShellReadFile (FileHandle, &BufferSize, &NameSize);
- if (EFI_ERROR (Status) || (BufferSize != sizeof (NameSize))) {
- ShellStatus = SHELL_VOLUME_CORRUPTED;
- break;
- }
-
- //
- // DataSize
- //
- BufferSize = sizeof (DataSize);
- Status = ShellReadFile (FileHandle, &BufferSize, &DataSize);
- if (EFI_ERROR (Status) || (BufferSize != sizeof (DataSize))) {
- ShellStatus = SHELL_VOLUME_CORRUPTED;
- break;
- }
-
- //
- // Name, Guid, Attributes, Data, Crc32
- //
- RemainingSize = NameSize + sizeof (EFI_GUID) + sizeof (UINT32) + DataSize + sizeof (Crc32);
- BufferSize = sizeof (NameSize) + sizeof (DataSize) + RemainingSize;
- Buffer = AllocatePool (BufferSize);
- if (Buffer == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- break;
- }
- BufferSize = RemainingSize;
- Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *) Buffer + 2);
- if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
- ShellStatus = SHELL_VOLUME_CORRUPTED;
- FreePool (Buffer);
- break;
- }
-
- //
- // Check Crc32
- //
- * (UINT32 *) Buffer = NameSize;
- * ((UINT32 *) Buffer + 1) = DataSize;
- BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32);
- gBS->CalculateCrc32 (
- Buffer,
- BufferSize,
- &Crc32
- );
- if (Crc32 != * (UINT32 *) (Buffer + BufferSize)) {
- FreePool (Buffer);
- ShellStatus = SHELL_VOLUME_CORRUPTED;
- break;
- }
-
- Position += BufferSize + sizeof (Crc32);
-
- Variable = AllocateZeroPool (sizeof (*Variable) + NameSize + DataSize);
- if (Variable == NULL) {
- FreePool (Buffer);
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- break;
- }
- Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
- Variable->Name = (CHAR16 *) (Variable + 1);
- Variable->DataSize = DataSize;
- Variable->Data = (UINT8 *) Variable->Name + NameSize;
- CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize);
- CopyMem (&Variable->Guid, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize, sizeof (EFI_GUID));
- CopyMem (&Variable->Attributes, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID), sizeof (UINT32));
- CopyMem (Variable->Data, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID) + sizeof (UINT32), DataSize);
-
- InsertTailList (&List, &Variable->Link);
- FreePool (Buffer);
- }
-
- if ((Position != FileSize) || (ShellStatus != SHELL_SUCCESS)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle, L"dmpstore");
- if (Position != FileSize) {
- ShellStatus = SHELL_VOLUME_CORRUPTED;
- }
- }
-
- for ( Link = GetFirstNode (&List)
- ; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
- ; Link = GetNextNode (&List, Link)
- ) {
- Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
-
- if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *) Name)) &&
- ((Guid == NULL) || CompareGuid (&Variable->Guid, Guid))
- ) {
- Attributes = GetAttrType (Variable->Attributes);
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
- Attributes, &Variable->Guid, Variable->Name, Variable->DataSize
- );
- SHELL_FREE_NON_NULL(Attributes);
-
- *Found = TRUE;
- Status = gRT->SetVariable (
- Variable->Name,
- &Variable->Guid,
- Variable->Attributes,
- Variable->DataSize,
- Variable->Data
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", Variable->Name, Status);
- }
- }
- }
-
- for (Link = GetFirstNode (&List); !IsNull (&List, Link); ) {
- Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
- Link = RemoveEntryList (&Variable->Link);
- FreePool (Variable);
- }
-
- return ShellStatus;
-}
-
-/**
- Append one variable to file.
-
- @param[in] FileHandle The file to be appended.
- @param[in] Name The variable name.
- @param[in] Guid The variable GUID.
- @param[in] Attributes The variable attributes.
- @param[in] DataSize The variable data size.
- @param[in] Data The variable data.
-
- @retval EFI_OUT_OF_RESOURCES There is not enough memory to perform the operation.
- @retval EFI_SUCCESS The variable is appended to file successfully.
- @retval others Failed to append the variable to file.
-**/
-EFI_STATUS
-AppendSingleVariableToFile (
- IN SHELL_FILE_HANDLE FileHandle,
- IN CONST CHAR16 *Name,
- IN CONST EFI_GUID *Guid,
- IN UINT32 Attributes,
- IN UINT32 DataSize,
- IN CONST UINT8 *Data
- )
-{
- UINT32 NameSize;
- UINT8 *Buffer;
- UINT8 *Ptr;
- UINTN BufferSize;
- EFI_STATUS Status;
-
- NameSize = (UINT32) StrSize (Name);
- BufferSize = sizeof (NameSize) + sizeof (DataSize)
- + sizeof (*Guid)
- + sizeof (Attributes)
- + NameSize + DataSize
- + sizeof (UINT32);
-
- Buffer = AllocatePool (BufferSize);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Ptr = Buffer;
- //
- // NameSize and DataSize
- //
- * (UINT32 *) Ptr = NameSize;
- Ptr += sizeof (NameSize);
- *(UINT32 *) Ptr = DataSize;
- Ptr += sizeof (DataSize);
-
- //
- // Name
- //
- CopyMem (Ptr, Name, NameSize);
- Ptr += NameSize;
-
- //
- // Guid
- //
- CopyMem (Ptr, Guid, sizeof (*Guid));
- Ptr += sizeof (*Guid);
-
- //
- // Attributes
- //
- * (UINT32 *) Ptr = Attributes;
- Ptr += sizeof (Attributes);
-
- //
- // Data
- //
- CopyMem (Ptr, Data, DataSize);
- Ptr += DataSize;
-
- //
- // Crc32
- //
- gBS->CalculateCrc32 (Buffer, (UINTN) (Ptr - Buffer), (UINT32 *) Ptr);
-
- Status = ShellWriteFile (FileHandle, &BufferSize, Buffer);
- FreePool (Buffer);
-
- if (!EFI_ERROR (Status) &&
- (BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32))
- ) {
- Status = EFI_DEVICE_ERROR;
- }
-
- return Status;
-}
-
-/**
- Recursive function to display or delete variables.
-
- This function will call itself to create a stack-based list of allt he variables to process,
- then fromt he last to the first, they will do either printing or deleting.
-
- This is necessary since once a delete happens GetNextVariableName() will work.
-
- @param[in] Name The variable name of the EFI variable (or NULL).
- @param[in] Guid The GUID of the variable set (or NULL).
- @param[in] Type The operation type.
- @param[in] FileHandle The file to operate on (or NULL).
- @param[in] PrevName The previous variable name from GetNextVariableName. L"" to start.
- @param[in] FoundVarGuid The previous GUID from GetNextVariableName. ignored at start.
- @param[in] FoundOne If a VariableName or Guid was specified and one was printed or
- deleted, then set this to TRUE, otherwise ignored.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed.
- @retval SHELL_ABORTED The abort message was received.
- @retval SHELL_DEVICE_ERROR UEFI Variable Services returned an error.
- @retval SHELL_NOT_FOUND the Name/Guid pair could not be found.
-**/
-SHELL_STATUS
-EFIAPI
-CascadeProcessVariables (
- IN CONST CHAR16 *Name OPTIONAL,
- IN CONST EFI_GUID *Guid OPTIONAL,
- IN DMP_STORE_TYPE Type,
- IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL,
- IN CONST CHAR16 * CONST PrevName,
- IN EFI_GUID FoundVarGuid,
- IN BOOLEAN *FoundOne
- )
-{
- EFI_STATUS Status;
- CHAR16 *FoundVarName;
- UINT8 *DataBuffer;
- UINTN DataSize;
- UINT32 Atts;
- SHELL_STATUS ShellStatus;
- UINTN NameSize;
- CHAR16 *RetString;
-
- if (ShellGetExecutionBreakFlag()) {
- return (SHELL_ABORTED);
- }
-
- NameSize = 0;
- FoundVarName = NULL;
-
- if (PrevName!=NULL) {
- StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0);
- } else {
- FoundVarName = AllocateZeroPool(sizeof(CHAR16));
- }
-
- Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SHELL_FREE_NON_NULL(FoundVarName);
- FoundVarName = AllocateZeroPool (NameSize);
- if (FoundVarName != NULL) {
- if (PrevName != NULL) {
- StrnCpyS(FoundVarName, NameSize/sizeof(CHAR16), PrevName, NameSize/sizeof(CHAR16) - 1);
- }
-
- Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
- } else {
- Status = EFI_OUT_OF_RESOURCES;
- }
- }
-
- //
- // No more is fine.
- //
- if (Status == EFI_NOT_FOUND) {
- SHELL_FREE_NON_NULL(FoundVarName);
- return (SHELL_SUCCESS);
- } else if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(FoundVarName);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Recurse to the next iteration. We know "our" variable's name.
- //
- ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne);
-
- if (ShellGetExecutionBreakFlag() || (ShellStatus == SHELL_ABORTED)) {
- SHELL_FREE_NON_NULL(FoundVarName);
- return (SHELL_ABORTED);
- }
-
- //
- // No matter what happened we process our own variable
- // Only continue if Guid and VariableName are each either NULL or a match
- //
- if ( ( Name == NULL
- || gUnicodeCollation->MetaiMatch(gUnicodeCollation, FoundVarName, (CHAR16*) Name) )
- && ( Guid == NULL
- || CompareGuid(&FoundVarGuid, Guid) )
- ) {
- DataSize = 0;
- DataBuffer = NULL;
- //
- // do the print or delete
- //
- *FoundOne = TRUE;
- Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SHELL_FREE_NON_NULL (DataBuffer);
- DataBuffer = AllocatePool (DataSize);
- if (DataBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
- }
- }
- if ((Type == DmpStoreDisplay) || (Type == DmpStoreSave)) {
- //
- // Last error check then print this variable out.
- //
- if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) {
- RetString = GetAttrType(Atts);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DMPSTORE_HEADER_LINE),
- gShellDebug1HiiHandle,
- RetString,
- &FoundVarGuid,
- FoundVarName,
- DataSize);
- if (Type == DmpStoreDisplay) {
- DumpHex(2, 0, DataSize, DataBuffer);
- } else {
- Status = AppendSingleVariableToFile (
- FileHandle,
- FoundVarName,
- &FoundVarGuid,
- Atts,
- (UINT32) DataSize,
- DataBuffer
- );
- }
- SHELL_FREE_NON_NULL(RetString);
- }
- } else if (Type == DmpStoreDelete) {
- //
- // We only need name to delete it...
- //
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DMPSTORE_DELETE_LINE),
- gShellDebug1HiiHandle,
- &FoundVarGuid,
- FoundVarName,
- gRT->SetVariable (FoundVarName, &FoundVarGuid, Atts, 0, NULL)
- );
- }
- SHELL_FREE_NON_NULL(DataBuffer);
- }
-
- SHELL_FREE_NON_NULL(FoundVarName);
-
- if (Status == EFI_DEVICE_ERROR) {
- ShellStatus = SHELL_DEVICE_ERROR;
- } else if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_READY;
- }
-
- return (ShellStatus);
-}
-
-/**
- Function to display or delete variables. This will set up and call into the recursive function.
-
- @param[in] Name The variable name of the EFI variable (or NULL).
- @param[in] Guid The GUID of the variable set (or NULL).
- @param[in] Type The operation type.
- @param[in] FileHandle The file to save or load variables.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed.
- @retval SHELL_ABORTED The abort message was received.
- @retval SHELL_DEVICE_ERROR UEFI Variable Services returned an error.
- @retval SHELL_NOT_FOUND the Name/Guid pair could not be found.
-**/
-SHELL_STATUS
-EFIAPI
-ProcessVariables (
- IN CONST CHAR16 *Name OPTIONAL,
- IN CONST EFI_GUID *Guid OPTIONAL,
- IN DMP_STORE_TYPE Type,
- IN SHELL_FILE_HANDLE FileHandle OPTIONAL
- )
-{
- SHELL_STATUS ShellStatus;
- BOOLEAN Found;
- EFI_GUID FoundVarGuid;
-
- Found = FALSE;
- ShellStatus = SHELL_SUCCESS;
- ZeroMem (&FoundVarGuid, sizeof(EFI_GUID));
-
- if (Type == DmpStoreLoad) {
- ShellStatus = LoadVariablesFromFile (FileHandle, Name, Guid, &Found);
- } else {
- ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, NULL, FoundVarGuid, &Found);
- }
-
- if (!Found) {
- if (ShellStatus == SHELL_OUT_OF_RESOURCES) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"dmpstore");
- return (ShellStatus);
- } else if (Name != NULL && Guid == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, L"dmpstore", Name);
- } else if (Name != NULL && Guid != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, L"dmpstore", Guid, Name);
- } else if (Name == NULL && Guid == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle, L"dmpstore");
- } else if (Name == NULL && Guid != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid);
- }
- return (SHELL_NOT_FOUND);
- }
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-d", TypeFlag},
- {L"-l", TypeValue},
- {L"-s", TypeValue},
- {L"-all", TypeFlag},
- {L"-guid", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'dmpstore' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDmpStore (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *GuidStr;
- CONST CHAR16 *File;
- EFI_GUID *Guid;
- EFI_GUID GuidData;
- CONST CHAR16 *Name;
- DMP_STORE_TYPE Type;
- SHELL_FILE_HANDLE FileHandle;
- EFI_FILE_INFO *FileInfo;
-
- ShellStatus = SHELL_SUCCESS;
- Package = NULL;
- FileHandle = NULL;
- File = NULL;
- Type = DmpStoreDisplay;
-
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-all") && ShellCommandLineGetFlag(Package, L"-guid")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-all", L"-guid");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-l")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-d")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-d");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Determine the GUID to search for based on -all and -guid parameters
- //
- if (!ShellCommandLineGetFlag(Package, L"-all")) {
- GuidStr = ShellCommandLineGetValue(Package, L"-guid");
- if (GuidStr != NULL) {
- Status = ConvertStringToGuid(GuidStr, &GuidData);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmpstore", GuidStr);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- Guid = &GuidData;
- } else {
- Guid = &gEfiGlobalVariableGuid;
- }
- } else {
- Guid = NULL;
- }
-
- //
- // Get the Name of the variable to find
- //
- Name = ShellCommandLineGetRawValue(Package, 1);
-
- if (ShellStatus == SHELL_SUCCESS) {
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- Type = DmpStoreSave;
- File = ShellCommandLineGetValue(Package, L"-s");
- if (File == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
- if (!EFI_ERROR (Status)) {
- //
- // Delete existing file, but do not delete existing directory
- //
- FileInfo = ShellGetFileInfo (FileHandle);
- if (FileInfo == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- Status = EFI_DEVICE_ERROR;
- } else {
- if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File);
- Status = EFI_INVALID_PARAMETER;
- } else {
- Status = ShellDeleteFile (&FileHandle);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- }
- }
- FreePool (FileInfo);
- }
- } else if (Status == EFI_NOT_FOUND) {
- //
- // Good when file doesn't exist
- //
- Status = EFI_SUCCESS;
- } else {
- //
- // Otherwise it's bad.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- }
-
- if (!EFI_ERROR (Status)) {
- Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- }
- }
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- } else if (ShellCommandLineGetFlag(Package, L"-l")) {
- Type = DmpStoreLoad;
- File = ShellCommandLineGetValue(Package, L"-l");
- if (File == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-l");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- FileInfo = ShellGetFileInfo (FileHandle);
- if (FileInfo == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File);
- ShellStatus = SHELL_DEVICE_ERROR;
- } else {
- if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- FreePool (FileInfo);
- }
- }
- }
- } else if (ShellCommandLineGetFlag(Package, L"-d")) {
- Type = DmpStoreDelete;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- if (Type == DmpStoreSave) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_SAVE), gShellDebug1HiiHandle, File);
- } else if (Type == DmpStoreLoad) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File);
- }
- ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle);
- if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
- ShellCloseFile (&FileHandle);
- }
- }
- }
- }
-
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- return ShellStatus;
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Edit.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Edit.c
deleted file mode 100644
index 986b7e7b88..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Edit.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/** @file
- Main file for Edit shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include "TextEditor.h"
-
-/**
- Function for 'edit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEdit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- CHAR16 *Buffer;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- LIST_ENTRY *Package;
- CONST CHAR16 *Cwd;
- CHAR16 *Nfs;
- CHAR16 *Spot;
- CONST CHAR16 *TempParam;
-// SHELL_FILE_HANDLE TempHandle;
-
- Buffer = NULL;
- ShellStatus = SHELL_SUCCESS;
- Nfs = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"edit", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"edit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Cwd = gEfiShellProtocol->GetCurDir(NULL);
- if (Cwd == NULL) {
- Cwd = ShellGetEnvironmentVariable(L"path");
- if (Cwd != NULL) {
- Nfs = StrnCatGrow(&Nfs, NULL, Cwd+3, 0);
- if (Nfs != NULL) {
- Spot = StrStr(Nfs, L";");
- if (Spot != NULL) {
- *Spot = CHAR_NULL;
- }
- Spot = StrStr(Nfs, L"\\");
- if (Spot != NULL) {
- Spot[1] = CHAR_NULL;
- }
- gEfiShellProtocol->SetCurDir(NULL, Nfs);
- FreePool(Nfs);
- }
- }
- }
-
- Status = MainEditorInit ();
-
- if (EFI_ERROR (Status)) {
- gST->ConOut->ClearScreen (gST->ConOut);
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_INIT_FAILED), gShellDebug1HiiHandle);
- } else {
- MainEditorBackup ();
-
- //
- // if editor launched with file named
- //
- if (ShellCommandLineGetCount(Package) == 2) {
- TempParam = ShellCommandLineGetRawValue(Package, 1);
- ASSERT(TempParam != NULL);
- FileBufferSetFileName (TempParam);
-// if (EFI_ERROR(ShellFileExists(MainEditor.FileBuffer->FileName))) {
-// Status = ShellOpenFileByName(MainEditor.FileBuffer->FileName, &TempHandle, EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
-// if (!EFI_ERROR(Status)) {
-// ShellCloseFile(&TempHandle);
-// }
-// }
- }
-
- Status = FileBufferRead (MainEditor.FileBuffer->FileName, FALSE);
- if (!EFI_ERROR (Status)) {
- MainEditorRefresh ();
-
- Status = MainEditorKeyInput ();
- }
-
- if (Status != EFI_OUT_OF_RESOURCES) {
- //
- // back up the status string
- //
- Buffer = CatSPrint (NULL, L"%s", StatusBarGetString());
- }
-
- MainEditorCleanup ();
-
- //
- // print editor exit code on screen
- //
- if (Status == EFI_SUCCESS) {
- } else if (Status == EFI_OUT_OF_RESOURCES) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"edit");
- } else {
- if (Buffer != NULL) {
- if (StrCmp (Buffer, L"") != 0) {
- //
- // print out the status string
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_BUFFER), gShellDebug1HiiHandle, Buffer);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle);
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gShellDebug1HiiHandle);
- }
- }
-
- if (Status != EFI_OUT_OF_RESOURCES) {
- SHELL_FREE_NON_NULL (Buffer);
- }
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
- return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
deleted file mode 100644
index acd8512ff3..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
+++ /dev/null
@@ -1,3371 +0,0 @@
-/** @file
- Implements filebuffer interface functions.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved. <BR>
- 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 "TextEditor.h"
-#include <Guid/FileSystemInfo.h>
-#include <Library/FileHandleLib.h>
-
-EFI_EDITOR_FILE_BUFFER FileBuffer;
-EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
-
-//
-// for basic initialization of FileBuffer
-//
-EFI_EDITOR_FILE_BUFFER FileBufferConst = {
- NULL,
- FileTypeUnicode,
- NULL,
- NULL,
- 0,
- {
- 0,
- 0
- },
- {
- 0,
- 0
- },
- {
- 0,
- 0
- },
- {
- 0,
- 0
- },
- FALSE,
- TRUE,
- FALSE,
- NULL
-};
-
-//
-// the whole edit area needs to be refreshed
-//
-BOOLEAN FileBufferNeedRefresh;
-
-//
-// only the current line in edit area needs to be refresh
-//
-BOOLEAN FileBufferOnlyLineNeedRefresh;
-
-BOOLEAN FileBufferMouseNeedRefresh;
-
-extern BOOLEAN EditorMouseAction;
-
-/**
- Initialization function for FileBuffer.
-
- @param EFI_SUCCESS The initialization was successful.
- @param EFI_LOAD_ERROR A default name could not be created.
- @param EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferInit (
- VOID
- )
-{
- //
- // basically initialize the FileBuffer
- //
- CopyMem (&FileBuffer , &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER));
- CopyMem (&FileBufferBackupVar, &FileBufferConst, sizeof (EFI_EDITOR_FILE_BUFFER));
-
- //
- // set default FileName
- //
- FileBuffer.FileName = EditGetDefaultFileName (L"txt");
- if (FileBuffer.FileName == NULL) {
- return EFI_LOAD_ERROR;
- }
-
- FileBuffer.ListHead = AllocateZeroPool (sizeof (LIST_ENTRY));
- if (FileBuffer.ListHead == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- InitializeListHead (FileBuffer.ListHead);
-
- FileBuffer.DisplayPosition.Row = 2;
- FileBuffer.DisplayPosition.Column = 1;
- FileBuffer.LowVisibleRange.Row = 2;
- FileBuffer.LowVisibleRange.Column = 1;
-
- FileBufferNeedRefresh = FALSE;
- FileBufferMouseNeedRefresh = FALSE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Backup function for FileBuffer. Only backup the following items:
- Mouse/Cursor position
- File Name, Type, ReadOnly, Modified
- Insert Mode
-
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The backup operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferBackup (
- VOID
- )
-{
- FileBufferBackupVar.MousePosition = FileBuffer.MousePosition;
-
- SHELL_FREE_NON_NULL (FileBufferBackupVar.FileName);
- FileBufferBackupVar.FileName = NULL;
- FileBufferBackupVar.FileName = StrnCatGrow (&FileBufferBackupVar.FileName, NULL, FileBuffer.FileName, 0);
-
- FileBufferBackupVar.ModeInsert = FileBuffer.ModeInsert;
- FileBufferBackupVar.FileType = FileBuffer.FileType;
-
- FileBufferBackupVar.FilePosition = FileBuffer.FilePosition;
- FileBufferBackupVar.LowVisibleRange = FileBuffer.LowVisibleRange;
-
- FileBufferBackupVar.FileModified = FileBuffer.FileModified;
- FileBufferBackupVar.ReadOnly = FileBuffer.ReadOnly;
-
- return EFI_SUCCESS;
-}
-
-/**
- Advance to the next Count lines
-
- @param[in] Count The line number to advance by.
- @param[in] CurrentLine The pointer to the current line structure.
- @param[in] LineList The pointer to the linked list of lines.
-
- @retval NULL There was an error.
- @return The line structure after the advance.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-InternalEditorMiscLineAdvance (
- IN CONST UINTN Count,
- IN CONST EFI_EDITOR_LINE *CurrentLine,
- IN CONST LIST_ENTRY *LineList
- )
-
-{
- UINTN Index;
- CONST EFI_EDITOR_LINE *Line;
-
- if (CurrentLine == NULL || LineList == NULL) {
- return NULL;
- }
-
- for (Line = CurrentLine, Index = 0; Index < Count; Index++) {
- //
- // if already last line
- //
- if (Line->Link.ForwardLink == LineList) {
- return NULL;
- }
-
- Line = CR (Line->Link.ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- }
-
- return ((EFI_EDITOR_LINE *)Line);
-}
-
-/**
- Retreat to the previous Count lines.
-
- @param[in] Count The line number to retreat by.
- @param[in] CurrentLine The pointer to the current line structure.
- @param[in] LineList The pointer to the linked list of lines.
-
- @retval NULL There was an error.
- @return The line structure after the retreat.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-InternalEditorMiscLineRetreat (
- IN CONST UINTN Count,
- IN CONST EFI_EDITOR_LINE *CurrentLine,
- IN CONST LIST_ENTRY *LineList
- )
-
-{
- UINTN Index;
- CONST EFI_EDITOR_LINE *Line;
-
- if (CurrentLine == NULL || LineList == NULL) {
- return NULL;
- }
-
- for (Line = CurrentLine, Index = 0; Index < Count; Index++) {
- //
- // already the first line
- //
- if (Line->Link.BackLink == LineList) {
- return NULL;
- }
-
- Line = CR (Line->Link.BackLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- }
-
- return ((EFI_EDITOR_LINE *)Line);
-}
-
-/**
- Advance/Retreat lines
-
- @param[in] Count line number to advance/retreat
- >0 : advance
- <0 : retreat
-
- @retval NULL An error occured.
- @return The line after advance/retreat.
-**/
-EFI_EDITOR_LINE *
-MoveLine (
- IN CONST INTN Count
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN AbsCount;
-
- //
- // if < 0, then retreat
- // if > 0, the advance
- //
- if (Count <= 0) {
- AbsCount = (UINTN)ABS(Count);
- Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);
- } else {
- Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);
- }
-
- return Line;
-}
-
-/**
- Function to update the 'screen' to display the mouse position.
-
- @retval EFI_SUCCESS The backup operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRestoreMousePosition (
- VOID
- )
-{
- EFI_EDITOR_COLOR_UNION Orig;
- EFI_EDITOR_COLOR_UNION New;
- UINTN FRow;
- UINTN FColumn;
- BOOLEAN HasCharacter;
- EFI_EDITOR_LINE *CurrentLine;
- EFI_EDITOR_LINE *Line;
- CHAR16 Value;
-
- //
- // variable initialization
- //
- Line = NULL;
-
- if (MainEditor.MouseSupported) {
-
- if (FileBufferMouseNeedRefresh) {
-
- FileBufferMouseNeedRefresh = FALSE;
-
- //
- // if mouse position not moved and only mouse action
- // so do not need to refresh mouse position
- //
- if ((FileBuffer.MousePosition.Row == FileBufferBackupVar.MousePosition.Row &&
- FileBuffer.MousePosition.Column == FileBufferBackupVar.MousePosition.Column)
- && EditorMouseAction) {
- return EFI_SUCCESS;
- }
- //
- // backup the old screen attributes
- //
- Orig = MainEditor.ColorAttributes;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background & 0xF;
- New.Colors.Background = Orig.Colors.Foreground & 0x7;
-
- //
- // clear the old mouse position
- //
- FRow = FileBuffer.LowVisibleRange.Row + FileBufferBackupVar.MousePosition.Row - 2;
-
- FColumn = FileBuffer.LowVisibleRange.Column + FileBufferBackupVar.MousePosition.Column - 1;
-
- HasCharacter = TRUE;
- if (FRow > FileBuffer.NumLines) {
- HasCharacter = FALSE;
- } else {
- CurrentLine = FileBuffer.CurrentLine;
- Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
-
- if (Line == NULL || FColumn > Line->Size) {
- HasCharacter = FALSE;
- }
-
- FileBuffer.CurrentLine = CurrentLine;
- }
-
- ShellPrintEx (
- (INT32)FileBufferBackupVar.MousePosition.Column - 1,
- (INT32)FileBufferBackupVar.MousePosition.Row - 1,
- L" "
- );
-
- if (HasCharacter) {
- Value = (Line->Buffer[FColumn - 1]);
- ShellPrintEx (
- (INT32)FileBufferBackupVar.MousePosition.Column - 1,
- (INT32)FileBufferBackupVar.MousePosition.Row - 1,
- L"%c",
- Value
- );
- }
- //
- // set the new mouse position
- //
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
-
- //
- // clear the old mouse position
- //
- FRow = FileBuffer.LowVisibleRange.Row + FileBuffer.MousePosition.Row - 2;
- FColumn = FileBuffer.LowVisibleRange.Column + FileBuffer.MousePosition.Column - 1;
-
- HasCharacter = TRUE;
- if (FRow > FileBuffer.NumLines) {
- HasCharacter = FALSE;
- } else {
- CurrentLine = FileBuffer.CurrentLine;
- Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
-
- if (Line == NULL || FColumn > Line->Size) {
- HasCharacter = FALSE;
- }
-
- FileBuffer.CurrentLine = CurrentLine;
- }
-
- ShellPrintEx (
- (INT32)FileBuffer.MousePosition.Column - 1,
- (INT32)FileBuffer.MousePosition.Row - 1,
- L" "
- );
-
- if (HasCharacter) {
- Value = Line->Buffer[FColumn - 1];
- ShellPrintEx (
- (INT32)FileBuffer.MousePosition.Column - 1,
- (INT32)FileBuffer.MousePosition.Row - 1,
- L"%c",
- Value
- );
- }
- //
- // end of HasCharacter
- //
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- }
- //
- // end of MouseNeedRefresh
- //
- }
- //
- // end of MouseSupported
- //
- return EFI_SUCCESS;
-}
-
-/**
- Free all the lines in FileBuffer
- Fields affected:
- Lines
- CurrentLine
- NumLines
- ListHead
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferFreeLines (
- VOID
- )
-{
- LIST_ENTRY *Link;
- EFI_EDITOR_LINE *Line;
-
- //
- // free all the lines
- //
- if (FileBuffer.Lines != NULL) {
-
- Line = FileBuffer.Lines;
- Link = &(Line->Link);
- do {
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- Link = Link->ForwardLink;
-
- //
- // free line's buffer and line itself
- //
- LineFree (Line);
- } while (Link != FileBuffer.ListHead);
- }
- //
- // clean the line list related structure
- //
- FileBuffer.Lines = NULL;
- FileBuffer.CurrentLine = NULL;
- FileBuffer.NumLines = 0;
-
- FileBuffer.ListHead->ForwardLink = FileBuffer.ListHead;
- FileBuffer.ListHead->BackLink = FileBuffer.ListHead;
-
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup function for FileBuffer.
-
- @retval EFI_SUCCESS The cleanup was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferCleanup (
- VOID
- )
-{
- EFI_STATUS Status;
-
- SHELL_FREE_NON_NULL (FileBuffer.FileName);
-
- //
- // free all the lines
- //
- Status = FileBufferFreeLines ();
-
- SHELL_FREE_NON_NULL (FileBuffer.ListHead);
- FileBuffer.ListHead = NULL;
-
- SHELL_FREE_NON_NULL (FileBufferBackupVar.FileName);
- return Status;
-
-}
-
-/**
- Print a line specified by Line on a row specified by Row of the screen.
-
- @param[in] Line The line to print.
- @param[in] Row The row on the screen to print onto (begin from 1).
-
- @retval EFI_SUCCESS The printing was successful.
-**/
-EFI_STATUS
-FileBufferPrintLine (
- IN CONST EFI_EDITOR_LINE *Line,
- IN CONST UINTN Row
- )
-{
-
- CHAR16 *Buffer;
- UINTN Limit;
- CHAR16 *PrintLine;
- CHAR16 *PrintLine2;
- UINTN BufLen;
-
- //
- // print start from correct character
- //
- Buffer = Line->Buffer + FileBuffer.LowVisibleRange.Column - 1;
-
- Limit = Line->Size - FileBuffer.LowVisibleRange.Column + 1;
- if (Limit > Line->Size) {
- Limit = 0;
- }
-
- BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16);
- PrintLine = AllocatePool (BufLen);
- ASSERT (PrintLine != NULL);
-
- StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column));
- for (; Limit < MainEditor.ScreenSize.Column; Limit++) {
- PrintLine[Limit] = L' ';
- }
-
- PrintLine[MainEditor.ScreenSize.Column] = CHAR_NULL;
-
- PrintLine2 = AllocatePool (BufLen * 2);
- ASSERT (PrintLine2 != NULL);
-
- ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
-
- ShellPrintEx (
- 0,
- (INT32)Row - 1,
- L"%s",
- PrintLine2
- );
-
- FreePool (PrintLine);
- FreePool (PrintLine2);
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the cursor position according to FileBuffer.DisplayPosition.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRestorePosition (
- VOID
- )
-{
- //
- // set cursor position
- //
- return (gST->ConOut->SetCursorPosition (
- gST->ConOut,
- FileBuffer.DisplayPosition.Column - 1,
- FileBuffer.DisplayPosition.Row - 1
- ));
-}
-
-/**
- Refresh the screen with whats in the buffer.
-
- @retval EFI_SUCCESS The refresh was successful.
- @retval EFI_LOAD_ERROR There was an error finding what to write.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRefresh (
- VOID
- )
-{
- LIST_ENTRY *Link;
- EFI_EDITOR_LINE *Line;
- UINTN Row;
-
- //
- // if it's the first time after editor launch, so should refresh
- //
- if (!EditorFirst) {
- //
- // no definite required refresh
- // and file position displayed on screen has not been changed
- //
- if (!FileBufferNeedRefresh &&
- !FileBufferOnlyLineNeedRefresh &&
- FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
- FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
- ) {
-
- FileBufferRestoreMousePosition ();
- FileBufferRestorePosition ();
-
- return EFI_SUCCESS;
- }
- }
-
- gST->ConOut->EnableCursor (gST->ConOut, FALSE);
-
- //
- // only need to refresh current line
- //
- if (FileBufferOnlyLineNeedRefresh &&
- FileBufferBackupVar.LowVisibleRange.Row == FileBuffer.LowVisibleRange.Row &&
- FileBufferBackupVar.LowVisibleRange.Column == FileBuffer.LowVisibleRange.Column
- ) {
-
- EditorClearLine (FileBuffer.DisplayPosition.Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
- FileBufferPrintLine (
- FileBuffer.CurrentLine,
- FileBuffer.DisplayPosition.Row
- );
- } else {
- //
- // the whole edit area need refresh
- //
-
- //
- // no line
- //
- if (FileBuffer.Lines == NULL) {
- FileBufferRestoreMousePosition ();
- FileBufferRestorePosition ();
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- return EFI_SUCCESS;
- }
- //
- // get the first line that will be displayed
- //
- Line = MoveLine (FileBuffer.LowVisibleRange.Row - FileBuffer.FilePosition.Row);
- if (Line == NULL) {
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- return EFI_LOAD_ERROR;
- }
-
- Link = &(Line->Link);
- Row = 2;
- do {
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- //
- // print line at row
- //
- FileBufferPrintLine (Line, Row);
-
- Link = Link->ForwardLink;
- Row++;
- } while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1));
- //
- // while not file end and not screen full
- //
- while (Row <= (MainEditor.ScreenSize.Row - 1)) {
- EditorClearLine (Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
- Row++;
- }
- }
-
- FileBufferRestoreMousePosition ();
- FileBufferRestorePosition ();
-
- FileBufferNeedRefresh = FALSE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- return EFI_SUCCESS;
-}
-
-/**
- Create a new line and append it to the line list.
- Fields affected:
- NumLines
- Lines
-
- @retval NULL The create line failed.
- @return The line created.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-FileBufferCreateLine (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
-
- //
- // allocate a line structure
- //
- Line = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
- if (Line == NULL) {
- return NULL;
- }
- //
- // initialize the structure
- //
- Line->Signature = LINE_LIST_SIGNATURE;
- Line->Size = 0;
- Line->TotalSize = 0;
- Line->Type = NewLineTypeDefault;
-
- //
- // initial buffer of the line is "\0"
- //
- ASSERT(CHAR_NULL == CHAR_NULL);
- Line->Buffer = CatSPrint (NULL, L"\0");
- if (Line->Buffer == NULL) {
- return NULL;
- }
-
- FileBuffer.NumLines++;
-
- //
- // insert the line into line list
- //
- InsertTailList (FileBuffer.ListHead, &Line->Link);
-
- if (FileBuffer.Lines == NULL) {
- FileBuffer.Lines = CR (FileBuffer.ListHead->ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- }
-
- return Line;
-}
-
-/**
- Set FileName field in FileBuffer.
-
- @param Str The file name to set.
-
- @retval EFI_SUCCESS The filename was successfully set.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER Str is not a valid filename.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSetFileName (
- IN CONST CHAR16 *Str
- )
-{
- //
- // Verify the parameters
- //
- if (!IsValidFileName(Str)) {
- return (EFI_INVALID_PARAMETER);
- }
- //
- // free the old file name
- //
- SHELL_FREE_NON_NULL (FileBuffer.FileName);
-
- //
- // Allocate and set the new name
- //
- FileBuffer.FileName = CatSPrint (NULL, L"%s", Str);
- if (FileBuffer.FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-/**
- Free the existing file lines and reset the modified flag.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferFree (
- VOID
- )
-{
- //
- // free all the lines
- //
- FileBufferFreeLines ();
- FileBuffer.FileModified = FALSE;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Read a file from disk into the FileBuffer.
-
- @param[in] FileName The filename to read.
- @param[in] Recover TRUE if is for recover mode, no information printouts.
-
- @retval EFI_SUCCESS The load was successful.
- @retval EFI_LOAD_ERROR The load failed.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER FileName is a directory.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRead (
- IN CONST CHAR16 *FileName,
- IN CONST BOOLEAN Recover
- )
-{
- EFI_EDITOR_LINE *Line;
- EE_NEWLINE_TYPE Type;
- UINTN LoopVar1;
- UINTN LoopVar2;
- UINTN LineSize;
- VOID *Buffer;
- CHAR16 *UnicodeBuffer;
- UINT8 *AsciiBuffer;
- UINTN FileSize;
- SHELL_FILE_HANDLE FileHandle;
- BOOLEAN CreateFile;
- EFI_STATUS Status;
- UINTN LineSizeBackup;
- EFI_FILE_INFO *Info;
-
- Line = NULL;
- LoopVar1 = 0;
- FileSize = 0;
- UnicodeBuffer = NULL;
- Type = NewLineTypeDefault;
- FileHandle = NULL;
- CreateFile = FALSE;
-
- //
- // in this function, when you return error ( except EFI_OUT_OF_RESOURCES )
- // you should set status string via StatusBarSetStatusString(L"blah")
- // since this function maybe called before the editorhandleinput loop
- // so any error will cause editor return
- // so if you want to print the error status
- // you should set the status string
- //
-
- //
- // try to open the file
- //
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
-
- if (!EFI_ERROR(Status)) {
- CreateFile = FALSE;
- if (FileHandle == NULL) {
- StatusBarSetStatusString (L"Disk Error");
- return EFI_LOAD_ERROR;
- }
-
- Info = ShellGetFileInfo(FileHandle);
-
- if (Info->Attribute & EFI_FILE_DIRECTORY) {
- StatusBarSetStatusString (L"Directory Can Not Be Edited");
- FreePool (Info);
- return EFI_INVALID_PARAMETER;
- }
-
- if (Info->Attribute & EFI_FILE_READ_ONLY) {
- FileBuffer.ReadOnly = TRUE;
- } else {
- FileBuffer.ReadOnly = FALSE;
- }
- //
- // get file size
- //
- FileSize = (UINTN) Info->FileSize;
-
- FreePool (Info);
- } else if (Status == EFI_NOT_FOUND) {
- //
- // file not exists. add create and try again
- //
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR (Status)) {
- if (Status == EFI_WRITE_PROTECTED ||
- Status == EFI_ACCESS_DENIED ||
- Status == EFI_NO_MEDIA ||
- Status == EFI_MEDIA_CHANGED
- ) {
- StatusBarSetStatusString (L"Access Denied");
- } else if (Status == EFI_DEVICE_ERROR || Status == EFI_VOLUME_CORRUPTED || Status == EFI_VOLUME_FULL) {
- StatusBarSetStatusString (L"Disk Error");
- } else {
- StatusBarSetStatusString (L"Invalid File Name or Current-working-directory");
- }
-
- return Status;
- } else {
- //
- // it worked. now delete it and move on with the name (now validated)
- //
- Status = ShellDeleteFile (&FileHandle);
- if (Status == EFI_WARN_DELETE_FAILURE) {
- Status = EFI_ACCESS_DENIED;
- }
- FileHandle = NULL;
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Access Denied");
- return Status;
- }
- }
- //
- // file doesn't exist, so set CreateFile to TRUE
- //
- CreateFile = TRUE;
- FileBuffer.ReadOnly = FALSE;
-
- //
- // all the check ends
- // so now begin to set file name, free lines
- //
- if (StrCmp (FileName, FileBuffer.FileName) != 0) {
- FileBufferSetFileName (FileName);
- }
- //
- // free the old lines
- //
- FileBufferFree ();
-
- }
- //
- // the file exists
- //
- if (!CreateFile) {
- //
- // allocate buffer to read file
- //
- Buffer = AllocateZeroPool (FileSize);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // read file into Buffer
- //
- Status = ShellReadFile (FileHandle, &FileSize, Buffer);
- ShellCloseFile(&FileHandle);
- FileHandle = NULL;
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read File Failed");
- SHELL_FREE_NON_NULL (Buffer);
- return EFI_LOAD_ERROR;
- }
- //
- // nothing in this file
- //
- if (FileSize == 0) {
- SHELL_FREE_NON_NULL (Buffer);
- //
- // since has no head, so only can be an ASCII file
- //
- FileBuffer.FileType = FileTypeAscii;
-
- goto Done;
- }
-
- AsciiBuffer = Buffer;
-
- if (FileSize < 2) {
- //
- // size < Unicode file header, so only can be ASCII file
- //
- FileBuffer.FileType = FileTypeAscii;
- } else {
- //
- // Unicode file
- //
- if (*(UINT16 *) Buffer == EFI_UNICODE_BYTE_ORDER_MARK) {
- //
- // Unicode file's size should be even
- //
- if ((FileSize % 2) != 0) {
- StatusBarSetStatusString (L"File Format Wrong");
- SHELL_FREE_NON_NULL (Buffer);
- return EFI_LOAD_ERROR;
- }
-
- FileSize /= 2;
-
- FileBuffer.FileType = FileTypeUnicode;
- UnicodeBuffer = Buffer;
-
- //
- // pass this 0xff and 0xfe
- //
- UnicodeBuffer++;
- FileSize--;
- } else {
- FileBuffer.FileType = FileTypeAscii;
- }
- //
- // end of AsciiBuffer ==
- //
- }
- //
- // end of FileSize < 2
- // all the check ends
- // so now begin to set file name, free lines
- //
- if (StrCmp (FileName, FileBuffer.FileName) != 0) {
- FileBufferSetFileName (FileName);
- }
-
- //
- // free the old lines
- //
- FileBufferFree ();
-
- //
- // parse file content line by line
- //
- for (LoopVar1 = 0; LoopVar1 < FileSize; LoopVar1++) {
- Type = NewLineTypeUnknown;
-
- for (LineSize = LoopVar1; LineSize < FileSize; LineSize++) {
- if (FileBuffer.FileType == FileTypeAscii) {
- if (AsciiBuffer[LineSize] == CHAR_CARRIAGE_RETURN) {
- Type = NewLineTypeCarriageReturn;
-
- //
- // has LF following
- //
- if (LineSize < FileSize - 1) {
- if (AsciiBuffer[LineSize + 1] == CHAR_LINEFEED) {
- Type = NewLineTypeCarriageReturnLineFeed;
- }
- }
-
- break;
- } else if (AsciiBuffer[LineSize] == CHAR_LINEFEED) {
- Type = NewLineTypeLineFeed;
-
- //
- // has CR following
- //
- if (LineSize < FileSize - 1) {
- if (AsciiBuffer[LineSize + 1] == CHAR_CARRIAGE_RETURN) {
- Type = NewLineTypeLineFeedCarriageReturn;
- }
- }
-
- break;
- }
- } else {
- if (UnicodeBuffer[LineSize] == CHAR_CARRIAGE_RETURN) {
- Type = NewLineTypeCarriageReturn;
-
- //
- // has LF following
- //
- if (LineSize < FileSize - 1) {
- if (UnicodeBuffer[LineSize + 1] == CHAR_LINEFEED) {
- Type = NewLineTypeCarriageReturnLineFeed;
- }
- }
-
- break;
- } else if (UnicodeBuffer[LineSize] == CHAR_LINEFEED) {
- Type = NewLineTypeLineFeed;
-
- //
- // has CR following
- //
- if (LineSize < FileSize - 1) {
- if (UnicodeBuffer[LineSize + 1] == CHAR_CARRIAGE_RETURN) {
- Type = NewLineTypeLineFeedCarriageReturn;
- }
- }
-
- break;
- }
- }
- //
- // endif == ASCII
- //
- }
- //
- // end of for LineSize
- //
- // if the type is wrong, then exit
- //
- if (Type == NewLineTypeUnknown) {
- //
- // Now if Type is NewLineTypeUnknown, it should be file end
- //
- Type = NewLineTypeDefault;
- }
-
- LineSizeBackup = LineSize;
-
- //
- // create a new line
- //
- Line = FileBufferCreateLine ();
- if (Line == NULL) {
- SHELL_FREE_NON_NULL (Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // calculate file length
- //
- LineSize -= LoopVar1;
-
- //
- // Unicode and one CHAR_NULL
- //
- SHELL_FREE_NON_NULL (Line->Buffer);
- Line->Buffer = AllocateZeroPool (LineSize * 2 + 2);
-
- if (Line->Buffer == NULL) {
- RemoveEntryList (&Line->Link);
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // copy this line to Line->Buffer
- //
- for (LoopVar2 = 0; LoopVar2 < LineSize; LoopVar2++) {
- if (FileBuffer.FileType == FileTypeAscii) {
- Line->Buffer[LoopVar2] = (CHAR16) AsciiBuffer[LoopVar1];
- } else {
- Line->Buffer[LoopVar2] = UnicodeBuffer[LoopVar1];
- }
-
- LoopVar1++;
- }
- //
- // LoopVar1 now points to where CHAR_CARRIAGE_RETURN or CHAR_LINEFEED;
- //
- Line->Buffer[LineSize] = 0;
-
- Line->Size = LineSize;
- Line->TotalSize = LineSize;
- Line->Type = Type;
-
- if (Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) {
- LoopVar1++;
- }
-
- //
- // last character is a return, SO create a new line
- //
- if (((Type == NewLineTypeCarriageReturnLineFeed || Type == NewLineTypeLineFeedCarriageReturn) && LineSizeBackup == FileSize - 2) ||
- ((Type == NewLineTypeLineFeed || Type == NewLineTypeCarriageReturn) && LineSizeBackup == FileSize - 1)
- ) {
- Line = FileBufferCreateLine ();
- if (Line == NULL) {
- SHELL_FREE_NON_NULL (Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
- }
- //
- // end of if
- //
- }
- //
- // end of LoopVar1
- //
- SHELL_FREE_NON_NULL (Buffer);
-
- }
- //
- // end of if CreateFile
- //
-Done:
-
- FileBuffer.DisplayPosition.Row = 2;
- FileBuffer.DisplayPosition.Column = 1;
- FileBuffer.LowVisibleRange.Row = 1;
- FileBuffer.LowVisibleRange.Column = 1;
- FileBuffer.FilePosition.Row = 1;
- FileBuffer.FilePosition.Column = 1;
- FileBuffer.MousePosition.Row = 2;
- FileBuffer.MousePosition.Column = 1;
-
- if (!Recover) {
- UnicodeBuffer = CatSPrint (NULL, L"%d Lines Read", FileBuffer.NumLines);
- if (UnicodeBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (UnicodeBuffer);
- FreePool (UnicodeBuffer);
- }
-/*
- //
- // check whether we have fs?: in filename
- //
- LoopVar1 = 0;
- FSMappingPtr = NULL;
- while (FileName[LoopVar1] != 0) {
- if (FileName[LoopVar1] == L':') {
- FSMappingPtr = &FileName[LoopVar1];
- break;
- }
-
- LoopVar1++;
- }
-
- if (FSMappingPtr == NULL) {
- CurDir = ShellGetCurrentDir (NULL);
- } else {
- LoopVar1 = 0;
- LoopVar2 = 0;
- while (FileName[LoopVar1] != 0) {
- if (FileName[LoopVar1] == L':') {
- break;
- }
-
- FSMapping[LoopVar2++] = FileName[LoopVar1];
-
- LoopVar1++;
- }
-
- FSMapping[LoopVar2] = 0;
- CurDir = ShellGetCurrentDir (FSMapping);
- }
-
- if (CurDir != NULL) {
- for (LoopVar1 = 0; LoopVar1 < StrLen (CurDir) && CurDir[LoopVar1] != ':'; LoopVar1++);
-
- CurDir[LoopVar1] = 0;
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ShellGetMap (CurDir);
- FreePool (CurDir);
- } else {
- return EFI_LOAD_ERROR;
- }
-
- Status = LibDevicePathToInterface (
- &gEfiSimpleFileSystemProtocolGuid,
- DevicePath,
- (VOID **) &Vol
- );
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
-
- Status = Vol->OpenVolume (Vol, &RootFs);
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
- //
- // Get volume information of file system
- //
- Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + 100;
- VolumeInfo = (EFI_FILE_SYSTEM_INFO *) AllocateZeroPool (Size);
- Status = RootFs->GetInfo (RootFs, &gEfiFileSystemInfoGuid, &Size, VolumeInfo);
- if (EFI_ERROR (Status)) {
- RootFs->Close (RootFs);
- return EFI_LOAD_ERROR;
- }
-
- if (VolumeInfo->ReadOnly) {
- StatusBarSetStatusString (L"WARNING: Volume Read Only");
- }
-
- FreePool (VolumeInfo);
- RootFs->Close (RootFs);
- }
-//
-*/
- //
- // has line
- //
- if (FileBuffer.Lines != 0) {
- FileBuffer.CurrentLine = CR (FileBuffer.ListHead->ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- } else {
- //
- // create a dummy line
- //
- Line = FileBufferCreateLine ();
- if (Line == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- FileBuffer.CurrentLine = Line;
- }
-
- FileBuffer.FileModified = FALSE;
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
- FileBufferMouseNeedRefresh = TRUE;
-
-
- return EFI_SUCCESS;
-}
-
-/**
- According to FileBuffer.NewLineType & FileBuffer.FileType,
- get the return buffer and size.
-
- @param[in] Type The type of line.
- @param[out] Buffer The buffer to fill.
- @param[out] Size The amount of the buffer used on return.
-**/
-VOID
-EFIAPI
-GetNewLine (
- IN CONST EE_NEWLINE_TYPE Type,
- OUT CHAR8 *Buffer,
- OUT UINT8 *Size
- )
-{
- UINT8 NewLineSize;
-
- //
- // give new line buffer,
- // and will judge unicode or ascii
- //
- NewLineSize = 0;
-
- //
- // not legal new line type
- //
- if (Type != NewLineTypeLineFeed && Type != NewLineTypeCarriageReturn && Type != NewLineTypeCarriageReturnLineFeed && Type != NewLineTypeLineFeedCarriageReturn) {
- *Size = 0;
- return ;
- }
- //
- // use_cr: give 0x0d
- //
- if (Type == NewLineTypeCarriageReturn) {
- if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
- Buffer[0] = 0x0d;
- Buffer[1] = 0;
- NewLineSize = 2;
- } else {
- Buffer[0] = 0x0d;
- NewLineSize = 1;
- }
-
- *Size = NewLineSize;
- return ;
- }
- //
- // use_lf: give 0x0a
- //
- if (Type == NewLineTypeLineFeed) {
- if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
- Buffer[0] = 0x0a;
- Buffer[1] = 0;
- NewLineSize = 2;
- } else {
- Buffer[0] = 0x0a;
- NewLineSize = 1;
- }
-
- *Size = NewLineSize;
- return ;
- }
- //
- // use_crlf: give 0x0d 0x0a
- //
- if (Type == NewLineTypeCarriageReturnLineFeed) {
- if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
- Buffer[0] = 0x0d;
- Buffer[1] = 0;
- Buffer[2] = 0x0a;
- Buffer[3] = 0;
-
- NewLineSize = 4;
- } else {
- Buffer[0] = 0x0d;
- Buffer[1] = 0x0a;
- NewLineSize = 2;
- }
-
- *Size = NewLineSize;
- return ;
- }
- //
- // use_lfcr: give 0x0a 0x0d
- //
- if (Type == NewLineTypeLineFeedCarriageReturn) {
- if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
- Buffer[0] = 0x0a;
- Buffer[1] = 0;
- Buffer[2] = 0x0d;
- Buffer[3] = 0;
-
- NewLineSize = 4;
- } else {
- Buffer[0] = 0x0a;
- Buffer[1] = 0x0d;
- NewLineSize = 2;
- }
-
- *Size = NewLineSize;
- return ;
- }
-
-}
-
-/**
- Change a Unicode string to an ASCII string.
-
- @param[in] UStr The Unicode string.
- @param[in] Length The maximum size of AStr.
- @param[out] AStr ASCII string to pass out.
-
- @return The actuall length.
-**/
-UINTN
-EFIAPI
-UnicodeToAscii (
- IN CONST CHAR16 *UStr,
- IN CONST UINTN Length,
- OUT CHAR8 *AStr
- )
-{
- UINTN Index;
-
- //
- // just buffer copy, not character copy
- //
- for (Index = 0; Index < Length; Index++) {
- *AStr++ = (CHAR8) *UStr++;
- }
-
- return Index;
-}
-
-/**
- Save lines in FileBuffer to disk
-
- @param[in] FileName The file name for writing.
-
- @retval EFI_SUCCESS Data was written.
- @retval EFI_LOAD_ERROR
- @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSave (
- IN CONST CHAR16 *FileName
- )
-{
- SHELL_FILE_HANDLE FileHandle;
- LIST_ENTRY *Link;
- EFI_EDITOR_LINE *Line;
- CHAR16 *Str;
-
- EFI_STATUS Status;
- UINTN Length;
- UINTN NumLines;
- CHAR8 NewLineBuffer[4];
- UINT8 NewLineSize;
-
- EFI_FILE_INFO *Info;
-
- UINT64 Attribute;
-
- EE_NEWLINE_TYPE Type;
-
- UINTN TotalSize;
- //
- // 2M
- //
- CHAR8 *Cache;
- UINTN LeftSize;
- UINTN Size;
- CHAR8 *Ptr;
-
- Length = 0;
- //
- // 2M
- //
- TotalSize = 0x200000;
-
- Attribute = 0;
-
-
-
- //
- // if is the old file
- //
- if (FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) == 0) {
- //
- // file has not been modified
- //
- if (!FileBuffer.FileModified) {
- return EFI_SUCCESS;
- }
-
- //
- // if file is read-only, set error
- //
- if (FileBuffer.ReadOnly) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Saved");
- return EFI_SUCCESS;
- }
- }
-
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
-
- if (!EFI_ERROR (Status)) {
- Info = ShellGetFileInfo(FileHandle);
-
- if (Info != NULL && Info->Attribute & EFI_FILE_DIRECTORY) {
- StatusBarSetStatusString (L"Directory Can Not Be Saved");
- ShellCloseFile(FileHandle);
- FreePool(Info);
- return EFI_LOAD_ERROR;
- }
-
- if (Info != NULL) {
- Attribute = Info->Attribute & ~EFI_FILE_READ_ONLY;
- FreePool(Info);
- }
-
- //
- // if file exits, so delete it
- //
- Status = ShellDeleteFile (&FileHandle);
- if (EFI_ERROR (Status) || Status == EFI_WARN_DELETE_FAILURE) {
- StatusBarSetStatusString (L"Write File Failed");
- return EFI_LOAD_ERROR;
- }
- }
-
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, Attribute);
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Create File Failed");
- return EFI_LOAD_ERROR;
- }
-
- //
- // if file is Unicode file, write Unicode header to it.
- //
- if (FileBuffer.FileType == FileTypeUnicode) {
- Length = 2;
- Status = ShellWriteFile (FileHandle, &Length, (VOID*)&gUnicodeFileTag);
- if (EFI_ERROR (Status)) {
- ShellDeleteFile (&FileHandle);
- return EFI_LOAD_ERROR;
- }
- }
-
- Cache = AllocateZeroPool (TotalSize);
- if (Cache == NULL) {
- ShellDeleteFile (&FileHandle);
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // write all the lines back to disk
- //
- NumLines = 0;
- Type = NewLineTypeCarriageReturnLineFeed;
-
- Ptr = Cache;
- LeftSize = TotalSize;
-
- for (Link = FileBuffer.ListHead->ForwardLink; Link != FileBuffer.ListHead; Link = Link->ForwardLink) {
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- if (Line->Type != NewLineTypeDefault) {
- Type = Line->Type;
- }
- //
- // newline character is at most 4 bytes ( two Unicode characters )
- //
- Length = 4;
- if (Line->Buffer != NULL && Line->Size != 0) {
- if (FileBuffer.FileType == FileTypeAscii) {
- Length += Line->Size;
- } else {
- Length += (Line->Size * 2);
- }
- //
- // end if FileTypeAscii
- //
- }
-
- //
- // no cache room left, so write cache to disk
- //
- if (LeftSize < Length) {
- Size = TotalSize - LeftSize;
- Status = ShellWriteFile (FileHandle, &Size, Cache);
- if (EFI_ERROR (Status)) {
- ShellDeleteFile (&FileHandle);
- FreePool (Cache);
- return EFI_LOAD_ERROR;
- }
- Ptr = Cache;
- LeftSize = TotalSize;
- }
-
- if (Line->Buffer != NULL && Line->Size != 0) {
- if (FileBuffer.FileType == FileTypeAscii) {
- UnicodeToAscii (Line->Buffer, Line->Size, Ptr);
- Length = Line->Size;
- } else {
- Length = (Line->Size * 2);
- CopyMem (Ptr, (CHAR8 *) Line->Buffer, Length);
- }
- //
- // end if FileTypeAscii
- //
- Ptr += Length;
- LeftSize -= Length;
-
- }
- //
- // end of if Line -> Buffer != NULL && Line -> Size != 0
- //
- // if not the last line , write return buffer to disk
- //
- if (Link->ForwardLink != FileBuffer.ListHead) {
- GetNewLine (Type, NewLineBuffer, &NewLineSize);
- CopyMem (Ptr, (CHAR8 *) NewLineBuffer, NewLineSize);
-
- Ptr += NewLineSize;
- LeftSize -= NewLineSize;
- }
-
- NumLines++;
- }
-
- if (TotalSize != LeftSize) {
- Size = TotalSize - LeftSize;
- Status = ShellWriteFile (FileHandle, &Size, Cache);
- if (EFI_ERROR (Status)) {
- ShellDeleteFile (&FileHandle);
- FreePool (Cache);
- return EFI_LOAD_ERROR;
- }
- }
-
- FreePool (Cache);
-
- ShellCloseFile(&FileHandle);
-
- FileBuffer.FileModified = FALSE;
-
- //
- // set status string
- //
- Str = CatSPrint (NULL, L"%d Lines Wrote", NumLines);
- if (Str == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (Str);
- SHELL_FREE_NON_NULL (Str);
-
- //
- // now everything is ready , you can set the new file name to filebuffer
- //
- if (FileName != NULL && FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) != 0) {
- //
- // not the same
- //
- FileBufferSetFileName (FileName);
- if (FileBuffer.FileName == NULL) {
- ShellDeleteFile (&FileHandle);
- return EFI_OUT_OF_RESOURCES;
- }
- }
-
- FileBuffer.ReadOnly = FALSE;
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to left 1 character position.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferScrollLeft (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = FileBuffer.CurrentLine;
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // if already at start of this line, so move to the end of previous line
- //
- if (FCol <= 1) {
- //
- // has previous line
- //
- if (Line->Link.BackLink != FileBuffer.ListHead) {
- FRow--;
- Line = CR (Line->Link.BackLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- FCol = Line->Size + 1;
- } else {
- return EFI_SUCCESS;
- }
- } else {
- //
- // if not at start of this line, just move to previous column
- //
- FCol--;
- }
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Delete a char in line
-
- @param[in, out] Line The line to delete in.
- @param[in] Pos Position to delete the char at ( start from 0 ).
-**/
-VOID
-EFIAPI
-LineDeleteAt (
- IN OUT EFI_EDITOR_LINE *Line,
- IN UINTN Pos
- )
-{
- UINTN Index;
-
- //
- // move the latter characters front
- //
- for (Index = Pos - 1; Index < Line->Size; Index++) {
- Line->Buffer[Index] = Line->Buffer[Index + 1];
- }
-
- Line->Size--;
-}
-
-/**
- Concatenate Src into Dest.
-
- @param[in, out] Dest Destination string
- @param[in] Src Src String.
-**/
-VOID
-EFIAPI
-LineCat (
- IN OUT EFI_EDITOR_LINE *Dest,
- IN EFI_EDITOR_LINE *Src
- )
-{
- CHAR16 *Str;
- UINTN Size;
-
- Size = Dest->Size;
-
- Dest->Buffer[Size] = 0;
-
- //
- // concatenate the two strings
- //
- Str = CatSPrint (NULL, L"%s%s", Dest->Buffer, Src->Buffer);
- if (Str == NULL) {
- Dest->Buffer = NULL;
- return ;
- }
-
- Dest->Size = Size + Src->Size;
- Dest->TotalSize = Dest->Size;
-
- FreePool (Dest->Buffer);
- FreePool (Src->Buffer);
-
- //
- // put str to dest->buffer
- //
- Dest->Buffer = Str;
-}
-
-/**
- Delete the previous character.
-
- @retval EFI_SUCCESS The delete was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferDoBackspace (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- EFI_EDITOR_LINE *End;
- LIST_ENTRY *Link;
- UINTN FileColumn;
-
- FileColumn = FileBuffer.FilePosition.Column;
-
- Line = FileBuffer.CurrentLine;
-
- //
- // the first column
- //
- if (FileColumn == 1) {
- //
- // the first row
- //
- if (FileBuffer.FilePosition.Row == 1) {
- return EFI_SUCCESS;
- }
-
- FileBufferScrollLeft ();
-
- Line = FileBuffer.CurrentLine;
- Link = Line->Link.ForwardLink;
- End = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- //
- // concatenate this line with previous line
- //
- LineCat (Line, End);
- if (Line->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // remove End from line list
- //
- RemoveEntryList (&End->Link);
- FreePool (End);
-
- FileBuffer.NumLines--;
-
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- } else {
- //
- // just delete the previous character
- //
- LineDeleteAt (Line, FileColumn - 1);
- FileBufferScrollLeft ();
- FileBufferOnlyLineNeedRefresh = TRUE;
- }
-
- if (!FileBuffer.FileModified) {
- FileBuffer.FileModified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Add a return into line at current position.
-
- @retval EFI_SUCCESS The insetrion of the character was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferDoReturn (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- EFI_EDITOR_LINE *NewLine;
- UINTN FileColumn;
- UINTN Index;
- CHAR16 *Buffer;
- UINTN Row;
- UINTN Col;
-
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- Line = FileBuffer.CurrentLine;
-
- FileColumn = FileBuffer.FilePosition.Column;
-
- NewLine = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
- if (NewLine == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- NewLine->Signature = LINE_LIST_SIGNATURE;
- NewLine->Size = Line->Size - FileColumn + 1;
- NewLine->TotalSize = NewLine->Size;
- NewLine->Buffer = CatSPrint (NULL, L"\0");
- if (NewLine->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- NewLine->Type = NewLineTypeDefault;
-
- if (NewLine->Size > 0) {
- //
- // UNICODE + CHAR_NULL
- //
- Buffer = AllocateZeroPool (2 * (NewLine->Size + 1));
- if (Buffer == NULL) {
- FreePool (NewLine->Buffer);
- FreePool (NewLine);
- return EFI_OUT_OF_RESOURCES;
- }
-
- FreePool (NewLine->Buffer);
-
- NewLine->Buffer = Buffer;
-
- for (Index = 0; Index < NewLine->Size; Index++) {
- NewLine->Buffer[Index] = Line->Buffer[Index + FileColumn - 1];
- }
-
- NewLine->Buffer[NewLine->Size] = CHAR_NULL;
-
- Line->Buffer[FileColumn - 1] = CHAR_NULL;
- Line->Size = FileColumn - 1;
- }
- //
- // increase NumLines
- //
- FileBuffer.NumLines++;
-
- //
- // insert it into the correct position of line list
- //
- NewLine->Link.BackLink = &(Line->Link);
- NewLine->Link.ForwardLink = Line->Link.ForwardLink;
- Line->Link.ForwardLink->BackLink = &(NewLine->Link);
- Line->Link.ForwardLink = &(NewLine->Link);
-
- //
- // move cursor to the start of next line
- //
- Row = FileBuffer.FilePosition.Row + 1;
- Col = 1;
-
- FileBufferMovePosition (Row, Col);
-
- //
- // set file is modified
- //
- if (!FileBuffer.FileModified) {
- FileBuffer.FileModified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Delete current character from current line. This is the effect caused
- by the 'del' key.
-
- @retval EFI_SUCCESS
-**/
-EFI_STATUS
-EFIAPI
-FileBufferDoDelete (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- EFI_EDITOR_LINE *Next;
- LIST_ENTRY *Link;
- UINTN FileColumn;
-
- Line = FileBuffer.CurrentLine;
- FileColumn = FileBuffer.FilePosition.Column;
-
- //
- // the last column
- //
- if (FileColumn >= Line->Size + 1) {
- //
- // the last line
- //
- if (Line->Link.ForwardLink == FileBuffer.ListHead) {
- return EFI_SUCCESS;
- }
- //
- // since last character,
- // so will add the next line to this line
- //
- Link = Line->Link.ForwardLink;
- Next = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- LineCat (Line, Next);
- if (Line->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- RemoveEntryList (&Next->Link);
- FreePool (Next);
-
- FileBuffer.NumLines--;
-
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- } else {
- //
- // just delete current character
- //
- LineDeleteAt (Line, FileColumn);
- FileBufferOnlyLineNeedRefresh = TRUE;
- }
-
- if (!FileBuffer.FileModified) {
- FileBuffer.FileModified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to right 1 character.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferScrollRight (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = FileBuffer.CurrentLine;
- if (Line->Buffer == NULL) {
- return EFI_SUCCESS;
- }
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // if already at end of this line, scroll it to the start of next line
- //
- if (FCol > Line->Size) {
- //
- // has next line
- //
- if (Line->Link.ForwardLink != FileBuffer.ListHead) {
- FRow++;
- FCol = 1;
- } else {
- return EFI_SUCCESS;
- }
- } else {
- //
- // if not at end of this line, just move to next column
- //
- FCol++;
- }
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Insert a char into line
-
-
- @param[in] Line The line to insert into.
- @param[in] Char The char to insert.
- @param[in] Pos The position to insert the char at ( start from 0 ).
- @param[in] StrSize The current string size ( include CHAR_NULL ),unit is Unicode character.
-
- @return The new string size ( include CHAR_NULL ) ( unit is Unicode character ).
-**/
-UINTN
-EFIAPI
-LineStrInsert (
- IN EFI_EDITOR_LINE *Line,
- IN CHAR16 Char,
- IN UINTN Pos,
- IN UINTN StrSize
- )
-{
- UINTN Index;
- CHAR16 *TempStringPtr;
- CHAR16 *Str;
-
- Index = (StrSize) * 2;
-
- Str = Line->Buffer;
-
- //
- // do not have free space
- //
- if (Line->TotalSize <= Line->Size) {
- Str = ReallocatePool (Index, Index + 16, Str);
- if (Str == NULL) {
- return 0;
- }
-
- Line->TotalSize += 8;
- }
- //
- // move the later part of the string one character right
- //
- TempStringPtr = Str;
- for (Index = StrSize; Index > Pos; Index--) {
- TempStringPtr[Index] = TempStringPtr[Index - 1];
- }
- //
- // insert char into it.
- //
- TempStringPtr[Index] = Char;
-
- Line->Buffer = Str;
- Line->Size++;
-
- return StrSize + 1;
-}
-
-/**
- Add a character to the current line.
-
- @param[in] Char The Character to input.
-
- @retval EFI_SUCCESS The input was succesful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferAddChar (
- IN CHAR16 Char
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FilePos;
-
- Line = FileBuffer.CurrentLine;
-
- //
- // only needs to refresh current line
- //
- FileBufferOnlyLineNeedRefresh = TRUE;
-
- //
- // when is insert mode, or cursor is at end of this line,
- // so insert this character
- // or replace the character.
- //
- FilePos = FileBuffer.FilePosition.Column - 1;
- if (FileBuffer.ModeInsert || FilePos + 1 > Line->Size) {
- LineStrInsert (Line, Char, FilePos, Line->Size + 1);
- } else {
- Line->Buffer[FilePos] = Char;
- }
- //
- // move cursor to right
- //
- FileBufferScrollRight ();
-
- if (!FileBuffer.FileModified) {
- FileBuffer.FileModified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Handles inputs from characters (ASCII key + Backspace + return)
-
- @param[in] Char The input character.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR There was an error.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferDoCharInput (
- IN CONST CHAR16 Char
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- switch (Char) {
- case CHAR_NULL:
- break;
-
- case CHAR_BACKSPACE:
- Status = FileBufferDoBackspace ();
- break;
-
- case CHAR_TAB:
- //
- // Tabs are ignored
- //
- break;
-
- case CHAR_LINEFEED:
- case CHAR_CARRIAGE_RETURN:
- Status = FileBufferDoReturn ();
- break;
-
- default:
- //
- // DEAL WITH ASCII CHAR, filter out thing like ctrl+f
- //
- if (Char > 127 || Char < 32) {
- Status = StatusBarSetStatusString (L"Unknown Command");
- } else {
- Status = FileBufferAddChar (Char);
- }
-
- break;
-
- }
-
- return Status;
-}
-
-/**
- Scroll cursor to the next line.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferScrollDown (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = FileBuffer.CurrentLine;
- if (Line->Buffer == NULL) {
- return EFI_SUCCESS;
- }
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // has next line
- //
- if (Line->Link.ForwardLink != FileBuffer.ListHead) {
- FRow++;
- Line = CR (Line->Link.ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- //
- // if the next line is not that long, so move to end of next line
- //
- if (FCol > Line->Size) {
- FCol = Line->Size + 1;
- }
-
- } else {
- return EFI_SUCCESS;
- }
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll the cursor to previous line.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferScrollUp (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = FileBuffer.CurrentLine;
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // has previous line
- //
- if (Line->Link.BackLink != FileBuffer.ListHead) {
- FRow--;
- Line = CR (Line->Link.BackLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- //
- // if previous line is not that long, so move to the end of previous line
- //
- if (FCol > Line->Size) {
- FCol = Line->Size + 1;
- }
-
- } else {
- return EFI_SUCCESS;
- }
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to next page.
-
- @retval EFI_SUCCESS The operation wa successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferPageDown (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
- UINTN Gap;
-
- Line = FileBuffer.CurrentLine;
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // has next page
- //
- if (FileBuffer.NumLines >= FRow + (MainEditor.ScreenSize.Row - 2)) {
- Gap = (MainEditor.ScreenSize.Row - 2);
- } else {
- //
- // MOVE CURSOR TO LAST LINE
- //
- Gap = FileBuffer.NumLines - FRow;
- }
- //
- // get correct line
- //
- Line = MoveLine (Gap);
-
- //
- // if that line, is not that long, so move to the end of that line
- //
- if (Line != NULL && FCol > Line->Size) {
- FCol = Line->Size + 1;
- }
-
- FRow += Gap;
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to previous screen.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferPageUp (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
- UINTN Gap;
- INTN Retreat;
-
- Line = FileBuffer.CurrentLine;
-
- FRow = FileBuffer.FilePosition.Row;
- FCol = FileBuffer.FilePosition.Column;
-
- //
- // has previous page
- //
- if (FRow > (MainEditor.ScreenSize.Row - 2)) {
- Gap = (MainEditor.ScreenSize.Row - 2);
- } else {
- //
- // the first line of file will displayed on the first line of screen
- //
- Gap = FRow - 1;
- }
-
- Retreat = Gap;
- Retreat = -Retreat;
-
- //
- // get correct line
- //
- Line = MoveLine (Retreat);
-
- //
- // if that line is not that long, so move to the end of that line
- //
- if (Line != NULL && FCol > Line->Size) {
- FCol = Line->Size + 1;
- }
-
- FRow -= Gap;
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to end of the current line.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferEnd (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = FileBuffer.CurrentLine;
-
- FRow = FileBuffer.FilePosition.Row;
-
- //
- // goto the last column of the line
- //
- FCol = Line->Size + 1;
-
- FileBufferMovePosition (FRow, FCol);
-
- return EFI_SUCCESS;
-}
-
-/**
- Dispatch input to different handler
- @param[in] Key The input key. One of:
- ASCII KEY
- Backspace/Delete
- Return
- Direction key: up/down/left/right/pgup/pgdn
- Home/End
- INS
-
- @retval EFI_SUCCESS The dispatch was done successfully.
- @retval EFI_LOAD_ERROR The dispatch was not successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferHandleInput (
- IN CONST EFI_INPUT_KEY *Key
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- switch (Key->ScanCode) {
- //
- // ordinary key input
- //
- case SCAN_NULL:
- if (!FileBuffer.ReadOnly) {
- Status = FileBufferDoCharInput (Key->UnicodeChar);
- } else {
- Status = StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- }
-
- break;
-
- //
- // up arrow
- //
- case SCAN_UP:
- Status = FileBufferScrollUp ();
- break;
-
- //
- // down arrow
- //
- case SCAN_DOWN:
- Status = FileBufferScrollDown ();
- break;
-
- //
- // right arrow
- //
- case SCAN_RIGHT:
- Status = FileBufferScrollRight ();
- break;
-
- //
- // left arrow
- //
- case SCAN_LEFT:
- Status = FileBufferScrollLeft ();
- break;
-
- //
- // page up
- //
- case SCAN_PAGE_UP:
- Status = FileBufferPageUp ();
- break;
-
- //
- // page down
- //
- case SCAN_PAGE_DOWN:
- Status = FileBufferPageDown ();
- break;
-
- //
- // delete
- //
- case SCAN_DELETE:
- if (!FileBuffer.ReadOnly) {
- Status = FileBufferDoDelete ();
- } else {
- Status = StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- }
-
- break;
-
- //
- // home
- //
- case SCAN_HOME:
- FileBufferMovePosition (FileBuffer.FilePosition.Row, 1);
- Status = EFI_SUCCESS;
- break;
-
- //
- // end
- //
- case SCAN_END:
- Status = FileBufferEnd ();
- break;
-
- //
- // insert
- //
- case SCAN_INSERT:
- FileBuffer.ModeInsert = (BOOLEAN)!FileBuffer.ModeInsert;
- Status = EFI_SUCCESS;
- break;
-
- default:
- Status = StatusBarSetStatusString (L"Unknown Command");
- break;
- }
-
- return Status;
-}
-
-/**
- Check user specified FileRow is above current screen.
-
- @param[in] FileRow The row of file position ( start from 1 ).
-
- @retval TRUE It is above the current screen.
- @retval FALSE It is not above the current screen.
-**/
-BOOLEAN
-EFIAPI
-AboveCurrentScreen (
- IN UINTN FileRow
- )
-{
- //
- // if is to the above of the screen
- //
- if (FileRow < FileBuffer.LowVisibleRange.Row) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Check user specified FileRow is under current screen.
-
- @param[in] FileRow The row of file position ( start from 1 ).
-
- @retval TRUE It is under the current screen.
- @retval FALSE It is not under the current screen.
-**/
-BOOLEAN
-EFIAPI
-UnderCurrentScreen (
- IN UINTN FileRow
- )
-{
- //
- // if is to the under of the screen
- //
- if (FileRow > FileBuffer.LowVisibleRange.Row + (MainEditor.ScreenSize.Row - 2) - 1) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Check user specified FileCol is left to current screen.
-
- @param[in] FileCol The column of file position ( start from 1 ).
-
- @retval TRUE It is to the left.
- @retval FALSE It is not to the left.
-**/
-BOOLEAN
-EFIAPI
-LeftCurrentScreen (
- IN UINTN FileCol
- )
-{
- //
- // if is to the left of the screen
- //
- if (FileCol < FileBuffer.LowVisibleRange.Column) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Check user specified FileCol is right to current screen.
-
- @param[in] FileCol The column of file position ( start from 1 ).
-
- @retval TRUE It is to the right.
- @retval FALSE It is not to the right.
-**/
-BOOLEAN
-EFIAPI
-RightCurrentScreen (
- IN UINTN FileCol
- )
-{
- //
- // if is to the right of the screen
- //
- if (FileCol > FileBuffer.LowVisibleRange.Column + MainEditor.ScreenSize.Column - 1) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Advance/Retreat lines and set CurrentLine in FileBuffer to it
-
- @param[in] Count The line number to advance/retreat
- >0 : advance
- <0: retreat
-
- @retval NULL An error occured.
- @return The line after advance/retreat.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-MoveCurrentLine (
- IN INTN Count
- )
-{
- EFI_EDITOR_LINE *Line;
- UINTN AbsCount;
-
- if (Count <= 0) {
- AbsCount = (UINTN)ABS(Count);
- Line = InternalEditorMiscLineRetreat (AbsCount,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);
- } else {
- Line = InternalEditorMiscLineAdvance ((UINTN)Count,MainEditor.FileBuffer->CurrentLine,MainEditor.FileBuffer->ListHead);
- }
-
- if (Line == NULL) {
- return NULL;
- }
-
- MainEditor.FileBuffer->CurrentLine = Line;
-
- return Line;
-}
-
-/**
- According to cursor's file position, adjust screen display
-
- @param[in] NewFilePosRow The row of file position ( start from 1 ).
- @param[in] NewFilePosCol The column of file position ( start from 1 ).
-**/
-VOID
-EFIAPI
-FileBufferMovePosition (
- IN CONST UINTN NewFilePosRow,
- IN CONST UINTN NewFilePosCol
- )
-{
- INTN RowGap;
- INTN ColGap;
- UINTN Abs;
- BOOLEAN Above;
- BOOLEAN Under;
- BOOLEAN Right;
- BOOLEAN Left;
-
- //
- // CALCULATE gap between current file position and new file position
- //
- RowGap = NewFilePosRow - FileBuffer.FilePosition.Row;
- ColGap = NewFilePosCol - FileBuffer.FilePosition.Column;
-
- Under = UnderCurrentScreen (NewFilePosRow);
- Above = AboveCurrentScreen (NewFilePosRow);
- //
- // if is below current screen
- //
- if (Under) {
- //
- // display row will be unchanged
- //
- FileBuffer.FilePosition.Row = NewFilePosRow;
- } else {
- if (Above) {
- //
- // has enough above line, so display row unchanged
- // not has enough above lines, so the first line is at the
- // first display line
- //
- if (NewFilePosRow < (FileBuffer.DisplayPosition.Row - 1)) {
- FileBuffer.DisplayPosition.Row = NewFilePosRow + 1;
- }
-
- FileBuffer.FilePosition.Row = NewFilePosRow;
- } else {
- //
- // in current screen
- //
- FileBuffer.FilePosition.Row = NewFilePosRow;
- if (RowGap < 0) {
- Abs = (UINTN)ABS(RowGap);
- FileBuffer.DisplayPosition.Row -= Abs;
- } else {
- FileBuffer.DisplayPosition.Row += RowGap;
- }
- }
- }
-
- FileBuffer.LowVisibleRange.Row = FileBuffer.FilePosition.Row - (FileBuffer.DisplayPosition.Row - 2);
-
- Right = RightCurrentScreen (NewFilePosCol);
- Left = LeftCurrentScreen (NewFilePosCol);
-
- //
- // if right to current screen
- //
- if (Right) {
- //
- // display column will be changed to end
- //
- FileBuffer.DisplayPosition.Column = MainEditor.ScreenSize.Column;
- FileBuffer.FilePosition.Column = NewFilePosCol;
- } else {
- if (Left) {
- //
- // has enough left characters , so display row unchanged
- // not has enough left characters,
- // so the first character is at the first display column
- //
- if (NewFilePosCol < (FileBuffer.DisplayPosition.Column)) {
- FileBuffer.DisplayPosition.Column = NewFilePosCol;
- }
-
- FileBuffer.FilePosition.Column = NewFilePosCol;
- } else {
- //
- // in current screen
- //
- FileBuffer.FilePosition.Column = NewFilePosCol;
- if (ColGap < 0) {
- Abs = (UINTN)(-ColGap);
- FileBuffer.DisplayPosition.Column -= Abs;
- } else {
- FileBuffer.DisplayPosition.Column += ColGap;
- }
- }
- }
-
- FileBuffer.LowVisibleRange.Column = FileBuffer.FilePosition.Column - (FileBuffer.DisplayPosition.Column - 1);
-
- //
- // let CurrentLine point to correct line;
- //
- FileBuffer.CurrentLine = MoveCurrentLine (RowGap);
-
-}
-
-/**
- Cut current line out and return a pointer to it.
-
- @param[out] CutLine Upon a successful return pointer to the pointer to
- the allocated cut line.
-
- @retval EFI_SUCCESS The cut was successful.
- @retval EFI_NOT_FOUND There was no selection to cut.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferCutLine (
- OUT EFI_EDITOR_LINE **CutLine
- )
-{
- EFI_EDITOR_LINE *Line;
- EFI_EDITOR_LINE *NewLine;
- UINTN Row;
- UINTN Col;
-
- if (FileBuffer.ReadOnly) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- return EFI_SUCCESS;
- }
-
- Line = FileBuffer.CurrentLine;
-
- //
- // if is the last dummy line, SO CAN not cut
- //
- if (StrCmp (Line->Buffer, L"\0") == 0 && Line->Link.ForwardLink == FileBuffer.ListHead
- //
- // last line
- //
- ) {
- //
- // LAST LINE AND NOTHING ON THIS LINE, SO CUT NOTHING
- //
- StatusBarSetStatusString (L"Nothing to Cut");
- return EFI_NOT_FOUND;
- }
- //
- // if is the last line, so create a dummy line
- //
- if (Line->Link.ForwardLink == FileBuffer.ListHead) {
- //
- // last line
- // create a new line
- //
- NewLine = FileBufferCreateLine ();
- if (NewLine == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- }
-
- FileBuffer.NumLines--;
- Row = FileBuffer.FilePosition.Row;
- Col = 1;
- //
- // move home
- //
- FileBuffer.CurrentLine = CR (
- FileBuffer.CurrentLine->Link.ForwardLink,
- EFI_EDITOR_LINE,
- Link,
- LINE_LIST_SIGNATURE
- );
-
- RemoveEntryList (&Line->Link);
-
- FileBuffer.Lines = CR (FileBuffer.ListHead->ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- FileBufferMovePosition (Row, Col);
-
- FileBuffer.FileModified = TRUE;
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- *CutLine = Line;
-
- return EFI_SUCCESS;
-}
-
-/**
- Paste a line into line list.
-
- @retval EFI_SUCCESS The paste was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferPasteLine (
- VOID
- )
-{
- EFI_EDITOR_LINE *Line;
- EFI_EDITOR_LINE *NewLine;
- UINTN Row;
- UINTN Col;
-
- //
- // if nothing is on clip board
- // then do nothing
- //
- if (MainEditor.CutLine == NULL) {
- return EFI_SUCCESS;
- }
- //
- // read only file can not be pasted on
- //
- if (FileBuffer.ReadOnly) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- return EFI_SUCCESS;
- }
-
- NewLine = LineDup (MainEditor.CutLine);
- if (NewLine == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // insert it above current line
- //
- Line = FileBuffer.CurrentLine;
- NewLine->Link.BackLink = Line->Link.BackLink;
- NewLine->Link.ForwardLink = &Line->Link;
-
- Line->Link.BackLink->ForwardLink = &NewLine->Link;
- Line->Link.BackLink = &NewLine->Link;
-
- FileBuffer.NumLines++;
- FileBuffer.CurrentLine = NewLine;
-
- FileBuffer.Lines = CR (FileBuffer.ListHead->ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- Col = 1;
- //
- // move home
- //
- Row = FileBuffer.FilePosition.Row;
-
- FileBufferMovePosition (Row, Col);
-
- //
- // after paste, set some value so that refresh knows to do something
- //
- FileBuffer.FileModified = TRUE;
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Search string from current position on in file
-
- @param[in] Str The search string.
- @param[in] Offset The offset from current position.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND The string Str was not found.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSearch (
- IN CONST CHAR16 *Str,
- IN CONST UINTN Offset
- )
-{
- CHAR16 *Current;
- UINTN Position;
- UINTN Row;
- UINTN Column;
- EFI_EDITOR_LINE *Line;
- CHAR16 *CharPos;
- LIST_ENTRY *Link;
- BOOLEAN Found;
-
- Column = 0;
- Position = 0;
-
- //
- // search if in current line
- //
- Current = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1 + Offset;
-
- if (Current >= (FileBuffer.CurrentLine->Buffer + FileBuffer.CurrentLine->Size)) {
- //
- // the end
- //
- Current = FileBuffer.CurrentLine->Buffer + FileBuffer.CurrentLine->Size;
- }
-
- Found = FALSE;
-
- CharPos = StrStr (Current, Str);
- if (CharPos != NULL) {
- Position = CharPos - Current + 1;
- Found = TRUE;
- }
-
- //
- // found
- //
- if (Found) {
- Column = (Position - 1) + FileBuffer.FilePosition.Column + Offset;
- Row = FileBuffer.FilePosition.Row;
- } else {
- //
- // not found so find through next lines
- //
- Link = FileBuffer.CurrentLine->Link.ForwardLink;
-
- Row = FileBuffer.FilePosition.Row + 1;
- while (Link != FileBuffer.ListHead) {
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-// Position = StrStr (Line->Buffer, Str);
- CharPos = StrStr (Line->Buffer, Str);
- if (CharPos != NULL) {
- Position = CharPos - Line->Buffer + 1;
- Found = TRUE;
- }
-
- if (Found) {
- //
- // found
- //
- Column = Position;
- break;
- }
-
- Row++;
- Link = Link->ForwardLink;
- }
-
- if (Link == FileBuffer.ListHead) {
- Found = FALSE;
- } else {
- Found = TRUE;
- }
- }
-
- if (!Found) {
- return EFI_NOT_FOUND;
- }
-
- FileBufferMovePosition (Row, Column);
-
- //
- // call refresh to fresh edit area,
- // because the outer may loop to find multiply occurrence of this string
- //
- FileBufferRefresh ();
-
- return EFI_SUCCESS;
-}
-
-/**
- Replace SearchLen characters from current position on with Replace.
-
- This will modify the current buffer at the current position.
-
- @param[in] Replace The string to replace.
- @param[in] SearchLen Search string's length.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferReplace (
- IN CONST CHAR16 *Replace,
- IN CONST UINTN SearchLen
- )
-{
- UINTN ReplaceLen;
- UINTN Index;
- CHAR16 *Buffer;
- UINTN NewSize;
- UINTN OldSize;
- UINTN Gap;
-
- ReplaceLen = StrLen (Replace);
-
- OldSize = FileBuffer.CurrentLine->Size + 1;
- //
- // include CHAR_NULL
- //
- NewSize = OldSize + (ReplaceLen - SearchLen);
-
- if (ReplaceLen > SearchLen) {
- //
- // do not have the enough space
- //
- if (FileBuffer.CurrentLine->TotalSize + 1 <= NewSize) {
- FileBuffer.CurrentLine->Buffer = ReallocatePool (
- 2 * OldSize,
- 2 * NewSize,
- FileBuffer.CurrentLine->Buffer
- );
- FileBuffer.CurrentLine->TotalSize = NewSize - 1;
- }
-
- if (FileBuffer.CurrentLine->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // the end CHAR_NULL character;
- //
- Buffer = FileBuffer.CurrentLine->Buffer + (NewSize - 1);
- Gap = ReplaceLen - SearchLen;
-
- //
- // keep the latter part
- //
- for (Index = 0; Index < (FileBuffer.CurrentLine->Size - FileBuffer.FilePosition.Column - SearchLen + 2); Index++) {
- *Buffer = *(Buffer - Gap);
- Buffer--;
- }
- //
- // set replace into it
- //
- Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1;
- for (Index = 0; Index < ReplaceLen; Index++) {
- Buffer[Index] = Replace[Index];
- }
- }
-
- if (ReplaceLen < SearchLen) {
- Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1;
-
- for (Index = 0; Index < ReplaceLen; Index++) {
- Buffer[Index] = Replace[Index];
- }
-
- Buffer += ReplaceLen;
- Gap = SearchLen - ReplaceLen;
-
- //
- // set replace into it
- //
- for (Index = 0; Index < (FileBuffer.CurrentLine->Size - FileBuffer.FilePosition.Column - ReplaceLen + 2); Index++) {
- *Buffer = *(Buffer + Gap);
- Buffer++;
- }
- }
-
- if (ReplaceLen == SearchLen) {
- Buffer = FileBuffer.CurrentLine->Buffer + FileBuffer.FilePosition.Column - 1;
- for (Index = 0; Index < ReplaceLen; Index++) {
- Buffer[Index] = Replace[Index];
- }
- }
-
- FileBuffer.CurrentLine->Size += (ReplaceLen - SearchLen);
-
- FileBufferOnlyLineNeedRefresh = TRUE;
-
- FileBuffer.FileModified = TRUE;
-
- MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
- FileBufferRestorePosition ();
- FileBufferRefresh ();
-
- return EFI_SUCCESS;
-}
-
-/**
- Move the mouse cursor position.
-
- @param[in] TextX The new x-coordinate.
- @param[in] TextY The new y-coordinate.
-**/
-VOID
-EFIAPI
-FileBufferAdjustMousePosition (
- IN CONST INT32 TextX,
- IN CONST INT32 TextY
- )
-{
- UINTN CoordinateX;
- UINTN CoordinateY;
- UINTN AbsX;
- UINTN AbsY;
-
- //
- // TextX and TextY is mouse movement data returned by mouse driver
- // This function will change it to MousePosition
- //
- //
- // get absolute value
- //
-
- AbsX = ABS(TextX);
- AbsY = ABS(TextY);
-
- CoordinateX = FileBuffer.MousePosition.Column;
- CoordinateY = FileBuffer.MousePosition.Row;
-
- if (TextX >= 0) {
- CoordinateX += TextX;
- } else {
- if (CoordinateX >= AbsX) {
- CoordinateX -= AbsX;
- } else {
- CoordinateX = 0;
- }
- }
-
- if (TextY >= 0) {
- CoordinateY += TextY;
- } else {
- if (CoordinateY >= AbsY) {
- CoordinateY -= AbsY;
- } else {
- CoordinateY = 0;
- }
- }
- //
- // check whether new mouse column position is beyond screen
- // if not, adjust it
- //
- if (CoordinateX >= 1 && CoordinateX <= MainEditor.ScreenSize.Column) {
- FileBuffer.MousePosition.Column = CoordinateX;
- } else if (CoordinateX < 1) {
- FileBuffer.MousePosition.Column = 1;
- } else if (CoordinateX > MainEditor.ScreenSize.Column) {
- FileBuffer.MousePosition.Column = MainEditor.ScreenSize.Column;
- }
- //
- // check whether new mouse row position is beyond screen
- // if not, adjust it
- //
- if (CoordinateY >= 2 && CoordinateY <= (MainEditor.ScreenSize.Row - 1)) {
- FileBuffer.MousePosition.Row = CoordinateY;
- } else if (CoordinateY < 2) {
- FileBuffer.MousePosition.Row = 2;
- } else if (CoordinateY > (MainEditor.ScreenSize.Row - 1)) {
- FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 1);
- }
-
-}
-
-/**
- Search and replace operation.
-
- @param[in] SearchStr The string to search for.
- @param[in] ReplaceStr The string to replace with.
- @param[in] Offset The column to start at.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferReplaceAll (
- IN CHAR16 *SearchStr,
- IN CHAR16 *ReplaceStr,
- IN UINTN Offset
- )
-{
- CHAR16 *Buffer;
- UINTN Position;
- UINTN Column;
- UINTN ReplaceLen;
- UINTN SearchLen;
- UINTN Index;
- UINTN NewSize;
- UINTN OldSize;
- UINTN Gap;
- EFI_EDITOR_LINE *Line;
- LIST_ENTRY *Link;
- CHAR16 *CharPos;
-
- SearchLen = StrLen (SearchStr);
- ReplaceLen = StrLen (ReplaceStr);
-
- Column = FileBuffer.FilePosition.Column + Offset - 1;
-
- if (Column > FileBuffer.CurrentLine->Size) {
- Column = FileBuffer.CurrentLine->Size;
- }
-
- Link = &(FileBuffer.CurrentLine->Link);
-
- while (Link != FileBuffer.ListHead) {
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
- CharPos = StrStr (Line->Buffer + Column, SearchStr);
- if (CharPos != NULL) {
- Position = CharPos - Line->Buffer;// + Column;
- //
- // found
- //
- if (ReplaceLen > SearchLen) {
- OldSize = Line->Size + 1;
- //
- // include CHAR_NULL
- //
- NewSize = OldSize + (ReplaceLen - SearchLen);
-
- //
- // do not have the enough space
- //
- if (Line->TotalSize + 1 <= NewSize) {
- Line->Buffer = ReallocatePool (
- 2 * OldSize,
- 2 * NewSize,
- Line->Buffer
- );
- Line->TotalSize = NewSize - 1;
- }
-
- if (Line->Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // the end CHAR_NULL character;
- //
- Buffer = Line->Buffer + (NewSize - 1);
- Gap = ReplaceLen - SearchLen;
-
- //
- // keep the latter part
- //
- for (Index = 0; Index < (Line->Size - Position - SearchLen + 1); Index++) {
- *Buffer = *(Buffer - Gap);
- Buffer--;
- }
-
- } else if (ReplaceLen < SearchLen){
- Buffer = Line->Buffer + Position + ReplaceLen;
- Gap = SearchLen - ReplaceLen;
-
- for (Index = 0; Index < (Line->Size - Position - ReplaceLen + 1); Index++) {
- *Buffer = *(Buffer + Gap);
- Buffer++;
- }
- } else {
- ASSERT(ReplaceLen == SearchLen);
- }
- //
- // set replace into it
- //
- Buffer = Line->Buffer + Position;
- for (Index = 0; Index < ReplaceLen; Index++) {
- Buffer[Index] = ReplaceStr[Index];
- }
-
- Line->Size += (ReplaceLen - SearchLen);
- Column += ReplaceLen;
- } else {
- //
- // not found
- //
- Column = 0;
- Link = Link->ForwardLink;
- }
- }
- //
- // call refresh to fresh edit area
- //
- FileBuffer.FileModified = TRUE;
- FileBufferNeedRefresh = TRUE;
- FileBufferRefresh ();
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the modified state to TRUE.
-**/
-VOID
-EFIAPI
-FileBufferSetModified (
- VOID
- )
-{
- FileBuffer.FileModified = TRUE;
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.h
deleted file mode 100644
index 9d4a08d7a3..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/** @file
- Declares filebuffer interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_FILE_BUFFER_H_
-#define _LIB_FILE_BUFFER_H_
-
-#include "TextEditorTypes.h"
-
-/**
- Initialization function for FileBuffer.
-
- @param EFI_SUCCESS The initialization was successful.
- @param EFI_LOAD_ERROR A default name could not be created.
- @param EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferInit (
- VOID
- );
-
-/**
- Cleanup function for FileBuffer.
-
- @retval EFI_SUCCESS The cleanup was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferCleanup (
- VOID
- );
-
-/**
- Refresh the screen with whats in the buffer.
-
- @retval EFI_SUCCESS The refresh was successful.
- @retval EFI_LOAD_ERROR There was an error finding what to write.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRefresh (
- VOID
- );
-
-/**
- Dispatch input to different handler
- @param[in] Key The input key. One of:
- ASCII KEY
- Backspace/Delete
- Return
- Direction key: up/down/left/right/pgup/pgdn
- Home/End
- INS
-
- @retval EFI_SUCCESS The dispatch was done successfully.
- @retval EFI_LOAD_ERROR The dispatch was not successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferHandleInput (
- IN CONST EFI_INPUT_KEY * Key
- );
-
-/**
- Backup function for FileBuffer. Only backup the following items:
- Mouse/Cursor position
- File Name, Type, ReadOnly, Modified
- Insert Mode
-
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The backup operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferBackup (
- VOID
- );
-
-/**
- Set the cursor position according to FileBuffer.DisplayPosition.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRestorePosition (
- VOID
- );
-
-/**
- Set FileName field in FileBuffer.
-
- @param Str The file name to set.
-
- @retval EFI_SUCCESS The filename was successfully set.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER Str is not a valid filename.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSetFileName (
- IN CONST CHAR16 *Str
- );
-
-/**
- Read a file from disk into the FileBuffer.
-
- @param[in] FileName The filename to read.
- @param[in] Recover TRUE if is for recover mode, no information printouts.
-
- @retval EFI_SUCCESS The load was successful.
- @retval EFI_LOAD_ERROR The load failed.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER FileName is a directory.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferRead (
- IN CONST CHAR16 *FileName,
- IN CONST BOOLEAN Recover
- );
-
-/**
- Save lines in FileBuffer to disk
-
- @param[in] FileName The file name for writing.
-
- @retval EFI_SUCCESS Data was written.
- @retval EFI_LOAD_ERROR
- @retval EFI_OUT_OF_RESOURCES There were not enough resources to write the file.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSave (
- CONST CHAR16 *FileName
- );
-
-/**
- According to cursor's file position, adjust screen display
-
- @param[in] NewFilePosRow The row of file position ( start from 1 ).
- @param[in] NewFilePosCol The column of file position ( start from 1 ).
-**/
-VOID
-EFIAPI
-FileBufferMovePosition (
- IN CONST UINTN NewFilePosRow,
- IN CONST UINTN NewFilePosCol
- );
-
-/**
- Cut current line out and return a pointer to it.
-
- @param[out] CutLine Upon a successful return pointer to the pointer to
- the allocated cut line.
-
- @retval EFI_SUCCESS The cut was successful.
- @retval EFI_NOT_FOUND There was no selection to cut.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferCutLine (
- OUT EFI_EDITOR_LINE **CutLine
- );
-
-/**
- Paste a line into line list.
-
- @retval EFI_SUCCESS The paste was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferPasteLine (
- VOID
- );
-
-/**
- Search string from current position on in file
-
- @param[in] Str The search string.
- @param[in] Offset The offset from current position.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND The string Str was not found.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferSearch (
- IN CONST CHAR16 *Str,
- IN CONST UINTN Offset
- );
-
-/**
- Replace SearchLen characters from current position on with Replace.
-
- This will modify the current buffer at the current position.
-
- @param[in] Replace The string to replace.
- @param[in] SearchLen Search string's length.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferReplace (
- IN CONST CHAR16 *Replace,
- IN CONST UINTN SearchLen
- );
-
-/**
- Search and replace operation.
-
- @param[in] SearchStr The string to search for.
- @param[in] ReplaceStr The string to replace with.
- @param[in] Offset The column to start at.
-**/
-EFI_STATUS
-EFIAPI
-FileBufferReplaceAll (
- IN CHAR16 *SearchStr,
- IN CHAR16 *ReplaceStr,
- IN UINTN Offset
- );
-
-/**
- Move the mouse cursor position.
-
- @param[in] TextX The new x-coordinate.
- @param[in] TextY The new y-coordinate.
-**/
-VOID
-EFIAPI
-FileBufferAdjustMousePosition (
- IN CONST INT32 TextX,
- IN CONST INT32 TextY
- );
-
-/**
- Set the modified state to TRUE.
-**/
-VOID
-EFIAPI
-FileBufferSetModified (
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
deleted file mode 100644
index f972c37839..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ /dev/null
@@ -1,1935 +0,0 @@
-/** @file
- Implements editor interface functions.
-
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "TextEditor.h"
-#include "EditStatusBar.h"
-#include "EditInputBar.h"
-#include "EditMenuBar.h"
-
-//
-// the first time editor launch
-//
-BOOLEAN EditorFirst;
-
-//
-// it's time editor should exit
-//
-BOOLEAN EditorExit;
-
-BOOLEAN EditorMouseAction;
-
-extern EFI_EDITOR_FILE_BUFFER FileBuffer;
-
-extern BOOLEAN FileBufferNeedRefresh;
-
-extern BOOLEAN FileBufferOnlyLineNeedRefresh;
-
-extern BOOLEAN FileBufferMouseNeedRefresh;
-
-extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
-
-EFI_EDITOR_GLOBAL_EDITOR MainEditor;
-
-
-/**
- Load a file from disk to editor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-MainCommandOpenFile (
- VOID
- );
-
-/**
- Switch a file from ASCII to UNICODE or vise-versa.
-
- @retval EFI_SUCCESS The switch was ok or a warning was presented.
-**/
-EFI_STATUS
-MainCommandSwitchFileType (
- VOID
- );
-
-/**
- move cursor to specified lines
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-MainCommandGotoLine (
- VOID
- );
-
-/**
- Save current file to disk, you can save to current file name or
- save to another file name.
-
- @retval EFI_SUCCESS The file was saved correctly.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A file access error occured.
-**/
-EFI_STATUS
-MainCommandSaveFile (
- VOID
- );
-
-/**
- Show help information for the editor.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-MainCommandDisplayHelp (
- VOID
- );
-
-/**
- exit editor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandExit (
- VOID
- );
-
-/**
- search string in file buffer
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandSearch (
- VOID
- );
-
-/**
- search string in file buffer, and replace it with another str
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandSearchReplace (
- VOID
- );
-
-/**
- cut current line to clipboard
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandCutLine (
- VOID
- );
-
-/**
- paste line to file buffer.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandPasteLine (
- VOID
- );
-
-/**
- Help info that will be displayed.
-**/
-EFI_STRING_ID MainMenuHelpInfo[] = {
- STRING_TOKEN(STR_EDIT_HELP_TITLE),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_LIST_TITLE),
- STRING_TOKEN(STR_EDIT_HELP_DIV),
- STRING_TOKEN(STR_EDIT_HELP_GO_TO_LINE),
- STRING_TOKEN(STR_EDIT_HELP_SAVE_FILE),
- STRING_TOKEN(STR_EDIT_HELP_EXIT),
- STRING_TOKEN(STR_EDIT_HELP_SEARCH),
- STRING_TOKEN(STR_EDIT_HELP_SEARCH_REPLACE),
- STRING_TOKEN(STR_EDIT_HELP_CUT_LINE),
- STRING_TOKEN(STR_EDIT_HELP_PASTE_LINE),
- STRING_TOKEN(STR_EDIT_HELP_OPEN_FILE),
- STRING_TOKEN(STR_EDIT_HELP_FILE_TYPE),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_EXIT_HELP),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_BLANK),
- STRING_TOKEN(STR_EDIT_HELP_DIV),
-0
-};
-
-MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {
- NULL,
- NULL, /* Ctrl - A */
- NULL, /* Ctrl - B */
- NULL, /* Ctrl - C */
- NULL, /* Ctrl - D */
- MainCommandDisplayHelp, /* Ctrl - E */
- MainCommandSearch, /* Ctrl - F */
- MainCommandGotoLine, /* Ctrl - G */
- NULL, /* Ctrl - H */
- NULL, /* Ctrl - I */
- NULL, /* Ctrl - J */
- MainCommandCutLine, /* Ctrl - K */
- NULL, /* Ctrl - L */
- NULL, /* Ctrl - M */
- NULL, /* Ctrl - N */
- MainCommandOpenFile, /* Ctrl - O */
- NULL, /* Ctrl - P */
- MainCommandExit, /* Ctrl - Q */
- MainCommandSearchReplace, /* Ctrl - R */
- MainCommandSaveFile, /* Ctrl - S */
- MainCommandSwitchFileType, /* Ctrl - T */
- MainCommandPasteLine, /* Ctrl - U */
- NULL, /* Ctrl - V */
- NULL, /* Ctrl - W */
- NULL, /* Ctrl - X */
- NULL, /* Ctrl - Y */
- NULL, /* Ctrl - Z */
-};
-
-EDITOR_MENU_ITEM MainMenuItems[] = {
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_GO_TO_LINE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F1),
- MainCommandGotoLine
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_SAVE_FILE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F2),
- MainCommandSaveFile
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_EXIT),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F3),
- MainCommandExit
- },
-
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_SEARCH),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F4),
- MainCommandSearch
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_SEARCH_REPLACE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F5),
- MainCommandSearchReplace
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_CUT_LINE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F6),
- MainCommandCutLine
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_PASTE_LINE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F7),
- MainCommandPasteLine
- },
-
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_OPEN_FILE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F8),
- MainCommandOpenFile
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F9),
- MainCommandSwitchFileType
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F11),
- MainCommandSwitchFileType
- },
-
- {
- 0,
- 0,
- NULL
- }
-};
-
-
-/**
- Load a file from disk to editor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-MainCommandOpenFile (
- VOID
- )
-{
- BOOLEAN Done;
- EFI_STATUS Status;
-
- //
- // This command will open a file from current working directory.
- // Read-only file can also be opened. But it can not be modified.
- // Below is the scenario of Open File command:
- // 1.IF currently opened file has not been modIFied, directly go to step .
- // IF currently opened file has been modified,
- // an Input Bar will be prompted as :
- // "File Modified. Save ( Yes/No/Cancel) ?"
- // IF user press 'y' or 'Y', currently opened file will be saved.
- // IF user press 'n' or 'N', currently opened file will
- // not be saved.
- // IF user press 'c' or 'C' or ESC, Open File command ends and
- // currently opened file is still opened.
- //
- // 2. An Input Bar will be prompted as : "File Name to Open: "
- // IF user press ESC, Open File command ends and
- // currently opened file is still opened.
- // Any other inputs with a Return will
- // cause currently opened file close.
- //
- // 3. IF user input file name is an existing file , this file will be read
- // and opened.
- // IF user input file name is a new file, this file will be created
- // and opened. This file's type ( UNICODE or ASCII ) is the same
- // with the old file.
- // if current file is modified, so you need to choose
- // whether to save it first.
- //
- if (MainEditor.FileBuffer->FileModified) {
-
- Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // the answer is just one character
- //
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // loop for user's answer
- // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
- //
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // want to save this file first
- //
- Status = FileBufferSave (MainEditor.FileBuffer->FileName);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
- FileBufferRestorePosition ();
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- //
- // the file won't be saved
- //
- Done = TRUE;
- break;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
- }
- }
- }
- //
- // TO get the open file name
- //
- Status = InputBarSetPrompt (L"File Name to Open: ");
- if (EFI_ERROR (Status)) {
- FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
- return Status;
- }
-
- Status = InputBarSetStringSize (100);
- if (EFI_ERROR (Status)) {
- FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
- //
- // The input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- //
- // CHECK if filename is valid
- //
- if (!IsValidFileName (InputBarGetString())) {
- FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
- StatusBarSetStatusString (L"Invalid File Name");
- return EFI_SUCCESS;
- }
-
- break;
- }
- }
- //
- // read from disk
- //
- Status = FileBufferRead (InputBarGetString(), FALSE);
-
- if (EFI_ERROR (Status)) {
- FileBufferRead (MainEditor.FileBuffer->FileName, TRUE);
- return EFI_LOAD_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Switch a file from ASCII to UNICODE or vise-versa.
-
- @retval EFI_SUCCESS The switch was ok or a warning was presented.
-**/
-EFI_STATUS
-MainCommandSwitchFileType (
- VOID
- )
-{
- //
- // Below is the scenario of File Type command:
- // After File Type is executed, file type will be changed to another type
- // if file is read-only, can not be modified
- //
- if (MainEditor.FileBuffer->ReadOnly) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- return EFI_SUCCESS;
- }
-
- if (MainEditor.FileBuffer->FileType == FileTypeUnicode) {
- MainEditor.FileBuffer->FileType = FileTypeAscii;
- } else {
- MainEditor.FileBuffer->FileType = FileTypeUnicode;
- }
-
- MainEditor.FileBuffer->FileModified = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- cut current line to clipboard
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandCutLine (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_EDITOR_LINE *Line;
-
- //
- // This command will cut current line ( where cursor is on ) to clip board.
- // And cursor will move to the beginning of next line.
- // Below is the scenario of Cut Line command:
- // 1. IF cursor is on valid line, current line will be cut to clip board.
- // IF cursor is not on valid line, an Status String will be prompted :
- // "Nothing to Cut".
- //
- Line = NULL;
- Status = FileBufferCutLine (&Line);
- if (Status == EFI_NOT_FOUND) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MainEditor.CutLine = Line;
-
- return EFI_SUCCESS;
-}
-
-/**
- paste line to file buffer.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandPasteLine (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Below is the scenario of Paste Line command:
- // 1. IF nothing is on clipboard, a Status String will be prompted :
- // "No Line to Paste" and Paste Line command ends.
- // IF something is on clipboard, insert it above current line.
- // nothing on clipboard
- //
- if (MainEditor.CutLine == NULL) {
- StatusBarSetStatusString (L"No Line to Paste");
- return EFI_SUCCESS;
- }
-
- Status = FileBufferPasteLine ();
-
- return Status;
-}
-
-
-/**
- search string in file buffer
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandSearch (
- VOID
- )
-{
- EFI_STATUS Status;
- CHAR16 *Buffer;
- BOOLEAN Done;
- UINTN Offset;
-
- //
- // Below is the scenario of Search command:
- // 1. An Input Bar will be prompted : "Enter Search String:".
- // IF user press ESC, Search command ends.
- // IF user just press Enter, Search command ends.
- // IF user inputs the search string, do Step 2.
- //
- // 2. IF input search string is found, cursor will move to the first
- // occurrence and do Step 3.
- // IF input search string is not found, a Status String
- // "Search String Not Found" will be prompted and Search command ends.
- //
- // 3. An Input Bar will be prompted: "Find Next (Yes/No/Cancel ) ?".
- // IF user press ESC, Search command ends.
- // IF user press 'y' or 'Y', do Step 2.
- // IF user press 'n' or 'N', Search command ends.
- // IF user press 'c' or 'C', Search command ends.
- //
- Status = InputBarSetPrompt (L"Enter Search String: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (40);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
- //
- // just enter pressed
- //
- if (StrLen (InputBarGetString()) == 0) {
- return EFI_SUCCESS;
- }
-
- Buffer = CatSPrint (NULL, L"%s", InputBarGetString());
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // the first time , search from current position
- //
- Offset = 0;
- do {
- //
- // since search may be continued to search multiple times
- // so we need to backup editor each time
- //
- MainEditorBackup ();
-
- Status = FileBufferSearch (Buffer, Offset);
-
- if (Status == EFI_NOT_FOUND) {
- break;
- }
- //
- // Find next
- //
- Status = InputBarSetPrompt (L"Find Next (Yes/No) ?");
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- return Status;
- }
-
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- FreePool (Buffer);
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- FreePool (Buffer);
- return EFI_SUCCESS;
-
- }
- //
- // end of which
- //
- }
- //
- // end of while !Done
- // for search second, third time, search from current position + strlen
- //
- Offset = StrLen (Buffer);
-
- } while (1);
- //
- // end of do
- //
- FreePool (Buffer);
- StatusBarSetStatusString (L"Search String Not Found");
-
- return EFI_SUCCESS;
-}
-
-/**
- Search string in file buffer, and replace it with another str.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandSearchReplace (
- VOID
- )
-{
- EFI_STATUS Status;
- CHAR16 *Search;
- CHAR16 *Replace;
- BOOLEAN Done;
- BOOLEAN First;
- BOOLEAN ReplaceOption;
- UINTN SearchLen;
- UINTN ReplaceLen;
- BOOLEAN ReplaceAll;
-
- ReplaceOption = FALSE;
-
- //
- // Below is the scenario of Search/Replace command:
- // 1. An Input Bar is prompted : "Enter Search String:".
- // IF user press ESC, Search/Replace command ends.
- // IF user just press Enter, Search/Replace command ends.
- // IF user inputs the search string S, do Step 2.
- //
- // 2. An Input Bar is prompted: "Replace With:".
- // IF user press ESC, Search/Replace command ends.
- // IF user inputs the replace string R, do Step 3.
- //
- // 3. IF input search string is not found, an Status String
- // "Search String Not Found" will be prompted
- // and Search/Replace command ends
- // IF input search string is found, do Step 4.
- //
- // 4. An Input Bar will be prompted: "Replace ( Yes/No/All/Cancel )?"
- // IF user press 'y' or 'Y', S will be replaced with R and do Step 5
- // IF user press 'n' or 'N', S will not be replaced and do Step 5.
- // IF user press 'a' or 'A', all the S from file current position on
- // will be replaced with R and Search/Replace command ends.
- // IF user press 'c' or 'C' or ESC, Search/Replace command ends.
- //
- // 5. An Input Bar will be prompted: "Find Next (Yes/No/Cancel) ?".
- // IF user press ESC, Search/Replace command ends.
- // IF user press 'y' or 'Y', do Step 3.
- // IF user press 'n' or 'N', Search/Replace command ends.
- // IF user press 'c' or 'C', Search/Replace command ends.
- // input search string
- //
- Status = InputBarSetPrompt (L"Enter Search String: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (40);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
- //
- // if just pressed enter
- //
- if (StrLen (InputBarGetString()) == 0) {
- return EFI_SUCCESS;
- }
-
- Search = CatSPrint (NULL, L"%s", InputBarGetString());
- if (Search == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- SearchLen = StrLen (Search);
-
- //
- // input replace string
- //
- Status = InputBarSetPrompt (L"Replace With: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (40);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- Replace = CatSPrint (NULL, L"%s", InputBarGetString());
- if (Replace == NULL) {
- FreePool (Search);
- return EFI_OUT_OF_RESOURCES;
- }
-
- ReplaceLen = StrLen (Replace);
-
- First = TRUE;
- ReplaceAll = FALSE;
- do {
- //
- // since search may be continued to search multiple times
- // so we need to backup editor each time
- //
- MainEditorBackup ();
-
- if (First) {
- Status = FileBufferSearch (Search, 0);
- } else {
- //
- // if just replace, so skip this replace string
- // if replace string is an empty string, so skip to next character
- //
- if (ReplaceOption) {
- Status = FileBufferSearch (Search, (ReplaceLen == 0) ? 1 : ReplaceLen);
- } else {
- Status = FileBufferSearch (Search, SearchLen);
- }
- }
-
- if (Status == EFI_NOT_FOUND) {
- break;
- }
- //
- // replace or not?
- //
- Status = InputBarSetPrompt (L"Replace (Yes/No/All/Cancel) ?");
-
- if (EFI_ERROR (Status)) {
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
-
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- FreePool (Search);
- FreePool (Replace);
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- Done = TRUE;
- ReplaceOption = TRUE;
- break;
-
- case L'n':
- case L'N':
- Done = TRUE;
- ReplaceOption = FALSE;
- break;
-
- case L'a':
- case L'A':
- Done = TRUE;
- ReplaceOption = TRUE;
- ReplaceAll = TRUE;
- break;
-
- case L'c':
- case L'C':
- FreePool (Search);
- FreePool (Replace);
- return EFI_SUCCESS;
-
- }
- //
- // end of which
- //
- }
- //
- // end of while !Done
- // Decide to Replace
- //
- if (ReplaceOption) {
- //
- // file is read-only
- //
- if (MainEditor.FileBuffer->ReadOnly) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Modified");
- return EFI_SUCCESS;
- }
- //
- // replace all
- //
- if (ReplaceAll) {
- Status = FileBufferReplaceAll (Search, Replace, 0);
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
- //
- // replace
- //
- Status = FileBufferReplace (Replace, SearchLen);
- if (EFI_ERROR (Status)) {
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
- }
- //
- // Find next
- //
- Status = InputBarSetPrompt (L"Find Next (Yes/No) ?");
- if (EFI_ERROR (Status)) {
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- FreePool (Search);
- FreePool (Replace);
- return Status;
- }
-
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- FreePool (Search);
- FreePool (Replace);
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- FreePool (Search);
- FreePool (Replace);
- return EFI_SUCCESS;
-
- }
- //
- // end of which
- //
- }
- //
- // end of while !Done
- //
- First = FALSE;
-
- } while (1);
- //
- // end of do
- //
- FreePool (Search);
- FreePool (Replace);
-
- StatusBarSetStatusString (L"Search String Not Found");
-
- return EFI_SUCCESS;
-}
-
-/**
- exit editor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-MainCommandExit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Below is the scenario of Exit command:
- // 1. IF currently opened file is not modified, exit the editor and
- // Exit command ends.
- // IF currently opened file is modified, do Step 2
- //
- // 2. An Input Bar will be prompted:
- // "File modified. Save ( Yes/No/Cancel )?"
- // IF user press 'y' or 'Y', currently opened file will be saved
- // and Editor exits
- // IF user press 'n' or 'N', currently opened file will not be saved
- // and Editor exits.
- // IF user press 'c' or 'C' or ESC, Exit command ends.
- // if file has been modified, so will prompt user whether to save the changes
- //
- if (MainEditor.FileBuffer->FileModified) {
-
- Status = InputBarSetPrompt (L"File modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // write file back to disk
- //
- Status = FileBufferSave (MainEditor.FileBuffer->FileName);
- if (!EFI_ERROR (Status)) {
- EditorExit = TRUE;
- }
-
- return Status;
-
- case L'n':
- case L'N':
- EditorExit = TRUE;
- return EFI_SUCCESS;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
-
- }
- }
- }
-
- EditorExit = TRUE;
- return EFI_SUCCESS;
-
-}
-
-/**
- move cursor to specified lines
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-MainCommandGotoLine (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN Row;
-
- //
- // Below is the scenario of Go To Line command:
- // 1. An Input Bar will be prompted : "Go To Line:".
- // IF user press ESC, Go To Line command ends.
- // IF user just press Enter, cursor remains unchanged.
- // IF user inputs line number, do Step 2.
- //
- // 2. IF input line number is valid, move cursor to the beginning
- // of specified line and Go To Line command ends.
- // IF input line number is invalid, a Status String will be prompted:
- // "No Such Line" and Go To Line command ends.
- //
- Status = InputBarSetPrompt (L"Go To Line: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // line number's digit <= 6
- //
- Status = InputBarSetStringSize (6);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // press ESC
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
- //
- // if JUST press enter
- //
- if (StrLen (InputBarGetString()) == 0) {
- return EFI_SUCCESS;
- }
-
- Row = ShellStrToUintn (InputBarGetString());
-
- //
- // invalid line number
- //
- if (Row > MainEditor.FileBuffer->NumLines || Row <= 0) {
- StatusBarSetStatusString (L"No Such Line");
- return EFI_SUCCESS;
- }
- //
- // move cursor to that line's start
- //
- FileBufferMovePosition (Row, 1);
-
- return EFI_SUCCESS;
-}
-
-/**
- Save current file to disk, you can save to current file name or
- save to another file name.
-
- @retval EFI_SUCCESS The file was saved correctly.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A file access error occured.
-**/
-EFI_STATUS
-MainCommandSaveFile (
- VOID
- )
-{
- EFI_STATUS Status;
- CHAR16 *FileName;
- BOOLEAN OldFile;
- CHAR16 *Str;
- SHELL_FILE_HANDLE FileHandle;
- EFI_FILE_INFO *Info;
-
- //
- // This command will save currently opened file to disk.
- // You can choose save to another file name or just save to
- // current file name.
- // Below is the scenario of Save File command:
- // ( Suppose the old file name is A )
- // 1. An Input Bar will be prompted: "File To Save: [ old file name]"
- // IF user press ESC, Save File command ends .
- // IF user press Enter, input file name will be A.
- // IF user inputs a new file name B, input file name will be B.
- //
- // 2. IF input file name is A, go to do Step 3.
- // IF input file name is B, go to do Step 4.
- //
- // 3. IF A is read only, Status Bar will show "Access Denied" and
- // Save File commands ends.
- // IF A is not read only, save file buffer to disk and remove modified
- // flag in Title Bar , then Save File command ends.
- //
- // 4. IF B does not exist, create this file and save file buffer to it.
- // Go to do Step 7.
- // IF B exits, do Step 5.
- //
- // 5.An Input Bar will be prompted:
- // "File Exists. Overwrite ( Yes/No/Cancel )?"
- // IF user press 'y' or 'Y', do Step 6.
- // IF user press 'n' or 'N', Save File commands ends.
- // IF user press 'c' or 'C' or ESC, Save File commands ends.
- //
- // 6. IF B is a read-only file, Status Bar will show "Access Denied" and
- // Save File commands ends.
- // IF B can be read and write, save file buffer to B.
- //
- // 7. Update File Name field in Title Bar to B and remove the modified
- // flag in Title Bar.
- //
- Str = CatSPrint (NULL, L"File to Save: [%s]", MainEditor.FileBuffer->FileName);
- if (Str == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (StrLen (Str) >= 50) {
- //
- // replace the long file name with "..."
- //
- Str[46] = L'.';
- Str[47] = L'.';
- Str[48] = L'.';
- Str[49] = L']';
- Str[50] = CHAR_NULL;
- }
-
- Status = InputBarSetPrompt (Str);
- FreePool(Str);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
-
- Status = InputBarSetStringSize (100);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // get new file name
- //
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // if user pressed ESC
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- //
- // if just enter pressed, so think save to current file name
- //
- if (StrLen (InputBarGetString()) == 0) {
- FileName = CatSPrint (NULL, L"%s", MainEditor.FileBuffer->FileName);
- } else {
- FileName = CatSPrint (NULL, L"%s", InputBarGetString());
- }
-
- if (FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (!IsValidFileName (FileName)) {
- StatusBarSetStatusString (L"Invalid File Name");
- FreePool (FileName);
- return EFI_SUCCESS;
- }
-
- OldFile = FALSE;
-
- //
- // save to the old file
- //
- if (StringNoCaseCompare (&FileName, &MainEditor.FileBuffer->FileName) == 0) {
- OldFile = TRUE;
- }
-
- if (OldFile) {
- //
- // if the file is read only, so can not write back to it.
- //
- if (MainEditor.FileBuffer->ReadOnly == TRUE) {
- StatusBarSetStatusString (L"Access Denied");
- FreePool (FileName);
- return EFI_SUCCESS;
- }
- } else {
- //
- // if the file exists
- //
- if (ShellFileExists(FileName) != EFI_NOT_FOUND) {
- //
- // check for read only
- //
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- StatusBarSetStatusString (L"Open Failed");
- FreePool (FileName);
- return EFI_SUCCESS;
- }
-
- Info = ShellGetFileInfo(FileHandle);
- if (Info == NULL) {
- StatusBarSetStatusString (L"Access Denied");
- FreePool (FileName);
- return (EFI_SUCCESS);
- }
-
- if (Info->Attribute & EFI_FILE_READ_ONLY) {
- StatusBarSetStatusString (L"Access Denied - Read Only");
- FreePool (Info);
- FreePool (FileName);
- return (EFI_SUCCESS);
- }
- FreePool (Info);
-
- //
- // ask user whether to overwrite this file
- //
- Status = InputBarSetPrompt (L"File exists. Overwrite (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (FileName);
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (FileName);
- return Status;
- }
-
- while (TRUE) {
- Status = InputBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
- StatusBarSetRefresh();
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- break;
-
- case L'n':
- case L'N':
- case L'c':
- case L'C':
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- } // end switch
- } // while (!done)
- } // file does exist
- } // if old file name same
-
- //
- // save file to disk with specified name
- //
- FileBufferSetModified();
- Status = FileBufferSave (FileName);
- SHELL_FREE_NON_NULL (FileName);
-
- return Status;
-}
-
-/**
- Show help information for the editor.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-MainCommandDisplayHelp (
- VOID
- )
-{
- INT32 CurrentLine;
- CHAR16 *InfoString;
- EFI_INPUT_KEY Key;
-
- //
- // print helpInfo
- //
- for (CurrentLine = 0; 0 != MainMenuHelpInfo[CurrentLine]; CurrentLine++) {
- InfoString = HiiGetString(gShellDebug1HiiHandle, MainMenuHelpInfo[CurrentLine], NULL);
- ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString);
- }
-
- //
- // scan for ctrl+w
- //
- do {
- gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- } while(SCAN_CONTROL_W != Key.UnicodeChar);
-
- //
- // update screen with file buffer's info
- //
- FileBufferRestorePosition ();
- FileBufferNeedRefresh = TRUE;
- FileBufferOnlyLineNeedRefresh = FALSE;
- FileBufferRefresh ();
-
- return EFI_SUCCESS;
-}
-
-EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
-INTN OriginalMode;
-
-
-//
-// basic initialization for MainEditor
-//
-EFI_EDITOR_GLOBAL_EDITOR MainEditorConst = {
- &FileBuffer,
- {
- {0, 0}
- },
- {
- 0,
- 0
- },
- NULL,
- FALSE,
- NULL
-};
-
-/**
- The initialization function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorInit (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- UINTN Index;
-
- //
- // basic initialization
- //
- CopyMem (&MainEditor, &MainEditorConst, sizeof (MainEditor));
-
- //
- // set screen attributes
- //
- MainEditor.ColorAttributes.Colors.Foreground = gST->ConOut->Mode->Attribute & 0x000000ff;
-
- MainEditor.ColorAttributes.Colors.Background = (UINT8) (gST->ConOut->Mode->Attribute >> 4);
- OriginalColors = MainEditor.ColorAttributes.Colors;
-
- OriginalMode = gST->ConOut->Mode->Mode;
-
- //
- // query screen size
- //
- gST->ConOut->QueryMode (
- gST->ConOut,
- gST->ConOut->Mode->Mode,
- &(MainEditor.ScreenSize.Column),
- &(MainEditor.ScreenSize.Row)
- );
-
- //
- // Find mouse in System Table ConsoleInHandle
- //
- Status = gBS->HandleProtocol (
- gST->ConIn,
- &gEfiSimplePointerProtocolGuid,
- (VOID**)&MainEditor.MouseInterface
- );
- if (EFI_ERROR (Status)) {
- //
- // If there is no Simple Pointer Protocol on System Table
- //
- HandleBuffer = NULL;
- MainEditor.MouseInterface = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimplePointerProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (!EFI_ERROR (Status) && HandleCount > 0) {
- //
- // Try to find the first available mouse device
- //
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiSimplePointerProtocolGuid,
- (VOID**)&MainEditor.MouseInterface
- );
- if (!EFI_ERROR (Status)) {
- break;
- }
- }
- }
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
- }
-
- if (!EFI_ERROR (Status) && MainEditor.MouseInterface != NULL) {
- MainEditor.MouseAccumulatorX = 0;
- MainEditor.MouseAccumulatorY = 0;
- MainEditor.MouseSupported = TRUE;
- }
-
- //
- // below will call the five components' init function
- //
- Status = MainTitleBarInit (L"UEFI EDIT");
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_TITLEBAR), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = ControlHotKeyInit (MainControlBasedMenuFunctions);
- Status = MenuBarInit (MainMenuItems);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_MAINMENU), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = StatusBarInit ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_STATUSBAR), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- InputBarInit ();
-
- Status = FileBufferInit ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_FILEBUFFER), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
- //
- // clear whole screen and enable cursor
- //
- gST->ConOut->ClearScreen (gST->ConOut);
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- //
- // initialize EditorFirst and EditorExit
- //
- EditorFirst = TRUE;
- EditorExit = FALSE;
- EditorMouseAction = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- The cleanup function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorCleanup (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // call the five components' cleanup function
- // if error, do not exit
- // just print some warning
- //
- MainTitleBarCleanup();
- StatusBarCleanup();
- InputBarCleanup();
- MenuBarCleanup ();
-
- Status = FileBufferCleanup ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gShellDebug1HiiHandle);
- }
- //
- // restore old mode
- //
- if (OriginalMode != gST->ConOut->Mode->Mode) {
- gST->ConOut->SetMode (gST->ConOut, OriginalMode);
- }
- //
- // restore old screen color
- //
- gST->ConOut->SetAttribute (
- gST->ConOut,
- EFI_TEXT_ATTR (OriginalColors.Foreground, OriginalColors.Background)
- );
-
- gST->ConOut->ClearScreen (gST->ConOut);
-
- return EFI_SUCCESS;
-}
-
-/**
- Refresh the main editor component.
-**/
-VOID
-EFIAPI
-MainEditorRefresh (
- VOID
- )
-{
- //
- // The Stall value is from experience. NOT from spec. avoids 'flicker'
- //
- gBS->Stall (50);
-
- //
- // call the components refresh function
- //
- if (EditorFirst
- || StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0
- || FileBufferBackupVar.FileType != FileBuffer.FileType
- || FileBufferBackupVar.FileModified != FileBuffer.FileModified
- || FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly) {
-
- MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);
- FileBufferRestorePosition ();
- FileBufferRefresh ();
- }
- if (EditorFirst
- || FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row
- || FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column
- || FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert
- || StatusBarGetRefresh()) {
-
- StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert);
- FileBufferRestorePosition ();
- FileBufferRefresh ();
- }
-
- if (EditorFirst) {
- FileBufferRestorePosition ();
- }
-
- //
- // EditorFirst is now set to FALSE
- //
- EditorFirst = FALSE;
-}
-
-/**
- Get's the resultant location of the cursor based on the relative movement of the Mouse.
-
- @param[in] GuidX The relative mouse movement.
-
- @return The X location of the mouse.
-**/
-INT32
-EFIAPI
-GetTextX (
- IN INT32 GuidX
- )
-{
- INT32 Gap;
-
- MainEditor.MouseAccumulatorX += GuidX;
- Gap = (MainEditor.MouseAccumulatorX * (INT32) MainEditor.ScreenSize.Column) / (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionX);
- MainEditor.MouseAccumulatorX = (MainEditor.MouseAccumulatorX * (INT32) MainEditor.ScreenSize.Column) % (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionX);
- MainEditor.MouseAccumulatorX = MainEditor.MouseAccumulatorX / (INT32) MainEditor.ScreenSize.Column;
- return Gap;
-}
-
-/**
- Get's the resultant location of the cursor based on the relative movement of the Mouse.
-
- @param[in] GuidY The relative mouse movement.
-
- @return The Y location of the mouse.
-**/
-INT32
-EFIAPI
-GetTextY (
- IN INT32 GuidY
- )
-{
- INT32 Gap;
-
- MainEditor.MouseAccumulatorY += GuidY;
- Gap = (MainEditor.MouseAccumulatorY * (INT32) MainEditor.ScreenSize.Row) / (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionY);
- MainEditor.MouseAccumulatorY = (MainEditor.MouseAccumulatorY * (INT32) MainEditor.ScreenSize.Row) % (INT32) (50 * (INT32) MainEditor.MouseInterface->Mode->ResolutionY);
- MainEditor.MouseAccumulatorY = MainEditor.MouseAccumulatorY / (INT32) MainEditor.ScreenSize.Row;
-
- return Gap;
-}
-
-/**
- Support mouse movement. Move the cursor.
-
- @param[in] MouseState The current mouse state.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND There was no mouse support found.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorHandleMouseInput (
- IN EFI_SIMPLE_POINTER_STATE MouseState
- )
-{
-
- INT32 TextX;
- INT32 TextY;
- UINTN FRow;
- UINTN FCol;
-
- LIST_ENTRY *Link;
- EFI_EDITOR_LINE *Line;
-
- UINTN Index;
- BOOLEAN Action;
-
- //
- // mouse action means:
- // mouse movement
- // mouse left button
- //
- Action = FALSE;
-
- //
- // have mouse movement
- //
- if (MouseState.RelativeMovementX || MouseState.RelativeMovementY) {
- //
- // handle
- //
- TextX = GetTextX (MouseState.RelativeMovementX);
- TextY = GetTextY (MouseState.RelativeMovementY);
-
- FileBufferAdjustMousePosition (TextX, TextY);
-
- Action = TRUE;
-
- }
-
- //
- // if left button pushed down
- //
- if (MouseState.LeftButton) {
-
- FCol = MainEditor.FileBuffer->MousePosition.Column - 1 + 1;
-
- FRow = MainEditor.FileBuffer->FilePosition.Row +
- MainEditor.FileBuffer->MousePosition.Row -
- MainEditor.FileBuffer->DisplayPosition.Row;
-
- //
- // beyond the file line length
- //
- if (MainEditor.FileBuffer->NumLines < FRow) {
- FRow = MainEditor.FileBuffer->NumLines;
- }
-
- Link = MainEditor.FileBuffer->ListHead->ForwardLink;
- for (Index = 0; Index < FRow - 1; Index++) {
- Link = Link->ForwardLink;
- }
-
- Line = CR (Link, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
-
- //
- // beyond the line's column length
- //
- if (FCol > Line->Size + 1) {
- FCol = Line->Size + 1;
- }
-
- FileBufferMovePosition (FRow, FCol);
-
- MainEditor.FileBuffer->MousePosition.Row = MainEditor.FileBuffer->DisplayPosition.Row;
-
- MainEditor.FileBuffer->MousePosition.Column = MainEditor.FileBuffer->DisplayPosition.Column;
-
- Action = TRUE;
- }
- //
- // mouse has action
- //
- if (Action) {
- return EFI_SUCCESS;
- }
-
- //
- // no mouse action
- //
- return EFI_NOT_FOUND;
-}
-
-/**
- Handle user key input. This routes to other functions for the actions.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorKeyInput (
- VOID
- )
-{
- EFI_INPUT_KEY Key;
- EFI_STATUS Status;
- EFI_SIMPLE_POINTER_STATE MouseState;
-
- do {
-
- Status = EFI_SUCCESS;
- EditorMouseAction = FALSE;
-
- //
- // backup some key elements, so that can aVOID some refresh work
- //
- MainEditorBackup ();
-
- //
- // change priority of checking mouse/keyboard activity dynamically
- // so prevent starvation of keyboard.
- // if last time, mouse moves then this time check keyboard
- //
- if (MainEditor.MouseSupported) {
- Status = MainEditor.MouseInterface->GetState (
- MainEditor.MouseInterface,
- &MouseState
- );
- if (!EFI_ERROR (Status)) {
-
- Status = MainEditorHandleMouseInput (MouseState);
-
- if (!EFI_ERROR (Status)) {
- EditorMouseAction = TRUE;
- FileBufferMouseNeedRefresh = TRUE;
- } else if (Status == EFI_LOAD_ERROR) {
- StatusBarSetStatusString (L"Invalid Mouse Movement ");
- }
- }
- }
-
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (!EFI_ERROR (Status)) {
- //
- // dispatch to different components' key handling function
- // so not everywhere has to set this variable
- //
- FileBufferMouseNeedRefresh = TRUE;
- //
- // clear previous status string
- //
- StatusBarSetRefresh();
-
- //
- // dispatch to different components' key handling function
- //
- if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey(&Key)) {
- Status = EFI_SUCCESS;
- } else if ((Key.ScanCode == SCAN_NULL) || ((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {
- Status = FileBufferHandleInput (&Key);
- } else if ((Key.ScanCode >= SCAN_F1) && (Key.ScanCode <= SCAN_F12)) {
- Status = MenuBarDispatchFunctionKey (&Key);
- } else {
- StatusBarSetStatusString (L"Unknown Command");
- FileBufferMouseNeedRefresh = FALSE;
- }
-
- if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {
- //
- // not already has some error status
- //
- if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {
- StatusBarSetStatusString (L"Disk Error. Try Again");
- }
- }
-
- }
- //
- // after handling, refresh editor
- //
- MainEditorRefresh ();
-
- } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
-
- return Status;
-}
-
-/**
- Set clipboard
-
- @param[in] Line A pointer to the line to be set to clipboard
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorSetCutLine (
- EFI_EDITOR_LINE *Line
- )
-{
- if (Line == NULL) {
- return EFI_SUCCESS;
- }
-
- if (MainEditor.CutLine != NULL) {
- //
- // free the old clipboard
- //
- LineFree (MainEditor.CutLine);
- }
- //
- // duplicate the line to clipboard
- //
- MainEditor.CutLine = LineDup (Line);
- if (MainEditor.CutLine == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Backup function for MainEditor
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorBackup (
- VOID
- )
-{
- FileBufferBackup ();
-
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.h
deleted file mode 100644
index c45859deda..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
- Declares editor interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_EDITOR_H_
-#define _LIB_EDITOR_H_
-
-#include "TextEditorTypes.h"
-
-/**
- The initialization function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorInit (
- VOID
- );
-
-/**
- The cleanup function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorCleanup (
- VOID
- );
-
-/**
- Refresh the main editor component.
-**/
-VOID
-EFIAPI
-MainEditorRefresh (
- VOID
- );
-
-/**
- Handle user key input. This routes to other functions for the actions.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorKeyInput (
- VOID
- );
-
-/**
- Backup function for MainEditor
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-MainEditorBackup (
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.c
deleted file mode 100644
index ade78b8f90..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/** @file
- Implementation of various string and line routines.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "TextEditor.h"
-#include "Misc.h"
-
-/**
- Duplicate a EFI_EDITOR_LINE structure.
-
- @param Src The line structure to copy from.
-
- @retval NULL A memory allocation failed.
- @return a pointer to the newly allcoated line.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-LineDup (
- IN EFI_EDITOR_LINE *Src
- )
-{
- EFI_EDITOR_LINE *Dest;
-
- //
- // allocate for the line structure
- //
- Dest = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
- if (Dest == NULL) {
- return NULL;
- }
- //
- // allocate and set the line buffer
- //
- Dest->Buffer = CatSPrint (NULL, L"%s", Src->Buffer);
- if (Dest->Buffer == NULL) {
- FreePool (Dest);
- return NULL;
- }
-
- //
- // set the other structure members
- //
- Dest->Signature = LINE_LIST_SIGNATURE;
- Dest->Size = Src->Size;
- Dest->TotalSize = Dest->Size;
- Dest->Type = Src->Type;
- Dest->Link = Src->Link;
-
- return Dest;
-}
-
-/**
- Free a EFI_EDITOR_LINE structure.
-
- @param Src The line structure to free.
-**/
-VOID
-EFIAPI
-LineFree (
- IN EFI_EDITOR_LINE *Src
- )
-{
- if (Src == NULL) {
- return ;
- }
- //
- // free the line buffer and then the line structure itself
- //
- SHELL_FREE_NON_NULL (Src->Buffer);
- SHELL_FREE_NON_NULL (Src);
-
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.h
deleted file mode 100644
index 583de3b42c..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/Misc.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/** @file
- Declares generic editor helper functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_MISC_H_
-#define _LIB_MISC_H_
-
-#include "TextEditorTypes.h"
-
-
-
-/**
- Free a EFI_EDITOR_LINE structure.
-
- @param Src The line structure to free.
-**/
-VOID
-EFIAPI
-LineFree (
- IN EFI_EDITOR_LINE *Src
- );
-
-/**
- Duplicate a EFI_EDITOR_LINE structure.
-
- @param Src The line structure to copy from.
-
- @retval NULL A memory allocation failed.
- @return a pointer to the newly allcoated line.
-**/
-EFI_EDITOR_LINE *
-EFIAPI
-LineDup (
- IN EFI_EDITOR_LINE *Src
- );
-
-
-
-
-
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni
deleted file mode 100644
index a61cae33d3..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditor.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditor.h
deleted file mode 100644
index 774f01a291..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditor.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/** @file
- Main include file for Edit shell Debug1 function.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _EFI_EDIT_H_
-#define _EFI_EDIT_H_
-
-#include "TextEditorTypes.h"
-
-#include "MainTextEditor.h"
-#include "FileBuffer.h"
-#include "EditTitleBar.h"
-#include "EditStatusBar.h"
-#include "EditInputBar.h"
-#include "EditMenuBar.h"
-#include "Misc.h"
-
-extern EFI_EDITOR_GLOBAL_EDITOR MainEditor;
-extern BOOLEAN EditorFirst;
-extern BOOLEAN EditorExit;
-
-#endif // _EFI_EDIT_H_
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditorTypes.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditorTypes.h
deleted file mode 100644
index dfd56dd9a6..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditorTypes.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/** @file
- Declares editor types.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _EDITOR_TYPE_H_
-#define _EDITOR_TYPE_H_
-
-#include "UefiShellDebug1CommandsLib.h"
-#include "EditTitleBar.h"
-#include "EditMenuBar.h"
-
-#define MIN_POOL_SIZE 125
-#define MAX_STRING_LENGTH 127
-
-typedef struct {
- UINTN Row;
- UINTN Column;
-} EFI_EDITOR_POSITION;
-
-typedef
-EFI_STATUS
-(*EFI_MENU_ITEM_FUNCTION) (
- VOID
- );
-
-typedef enum {
- NewLineTypeDefault,
- NewLineTypeLineFeed,
- NewLineTypeCarriageReturn,
- NewLineTypeCarriageReturnLineFeed,
- NewLineTypeLineFeedCarriageReturn,
- NewLineTypeUnknown
-} EE_NEWLINE_TYPE;
-
-#define LINE_LIST_SIGNATURE SIGNATURE_32 ('e', 'e', 'l', 'l')
-typedef struct _EFI_EDITOR_LINE {
- UINTN Signature;
- CHAR16 *Buffer;
- UINTN Size; // unit is Unicode
- UINTN TotalSize; // unit is Unicode, exclude CHAR_NULL
- EE_NEWLINE_TYPE Type;
- LIST_ENTRY Link;
-} EFI_EDITOR_LINE;
-
-typedef struct {
- UINT32 Foreground : 4;
- UINT32 Background : 4;
-} EFI_EDITOR_COLOR_ATTRIBUTES;
-
-typedef union {
- EFI_EDITOR_COLOR_ATTRIBUTES Colors;
- UINTN Data;
-} EFI_EDITOR_COLOR_UNION;
-
-typedef struct {
- UINTN Columns;
- UINTN Rows;
-} EFI_EDITOR_TEXT_MODE;
-
-typedef struct {
- CHAR16 *FileName; // file name current edited in editor
- EDIT_FILE_TYPE FileType; // Unicode file or ASCII file
- LIST_ENTRY *ListHead; // list head of lines
- EFI_EDITOR_LINE *Lines; // lines of current file
- UINTN NumLines; // total line numbers
- EFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
- EFI_EDITOR_POSITION FilePosition; // cursor position in file
- EFI_EDITOR_POSITION MousePosition; // mouse position in screen
- // file position of first byte displayed on screen
- //
- EFI_EDITOR_POSITION LowVisibleRange;
-
- BOOLEAN FileModified; // file is modified or not
- BOOLEAN ModeInsert; // input mode INS or OVR
- BOOLEAN ReadOnly; // file is read-only or not
- EFI_EDITOR_LINE *CurrentLine; // current line cursor is at
-} EFI_EDITOR_FILE_BUFFER;
-
-typedef struct {
- EFI_EDITOR_FILE_BUFFER *FileBuffer;
-
- EFI_EDITOR_COLOR_UNION ColorAttributes;
- EFI_EDITOR_POSITION ScreenSize; // row number and column number
- EFI_EDITOR_LINE *CutLine; // clip board
- BOOLEAN MouseSupported;
- EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
- INT32 MouseAccumulatorX;
- INT32 MouseAccumulatorY;
-
-} EFI_EDITOR_GLOBAL_EDITOR;
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
deleted file mode 100644
index 5c43ffcd9d..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/** @file
- Implements inputbar interface functions.
-
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "EditInputBar.h"
-#include "UefiShellDebug1CommandsLib.h"
-
-CHAR16 *mPrompt; // Input bar mPrompt string.
-CHAR16 *mReturnString; // The returned string.
-UINTN StringSize; // Size of mReturnString space size.
-
-/**
- Initialize the input bar.
-**/
-VOID
-EFIAPI
-InputBarInit (
- VOID
- )
-{
- mPrompt = NULL;
- mReturnString = NULL;
- StringSize = 0;
-}
-
-/**
- Cleanup function for input bar.
-**/
-VOID
-EFIAPI
-InputBarCleanup (
- VOID
- )
-{
- //
- // free input bar's prompt and input string
- //
- SHELL_FREE_NON_NULL (mPrompt);
- SHELL_FREE_NON_NULL (mReturnString);
- mPrompt = NULL;
- mReturnString = NULL;
-}
-
-/**
- Display the prompt.
- Do the requesting of input.
-
- @param[in] LastColumn The last printable column.
- @param[in] LastRow The last printable row.
-**/
-VOID
-EFIAPI
-InputBarPrintInput (
- IN UINTN LastColumn,
- IN UINTN LastRow
- )
-{
- UINTN Limit;
- UINTN Size;
- CHAR16 *Buffer;
- UINTN Index;
- UINTN mPromptLen;
-
- mPromptLen = StrLen (mPrompt);
- Limit = LastColumn - mPromptLen - 1;
- Size = StrLen (mReturnString);
-
- //
- // check whether the mPrompt length and input length will
- // exceed limit
- //
- if (Size <= Limit) {
- Buffer = mReturnString;
- } else {
- Buffer = mReturnString + Size - Limit;
- }
-
- gST->ConOut->EnableCursor (gST->ConOut, FALSE);
-
- ShellPrintEx (((INT32)mPromptLen), ((INT32)LastRow) - 1, L"%s", Buffer);
- Size = StrLen (Buffer);
-
- //
- // print " " after mPrompt
- //
- for (Index = Size; Index < Limit; Index++) {
- ShellPrintEx ((INT32)(mPromptLen + Size), ((INT32)LastRow) - 1, L" ");
- }
-
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- gST->ConOut->SetCursorPosition (gST->ConOut, Size + mPromptLen, LastRow - 1);
-}
-
-typedef struct {
- UINT32 Foreground : 4;
- UINT32 Background : 3;
-} INPUT_BAR_COLOR_ATTRIBUTES;
-
-typedef union {
- INPUT_BAR_COLOR_ATTRIBUTES Colors;
- UINTN Data;
-} INPUT_BAR_COLOR_UNION;
-
-
-/**
- The refresh function for InputBar, it will wait for user input
-
- @param[in] LastRow The last printable row.
- @param[in] LastColumn The last printable column.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-InputBarRefresh (
- UINTN LastRow,
- UINTN LastColumn
- )
-{
- INPUT_BAR_COLOR_UNION Orig;
- INPUT_BAR_COLOR_UNION New;
- EFI_INPUT_KEY Key;
- UINTN Size;
- EFI_STATUS Status;
- BOOLEAN NoDisplay;
- UINTN EventIndex;
- UINTN CursorRow;
- UINTN CursorCol;
-
- //
- // variable initialization
- //
- Size = 0;
- Status = EFI_SUCCESS;
-
- //
- // back up the old screen attributes
- //
- CursorCol = gST->ConOut->Mode->CursorColumn;
- CursorRow = gST->ConOut->Mode->CursorRow;
- Orig.Data = gST->ConOut->Mode->Attribute;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background & 0xF;
- New.Colors.Background = Orig.Colors.Foreground & 0x7;
-
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
-
- //
- // clear input bar
- //
- EditorClearLine (LastRow , LastColumn, LastRow);
-
- gST->ConOut->SetCursorPosition (gST->ConOut, 0, LastRow - 1);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);
-
- //
- // this is a selection mPrompt, cursor will stay in edit area
- // actually this is for search , search/replace
- //
- if (StrStr (mPrompt, L"Yes/No")) {
- NoDisplay = TRUE;
- gST->ConOut->SetCursorPosition (gST->ConOut, CursorCol, CursorRow);
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- } else {
- NoDisplay = FALSE;
- }
- //
- // wait for user input
- //
- for (;;) {
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR (Status)) {
- continue;
- }
- //
- // pressed ESC
- //
- if (Key.ScanCode == SCAN_ESC) {
- Size = 0;
- Status = EFI_NOT_READY;
- break;
- }
- //
- // return pressed
- //
- if (Key.UnicodeChar == CHAR_LINEFEED || Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- break;
- } else if (Key.UnicodeChar == CHAR_BACKSPACE) {
- //
- // backspace
- //
- if (Size > 0) {
- Size--;
- mReturnString[Size] = CHAR_NULL;
- if (!NoDisplay) {
-
- InputBarPrintInput (LastColumn, LastRow);
-
- }
- }
- } else if (Key.UnicodeChar <= 127 && Key.UnicodeChar >= 32) {
- //
- // VALID ASCII char pressed
- //
- mReturnString[Size] = Key.UnicodeChar;
-
- //
- // should be less than specified length
- //
- if (Size >= StringSize) {
- continue;
- }
-
- Size++;
-
- mReturnString[Size] = CHAR_NULL;
-
- if (!NoDisplay) {
-
- InputBarPrintInput (LastColumn, LastRow);
-
- } else {
- //
- // if just choose yes/no
- //
- break;
- }
-
- }
- }
-
- mReturnString[Size] = CHAR_NULL;
-
-
- //
- // restore screen attributes
- //
- gST->ConOut->SetCursorPosition (gST->ConOut, CursorCol, CursorRow);
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
-
- return Status;
-}
-
-/**
- SetPrompt and wait for input.
-
- @param[in] Str The prompt string.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-InputBarSetPrompt (
- IN CONST CHAR16 *Str
- )
-{
- //
- // FREE the old mPrompt string
- //
- SHELL_FREE_NON_NULL (mPrompt);
-
- mPrompt = CatSPrint (NULL, L"%s ", Str);
- if (mPrompt == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the size of the string in characters.
-
- @param[in] Size The max number of characters to accept.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-InputBarSetStringSize (
- UINTN Size
- )
-{
- //
- // free the old ReturnStirng
- //
- SHELL_FREE_NON_NULL (mReturnString);
-
- StringSize = Size;
- mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof(mReturnString[0]));
- if (mReturnString == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to retrieve the input from the user.
-
- @retval NULL No input has been received.
- @return The string that was input.
-**/
-CONST CHAR16*
-EFIAPI
-InputBarGetString (
- VOID
- )
-{
- return (mReturnString);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.h
deleted file mode 100644
index c8557a83f1..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
- Declares imputbar interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_INPUT_BAR_H_
-#define _LIB_INPUT_BAR_H_
-
-/**
- Initialize the input bar.
-**/
-VOID
-EFIAPI
-InputBarInit (
- VOID
- );
-
-/**
- Cleanup function for input bar.
-**/
-VOID
-EFIAPI
-InputBarCleanup (
- VOID
- );
-
-/**
- The refresh function for InputBar, it will wait for user input
-
- @param[in] LastRow The last printable row.
- @param[in] LastColumn The last printable column.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-InputBarRefresh (
- UINTN LastRow,
- UINTN LastColumn
- );
-
-/**
- SetPrompt and wait for input.
-
- @param[in] Str The prompt string.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-InputBarSetPrompt (
- IN CONST CHAR16 *Str
- );
-
-/**
- Set the size of the string in characters.
-
- @param[in] Size The max number of characters to accept.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-InputBarSetStringSize (
- UINTN Size
- );
-
-/**
- Function to retrieve the input from the user.
-
- @retval NULL No input has been received.
- @return The string that was input.
-**/
-CONST CHAR16*
-EFIAPI
-InputBarGetString (
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
deleted file mode 100644
index b721850300..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/** @file
- implements menubar interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "EditMenuBar.h"
-#include "UefiShellDebug1CommandsLib.h"
-#include "EditStatusBar.h"
-
-EDITOR_MENU_ITEM *MenuItems;
-MENU_ITEM_FUNCTION *ControlBasedMenuFunctions;
-UINTN NumItems;
-
-/**
- Cleanup function for a menu bar. frees all allocated memory.
-**/
-VOID
-EFIAPI
-MenuBarCleanup (
- VOID
- )
-{
- SHELL_FREE_NON_NULL(MenuItems);
-}
-
-/**
- Initialize the menu bar with the specified items.
-
- @param[in] Items The items to display and their functions.
-
- @retval EFI_SUCCESS The initialization was correct.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarInit (
- IN CONST EDITOR_MENU_ITEM *Items
- )
-{
- CONST EDITOR_MENU_ITEM *ItemsWalker;
-
- for (NumItems = 0, ItemsWalker = Items ; ItemsWalker != NULL && ItemsWalker->Function != NULL ; ItemsWalker++,NumItems++);
-
- MenuItems = AllocateZeroPool((NumItems+1) * sizeof(EDITOR_MENU_ITEM));
- if (MenuItems == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem(MenuItems, Items, (NumItems+1) * sizeof(EDITOR_MENU_ITEM));
- return EFI_SUCCESS;
-}
-
-/**
- Initialize the control hot-key with the specified items.
-
- @param[in] Items The hot-key functions.
-
- @retval EFI_SUCCESS The initialization was correct.
-**/
-EFI_STATUS
-EFIAPI
-ControlHotKeyInit (
- IN MENU_ITEM_FUNCTION *Items
- )
-{
- ControlBasedMenuFunctions = Items;
- return EFI_SUCCESS;
-}
-/**
- Refresh function for the menu bar.
-
- @param[in] LastRow The last printable row.
- @param[in] LastCol The last printable column.
-
- @retval EFI_SUCCESS The refresh was successful.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarRefresh (
- IN CONST UINTN LastRow,
- IN CONST UINTN LastCol
- )
-{
- EDITOR_MENU_ITEM *Item;
- UINTN Col;
- UINTN Row;
- UINTN Width;
- CHAR16 *NameString;
- CHAR16 *FunctionKeyString;
-
- //
- // variable initialization
- //
- Col = 1;
- Row = (LastRow - 2);
-
- //
- // clear menu bar rows
- //
- EditorClearLine (LastRow - 2, LastCol, LastRow);
- EditorClearLine (LastRow - 1, LastCol, LastRow);
- EditorClearLine (LastRow , LastCol, LastRow);
-
-
- //
- // print out the menu items
- //
- for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) {
-
-
- NameString = HiiGetString(gShellDebug1HiiHandle, Item->NameToken, NULL);
-
-
- Width = MAX ((StrLen (NameString) + 6), 20);
- if (((Col + Width) > LastCol)) {
- Row++;
- Col = 1;
- }
-
- FunctionKeyString = HiiGetString(gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);
-
- ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
-
- FreePool (NameString);
- FreePool (FunctionKeyString);
- Col += Width;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to dispatch the correct function based on a function key (F1...)
-
- @param[in] Key The pressed key.
-
- @retval EFI_NOT_FOUND The key was not a valid function key
- (an error was sent to the status bar).
- @return The return value from the called dispatch function.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarDispatchFunctionKey (
- IN CONST EFI_INPUT_KEY *Key
- )
-{
- UINTN Index;
-
- Index = Key->ScanCode - SCAN_F1;
-
- //
- // check whether in range
- //
- if (Index > (NumItems - 1)) {
- StatusBarSetStatusString (L"Unknown Command");
- return EFI_SUCCESS;
- }
-
- return (MenuItems[Index].Function ());
-}
-
-/**
- Function to dispatch the correct function based on a control-based key (ctrl+o...)
-
- @param[in] Key The pressed key.
-
- @retval EFI_NOT_FOUND The key was not a valid control-based key
- (an error was sent to the status bar).
- @return EFI_SUCCESS.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarDispatchControlHotKey (
- IN CONST EFI_INPUT_KEY *Key
- )
-{
-
- if ((SCAN_CONTROL_Z < Key->UnicodeChar)
- ||(NULL == ControlBasedMenuFunctions[Key->UnicodeChar]))
- {
- return EFI_NOT_FOUND;
- }
-
- ControlBasedMenuFunctions[Key->UnicodeChar]();
- return EFI_SUCCESS;
-}
-
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.h
deleted file mode 100644
index 8cd846f28b..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/** @file
- Declares menubar interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_MENU_BAR_H_
-#define _LIB_MENU_BAR_H_
-
-#define SCAN_CONTROL_E 5
-#define SCAN_CONTROL_F 6
-#define SCAN_CONTROL_G 7
-#define SCAN_CONTROL_K 11
-#define SCAN_CONTROL_O 15
-#define SCAN_CONTROL_Q 17
-#define SCAN_CONTROL_R 18
-#define SCAN_CONTROL_S 19
-#define SCAN_CONTROL_T 20
-#define SCAN_CONTROL_U 21
-#define SCAN_CONTROL_W 23
-#define SCAN_CONTROL_Z 26
-
-
-typedef
-EFI_STATUS
-(*MENU_ITEM_FUNCTION) (
- VOID
- );
-
-typedef struct _EDITOR_MENU_ITEM {
- EFI_STRING_ID NameToken;
- CHAR16 FunctionKeyToken;
- MENU_ITEM_FUNCTION Function;
-} EDITOR_MENU_ITEM;
-
-/**
- Initializa the menu bar with the specified items.
-
- @param[in] Items The items to display and their functions.
-
- @retval EFI_SUCCESS The initialization was correct.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarInit (
- IN CONST EDITOR_MENU_ITEM *Items
- );
-
-/**
- Initialize the control hot-key with the specified items.
-
- @param[in] Items The hot-key functions.
-
- @retval EFI_SUCCESS The initialization was correct.
-**/
-EFI_STATUS
-EFIAPI
-ControlHotKeyInit (
- IN MENU_ITEM_FUNCTION *Items
- );
-
-/**
- Cleanup function for a menu bar. frees all allocated memory.
-**/
-VOID
-EFIAPI
-MenuBarCleanup (
- VOID
- );
-
-/**
- Refresh function for the menu bar.
-
- @param[in] LastRow The last printable row.
- @param[in] LastCol The last printable column.
-
- @retval EFI_SUCCESS The refresh was successful.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarRefresh (
- IN CONST UINTN LastRow,
- IN CONST UINTN LastCol
- );
-
-/**
- Function to dispatch the correct function based on a function key (F1...)
-
- @param[in] Key The pressed key.
-
- @retval EFI_NOT_FOUND The key was not a valid function key
- (an error was sent to the status bar).
- @return The return value from the called dispatch function.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarDispatchFunctionKey (
- IN CONST EFI_INPUT_KEY *Key
- );
-
-/**
- Function to dispatch the correct function based on a control-based key (ctrl+o...)
-
- @param[in] Key The pressed key.
-
- @retval EFI_NOT_FOUND The key was not a valid control-based key
- (an error was sent to the status bar).
- @return EFI_SUCCESS.
-**/
-EFI_STATUS
-EFIAPI
-MenuBarDispatchControlHotKey (
- IN CONST EFI_INPUT_KEY *Key
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c
deleted file mode 100644
index fbf48b7e2b..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/** @file
- Implements statusbar interface functions.
-
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "EditStatusBar.h"
-#include "UefiShellDebug1CommandsLib.h"
-
-CHAR16 *StatusString;
-BOOLEAN StatusBarNeedRefresh;
-BOOLEAN StatusStringChanged;
-
-/**
- Initialization function for Status Bar.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @sa StatusBarSetStatusString
-**/
-EFI_STATUS
-EFIAPI
-StatusBarInit (
- VOID
- )
-{
- //
- // initialize the statusbar
- //
- StatusString = NULL;
- StatusBarNeedRefresh = TRUE;
- StatusStringChanged = FALSE;
-
- //
- // status string set to ""
- //
- return (StatusBarSetStatusString (L""));
-}
-
-/**
- Cleanup function for the status bar.
-**/
-VOID
-EFIAPI
-StatusBarCleanup (
- VOID
- )
-{
- //
- // free the status string and backvar's status string
- //
- SHELL_FREE_NON_NULL (StatusString);
-}
-
-typedef struct {
- UINT32 Foreground : 4;
- UINT32 Background : 3;
-} STATUS_BAR_COLOR_ATTRIBUTES;
-
-typedef union {
- STATUS_BAR_COLOR_ATTRIBUTES Colors;
- UINTN Data;
-} STATUS_BAR_COLOR_UNION;
-
-/**
- Cause the status bar to refresh it's printing on the screen.
-
- @param[in] EditorFirst TRUE to indicate the first launch of the editor.
- FALSE otherwise.
- @param[in] LastRow LastPrintable row.
- @param[in] LastCol Last printable column.
- @param[in] FileRow Row in the file.
- @param[in] FileCol Column in the file.
- @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-StatusBarRefresh (
- IN BOOLEAN EditorFirst,
- IN UINTN LastRow,
- IN UINTN LastCol,
- IN UINTN FileRow,
- IN UINTN FileCol,
- IN BOOLEAN InsertMode
- )
-{
- STATUS_BAR_COLOR_UNION Orig;
- STATUS_BAR_COLOR_UNION New;
-
- if (!StatusStringChanged && StatusBarNeedRefresh) {
- StatusBarSetStatusString (L"\0");
- }
- //
- // when it's called first time after editor launch, so refresh is mandatory
- //
- if (!StatusBarNeedRefresh && !StatusStringChanged) {
- return EFI_SUCCESS;
- }
-
- //
- // back up the screen attributes
- //
- Orig.Data = gST->ConOut->Mode->Attribute;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background & 0xF;
- New.Colors.Background = Orig.Colors.Foreground & 0x7;
-
- gST->ConOut->EnableCursor (gST->ConOut, FALSE);
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
-
- //
- // clear status bar
- //
- EditorClearLine (LastRow, LastCol, LastRow);
-
- //
- // print row, column fields
- //
- if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) {
- ShellPrintEx (
- 0,
- (INT32)(LastRow) - 1,
- L" %d,%d %s",
- FileRow,
- FileCol,
- StatusString
- );
- } else {
- ShellPrintEx (
- 0,
- (INT32)(LastRow) - 1,
- L" %s",
- StatusString
- );
- }
-
- //
- // print insert mode field
- //
- if (InsertMode) {
- ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"INS");
- } else {
- ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
- }
- //
- // restore the old screen attributes
- //
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
-
- //
- // restore position in edit area
- //
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- StatusBarNeedRefresh = FALSE;
- StatusStringChanged = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the status string text part.
-
- @param[in] Str The string to use.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-StatusBarSetStatusString (
- IN CHAR16 *Str
- )
-{
- StatusStringChanged = TRUE;
-
- //
- // free the old status string
- //
- SHELL_FREE_NON_NULL (StatusString);
- StatusString = CatSPrint (NULL, L"%s", Str);
- if (StatusString == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to retrieve the current status string.
-
- @return The string that is used.
-**/
-CONST CHAR16*
-EFIAPI
-StatusBarGetString (
- VOID
- )
-{
- return (StatusString);
-}
-
-/**
- Function to set the need refresh boolean to TRUE.
-**/
-VOID
-EFIAPI
-StatusBarSetRefresh(
- VOID
- )
-{
- StatusBarNeedRefresh = TRUE;
-}
-
-/**
- Function to get the need refresh boolean to TRUE.
-
- @retval TRUE The status bar needs to be refreshed.
-**/
-BOOLEAN
-EFIAPI
-StatusBarGetRefresh(
- VOID
- )
-{
- return (StatusBarNeedRefresh);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.h
deleted file mode 100644
index debf83a9ec..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file
- Declares statusbar interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_STATUS_BAR_H_
-#define _LIB_STATUS_BAR_H_
-
-/**
- Initialization function for Status Bar.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @sa StatusBarSetStatusString
-**/
-EFI_STATUS
-EFIAPI
-StatusBarInit (
- VOID
- );
-
-/**
- Cleanup function for the status bar.
-**/
-VOID
-EFIAPI
-StatusBarCleanup (
- VOID
- );
-
-/**
- Cause the status bar to refresh it's printing on the screen.
-
- @param[in] EditorFirst TRUE to indicate the first launch of the editor.
- FALSE otherwise.
- @param[in] LastRow LastPrintable row.
- @param[in] LastCol Last printable column.
- @param[in] FileRow Row in the file.
- @param[in] FileCol Column in the file.
- @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-StatusBarRefresh (
- IN BOOLEAN EditorFirst,
- IN UINTN LastRow,
- IN UINTN LastCol,
- IN UINTN FileRow,
- IN UINTN FileCol,
- IN BOOLEAN InsertMode
- );
-
-/**
- Set the status string text part.
-
- @param[in] Str The string to use.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-StatusBarSetStatusString (
- IN CHAR16 *Str
- );
-
-/**
- Function to retrieve the current status string.
-
- @return The string that is used.
-**/
-CONST CHAR16*
-EFIAPI
-StatusBarGetString (
- VOID
- );
-
-/**
- Function to set the need refresh boolean to TRUE.
-**/
-VOID
-EFIAPI
-StatusBarSetRefresh(
- VOID
- );
-
-/**
- Function to get the need refresh boolean to TRUE.
-
- @retval TRUE The status bar needs to be refreshed.
-**/
-BOOLEAN
-EFIAPI
-StatusBarGetRefresh(
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c
deleted file mode 100644
index a0d7cad1e5..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/** @file
- Implements titlebar interface functions.
-
- (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "EditTitleBar.h"
-#include "UefiShellDebug1CommandsLib.h"
-
-CHAR16 *Title = NULL;
-
-/**
- Initialize a title bar.
-
- @param[in] Prompt The prompt to print in the title bar.
-
- @retval EFI_SUCCESS The initialization was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MainTitleBarInit (
- CONST CHAR16 *Prompt
- )
-{
- SHELL_FREE_NON_NULL (Title);
- if (Prompt == NULL) {
- Title = CatSPrint (NULL, L"");
- } else {
- //
- // set Title
- //
- Title = CatSPrint (NULL, L"%s", Prompt);
- }
- if (Title == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Clean up the memory used.
-**/
-VOID
-EFIAPI
-MainTitleBarCleanup (
- VOID
- )
-{
- SHELL_FREE_NON_NULL (Title);
- Title = NULL;
-}
-
-typedef struct {
- UINT32 Foreground : 4;
- UINT32 Background : 4;
-} TITLE_BAR_COLOR_ATTRIBUTES;
-
-typedef union {
- TITLE_BAR_COLOR_ATTRIBUTES Colors;
- UINTN Data;
-} TITLE_BAR_COLOR_UNION;
-
-/**
- Refresh function for MainTitleBar
-
- @param[in] FileName The open file's name (or NULL).
- @param[in] FileType The type fo the file.
- @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
- @param[in] Modified TRUE if the file was modified. FALSE otherwise.
- @param[in] LastCol The last printable column.
- @param[in] LastRow The last printable row.
- @param[in] Offset The offset into the file. (only for mem/disk)
- @param[in] Size The file's size. (only for mem/disk)
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-MainTitleBarRefresh (
- IN CONST CHAR16 *FileName OPTIONAL,
- IN CONST EDIT_FILE_TYPE FileType,
- IN CONST BOOLEAN ReadOnly,
- IN CONST BOOLEAN Modified,
- IN CONST UINTN LastCol,
- IN CONST UINTN LastRow,
- IN CONST UINTN Offset,
- IN CONST UINTN Size
- )
-{
- TITLE_BAR_COLOR_UNION Orig;
- TITLE_BAR_COLOR_UNION New;
- CONST CHAR16 *FileNameTmp;
- INTN TempInteger;
-
-
- //
- // backup the old screen attributes
- //
- Orig.Data = gST->ConOut->Mode->Attribute;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background & 0xF;
- New.Colors.Background = Orig.Colors.Foreground & 0x7;
-
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
-
- //
- // clear the title line
- //
- EditorClearLine (1, LastCol, LastRow);
-
- if (Title != NULL) {
- //
- // print the new title bar prefix
- //
- ShellPrintEx (
- 0,
- 0,
- L"%s ",
- Title
- );
- }
- if (FileName == NULL) {
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- return EFI_SUCCESS;
- }
- //
- // First Extract the FileName from fullpath
- //
- FileNameTmp = FileName;
- for (TempInteger = StrLen (FileNameTmp) - 1; TempInteger >= 0; TempInteger--) {
- if (FileNameTmp[TempInteger] == L'\\') {
- break;
- }
- }
-
- FileNameTmp = FileNameTmp + TempInteger + 1;
-
- //
- // the space for file name is 20 characters
- //
- if (StrLen (FileNameTmp) <= 20) {
- ShellPrintEx (-1,-1, L"%s ", FileNameTmp);
- for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) {
- ShellPrintEx (-1,-1, L" ");
- }
-
- } else {
- for (TempInteger = 0; TempInteger < 17; TempInteger++) {
- ShellPrintEx (-1,-1, L"%c", FileNameTmp[TempInteger]);
- }
- //
- // print "..."
- //
- ShellPrintEx (-1,-1, L"... ");
- }
- //
- // print file type field
- //
- switch (FileType){
- case FileTypeAscii:
- case FileTypeUnicode:
- if (FileType == FileTypeAscii){
- ShellPrintEx (-1,-1, L" ASCII ");
- } else {
- ShellPrintEx (-1,-1, L" UNICODE ");
- }
- //
- // print read-only field for text files
- //
- if (ReadOnly) {
- ShellPrintEx (-1,-1, L"ReadOnly ");
- } else {
- ShellPrintEx (-1,-1, L" ");
- }
- break;
- case FileTypeDiskBuffer:
- case FileTypeMemBuffer:
- //
- // Print the offset.
- //
- ShellPrintEx (-1,-1, L"Offset %X | Size %X", Offset, Size);
- case FileTypeFileBuffer:
- break;
- default:
- break;
- }
- //
- // print modified field
- //
- if (Modified) {
- ShellPrintEx (-1,-1, L"Modified");
- }
- //
- // restore the old attribute
- //
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
-
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.h
deleted file mode 100644
index d8f420fb80..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
- Declares titlebar interface functions.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_TITLE_BAR_H_
-#define _LIB_TITLE_BAR_H_
-
-/**
- Initialize a title bar.
-
- @param[in] Prompt The prompt to print in the title bar.
-
- @retval EFI_SUCCESS The initialization was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MainTitleBarInit (
- CONST CHAR16 *Prompt
- );
-
-/**
- Clean up the memory used.
-**/
-VOID
-EFIAPI
-MainTitleBarCleanup (
- VOID
- );
-
-typedef enum {
- FileTypeNone,
- FileTypeAscii,
- FileTypeUnicode,
- FileTypeDiskBuffer,
- FileTypeMemBuffer,
- FileTypeFileBuffer
-} EDIT_FILE_TYPE;
-
-/**
- Refresh function for MainTitleBar
-
- @param[in] FileName The open file's name (or NULL).
- @param[in] FileType The type fo the file.
- @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
- @param[in] Modified TRUE if the file was modified. FALSE otherwise.
- @param[in] LastCol The last printable column.
- @param[in] LastRow The last printable row.
- @param[in] Offset The offset into the file. (only for mem/disk)
- @param[in] Size The file's size. (only for mem/disk)
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-MainTitleBarRefresh (
- IN CONST CHAR16 *FileName OPTIONAL,
- IN CONST EDIT_FILE_TYPE FileType,
- IN CONST BOOLEAN ReadOnly,
- IN CONST BOOLEAN Modified,
- IN CONST UINTN LastCol,
- IN CONST UINTN LastRow,
- IN CONST UINTN Offset,
- IN CONST UINTN Size
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c
deleted file mode 100644
index 85ae732521..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/** @file
- Main file for EfiCompress shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include "Compress.h"
-
-/**
- Function for 'compress' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEfiCompress (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- SHELL_FILE_HANDLE InShellFileHandle;
- SHELL_FILE_HANDLE OutShellFileHandle;
- UINT64 OutSize;
- UINTN OutSize2;
- VOID *OutBuffer;
- UINT64 InSize;
- UINTN InSize2;
- VOID *InBuffer;
- CHAR16 *InFileName;
- CONST CHAR16 *OutFileName;
- CONST CHAR16 *TempParam;
-
- InFileName = NULL;
- OutFileName = NULL;
- OutSize = 0;
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- OutBuffer = NULL;
- InShellFileHandle = NULL;
- OutShellFileHandle = NULL;
- InBuffer = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"eficompress", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"eficompress");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TempParam = ShellCommandLineGetRawValue(Package, 1);
- ASSERT(TempParam != NULL);
- InFileName = ShellFindFilePath(TempParam);
- OutFileName = ShellCommandLineGetRawValue(Package, 2);
- if (InFileName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_NOT_FOUND;
- }
- Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 2));
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize);
- ASSERT_EFI_ERROR(Status);
- InBuffer = AllocateZeroPool((UINTN)InSize);
- ASSERT(InBuffer != NULL);
- InSize2 = (UINTN)InSize;
- Status = gEfiShellProtocol->ReadFile(InShellFileHandle, &InSize2, InBuffer);
- InSize = InSize2;
- ASSERT_EFI_ERROR(Status);
- Status = Compress(InBuffer, InSize, OutBuffer, &OutSize);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- OutBuffer = AllocateZeroPool((UINTN)OutSize);
- ASSERT(OutBuffer != NULL);
- Status = Compress(InBuffer, InSize, OutBuffer, &OutSize);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- } else {
- OutSize2 = (UINTN)OutSize;
- Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &OutSize2, OutBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"eficompress", OutFileName);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- if (InShellFileHandle != NULL) {
- gEfiShellProtocol->CloseFile(InShellFileHandle);
- }
- if (OutShellFileHandle != NULL) {
- gEfiShellProtocol->CloseFile(OutShellFileHandle);
- }
- SHELL_FREE_NON_NULL(InFileName);
- SHELL_FREE_NON_NULL(InBuffer);
- SHELL_FREE_NON_NULL(OutBuffer);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c
deleted file mode 100644
index c1457430d8..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/** @file
- Main file for EfiDecompress shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Protocol/Decompress.h>
-
-
-/**
- Function for 'decompress' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEfiDecompress (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- SHELL_FILE_HANDLE InFileHandle;
- SHELL_FILE_HANDLE OutFileHandle;
- UINT32 OutSize;
- UINTN OutSizeTemp;
- VOID *OutBuffer;
- UINTN InSize;
- VOID *InBuffer;
- CHAR16 *InFileName;
- CONST CHAR16 *OutFileName;
- UINT64 Temp64Bit;
- UINT32 ScratchSize;
- VOID *ScratchBuffer;
- EFI_DECOMPRESS_PROTOCOL *Decompress;
- CONST CHAR16 *TempParam;
-
- InFileName = NULL;
- OutFileName = NULL;
- OutSize = 0;
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- OutBuffer = NULL;
- InBuffer = NULL;
- ScratchBuffer = NULL;
- InFileHandle = NULL;
- OutFileHandle = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"efidecompress", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"efidecompress");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"efidecompress");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TempParam = ShellCommandLineGetRawValue(Package, 1);
- ASSERT(TempParam != NULL);
- InFileName = ShellFindFilePath(TempParam);
- OutFileName = ShellCommandLineGetRawValue(Package, 2);
- if (InFileName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"efidecompress", TempParam);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", InFileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"efidecompress", OutFileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"efidecompress", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- Status = FileHandleGetSize(InFileHandle, &Temp64Bit);
- ASSERT(Temp64Bit <= (UINT32)(-1));
- InSize = (UINTN)Temp64Bit;
- ASSERT_EFI_ERROR(Status);
- InBuffer = AllocateZeroPool(InSize);
- ASSERT(InBuffer != NULL);
- Status = gEfiShellProtocol->ReadFile(InFileHandle, &InSize, InBuffer);
- ASSERT_EFI_ERROR(Status);
-
- Status = gBS->LocateProtocol(&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
- ASSERT_EFI_ERROR(Status);
-
- Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize);
- if (EFI_ERROR(Status) || OutSize == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_NOPE), gShellDebug1HiiHandle, InFileName);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- OutBuffer = AllocateZeroPool(OutSize);
- ScratchBuffer = AllocateZeroPool(ScratchSize);
- ASSERT(OutBuffer != NULL);
- ASSERT(ScratchBuffer != NULL);
-
- Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize);
- ASSERT_EFI_ERROR(Status);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- } else {
- OutSizeTemp = OutSize;
- Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer);
- OutSize = (UINT32)OutSizeTemp;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, L"efidecompress", OutFileName, Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- }
- }
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- if (InFileHandle != NULL) {
- gEfiShellProtocol->CloseFile(InFileHandle);
- }
- if (OutFileHandle != NULL) {
- gEfiShellProtocol->CloseFile(OutFileHandle);
- }
-
- SHELL_FREE_NON_NULL(InFileName);
- SHELL_FREE_NON_NULL(InBuffer);
- SHELL_FREE_NON_NULL(OutBuffer);
- SHELL_FREE_NON_NULL(ScratchBuffer);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
deleted file mode 100644
index 777c2e0199..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
+++ /dev/null
@@ -1,2484 +0,0 @@
-/** @file
- Defines HBufferImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-
-extern EFI_HANDLE HImageHandleBackup;
-
-extern HEFI_EDITOR_FILE_IMAGE HFileImage;
-extern HEFI_EDITOR_DISK_IMAGE HDiskImage;
-extern HEFI_EDITOR_MEM_IMAGE HMemImage;
-
-extern HEFI_EDITOR_FILE_IMAGE HFileImageBackupVar;
-extern HEFI_EDITOR_DISK_IMAGE HDiskImageBackupVar;
-extern HEFI_EDITOR_MEM_IMAGE HMemImageBackupVar;
-
-extern BOOLEAN HEditorMouseAction;
-
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditorBackupVar;
-
-HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
-HEFI_EDITOR_BUFFER_IMAGE HBufferImageBackupVar;
-
-//
-// for basic initialization of HBufferImage
-//
-HEFI_EDITOR_BUFFER_IMAGE HBufferImageConst = {
- NULL,
- NULL,
- 0,
- NULL,
- {
- 0,
- 0
- },
- {
- 0,
- 0
- },
- {
- 0,
- 0
- },
- 0,
- TRUE,
- FALSE,
- FileTypeNone,
- NULL,
- NULL,
- NULL
-};
-
-//
-// the whole edit area needs to be refreshed
-//
-BOOLEAN HBufferImageNeedRefresh;
-
-//
-// only the current line in edit area needs to be refresh
-//
-BOOLEAN HBufferImageOnlyLineNeedRefresh;
-
-BOOLEAN HBufferImageMouseNeedRefresh;
-
-/**
- Initialization function for HBufferImage
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HBufferImageInit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // basically initialize the HBufferImage
- //
- CopyMem (&HBufferImage, &HBufferImageConst, sizeof (HBufferImage));
-
- //
- // INIT listhead
- //
- HBufferImage.ListHead = AllocateZeroPool (sizeof (LIST_ENTRY));
- if (HBufferImage.ListHead == NULL) {
- return EFI_LOAD_ERROR;
- }
-
- InitializeListHead (HBufferImage.ListHead);
-
- HBufferImage.DisplayPosition.Row = 2;
- HBufferImage.DisplayPosition.Column = 10;
- HBufferImage.MousePosition.Row = 2;
- HBufferImage.MousePosition.Column = 10;
-
- HBufferImage.FileImage = &HFileImage;
- HBufferImage.DiskImage = &HDiskImage;
- HBufferImage.MemImage = &HMemImage;
-
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageMouseNeedRefresh = FALSE;
-
- HBufferImageBackupVar.FileImage = &HFileImageBackupVar;
- HBufferImageBackupVar.DiskImage = &HDiskImageBackupVar;
- HBufferImageBackupVar.MemImage = &HMemImageBackupVar;
-
- Status = HFileImageInit ();
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
-
- Status = HDiskImageInit ();
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
-
- Status = HMemImageInit ();
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Backup function for HBufferImage. Only a few fields need to be backup.
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageBackup (
- VOID
- )
-{
- HBufferImageBackupVar.MousePosition = HBufferImage.MousePosition;
-
- HBufferImageBackupVar.BufferPosition = HBufferImage.BufferPosition;
-
- HBufferImageBackupVar.Modified = HBufferImage.Modified;
-
- HBufferImageBackupVar.BufferType = HBufferImage.BufferType;
- HBufferImageBackupVar.LowVisibleRow = HBufferImage.LowVisibleRow;
- HBufferImageBackupVar.HighBits = HBufferImage.HighBits;
-
- //
- // three kinds of buffer supported
- // file buffer
- // disk buffer
- // memory buffer
- //
- switch (HBufferImage.BufferType) {
- case FileTypeFileBuffer:
- HFileImageBackup ();
- break;
-
- case FileTypeDiskBuffer:
- HDiskImageBackup ();
- break;
-
- case FileTypeMemBuffer:
- HMemImageBackup ();
- break;
-
- default:
- break;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Free all the lines in HBufferImage.
- Fields affected:
- Lines
- CurrentLine
- NumLines
- ListHead
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageFreeLines (
- VOID
- )
-{
- HFreeLines (HBufferImage.ListHead, HBufferImage.Lines);
-
- HBufferImage.Lines = NULL;
- HBufferImage.CurrentLine = NULL;
- HBufferImage.NumLines = 0;
-
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup function for HBufferImage
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageCleanup (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // free all the lines
- //
- Status = HBufferImageFreeLines ();
-
- SHELL_FREE_NON_NULL (HBufferImage.ListHead);
- HBufferImage.ListHead = NULL;
-
- HFileImageCleanup ();
- HDiskImageCleanup ();
-
- return Status;
-
-}
-
-/**
- Print Line on Row
-
- @param[in] Line The lline to print.
- @param[in] Row The row on screen ( begin from 1 ).
- @param[in] FRow The FRow.
- @param[in] Orig The original color.
- @param[in] New The color to print with.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImagePrintLine (
- IN HEFI_EDITOR_LINE *Line,
- IN UINTN Row,
- IN UINTN FRow,
- IN HEFI_EDITOR_COLOR_UNION Orig,
- IN HEFI_EDITOR_COLOR_UNION New
-
- )
-{
-
- UINTN Index;
- UINTN Pos;
- BOOLEAN Selected;
- BOOLEAN BeNewColor;
- UINTN RowStart;
- UINTN RowEnd;
- UINTN ColStart;
- UINTN ColEnd;
-
- //
- // variable initialization
- //
- ColStart = 0;
- ColEnd = 0;
- Selected = FALSE;
-
- //
- // print the selected area in opposite color
- //
- if (HMainEditor.SelectStart != 0 && HMainEditor.SelectEnd != 0) {
- RowStart = (HMainEditor.SelectStart - 1) / 0x10 + 1;
- RowEnd = (HMainEditor.SelectEnd - 1) / 0x10 + 1;
-
- ColStart = (HMainEditor.SelectStart - 1) % 0x10 + 1;
- ColEnd = (HMainEditor.SelectEnd - 1) % 0x10 + 1;
-
- if (FRow >= RowStart && FRow <= RowEnd) {
- Selected = TRUE;
- }
-
- if (FRow > RowStart) {
- ColStart = 1;
- }
-
- if (FRow < RowEnd) {
- ColEnd = 0x10;
- }
-
- }
-
- if (!HEditorMouseAction) {
- ShellPrintEx (
- 0,
- (INT32)Row - 1,
- L"%8X ",
- ((INT32)Row - 2 + HBufferImage.LowVisibleRow - 1) * 0x10
- );
-
- }
-
- for (Index = 0; Index < 0x08 && Index < Line->Size; Index++) {
-
- BeNewColor = FALSE;
-
- if (Selected) {
- if (Index + 1 >= ColStart && Index + 1 <= ColEnd) {
- BeNewColor = TRUE;
- }
- }
-
- if (BeNewColor) {
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
- }
-
- Pos = 10 + (Index * 3);
- if (Line->Buffer[Index] < 0x10) {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"0");
- Pos++;
- }
-
- if (Index < 0x07) {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%x ", Line->Buffer[Index]);
- } else {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%x ", Line->Buffer[Index]);
- }
-
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
- while (Index < 0x08) {
- Pos = 10 + (Index * 3);
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- Index++;
- }
-
- while (Index < 0x10 && Index < Line->Size) {
-
- BeNewColor = FALSE;
-
- if (Selected) {
- if (Index + 1 >= ColStart && Index + 1 <= ColEnd) {
- BeNewColor = TRUE;
- }
- }
-
- if (BeNewColor) {
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
- }
-
- Pos = 10 + (Index * 3) + 1;
- if (Line->Buffer[Index] < 0x10) {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"0");
- Pos++;
- }
-
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%x ", Line->Buffer[Index]);
- Index++;
- }
-
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
- while (Index < 0x10) {
- Pos = 10 + (Index * 3) + 1;
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- Index++;
- }
- //
- // restore the original color
- //
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);
-
- //
- // PRINT the buffer content
- //
- if (!HEditorMouseAction) {
- for (Index = 0; Index < 0x10 && Index < Line->Size; Index++) {
- Pos = ASCII_POSITION + Index;
-
- //
- // learned from shelle.h -- IsValidChar
- //
- if (Line->Buffer[Index] >= L' ') {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%c", (CHAR16) Line->Buffer[Index]);
- } else {
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"%c", '.');
- }
- }
-
- while (Index < 0x10) {
- Pos = ASCII_POSITION + Index;
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- Index++;
- }
- }
- //
- // restore the abundant blank in hex edit area to original color
- //
- if (Selected) {
- if (ColEnd <= 7) {
- Pos = 10 + (ColEnd - 1) * 3 + 2;
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- } else if (ColEnd == 8) {
- Pos = 10 + (ColEnd - 1) * 3 + 2;
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- } else {
- Pos = 10 + (ColEnd - 1) * 3 + 3;
- ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L" ");
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to decide if a column number is stored in the high bits.
-
- @param[in] Column The column to examine.
- @param[out] FCol The actual column number.
-
- @retval TRUE The actual column was in high bits and is now in FCol.
- @retval FALSE There was not a column number in the high bits.
-**/
-BOOLEAN
-HBufferImageIsAtHighBits (
- IN UINTN Column,
- OUT UINTN *FCol
- )
-{
- Column -= 10;
-
- //
- // NOW AFTER THE SUB, Column start from 0
- // 23 AND 24 ARE BOTH BLANK
- //
- if (Column == 24) {
- *FCol = 0;
- return FALSE;
- }
-
- if (Column > 24) {
- Column--;
- }
-
- *FCol = (Column / 3) + 1;
-
- if (Column % 3 == 0) {
- return TRUE;
- }
-
- if ((Column % 3 == 2)) {
- *FCol = 0;
- }
-
- return FALSE;
-}
-
-/**
- Decide if a point is in the already selected area.
-
- @param[in] MouseRow The row of the point to test.
- @param[in] MouseCol The col of the point to test.
-
- @retval TRUE The point is in the selected area.
- @retval FALSE The point is not in the selected area.
-**/
-BOOLEAN
-HBufferImageIsInSelectedArea (
- IN UINTN MouseRow,
- IN UINTN MouseCol
- )
-{
- UINTN FRow;
- UINTN RowStart;
- UINTN RowEnd;
- UINTN ColStart;
- UINTN ColEnd;
- UINTN MouseColStart;
- UINTN MouseColEnd;
-
- //
- // judge mouse position whether is in selected area
- //
- //
- // not select
- //
- if (HMainEditor.SelectStart == 0 || HMainEditor.SelectEnd == 0) {
- return FALSE;
- }
- //
- // calculate the select area
- //
- RowStart = (HMainEditor.SelectStart - 1) / 0x10 + 1;
- RowEnd = (HMainEditor.SelectEnd - 1) / 0x10 + 1;
-
- ColStart = (HMainEditor.SelectStart - 1) % 0x10 + 1;
- ColEnd = (HMainEditor.SelectEnd - 1) % 0x10 + 1;
-
- FRow = HBufferImage.LowVisibleRow + MouseRow - 2;
- if (FRow < RowStart || FRow > RowEnd) {
- return FALSE;
- }
-
- if (FRow > RowStart) {
- ColStart = 1;
- }
-
- if (FRow < RowEnd) {
- ColEnd = 0x10;
- }
-
- MouseColStart = 10 + (ColStart - 1) * 3;
- if (ColStart > 8) {
- MouseColStart++;
- }
-
- MouseColEnd = 10 + (ColEnd - 1) * 3 + 1;
- if (ColEnd > 8) {
- MouseColEnd++;
- }
-
- if (MouseCol < MouseColStart || MouseCol > MouseColEnd) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- Set mouse position according to HBufferImage.MousePosition.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageRestoreMousePosition (
- VOID
- )
-{
- HEFI_EDITOR_COLOR_UNION Orig;
- HEFI_EDITOR_COLOR_UNION New;
- UINTN FRow;
- UINTN FColumn;
- BOOLEAN HasCharacter;
- HEFI_EDITOR_LINE *CurrentLine;
- HEFI_EDITOR_LINE *Line;
- UINT8 Value;
- BOOLEAN HighBits;
-
- Line = NULL;
- if (HMainEditor.MouseSupported) {
-
- if (HBufferImageMouseNeedRefresh) {
-
- HBufferImageMouseNeedRefresh = FALSE;
-
- //
- // if mouse position not moved and only mouse action
- // so do not need to refresh mouse position
- //
- if ((
- HBufferImage.MousePosition.Row == HBufferImageBackupVar.MousePosition.Row &&
- HBufferImage.MousePosition.Column == HBufferImageBackupVar.MousePosition.Column
- ) &&
- HEditorMouseAction
- ) {
- return EFI_SUCCESS;
- }
- //
- // backup the old screen attributes
- //
- Orig = HMainEditor.ColorAttributes;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background & 0xF;
- New.Colors.Background = Orig.Colors.Foreground & 0x7;
-
- //
- // if in selected area,
- // so do not need to refresh mouse
- //
- if (!HBufferImageIsInSelectedArea (
- HBufferImageBackupVar.MousePosition.Row,
- HBufferImageBackupVar.MousePosition.Column
- )) {
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
- }
- //
- // clear the old mouse position
- //
- FRow = HBufferImage.LowVisibleRow + HBufferImageBackupVar.MousePosition.Row - 2;
-
- HighBits = HBufferImageIsAtHighBits (
- HBufferImageBackupVar.MousePosition.Column,
- &FColumn
- );
-
- HasCharacter = TRUE;
- if (FRow > HBufferImage.NumLines || FColumn == 0) {
- HasCharacter = FALSE;
- } else {
- CurrentLine = HBufferImage.CurrentLine;
- Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);
-
- if (Line == NULL || FColumn > Line->Size) {
- HasCharacter = FALSE;
- }
-
- HBufferImage.CurrentLine = CurrentLine;
- }
-
- ShellPrintEx (
- (INT32)HBufferImageBackupVar.MousePosition.Column - 1,
- (INT32)HBufferImageBackupVar.MousePosition.Row - 1,
- L" "
- );
-
- if (HasCharacter) {
- if (HighBits) {
- Value = (UINT8) (Line->Buffer[FColumn - 1] & 0xf0);
- Value = (UINT8) (Value >> 4);
- } else {
- Value = (UINT8) (Line->Buffer[FColumn - 1] & 0xf);
- }
-
- ShellPrintEx (
- (INT32)HBufferImageBackupVar.MousePosition.Column - 1,
- (INT32)HBufferImageBackupVar.MousePosition.Row - 1,
- L"%x",
- Value
- );
- }
-
- if (!HBufferImageIsInSelectedArea (
- HBufferImage.MousePosition.Row,
- HBufferImage.MousePosition.Column
- )) {
- gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- }
- //
- // clear the old mouse position
- //
- FRow = HBufferImage.LowVisibleRow + HBufferImage.MousePosition.Row - 2;
-
- HighBits = HBufferImageIsAtHighBits (
- HBufferImage.MousePosition.Column,
- &FColumn
- );
-
- HasCharacter = TRUE;
- if (FRow > HBufferImage.NumLines || FColumn == 0) {
- HasCharacter = FALSE;
- } else {
- CurrentLine = HBufferImage.CurrentLine;
- Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);
-
- if (Line == NULL || FColumn > Line->Size) {
- HasCharacter = FALSE;
- }
-
- HBufferImage.CurrentLine = CurrentLine;
- }
-
- ShellPrintEx (
- (INT32)HBufferImage.MousePosition.Column - 1,
- (INT32)HBufferImage.MousePosition.Row - 1,
- L" "
- );
-
- if (HasCharacter) {
- if (HighBits) {
- Value = (UINT8) (Line->Buffer[FColumn - 1] & 0xf0);
- Value = (UINT8) (Value >> 4);
- } else {
- Value = (UINT8) (Line->Buffer[FColumn - 1] & 0xf);
- }
-
- ShellPrintEx (
- (INT32)HBufferImage.MousePosition.Column - 1,
- (INT32)HBufferImage.MousePosition.Row - 1,
- L"%x",
- Value
- );
- }
- //
- // end of HasCharacter
- //
- gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
- }
- //
- // end of MouseNeedRefresh
- //
- }
- //
- // end of MouseSupported
- //
- return EFI_SUCCESS;
-}
-
-/**
- Set cursor position according to HBufferImage.DisplayPosition.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageRestorePosition (
- VOID
- )
-{
- //
- // set cursor position
- //
- gST->ConOut->SetCursorPosition (
- gST->ConOut,
- HBufferImage.DisplayPosition.Column - 1,
- HBufferImage.DisplayPosition.Row - 1
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Refresh function for HBufferImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A Load error occured.
-
-**/
-EFI_STATUS
-HBufferImageRefresh (
- VOID
- )
-{
- LIST_ENTRY *Link;
- HEFI_EDITOR_LINE *Line;
- UINTN Row;
- HEFI_EDITOR_COLOR_UNION Orig;
- HEFI_EDITOR_COLOR_UNION New;
-
- UINTN StartRow;
- UINTN EndRow;
- UINTN FStartRow;
- UINTN Tmp;
-
- Orig = HMainEditor.ColorAttributes;
- New.Data = 0;
- New.Colors.Foreground = Orig.Colors.Background;
- New.Colors.Background = Orig.Colors.Foreground;
-
- //
- // if it's the first time after editor launch, so should refresh
- //
- if (HEditorFirst == FALSE) {
- //
- // no definite required refresh
- // and file position displayed on screen has not been changed
- //
- if (!HBufferImageNeedRefresh &&
- !HBufferImageOnlyLineNeedRefresh &&
- HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow
- ) {
- HBufferImageRestoreMousePosition ();
- HBufferImageRestorePosition ();
- return EFI_SUCCESS;
- }
- }
-
- gST->ConOut->EnableCursor (gST->ConOut, FALSE);
-
- //
- // only need to refresh current line
- //
- if (HBufferImageOnlyLineNeedRefresh && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {
-
- HBufferImagePrintLine (
- HBufferImage.CurrentLine,
- HBufferImage.DisplayPosition.Row,
- HBufferImage.BufferPosition.Row,
- Orig,
- New
- );
- } else {
- //
- // the whole edit area need refresh
- //
- if (HEditorMouseAction && HMainEditor.SelectStart != 0 && HMainEditor.SelectEnd != 0) {
- if (HMainEditor.SelectStart != HMainEditorBackupVar.SelectStart) {
- if (HMainEditor.SelectStart >= HMainEditorBackupVar.SelectStart && HMainEditorBackupVar.SelectStart != 0) {
- StartRow = (HMainEditorBackupVar.SelectStart - 1) / 0x10 + 1;
- } else {
- StartRow = (HMainEditor.SelectStart - 1) / 0x10 + 1;
- }
- } else {
- StartRow = (HMainEditor.SelectStart - 1) / 0x10 + 1;
- }
-
- if (HMainEditor.SelectEnd <= HMainEditorBackupVar.SelectEnd) {
- EndRow = (HMainEditorBackupVar.SelectEnd - 1) / 0x10 + 1;
- } else {
- EndRow = (HMainEditor.SelectEnd - 1) / 0x10 + 1;
- }
- //
- // swap
- //
- if (StartRow > EndRow) {
- Tmp = StartRow;
- StartRow = EndRow;
- EndRow = Tmp;
- }
-
- FStartRow = StartRow;
-
- StartRow = 2 + StartRow - HBufferImage.LowVisibleRow;
- EndRow = 2 + EndRow - HBufferImage.LowVisibleRow;
-
- } else {
- //
- // not mouse selection actions
- //
- FStartRow = HBufferImage.LowVisibleRow;
- StartRow = 2;
- EndRow = (HMainEditor.ScreenSize.Row - 1);
- }
- //
- // no line
- //
- if (HBufferImage.Lines == NULL) {
- HBufferImageRestoreMousePosition ();
- HBufferImageRestorePosition ();
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- return EFI_SUCCESS;
- }
- //
- // get the first line that will be displayed
- //
- Line = HMoveLine (FStartRow - HBufferImage.BufferPosition.Row);
- if (Line == NULL) {
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- return EFI_LOAD_ERROR;
- }
-
- Link = &(Line->Link);
- Row = StartRow;
- do {
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- //
- // print line at row
- //
- HBufferImagePrintLine (
- Line,
- Row,
- HBufferImage.LowVisibleRow + Row - 2,
- Orig,
- New
- );
-
- Link = Link->ForwardLink;
- Row++;
- } while (Link != HBufferImage.ListHead && Row <= EndRow);
-
- while (Row <= EndRow) {
- EditorClearLine (Row, HMainEditor.ScreenSize.Column, HMainEditor.ScreenSize.Row);
- Row++;
- }
- //
- // while not file end and not screen full
- //
- }
-
- HBufferImageRestoreMousePosition ();
- HBufferImageRestorePosition ();
-
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Read an image into a buffer friom a source.
-
- @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
- @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] BufferType The type of buffer to save. IGNORED.
- @param[in] Recover TRUE for recovermode, FALSE otherwise.
-
- @return EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageRead (
- IN CONST CHAR16 *FileName,
- IN CONST CHAR16 *DiskName,
- IN UINTN DiskOffset,
- IN UINTN DiskSize,
- IN UINTN MemOffset,
- IN UINTN MemSize,
- IN EDIT_FILE_TYPE BufferType,
- IN BOOLEAN Recover
- )
-{
- EFI_STATUS Status;
- EDIT_FILE_TYPE BufferTypeBackup;
-
- //
- // variable initialization
- //
- Status = EFI_SUCCESS;
- HBufferImage.BufferType = BufferType;
-
- //
- // three types of buffer supported
- // file buffer
- // disk buffer
- // memory buffer
- //
- BufferTypeBackup = HBufferImage.BufferType;
-
- switch (BufferType) {
- case FileTypeFileBuffer:
- Status = HFileImageRead (FileName, Recover);
- break;
-
- case FileTypeDiskBuffer:
- Status = HDiskImageRead (DiskName, DiskOffset, DiskSize, Recover);
- break;
-
- case FileTypeMemBuffer:
- Status = HMemImageRead (MemOffset, MemSize, Recover);
- break;
-
- default:
- Status = EFI_NOT_FOUND;
- break;
- }
-
- if (EFI_ERROR (Status)) {
- HBufferImage.BufferType = BufferTypeBackup;
- }
-
- return Status;
-}
-
-/**
- Save the current image.
-
- @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
- @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] BufferType The type of buffer to save. IGNORED.
-
- @return EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageSave (
- IN CHAR16 *FileName,
- IN CHAR16 *DiskName,
- IN UINTN DiskOffset,
- IN UINTN DiskSize,
- IN UINTN MemOffset,
- IN UINTN MemSize,
- IN EDIT_FILE_TYPE BufferType
- )
-{
- EFI_STATUS Status;
- EDIT_FILE_TYPE BufferTypeBackup;
-
- //
- // variable initialization
- //
- Status = EFI_SUCCESS;
- BufferTypeBackup = HBufferImage.BufferType;
-
- switch (HBufferImage.BufferType) {
- //
- // file buffer
- //
- case FileTypeFileBuffer:
- Status = HFileImageSave (FileName);
- break;
-
- //
- // disk buffer
- //
- case FileTypeDiskBuffer:
- Status = HDiskImageSave (DiskName, DiskOffset, DiskSize);
- break;
-
- //
- // memory buffer
- //
- case FileTypeMemBuffer:
- Status = HMemImageSave (MemOffset, MemSize);
- break;
-
- default:
- Status = EFI_NOT_FOUND;
- break;
- }
-
- if (EFI_ERROR (Status)) {
- HBufferImage.BufferType = BufferTypeBackup;
- }
-
- return Status;
-}
-
-/**
- Create a new line and append it to the line list.
- Fields affected:
- NumLines
- Lines
-
- @retval NULL create line failed.
- @return the line created.
-
-**/
-HEFI_EDITOR_LINE *
-HBufferImageCreateLine (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
-
- //
- // allocate for line structure
- //
- Line = AllocateZeroPool (sizeof (HEFI_EDITOR_LINE));
- if (Line == NULL) {
- return NULL;
- }
-
- Line->Signature = EFI_EDITOR_LINE_LIST;
- Line->Size = 0;
-
- HBufferImage.NumLines++;
-
- //
- // insert to line list
- //
- InsertTailList (HBufferImage.ListHead, &Line->Link);
-
- if (HBufferImage.Lines == NULL) {
- HBufferImage.Lines = CR (
- HBufferImage.ListHead->ForwardLink,
- HEFI_EDITOR_LINE,
- Link,
- EFI_EDITOR_LINE_LIST
- );
- }
-
- return Line;
-}
-
-/**
- Free the current image.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageFree (
- VOID
- )
-{
- //
- // free all lines
- //
- HBufferImageFreeLines ();
-
- return EFI_SUCCESS;
-}
-
-/**
- change char to int value based on Hex.
-
- @param[in] Char The input char.
-
- @return The character's index value.
- @retval -1 The operation failed.
-**/
-INTN
-EFIAPI
-HBufferImageCharToHex (
- IN CHAR16 Char
- )
-{
- //
- // change the character to hex
- //
- if (Char >= L'0' && Char <= L'9') {
- return (INTN) (Char - L'0');
- }
-
- if (Char >= L'a' && Char <= L'f') {
- return (INTN) (Char - L'a' + 10);
- }
-
- if (Char >= L'A' && Char <= L'F') {
- return (INTN) (Char - L'A' + 10);
- }
-
- return -1;
-}
-
-/**
- Add character.
-
- @param[in] Char -- input char.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageAddChar (
- IN CHAR16 Char
- )
-{
- HEFI_EDITOR_LINE *Line;
- HEFI_EDITOR_LINE *NewLine;
- INTN Value;
- UINT8 Old;
- UINTN FRow;
- UINTN FCol;
- BOOLEAN High;
-
- Value = HBufferImageCharToHex (Char);
-
- //
- // invalid input
- //
- if (Value == -1) {
- return EFI_SUCCESS;
- }
-
- Line = HBufferImage.CurrentLine;
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
- High = HBufferImage.HighBits;
-
- //
- // only needs to refresh current line
- //
- HBufferImageOnlyLineNeedRefresh = TRUE;
-
- //
- // not a full line and beyond the last character
- //
- if (FCol > Line->Size) {
- //
- // cursor always at high 4 bits
- // and always put input to the low 4 bits
- //
- Line->Buffer[Line->Size] = (UINT8) Value;
- Line->Size++;
- High = FALSE;
- } else {
-
- Old = Line->Buffer[FCol - 1];
-
- //
- // always put the input to the low 4 bits
- //
- Old = (UINT8) (Old & 0x0f);
- Old = (UINT8) (Old << 4);
- Old = (UINT8) (Value + Old);
- Line->Buffer[FCol - 1] = Old;
-
- //
- // at the low 4 bits of the last character of a full line
- // so if no next line, need to create a new line
- //
- if (!High && FCol == 0x10) {
-
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageNeedRefresh = TRUE;
-
- if (Line->Link.ForwardLink == HBufferImage.ListHead) {
- //
- // last line
- //
- // create a new line
- //
- NewLine = HBufferImageCreateLine ();
- if (NewLine == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // end of NULL
- //
- }
- //
- // end of == ListHead
- //
- }
- //
- // end of == 0x10
- //
- // if already at end of this line, scroll it to the start of next line
- //
- if (FCol == 0x10 && !High) {
- //
- // definitely has next line
- //
- FRow++;
- FCol = 1;
- High = TRUE;
- } else {
- //
- // if not at end of this line, just move to next column
- //
- if (!High) {
- FCol++;
- }
-
- if (High) {
- High = FALSE;
- } else {
- High = TRUE;
- }
-
- }
- //
- // end of ==FALSE
- //
- }
- //
- // move cursor to right
- //
- HBufferImageMovePosition (FRow, FCol, High);
-
- if (!HBufferImage.Modified) {
- HBufferImage.Modified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Delete the previous character.
-
- @retval EFI_SUCCESS The operationw as successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageDoBackspace (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
-
- UINTN FileColumn;
- UINTN FPos;
- BOOLEAN LastLine;
-
- //
- // variable initialization
- //
- LastLine = FALSE;
-
- //
- // already the first character
- //
- if (HBufferImage.BufferPosition.Row == 1 && HBufferImage.BufferPosition.Column == 1) {
- return EFI_SUCCESS;
- }
-
- FPos = (HBufferImage.BufferPosition.Row - 1) * 0x10 + HBufferImage.BufferPosition.Column - 1;
-
- FileColumn = HBufferImage.BufferPosition.Column;
-
- Line = HBufferImage.CurrentLine;
- LastLine = FALSE;
- if (Line->Link.ForwardLink == HBufferImage.ListHead && FileColumn > 1) {
- LastLine = TRUE;
- }
-
- HBufferImageDeleteCharacterFromBuffer (FPos - 1, 1, NULL);
-
- //
- // if is the last line
- // then only this line need to be refreshed
- //
- if (LastLine) {
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = TRUE;
- } else {
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- }
-
- if (!HBufferImage.Modified) {
- HBufferImage.Modified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- ASCII key + Backspace + return.
-
- @param[in] Char The input char.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageDoCharInput (
- IN CHAR16 Char
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- switch (Char) {
- case 0:
- break;
-
- case 0x08:
- Status = HBufferImageDoBackspace ();
- break;
-
- case 0x09:
- case 0x0a:
- case 0x0d:
- //
- // Tabs, Returns are thought as nothing
- //
- break;
-
- default:
- //
- // DEAL WITH ASCII CHAR, filter out thing like ctrl+f
- //
- if (Char > 127 || Char < 32) {
- Status = StatusBarSetStatusString (L"Unknown Command");
- } else {
- Status = HBufferImageAddChar (Char);
- }
-
- break;
- }
-
- return Status;
-}
-
-/**
- Check user specified FileRow is above current screen.
-
- @param[in] FileRow Row of file position ( start from 1 ).
-
- @retval TRUE It is above the current screen.
- @retval FALSE It is not above the current screen.
-
-**/
-BOOLEAN
-HAboveCurrentScreen (
- IN UINTN FileRow
- )
-{
- if (FileRow < HBufferImage.LowVisibleRow) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Check user specified FileRow is under current screen.
-
- @param[in] FileRow Row of file position ( start from 1 ).
-
- @retval TRUE It is under the current screen.
- @retval FALSE It is not under the current screen.
-
-**/
-BOOLEAN
-HUnderCurrentScreen (
- IN UINTN FileRow
- )
-{
- if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 2) - 1) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- According to cursor's file position, adjust screen display.
-
- @param[in] NewFilePosRow Row of file position ( start from 1 ).
- @param[in] NewFilePosCol Column of file position ( start from 1 ).
- @param[in] HighBits Cursor will on high4 bits or low4 bits.
-**/
-VOID
-HBufferImageMovePosition (
- IN UINTN NewFilePosRow,
- IN UINTN NewFilePosCol,
- IN BOOLEAN HighBits
- )
-{
- INTN RowGap;
- UINTN Abs;
- BOOLEAN Above;
- BOOLEAN Under;
- UINTN NewDisplayCol;
-
- //
- // CALCULATE gap between current file position and new file position
- //
- RowGap = NewFilePosRow - HBufferImage.BufferPosition.Row;
-
- Under = HUnderCurrentScreen (NewFilePosRow);
- Above = HAboveCurrentScreen (NewFilePosRow);
-
- HBufferImage.HighBits = HighBits;
-
- //
- // if is below current screen
- //
- if (Under) {
- //
- // display row will be unchanged
- //
- HBufferImage.BufferPosition.Row = NewFilePosRow;
- } else {
- if (Above) {
- //
- // has enough above line, so display row unchanged
- // not has enough above lines, so the first line is
- // at the first display line
- //
- if (NewFilePosRow < (HBufferImage.DisplayPosition.Row - 2 + 1)) {
- HBufferImage.DisplayPosition.Row = NewFilePosRow + 2 - 1;
- }
-
- HBufferImage.BufferPosition.Row = NewFilePosRow;
- } else {
- //
- // in current screen
- //
- HBufferImage.BufferPosition.Row = NewFilePosRow;
- if (RowGap <= 0) {
- Abs = (UINTN)ABS(RowGap);
- HBufferImage.DisplayPosition.Row -= Abs;
- } else {
- HBufferImage.DisplayPosition.Row += RowGap;
- }
-
- }
- }
-
- HBufferImage.LowVisibleRow = HBufferImage.BufferPosition.Row - (HBufferImage.DisplayPosition.Row - 2);
-
- //
- // always in current screen
- //
- HBufferImage.BufferPosition.Column = NewFilePosCol;
-
- NewDisplayCol = 10 + (NewFilePosCol - 1) * 3;
- if (NewFilePosCol > 0x8) {
- NewDisplayCol++;
- }
-
- if (!HighBits) {
- NewDisplayCol++;
- }
-
- HBufferImage.DisplayPosition.Column = NewDisplayCol;
-
- //
- // let CurrentLine point to correct line;
- //
- HBufferImage.CurrentLine = HMoveCurrentLine (RowGap);
-
-}
-
-/**
- Scroll cursor to right.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageScrollRight (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- //
- // scroll right will always move to the high4 bits of the next character
- //
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
-
- //
- // this line is not full and no next line
- //
- if (FCol > Line->Size) {
- return EFI_SUCCESS;
- }
- //
- // if already at end of this line, scroll it to the start of next line
- //
- if (FCol == 0x10) {
- //
- // has next line
- //
- if (Line->Link.ForwardLink != HBufferImage.ListHead) {
- FRow++;
- FCol = 1;
-
- } else {
- return EFI_SUCCESS;
- }
- } else {
- //
- // if not at end of this line, just move to next column
- //
- FCol++;
-
- }
-
- HBufferImageMovePosition (FRow, FCol, TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to left.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageScrollLeft (
- VOID
- )
-{
-
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
-
- //
- // if already at start of this line, so move to the end of previous line
- //
- if (FCol <= 1) {
- //
- // has previous line
- //
- if (Line->Link.BackLink != HBufferImage.ListHead) {
- FRow--;
- Line = CR (Line->Link.BackLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- FCol = Line->Size;
- } else {
- return EFI_SUCCESS;
- }
- } else {
- //
- // if not at start of this line, just move to previous column
- //
- FCol--;
- }
-
- HBufferImageMovePosition (FRow, FCol, TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to the next line
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageScrollDown (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
- BOOLEAN HighBits;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
- HighBits = HBufferImage.HighBits;
-
- //
- // has next line
- //
- if (Line->Link.ForwardLink != HBufferImage.ListHead) {
- FRow++;
- Line = CR (Line->Link.ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- //
- // if the next line is not that long, so move to end of next line
- //
- if (FCol > Line->Size) {
- FCol = Line->Size + 1;
- HighBits = TRUE;
- }
-
- } else {
- return EFI_SUCCESS;
- }
-
- HBufferImageMovePosition (FRow, FCol, HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to previous line
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageScrollUp (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
-
- //
- // has previous line
- //
- if (Line->Link.BackLink != HBufferImage.ListHead) {
- FRow--;
-
- } else {
- return EFI_SUCCESS;
- }
-
- HBufferImageMovePosition (FRow, FCol, HBufferImage.HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to next page
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImagePageDown (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
- UINTN Gap;
- BOOLEAN HighBits;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
- HighBits = HBufferImage.HighBits;
-
- //
- // has next page
- //
- if (HBufferImage.NumLines >= FRow + (HMainEditor.ScreenSize.Row - 2)) {
- Gap = (HMainEditor.ScreenSize.Row - 2);
- } else {
- //
- // MOVE CURSOR TO LAST LINE
- //
- Gap = HBufferImage.NumLines - FRow;
- }
- //
- // get correct line
- //
- Line = HMoveLine (Gap);
-
- //
- // if that line, is not that long, so move to the end of that line
- //
- if (Line != NULL && FCol > Line->Size) {
- FCol = Line->Size + 1;
- HighBits = TRUE;
- }
-
- FRow += Gap;
-
- HBufferImageMovePosition (FRow, FCol, HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to previous page
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImagePageUp (
- VOID
- )
-{
- UINTN FRow;
- UINTN FCol;
- UINTN Gap;
- INTN Retreat;
-
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
-
- //
- // has previous page
- //
- if (FRow > (HMainEditor.ScreenSize.Row - 2)) {
- Gap = (HMainEditor.ScreenSize.Row - 2);
- } else {
- //
- // the first line of file will displayed on the first line of screen
- //
- Gap = FRow - 1;
- }
-
- Retreat = Gap;
- Retreat = -Retreat;
-
- FRow -= Gap;
-
- HBufferImageMovePosition (FRow, FCol, HBufferImage.HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to start of line
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageHome (
- VOID
- )
-{
- UINTN FRow;
- UINTN FCol;
- BOOLEAN HighBits;
-
- //
- // curosr will at the high bit
- //
- FRow = HBufferImage.BufferPosition.Row;
- FCol = 1;
- HighBits = TRUE;
-
- //
- // move cursor position
- //
- HBufferImageMovePosition (FRow, FCol, HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Scroll cursor to end of line.
-
- @retval EFI_SUCCESS Teh operation was successful.
-**/
-EFI_STATUS
-HBufferImageEnd (
- VOID
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN FRow;
- UINTN FCol;
- BOOLEAN HighBits;
-
- //
- // need refresh mouse
- //
- HBufferImageMouseNeedRefresh = TRUE;
-
- Line = HBufferImage.CurrentLine;
-
- FRow = HBufferImage.BufferPosition.Row;
-
- if (Line->Size == 0x10) {
- FCol = Line->Size;
- HighBits = FALSE;
- } else {
- FCol = Line->Size + 1;
- HighBits = TRUE;
- }
- //
- // move cursor position
- //
- HBufferImageMovePosition (FRow, FCol, HighBits);
-
- return EFI_SUCCESS;
-}
-
-/**
- Get the size of the open buffer.
-
- @retval The size in bytes.
-**/
-UINTN
-HBufferImageGetTotalSize (
- VOID
- )
-{
- UINTN Size;
-
- HEFI_EDITOR_LINE *Line;
-
- //
- // calculate the total size of whole line list's buffer
- //
- if (HBufferImage.Lines == NULL) {
- return 0;
- }
-
- Line = CR (
- HBufferImage.ListHead->BackLink,
- HEFI_EDITOR_LINE,
- Link,
- EFI_EDITOR_LINE_LIST
- );
- //
- // one line at most 0x10
- //
- Size = 0x10 * (HBufferImage.NumLines - 1) + Line->Size;
-
- return Size;
-}
-
-/**
- Delete character from buffer.
-
- @param[in] Pos Position, Pos starting from 0.
- @param[in] Count The Count of characters to delete.
- @param[out] DeleteBuffer The DeleteBuffer.
-
- @retval EFI_SUCCESS Success
-**/
-EFI_STATUS
-HBufferImageDeleteCharacterFromBuffer (
- IN UINTN Pos,
- IN UINTN Count,
- OUT UINT8 *DeleteBuffer
- )
-{
- UINTN Index;
-
- VOID *Buffer;
- UINT8 *BufferPtr;
- UINTN Size;
-
- HEFI_EDITOR_LINE *Line;
- LIST_ENTRY *Link;
-
- UINTN OldFCol;
- UINTN OldFRow;
- UINTN OldPos;
-
- UINTN NewPos;
-
- EFI_STATUS Status;
-
- Size = HBufferImageGetTotalSize ();
-
- if (Size < Count) {
- return EFI_LOAD_ERROR;
- }
-
- if (Size == 0) {
- return EFI_SUCCESS;
- }
-
- //
- // relocate all the HBufferImage fields
- //
- OldFRow = HBufferImage.BufferPosition.Row;
- OldFCol = HBufferImage.BufferPosition.Column;
- OldPos = (OldFRow - 1) * 0x10 + OldFCol - 1;
-
- if (Pos > 0) {
- //
- // has character before it,
- // so locate according to block's previous character
- //
- NewPos = Pos - 1;
-
- } else {
- //
- // has no character before it,
- // so locate according to block's next character
- //
- NewPos = 0;
- }
-
- HBufferImageMovePosition (NewPos / 0x10 + 1, NewPos % 0x10 + 1, TRUE);
-
- Buffer = AllocateZeroPool (Size);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- HBufferImageListToBuffer (Buffer, Size);
-
- BufferPtr = (UINT8 *) Buffer;
-
- //
- // pass deleted buffer out
- //
- if (DeleteBuffer != NULL) {
- for (Index = 0; Index < Count; Index++) {
- DeleteBuffer[Index] = BufferPtr[Pos + Index];
- }
- }
- //
- // delete the part from Pos
- //
- for (Index = Pos; Index < Size - Count; Index++) {
- BufferPtr[Index] = BufferPtr[Index + Count];
- }
-
- Size -= Count;
-
- HBufferImageFreeLines ();
-
- Status = HBufferImageBufferToList (Buffer, Size);
- FreePool (Buffer);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Link = HMainEditor.BufferImage->ListHead->ForwardLink;
- for (Index = 0; Index < NewPos / 0x10; Index++) {
- Link = Link->ForwardLink;
- }
-
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- HBufferImage.CurrentLine = Line;
-
- //
- // if current cursor position if inside select area
- // then move it to the block's NEXT character
- //
- if (OldPos >= Pos && OldPos < (Pos + Count)) {
- NewPos = Pos;
- } else {
- if (OldPos < Pos) {
- NewPos = OldPos;
- } else {
- NewPos = OldPos - Count;
- }
- }
-
- HBufferImageMovePosition (NewPos / 0x10 + 1, NewPos % 0x10 + 1, TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Add character to buffer, add before pos.
-
- @param[in] Pos Position, Pos starting from 0.
- @param[in] Count Count of characters to add.
- @param[in] AddBuffer Add buffer.
-
- @retval EFI_SUCCESS Success.
-**/
-EFI_STATUS
-HBufferImageAddCharacterToBuffer (
- IN UINTN Pos,
- IN UINTN Count,
- IN UINT8 *AddBuffer
- )
-{
- INTN Index;
-
- VOID *Buffer;
- UINT8 *BufferPtr;
- UINTN Size;
-
- HEFI_EDITOR_LINE *Line;
-
- LIST_ENTRY *Link;
-
- UINTN OldFCol;
- UINTN OldFRow;
- UINTN OldPos;
-
- UINTN NewPos;
-
- Size = HBufferImageGetTotalSize ();
-
- //
- // relocate all the HBufferImage fields
- //
- OldFRow = HBufferImage.BufferPosition.Row;
- OldFCol = HBufferImage.BufferPosition.Column;
- OldPos = (OldFRow - 1) * 0x10 + OldFCol - 1;
-
- //
- // move cursor before Pos
- //
- if (Pos > 0) {
- NewPos = Pos - 1;
- } else {
- NewPos = 0;
- }
-
- HBufferImageMovePosition (NewPos / 0x10 + 1, NewPos % 0x10 + 1, TRUE);
-
- Buffer = AllocateZeroPool (Size + Count);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- HBufferImageListToBuffer (Buffer, Size);
-
- BufferPtr = (UINT8 *) Buffer;
-
- //
- // get a place to add
- //
- for (Index = (INTN) (Size + Count - 1); Index >= (INTN) Pos; Index--) {
- BufferPtr[Index] = BufferPtr[Index - Count];
- }
- //
- // add the buffer
- //
- for (Index = (INTN) 0; Index < (INTN) Count; Index++) {
- BufferPtr[Index + Pos] = AddBuffer[Index];
- }
-
- Size += Count;
-
- HBufferImageFreeLines ();
-
- HBufferImageBufferToList (Buffer, Size);
-
- FreePool (Buffer);
-
- Link = HMainEditor.BufferImage->ListHead->ForwardLink;
- for (Index = 0; Index < (INTN) NewPos / 0x10; Index++) {
- Link = Link->ForwardLink;
- }
-
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- HBufferImage.CurrentLine = Line;
-
- if (OldPos >= Pos) {
- NewPos = OldPos + Count;
- } else {
- NewPos = OldPos;
- }
-
- HBufferImageMovePosition (NewPos / 0x10 + 1, NewPos % 0x10 + 1, TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Delete current character from line.
-
- @retval EFI_SUCCESS The operationw as successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageDoDelete (
- VOID
- )
-{
-
- HEFI_EDITOR_LINE *Line;
-
- BOOLEAN LastLine;
- UINTN FileColumn;
- UINTN FPos;
-
- FPos = (HBufferImage.BufferPosition.Row - 1) * 0x10 + HBufferImage.BufferPosition.Column - 1;
-
- FileColumn = HBufferImage.BufferPosition.Column;
-
- Line = HBufferImage.CurrentLine;
-
- //
- // if beyond the last character
- //
- if (FileColumn > Line->Size) {
- return EFI_SUCCESS;
- }
-
- LastLine = FALSE;
- if (Line->Link.ForwardLink == HBufferImage.ListHead) {
- LastLine = TRUE;
- }
-
- HBufferImageDeleteCharacterFromBuffer (FPos, 1, NULL);
-
- //
- // if is the last line
- // then only this line need to be refreshed
- //
- if (LastLine) {
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = TRUE;
- } else {
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- }
-
- if (!HBufferImage.Modified) {
- HBufferImage.Modified = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Change the raw buffer to a list of lines for the UI.
-
- @param[in] Buffer The pointer to the buffer to fill.
- @param[in] Bytes The size of the buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageBufferToList (
- IN VOID *Buffer,
- IN UINTN Bytes
- )
-{
- UINTN TempI;
- UINTN TempJ;
- UINTN Left;
- HEFI_EDITOR_LINE *Line;
- UINT8 *BufferPtr;
-
- TempI = 0;
- Left = 0;
- BufferPtr = (UINT8 *) Buffer;
-
- //
- // parse file content line by line
- //
- while (TempI < Bytes) {
- if (Bytes - TempI >= 0x10) {
- Left = 0x10;
- } else {
- Left = Bytes - TempI;
- }
-
- //
- // allocate a new line
- //
- Line = HBufferImageCreateLine ();
- if (Line == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Line->Size = Left;
-
- for (TempJ = 0; TempJ < Left; TempJ++) {
- Line->Buffer[TempJ] = BufferPtr[TempI];
- TempI++;
- }
-
- }
-
- //
- // last line is a full line, SO create a new line
- //
- if (Left == 0x10 || Bytes == 0) {
- Line = HBufferImageCreateLine ();
- if (Line == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Change the list of lines from the UI to a raw buffer.
-
- @param[in] Buffer The pointer to the buffer to fill.
- @param[in] Bytes The size of the buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageListToBuffer (
- IN VOID *Buffer,
- IN UINTN Bytes
- )
-{
- UINTN Count;
- UINTN Index;
- HEFI_EDITOR_LINE *Line;
- LIST_ENTRY *Link;
- UINT8 *BufferPtr;
-
- //
- // change the line list to a large buffer
- //
- if (HBufferImage.Lines == NULL) {
- return EFI_SUCCESS;
- }
-
- Link = &HBufferImage.Lines->Link;
- Count = 0;
- BufferPtr = (UINT8 *) Buffer;
-
- //
- // deal line by line
- //
- while (Link != HBufferImage.ListHead) {
-
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- //@todo shouldn't this be an error???
- if (Count + Line->Size > Bytes) {
- return EFI_SUCCESS;
- }
-
- for (Index = 0; Index < Line->Size; Index++) {
- BufferPtr[Index] = Line->Buffer[Index];
- }
-
- Count += Line->Size;
- BufferPtr += Line->Size;
-
- Link = Link->ForwardLink;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Move the mouse in the image buffer.
-
- @param[in] TextX The x-coordinate.
- @param[in] TextY The y-coordinate.
-**/
-VOID
-EFIAPI
-HBufferImageAdjustMousePosition (
- IN INT32 TextX,
- IN INT32 TextY
- )
-{
- UINTN TempX;
- UINTN TempY;
- UINTN AbsX;
- UINTN AbsY;
-
- //
- // TextX and TextY is mouse movement data returned by mouse driver
- // This function will change it to MousePosition
- //
- //
- // get absolute TempX value
- //
- if (TextX >= 0) {
- AbsX = TextX;
- } else {
- AbsX = -TextX;
- }
- //
- // get absolute TempY value
- //
- if (TextY >= 0) {
- AbsY = TextY;
- } else {
- AbsY = -TextY;
- }
-
- TempX = HBufferImage.MousePosition.Column;
- TempY = HBufferImage.MousePosition.Row;
-
- if (TextX >= 0) {
- TempX += TextX;
- } else {
- if (TempX >= AbsX) {
- TempX -= AbsX;
- } else {
- TempX = 0;
- }
- }
-
- if (TextY >= 0) {
- TempY += TextY;
- } else {
- if (TempY >= AbsY) {
- TempY -= AbsY;
- } else {
- TempY = 0;
- }
- }
- //
- // check whether new mouse column position is beyond screen
- // if not, adjust it
- //
- if (TempX >= 10 && TempX <= (10 + 0x10 * 3 - 1)) {
- HBufferImage.MousePosition.Column = TempX;
- } else if (TempX < 10) {
- HBufferImage.MousePosition.Column = 10;
- } else if (TempX > (10 + 0x10 * 3 - 1)) {
- HBufferImage.MousePosition.Column = 10 + 0x10 * 3 - 1;
- }
- //
- // check whether new mouse row position is beyond screen
- // if not, adjust it
- //
- if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 1)) {
- HBufferImage.MousePosition.Row = TempY;
- } else if (TempY < 2) {
- HBufferImage.MousePosition.Row = 2;
- } else if (TempY > (HMainEditor.ScreenSize.Row - 1)) {
- HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 1);
- }
-
-}
-
-/**
- Dispatch input to different handler
-
- @param[in] Key The input key:
- the keys can be:
- ASCII KEY
- Backspace/Delete
- Direction key: up/down/left/right/pgup/pgdn
- Home/End
- INS
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
-**/
-EFI_STATUS
-HBufferImageHandleInput (
- IN EFI_INPUT_KEY *Key
- )
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- switch (Key->ScanCode) {
- //
- // ordinary key
- //
- case SCAN_NULL:
- Status = HBufferImageDoCharInput (Key->UnicodeChar);
- break;
-
- //
- // up arrow
- //
- case SCAN_UP:
- Status = HBufferImageScrollUp ();
- break;
-
- //
- // down arrow
- //
- case SCAN_DOWN:
- Status = HBufferImageScrollDown ();
- break;
-
- //
- // right arrow
- //
- case SCAN_RIGHT:
- Status = HBufferImageScrollRight ();
- break;
-
- //
- // left arrow
- //
- case SCAN_LEFT:
- Status = HBufferImageScrollLeft ();
- break;
-
- //
- // page up
- //
- case SCAN_PAGE_UP:
- Status = HBufferImagePageUp ();
- break;
-
- //
- // page down
- //
- case SCAN_PAGE_DOWN:
- Status = HBufferImagePageDown ();
- break;
-
- //
- // delete
- //
- case SCAN_DELETE:
- Status = HBufferImageDoDelete ();
- break;
-
- //
- // home
- //
- case SCAN_HOME:
- Status = HBufferImageHome ();
- break;
-
- //
- // end
- //
- case SCAN_END:
- Status = HBufferImageEnd ();
- break;
-
- default:
- Status = StatusBarSetStatusString (L"Unknown Command");
- break;
- }
-
- return Status;
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
deleted file mode 100644
index 91369b5931..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Defines BufferImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_BUFFER_IMAGE_H_
-#define _LIB_BUFFER_IMAGE_H_
-
-#include "HexEditor.h"
-
-/**
- Initialization function for HBufferImage
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HBufferImageInit (
- VOID
- );
-
-/**
- Cleanup function for HBufferImage
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageCleanup (
- VOID
- );
-
-/**
- Refresh function for HBufferImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A Load error occured.
-
-**/
-EFI_STATUS
-HBufferImageRefresh (
- VOID
- );
-
-/**
- Dispatch input to different handler
-
- @param[in] Key The input key:
- the keys can be:
- ASCII KEY
- Backspace/Delete
- Direction key: up/down/left/right/pgup/pgdn
- Home/End
- INS
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
-**/
-EFI_STATUS
-HBufferImageHandleInput (
- IN EFI_INPUT_KEY *Key
- );
-
-/**
- Backup function for HBufferImage. Only a few fields need to be backup.
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageBackup (
- VOID
- );
-
-/**
- Read an image into a buffer friom a source.
-
- @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
- @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] BufferType The type of buffer to save. IGNORED.
- @param[in] Recover TRUE for recovermode, FALSE otherwise.
-
- @return EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageRead (
- IN CONST CHAR16 *FileName,
- IN CONST CHAR16 *DiskName,
- IN UINTN DiskOffset,
- IN UINTN DiskSize,
- IN UINTN MemOffset,
- IN UINTN MemSize,
- IN EDIT_FILE_TYPE BufferType,
- IN BOOLEAN Recover
- );
-
-/**
- Save the current image.
-
- @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
- @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
- @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
- @param[in] BufferType The type of buffer to save. IGNORED.
-
- @return EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageSave (
- IN CHAR16 *FileName,
- IN CHAR16 *DiskName,
- IN UINTN DiskOffset,
- IN UINTN DiskSize,
- IN UINTN MemOffset,
- IN UINTN MemSize,
- IN EDIT_FILE_TYPE BufferType
- );
-
-/**
- According to cursor's file position, adjust screen display.
-
- @param[in] NewFilePosRow Row of file position ( start from 1 ).
- @param[in] NewFilePosCol Column of file position ( start from 1 ).
- @param[in] HighBits Cursor will on high4 bits or low4 bits.
-**/
-VOID
-HBufferImageMovePosition (
- IN UINTN NewFilePosRow,
- IN UINTN NewFilePosCol,
- IN BOOLEAN HighBits
- );
-
-
-/**
- Create a new line and append it to the line list.
- Fields affected:
- NumLines
- Lines
-
- @retval NULL create line failed.
- @return the line created.
-
-**/
-HEFI_EDITOR_LINE *
-HBufferImageCreateLine (
- VOID
- );
-
-/**
- Free the current image.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HBufferImageFree (
- VOID
- );
-
-/**
- Delete character from buffer.
-
- @param[in] Pos Position, Pos starting from 0.
- @param[in] Count The Count of characters to delete.
- @param[out] DeleteBuffer The DeleteBuffer.
-
- @retval EFI_SUCCESS Success
-**/
-EFI_STATUS
-HBufferImageDeleteCharacterFromBuffer (
- IN UINTN Pos,
- IN UINTN Count,
- OUT UINT8 *DeleteBuffer
- );
-
-/**
- Add character to buffer, add before pos.
-
- @param[in] Pos Position, Pos starting from 0.
- @param[in] Count Count of characters to add.
- @param[in] AddBuffer Add buffer.
-
- @retval EFI_SUCCESS Success.
-**/
-EFI_STATUS
-HBufferImageAddCharacterToBuffer (
- IN UINTN Pos,
- IN UINTN Count,
- IN UINT8 *AddBuffer
- );
-
-/**
- Change the raw buffer to a list of lines for the UI.
-
- @param[in] Buffer The pointer to the buffer to fill.
- @param[in] Bytes The size of the buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageBufferToList (
- IN VOID *Buffer,
- IN UINTN Bytes
- );
-
-/**
- Change the list of lines from the UI to a raw buffer.
-
- @param[in] Buffer The pointer to the buffer to fill.
- @param[in] Bytes The size of the buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-HBufferImageListToBuffer (
- IN VOID *Buffer,
- IN UINTN Bytes
- );
-
-/**
- Move the mouse in the image buffer.
-
- @param[in] TextX The x-coordinate.
- @param[in] TextY The y-coordinate.
-**/
-VOID
-EFIAPI
-HBufferImageAdjustMousePosition (
- IN INT32 TextX,
- IN INT32 TextY
- );
-
-/**
- Function to decide if a column number is stored in the high bits.
-
- @param[in] Column The column to examine.
- @param[out] FCol The actual column number.
-
- @retval TRUE The actual column was in high bits and is now in FCol.
- @retval FALSE There was not a column number in the high bits.
-**/
-BOOLEAN
-HBufferImageIsAtHighBits (
- IN UINTN Column,
- OUT UINTN *FCol
- );
-
-/**
- Get the size of the open buffer.
-
- @retval The size in bytes.
-**/
-UINTN
-HBufferImageGetTotalSize (
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c
deleted file mode 100644
index 4d5bfb391f..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/** @file
- Functions to deal with Clip Board
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-
-typedef struct {
- UINT8 *Buffer;
- UINTN Size;
-} HEFI_EDITOR_CLIPBOARD;
-
-HEFI_EDITOR_CLIPBOARD HClipBoard;
-
-//
-// for basic initialization of HClipBoard
-//
-HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
- NULL,
- 0
-};
-
-/**
- Initialization function for HDiskImage.
-
- @param[in] EFI_SUCCESS The operation was successful.
- @param[in] EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HClipBoardInit (
- VOID
- )
-{
- //
- // basiclly initialize the HDiskImage
- //
- CopyMem (&HClipBoard, &HClipBoardConst, sizeof (HClipBoard));
-
- return EFI_SUCCESS;
-}
-
-/**
- Initialization function for HDiskImage.
-
- @param[in] EFI_SUCCESS The operation was successful.
- @param[in] EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HClipBoardCleanup (
- VOID
- )
-{
-
- SHELL_FREE_NON_NULL (HClipBoard.Buffer);
-
- return EFI_SUCCESS;
-}
-
-/**
- Set a buffer into the clipboard.
-
- @param[in] Buffer The buffer to add to the clipboard.
- @param[in] Size The size of Buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HClipBoardSet (
- IN UINT8 *Buffer,
- IN UINTN Size
- )
-{
- //
- // free the old clipboard buffer
- // and set new clipboard buffer
- //
- SHELL_FREE_NON_NULL (HClipBoard.Buffer);
- HClipBoard.Buffer = Buffer;
-
- HClipBoard.Size = Size;
-
- return EFI_SUCCESS;
-}
-
-/**
- Get a buffer from the clipboard.
-
- @param[out] Buffer The pointer to the buffer to add to the clipboard.
-
- @return the size of the buffer.
-**/
-UINTN
-HClipBoardGet (
- OUT UINT8 **Buffer
- )
-{
- //
- // return the clipboard buffer
- //
- *Buffer = HClipBoard.Buffer;
-
- return HClipBoard.Size;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.h
deleted file mode 100644
index 8066c29247..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file
- Defines DiskImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_CLIP_BOARD_H_
-#define _LIB_CLIP_BOARD_H_
-
-#include "HexEditor.h"
-
-/**
- Initialization function for HDiskImage
-
- @param[in] EFI_SUCCESS The operation was successful.
- @param[in] EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HClipBoardInit (
- VOID
- );
-
-/**
- Initialization function for HDiskImage.
-
- @param[in] EFI_SUCCESS The operation was successful.
- @param[in] EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HClipBoardCleanup (
- VOID
- );
-
-/**
- Set a buffer into the clipboard.
-
- @param[in] Buffer The buffer to add to the clipboard.
- @param[in] Size The size of Buffer in bytes.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HClipBoardSet (
- IN UINT8 *Buffer,
- IN UINTN Size
- );
-
-/**
- Get a buffer from the clipboard.
-
- @param[out] Buffer The pointer to the buffer to add to the clipboard.
-
- @return the size of the buffer.
-**/
-UINTN
-HClipBoardGet (
- OUT UINT8 **Buffer
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
deleted file mode 100644
index a50b52f5f2..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/** @file
- Functions to deal with Disk buffer.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-#include <Protocol/BlockIo.h>
-
-extern EFI_HANDLE HImageHandleBackup;
-extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
-
-extern BOOLEAN HBufferImageNeedRefresh;
-extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
-extern BOOLEAN HBufferImageMouseNeedRefresh;
-
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-
-HEFI_EDITOR_DISK_IMAGE HDiskImage;
-HEFI_EDITOR_DISK_IMAGE HDiskImageBackupVar;
-
-//
-// for basic initialization of HDiskImage
-//
-HEFI_EDITOR_DISK_IMAGE HDiskImageConst = {
- NULL,
- 0,
- 0,
- 0
-};
-
-/**
- Initialization function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HDiskImageInit (
- VOID
- )
-{
- //
- // basically initialize the HDiskImage
- //
- CopyMem (&HDiskImage, &HDiskImageConst, sizeof (HDiskImage));
-
- CopyMem (&HDiskImageBackupVar, &HDiskImageConst, sizeof (HDiskImageBackupVar));
-
- return EFI_SUCCESS;
-}
-
-/**
- Backup function for HDiskImage. Only a few fields need to be backup.
- This is for making the Disk buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES gST->ConOut of resources.
-**/
-EFI_STATUS
-HDiskImageBackup (
- VOID
- )
-{
- //
- // backup the disk name, offset and size
- //
- //
- SHELL_FREE_NON_NULL (HDiskImageBackupVar.Name);
-
- HDiskImageBackupVar.Name = CatSPrint(NULL, L"%s", HDiskImage.Name);
- if (HDiskImageBackupVar.Name == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- HDiskImageBackupVar.Offset = HDiskImage.Offset;
- HDiskImageBackupVar.Size = HDiskImage.Size;
-
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HDiskImageCleanup (
- VOID
- )
-{
- SHELL_FREE_NON_NULL (HDiskImage.Name);
- SHELL_FREE_NON_NULL (HDiskImageBackupVar.Name);
-
- return EFI_SUCCESS;
-}
-
-/**
- Set FileName field in HFileImage.
-
- @param[in] Str File name to set.
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-HDiskImageSetDiskNameOffsetSize (
- IN CONST CHAR16 *Str,
- IN UINTN Offset,
- IN UINTN Size
- )
-{
- UINTN Len;
- UINTN Index;
-
- //
- // free the old file name
- //
- SHELL_FREE_NON_NULL (HDiskImage.Name);
-
- Len = StrLen (Str);
-
- HDiskImage.Name = AllocateZeroPool (2 * (Len + 1));
- if (HDiskImage.Name == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Index = 0; Index < Len; Index++) {
- HDiskImage.Name[Index] = Str[Index];
- }
-
- HDiskImage.Name[Len] = L'\0';
-
- HDiskImage.Offset = Offset;
- HDiskImage.Size = Size;
-
- return EFI_SUCCESS;
-}
-
-/**
- Read a disk from disk into HBufferImage.
-
- @param[in] DeviceName filename to read.
- @param[in] Offset The offset.
- @param[in] Size The size.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-HDiskImageRead (
- IN CONST CHAR16 *DeviceName,
- IN UINTN Offset,
- IN UINTN Size,
- IN BOOLEAN Recover
- )
-{
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree;
- EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_STATUS Status;
-
- VOID *Buffer;
- CHAR16 *Str;
- UINTN Bytes;
-
- HEFI_EDITOR_LINE *Line;
-
- HBufferImage.BufferType = FileTypeDiskBuffer;
-
- DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
- if (DevicePath == NULL) {
- StatusBarSetStatusString (L"Cannot Find Device");
- return EFI_INVALID_PARAMETER;
- }
- DupDevicePath = DuplicateDevicePath(DevicePath);
- DupDevicePathForFree = DupDevicePath;
- //
- // get blkio interface
- //
- Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);
- FreePool(DupDevicePathForFree);
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return Status;
- }
- Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return Status;
- }
- //
- // if Offset exceeds LastBlock,
- // return error
- //
- if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) {
- StatusBarSetStatusString (L"Invalid Offset + Size");
- return EFI_LOAD_ERROR;
- }
-
- Bytes = BlkIo->Media->BlockSize * Size;
- Buffer = AllocateZeroPool (Bytes);
-
- if (Buffer == NULL) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // read from disk
- //
- Status = BlkIo->ReadBlocks (
- BlkIo,
- BlkIo->Media->MediaId,
- Offset,
- Bytes,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- StatusBarSetStatusString (L"Read Disk Failed");
- return EFI_LOAD_ERROR;
- }
-
- HBufferImageFree ();
-
- //
- // convert buffer to line list
- //
- Status = HBufferImageBufferToList (Buffer, Bytes);
- FreePool (Buffer);
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return Status;
- }
-
- Status = HDiskImageSetDiskNameOffsetSize (DeviceName, Offset, Size);
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // initialize some variables
- //
- HDiskImage.BlockSize = BlkIo->Media->BlockSize;
-
- HBufferImage.DisplayPosition.Row = 2;
- HBufferImage.DisplayPosition.Column = 10;
-
- HBufferImage.MousePosition.Row = 2;
- HBufferImage.MousePosition.Column = 10;
-
- HBufferImage.LowVisibleRow = 1;
- HBufferImage.HighBits = TRUE;
-
- HBufferImage.BufferPosition.Row = 1;
- HBufferImage.BufferPosition.Column = 1;
-
- if (!Recover) {
- Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
- if (Str == NULL) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (Str);
- SHELL_FREE_NON_NULL (Str);
-
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
-
- }
-
- //
- // has line
- //
- if (HBufferImage.Lines != NULL) {
- HBufferImage.CurrentLine = CR (
- HBufferImage.ListHead->ForwardLink,
- HEFI_EDITOR_LINE,
- Link,
- EFI_EDITOR_LINE_LIST
- );
- } else {
- //
- // create a dummy line
- //
- Line = HBufferImageCreateLine ();
- if (Line == NULL) {
- StatusBarSetStatusString (L"Read Disk Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- HBufferImage.CurrentLine = Line;
- }
-
- HBufferImage.Modified = FALSE;
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageMouseNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Save lines in HBufferImage to disk.
- NOT ALLOW TO WRITE TO ANOTHER DISK!!!!!!!!!
-
- @param[in] DeviceName The device name.
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-HDiskImageSave (
- IN CHAR16 *DeviceName,
- IN UINTN Offset,
- IN UINTN Size
- )
-{
-
- CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- VOID *Buffer;
- UINTN Bytes;
-
- //
- // if not modified, directly return
- //
- if (HBufferImage.Modified == FALSE) {
- return EFI_SUCCESS;
- }
-
- HBufferImage.BufferType = FileTypeDiskBuffer;
-
- DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
- if (DevicePath == NULL) {
-// StatusBarSetStatusString (L"Cannot Find Device");
- return EFI_INVALID_PARAMETER;
- }
- DupDevicePath = DuplicateDevicePath(DevicePath);
-
- //
- // get blkio interface
- //
- Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);
- FreePool(DupDevicePath);
- if (EFI_ERROR (Status)) {
-// StatusBarSetStatusString (L"Read Disk Failed");
- return Status;
- }
- Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR (Status)) {
-// StatusBarSetStatusString (L"Read Disk Failed");
- return Status;
- }
-
- Bytes = BlkIo->Media->BlockSize * Size;
- Buffer = AllocateZeroPool (Bytes);
-
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // concatenate the line list to a buffer
- //
- Status = HBufferImageListToBuffer (Buffer, Bytes);
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- return Status;
- }
-
- //
- // write the buffer to disk
- //
- Status = BlkIo->WriteBlocks (
- BlkIo,
- BlkIo->Media->MediaId,
- Offset,
- Bytes,
- Buffer
- );
-
- FreePool (Buffer);
-
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
- //
- // now not modified
- //
- HBufferImage.Modified = FALSE;
-
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.h
deleted file mode 100644
index 06fb53020a..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/** @file
- Defines DiskImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_DISK_IMAGE_H_
-#define _LIB_DISK_IMAGE_H_
-
-#include "HexEditor.h"
-
-/**
- Initialization function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HDiskImageInit (
- VOID
- );
-
-/**
- Cleanup function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HDiskImageCleanup (
- VOID
- );
-
-/**
- Backup function for HDiskImage. Only a few fields need to be backup.
- This is for making the Disk buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES gST->ConOut of resources.
-**/
-EFI_STATUS
-HDiskImageBackup (
- VOID
- );
-
-/**
- Read a disk from disk into HBufferImage.
-
- @param[in] DeviceName filename to read.
- @param[in] Offset The offset.
- @param[in] Size The size.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-HDiskImageRead (
- IN CONST CHAR16 *DeviceName,
- IN UINTN Offset,
- IN UINTN Size,
- IN BOOLEAN Recover
- );
-
-/**
- Save lines in HBufferImage to disk.
- NOT ALLOW TO WRITE TO ANOTHER DISK!!!!!!!!!
-
- @param[in] DeviceName The device name.
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-HDiskImageSave (
- IN CHAR16 *DeviceName,
- IN UINTN Offset,
- IN UINTN Size
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
deleted file mode 100644
index 2517a57f59..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/** @file
- Functions to deal with file buffer.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-
-extern EFI_HANDLE HImageHandleBackup;
-extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
-
-extern BOOLEAN HBufferImageNeedRefresh;
-extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
-extern BOOLEAN HBufferImageMouseNeedRefresh;
-
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-
-HEFI_EDITOR_FILE_IMAGE HFileImage;
-HEFI_EDITOR_FILE_IMAGE HFileImageBackupVar;
-
-//
-// for basic initialization of HFileImage
-//
-HEFI_EDITOR_BUFFER_IMAGE HFileImageConst = {
- NULL,
- 0,
- FALSE
-};
-
-/**
- Initialization function for HFileImage
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFileImageInit (
- VOID
- )
-{
- //
- // basically initialize the HFileImage
- //
- CopyMem (&HFileImage, &HFileImageConst, sizeof (HFileImage));
-
- CopyMem (
- &HFileImageBackupVar,
- &HFileImageConst,
- sizeof (HFileImageBackupVar)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Backup function for HFileImage. Only a few fields need to be backup.
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HFileImageBackup (
- VOID
- )
-{
- SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
- HFileImageBackupVar.FileName = CatSPrint(NULL, L"%s", HFileImage.FileName);
- if (HFileImageBackupVar.FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup function for HFileImage.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFileImageCleanup (
- VOID
- )
-{
-
- SHELL_FREE_NON_NULL (HFileImage.FileName);
- SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
-
- return EFI_SUCCESS;
-}
-
-/**
- Set FileName field in HFileImage
-
- @param[in] Str File name to set.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HFileImageSetFileName (
- IN CONST CHAR16 *Str
- )
-{
- UINTN Size;
- UINTN Index;
-
- //
- // free the old file name
- //
- SHELL_FREE_NON_NULL (HFileImage.FileName);
-
- Size = StrLen (Str);
-
- HFileImage.FileName = AllocateZeroPool (2 * (Size + 1));
- if (HFileImage.FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Index = 0; Index < Size; Index++) {
- HFileImage.FileName[Index] = Str[Index];
- }
-
- HFileImage.FileName[Size] = L'\0';
-
- return EFI_SUCCESS;
-}
-
-/**
- Read a file from disk into HBufferImage.
-
- @param[in] FileName filename to read.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HFileImageRead (
- IN CONST CHAR16 *FileName,
- IN BOOLEAN Recover
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINT8 *Buffer;
- CHAR16 *UnicodeBuffer;
- EFI_STATUS Status;
-
- //
- // variable initialization
- //
- Line = NULL;
-
- //
- // in this function, when you return error ( except EFI_OUT_OF_RESOURCES )
- // you should set status string
- // since this function maybe called before the editorhandleinput loop
- // so any error will cause editor return
- // so if you want to print the error status
- // you should set the status string
- //
- Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);
- //
- // NULL pointer is only also a failure for a non-zero file size.
- //
- if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) {
- UnicodeBuffer = CatSPrint(NULL, L"Read error on file %s: %r", FileName, Status);
- if (UnicodeBuffer == NULL) {
- SHELL_FREE_NON_NULL(Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (UnicodeBuffer);
- FreePool (UnicodeBuffer);
- return EFI_OUT_OF_RESOURCES;
- }
-
- HFileImageSetFileName (FileName);
-
- //
- // free the old lines
- //
- HBufferImageFree ();
-
- Status = HBufferImageBufferToList (Buffer, HFileImage.Size);
- SHELL_FREE_NON_NULL (Buffer);
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Error parsing file.");
- return Status;
- }
-
- HBufferImage.DisplayPosition.Row = 2;
- HBufferImage.DisplayPosition.Column = 10;
- HBufferImage.MousePosition.Row = 2;
- HBufferImage.MousePosition.Column = 10;
- HBufferImage.LowVisibleRow = 1;
- HBufferImage.HighBits = TRUE;
- HBufferImage.BufferPosition.Row = 1;
- HBufferImage.BufferPosition.Column = 1;
- HBufferImage.BufferType = FileTypeFileBuffer;
-
- if (!Recover) {
- UnicodeBuffer = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
- if (UnicodeBuffer == NULL) {
- SHELL_FREE_NON_NULL(Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (UnicodeBuffer);
- FreePool (UnicodeBuffer);
-
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
- }
-
- //
- // has line
- //
- if (HBufferImage.Lines != 0) {
- HBufferImage.CurrentLine = CR (HBufferImage.ListHead->ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- } else {
- //
- // create a dummy line
- //
- Line = HBufferImageCreateLine ();
- if (Line == NULL) {
- SHELL_FREE_NON_NULL(Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
-
- HBufferImage.CurrentLine = Line;
- }
-
- HBufferImage.Modified = FALSE;
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageMouseNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Save lines in HBufferImage to disk.
-
- @param[in] FileName The file name.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HFileImageSave (
- IN CHAR16 *FileName
- )
-{
-
- LIST_ENTRY *Link;
- HEFI_EDITOR_LINE *Line;
- CHAR16 *Str;
- EFI_STATUS Status;
- UINTN NumLines;
- SHELL_FILE_HANDLE FileHandle;
- UINTN TotalSize;
- UINT8 *Buffer;
- UINT8 *Ptr;
- EDIT_FILE_TYPE BufferTypeBackup;
-
- BufferTypeBackup = HBufferImage.BufferType;
- HBufferImage.BufferType = FileTypeFileBuffer;
-
- //
- // if is the old file
- //
- if (HFileImage.FileName != NULL && FileName != NULL && StrCmp (FileName, HFileImage.FileName) == 0) {
- //
- // check whether file exists on disk
- //
- if (ShellIsFile(FileName) == EFI_SUCCESS) {
- //
- // current file exists on disk
- // so if not modified, then not save
- //
- if (HBufferImage.Modified == FALSE) {
- return EFI_SUCCESS;
- }
- //
- // if file is read-only, set error
- //
- if (HFileImage.ReadOnly == TRUE) {
- StatusBarSetStatusString (L"Read Only File Can Not Be Saved");
- return EFI_SUCCESS;
- }
- }
- }
-
- if (ShellIsDirectory(FileName) == EFI_SUCCESS) {
- StatusBarSetStatusString (L"Directory Can Not Be Saved");
- return EFI_LOAD_ERROR;
- }
-
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
-
- if (!EFI_ERROR (Status)) {
- //
- // the file exits, delete it
- //
- Status = ShellDeleteFile (&FileHandle);
- if (EFI_ERROR (Status) || Status == EFI_WARN_DELETE_FAILURE) {
- StatusBarSetStatusString (L"Write File Failed");
- return EFI_LOAD_ERROR;
- }
- }
-
- //
- // write all the lines back to disk
- //
- NumLines = 0;
- TotalSize = 0;
- for (Link = HBufferImage.ListHead->ForwardLink; Link != HBufferImage.ListHead; Link = Link->ForwardLink) {
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- if (Line->Size != 0) {
- TotalSize += Line->Size;
- }
- //
- // end of if Line -> Size != 0
- //
- NumLines++;
- }
- //
- // end of for Link
- //
- Buffer = AllocateZeroPool (TotalSize);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Ptr = Buffer;
- for (Link = HBufferImage.ListHead->ForwardLink; Link != HBufferImage.ListHead; Link = Link->ForwardLink) {
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- if (Line->Size != 0) {
- CopyMem (Ptr, Line->Buffer, Line->Size);
- Ptr += Line->Size;
- }
- //
- // end of if Line -> Size != 0
- //
- }
-
-
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Create File Failed");
- return EFI_LOAD_ERROR;
- }
-
- Status = ShellWriteFile (FileHandle, &TotalSize, Buffer);
- FreePool (Buffer);
- if (EFI_ERROR (Status)) {
- ShellDeleteFile (&FileHandle);
- return EFI_LOAD_ERROR;
- }
-
- ShellCloseFile(&FileHandle);
-
- HBufferImage.Modified = FALSE;
-
- //
- // set status string
- //
- Str = CatSPrint(NULL, L"%d Lines Wrote", NumLines);
- StatusBarSetStatusString (Str);
- FreePool (Str);
-
- //
- // now everything is ready , you can set the new file name to filebuffer
- //
- if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||
- (FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){
- //
- // not the same
- //
- HFileImageSetFileName (FileName);
- if (HFileImage.FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- }
-
- HFileImage.ReadOnly = FALSE;
-
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.h
deleted file mode 100644
index ed27ad03ae..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/** @file
- Defines FileImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_FILE_IMAGE_H_
-#define _LIB_FILE_IMAGE_H_
-
-#include "HexEditor.h"
-
-/**
- Initialization function for HFileImage
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFileImageInit (
- VOID
- );
-
-/**
- Cleanup function for HFileImage.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFileImageCleanup (
- VOID
- );
-
-/**
- Backup function for HFileImage. Only a few fields need to be backup.
- This is for making the file buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HFileImageBackup (
- VOID
- );
-
-/**
- Read a file from disk into HBufferImage.
-
- @param[in] FileName filename to read.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HFileImageRead (
- IN CONST CHAR16 *FileName,
- IN BOOLEAN Recover
- );
-
-/**
- Save lines in HBufferImage to disk.
-
- @param[in] FileName The file name.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HFileImageSave (
- IN CHAR16 *FileName
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
deleted file mode 100644
index 118aa7c3ed..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Main entry point of editor
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include "HexEditor.h"
-
-//
-// Global Variables
-//
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-f", TypeFlag},
- {L"-d", TypeFlag},
- {L"-m", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'hexedit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunHexEdit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- CHAR16 *Buffer;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- LIST_ENTRY *Package;
- CHAR16 *NewName;
- CONST CHAR16 *Name;
- UINTN Offset;
- UINTN Size;
- EDIT_FILE_TYPE WhatToDo;
-
- Buffer = NULL;
- ShellStatus = SHELL_SUCCESS;
- NewName = NULL;
- Buffer = NULL;
- Name = NULL;
- Offset = 0;
- Size = 0;
- WhatToDo = FileTypeNone;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"hexedit", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // Check for -d
- //
- if (ShellCommandLineGetFlag(Package, L"-d")){
- if (ShellCommandLineGetCount(Package) < 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- WhatToDo = FileTypeDiskBuffer;
- Name = ShellCommandLineGetRawValue(Package, 1);
- Offset = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
- Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 3));
- }
- if (Offset == (UINTN)-1 || Size == (UINTN)-1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
-
- //
- // check for -f
- //
- if (ShellCommandLineGetFlag(Package, L"-f") && (WhatToDo == FileTypeNone)){
- if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Name = ShellCommandLineGetRawValue(Package, 1);
- if (Name == NULL || !IsValidFileName(Name)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- WhatToDo = FileTypeFileBuffer;
- }
- }
- }
-
- //
- // check for -m
- //
- if (ShellCommandLineGetFlag(Package, L"-m") && (WhatToDo == FileTypeNone)){
- if (ShellCommandLineGetCount(Package) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- WhatToDo = FileTypeMemBuffer;
- Offset = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 1));
- Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
- }
- }
- Name = ShellCommandLineGetRawValue(Package, 1);
- if (WhatToDo == FileTypeNone && Name != NULL) {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (!IsValidFileName(Name)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- WhatToDo = FileTypeFileBuffer;
- }
- } else if (WhatToDo == FileTypeNone) {
- if (gEfiShellProtocol->GetCurDir(NULL) == NULL) {
- ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
- } else {
- NewName = EditGetDefaultFileName(L"bin");
- Name = NewName;
- WhatToDo = FileTypeFileBuffer;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS && WhatToDo == FileTypeNone) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (WhatToDo == FileTypeFileBuffer && ShellGetCurrentDir(NULL) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle, L"hexedit");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // Do the editor
- //
- Status = HMainEditorInit ();
- if (EFI_ERROR (Status)) {
- gST->ConOut->ClearScreen (gST->ConOut);
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_INIT_FAILED), gShellDebug1HiiHandle);
- } else {
- HMainEditorBackup ();
- switch (WhatToDo) {
- case FileTypeFileBuffer:
- Status = HBufferImageRead (
- Name==NULL?L"":Name,
- NULL,
- 0,
- 0,
- 0,
- 0,
- FileTypeFileBuffer,
- FALSE
- );
- break;
-
- case FileTypeDiskBuffer:
- Status = HBufferImageRead (
- NULL,
- Name==NULL?L"":Name,
- Offset,
- Size,
- 0,
- 0,
- FileTypeDiskBuffer,
- FALSE
- );
- break;
-
- case FileTypeMemBuffer:
- Status = HBufferImageRead (
- NULL,
- NULL,
- 0,
- 0,
- (UINT32) Offset,
- Size,
- FileTypeMemBuffer,
- FALSE
- );
- break;
-
- default:
- Status = EFI_NOT_FOUND;
- break;
- }
- if (!EFI_ERROR (Status)) {
- HMainEditorRefresh ();
- Status = HMainEditorKeyInput ();
- }
- if (Status != EFI_OUT_OF_RESOURCES) {
- //
- // back up the status string
- //
- Buffer = CatSPrint (NULL, L"%s\r\n", StatusBarGetString());
- }
- }
-
- //
- // cleanup
- //
- HMainEditorCleanup ();
-
- if (EFI_ERROR (Status)) {
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = SHELL_UNSUPPORTED;
- }
- }
-
- //
- // print editor exit code on screen
- //
- if (Status == EFI_OUT_OF_RESOURCES) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"hexedit");
- } else if (EFI_ERROR(Status)){
- if (Buffer != NULL) {
- if (StrCmp (Buffer, L"") != 0) {
- //
- // print out the status string
- //
- ShellPrintEx(-1, -1, L"%s", Buffer);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_UNKNOWN_EDITOR), gShellDebug1HiiHandle);
- }
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
-
- SHELL_FREE_NON_NULL (Buffer);
- SHELL_FREE_NON_NULL (NewName);
- return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditor.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditor.h
deleted file mode 100644
index d0a4bf4aae..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditor.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file
- Main include file for hex editor
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _EFI_SHELL_HEXEDIT_H_
-#define _EFI_SHELL_HEXEDIT_H_
-
-#include "UefiShellDebug1CommandsLib.h"
-#include "HexEditorTypes.h"
-
-#include "MainHexEditor.h"
-
-#include "BufferImage.h"
-#include "FileImage.h"
-#include "DiskImage.h"
-#include "MemImage.h"
-
-#include "EditTitleBar.h"
-#include "EditStatusBar.h"
-#include "EditInputBar.h"
-#include "EditMenuBar.h"
-
-#include "Misc.h"
-
-#include "Clipboard.h"
-
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-extern BOOLEAN HEditorFirst;
-extern BOOLEAN HEditorExit;
-
-#endif // _HEDITOR_H
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h
deleted file mode 100644
index ddd6070c94..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/** @file
- data types that are used by editor
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _HEDITOR_TYPE_H_
-#define _HEDITOR_TYPE_H_
-
-#include "UefiShellDebug1CommandsLib.h"
-#include "EditTitleBar.h"
-
-#define EFI_EDITOR_LINE_LIST SIGNATURE_32 ('e', 'e', 'l', 'l')
-
-#define ASCII_POSITION ((0x10 * 3) + 12)
-
-
-typedef struct {
- UINTN Row;
- UINTN Column;
-} HEFI_EDITOR_POSITION;
-
-typedef
-EFI_STATUS
-(*HEFI_MENU_ITEM_FUNCTION) (
- VOID
- );
-
-typedef struct {
- CHAR16 Name[50];
- CHAR16 Key[3];
- HEFI_MENU_ITEM_FUNCTION Function;
-} HMENU_ITEMS;
-
-typedef struct _HEFI_EDITOR_LINE {
- UINTN Signature;
- UINT8 Buffer[0x10];
- UINTN Size; // unit is Unicode
- LIST_ENTRY Link;
-} HEFI_EDITOR_LINE;
-
-typedef struct _HEFI_EDITOR_MENU_ITEM {
- CHAR16 NameToken;
- CHAR16 FunctionKeyToken;
- HEFI_MENU_ITEM_FUNCTION Function;
-} HEFI_EDITOR_MENU_ITEM;
-
-typedef struct {
- UINT32 Foreground : 4;
- UINT32 Background : 4;
-} HEFI_EDITOR_COLOR_ATTRIBUTES;
-
-typedef union {
- HEFI_EDITOR_COLOR_ATTRIBUTES Colors;
- UINTN Data;
-} HEFI_EDITOR_COLOR_UNION;
-
-typedef struct {
- UINTN Columns;
- UINTN Rows;
-} HEFI_EDITOR_TEXT_MODE;
-
-
-typedef struct {
- CHAR16 *Name;
-
- UINTN BlockSize;
- UINTN Size;
- UINTN Offset;
-} HEFI_EDITOR_DISK_IMAGE;
-
-typedef struct {
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoFncs;
-
- UINTN Offset;
- UINTN Size;
-} HEFI_EDITOR_MEM_IMAGE;
-
-typedef struct {
- CHAR16 *FileName;
- UINTN Size; // file size
- BOOLEAN ReadOnly; // file is read-only or not
-} HEFI_EDITOR_FILE_IMAGE;
-
-typedef struct {
- LIST_ENTRY *ListHead; // list head of lines
- HEFI_EDITOR_LINE *Lines; // lines of current file
- UINTN NumLines; // number of lines
- HEFI_EDITOR_LINE *CurrentLine; // current line cursor is at
- HEFI_EDITOR_POSITION DisplayPosition; // cursor position in screen
- HEFI_EDITOR_POSITION MousePosition; // mouse position in screen
- HEFI_EDITOR_POSITION BufferPosition; // cursor position in buffer
- UINTN LowVisibleRow; // the lowest visible row of file position
- BOOLEAN HighBits; // cursor is at the high4 bits or low4 bits
- BOOLEAN Modified; // BUFFER is modified or not
- EDIT_FILE_TYPE BufferType;
-
- HEFI_EDITOR_FILE_IMAGE *FileImage;
- HEFI_EDITOR_DISK_IMAGE *DiskImage;
- HEFI_EDITOR_MEM_IMAGE *MemImage;
-
-} HEFI_EDITOR_BUFFER_IMAGE;
-
-typedef struct {
- HEFI_EDITOR_BUFFER_IMAGE *BufferImage;
-
- HEFI_EDITOR_COLOR_UNION ColorAttributes;
- HEFI_EDITOR_POSITION ScreenSize; // row number and column number
- BOOLEAN MouseSupported;
- EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
- INT32 MouseAccumulatorX;
- INT32 MouseAccumulatorY;
-
- UINTN SelectStart; // starting from 1
- UINTN SelectEnd; // starting from 1
-} HEFI_EDITOR_GLOBAL_EDITOR;
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni
deleted file mode 100644
index f52193106f..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
deleted file mode 100644
index 4c346cc24e..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ /dev/null
@@ -1,2318 +0,0 @@
-/** @file
- Defines the Main Editor data type -
- - Global variables
- - Instances of the other objects of the editor
- - Main Interfaces
-
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-#include "EditStatusBar.h"
-#include "EditInputBar.h"
-
-HEFI_EDITOR_COLOR_ATTRIBUTES HOriginalColors;
-INTN HOriginalMode;
-
-//
-// the first time editor launch
-//
-BOOLEAN HEditorFirst;
-
-//
-// it's time editor should exit
-//
-BOOLEAN HEditorExit;
-
-BOOLEAN HEditorMouseAction;
-
-extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
-extern HEFI_EDITOR_BUFFER_IMAGE HBufferImageBackupVar;
-
-extern BOOLEAN HBufferImageMouseNeedRefresh;
-extern BOOLEAN HBufferImageNeedRefresh;
-extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
-
-HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-HEFI_EDITOR_GLOBAL_EDITOR HMainEditorBackupVar;
-
-//
-// basic initialization for MainEditor
-//
-HEFI_EDITOR_GLOBAL_EDITOR HMainEditorConst = {
- &HBufferImage,
- {
- {0, 0}
- },
- {
- 0,
- 0
- },
- FALSE,
- NULL,
- 0,
- 0,
- 1,
- 1
-};
-
-/**
- Help info that will be displayed.
-**/
-EFI_STRING_ID HexMainMenuHelpInfo[] = {
- STRING_TOKEN(STR_HEXEDIT_HELP_TITLE),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_LIST_TITLE),
- STRING_TOKEN(STR_HEXEDIT_HELP_DIV),
- STRING_TOKEN(STR_HEXEDIT_HELP_GO_TO_OFFSET),
- STRING_TOKEN(STR_HEXEDIT_HELP_SAVE_BUFFER),
- STRING_TOKEN(STR_HEXEDIT_HELP_EXIT),
- STRING_TOKEN(STR_HEXEDIT_HELP_SELECT_START),
- STRING_TOKEN(STR_HEXEDIT_HELP_SELECT_END),
- STRING_TOKEN(STR_HEXEDIT_HELP_CUT),
- STRING_TOKEN(STR_HEXEDIT_HELP_PASTE),
- STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_FILE),
- STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_DISK),
- STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_MEMORY),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_EXIT_HELP),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_BLANK),
- STRING_TOKEN(STR_HEXEDIT_HELP_DIV),
- 0
-};
-
-
-/**
- show help menu.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMainCommandDisplayHelp (
- VOID
- )
-{
- INT32 CurrentLine;
- CHAR16 * InfoString;
- EFI_INPUT_KEY Key;
-
- CurrentLine = 0;
- // print helpInfo
- for (CurrentLine = 0; 0 != HexMainMenuHelpInfo[CurrentLine]; CurrentLine++) {
- InfoString = HiiGetString(gShellDebug1HiiHandle, HexMainMenuHelpInfo[CurrentLine]
-, NULL);
- ShellPrintEx (0,CurrentLine+1,L"%E%s%N",InfoString);
- }
-
- // scan for ctrl+w
- do {
- gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- } while(SCAN_CONTROL_W != Key.UnicodeChar);
-
- // update screen with buffer's info
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageRefresh ();
-
- return EFI_SUCCESS;
-}
-
-/**
- Move cursor to specified lines.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMainCommandGoToOffset (
- VOID
- )
-{
- UINTN Size;
- UINT64 Offset;
- EFI_STATUS Status;
- UINTN FRow;
- UINTN FCol;
-
- //
- // variable initialization
- //
- Size = 0;
- Offset = 0;
- FRow = 0;
- FCol = 0;
-
- //
- // get offset
- //
- Status = InputBarSetPrompt (L"Go To Offset: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (8);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- Status = ShellConvertStringToUint64 (InputBarGetString(), &Offset, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Invalid Offset");
- return EFI_SUCCESS;
- }
-
- break;
- }
- }
-
- Size = HBufferImageGetTotalSize ();
- if (Offset >= Size) {
- StatusBarSetStatusString (L"Invalid Offset");
- return EFI_SUCCESS;
- }
-
- FRow = (UINTN)DivU64x32(Offset , 0x10) + 1;
- FCol = (UINTN)ModU64x32(Offset , 0x10) + 1;
-
- HBufferImageMovePosition (FRow, FCol, TRUE);
-
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageMouseNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Save current opened buffer.
- If is file buffer, you can save to current file name or
- save to another file name.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandSaveBuffer (
- VOID
- )
-{
- EFI_STATUS Status;
- BOOLEAN Done;
- CHAR16 *FileName;
- BOOLEAN OldFile;
- CHAR16 *Str;
- EFI_FILE_INFO *Info;
- SHELL_FILE_HANDLE ShellFileHandle;
-
- if (HMainEditor.BufferImage->BufferType != FileTypeFileBuffer) {
- if (!HMainEditor.BufferImage->Modified) {
- return EFI_SUCCESS;
- }
-
- Status = InputBarSetPrompt (L"Dangerous to save disk/mem buffer. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // the answer is just one character
- //
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // loop for user's answer
- // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
- //
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // want to save this buffer first
- //
- Status = HBufferImageSave (
- NULL,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- HMainEditor.BufferImage->BufferType
- );
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"BufferSave: Problems Writing");
- return Status;
- }
-
- return EFI_SUCCESS;
-
- case L'n':
- case L'N':
- //
- // the file won't be saved
- //
- return EFI_SUCCESS;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
- }
- //
- // end of switch
- //
- }
- //
- // ENDOF WHILE
- //
- }
- //
- // ENDOF != FILEBUFFER
- //
- // This command will save currently opened file to disk.
- // You can choose save to another file name or just save to
- // current file name.
- // Below is the scenario of Save File command: (
- // Suppose the old file name is A )
- // 1. An Input Bar will be prompted: "File To Save: [ old file name]"
- // IF user press ESC, Save File command ends .
- // IF user press Enter, input file name will be A.
- // IF user inputs a new file name B, input file name will be B.
- //
- // 2. IF input file name is A, go to do Step 3.
- // IF input file name is B, go to do Step 4.
- //
- // 3. IF A is read only, Status Bar will show "Access Denied"
- // and Save File commands ends.
- // IF A is not read only, save file buffer to disk
- // and remove Modified flag in Title Bar , then Save File command ends.
- //
- // 4. IF B does not exist, create this file and save file buffer to it.
- // Go to do Step 7.
- // IF B exits, do Step 5.
- //
- // 5. An Input Bar will be prompted:
- // "File Exists. Overwrite ( Yes/No/Cancel ) ?"
- // IF user press 'y' or 'Y', do Step 6.
- // IF user press 'n' or 'N', Save File commands ends.
- // IF user press 'c' or 'C' or ESC, Save File commands ends.
- //
- // 6. IF B is a read-only file, Status Bar will show "Access Denied"
- // and Save File commands ends.
- // IF B can be read and write, save file buffer to B.
- //
- // 7. Update File Name field in Title Bar to B
- // and remove the Modified flag in Title Bar.
- //
- Str = CatSPrint(NULL,
- L"File to Save: [%s]",
- HMainEditor.BufferImage->FileImage->FileName
- );
- if (Str == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (StrLen (Str) >= 50) {
- //
- // replace the long file name with "..."
- //
- Str[46] = L'.';
- Str[47] = L'.';
- Str[48] = L'.';
- Str[49] = L']';
- Str[50] = L'\0';
- }
-
- Status = InputBarSetPrompt (Str);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (100);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // get new file name
- //
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // if user pressed ESC
- //
- if (Status == EFI_NOT_READY) {
- SHELL_FREE_NON_NULL (Str);
- return EFI_SUCCESS;
- }
-
- SHELL_FREE_NON_NULL (Str);
-
- //
- // if just enter pressed, so think save to current file name
- //
- if (StrLen (InputBarGetString()) == 0) {
- FileName = CatSPrint(NULL,
- L"%s",
- HMainEditor.BufferImage->FileImage->FileName
- );
- } else {
- FileName = CatSPrint(NULL, L"%s", InputBarGetString());
- }
-
- if (FileName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (!IsValidFileName (FileName)) {
- StatusBarSetStatusString (L"Invalid File Name");
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- }
-
- OldFile = FALSE;
-
- //
- // save to the old file
- //
- if (StringNoCaseCompare (
- &FileName,
- &HMainEditor.BufferImage->FileImage->FileName
- ) == 0) {
- OldFile = TRUE;
- }
-
- if (OldFile) {
- //
- // if the file is read only, so can not write back to it.
- //
- if (HMainEditor.BufferImage->FileImage->ReadOnly) {
- StatusBarSetStatusString (L"Access Denied");
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- }
- } else {
- Status = ShellOpenFileByName (FileName, &ShellFileHandle, EFI_FILE_MODE_READ, 0);
-
- if (!EFI_ERROR (Status)) {
-
- Info = ShellGetFileInfo(ShellFileHandle);
-
- ShellCloseFile(&ShellFileHandle);
- //
- // check if read only
- //
- if (Info->Attribute & EFI_FILE_READ_ONLY) {
- StatusBarSetStatusString (L"Access Denied");
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- }
-
- SHELL_FREE_NON_NULL(Info);
- //
- // ask user whether to overwrite this file
- //
- Status = InputBarSetPrompt (L"File exists. Overwrite (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (FileName);
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (FileName);
- return Status;
- }
-
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- if (Status == EFI_NOT_READY) {
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- Done = TRUE;
- break;
- case L'n':
- case L'N':
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- case L'c':
- case L'C':
- SHELL_FREE_NON_NULL (FileName);
- return EFI_SUCCESS;
- } // switch
- } // while
- } // if opened existing file
- } // if OldFile
-
- //
- // save file back to disk
- //
- Status = HBufferImageSave (
- FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- FileTypeFileBuffer
- );
- SHELL_FREE_NON_NULL (FileName);
-
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Load a disk buffer editor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandSelectStart (
- VOID
- )
-{
- UINTN Start;
-
- Start = (HMainEditor.BufferImage->BufferPosition.Row - 1) * 0x10 + HMainEditor.BufferImage->BufferPosition.Column;
-
- //
- // last line
- //
- if (HMainEditor.BufferImage->CurrentLine->Link.ForwardLink == HMainEditor.BufferImage->ListHead) {
- if (HMainEditor.BufferImage->BufferPosition.Column > HMainEditor.BufferImage->CurrentLine->Size) {
- StatusBarSetStatusString (L"Invalid Block Start");
- return EFI_LOAD_ERROR;
- }
- }
-
- if (HMainEditor.SelectEnd != 0 && Start > HMainEditor.SelectEnd) {
- StatusBarSetStatusString (L"Invalid Block Start");
- return EFI_LOAD_ERROR;
- }
-
- HMainEditor.SelectStart = Start;
-
- HBufferImageNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Load a disk buffer editor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandSelectEnd (
- VOID
- )
-{
- UINTN End;
-
- End = (HMainEditor.BufferImage->BufferPosition.Row - 1) * 0x10 + HMainEditor.BufferImage->BufferPosition.Column;
-
- //
- // last line
- //
- if (HMainEditor.BufferImage->CurrentLine->Link.ForwardLink == HMainEditor.BufferImage->ListHead) {
- if (HMainEditor.BufferImage->BufferPosition.Column > HMainEditor.BufferImage->CurrentLine->Size) {
- StatusBarSetStatusString (L"Invalid Block End");
- return EFI_LOAD_ERROR;
- }
- }
-
- if (HMainEditor.SelectStart != 0 && End < HMainEditor.SelectStart) {
- StatusBarSetStatusString (L"Invalid Block End");
- return EFI_SUCCESS;
- }
-
- HMainEditor.SelectEnd = End;
-
- HBufferImageNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Cut current line to clipboard.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandCut (
- VOID
- )
-{
- UINTN Index;
- LIST_ENTRY *Link;
- UINT8 *Buffer;
- UINTN Count;
-
- //
- // not select, so not allowed to cut
- //
- if (HMainEditor.SelectStart == 0) {
- StatusBarSetStatusString (L"No Block is Selected");
- return EFI_SUCCESS;
- }
- //
- // not select, so not allowed to cut
- //
- if (HMainEditor.SelectEnd == 0) {
- StatusBarSetStatusString (L"No Block is Selected");
- return EFI_SUCCESS;
- }
-
- Link = HMainEditor.BufferImage->ListHead->ForwardLink;
- for (Index = 0; Index < (HMainEditor.SelectEnd - 1) / 0x10; Index++) {
- Link = Link->ForwardLink;
- }
-
- Count = HMainEditor.SelectEnd - HMainEditor.SelectStart + 1;
- Buffer = AllocateZeroPool (Count);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // cut the selected area
- //
- HBufferImageDeleteCharacterFromBuffer (
- HMainEditor.SelectStart - 1,
- Count,
- Buffer
- );
-
- //
- // put to clipboard
- //
- HClipBoardSet (Buffer, Count);
-
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
-
- if (!HMainEditor.BufferImage->Modified) {
- HMainEditor.BufferImage->Modified = TRUE;
- }
-
- //
- // now no select area
- //
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
-
- return EFI_SUCCESS;
-}
-
-/**
- Paste line to file buffer.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandPaste (
- VOID
- )
-{
-
- BOOLEAN OnlyLineRefresh;
- HEFI_EDITOR_LINE *Line;
- UINT8 *Buffer;
- UINTN Count;
- UINTN FPos;
-
- Count = HClipBoardGet (&Buffer);
- if (Count == 0 || Buffer == NULL) {
- StatusBarSetStatusString (L"Nothing to Paste");
- return EFI_SUCCESS;
- }
-
- Line = HMainEditor.BufferImage->CurrentLine;
-
- OnlyLineRefresh = FALSE;
- if (Line->Link.ForwardLink == HMainEditor.BufferImage->ListHead && Line->Size + Count < 0x10) {
- //
- // is at last line, and after paste will not exceed
- // so only this line need to be refreshed
- //
- // if after add, the line is 0x10, then will append a new line
- // so the whole page will need be refreshed
- //
- OnlyLineRefresh = TRUE;
-
- }
-
- FPos = 0x10 * (HMainEditor.BufferImage->BufferPosition.Row - 1) + HMainEditor.BufferImage->BufferPosition.Column - 1;
-
- HBufferImageAddCharacterToBuffer (FPos, Count, Buffer);
-
- if (OnlyLineRefresh) {
- HBufferImageNeedRefresh = FALSE;
- HBufferImageOnlyLineNeedRefresh = TRUE;
- } else {
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- }
-
- if (!HMainEditor.BufferImage->Modified) {
- HMainEditor.BufferImage->Modified = TRUE;
- }
-
- return EFI_SUCCESS;
-
-}
-
-/**
- Exit editor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandExit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Below is the scenario of Exit command:
- // 1. IF currently opened file is not modified, exit the editor and
- // Exit command ends.
- // IF currently opened file is modified, do Step 2
- //
- // 2. An Input Bar will be prompted:
- // "File modified. Save ( Yes/No/Cancel )?"
- // IF user press 'y' or 'Y', currently opened file will be saved and
- // Editor exits
- // IF user press 'n' or 'N', currently opened file will not be saved
- // and Editor exits.
- // IF user press 'c' or 'C' or ESC, Exit command ends.
- //
- //
- // if file has been modified, so will prompt user
- // whether to save the changes
- //
- if (HMainEditor.BufferImage->Modified) {
-
- Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // write file back to disk
- //
- Status = HBufferImageSave (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- HMainEditor.BufferImage->BufferType
- );
- if (!EFI_ERROR (Status)) {
- HEditorExit = TRUE;
- }
-
- return Status;
-
- case L'n':
- case L'N':
- HEditorExit = TRUE;
- return EFI_SUCCESS;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
-
- }
- }
- }
-
- HEditorExit = TRUE;
- return EFI_SUCCESS;
-
-}
-
-/**
- Load a file from disk to editor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainCommandOpenFile (
- VOID
- )
-{
- BOOLEAN Done;
- EFI_STATUS Status;
- EDIT_FILE_TYPE BufferType;
-
- BufferType = HMainEditor.BufferImage->BufferType;
-
- //
- // This command will open a file from current working directory.
- // Read-only file can also be opened. But it can not be modified.
- // Below is the scenario of Open File command:
- // 1. IF currently opened file has not been modified, directly go to step .
- // IF currently opened file has been modified, an Input Bar will be
- // prompted as :
- // "File Modified. Save ( Yes/No/Cancel) ?"
- // IF user press 'y' or 'Y', currently opened file will be saved.
- // IF user press 'n' or 'N', currently opened file will
- // not be saved.
- // IF user press 'c' or 'C' or ESC, Open File command ends and
- // currently opened file is still opened.
- //
- // 2. An Input Bar will be prompted as : "File Name to Open: "
- // IF user press ESC, Open File command ends and
- // currently opened file is still opened.
- // Any other inputs with a Return will cause
- // currently opened file close.
- //
- // 3. IF user input file name is an existing file ,
- // this file will be read and opened.
- // IF user input file name is a new file, this file will be created
- // and opened. This file's type ( UNICODE or ASCII ) is the same with
- // the old file.
- //
- //
- // if current file is modified, so you need to choose whether to
- // save it first.
- //
- if (HMainEditor.BufferImage->Modified) {
-
- Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // the answer is just one character
- //
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // loop for user's answer
- // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
- //
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // want to save this buffer first
- //
- Status = HBufferImageSave (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- HMainEditor.BufferImage->BufferType
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MainTitleBarRefresh (
- HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL,
- HMainEditor.BufferImage->BufferType,
- HMainEditor.BufferImage->FileImage->ReadOnly,
- FALSE,
- HMainEditor.ScreenSize.Column,
- HMainEditor.ScreenSize.Row,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Offset:HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Offset:0,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Size :HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Size :0
- );
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- //
- // the file won't be saved
- //
- Done = TRUE;
- break;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
- }
- }
- }
- //
- // TO get the open file name
- //
- Status = InputBarSetPrompt (L"File Name to Open: ");
- if (EFI_ERROR (Status)) {
- HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
- return Status;
- }
-
- Status = InputBarSetStringSize (100);
- if (EFI_ERROR (Status)) {
- Status = HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- Status = HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
-
- return Status;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- //
- // CHECK if filename's valid
- //
- if (!IsValidFileName (InputBarGetString())) {
- HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
-
- StatusBarSetStatusString (L"Invalid File Name");
- return EFI_SUCCESS;
- }
-
- break;
- }
- }
- //
- // read from disk
- //
- Status = HBufferImageRead (
- InputBarGetString(),
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- FileTypeFileBuffer,
- FALSE
- );
-
- if (EFI_ERROR (Status)) {
- HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
-
- return EFI_LOAD_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Load a disk buffer editor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_NOT_FOUND The disk was not found.
-**/
-EFI_STATUS
-HMainCommandOpenDisk (
- VOID
- )
-{
- UINT64 Size;
- UINT64 Offset;
- CHAR16 *DeviceName;
- EFI_STATUS Status;
- BOOLEAN Done;
-
- EDIT_FILE_TYPE BufferType;
-
- //
- // variable initialization
- //
- Size = 0;
- Offset = 0;
- BufferType = HMainEditor.BufferImage->BufferType;
-
- //
- // if current file is modified, so you need to choose
- // whether to save it first.
- //
- if (HMainEditor.BufferImage->Modified) {
-
- Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // the answer is just one character
- //
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // loop for user's answer
- // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
- //
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // want to save this buffer first
- //
- Status = HBufferImageSave (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MainTitleBarRefresh (
- HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL,
- HMainEditor.BufferImage->BufferType,
- HMainEditor.BufferImage->FileImage->ReadOnly,
- FALSE,
- HMainEditor.ScreenSize.Column,
- HMainEditor.ScreenSize.Row,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Offset:HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Offset:0,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Size :HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Size :0
- );
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- //
- // the file won't be saved
- //
- Done = TRUE;
- break;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
- }
- }
- }
- //
- // get disk block device name
- //
- Status = InputBarSetPrompt (L"Block Device to Open: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (100);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- break;
- }
- }
-
- DeviceName = CatSPrint(NULL, L"%s", InputBarGetString());
- if (DeviceName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // get starting offset
- //
- Status = InputBarSetPrompt (L"First Block No.: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (16);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- Status = ShellConvertStringToUint64 (InputBarGetString(), &Offset, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- break;
- }
- }
- //
- // get Number of Blocks:
- //
- Status = InputBarSetPrompt (L"Number of Blocks: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (8);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- Status = ShellConvertStringToUint64 (InputBarGetString(), &Size, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (Size == 0) {
- continue;
- }
-
- break;
- }
- }
-
- Status = HBufferImageRead (
- NULL,
- DeviceName,
- (UINTN)Offset,
- (UINTN)Size,
- 0,
- 0,
- FileTypeDiskBuffer,
- FALSE
- );
-
- if (EFI_ERROR (Status)) {
-
- HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Load memory content to editor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_NOT_FOUND The disk was not found.
-**/
-EFI_STATUS
-HMainCommandOpenMemory (
- VOID
- )
-{
- UINT64 Size;
- UINT64 Offset;
- EFI_STATUS Status;
- BOOLEAN Done;
- EDIT_FILE_TYPE BufferType;
-
- //
- // variable initialization
- //
- Size = 0;
- Offset = 0;
- BufferType = HMainEditor.BufferImage->BufferType;
-
- //
- // if current buffer is modified, so you need to choose
- // whether to save it first.
- //
- if (HMainEditor.BufferImage->Modified) {
-
- Status = InputBarSetPrompt (L"Buffer modified. Save (Yes/No/Cancel) ? ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // the answer is just one character
- //
- Status = InputBarSetStringSize (1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // loop for user's answer
- // valid answer is just 'y' 'Y', 'n' 'N', 'c' 'C'
- //
- Done = FALSE;
- while (!Done) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
- return EFI_SUCCESS;
- }
-
- switch (InputBarGetString()[0]) {
- case L'y':
- case L'Y':
- //
- // want to save this buffer first
- //
- Status = HBufferImageSave (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MainTitleBarRefresh (
- HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL,
- HMainEditor.BufferImage->BufferType,
- HMainEditor.BufferImage->FileImage->ReadOnly,
- FALSE,
- HMainEditor.ScreenSize.Column,
- HMainEditor.ScreenSize.Row,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Offset:HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Offset:0,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Size :HMainEditor.BufferImage->BufferType == FileTypeMemBuffer?HMainEditor.BufferImage->MemImage->Size :0
- );
- Done = TRUE;
- break;
-
- case L'n':
- case L'N':
- //
- // the file won't be saved
- //
- Done = TRUE;
- break;
-
- case L'c':
- case L'C':
- return EFI_SUCCESS;
- }
- }
- }
- //
- // get starting offset
- //
- Status = InputBarSetPrompt (L"Starting Offset: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (8);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- Status = ShellConvertStringToUint64 (InputBarGetString(), &Offset, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- break;
- }
- }
- //
- // get Number of Blocks:
- //
- Status = InputBarSetPrompt (L"Buffer Size: ");
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = InputBarSetStringSize (8);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- Status = InputBarRefresh (HMainEditor.ScreenSize.Row, HMainEditor.ScreenSize.Column);
-
- //
- // ESC pressed
- //
- if (Status == EFI_NOT_READY) {
-
- return EFI_SUCCESS;
- }
- //
- // THE input string length should > 0
- //
- if (StrLen (InputBarGetString()) > 0) {
- Status = ShellConvertStringToUint64 (InputBarGetString(), &Size, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (Size == 0) {
- continue;
- }
-
- break;
- }
- }
-
- if ((Offset + Size - 1)> 0xffffffff) {
- StatusBarSetStatusString (L"Invalid parameter");
- return EFI_LOAD_ERROR;
- }
-
- Status = HBufferImageRead (
- NULL,
- NULL,
- 0,
- 0,
- (UINTN)Offset,
- (UINTN)Size,
- FileTypeMemBuffer,
- FALSE
- );
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Device Error!");
- HBufferImageRead (
- HMainEditor.BufferImage->FileImage->FileName,
- HMainEditor.BufferImage->DiskImage->Name,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Size,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Size,
- BufferType,
- TRUE
- );
- return EFI_NOT_FOUND;
- }
- return EFI_SUCCESS;
-
-}
-
-MENU_ITEM_FUNCTION HexMainControlBasedMenuFunctions[] = {
- NULL,
- NULL, /* Ctrl - A */
- NULL, /* Ctrl - B */
- NULL, /* Ctrl - C */
- HMainCommandSelectEnd, /* Ctrl - D */
- HMainCommandDisplayHelp, /* Ctrl - E */
- NULL, /* Ctrl - F */
- HMainCommandGoToOffset, /* Ctrl - G */
- NULL, /* Ctrl - H */
- HMainCommandOpenDisk, /* Ctrl - I */
- NULL, /* Ctrl - J */
- NULL, /* Ctrl - K */
- NULL, /* Ctrl - L */
- HMainCommandOpenMemory, /* Ctrl - M */
- NULL, /* Ctrl - N */
- HMainCommandOpenFile, /* Ctrl - O */
- NULL, /* Ctrl - P */
- HMainCommandExit, /* Ctrl - Q */
- NULL, /* Ctrl - R */
- HMainCommandSaveBuffer, /* Ctrl - S */
- HMainCommandSelectStart, /* Ctrl - T */
- NULL, /* Ctrl - U */
- HMainCommandPaste, /* Ctrl - V */
- NULL, /* Ctrl - W */
- HMainCommandCut, /* Ctrl - X */
- NULL, /* Ctrl - Y */
- NULL, /* Ctrl - Z */
-};
-
-CONST EDITOR_MENU_ITEM HexEditorMenuItems[] = {
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_GO_TO_OFFSET),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F1),
- HMainCommandGoToOffset
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_SAVE_BUFFER),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F2),
- HMainCommandSaveBuffer
- },
- {
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_EXIT),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F3),
- HMainCommandExit
- },
-
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_SELECT_START),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F4),
- HMainCommandSelectStart
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_SELECT_END),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F5),
- HMainCommandSelectEnd
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_CUT),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F6),
- HMainCommandCut
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_PASTE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F7),
- HMainCommandPaste
- },
-
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_OPEN_FILE),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F8),
- HMainCommandOpenFile
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_OPEN_DISK),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F9),
- HMainCommandOpenDisk
- },
- {
- STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_OPEN_MEMORY),
- STRING_TOKEN(STR_EDIT_LIBMENUBAR_F10),
- HMainCommandOpenMemory
- },
-
- {
- 0,
- 0,
- NULL
- }
-};
-
-/**
- Init function for MainEditor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorInit (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- UINTN Index;
-
- //
- // basic initialization
- //
- CopyMem (&HMainEditor, &HMainEditorConst, sizeof (HMainEditor));
-
- //
- // set screen attributes
- //
- HMainEditor.ColorAttributes.Colors.Foreground = gST->ConOut->Mode->Attribute & 0x000000ff;
-
- HMainEditor.ColorAttributes.Colors.Background = (UINT8) (gST->ConOut->Mode->Attribute >> 4);
-
- HOriginalColors = HMainEditor.ColorAttributes.Colors;
-
- HOriginalMode = gST->ConOut->Mode->Mode;
-
- //
- // query screen size
- //
- gST->ConOut->QueryMode (
- gST->ConOut,
- gST->ConOut->Mode->Mode,
- &(HMainEditor.ScreenSize.Column),
- &(HMainEditor.ScreenSize.Row)
- );
-
- //
- // Find mouse in System Table ConsoleInHandle
- //
- Status = gBS->HandleProtocol (
- gST->ConIn,
- &gEfiSimplePointerProtocolGuid,
- (VOID**)&HMainEditor.MouseInterface
- );
- if (EFI_ERROR (Status)) {
- //
- // If there is no Simple Pointer Protocol on System Table
- //
- HandleBuffer = NULL;
- HMainEditor.MouseInterface = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimplePointerProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (!EFI_ERROR (Status) && HandleCount > 0) {
- //
- // Try to find the first available mouse device
- //
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiSimplePointerProtocolGuid,
- (VOID**)&HMainEditor.MouseInterface
- );
- if (!EFI_ERROR (Status)) {
- break;
- }
- }
- }
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
- }
-
- if (!EFI_ERROR (Status) && HMainEditor.MouseInterface != NULL) {
- HMainEditor.MouseAccumulatorX = 0;
- HMainEditor.MouseAccumulatorY = 0;
- HMainEditor.MouseSupported = TRUE;
- }
-
- //
- // below will call the five components' init function
- //
- Status = MainTitleBarInit (L"UEFI HEXEDIT");
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_TITLE), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = ControlHotKeyInit (HexMainControlBasedMenuFunctions);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
- Status = MenuBarInit (HexEditorMenuItems);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = StatusBarInit ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_STATUS), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- InputBarInit ();
-
- Status = HBufferImageInit ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_BUFFERIMAGE), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = HClipBoardInit ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_CLIPBOARD), gShellDebug1HiiHandle);
- return EFI_LOAD_ERROR;
- }
- //
- // clear whole screen and enable cursor
- //
- gST->ConOut->ClearScreen (gST->ConOut);
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
-
- //
- // initialize EditorFirst and EditorExit
- //
- HEditorFirst = TRUE;
- HEditorExit = FALSE;
- HEditorMouseAction = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorCleanup (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // call the five components' cleanup function
- //
- MainTitleBarCleanup ();
-
- MenuBarCleanup ();
-
- StatusBarCleanup ();
-
- InputBarCleanup ();
-
- Status = HBufferImageCleanup ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_BUFFERIMAGE_CLEAN), gShellDebug1HiiHandle);
- }
-
- Status = HClipBoardCleanup ();
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_CLIPBOARD_CLEAN), gShellDebug1HiiHandle);
- }
- //
- // restore old mode
- //
- if (HOriginalMode != gST->ConOut->Mode->Mode) {
- gST->ConOut->SetMode (gST->ConOut, HOriginalMode);
- }
-
- gST->ConOut->SetAttribute (
- gST->ConOut,
- EFI_TEXT_ATTR (HOriginalColors.Foreground, HOriginalColors.Background)
- );
- gST->ConOut->ClearScreen (gST->ConOut);
-
- return EFI_SUCCESS;
-}
-
-/**
- Refresh function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMainEditorRefresh (
- VOID
- )
-{
- BOOLEAN NameChange;
- BOOLEAN ReadChange;
-
- NameChange = FALSE;
- ReadChange = FALSE;
-
- if (HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer) {
- if (HMainEditor.BufferImage->DiskImage != NULL &&
- HBufferImageBackupVar.DiskImage != NULL &&
- (HMainEditor.BufferImage->DiskImage->Offset != HBufferImageBackupVar.DiskImage->Offset ||
- HMainEditor.BufferImage->DiskImage->Size != HBufferImageBackupVar.DiskImage->Size) ){
- NameChange = TRUE;
- }
- } else if (HMainEditor.BufferImage->BufferType == FileTypeMemBuffer) {
- if (HMainEditor.BufferImage->MemImage != NULL &&
- HBufferImageBackupVar.MemImage != NULL &&
- (HMainEditor.BufferImage->MemImage->Offset != HBufferImageBackupVar.MemImage->Offset ||
- HMainEditor.BufferImage->MemImage->Size != HBufferImageBackupVar.MemImage->Size) ){
- NameChange = TRUE;
- }
- } else if (HMainEditor.BufferImage->BufferType == FileTypeFileBuffer) {
- if ( HMainEditor.BufferImage->FileImage != NULL &&
- HMainEditor.BufferImage->FileImage->FileName != NULL &&
- HBufferImageBackupVar.FileImage != NULL &&
- HBufferImageBackupVar.FileImage->FileName != NULL &&
- StrCmp (HMainEditor.BufferImage->FileImage->FileName, HBufferImageBackupVar.FileImage->FileName) != 0 ) {
- NameChange = TRUE;
- }
- }
- if ( HMainEditor.BufferImage->FileImage != NULL &&
- HBufferImageBackupVar.FileImage != NULL &&
- HMainEditor.BufferImage->FileImage->ReadOnly != HBufferImageBackupVar.FileImage->ReadOnly ) {
- ReadChange = TRUE;
- }
-
- //
- // to aVOID screen flicker
- // the stall value is from experience
- //
- gBS->Stall (50);
-
- //
- // call the components refresh function
- //
- if (HEditorFirst
- || NameChange
- || HMainEditor.BufferImage->BufferType != HBufferImageBackupVar.BufferType
- || HBufferImageBackupVar.Modified != HMainEditor.BufferImage->Modified
- || ReadChange ) {
-
- MainTitleBarRefresh (
- HMainEditor.BufferImage->BufferType == FileTypeFileBuffer&&HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Name:NULL,
- HMainEditor.BufferImage->BufferType,
- (BOOLEAN)(HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->ReadOnly:FALSE),
- HMainEditor.BufferImage->Modified,
- HMainEditor.ScreenSize.Column,
- HMainEditor.ScreenSize.Row,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Offset:HMainEditor.BufferImage->BufferType == FileTypeMemBuffer&&HMainEditor.BufferImage->MemImage!=NULL?HMainEditor.BufferImage->MemImage->Offset:0,
- HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Size :HMainEditor.BufferImage->BufferType == FileTypeMemBuffer&&HMainEditor.BufferImage->MemImage!=NULL?HMainEditor.BufferImage->MemImage->Size :0
- );
- HBufferImageRefresh ();
- }
- if (HEditorFirst
- || HBufferImageBackupVar.DisplayPosition.Row != HMainEditor.BufferImage->DisplayPosition.Row
- || HBufferImageBackupVar.DisplayPosition.Column != HMainEditor.BufferImage->DisplayPosition.Column
- || StatusBarGetRefresh()) {
-
- StatusBarRefresh (
- HEditorFirst,
- HMainEditor.ScreenSize.Row,
- HMainEditor.ScreenSize.Column,
- (UINTN)(-1),
- (UINTN)(-1),
- FALSE
- );
- HBufferImageRefresh ();
- }
-
- if (HEditorFirst) {
- HBufferImageRefresh ();
- }
-
- //
- // EditorFirst is now set to FALSE
- //
- HEditorFirst = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Handle the mouse input.
-
- @param[in] MouseState The current mouse state.
- @param[out] BeforeLeftButtonDown helps with selections.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_NOT_FOUND The disk was not found.
-**/
-EFI_STATUS
-HMainEditorHandleMouseInput (
- IN EFI_SIMPLE_POINTER_STATE MouseState,
- OUT BOOLEAN *BeforeLeftButtonDown
- )
-{
-
- INT32 TextX;
- INT32 TextY;
- UINTN FRow;
- UINTN FCol;
- BOOLEAN HighBits;
- LIST_ENTRY *Link;
- HEFI_EDITOR_LINE *Line;
- UINTN Index;
- BOOLEAN Action;
-
- Action = FALSE;
-
- //
- // have mouse movement
- //
- if (MouseState.RelativeMovementX || MouseState.RelativeMovementY) {
- //
- // handle
- //
- TextX = HGetTextX (MouseState.RelativeMovementX);
- TextY = HGetTextY (MouseState.RelativeMovementY);
-
- HBufferImageAdjustMousePosition (TextX, TextY);
-
- Action = TRUE;
-
- }
-
- if (MouseState.LeftButton) {
- HighBits = HBufferImageIsAtHighBits (
- HMainEditor.BufferImage->MousePosition.Column,
- &FCol
- );
-
- //
- // not at an movable place
- //
- if (FCol == 0) {
- //
- // now just move mouse pointer to legal position
- //
- //
- // move mouse position to legal position
- //
- HMainEditor.BufferImage->MousePosition.Column -= 10;
- if (HMainEditor.BufferImage->MousePosition.Column > 24) {
- HMainEditor.BufferImage->MousePosition.Column--;
- FCol = HMainEditor.BufferImage->MousePosition.Column / 3 + 1 + 1;
- } else {
- if (HMainEditor.BufferImage->MousePosition.Column < 24) {
- FCol = HMainEditor.BufferImage->MousePosition.Column / 3 + 1 + 1;
- } else {
- //
- // == 24
- //
- FCol = 9;
- }
- }
-
- HighBits = TRUE;
-
- }
-
- FRow = HMainEditor.BufferImage->BufferPosition.Row +
- HMainEditor.BufferImage->MousePosition.Row -
- HMainEditor.BufferImage->DisplayPosition.Row;
-
- if (HMainEditor.BufferImage->NumLines < FRow) {
- //
- // dragging
- //
- //
- // now just move mouse pointer to legal position
- //
- FRow = HMainEditor.BufferImage->NumLines;
- HighBits = TRUE;
- }
-
- Link = HMainEditor.BufferImage->ListHead->ForwardLink;
- for (Index = 0; Index < FRow - 1; Index++) {
- Link = Link->ForwardLink;
- }
-
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
- //
- // dragging
- //
- //
- // now just move mouse pointer to legal position
- //
- if (FCol > Line->Size) {
- if (*BeforeLeftButtonDown) {
- HighBits = FALSE;
-
- if (Line->Size == 0) {
- if (FRow > 1) {
- FRow--;
- FCol = 16;
- } else {
- FRow = 1;
- FCol = 1;
- }
-
- } else {
- FCol = Line->Size;
- }
- } else {
- FCol = Line->Size + 1;
- HighBits = TRUE;
- }
- }
-
- HBufferImageMovePosition (FRow, FCol, HighBits);
-
- HMainEditor.BufferImage->MousePosition.Row = HMainEditor.BufferImage->DisplayPosition.Row;
-
- HMainEditor.BufferImage->MousePosition.Column = HMainEditor.BufferImage->DisplayPosition.Column;
-
- *BeforeLeftButtonDown = TRUE;
-
- Action = TRUE;
- } else {
- //
- // else of if LButton
- //
- // release LButton
- //
- if (*BeforeLeftButtonDown) {
- Action = TRUE;
- }
- //
- // mouse up
- //
- *BeforeLeftButtonDown = FALSE;
- }
-
- if (Action) {
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- Handle user key input. will route it to other components handle function.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorKeyInput (
- VOID
- )
-{
- EFI_INPUT_KEY Key;
- EFI_STATUS Status;
- EFI_SIMPLE_POINTER_STATE MouseState;
- BOOLEAN LengthChange;
- UINTN Size;
- UINTN OldSize;
- BOOLEAN BeforeMouseIsDown;
- BOOLEAN MouseIsDown;
- BOOLEAN FirstDown;
- BOOLEAN MouseDrag;
- UINTN FRow;
- UINTN FCol;
- UINTN SelectStartBackup;
- UINTN SelectEndBackup;
-
- //
- // variable initialization
- //
- OldSize = 0;
- FRow = 0;
- FCol = 0;
- LengthChange = FALSE;
-
- MouseIsDown = FALSE;
- FirstDown = FALSE;
- MouseDrag = FALSE;
-
- do {
-
- Status = EFI_SUCCESS;
-
- HEditorMouseAction = FALSE;
-
- //
- // backup some key elements, so that can aVOID some refresh work
- //
- HMainEditorBackup ();
-
- //
- // wait for user key input
- //
- //
- // change priority of checking mouse/keyboard activity dynamically
- // so prevent starvation of keyboard.
- // if last time, mouse moves then this time check keyboard
- //
- if (HMainEditor.MouseSupported) {
- Status = HMainEditor.MouseInterface->GetState (
- HMainEditor.MouseInterface,
- &MouseState
- );
- if (!EFI_ERROR (Status)) {
-
- BeforeMouseIsDown = MouseIsDown;
-
- Status = HMainEditorHandleMouseInput (MouseState, &MouseIsDown);
-
- if (!EFI_ERROR (Status)) {
- if (!BeforeMouseIsDown) {
- //
- // mouse down
- //
- if (MouseIsDown) {
- FRow = HBufferImage.BufferPosition.Row;
- FCol = HBufferImage.BufferPosition.Column;
- SelectStartBackup = HMainEditor.SelectStart;
- SelectEndBackup = HMainEditor.SelectEnd;
-
- FirstDown = TRUE;
- }
- } else {
-
- SelectStartBackup = HMainEditor.SelectStart;
- SelectEndBackup = HMainEditor.SelectEnd;
-
- //
- // begin to drag
- //
- if (MouseIsDown) {
- if (FirstDown) {
- if (MouseState.RelativeMovementX || MouseState.RelativeMovementY) {
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
- HMainEditor.SelectStart = (FRow - 1) * 0x10 + FCol;
-
- MouseDrag = TRUE;
- FirstDown = FALSE;
- }
- } else {
- if ((
- (HBufferImage.BufferPosition.Row - 1) *
- 0x10 +
- HBufferImage.BufferPosition.Column
- ) >= HMainEditor.SelectStart
- ) {
- HMainEditor.SelectEnd = (HBufferImage.BufferPosition.Row - 1) *
- 0x10 +
- HBufferImage.BufferPosition.Column;
- } else {
- HMainEditor.SelectEnd = 0;
- }
- }
- //
- // end of if RelativeX/Y
- //
- } else {
- //
- // mouse is up
- //
- if (MouseDrag) {
- if (HBufferImageGetTotalSize () == 0) {
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
- FirstDown = FALSE;
- MouseDrag = FALSE;
- }
-
- if ((
- (HBufferImage.BufferPosition.Row - 1) *
- 0x10 +
- HBufferImage.BufferPosition.Column
- ) >= HMainEditor.SelectStart
- ) {
- HMainEditor.SelectEnd = (HBufferImage.BufferPosition.Row - 1) *
- 0x10 +
- HBufferImage.BufferPosition.Column;
- } else {
- HMainEditor.SelectEnd = 0;
- }
-
- if (HMainEditor.SelectEnd == 0) {
- HMainEditor.SelectStart = 0;
- }
- }
-
- FirstDown = FALSE;
- MouseDrag = FALSE;
- }
-
- if (SelectStartBackup != HMainEditor.SelectStart || SelectEndBackup != HMainEditor.SelectEnd) {
- if ((SelectStartBackup - 1) / 0x10 != (HMainEditor.SelectStart - 1) / 0x10) {
- HBufferImageNeedRefresh = TRUE;
- } else {
- if ((SelectEndBackup - 1) / 0x10 != (HMainEditor.SelectEnd - 1) / 0x10) {
- HBufferImageNeedRefresh = TRUE;
- } else {
- HBufferImageOnlyLineNeedRefresh = TRUE;
- }
- }
- }
- }
-
- HEditorMouseAction = TRUE;
- HBufferImageMouseNeedRefresh = TRUE;
-
- } else if (Status == EFI_LOAD_ERROR) {
- StatusBarSetStatusString (L"Invalid Mouse Movement ");
- }
- }
- }
-
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (!EFI_ERROR (Status)) {
- //
- // dispatch to different components' key handling function
- // so not everywhere has to set this variable
- //
- HBufferImageMouseNeedRefresh = TRUE;
-
- //
- // clear previous status string
- //
- StatusBarSetRefresh();
- if (EFI_SUCCESS == MenuBarDispatchControlHotKey(&Key)) {
- Status = EFI_SUCCESS;
- } else if (Key.ScanCode == SCAN_NULL) {
- Status = HBufferImageHandleInput (&Key);
- } else if (((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {
- Status = HBufferImageHandleInput (&Key);
- } else if (((Key.ScanCode >= SCAN_F1) && Key.ScanCode <= (SCAN_F12))) {
- Status = MenuBarDispatchFunctionKey (&Key);
- } else {
- StatusBarSetStatusString (L"Unknown Command");
-
- HBufferImageMouseNeedRefresh = FALSE;
- }
-
- if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {
- //
- // not already has some error status
- //
- if (StrCmp (L"", StatusBarGetString()) == 0) {
- StatusBarSetStatusString (L"Disk Error. Try Again");
- }
- }
- }
- //
- // decide if has to set length warning
- //
- if (HBufferImage.BufferType != HBufferImageBackupVar.BufferType) {
- LengthChange = FALSE;
- } else {
- //
- // still the old buffer
- //
- if (HBufferImage.BufferType != FileTypeFileBuffer) {
- Size = HBufferImageGetTotalSize ();
-
- switch (HBufferImage.BufferType) {
- case FileTypeDiskBuffer:
- OldSize = HBufferImage.DiskImage->Size * HBufferImage.DiskImage->BlockSize;
- break;
-
- case FileTypeMemBuffer:
- OldSize = HBufferImage.MemImage->Size;
- break;
-
- default:
- OldSize = 0;
- break;
- }
-
- if (!LengthChange) {
- if (OldSize != Size) {
- StatusBarSetStatusString (L"Disk/Mem Buffer Length should not be changed");
- }
- }
-
- if (OldSize != Size) {
- LengthChange = TRUE;
- } else {
- LengthChange = FALSE;
- }
- }
- }
- //
- // after handling, refresh editor
- //
- HMainEditorRefresh ();
-
- } while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);
-
- return Status;
-}
-
-/**
- Backup function for MainEditor.
-**/
-VOID
-EFIAPI
-HMainEditorBackup (
- VOID
- )
-{
- HMainEditorBackupVar.SelectStart = HMainEditor.SelectStart;
- HMainEditorBackupVar.SelectEnd = HMainEditor.SelectEnd;
- HBufferImageBackup ();
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.h
deleted file mode 100644
index ad9a7b4be8..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @file
- Defines the Main Editor data type -
- - Global variables
- - Instances of the other objects of the editor
- - Main Interfaces
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_EDITOR_H_
-#define _LIB_EDITOR_H_
-
-#include "HexEditor.h"
-
-/**
- Init function for MainEditor
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorInit (
- VOID
- );
-
-/**
- Cleanup function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorCleanup (
- VOID
- );
-
-/**
- Refresh function for MainEditor.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMainEditorRefresh (
- VOID
- );
-
-/**
- Handle user key input. will route it to other components handle function.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation occured.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMainEditorKeyInput (
- VOID
- );
-
-/**
- Backup function for MainEditor.
-**/
-VOID
-EFIAPI
-HMainEditorBackup (
- VOID
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c
deleted file mode 100644
index 300c67f0d4..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/** @file
- Functions to deal with Mem buffer
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-
-extern EFI_HANDLE HImageHandleBackup;
-
-extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
-
-extern BOOLEAN HBufferImageNeedRefresh;
-extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
-extern BOOLEAN HBufferImageMouseNeedRefresh;
-
-extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
-
-HEFI_EDITOR_MEM_IMAGE HMemImage;
-HEFI_EDITOR_MEM_IMAGE HMemImageBackupVar;
-
-EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL DummyPciRootBridgeIo;
-
-//
-// for basic initialization of HDiskImage
-//
-HEFI_EDITOR_MEM_IMAGE HMemImageConst = {
- NULL,
- 0,
- 0
-};
-
-/**
- Empty function. always returns the same.
-
- @param[in] This Ignored.
- @param[in] Width Ignored.
- @param[in] Address Ignored.
- @param[in] Count Ignored.
- @param[in, out] Buffer Ignored.
-
- @retval EFI_UNSUPPORTED.
-**/
-EFI_STATUS
-EFIAPI
-DummyMemRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- Empty function. always returns the same.
-
- @param[in] This Ignored.
- @param[in] Width Ignored.
- @param[in] Address Ignored.
- @param[in] Count Ignored.
- @param[in, out] Buffer Ignored.
-
- @retval EFI_UNSUPPORTED.
-**/
-EFI_STATUS
-EFIAPI
-DummyMemWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- Initialization function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMemImageInit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // basically initialize the HMemImage
- //
- CopyMem (&HMemImage, &HMemImageConst, sizeof (HMemImage));
-
- Status = gBS->LocateProtocol (
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- (VOID**)&HMemImage.IoFncs
- );
- if (Status == EFI_NOT_FOUND) {
- //
- // For NT32, no EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL is available
- // Use Dummy PciRootBridgeIo for memory access
- //
- ZeroMem (&DummyPciRootBridgeIo, sizeof (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL));
- DummyPciRootBridgeIo.Mem.Read = DummyMemRead;
- DummyPciRootBridgeIo.Mem.Write = DummyMemWrite;
- HMemImage.IoFncs = &DummyPciRootBridgeIo;
- Status = EFI_SUCCESS;
- }
- if (!EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- } else {
- return EFI_LOAD_ERROR;
- }
-}
-
-/**
- Backup function for HDiskImage. Only a few fields need to be backup.
- This is for making the Disk buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMemImageBackup (
- VOID
- )
-{
- HMemImageBackupVar.Offset = HMemImage.Offset;
- HMemImageBackupVar.Size = HMemImage.Size;
-
- return EFI_SUCCESS;
-}
-
-/**
- Set FileName field in HFileImage.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageSetMemOffsetSize (
- IN UINTN Offset,
- IN UINTN Size
- )
-{
-
- HMemImage.Offset = Offset;
- HMemImage.Size = Size;
-
- return EFI_SUCCESS;
-}
-
-/**
- Read a disk from disk into HBufferImage.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageRead (
- IN UINTN Offset,
- IN UINTN Size,
- IN BOOLEAN Recover
- )
-{
-
- EFI_STATUS Status;
- void *Buffer;
- CHAR16 *Str;
- HEFI_EDITOR_LINE *Line;
-
- HBufferImage.BufferType = FileTypeMemBuffer;
-
- Buffer = AllocateZeroPool (Size);
- if (Buffer == NULL) {
- StatusBarSetStatusString (L"Read Memory Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = HMemImage.IoFncs->Mem.Read (
- HMemImage.IoFncs,
- EfiPciWidthUint8,
- Offset,
- Size,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- StatusBarSetStatusString (L"Memory Specified Not Accessible");
- return EFI_LOAD_ERROR;
- }
-
- HBufferImageFree ();
-
- Status = HBufferImageBufferToList (Buffer, Size);
- FreePool (Buffer);
-
- if (EFI_ERROR (Status)) {
- StatusBarSetStatusString (L"Read Memory Failed");
- return Status;
- }
-
- Status = HMemImageSetMemOffsetSize (Offset, Size);
-
- HBufferImage.DisplayPosition.Row = 2;
- HBufferImage.DisplayPosition.Column = 10;
-
- HBufferImage.MousePosition.Row = 2;
- HBufferImage.MousePosition.Column = 10;
-
- HBufferImage.LowVisibleRow = 1;
- HBufferImage.HighBits = TRUE;
-
- HBufferImage.BufferPosition.Row = 1;
- HBufferImage.BufferPosition.Column = 1;
-
- if (!Recover) {
- Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines);
- if (Str == NULL) {
- StatusBarSetStatusString (L"Read Memory Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- StatusBarSetStatusString (Str);
- SHELL_FREE_NON_NULL (Str);
-
- HMainEditor.SelectStart = 0;
- HMainEditor.SelectEnd = 0;
-
- }
-
- //
- // has line
- //
- if (HBufferImage.Lines != NULL) {
- HBufferImage.CurrentLine = CR (HBufferImage.ListHead->ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- } else {
- //
- // create a dummy line
- //
- Line = HBufferImageCreateLine ();
- if (Line == NULL) {
- StatusBarSetStatusString (L"Read Memory Failed");
- return EFI_OUT_OF_RESOURCES;
- }
-
- HBufferImage.CurrentLine = Line;
- }
-
- HBufferImage.Modified = FALSE;
- HBufferImageNeedRefresh = TRUE;
- HBufferImageOnlyLineNeedRefresh = FALSE;
- HBufferImageMouseNeedRefresh = TRUE;
-
- return EFI_SUCCESS;
-
-}
-
-/**
- Save lines in HBufferImage to disk.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageSave (
- IN UINTN Offset,
- IN UINTN Size
- )
-{
-
- EFI_STATUS Status;
- VOID *Buffer;
-
- //
- // not modified, so directly return
- //
- if (HBufferImage.Modified == FALSE) {
- return EFI_SUCCESS;
- }
-
- HBufferImage.BufferType = FileTypeMemBuffer;
-
- Buffer = AllocateZeroPool (Size);
-
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = HBufferImageListToBuffer (Buffer, Size);
- if (EFI_ERROR (Status)) {
- FreePool (Buffer);
- return Status;
- }
- //
- // write back to memory
- //
- Status = HMemImage.IoFncs->Mem.Write (
- HMemImage.IoFncs,
- EfiPciWidthUint8,
- Offset,
- Size,
- Buffer
- );
-
- FreePool (Buffer);
-
- if (EFI_ERROR (Status)) {
- return EFI_LOAD_ERROR;
- }
- //
- // now not modified
- //
- HBufferImage.Modified = FALSE;
-
- return EFI_SUCCESS;
-}
-
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.h
deleted file mode 100644
index 54fe517858..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/** @file
- Defines MemImage - the view of the file that is visible at any point,
- as well as the event handlers for editing the file
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_MEM_IMAGE_H_
-#define _LIB_MEM_IMAGE_H_
-
-#include "HexEditor.h"
-
-/**
- Initialization function for HDiskImage.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_LOAD_ERROR A load error occured.
-**/
-EFI_STATUS
-HMemImageInit (
- VOID
- );
-
-/**
- Backup function for HDiskImage. Only a few fields need to be backup.
- This is for making the Disk buffer refresh as few as possible.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HMemImageBackup (
- VOID
- );
-
-/**
- Set FileName field in HFileImage.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageSetMemOffsetSize (
- IN UINTN Offset,
- IN UINTN Size
- );
-
-/**
- Read a disk from disk into HBufferImage.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
- @param[in] Recover if is for recover, no information print.
-
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageRead (
- IN UINTN Offset,
- IN UINTN Size,
- IN BOOLEAN Recover
- );
-
-/**
- Save lines in HBufferImage to disk.
-
- @param[in] Offset The offset.
- @param[in] Size The size.
-
- @retval EFI_LOAD_ERROR A load error occured.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-HMemImageSave (
- IN UINTN Offset,
- IN UINTN Size
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c
deleted file mode 100644
index c3ed341936..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/** @file
- Implementation of various string and line routines
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "HexEditor.h"
-
-extern BOOLEAN HEditorMouseAction;
-
-/**
- Free a line and it's internal buffer.
-
- @param[in] Src The line to be freed.
-**/
-VOID
-HLineFree (
- IN HEFI_EDITOR_LINE *Src
- )
-{
- if (Src == NULL) {
- return ;
- }
-
- SHELL_FREE_NON_NULL (Src);
-
-}
-
-/**
- Advance to the next Count lines.
-
- @param[in] Count The line number to advance.
-
- @retval NULL An error occured.
- @return A pointer to the line after advance.
-**/
-HEFI_EDITOR_LINE *
-HLineAdvance (
- IN UINTN Count
- )
-{
- UINTN Index;
- HEFI_EDITOR_LINE *Line;
-
- Line = HMainEditor.BufferImage->CurrentLine;
- if (Line == NULL) {
- return NULL;
- }
-
- for (Index = 0; Index < Count; Index++) {
- //
- // if already last line
- //
- if (Line->Link.ForwardLink == HMainEditor.BufferImage->ListHead) {
- return NULL;
- }
-
- Line = CR (Line->Link.ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- }
-
- return Line;
-}
-
-/**
- Retreat to the previous Count lines.
-
- @param[in] Count The line number to retreat.
-
- @retval NULL An error occured.
- @return A pointer to the line after retreat.
-**/
-HEFI_EDITOR_LINE *
-HLineRetreat (
- IN UINTN Count
- )
-{
- UINTN Index;
- HEFI_EDITOR_LINE *Line;
-
- Line = HMainEditor.BufferImage->CurrentLine;
- if (Line == NULL) {
- return NULL;
- }
-
- for (Index = 0; Index < Count; Index++) {
- //
- // already the first line
- //
- if (Line->Link.BackLink == HMainEditor.BufferImage->ListHead) {
- return NULL;
- }
-
- Line = CR (Line->Link.BackLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- }
-
- return Line;
-}
-
-/**
- Advance/Retreat lines.
-
- @param[in] Count The line number to advance/retreat.
- >0 : advance
- <0: retreat
-
- @retval NULL An error occured.
- @return A pointer to the line after move.
-**/
-HEFI_EDITOR_LINE *
-HMoveLine (
- IN INTN Count
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN AbsCount;
-
- //
- // difference with MoveCurrentLine
- // just return Line
- // do not set currentline to Line
- //
- if (Count <= 0) {
- AbsCount = (UINTN)ABS(Count);
- Line = HLineRetreat (AbsCount);
- } else {
- Line = HLineAdvance ((UINTN)Count);
- }
-
- return Line;
-}
-
-/**
- Advance/Retreat lines and set CurrentLine in BufferImage to it.
-
- @param[in] Count The line number to advance/retreat.
- >0 : advance
- <0: retreat
-
- @retval NULL An error occured.
- @return A pointer to the line after move.
-**/
-HEFI_EDITOR_LINE *
-HMoveCurrentLine (
- IN INTN Count
- )
-{
- HEFI_EDITOR_LINE *Line;
- UINTN AbsCount;
-
- //
- // <0: retreat
- // >0: advance
- //
- if (Count <= 0) {
- AbsCount = (UINTN)ABS(Count);
- Line = HLineRetreat (AbsCount);
- } else {
- Line = HLineAdvance ((UINTN)Count);
- }
-
- if (Line == NULL) {
- return NULL;
- }
-
- HMainEditor.BufferImage->CurrentLine = Line;
-
- return Line;
-}
-
-
-/**
- Free all the lines in HBufferImage.
- Fields affected:
- Lines
- CurrentLine
- NumLines
- ListHead
-
- @param[in] ListHead The list head.
- @param[in] Lines The lines.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFreeLines (
- IN LIST_ENTRY *ListHead,
- IN HEFI_EDITOR_LINE *Lines
- )
-{
- LIST_ENTRY *Link;
- HEFI_EDITOR_LINE *Line;
-
- //
- // release all the lines
- //
- if (Lines != NULL) {
-
- Line = Lines;
- Link = &(Line->Link);
- do {
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
- Link = Link->ForwardLink;
- HLineFree (Line);
- } while (Link != ListHead);
- }
-
- ListHead->ForwardLink = ListHead;
- ListHead->BackLink = ListHead;
-
- return EFI_SUCCESS;
-}
-
-/**
- Get the X information for the mouse.
-
- @param[in] GuidX The change.
-
- @return the new information.
-**/
-INT32
-HGetTextX (
- IN INT32 GuidX
- )
-{
- INT32 Gap;
-
- HMainEditor.MouseAccumulatorX += GuidX;
- Gap = (HMainEditor.MouseAccumulatorX * (INT32) HMainEditor.ScreenSize.Column) / (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionX);
- HMainEditor.MouseAccumulatorX = (HMainEditor.MouseAccumulatorX * (INT32) HMainEditor.ScreenSize.Column) % (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionX);
- HMainEditor.MouseAccumulatorX = HMainEditor.MouseAccumulatorX / (INT32) HMainEditor.ScreenSize.Column;
- return Gap;
-}
-
-/**
- Get the Y information for the mouse.
-
- @param[in] GuidY The change.
-
- @return the new information.
-**/
-INT32
-HGetTextY (
- IN INT32 GuidY
- )
-{
- INT32 Gap;
-
- HMainEditor.MouseAccumulatorY += GuidY;
- Gap = (HMainEditor.MouseAccumulatorY * (INT32) HMainEditor.ScreenSize.Row) / (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionY);
- HMainEditor.MouseAccumulatorY = (HMainEditor.MouseAccumulatorY * (INT32) HMainEditor.ScreenSize.Row) % (INT32) (50 * (INT32) HMainEditor.MouseInterface->Mode->ResolutionY);
- HMainEditor.MouseAccumulatorY = HMainEditor.MouseAccumulatorY / (INT32) HMainEditor.ScreenSize.Row;
-
- return Gap;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.h
deleted file mode 100644
index df947935b0..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Misc.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/** @file
- Definitions for various line and string routines
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _LIB_MISC_H_
-#define _LIB_MISC_H_
-
-#include "HexEditor.h"
-
-/**
- Advance/Retreat lines.
-
- @param[in] Count The line number to advance/retreat.
- >0 : advance
- <0: retreat
-
- @retval NULL An error occured.
- @return A pointer to the line after move.
-**/
-HEFI_EDITOR_LINE *
-HMoveLine (
- IN INTN Count
- );
-
-/**
- Advance/Retreat lines and set CurrentLine in BufferImage to it.
-
- @param[in] Count The line number to advance/retreat.
- >0 : advance
- <0: retreat
-
- @retval NULL An error occured.
- @return A pointer to the line after move.
-**/
-HEFI_EDITOR_LINE *
-HMoveCurrentLine (
- IN INTN Count
- );
-
-/**
- Free all the lines in HBufferImage.
- Fields affected:
- Lines
- CurrentLine
- NumLines
- ListHead
-
- @param[in] ListHead The list head.
- @param[in] Lines The lines.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-HFreeLines (
- IN LIST_ENTRY *ListHead,
- IN HEFI_EDITOR_LINE *Lines
- );
-
-/**
- Get the X information for the mouse.
-
- @param[in] GuidX The change.
-
- @return the new information.
-**/
-INT32
-HGetTextX (
- IN INT32 GuidX
- );
-
-/**
- Get the Y information for the mouse.
-
- @param[in] GuidY The change.
-
- @return the new information.
-**/
-INT32
-HGetTextY (
- IN INT32 GuidY
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c
deleted file mode 100644
index 1b94746933..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/** @file
- Main file for LoadPciRom shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <IndustryStandard/Pci22.h>
-#include <IndustryStandard/Pci23.h>
-#include <IndustryStandard/PeImage.h>
-#include <Protocol/Decompress.h>
-
-/**
- Connects all available drives and controllers.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_ABORTED The abort mechanism was received.
-**/
-EFI_STATUS
-EFIAPI
-LoadPciRomConnectAllDriversToAllControllers (
- VOID
- );
-
-/**
- Command entry point.
-
- @param[in] RomBar The Rom Base address.
- @param[in] RomSize The Rom size.
- @param[in] FileName The file name.
-
- @retval EFI_SUCCESS The command completed successfully.
- @retval EFI_INVALID_PARAMETER Command usage error.
- @retval EFI_UNSUPPORTED Protocols unsupported.
- @retval EFI_OUT_OF_RESOURCES Out of memory.
- @retval Other value Unknown error.
-**/
-EFI_STATUS
-EFIAPI
-LoadEfiDriversFromRomImage (
- VOID *RomBar,
- UINTN RomSize,
- CONST CHAR16 *FileName
- );
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-nc", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'loadpcirom' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLoadPciRom (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_SHELL_FILE_INFO *FileList;
- UINTN SourceSize;
- UINT8 *File1Buffer;
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- BOOLEAN Connect;
- CONST CHAR16 *Param;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *Node;
- //
- // Local variable initializations
- //
- File1Buffer = NULL;
- ShellStatus = SHELL_SUCCESS;
- FileList = NULL;
-
-
- //
- // verify number of arguments
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"loadpcirom", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"loadpcirom");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellCommandLineGetFlag(Package, L"-nc")) {
- Connect = FALSE;
- } else {
- Connect = TRUE;
- }
-
- //
- // get a list with each file specified by parameters
- // if parameter is a directory then add all the files below it to the list
- //
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ; Param != NULL
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param);
- ShellStatus = SHELL_ACCESS_DENIED;
- break;
- }
- }
- if (ShellStatus == SHELL_SUCCESS && FileList != NULL) {
- //
- // loop through the list and make sure we are not aborting...
- //
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
- ){
- if (EFI_ERROR(Node->Status)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- continue;
- }
- if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- continue;
- }
- SourceSize = (UINTN) Node->Info->FileSize;
- File1Buffer = AllocateZeroPool (SourceSize);
- ASSERT(File1Buffer != NULL);
- Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = LoadEfiDriversFromRomImage (
- File1Buffer,
- SourceSize,
- Node->FullName
- );
-
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);
- }
- FreePool(File1Buffer);
- }
- } else if (ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom");
- ShellStatus = SHELL_NOT_FOUND;
- }
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- Status = ShellCloseFileMetaArg(&FileList);
- }
- FileList = NULL;
-
- if (Connect) {
- Status = LoadPciRomConnectAllDriversToAllControllers ();
- }
- }
- }
-
- return (ShellStatus);
-}
-
-/**
- Command entry point.
-
- @param[in] RomBar The Rom Base address.
- @param[in] RomSize The Rom size.
- @param[in] FileName The file name.
-
- @retval EFI_SUCCESS The command completed successfully.
- @retval EFI_INVALID_PARAMETER Command usage error.
- @retval EFI_UNSUPPORTED Protocols unsupported.
- @retval EFI_OUT_OF_RESOURCES Out of memory.
- @retval Other value Unknown error.
-**/
-EFI_STATUS
-EFIAPI
-LoadEfiDriversFromRomImage (
- VOID *RomBar,
- UINTN RomSize,
- CONST CHAR16 *FileName
- )
-
-{
- EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader;
- PCI_DATA_STRUCTURE *Pcir;
- UINTN ImageIndex;
- UINTN RomBarOffset;
- UINT32 ImageSize;
- UINT16 ImageOffset;
- EFI_HANDLE ImageHandle;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
- CHAR16 RomFileName[280];
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- BOOLEAN SkipImage;
- UINT32 DestinationSize;
- UINT32 ScratchSize;
- UINT8 *Scratch;
- VOID *ImageBuffer;
- VOID *DecompressedImageBuffer;
- UINT32 ImageLength;
- EFI_DECOMPRESS_PROTOCOL *Decompress;
- UINT32 InitializationSize;
-
- ImageIndex = 0;
- ReturnStatus = EFI_NOT_FOUND;
- RomBarOffset = (UINTN) RomBar;
-
- do {
-
- EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;
-
- if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
-// PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex);
- return ReturnStatus;
- }
-
- //
- // If the pointer to the PCI Data Structure is invalid, no further images can be located.
- // The PCI Data Structure must be DWORD aligned.
- //
- if (EfiRomHeader->PcirOffset == 0 ||
- (EfiRomHeader->PcirOffset & 3) != 0 ||
- RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
- break;
- }
-
- Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);
- //
- // If a valid signature is not present in the PCI Data Structure, no further images can be located.
- //
- if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
- break;
- }
- ImageSize = Pcir->ImageLength * 512;
- if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {
- break;
- }
-
- if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
- (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
- ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
- (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
-
- ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
- InitializationSize = EfiRomHeader->InitializationSize * 512;
-
- if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
-
- ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset);
- ImageLength = InitializationSize - ImageOffset;
- DecompressedImageBuffer = NULL;
-
- //
- // decompress here if needed
- //
- SkipImage = FALSE;
- if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
- SkipImage = TRUE;
- }
-
- if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
- Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR (Status)) {
- SkipImage = TRUE;
- } else {
- SkipImage = TRUE;
- Status = Decompress->GetInfo (
- Decompress,
- ImageBuffer,
- ImageLength,
- &DestinationSize,
- &ScratchSize
- );
- if (!EFI_ERROR (Status)) {
- DecompressedImageBuffer = AllocateZeroPool (DestinationSize);
- if (ImageBuffer != NULL) {
- Scratch = AllocateZeroPool (ScratchSize);
- if (Scratch != NULL) {
- Status = Decompress->Decompress (
- Decompress,
- ImageBuffer,
- ImageLength,
- DecompressedImageBuffer,
- DestinationSize,
- Scratch,
- ScratchSize
- );
- if (!EFI_ERROR (Status)) {
- ImageBuffer = DecompressedImageBuffer;
- ImageLength = DestinationSize;
- SkipImage = FALSE;
- }
-
- FreePool (Scratch);
- }
- }
- }
- }
- }
-
- if (!SkipImage) {
- //
- // load image and start image
- //
- UnicodeSPrint (RomFileName, sizeof (RomFileName), L"%s[%d]", FileName, ImageIndex);
- FilePath = FileDevicePath (NULL, RomFileName);
-
- Status = gBS->LoadImage (
- TRUE,
- gImageHandle,
- FilePath,
- ImageBuffer,
- ImageLength,
- &ImageHandle
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
-// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
- } else {
- Status = gBS->StartImage (ImageHandle, NULL, NULL);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
-// PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status);
- } else {
- ReturnStatus = Status;
- }
- }
- }
-
- if (DecompressedImageBuffer != NULL) {
- FreePool (DecompressedImageBuffer);
- }
-
- }
- }
-
- RomBarOffset = RomBarOffset + ImageSize;
- ImageIndex++;
- } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));
-
- return ReturnStatus;
-}
-
-/**
- Connects all available drives and controllers.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_ABORTED The abort mechanism was received.
-**/
-EFI_STATUS
-EFIAPI
-LoadPciRomConnectAllDriversToAllControllers (
- VOID
- )
-
-{
- EFI_STATUS Status;
- UINTN AllHandleCount;
- EFI_HANDLE *AllHandleBuffer;
- UINTN Index;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN *HandleType;
- UINTN HandleIndex;
- BOOLEAN Parent;
- BOOLEAN Device;
-
- Status = gBS->LocateHandleBuffer(
- AllHandles,
- NULL,
- NULL,
- &AllHandleCount,
- &AllHandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < AllHandleCount; Index++) {
- if (ShellGetExecutionBreakFlag ()) {
- Status = EFI_ABORTED;
- goto Done;
- }
- //
- // Scan the handle database
- //
- Status = ParseHandleDatabaseByRelationshipWithType(
- NULL,
- AllHandleBuffer[Index],
- &HandleCount,
- &HandleBuffer,
- &HandleType
- );
-/*
- Status = LibScanHandleDatabase (
- NULL,
- NULL,
- AllHandleBuffer[Index],
- NULL,
- &HandleCount,
- &HandleBuffer,
- &HandleType
- );
-*/
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- Device = TRUE;
- if ((HandleType[Index] & HR_DRIVER_BINDING_HANDLE) != 0) {
- Device = FALSE;
- }
-
- if ((HandleType[Index] & HR_IMAGE_HANDLE) != 0) {
- Device = FALSE;
- }
-
- if (Device) {
- Parent = FALSE;
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- if ((HandleType[HandleIndex] & HR_PARENT_HANDLE) != 0) {
- Parent = TRUE;
- }
- }
-
- if (!Parent) {
- if ((HandleType[Index] & HR_DEVICE_HANDLE) != 0) {
- Status = gBS->ConnectController (
- AllHandleBuffer[Index],
- NULL,
- NULL,
- TRUE
- );
- }
- }
- }
-
- FreePool (HandleBuffer);
- FreePool (HandleType);
- }
-
-Done:
- FreePool (AllHandleBuffer);
- return Status;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c
deleted file mode 100644
index 81c561f680..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/** @file
- Main file for Mode shell Debug1 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which acModeanies 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.
-
-**/
-
-//
-// Need full names for Standard-Format Output
-//
-STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
-STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
-STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
-STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
-STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
-STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
-STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
-STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
-STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
-STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
-STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
-STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
-STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
-STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
-STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
-
-//
-// Need short names for some memory types
-//
-STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
-STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
-STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
-STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
-STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
-STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
-STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
-STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
-STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
-
-#include "UefiShellDebug1CommandsLib.h"
-
-/**
- Function for 'memmap' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMemMap (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN Size;
- EFI_MEMORY_DESCRIPTOR *Buffer;
- UINTN MapKey;
- UINTN ItemSize;
- UINT32 Version;
- UINT8 *Walker;
- UINT64 ReservedPages;
- UINT64 LoadCodePages;
- UINT64 LoadDataPages;
- UINT64 BSCodePages;
- UINT64 BSDataPages;
- UINT64 RTDataPages;
- UINT64 RTCodePages;
- UINT64 AvailPages;
- UINT64 TotalPages;
- UINT64 ReservedPagesSize;
- UINT64 LoadCodePagesSize;
- UINT64 LoadDataPagesSize;
- UINT64 BSCodePagesSize;
- UINT64 BSDataPagesSize;
- UINT64 RTDataPagesSize;
- UINT64 RTCodePagesSize;
- UINT64 AvailPagesSize;
- UINT64 TotalPagesSize;
- UINT64 AcpiReclaimPages;
- UINT64 AcpiNvsPages;
- UINT64 MmioSpacePages;
- UINT64 AcpiReclaimPagesSize;
- UINT64 AcpiNvsPagesSize;
- UINT64 MmioSpacePagesSize;
- UINT64 MmioPortPages;
- UINT64 MmioPortPagesSize;
- UINT64 UnusableMemoryPages;
- UINT64 UnusableMemoryPagesSize;
- UINT64 PalCodePages;
- UINT64 PalCodePagesSize;
- BOOLEAN Sfo;
-
- AcpiReclaimPages = 0;
- AcpiNvsPages = 0;
- MmioSpacePages = 0;
- TotalPages = 0;
- ReservedPages = 0;
- LoadCodePages = 0;
- LoadDataPages = 0;
- BSCodePages = 0;
- BSDataPages = 0;
- RTDataPages = 0;
- RTCodePages = 0;
- AvailPages = 0;
- MmioPortPages = 0;
- UnusableMemoryPages = 0;
- PalCodePages = 0;
- Size = 0;
- Buffer = NULL;
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
- if (Status == EFI_BUFFER_TOO_SMALL){
- Size += SIZE_1KB;
- Buffer = AllocateZeroPool(Size);
- Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
-
- Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
- if (!Sfo) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"memmap");
- }
-
- for (Walker = (UINT8*)Buffer; Walker < (((UINT8*)Buffer)+Size) && Walker != NULL; Walker += ItemSize){
- switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) {
- case EfiReservedMemoryType:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiLoaderCode:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiLoaderData:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiBootServicesCode:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiBootServicesCodeShort:NameEfiBootServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiBootServicesData:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiBootServicesDataShort:NameEfiBootServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiRuntimeServicesCode:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiRuntimeServicesCodeShort:NameEfiRuntimeServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiRuntimeServicesData:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiRuntimeServicesDataShort:NameEfiRuntimeServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiConventionalMemory:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiPersistentMemory:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPersistentMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiUnusableMemory:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiUnusableMemoryShort:NameEfiUnusableMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- UnusableMemoryPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiACPIReclaimMemory:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiACPIReclaimMemoryShort:NameEfiACPIReclaimMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- AcpiReclaimPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiACPIMemoryNVS:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiACPIMemoryNVSShort:NameEfiACPIMemoryNVS, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- AcpiNvsPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiMemoryMappedIO:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiMemoryMappedIOShort:NameEfiMemoryMappedIO, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- MmioSpacePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiMemoryMappedIOPortSpace:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo?NameEfiMemoryMappedIOPortSpaceShort:NameEfiMemoryMappedIOPortSpace, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- MmioPortPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- case EfiPalCode:
- ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
- TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- PalCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
- break;
- default:
- ASSERT(FALSE);
- }
- }
- //
- // print the summary
- //
- ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages);
- LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages);
- LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages);
- BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages);
- BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages);
- RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages);
- RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages);
- AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages);
- TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages);
- AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages);
- AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages);
- MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages);
- MmioPortPagesSize = MultU64x64(SIZE_4KB,MmioPortPages);
- PalCodePagesSize = MultU64x64(SIZE_4KB,PalCodePages);
- UnusableMemoryPagesSize = MultU64x64(SIZE_4KB,UnusableMemoryPages);
- if (!Sfo) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
- ReservedPages, ReservedPagesSize,
- LoadCodePages, LoadCodePagesSize,
- LoadDataPages, LoadDataPagesSize,
- BSCodePages, BSCodePagesSize,
- BSDataPages, BSDataPagesSize,
- RTCodePages, RTCodePagesSize,
- RTDataPages, RTDataPagesSize,
- AcpiReclaimPages, AcpiReclaimPagesSize,
- AcpiNvsPages, AcpiNvsPagesSize,
- MmioSpacePages, MmioSpacePagesSize,
- MmioPortPages, MmioPortPagesSize,
- PalCodePages, PalCodePagesSize,
- AvailPages, AvailPagesSize,
- DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
- );
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
- TotalPagesSize,
- ReservedPagesSize,
- BSCodePagesSize,
- BSDataPagesSize,
- RTCodePagesSize,
- RTDataPagesSize,
- LoadCodePagesSize,
- LoadDataPagesSize,
- AvailPagesSize,
- MmioSpacePagesSize,
- MmioPortPagesSize,
- UnusableMemoryPagesSize,
- AcpiReclaimPagesSize,
- AcpiNvsPagesSize,
- PalCodePagesSize
- );
- }
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
deleted file mode 100644
index ca64f2c5b0..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
+++ /dev/null
@@ -1,647 +0,0 @@
-/** @file
- Main file for Mm shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Library/ShellLib.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/DeviceIo.h>
-
-typedef enum {
- EfiMemory,
- EFIMemoryMappedIo,
- EfiIo,
- EfiPciConfig,
- EfiPciEConfig
-} EFI_ACCESS_TYPE;
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-mmio", TypeFlag},
- {L"-mem", TypeFlag},
- {L"-io", TypeFlag},
- {L"-pci", TypeFlag},
- {L"-pcie", TypeFlag},
- {L"-n", TypeFlag},
- {L"-w", TypeValue},
- {NULL, TypeMax}
- };
-
-STATIC CONST UINT64 MaxNum[9] = { 0xff, 0xffff, 0xffffffff, 0xffffffffffffffffULL };
-
-/**
- Read some data into a buffer from memory.
-
- @param[in] Width The width of each read.
- @param[in] Addresss The memory location to start reading at.
- @param[in] Size The size of Buffer in Width sized units.
- @param[out] Buffer The buffer to read into.
-**/
-VOID
-EFIAPI
-ReadMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Size,
- OUT VOID *Buffer
- )
-{
- //
- // This function is defective. This ASSERT prevents the defect from affecting anything.
- //
- ASSERT(Size == 1);
- do {
- if (Width == EfiPciWidthUint8) {
- *(UINT8 *) Buffer = *(UINT8 *) (UINTN) Address;
- Address -= 1;
- } else if (Width == EfiPciWidthUint16) {
- *(UINT16 *) Buffer = *(UINT16 *) (UINTN) Address;
- Address -= 2;
- } else if (Width == EfiPciWidthUint32) {
- *(UINT32 *) Buffer = *(UINT32 *) (UINTN) Address;
- Address -= 4;
- } else if (Width == EfiPciWidthUint64) {
- *(UINT64 *) Buffer = *(UINT64 *) (UINTN) Address;
- Address -= 8;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_READ_ERROR), gShellDebug1HiiHandle, L"mm");
- break;
- }
- Size--;
- } while (Size > 0);
-}
-
-/**
- Write some data to memory.
-
- @param[in] Width The width of each write.
- @param[in] Addresss The memory location to start writing at.
- @param[in] Size The size of Buffer in Width sized units.
- @param[in] Buffer The buffer to write from.
-**/
-VOID
-EFIAPI
-WriteMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Size,
- IN VOID *Buffer
- )
-{
- //
- // This function is defective. This ASSERT prevents the defect from affecting anything.
- //
- ASSERT(Size == 1);
- do {
- if (Width == EfiPciWidthUint8) {
- *(UINT8 *) (UINTN) Address = *(UINT8 *) Buffer;
- Address += 1;
- } else if (Width == EfiPciWidthUint16) {
- *(UINT16 *) (UINTN) Address = *(UINT16 *) Buffer;
- Address += 2;
- } else if (Width == EfiPciWidthUint32) {
- *(UINT32 *) (UINTN) Address = *(UINT32 *) Buffer;
- Address += 4;
- } else if (Width == EfiPciWidthUint64) {
- *(UINT64 *) (UINTN) Address = *(UINT64 *) Buffer;
- Address += 8;
- } else {
- ASSERT (FALSE);
- }
- //
- //
- //
- Size--;
- } while (Size > 0);
-}
-
-/**
- Convert a string to it's hex data.
-
- @param[in] str The pointer to the string of hex data.
- @param[out] data The pointer to the buffer to fill. Valid upon a TRUE return.
-
- @retval TRUE The conversion was successful.
- @retval FALSE The conversion failed.
-**/
-BOOLEAN
-EFIAPI
-GetHex (
- IN UINT16 *str,
- OUT UINT64 *data
- )
-{
- UINTN TempUint;
- CHAR16 TempChar;
- BOOLEAN Find;
-
- Find = FALSE;
- //
- // convert hex digits
- //
- TempUint = 0;
- TempChar = *(str++);
- while (TempChar != CHAR_NULL) {
- if (TempChar >= 'a' && TempChar <= 'f') {
- TempChar -= 'a' - 'A';
- }
-
- if (TempChar == ' ') {
- break;
- }
-
- if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {
- TempUint = (TempUint << 4) | (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));
-
- Find = TRUE;
- } else {
- return FALSE;
- }
-
- TempChar = *(str++);
- }
-
- *data = TempUint;
- return Find;
-}
-
-/**
- Get the PCI-E Address from a PCI address format 0x0000ssbbddffrrr
- where ss is SEGMENT, bb is BUS, dd is DEVICE, ff is FUNCTION
- and rrr is REGISTER (extension format for PCI-E).
-
- @param[in] InputAddress PCI address format on input.
- @param[out]PciEAddress PCI-E address extention format.
-**/
-VOID
-EFIAPI
-GetPciEAddressFromInputAddress (
- IN UINT64 InputAddress,
- OUT UINT64 *PciEAddress
- )
-{
- *PciEAddress = RShiftU64(InputAddress & ~(UINT64) 0xFFF, 4);
- *PciEAddress += LShiftU64((UINT16) InputAddress & 0x0FFF, 32);
-}
-
-/**
- Function for 'mm' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMm (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev;
- UINT64 Address;
- UINT64 PciEAddress;
- UINT64 Value;
- UINT32 SegmentNumber;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width;
- EFI_ACCESS_TYPE AccessType;
- UINT64 Buffer;
- UINTN Index;
- UINTN Size;
-// CHAR16 *ValueStr;
- BOOLEAN Complete;
- CHAR16 *InputStr;
- BOOLEAN Interactive;
- EFI_HANDLE *HandleBuffer;
- UINTN BufferSize;
- UINTN ItemValue;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Temp;
-
- Value = 0;
- Address = 0;
- PciEAddress = 0;
- IoDev = NULL;
- HandleBuffer = NULL;
- BufferSize = 0;
- SegmentNumber = 0;
- ShellStatus = SHELL_SUCCESS;
- InputStr = NULL;
-
- //
- // Parse arguments
- //
- Width = EfiPciWidthUint8;
- Size = 1;
- AccessType = EfiMemory;
-// ValueStr = NULL;
- Interactive = TRUE;
- Package = NULL;
-
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mm", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else if (ShellCommandLineGetFlag(Package, L"-w") && ShellCommandLineGetValue(Package, L"-w") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"mm", L"-w");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else {
- if (ShellCommandLineGetFlag(Package, L"-mmio")) {
- AccessType = EFIMemoryMappedIo;
- if (ShellCommandLineGetFlag(Package, L"-mem")
- ||ShellCommandLineGetFlag(Package, L"-io")
- ||ShellCommandLineGetFlag(Package, L"-pci")
- ||ShellCommandLineGetFlag(Package, L"-pcie")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- } else if (ShellCommandLineGetFlag(Package, L"-mem")) {
- AccessType = EfiMemory;
- if (ShellCommandLineGetFlag(Package, L"-io")
- ||ShellCommandLineGetFlag(Package, L"-pci")
- ||ShellCommandLineGetFlag(Package, L"-pcie")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- } else if (ShellCommandLineGetFlag(Package, L"-io")) {
- AccessType = EfiIo;
- if (ShellCommandLineGetFlag(Package, L"-pci")
- ||ShellCommandLineGetFlag(Package, L"-pcie")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- } else if (ShellCommandLineGetFlag(Package, L"-pci")) {
- AccessType = EfiPciConfig;
- if (ShellCommandLineGetFlag(Package, L"-pcie")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- } else if (ShellCommandLineGetFlag(Package, L"-pcie")) {
- AccessType = EfiPciEConfig;
- }
- }
-
- //
- // Non interactive for a script file or for the specific parameter
- //
- if (gEfiShellProtocol->BatchIsActive() || ShellCommandLineGetFlag (Package, L"-n")) {
- Interactive = FALSE;
- }
-
- Temp = ShellCommandLineGetValue(Package, L"-w");
- if (Temp != NULL) {
- ItemValue = ShellStrToUintn (Temp);
-
- switch (ItemValue) {
- case 1:
- Width = EfiPciWidthUint8;
- Size = 1;
- break;
-
- case 2:
- Width = EfiPciWidthUint16;
- Size = 2;
- break;
-
- case 4:
- Width = EfiPciWidthUint32;
- Size = 4;
- break;
-
- case 8:
- Width = EfiPciWidthUint64;
- Size = 8;
- break;
-
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"mm", Temp, L"-w");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- Temp = ShellCommandLineGetRawValue(Package, 1);
- if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, (UINT64*)&Address, TRUE, FALSE))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mm", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- Temp = ShellCommandLineGetRawValue(Package, 2);
- if (Temp != NULL) {
- //
- // Per spec if value is specified, then -n is assumed.
- //
- Interactive = FALSE;
-
- if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, &Value, TRUE, FALSE))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mm", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- switch (Size) {
- case 1:
- if (Value > 0xFF) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- break;
-
- case 2:
- if (Value > 0xFFFF) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- break;
-
- case 4:
- if (Value > 0xFFFFFFFF) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- break;
-
- default:
- break;
- }
-
- if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mm", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- if ((Address & (Size - 1)) != 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_NOT_ALIGNED), gShellDebug1HiiHandle, L"mm", Address);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- //
- // locate DeviceIO protocol interface
- //
- if (AccessType != EfiMemory) {
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &BufferSize,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- //
- // In the case of PCI or PCIE
- // Get segment number and mask the segment bits in Address
- //
- if (AccessType == EfiPciEConfig) {
- SegmentNumber = (UINT32) RShiftU64 (Address, 36) & 0xff;
- Address &= 0xfffffffffULL;
- } else {
- if (AccessType == EfiPciConfig) {
- SegmentNumber = (UINT32) RShiftU64 (Address, 32) & 0xff;
- Address &= 0xffffffff;
- }
- }
- //
- // Find the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL of the specified segment number
- //
- for (Index = 0; Index < BufferSize; Index++) {
- Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiPciRootBridgeIoProtocolGuid,
- (VOID *) &IoDev
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
- if (IoDev->SegmentNumber != SegmentNumber) {
- IoDev = NULL;
- }
- }
- if (IoDev == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_SEGMENT_NOT_FOUND), gShellDebug1HiiHandle, L"mm", SegmentNumber);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- if (AccessType == EfiIo && Address + Size > 0x10000) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS_RANGE), gShellDebug1HiiHandle, L"mm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- if (AccessType == EfiPciEConfig) {
- GetPciEAddressFromInputAddress (Address, &PciEAddress);
- }
-
- //
- // Set value
- //
- if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- if (AccessType == EFIMemoryMappedIo) {
- IoDev->Mem.Write (IoDev, Width, Address, 1, &Value);
- } else if (AccessType == EfiIo) {
- IoDev->Io.Write (IoDev, Width, Address, 1, &Value);
- } else if (AccessType == EfiPciConfig) {
- IoDev->Pci.Write (IoDev, Width, Address, 1, &Value);
- } else if (AccessType == EfiPciEConfig) {
- IoDev->Pci.Write (IoDev, Width, PciEAddress, 1, &Value);
- } else {
- WriteMem (Width, Address, 1, &Value);
- }
-
- ASSERT(ShellStatus == SHELL_SUCCESS);
- goto Done;
- }
-
-
- //
- // non-interactive mode
- //
- if (!Interactive) {
- Buffer = 0;
- if (AccessType == EFIMemoryMappedIo) {
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle);
- }
- IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiIo) {
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle);
- }
- IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciConfig) {
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle);
- }
- IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciEConfig) {
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle);
- }
- IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer);
- } else {
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle);
- }
- ReadMem (Width, Address, 1, &Buffer);
- }
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
- }
- if (Size == 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF4), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF8), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 8) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF16), gShellDebug1HiiHandle, Buffer);
- }
-
- ShellPrintEx(-1, -1, L"\r\n");
-
- ASSERT(ShellStatus == SHELL_SUCCESS);
- goto Done;
- }
- //
- // interactive mode
- //
- Complete = FALSE;
- do {
- if (AccessType == EfiIo && Address + Size > 0x10000) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS_RANGE2), gShellDebug1HiiHandle, L"mm");
- break;
- }
-
- Buffer = 0;
- if (AccessType == EFIMemoryMappedIo) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle);
- IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiIo) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle);
- IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciConfig) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle);
- IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciEConfig) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle);
- IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle);
- ReadMem (Width, Address, 1, &Buffer);
- }
-
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
-
- if (Size == 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF4), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF8), gShellDebug1HiiHandle, (UINTN)Buffer);
- } else if (Size == 8) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF16), gShellDebug1HiiHandle, Buffer);
- }
- ShellPrintEx(-1, -1, L" > ");
- //
- // wait user input to modify
- //
- if (InputStr != NULL) {
- FreePool(InputStr);
- InputStr = NULL;
- }
- ShellPromptForResponse(ShellPromptResponseTypeFreeform, NULL, (VOID**)&InputStr);
-
- //
- // skip space characters
- //
- for (Index = 0; InputStr != NULL && InputStr[Index] == ' '; Index++);
-
- //
- // parse input string
- //
- if (InputStr != NULL && (InputStr[Index] == '.' || InputStr[Index] == 'q' || InputStr[Index] == 'Q')) {
- Complete = TRUE;
- } else if (InputStr == NULL || InputStr[Index] == CHAR_NULL) {
- //
- // Continue to next address
- //
- } else if (GetHex (InputStr + Index, &Buffer) && Buffer <= MaxNum[Width]) {
- if (AccessType == EFIMemoryMappedIo) {
- IoDev->Mem.Write (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiIo) {
- IoDev->Io.Write (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciConfig) {
- IoDev->Pci.Write (IoDev, Width, Address, 1, &Buffer);
- } else if (AccessType == EfiPciEConfig) {
- IoDev->Pci.Write (IoDev, Width, PciEAddress, 1, &Buffer);
- } else {
- WriteMem (Width, Address, 1, &Buffer);
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle, L"mm");
- continue;
- // PrintToken (STRING_TOKEN (STR_IOMOD_ERROR), HiiHandle);
- }
-
- Address += Size;
- if (AccessType == EfiPciEConfig) {
- GetPciEAddressFromInputAddress (Address, &PciEAddress);
- }
- ShellPrintEx(-1, -1, L"\r\n");
- // Print (L"\n");
- } while (!Complete);
- }
- ASSERT(ShellStatus == SHELL_SUCCESS);
-Done:
-
- if (InputStr != NULL) {
- FreePool(InputStr);
- }
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c
deleted file mode 100644
index 7696e3fbbd..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/** @file
- Main file for Mode shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which acModeanies 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 "UefiShellDebug1CommandsLib.h"
-
-/**
- Function for 'mode' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMode (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN NewCol;
- UINTN NewRow;
- UINTN Col;
- UINTN Row;
- CONST CHAR16 *Temp;
- BOOLEAN Done;
- INT32 LoopVar;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mode", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) == 3) {
- Temp = ShellCommandLineGetRawValue(Package, 1);
- if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- NewCol = ShellStrToUintn(Temp);
- Temp = ShellCommandLineGetRawValue(Package, 2);
- if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- NewRow = ShellStrToUintn(Temp);
-
- for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
- Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
- if (EFI_ERROR(Status)) {
- continue;
- }
- if (Col == NewCol && Row == NewRow) {
- Status = gST->ConOut->SetMode(gST->ConOut, LoopVar);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode");
- ShellStatus = SHELL_DEVICE_ERROR;
- } else {
- // worked fine...
- Done = TRUE;
- }
- break;
- }
- }
-
- if (!Done) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
-
- } else if (ShellCommandLineGetCount(Package) == 1) {
- //
- // print out valid
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);
- for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
- Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
- if (EFI_ERROR(Status)) {
- continue;
- }
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode?L'*':L' ');
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
deleted file mode 100644
index df45cd68aa..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
+++ /dev/null
@@ -1,5922 +0,0 @@
-/** @file
- Main file for Pci shell Debug1 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Protocol/PciRootBridgeIo.h>
-#include <Library/ShellLib.h>
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Acpi.h>
-#include "Pci.h"
-
-//
-// Printable strings for Pci class code
-//
-typedef struct {
- CHAR16 *BaseClass; // Pointer to the PCI base class string
- CHAR16 *SubClass; // Pointer to the PCI sub class string
- CHAR16 *PIFClass; // Pointer to the PCI programming interface string
-} PCI_CLASS_STRINGS;
-
-//
-// a structure holding a single entry, which also points to its lower level
-// class
-//
-typedef struct PCI_CLASS_ENTRY_TAG {
- UINT8 Code; // Class, subclass or I/F code
- CHAR16 *DescText; // Description string
- struct PCI_CLASS_ENTRY_TAG *LowerLevelClass; // Subclass or I/F if any
-} PCI_CLASS_ENTRY;
-
-//
-// Declarations of entries which contain printable strings for class codes
-// in PCI configuration space
-//
-PCI_CLASS_ENTRY PCIBlankEntry[];
-PCI_CLASS_ENTRY PCISubClass_00[];
-PCI_CLASS_ENTRY PCISubClass_01[];
-PCI_CLASS_ENTRY PCISubClass_02[];
-PCI_CLASS_ENTRY PCISubClass_03[];
-PCI_CLASS_ENTRY PCISubClass_04[];
-PCI_CLASS_ENTRY PCISubClass_05[];
-PCI_CLASS_ENTRY PCISubClass_06[];
-PCI_CLASS_ENTRY PCISubClass_07[];
-PCI_CLASS_ENTRY PCISubClass_08[];
-PCI_CLASS_ENTRY PCISubClass_09[];
-PCI_CLASS_ENTRY PCISubClass_0a[];
-PCI_CLASS_ENTRY PCISubClass_0b[];
-PCI_CLASS_ENTRY PCISubClass_0c[];
-PCI_CLASS_ENTRY PCISubClass_0d[];
-PCI_CLASS_ENTRY PCISubClass_0e[];
-PCI_CLASS_ENTRY PCISubClass_0f[];
-PCI_CLASS_ENTRY PCISubClass_10[];
-PCI_CLASS_ENTRY PCISubClass_11[];
-PCI_CLASS_ENTRY PCISubClass_12[];
-PCI_CLASS_ENTRY PCISubClass_13[];
-PCI_CLASS_ENTRY PCIPIFClass_0100[];
-PCI_CLASS_ENTRY PCIPIFClass_0101[];
-PCI_CLASS_ENTRY PCIPIFClass_0105[];
-PCI_CLASS_ENTRY PCIPIFClass_0106[];
-PCI_CLASS_ENTRY PCIPIFClass_0107[];
-PCI_CLASS_ENTRY PCIPIFClass_0108[];
-PCI_CLASS_ENTRY PCIPIFClass_0109[];
-PCI_CLASS_ENTRY PCIPIFClass_0300[];
-PCI_CLASS_ENTRY PCIPIFClass_0604[];
-PCI_CLASS_ENTRY PCIPIFClass_0609[];
-PCI_CLASS_ENTRY PCIPIFClass_060b[];
-PCI_CLASS_ENTRY PCIPIFClass_0700[];
-PCI_CLASS_ENTRY PCIPIFClass_0701[];
-PCI_CLASS_ENTRY PCIPIFClass_0703[];
-PCI_CLASS_ENTRY PCIPIFClass_0800[];
-PCI_CLASS_ENTRY PCIPIFClass_0801[];
-PCI_CLASS_ENTRY PCIPIFClass_0802[];
-PCI_CLASS_ENTRY PCIPIFClass_0803[];
-PCI_CLASS_ENTRY PCIPIFClass_0904[];
-PCI_CLASS_ENTRY PCIPIFClass_0c00[];
-PCI_CLASS_ENTRY PCIPIFClass_0c03[];
-PCI_CLASS_ENTRY PCIPIFClass_0c07[];
-PCI_CLASS_ENTRY PCIPIFClass_0d01[];
-PCI_CLASS_ENTRY PCIPIFClass_0e00[];
-
-//
-// Base class strings entries
-//
-PCI_CLASS_ENTRY gClassStringList[] = {
- {
- 0x00,
- L"Pre 2.0 device",
- PCISubClass_00
- },
- {
- 0x01,
- L"Mass Storage Controller",
- PCISubClass_01
- },
- {
- 0x02,
- L"Network Controller",
- PCISubClass_02
- },
- {
- 0x03,
- L"Display Controller",
- PCISubClass_03
- },
- {
- 0x04,
- L"Multimedia Device",
- PCISubClass_04
- },
- {
- 0x05,
- L"Memory Controller",
- PCISubClass_05
- },
- {
- 0x06,
- L"Bridge Device",
- PCISubClass_06
- },
- {
- 0x07,
- L"Simple Communications Controllers",
- PCISubClass_07
- },
- {
- 0x08,
- L"Base System Peripherals",
- PCISubClass_08
- },
- {
- 0x09,
- L"Input Devices",
- PCISubClass_09
- },
- {
- 0x0a,
- L"Docking Stations",
- PCISubClass_0a
- },
- {
- 0x0b,
- L"Processors",
- PCISubClass_0b
- },
- {
- 0x0c,
- L"Serial Bus Controllers",
- PCISubClass_0c
- },
- {
- 0x0d,
- L"Wireless Controllers",
- PCISubClass_0d
- },
- {
- 0x0e,
- L"Intelligent IO Controllers",
- PCISubClass_0e
- },
- {
- 0x0f,
- L"Satellite Communications Controllers",
- PCISubClass_0f
- },
- {
- 0x10,
- L"Encryption/Decryption Controllers",
- PCISubClass_10
- },
- {
- 0x11,
- L"Data Acquisition & Signal Processing Controllers",
- PCISubClass_11
- },
- {
- 0x12,
- L"Processing Accelerators",
- PCISubClass_12
- },
- {
- 0x13,
- L"Non-Essential Instrumentation",
- PCISubClass_13
- },
- {
- 0xff,
- L"Device does not fit in any defined classes",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-//
-// Subclass strings entries
-//
-PCI_CLASS_ENTRY PCIBlankEntry[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_00[] = {
- {
- 0x00,
- L"All devices other than VGA",
- PCIBlankEntry
- },
- {
- 0x01,
- L"VGA-compatible devices",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_01[] = {
- {
- 0x00,
- L"SCSI",
- PCIPIFClass_0100
- },
- {
- 0x01,
- L"IDE controller",
- PCIPIFClass_0101
- },
- {
- 0x02,
- L"Floppy disk controller",
- PCIBlankEntry
- },
- {
- 0x03,
- L"IPI controller",
- PCIBlankEntry
- },
- {
- 0x04,
- L"RAID controller",
- PCIBlankEntry
- },
- {
- 0x05,
- L"ATA controller with ADMA interface",
- PCIPIFClass_0105
- },
- {
- 0x06,
- L"Serial ATA controller",
- PCIPIFClass_0106
- },
- {
- 0x07,
- L"Serial Attached SCSI (SAS) controller ",
- PCIPIFClass_0107
- },
- {
- 0x08,
- L"Non-volatile memory subsystem",
- PCIPIFClass_0108
- },
- {
- 0x09,
- L"Universal Flash Storage (UFS) controller ",
- PCIPIFClass_0109
- },
- {
- 0x80,
- L"Other mass storage controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_02[] = {
- {
- 0x00,
- L"Ethernet controller",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Token ring controller",
- PCIBlankEntry
- },
- {
- 0x02,
- L"FDDI controller",
- PCIBlankEntry
- },
- {
- 0x03,
- L"ATM controller",
- PCIBlankEntry
- },
- {
- 0x04,
- L"ISDN controller",
- PCIBlankEntry
- },
- {
- 0x05,
- L"WorldFip controller",
- PCIBlankEntry
- },
- {
- 0x06,
- L"PICMG 2.14 Multi Computing",
- PCIBlankEntry
- },
- {
- 0x07,
- L"InfiniBand controller",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other network controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_03[] = {
- {
- 0x00,
- L"VGA/8514 controller",
- PCIPIFClass_0300
- },
- {
- 0x01,
- L"XGA controller",
- PCIBlankEntry
- },
- {
- 0x02,
- L"3D controller",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other display controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */PCIBlankEntry
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_04[] = {
- {
- 0x00,
- L"Video device",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Audio device",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Computer Telephony device",
- PCIBlankEntry
- },
- {
- 0x03,
- L"Mixed mode device",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other multimedia device",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_05[] = {
- {
- 0x00,
- L"RAM memory controller",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Flash memory controller",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other memory controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_06[] = {
- {
- 0x00,
- L"Host/PCI bridge",
- PCIBlankEntry
- },
- {
- 0x01,
- L"PCI/ISA bridge",
- PCIBlankEntry
- },
- {
- 0x02,
- L"PCI/EISA bridge",
- PCIBlankEntry
- },
- {
- 0x03,
- L"PCI/Micro Channel bridge",
- PCIBlankEntry
- },
- {
- 0x04,
- L"PCI/PCI bridge",
- PCIPIFClass_0604
- },
- {
- 0x05,
- L"PCI/PCMCIA bridge",
- PCIBlankEntry
- },
- {
- 0x06,
- L"NuBus bridge",
- PCIBlankEntry
- },
- {
- 0x07,
- L"CardBus bridge",
- PCIBlankEntry
- },
- {
- 0x08,
- L"RACEway bridge",
- PCIBlankEntry
- },
- {
- 0x09,
- L"Semi-transparent PCI-to-PCI bridge",
- PCIPIFClass_0609
- },
- {
- 0x0A,
- L"InfiniBand-to-PCI host bridge",
- PCIBlankEntry
- },
- {
- 0x0B,
- L"Advanced Switching to PCI host bridge",
- PCIPIFClass_060b
- },
- {
- 0x80,
- L"Other bridge type",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_07[] = {
- {
- 0x00,
- L"Serial controller",
- PCIPIFClass_0700
- },
- {
- 0x01,
- L"Parallel port",
- PCIPIFClass_0701
- },
- {
- 0x02,
- L"Multiport serial controller",
- PCIBlankEntry
- },
- {
- 0x03,
- L"Modem",
- PCIPIFClass_0703
- },
- {
- 0x04,
- L"GPIB (IEEE 488.1/2) controller",
- PCIBlankEntry
- },
- {
- 0x05,
- L"Smart Card",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other communication device",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_08[] = {
- {
- 0x00,
- L"PIC",
- PCIPIFClass_0800
- },
- {
- 0x01,
- L"DMA controller",
- PCIPIFClass_0801
- },
- {
- 0x02,
- L"System timer",
- PCIPIFClass_0802
- },
- {
- 0x03,
- L"RTC controller",
- PCIPIFClass_0803
- },
- {
- 0x04,
- L"Generic PCI Hot-Plug controller",
- PCIBlankEntry
- },
- {
- 0x05,
- L"SD Host controller",
- PCIBlankEntry
- },
- {
- 0x06,
- L"IOMMU",
- PCIBlankEntry
- },
- {
- 0x07,
- L"Root Complex Event Collector",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other system peripheral",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_09[] = {
- {
- 0x00,
- L"Keyboard controller",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Digitizer (pen)",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Mouse controller",
- PCIBlankEntry
- },
- {
- 0x03,
- L"Scanner controller",
- PCIBlankEntry
- },
- {
- 0x04,
- L"Gameport controller",
- PCIPIFClass_0904
- },
- {
- 0x80,
- L"Other input controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0a[] = {
- {
- 0x00,
- L"Generic docking station",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other type of docking station",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0b[] = {
- {
- 0x00,
- L"386",
- PCIBlankEntry
- },
- {
- 0x01,
- L"486",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Pentium",
- PCIBlankEntry
- },
- {
- 0x10,
- L"Alpha",
- PCIBlankEntry
- },
- {
- 0x20,
- L"PowerPC",
- PCIBlankEntry
- },
- {
- 0x30,
- L"MIPS",
- PCIBlankEntry
- },
- {
- 0x40,
- L"Co-processor",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other processor",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0c[] = {
- {
- 0x00,
- L"IEEE 1394",
- PCIPIFClass_0c00
- },
- {
- 0x01,
- L"ACCESS.bus",
- PCIBlankEntry
- },
- {
- 0x02,
- L"SSA",
- PCIBlankEntry
- },
- {
- 0x03,
- L"USB",
- PCIPIFClass_0c03
- },
- {
- 0x04,
- L"Fibre Channel",
- PCIBlankEntry
- },
- {
- 0x05,
- L"System Management Bus",
- PCIBlankEntry
- },
- {
- 0x06,
- L"InfiniBand",
- PCIBlankEntry
- },
- {
- 0x07,
- L"IPMI",
- PCIPIFClass_0c07
- },
- {
- 0x08,
- L"SERCOS Interface Standard (IEC 61491)",
- PCIBlankEntry
- },
- {
- 0x09,
- L"CANbus",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other bus type",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0d[] = {
- {
- 0x00,
- L"iRDA compatible controller",
- PCIBlankEntry
- },
- {
- 0x01,
- L"",
- PCIPIFClass_0d01
- },
- {
- 0x10,
- L"RF controller",
- PCIBlankEntry
- },
- {
- 0x11,
- L"Bluetooth",
- PCIBlankEntry
- },
- {
- 0x12,
- L"Broadband",
- PCIBlankEntry
- },
- {
- 0x20,
- L"Ethernet (802.11a - 5 GHz)",
- PCIBlankEntry
- },
- {
- 0x21,
- L"Ethernet (802.11b - 2.4 GHz)",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other type of wireless controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0e[] = {
- {
- 0x00,
- L"I2O Architecture",
- PCIPIFClass_0e00
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_0f[] = {
- {
- 0x01,
- L"TV",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Audio",
- PCIBlankEntry
- },
- {
- 0x03,
- L"Voice",
- PCIBlankEntry
- },
- {
- 0x04,
- L"Data",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other satellite communication controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_10[] = {
- {
- 0x00,
- L"Network & computing Encrypt/Decrypt",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Entertainment Encrypt/Decrypt",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other Encrypt/Decrypt",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_11[] = {
- {
- 0x00,
- L"DPIO modules",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Performance Counters",
- PCIBlankEntry
- },
- {
- 0x10,
- L"Communications synchronization plus time and frequency test/measurement ",
- PCIBlankEntry
- },
- {
- 0x20,
- L"Management card",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Other DAQ & SP controllers",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_12[] = {
- {
- 0x00,
- L"Processing Accelerator",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCISubClass_13[] = {
- {
- 0x00,
- L"Non-Essential Instrumentation Function",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-//
-// Programming Interface entries
-//
-PCI_CLASS_ENTRY PCIPIFClass_0100[] = {
- {
- 0x00,
- L"SCSI controller",
- PCIBlankEntry
- },
- {
- 0x11,
- L"SCSI storage device SOP using PQI",
- PCIBlankEntry
- },
- {
- 0x12,
- L"SCSI controller SOP using PQI",
- PCIBlankEntry
- },
- {
- 0x13,
- L"SCSI storage device and controller SOP using PQI",
- PCIBlankEntry
- },
- {
- 0x21,
- L"SCSI storage device SOP using NVMe",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0101[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"OM-primary",
- PCIBlankEntry
- },
- {
- 0x02,
- L"PI-primary",
- PCIBlankEntry
- },
- {
- 0x03,
- L"OM/PI-primary",
- PCIBlankEntry
- },
- {
- 0x04,
- L"OM-secondary",
- PCIBlankEntry
- },
- {
- 0x05,
- L"OM-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x06,
- L"PI-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x07,
- L"OM/PI-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x08,
- L"OM-secondary",
- PCIBlankEntry
- },
- {
- 0x09,
- L"OM-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x0a,
- L"PI-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x0b,
- L"OM/PI-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x0c,
- L"OM-secondary",
- PCIBlankEntry
- },
- {
- 0x0d,
- L"OM-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x0e,
- L"PI-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x0f,
- L"OM/PI-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Master",
- PCIBlankEntry
- },
- {
- 0x81,
- L"Master, OM-primary",
- PCIBlankEntry
- },
- {
- 0x82,
- L"Master, PI-primary",
- PCIBlankEntry
- },
- {
- 0x83,
- L"Master, OM/PI-primary",
- PCIBlankEntry
- },
- {
- 0x84,
- L"Master, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x85,
- L"Master, OM-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x86,
- L"Master, PI-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x87,
- L"Master, OM/PI-primary, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x88,
- L"Master, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x89,
- L"Master, OM-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x8a,
- L"Master, PI-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x8b,
- L"Master, OM/PI-primary, PI-secondary",
- PCIBlankEntry
- },
- {
- 0x8c,
- L"Master, OM-secondary",
- PCIBlankEntry
- },
- {
- 0x8d,
- L"Master, OM-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x8e,
- L"Master, PI-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x8f,
- L"Master, OM/PI-primary, OM/PI-secondary",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0105[] = {
- {
- 0x20,
- L"Single stepping",
- PCIBlankEntry
- },
- {
- 0x30,
- L"Continuous operation",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0106[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"AHCI",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Serial Storage Bus",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0107[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Obsolete",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0108[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"NVMHCI",
- PCIBlankEntry
- },
- {
- 0x02,
- L"NVM Express",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0109[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"UFSHCI",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0300[] = {
- {
- 0x00,
- L"VGA compatible",
- PCIBlankEntry
- },
- {
- 0x01,
- L"8514 compatible",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0604[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Subtractive decode",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0609[] = {
- {
- 0x40,
- L"Primary PCI bus side facing the system host processor",
- PCIBlankEntry
- },
- {
- 0x80,
- L"Secondary PCI bus side facing the system host processor",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_060b[] = {
- {
- 0x00,
- L"Custom",
- PCIBlankEntry
- },
- {
- 0x01,
- L"ASI-SIG Defined Portal",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0700[] = {
- {
- 0x00,
- L"Generic XT-compatible",
- PCIBlankEntry
- },
- {
- 0x01,
- L"16450-compatible",
- PCIBlankEntry
- },
- {
- 0x02,
- L"16550-compatible",
- PCIBlankEntry
- },
- {
- 0x03,
- L"16650-compatible",
- PCIBlankEntry
- },
- {
- 0x04,
- L"16750-compatible",
- PCIBlankEntry
- },
- {
- 0x05,
- L"16850-compatible",
- PCIBlankEntry
- },
- {
- 0x06,
- L"16950-compatible",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0701[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Bi-directional",
- PCIBlankEntry
- },
- {
- 0x02,
- L"ECP 1.X-compliant",
- PCIBlankEntry
- },
- {
- 0x03,
- L"IEEE 1284",
- PCIBlankEntry
- },
- {
- 0xfe,
- L"IEEE 1284 target (not a controller)",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0703[] = {
- {
- 0x00,
- L"Generic",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Hayes-compatible 16450",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Hayes-compatible 16550",
- PCIBlankEntry
- },
- {
- 0x03,
- L"Hayes-compatible 16650",
- PCIBlankEntry
- },
- {
- 0x04,
- L"Hayes-compatible 16750",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0800[] = {
- {
- 0x00,
- L"Generic 8259",
- PCIBlankEntry
- },
- {
- 0x01,
- L"ISA",
- PCIBlankEntry
- },
- {
- 0x02,
- L"EISA",
- PCIBlankEntry
- },
- {
- 0x10,
- L"IO APIC",
- PCIBlankEntry
- },
- {
- 0x20,
- L"IO(x) APIC interrupt controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0801[] = {
- {
- 0x00,
- L"Generic 8237",
- PCIBlankEntry
- },
- {
- 0x01,
- L"ISA",
- PCIBlankEntry
- },
- {
- 0x02,
- L"EISA",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0802[] = {
- {
- 0x00,
- L"Generic 8254",
- PCIBlankEntry
- },
- {
- 0x01,
- L"ISA",
- PCIBlankEntry
- },
- {
- 0x02,
- L"EISA",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0803[] = {
- {
- 0x00,
- L"Generic",
- PCIBlankEntry
- },
- {
- 0x01,
- L"ISA",
- PCIBlankEntry
- },
- {
- 0x02,
- L"EISA",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0904[] = {
- {
- 0x00,
- L"Generic",
- PCIBlankEntry
- },
- {
- 0x10,
- L"",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0c00[] = {
- {
- 0x00,
- L"",
- PCIBlankEntry
- },
- {
- 0x10,
- L"Using 1394 OpenHCI spec",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0c03[] = {
- {
- 0x00,
- L"UHCI",
- PCIBlankEntry
- },
- {
- 0x10,
- L"OHCI",
- PCIBlankEntry
- },
- {
- 0x20,
- L"EHCI",
- PCIBlankEntry
- },
- {
- 0x30,
- L"xHCI",
- PCIBlankEntry
- },
- {
- 0x80,
- L"No specific programming interface",
- PCIBlankEntry
- },
- {
- 0xfe,
- L"(Not Host Controller)",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0c07[] = {
- {
- 0x00,
- L"SMIC",
- PCIBlankEntry
- },
- {
- 0x01,
- L"Keyboard Controller Style",
- PCIBlankEntry
- },
- {
- 0x02,
- L"Block Transfer",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0d01[] = {
- {
- 0x00,
- L"Consumer IR controller",
- PCIBlankEntry
- },
- {
- 0x10,
- L"UWB Radio controller",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-PCI_CLASS_ENTRY PCIPIFClass_0e00[] = {
- {
- 0x00,
- L"Message FIFO at offset 40h",
- PCIBlankEntry
- },
- {
- 0x01,
- L"",
- PCIBlankEntry
- },
- {
- 0x00,
- NULL,
- /* null string ends the list */NULL
- }
-};
-
-
-/**
- Generates printable Unicode strings that represent PCI device class,
- subclass and programmed I/F based on a value passed to the function.
-
- @param[in] ClassCode Value representing the PCI "Class Code" register read from a
- PCI device. The encodings are:
- bits 23:16 - Base Class Code
- bits 15:8 - Sub-Class Code
- bits 7:0 - Programming Interface
- @param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
- printable class strings corresponding to ClassCode. The
- caller must not modify the strings that are pointed by
- the fields in ClassStrings.
-**/
-VOID
-PciGetClassStrings (
- IN UINT32 ClassCode,
- IN OUT PCI_CLASS_STRINGS *ClassStrings
- )
-{
- INTN Index;
- UINT8 Code;
- PCI_CLASS_ENTRY *CurrentClass;
-
- //
- // Assume no strings found
- //
- ClassStrings->BaseClass = L"UNDEFINED";
- ClassStrings->SubClass = L"UNDEFINED";
- ClassStrings->PIFClass = L"UNDEFINED";
-
- CurrentClass = gClassStringList;
- Code = (UINT8) (ClassCode >> 16);
- Index = 0;
-
- //
- // Go through all entries of the base class, until the entry with a matching
- // base class code is found. If reaches an entry with a null description
- // text, the last entry is met, which means no text for the base class was
- // found, so no more action is needed.
- //
- while (Code != CurrentClass[Index].Code) {
- if (NULL == CurrentClass[Index].DescText) {
- return ;
- }
-
- Index++;
- }
- //
- // A base class was found. Assign description, and check if this class has
- // sub-class defined. If sub-class defined, no more action is needed,
- // otherwise, continue to find description for the sub-class code.
- //
- ClassStrings->BaseClass = CurrentClass[Index].DescText;
- if (NULL == CurrentClass[Index].LowerLevelClass) {
- return ;
- }
- //
- // find Subclass entry
- //
- CurrentClass = CurrentClass[Index].LowerLevelClass;
- Code = (UINT8) (ClassCode >> 8);
- Index = 0;
-
- //
- // Go through all entries of the sub-class, until the entry with a matching
- // sub-class code is found. If reaches an entry with a null description
- // text, the last entry is met, which means no text for the sub-class was
- // found, so no more action is needed.
- //
- while (Code != CurrentClass[Index].Code) {
- if (NULL == CurrentClass[Index].DescText) {
- return ;
- }
-
- Index++;
- }
- //
- // A class was found for the sub-class code. Assign description, and check if
- // this sub-class has programming interface defined. If no, no more action is
- // needed, otherwise, continue to find description for the programming
- // interface.
- //
- ClassStrings->SubClass = CurrentClass[Index].DescText;
- if (NULL == CurrentClass[Index].LowerLevelClass) {
- return ;
- }
- //
- // Find programming interface entry
- //
- CurrentClass = CurrentClass[Index].LowerLevelClass;
- Code = (UINT8) ClassCode;
- Index = 0;
-
- //
- // Go through all entries of the I/F entries, until the entry with a
- // matching I/F code is found. If reaches an entry with a null description
- // text, the last entry is met, which means no text was found, so no more
- // action is needed.
- //
- while (Code != CurrentClass[Index].Code) {
- if (NULL == CurrentClass[Index].DescText) {
- return ;
- }
-
- Index++;
- }
- //
- // A class was found for the I/F code. Assign description, done!
- //
- ClassStrings->PIFClass = CurrentClass[Index].DescText;
- return ;
-}
-
-/**
- Print strings that represent PCI device class, subclass and programmed I/F.
-
- @param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
- configuration space.
- @param[in] IncludePIF If the printed string should include the programming I/F part
-**/
-VOID
-PciPrintClassCode (
- IN UINT8 *ClassCodePtr,
- IN BOOLEAN IncludePIF
- )
-{
- UINT32 ClassCode;
- PCI_CLASS_STRINGS ClassStrings;
-
- ClassCode = 0;
- ClassCode |= (UINT32)ClassCodePtr[0];
- ClassCode |= (UINT32)(ClassCodePtr[1] << 8);
- ClassCode |= (UINT32)(ClassCodePtr[2] << 16);
-
- //
- // Get name from class code
- //
- PciGetClassStrings (ClassCode, &ClassStrings);
-
- if (IncludePIF) {
- //
- // Print base class, sub class, and programming inferface name
- //
- ShellPrintEx (-1, -1, L"%s - %s - %s",
- ClassStrings.BaseClass,
- ClassStrings.SubClass,
- ClassStrings.PIFClass
- );
-
- } else {
- //
- // Only print base class and sub class name
- //
- ShellPrintEx (-1, -1, L"%s - %s",
- ClassStrings.BaseClass,
- ClassStrings.SubClass
- );
- }
-}
-
-/**
- This function finds out the protocol which is in charge of the given
- segment, and its bus range covers the current bus number. It lookes
- each instances of RootBridgeIoProtocol handle, until the one meets the
- criteria is found.
-
- @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
- @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
- @param[in] Segment Segment number of device we are dealing with.
- @param[in] Bus Bus number of device we are dealing with.
- @param[out] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
- @retval EFI_INVALID_PARAMETER Invalid parameter.
-
-**/
-EFI_STATUS
-PciFindProtocolInterface (
- IN EFI_HANDLE *HandleBuf,
- IN UINTN HandleCount,
- IN UINT16 Segment,
- IN UINT16 Bus,
- OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev
- );
-
-/**
- This function gets the protocol interface from the given handle, and
- obtains its address space descriptors.
-
- @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
- @param[out] IoDev Handle used to access configuration space of PCI device.
- @param[out] Descriptors Points to the address space descriptors.
-
- @retval EFI_SUCCESS The command completed successfully
-**/
-EFI_STATUS
-PciGetProtocolAndResource (
- IN EFI_HANDLE Handle,
- OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev,
- OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors
- );
-
-/**
- This function get the next bus range of given address space descriptors.
- It also moves the pointer backward a node, to get prepared to be called
- again.
-
- @param[in, out] Descriptors Points to current position of a serial of address space
- descriptors.
- @param[out] MinBus The lower range of bus number.
- @param[out] MaxBus The upper range of bus number.
- @param[out] IsEnd Meet end of the serial of descriptors.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciGetNextBusRange (
- IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
- OUT UINT16 *MinBus,
- OUT UINT16 *MaxBus,
- OUT BOOLEAN *IsEnd
- );
-
-/**
- Explain the data in PCI configuration space. The part which is common for
- PCI device and bridge is interpreted in this function. It calls other
- functions to interpret data unique for device or bridge.
-
- @param[in] ConfigSpace Data in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
- @param[in] EnhancedDump The print format for the dump data.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainData (
- IN PCI_CONFIG_SPACE *ConfigSpace,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN CONST UINT16 EnhancedDump
- );
-
-/**
- Explain the device specific part of data in PCI configuration space.
-
- @param[in] Device Data in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainDeviceData (
- IN PCI_DEVICE_HEADER *Device,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- );
-
-/**
- Explain the bridge specific part of data in PCI configuration space.
-
- @param[in] Bridge Bridge specific data region in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBridgeData (
- IN PCI_BRIDGE_HEADER *Bridge,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- );
-
-/**
- Explain the Base Address Register(Bar) in PCI configuration space.
-
- @param[in] Bar Points to the Base Address Register intended to interpret.
- @param[in] Command Points to the register Command.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
- @param[in, out] Index The Index.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBar (
- IN UINT32 *Bar,
- IN UINT16 *Command,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN OUT UINTN *Index
- );
-
-/**
- Explain the cardbus specific part of data in PCI configuration space.
-
- @param[in] CardBus CardBus specific region of PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainCardBusData (
- IN PCI_CARDBUS_HEADER *CardBus,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- );
-
-/**
- Explain each meaningful bit of register Status. The definition of Status is
- slightly different depending on the PCI header type.
-
- @param[in] Status Points to the content of register Status.
- @param[in] MainStatus Indicates if this register is main status(not secondary
- status).
- @param[in] HeaderType Header type of this PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainStatus (
- IN UINT16 *Status,
- IN BOOLEAN MainStatus,
- IN PCI_HEADER_TYPE HeaderType
- );
-
-/**
- Explain each meaningful bit of register Command.
-
- @param[in] Command Points to the content of register Command.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainCommand (
- IN UINT16 *Command
- );
-
-/**
- Explain each meaningful bit of register Bridge Control.
-
- @param[in] BridgeControl Points to the content of register Bridge Control.
- @param[in] HeaderType The headertype.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBridgeControl (
- IN UINT16 *BridgeControl,
- IN PCI_HEADER_TYPE HeaderType
- );
-
-/**
- Print each capability structure.
-
- @param[in] IoDev The pointer to the deivce.
- @param[in] Address The address to start at.
- @param[in] CapPtr The offset from the address.
- @param[in] EnhancedDump The print format for the dump data.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-PciExplainCapabilityStruct (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN UINT64 Address,
- IN UINT8 CapPtr,
- IN CONST UINT16 EnhancedDump
- );
-
-/**
- Display Pcie device structure.
-
- @param[in] IoDev The pointer to the root pci protocol.
- @param[in] Address The Address to start at.
- @param[in] CapabilityPtr The offset from the address to start.
- @param[in] EnhancedDump The print format for the dump data.
-
- @retval EFI_SUCCESS The command completed successfully.
- @retval @retval EFI_SUCCESS Pci express extend space IO is not suppoted.
-**/
-EFI_STATUS
-PciExplainPciExpress (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN UINT64 Address,
- IN UINT8 CapabilityPtr,
- IN CONST UINT16 EnhancedDump
- );
-
-/**
- Print out information of the capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieCapReg (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device link information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device link control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device link status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device slot information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device slot control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device slot status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device root information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device root capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-/**
- Print out information of the device root status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- );
-
-typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION) (IN PCIE_CAP_STRUCTURE *PciExpressCap);
-
-typedef enum {
- FieldWidthUINT8,
- FieldWidthUINT16,
- FieldWidthUINT32
-} PCIE_CAPREG_FIELD_WIDTH;
-
-typedef enum {
- PcieExplainTypeCommon,
- PcieExplainTypeDevice,
- PcieExplainTypeLink,
- PcieExplainTypeSlot,
- PcieExplainTypeRoot,
- PcieExplainTypeMax
-} PCIE_EXPLAIN_TYPE;
-
-typedef struct
-{
- UINT16 Token;
- UINTN Offset;
- PCIE_CAPREG_FIELD_WIDTH Width;
- PCIE_EXPLAIN_FUNCTION Func;
- PCIE_EXPLAIN_TYPE Type;
-} PCIE_EXPLAIN_STRUCT;
-
-PCIE_EXPLAIN_STRUCT PcieExplainList[] = {
- {
- STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID),
- 0x00,
- FieldWidthUINT8,
- NULL,
- PcieExplainTypeCommon
- },
- {
- STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR),
- 0x01,
- FieldWidthUINT8,
- NULL,
- PcieExplainTypeCommon
- },
- {
- STRING_TOKEN (STR_PCIEX_CAP_REGISTER),
- 0x02,
- FieldWidthUINT16,
- ExplainPcieCapReg,
- PcieExplainTypeCommon
- },
- {
- STRING_TOKEN (STR_PCIEX_DEVICE_CAP),
- 0x04,
- FieldWidthUINT32,
- ExplainPcieDeviceCap,
- PcieExplainTypeDevice
- },
- {
- STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL),
- 0x08,
- FieldWidthUINT16,
- ExplainPcieDeviceControl,
- PcieExplainTypeDevice
- },
- {
- STRING_TOKEN (STR_PCIEX_DEVICE_STATUS),
- 0x0a,
- FieldWidthUINT16,
- ExplainPcieDeviceStatus,
- PcieExplainTypeDevice
- },
- {
- STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES),
- 0x0c,
- FieldWidthUINT32,
- ExplainPcieLinkCap,
- PcieExplainTypeLink
- },
- {
- STRING_TOKEN (STR_PCIEX_LINK_CONTROL),
- 0x10,
- FieldWidthUINT16,
- ExplainPcieLinkControl,
- PcieExplainTypeLink
- },
- {
- STRING_TOKEN (STR_PCIEX_LINK_STATUS),
- 0x12,
- FieldWidthUINT16,
- ExplainPcieLinkStatus,
- PcieExplainTypeLink
- },
- {
- STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES),
- 0x14,
- FieldWidthUINT32,
- ExplainPcieSlotCap,
- PcieExplainTypeSlot
- },
- {
- STRING_TOKEN (STR_PCIEX_SLOT_CONTROL),
- 0x18,
- FieldWidthUINT16,
- ExplainPcieSlotControl,
- PcieExplainTypeSlot
- },
- {
- STRING_TOKEN (STR_PCIEX_SLOT_STATUS),
- 0x1a,
- FieldWidthUINT16,
- ExplainPcieSlotStatus,
- PcieExplainTypeSlot
- },
- {
- STRING_TOKEN (STR_PCIEX_ROOT_CONTROL),
- 0x1c,
- FieldWidthUINT16,
- ExplainPcieRootControl,
- PcieExplainTypeRoot
- },
- {
- STRING_TOKEN (STR_PCIEX_RSVDP),
- 0x1e,
- FieldWidthUINT16,
- ExplainPcieRootCap,
- PcieExplainTypeRoot
- },
- {
- STRING_TOKEN (STR_PCIEX_ROOT_STATUS),
- 0x20,
- FieldWidthUINT32,
- ExplainPcieRootStatus,
- PcieExplainTypeRoot
- },
- {
- 0,
- 0,
- (PCIE_CAPREG_FIELD_WIDTH)0,
- NULL,
- PcieExplainTypeMax
- }
-};
-
-//
-// Global Variables
-//
-PCI_CONFIG_SPACE *mConfigSpace = NULL;
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-s", TypeValue},
- {L"-i", TypeFlag},
- {NULL, TypeMax}
- };
-
-CHAR16 *DevicePortTypeTable[] = {
- L"PCI Express Endpoint",
- L"Legacy PCI Express Endpoint",
- L"Unknown Type",
- L"Unknonw Type",
- L"Root Port of PCI Express Root Complex",
- L"Upstream Port of PCI Express Switch",
- L"Downstream Port of PCI Express Switch",
- L"PCI Express to PCI/PCI-X Bridge",
- L"PCI/PCI-X to PCI Express Bridge",
- L"Root Complex Integrated Endpoint",
- L"Root Complex Event Collector"
-};
-
-CHAR16 *L0sLatencyStrTable[] = {
- L"Less than 64ns",
- L"64ns to less than 128ns",
- L"128ns to less than 256ns",
- L"256ns to less than 512ns",
- L"512ns to less than 1us",
- L"1us to less than 2us",
- L"2us-4us",
- L"More than 4us"
-};
-
-CHAR16 *L1LatencyStrTable[] = {
- L"Less than 1us",
- L"1us to less than 2us",
- L"2us to less than 4us",
- L"4us to less than 8us",
- L"8us to less than 16us",
- L"16us to less than 32us",
- L"32us-64us",
- L"More than 64us"
-};
-
-CHAR16 *ASPMCtrlStrTable[] = {
- L"Disabled",
- L"L0s Entry Enabled",
- L"L1 Entry Enabled",
- L"L0s and L1 Entry Enabled"
-};
-
-CHAR16 *SlotPwrLmtScaleTable[] = {
- L"1.0x",
- L"0.1x",
- L"0.01x",
- L"0.001x"
-};
-
-CHAR16 *IndicatorTable[] = {
- L"Reserved",
- L"On",
- L"Blink",
- L"Off"
-};
-
-
-/**
- Function for 'pci' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPci (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT16 Segment;
- UINT16 Bus;
- UINT16 Device;
- UINT16 Func;
- UINT64 Address;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev;
- EFI_STATUS Status;
- PCI_COMMON_HEADER PciHeader;
- PCI_CONFIG_SPACE ConfigSpace;
- UINTN ScreenCount;
- UINTN TempColumn;
- UINTN ScreenSize;
- BOOLEAN ExplainData;
- UINTN Index;
- UINTN SizeOfHeader;
- BOOLEAN PrintTitle;
- UINTN HandleBufSize;
- EFI_HANDLE *HandleBuf;
- UINTN HandleCount;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
- UINT16 MinBus;
- UINT16 MaxBus;
- BOOLEAN IsEnd;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Temp;
- UINT64 RetVal;
- UINT16 EnhancedDump;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Address = 0;
- IoDev = NULL;
- HandleBuf = NULL;
- Package = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"pci", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
-
- if (ShellCommandLineGetCount(Package) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- if (ShellCommandLineGetCount(Package) > 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetValue(Package, L"-s") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"pci", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- //
- // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
- // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
- // space for handles and call it again.
- //
- HandleBufSize = sizeof (EFI_HANDLE);
- HandleBuf = (EFI_HANDLE *) AllocateZeroPool (HandleBufSize);
- if (HandleBuf == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- goto Done;
- }
-
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &HandleBufSize,
- HandleBuf
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuf = ReallocatePool (sizeof (EFI_HANDLE), HandleBufSize, HandleBuf);
- if (HandleBuf == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- goto Done;
- }
-
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &HandleBufSize,
- HandleBuf
- );
- }
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
-
- HandleCount = HandleBufSize / sizeof (EFI_HANDLE);
- //
- // Argument Count == 1(no other argument): enumerate all pci functions
- //
- if (ShellCommandLineGetCount(Package) == 1) {
- gST->ConOut->QueryMode (
- gST->ConOut,
- gST->ConOut->Mode->Mode,
- &TempColumn,
- &ScreenSize
- );
-
- ScreenCount = 0;
- ScreenSize -= 4;
- if ((ScreenSize & 1) == 1) {
- ScreenSize -= 1;
- }
-
- PrintTitle = TRUE;
-
- //
- // For each handle, which decides a segment and a bus number range,
- // enumerate all devices on it.
- //
- for (Index = 0; Index < HandleCount; Index++) {
- Status = PciGetProtocolAndResource (
- HandleBuf[Index],
- &IoDev,
- &Descriptors
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- //
- // No document say it's impossible for a RootBridgeIo protocol handle
- // to have more than one address space descriptors, so find out every
- // bus range and for each of them do device enumeration.
- //
- while (TRUE) {
- Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd);
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
-
- if (IsEnd) {
- break;
- }
-
- for (Bus = MinBus; Bus <= MaxBus; Bus++) {
- //
- // For each devices, enumerate all functions it contains
- //
- for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {
- //
- // For each function, read its configuration space and print summary
- //
- for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- goto Done;
- }
- Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0);
- IoDev->Pci.Read (
- IoDev,
- EfiPciWidthUint16,
- Address,
- 1,
- &PciHeader.VendorId
- );
-
- //
- // If VendorId = 0xffff, there does not exist a device at this
- // location. For each device, if there is any function on it,
- // there must be 1 function at Function 0. So if Func = 0, there
- // will be no more functions in the same device, so we can break
- // loop to deal with the next device.
- //
- if (PciHeader.VendorId == 0xffff && Func == 0) {
- break;
- }
-
- if (PciHeader.VendorId != 0xffff) {
-
- if (PrintTitle) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_TITLE), gShellDebug1HiiHandle);
- PrintTitle = FALSE;
- }
-
- IoDev->Pci.Read (
- IoDev,
- EfiPciWidthUint32,
- Address,
- sizeof (PciHeader) / sizeof (UINT32),
- &PciHeader
- );
-
- ShellPrintHiiEx(
- -1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P1), gShellDebug1HiiHandle,
- IoDev->SegmentNumber,
- Bus,
- Device,
- Func
- );
-
- PciPrintClassCode (PciHeader.ClassCode, FALSE);
- ShellPrintHiiEx(
- -1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P2), gShellDebug1HiiHandle,
- PciHeader.VendorId,
- PciHeader.DeviceId,
- PciHeader.ClassCode[0]
- );
-
- ScreenCount += 2;
- if (ScreenCount >= ScreenSize && ScreenSize != 0) {
- //
- // If ScreenSize == 0 we have the console redirected so don't
- // block updates
- //
- ScreenCount = 0;
- }
- //
- // If this is not a multi-function device, we can leave the loop
- // to deal with the next device.
- //
- if (Func == 0 && ((PciHeader.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) {
- break;
- }
- }
- }
- }
- }
- //
- // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
- // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
- // devices on all bus, we can leave loop.
- //
- if (Descriptors == NULL) {
- break;
- }
- }
- }
-
- Status = EFI_SUCCESS;
- goto Done;
- }
-
- ExplainData = FALSE;
- Segment = 0;
- Bus = 0;
- Device = 0;
- Func = 0;
- if (ShellCommandLineGetFlag(Package, L"-i")) {
- ExplainData = TRUE;
- }
-
- Temp = ShellCommandLineGetValue(Package, L"-s");
- if (Temp != NULL) {
- //
- // Input converted to hexadecimal number.
- //
- if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
- Segment = (UINT16) RetVal;
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- //
- // The first Argument(except "-i") is assumed to be Bus number, second
- // to be Device number, and third to be Func number.
- //
- Temp = ShellCommandLineGetRawValue(Package, 1);
- if (Temp != NULL) {
- //
- // Input converted to hexadecimal number.
- //
- if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
- Bus = (UINT16) RetVal;
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- if (Bus > MAX_BUS_NUMBER) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- Temp = ShellCommandLineGetRawValue(Package, 2);
- if (Temp != NULL) {
- //
- // Input converted to hexadecimal number.
- //
- if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
- Device = (UINT16) RetVal;
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- if (Device > MAX_DEVICE_NUMBER){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- Temp = ShellCommandLineGetRawValue(Package, 3);
- if (Temp != NULL) {
- //
- // Input converted to hexadecimal number.
- //
- if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
- Func = (UINT16) RetVal;
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- if (Func > MAX_FUNCTION_NUMBER){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"pci", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- //
- // Find the protocol interface who's in charge of current segment, and its
- // bus range covers the current bus
- //
- Status = PciFindProtocolInterface (
- HandleBuf,
- HandleCount,
- Segment,
- Bus,
- &IoDev
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1, -1, NULL, STRING_TOKEN (STR_PCI_NO_FIND), gShellDebug1HiiHandle, L"pci",
- Segment,
- Bus
- );
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
-
- Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0);
- Status = IoDev->Pci.Read (
- IoDev,
- EfiPciWidthUint8,
- Address,
- sizeof (ConfigSpace),
- &ConfigSpace
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_NO_CFG), gShellDebug1HiiHandle, L"pci");
- ShellStatus = SHELL_ACCESS_DENIED;
- goto Done;
- }
-
- mConfigSpace = &ConfigSpace;
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PCI_INFO),
- gShellDebug1HiiHandle,
- Segment,
- Bus,
- Device,
- Func,
- Segment,
- Bus,
- Device,
- Func
- );
-
- //
- // Dump standard header of configuration space
- //
- SizeOfHeader = sizeof (ConfigSpace.Common) + sizeof (ConfigSpace.NonCommon);
-
- DumpHex (2, 0, SizeOfHeader, &ConfigSpace);
- ShellPrintEx(-1,-1, L"\r\n");
-
- //
- // Dump device dependent Part of configuration space
- //
- DumpHex (
- 2,
- SizeOfHeader,
- sizeof (ConfigSpace) - SizeOfHeader,
- ConfigSpace.Data
- );
-
- //
- // If "-i" appears in command line, interpret data in configuration space
- //
- if (ExplainData) {
- EnhancedDump = 0;
- if (ShellCommandLineGetFlag(Package, L"-_e")) {
- EnhancedDump = 0xFFFF;
- Temp = ShellCommandLineGetValue(Package, L"-_e");
- if (Temp != NULL) {
- EnhancedDump = (UINT16) ShellHexStrToUintn (Temp);
- }
- }
- Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump);
- }
- }
-Done:
- if (HandleBuf != NULL) {
- FreePool (HandleBuf);
- }
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- mConfigSpace = NULL;
- return ShellStatus;
-}
-
-/**
- This function finds out the protocol which is in charge of the given
- segment, and its bus range covers the current bus number. It lookes
- each instances of RootBridgeIoProtocol handle, until the one meets the
- criteria is found.
-
- @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
- @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
- @param[in] Segment Segment number of device we are dealing with.
- @param[in] Bus Bus number of device we are dealing with.
- @param[out] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
- @retval EFI_INVALID_PARAMETER Invalid parameter.
-
-**/
-EFI_STATUS
-PciFindProtocolInterface (
- IN EFI_HANDLE *HandleBuf,
- IN UINTN HandleCount,
- IN UINT16 Segment,
- IN UINT16 Bus,
- OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev
- )
-{
- UINTN Index;
- EFI_STATUS Status;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
- UINT16 MinBus;
- UINT16 MaxBus;
- BOOLEAN IsEnd;
-
- //
- // Go through all handles, until the one meets the criteria is found
- //
- for (Index = 0; Index < HandleCount; Index++) {
- Status = PciGetProtocolAndResource (HandleBuf[Index], IoDev, &Descriptors);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // When Descriptors == NULL, the Configuration() is not implemented,
- // so we only check the Segment number
- //
- if (Descriptors == NULL && Segment == (*IoDev)->SegmentNumber) {
- return EFI_SUCCESS;
- }
-
- if ((*IoDev)->SegmentNumber != Segment) {
- continue;
- }
-
- while (TRUE) {
- Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (IsEnd) {
- break;
- }
-
- if (MinBus <= Bus && MaxBus >= Bus) {
- return EFI_SUCCESS;
- }
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- This function gets the protocol interface from the given handle, and
- obtains its address space descriptors.
-
- @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
- @param[out] IoDev Handle used to access configuration space of PCI device.
- @param[out] Descriptors Points to the address space descriptors.
-
- @retval EFI_SUCCESS The command completed successfully
-**/
-EFI_STATUS
-PciGetProtocolAndResource (
- IN EFI_HANDLE Handle,
- OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev,
- OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors
- )
-{
- EFI_STATUS Status;
-
- //
- // Get inferface from protocol
- //
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiPciRootBridgeIoProtocolGuid,
- (VOID**)IoDev
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Call Configuration() to get address space descriptors
- //
- Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors);
- if (Status == EFI_UNSUPPORTED) {
- *Descriptors = NULL;
- return EFI_SUCCESS;
-
- } else {
- return Status;
- }
-}
-
-/**
- This function get the next bus range of given address space descriptors.
- It also moves the pointer backward a node, to get prepared to be called
- again.
-
- @param[in, out] Descriptors Points to current position of a serial of address space
- descriptors.
- @param[out] MinBus The lower range of bus number.
- @param[out] MaxBus The upper range of bus number.
- @param[out] IsEnd Meet end of the serial of descriptors.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciGetNextBusRange (
- IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
- OUT UINT16 *MinBus,
- OUT UINT16 *MaxBus,
- OUT BOOLEAN *IsEnd
- )
-{
- *IsEnd = FALSE;
-
- //
- // When *Descriptors is NULL, Configuration() is not implemented, so assume
- // range is 0~PCI_MAX_BUS
- //
- if ((*Descriptors) == NULL) {
- *MinBus = 0;
- *MaxBus = PCI_MAX_BUS;
- return EFI_SUCCESS;
- }
- //
- // *Descriptors points to one or more address space descriptors, which
- // ends with a end tagged descriptor. Examine each of the descriptors,
- // if a bus typed one is found and its bus range covers bus, this handle
- // is the handle we are looking for.
- //
-
- while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {
- if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
- *MinBus = (UINT16) (*Descriptors)->AddrRangeMin;
- *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax;
- (*Descriptors)++;
- return (EFI_SUCCESS);
- }
-
- (*Descriptors)++;
- }
-
- if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) {
- *IsEnd = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain the data in PCI configuration space. The part which is common for
- PCI device and bridge is interpreted in this function. It calls other
- functions to interpret data unique for device or bridge.
-
- @param[in] ConfigSpace Data in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
- @param[in] EnhancedDump The print format for the dump data.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainData (
- IN PCI_CONFIG_SPACE *ConfigSpace,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN CONST UINT16 EnhancedDump
- )
-{
- PCI_COMMON_HEADER *Common;
- PCI_HEADER_TYPE HeaderType;
- EFI_STATUS Status;
- UINT8 CapPtr;
-
- Common = &(ConfigSpace->Common);
-
- ShellPrintEx (-1, -1, L"\r\n");
-
- //
- // Print Vendor Id and Device Id
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_VID_DID), gShellDebug1HiiHandle,
- INDEX_OF (&(Common->VendorId)),
- Common->VendorId,
- INDEX_OF (&(Common->DeviceId)),
- Common->DeviceId
- );
-
- //
- // Print register Command
- //
- PciExplainCommand (&(Common->Command));
-
- //
- // Print register Status
- //
- PciExplainStatus (&(Common->Status), TRUE, PciUndefined);
-
- //
- // Print register Revision ID
- //
- ShellPrintEx(-1, -1, L"\r\n");
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_RID), gShellDebug1HiiHandle,
- INDEX_OF (&(Common->RevisionId)),
- Common->RevisionId
- );
-
- //
- // Print register BIST
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_BIST), gShellDebug1HiiHandle, INDEX_OF (&(Common->Bist)));
- if ((Common->Bist & PCI_BIT_7) != 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP), gShellDebug1HiiHandle, 0x0f & Common->Bist);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP_NO), gShellDebug1HiiHandle);
- }
- //
- // Print register Cache Line Size
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Common->CacheLineSize)),
- Common->CacheLineSize
- );
-
- //
- // Print register Latency Timer
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_LATENCY_TIMER),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Common->PrimaryLatencyTimer)),
- Common->PrimaryLatencyTimer
- );
-
- //
- // Print register Header Type
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_HEADER_TYPE),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Common->HeaderType)),
- Common->HeaderType
- );
-
- if ((Common->HeaderType & PCI_BIT_7) != 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION), gShellDebug1HiiHandle);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION), gShellDebug1HiiHandle);
- }
-
- HeaderType = (PCI_HEADER_TYPE)(UINT8) (Common->HeaderType & 0x7f);
- switch (HeaderType) {
- case PciDevice:
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_PCI_DEVICE), gShellDebug1HiiHandle);
- break;
-
- case PciP2pBridge:
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_P2P_BRIDGE), gShellDebug1HiiHandle);
- break;
-
- case PciCardBusBridge:
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED), gShellDebug1HiiHandle);
- HeaderType = PciUndefined;
- }
-
- //
- // Print register Class Code
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CLASS), gShellDebug1HiiHandle);
- PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE);
- ShellPrintEx (-1, -1, L"\r\n");
-
- if (ShellGetExecutionBreakFlag()) {
- return EFI_SUCCESS;
- }
-
- //
- // Interpret remaining part of PCI configuration header depending on
- // HeaderType
- //
- CapPtr = 0;
- Status = EFI_SUCCESS;
- switch (HeaderType) {
- case PciDevice:
- Status = PciExplainDeviceData (
- &(ConfigSpace->NonCommon.Device),
- Address,
- IoDev
- );
- CapPtr = ConfigSpace->NonCommon.Device.CapabilitiesPtr;
- break;
-
- case PciP2pBridge:
- Status = PciExplainBridgeData (
- &(ConfigSpace->NonCommon.Bridge),
- Address,
- IoDev
- );
- CapPtr = ConfigSpace->NonCommon.Bridge.CapabilitiesPtr;
- break;
-
- case PciCardBusBridge:
- Status = PciExplainCardBusData (
- &(ConfigSpace->NonCommon.CardBus),
- Address,
- IoDev
- );
- CapPtr = ConfigSpace->NonCommon.CardBus.CapabilitiesPtr;
- break;
- case PciUndefined:
- default:
- break;
- }
- //
- // If Status bit4 is 1, dump or explain capability structure
- //
- if ((Common->Status) & EFI_PCI_STATUS_CAPABILITY) {
- PciExplainCapabilityStruct (IoDev, Address, CapPtr, EnhancedDump);
- }
-
- return Status;
-}
-
-/**
- Explain the device specific part of data in PCI configuration space.
-
- @param[in] Device Data in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainDeviceData (
- IN PCI_DEVICE_HEADER *Device,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- )
-{
- UINTN Index;
- BOOLEAN BarExist;
- EFI_STATUS Status;
- UINTN BarCount;
-
- //
- // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
- // exist. If these no Bar for this function, print "none", otherwise
- // list detail information about this Bar.
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDR), gShellDebug1HiiHandle, INDEX_OF (Device->Bar));
-
- BarExist = FALSE;
- BarCount = sizeof (Device->Bar) / sizeof (Device->Bar[0]);
- for (Index = 0; Index < BarCount; Index++) {
- if (Device->Bar[Index] == 0) {
- continue;
- }
-
- if (!BarExist) {
- BarExist = TRUE;
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE), gShellDebug1HiiHandle);
- ShellPrintEx (-1, -1, L" --------------------------------------------------------------------------");
- }
-
- Status = PciExplainBar (
- &(Device->Bar[Index]),
- &(mConfigSpace->Common.Command),
- Address,
- IoDev,
- &Index
- );
-
- if (EFI_ERROR (Status)) {
- break;
- }
- }
-
- if (!BarExist) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
-
- } else {
- ShellPrintEx (-1, -1, L"\r\n --------------------------------------------------------------------------");
- }
-
- //
- // Print register Expansion ROM Base Address
- //
- if ((Device->ROMBar & PCI_BIT_0) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED), gShellDebug1HiiHandle, INDEX_OF (&(Device->ROMBar)));
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->ROMBar)),
- Device->ROMBar
- );
- }
- //
- // Print register Cardbus CIS ptr
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CARDBUS_CIS),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->CardBusCISPtr)),
- Device->CardBusCISPtr
- );
-
- //
- // Print register Sub-vendor ID and subsystem ID
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->SubVendorId)),
- Device->SubVendorId
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->SubSystemId)),
- Device->SubSystemId
- );
-
- //
- // Print register Capabilities Ptr
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->CapabilitiesPtr)),
- Device->CapabilitiesPtr
- );
-
- //
- // Print register Interrupt Line and interrupt pin
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_INTERRUPT_LINE),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->InterruptLine)),
- Device->InterruptLine
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_INTERRUPT_PIN),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->InterruptPin)),
- Device->InterruptPin
- );
-
- //
- // Print register Min_Gnt and Max_Lat
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MIN_GNT),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->MinGnt)),
- Device->MinGnt
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MAX_LAT),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Device->MaxLat)),
- Device->MaxLat
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain the bridge specific part of data in PCI configuration space.
-
- @param[in] Bridge Bridge specific data region in PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBridgeData (
- IN PCI_BRIDGE_HEADER *Bridge,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- )
-{
- UINTN Index;
- BOOLEAN BarExist;
- UINTN BarCount;
- UINT32 IoAddress32;
- EFI_STATUS Status;
-
- //
- // Print Base Address Registers. When Bar = 0, this Bar does not
- // exist. If these no Bar for this function, print "none", otherwise
- // list detail information about this Bar.
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDRESS), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->Bar)));
-
- BarExist = FALSE;
- BarCount = sizeof (Bridge->Bar) / sizeof (Bridge->Bar[0]);
-
- for (Index = 0; Index < BarCount; Index++) {
- if (Bridge->Bar[Index] == 0) {
- continue;
- }
-
- if (!BarExist) {
- BarExist = TRUE;
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE_2), gShellDebug1HiiHandle);
- ShellPrintEx (-1, -1, L" --------------------------------------------------------------------------");
- }
-
- Status = PciExplainBar (
- &(Bridge->Bar[Index]),
- &(mConfigSpace->Common.Command),
- Address,
- IoDev,
- &Index
- );
-
- if (EFI_ERROR (Status)) {
- break;
- }
- }
-
- if (!BarExist) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
- } else {
- ShellPrintEx (-1, -1, L"\r\n --------------------------------------------------------------------------");
- }
-
- //
- // Expansion register ROM Base Address
- //
- if ((Bridge->ROMBar & PCI_BIT_0) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->ROMBar)));
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->ROMBar)),
- Bridge->ROMBar
- );
- }
- //
- // Print Bus Numbers(Primary, Secondary, and Subordinate
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_BUS_NUMBERS),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->PrimaryBus)),
- INDEX_OF (&(Bridge->SecondaryBus)),
- INDEX_OF (&(Bridge->SubordinateBus))
- );
-
- ShellPrintEx (-1, -1, L" ------------------------------------------------------\r\n");
-
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->PrimaryBus);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SecondaryBus);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SubordinateBus);
-
- //
- // Print register Secondary Latency Timer
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SECONDARY_TIMER),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->SecondaryLatencyTimer)),
- Bridge->SecondaryLatencyTimer
- );
-
- //
- // Print register Secondary Status
- //
- PciExplainStatus (&(Bridge->SecondaryStatus), FALSE, PciP2pBridge);
-
- //
- // Print I/O and memory ranges this bridge forwards. There are 3 resource
- // types: I/O, memory, and pre-fetchable memory. For each resource type,
- // base and limit address are listed.
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE), gShellDebug1HiiHandle);
- ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");
-
- //
- // IO Base & Limit
- //
- IoAddress32 = (Bridge->IoBaseUpper << 16 | Bridge->IoBase << 8);
- IoAddress32 &= 0xfffff000;
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_TWO_VARS),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->IoBase)),
- IoAddress32
- );
-
- IoAddress32 = (Bridge->IoLimitUpper << 16 | Bridge->IoLimit << 8);
- IoAddress32 |= 0x00000fff;
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR), gShellDebug1HiiHandle, IoAddress32);
-
- //
- // Memory Base & Limit
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MEMORY),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->MemoryBase)),
- (Bridge->MemoryBase << 16) & 0xfff00000
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_ONE_VAR),
- gShellDebug1HiiHandle,
- (Bridge->MemoryLimit << 16) | 0x000fffff
- );
-
- //
- // Pre-fetch-able Memory Base & Limit
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_PREFETCHABLE),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->PrefetchableMemBase)),
- Bridge->PrefetchableBaseUpper,
- (Bridge->PrefetchableMemBase << 16) & 0xfff00000
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_TWO_VARS_2),
- gShellDebug1HiiHandle,
- Bridge->PrefetchableLimitUpper,
- (Bridge->PrefetchableMemLimit << 16) | 0x000fffff
- );
-
- //
- // Print register Capabilities Pointer
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->CapabilitiesPtr)),
- Bridge->CapabilitiesPtr
- );
-
- //
- // Print register Bridge Control
- //
- PciExplainBridgeControl (&(Bridge->BridgeControl), PciP2pBridge);
-
- //
- // Print register Interrupt Line & PIN
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->InterruptLine)),
- Bridge->InterruptLine
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_INTERRUPT_PIN),
- gShellDebug1HiiHandle,
- INDEX_OF (&(Bridge->InterruptPin)),
- Bridge->InterruptPin
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain the Base Address Register(Bar) in PCI configuration space.
-
- @param[in] Bar Points to the Base Address Register intended to interpret.
- @param[in] Command Points to the register Command.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
- @param[in, out] Index The Index.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBar (
- IN UINT32 *Bar,
- IN UINT16 *Command,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN OUT UINTN *Index
- )
-{
- UINT16 OldCommand;
- UINT16 NewCommand;
- UINT64 Bar64;
- UINT32 OldBar32;
- UINT32 NewBar32;
- UINT64 OldBar64;
- UINT64 NewBar64;
- BOOLEAN IsMem;
- BOOLEAN IsBar32;
- UINT64 RegAddress;
-
- IsBar32 = TRUE;
- Bar64 = 0;
- NewBar32 = 0;
- NewBar64 = 0;
-
- //
- // According the bar type, list detail about this bar, for example: 32 or
- // 64 bits; pre-fetchable or not.
- //
- if ((*Bar & PCI_BIT_0) == 0) {
- //
- // This bar is of memory type
- //
- IsMem = TRUE;
-
- if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_32_BITS), gShellDebug1HiiHandle);
-
- } else if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) != 0) {
- Bar64 = 0x0;
- CopyMem (&Bar64, Bar, sizeof (UINT64));
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_2), gShellDebug1HiiHandle, (UINT32) RShiftU64 ((Bar64 & 0xfffffffffffffff0ULL), 32));
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_3), gShellDebug1HiiHandle, (UINT32) (Bar64 & 0xfffffffffffffff0ULL));
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_64_BITS), gShellDebug1HiiHandle);
- IsBar32 = FALSE;
- *Index += 1;
-
- } else {
- //
- // Reserved
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM_2), gShellDebug1HiiHandle);
- }
-
- if ((*Bar & PCI_BIT_3) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO), gShellDebug1HiiHandle);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_YES), gShellDebug1HiiHandle);
- }
-
- } else {
- //
- // This bar is of io type
- //
- IsMem = FALSE;
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_4), gShellDebug1HiiHandle, *Bar & 0xfffffffc);
- ShellPrintEx (-1, -1, L"I/O ");
- }
-
- //
- // Get BAR length(or the amount of resource this bar demands for). To get
- // Bar length, first we should temporarily disable I/O and memory access
- // of this function(by set bits in the register Command), then write all
- // "1"s to this bar. The bar value read back is the amount of resource
- // this bar demands for.
- //
- //
- // Disable io & mem access
- //
- OldCommand = *Command;
- NewCommand = (UINT16) (OldCommand & 0xfffc);
- RegAddress = Address | INDEX_OF (Command);
- IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &NewCommand);
-
- RegAddress = Address | INDEX_OF (Bar);
-
- //
- // Read after write the BAR to get the size
- //
- if (IsBar32) {
- OldBar32 = *Bar;
- NewBar32 = 0xffffffff;
-
- IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32);
- IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32);
- IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &OldBar32);
-
- if (IsMem) {
- NewBar32 = NewBar32 & 0xfffffff0;
- NewBar32 = (~NewBar32) + 1;
-
- } else {
- NewBar32 = NewBar32 & 0xfffffffc;
- NewBar32 = (~NewBar32) + 1;
- NewBar32 = NewBar32 & 0x0000ffff;
- }
- } else {
-
- OldBar64 = 0x0;
- CopyMem (&OldBar64, Bar, sizeof (UINT64));
- NewBar64 = 0xffffffffffffffffULL;
-
- IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64);
- IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64);
- IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &OldBar64);
-
- if (IsMem) {
- NewBar64 = NewBar64 & 0xfffffffffffffff0ULL;
- NewBar64 = (~NewBar64) + 1;
-
- } else {
- NewBar64 = NewBar64 & 0xfffffffffffffffcULL;
- NewBar64 = (~NewBar64) + 1;
- NewBar64 = NewBar64 & 0x000000000000ffff;
- }
- }
- //
- // Enable io & mem access
- //
- RegAddress = Address | INDEX_OF (Command);
- IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &OldCommand);
-
- if (IsMem) {
- if (IsBar32) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32), gShellDebug1HiiHandle, NewBar32);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_2), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffff0) - 1);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) RShiftU64 (NewBar64, 32));
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) NewBar64);
- ShellPrintEx (-1, -1, L" ");
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_RSHIFT),
- gShellDebug1HiiHandle,
- (UINT32) RShiftU64 ((NewBar64 + (Bar64 & 0xfffffffffffffff0ULL) - 1), 32)
- );
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) (NewBar64 + (Bar64 & 0xfffffffffffffff0ULL) - 1));
-
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_3), gShellDebug1HiiHandle, NewBar32);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_4), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffffc) - 1);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain the cardbus specific part of data in PCI configuration space.
-
- @param[in] CardBus CardBus specific region of PCI configuration space.
- @param[in] Address Address used to access configuration space of this PCI device.
- @param[in] IoDev Handle used to access configuration space of PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainCardBusData (
- IN PCI_CARDBUS_HEADER *CardBus,
- IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
- )
-{
- BOOLEAN Io32Bit;
- PCI_CARDBUS_DATA *CardBusData;
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->CardBusSocketReg)),
- CardBus->CardBusSocketReg
- );
-
- //
- // Print Secondary Status
- //
- PciExplainStatus (&(CardBus->SecondaryStatus), FALSE, PciCardBusBridge);
-
- //
- // Print Bus Numbers(Primary bus number, CardBus bus number, and
- // Subordinate bus number
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->PciBusNumber)),
- INDEX_OF (&(CardBus->CardBusBusNumber)),
- INDEX_OF (&(CardBus->SubordinateBusNumber))
- );
-
- ShellPrintEx (-1, -1, L" ------------------------------------------------------\r\n");
-
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS), gShellDebug1HiiHandle, CardBus->PciBusNumber);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_2), gShellDebug1HiiHandle, CardBus->CardBusBusNumber);
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_3), gShellDebug1HiiHandle, CardBus->SubordinateBusNumber);
-
- //
- // Print CardBus Latency Timer
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->CardBusLatencyTimer)),
- CardBus->CardBusLatencyTimer
- );
-
- //
- // Print Memory/Io ranges this cardbus bridge forwards
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2), gShellDebug1HiiHandle);
- ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MEM_3),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->MemoryBase0)),
- CardBus->BridgeControl & PCI_BIT_8 ? L" Prefetchable" : L"Non-Prefetchable",
- CardBus->MemoryBase0 & 0xfffff000,
- CardBus->MemoryLimit0 | 0x00000fff
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MEM_3),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->MemoryBase1)),
- CardBus->BridgeControl & PCI_BIT_9 ? L" Prefetchable" : L"Non-Prefetchable",
- CardBus->MemoryBase1 & 0xfffff000,
- CardBus->MemoryLimit1 | 0x00000fff
- );
-
- Io32Bit = (BOOLEAN) (CardBus->IoBase0 & PCI_BIT_0);
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_IO_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->IoBase0)),
- Io32Bit ? L" 32 bit" : L" 16 bit",
- CardBus->IoBase0 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
- (CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
- );
-
- Io32Bit = (BOOLEAN) (CardBus->IoBase1 & PCI_BIT_0);
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_IO_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->IoBase1)),
- Io32Bit ? L" 32 bit" : L" 16 bit",
- CardBus->IoBase1 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
- (CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
- );
-
- //
- // Print register Interrupt Line & PIN
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBus->InterruptLine)),
- CardBus->InterruptLine,
- INDEX_OF (&(CardBus->InterruptPin)),
- CardBus->InterruptPin
- );
-
- //
- // Print register Bridge Control
- //
- PciExplainBridgeControl (&(CardBus->BridgeControl), PciCardBusBridge);
-
- //
- // Print some registers in data region of PCI configuration space for cardbus
- // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
- // Address.
- //
- CardBusData = (PCI_CARDBUS_DATA *) ((UINT8 *) CardBus + sizeof (PCI_CARDBUS_HEADER));
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBusData->SubVendorId)),
- CardBusData->SubVendorId,
- INDEX_OF (&(CardBusData->SubSystemId)),
- CardBusData->SubSystemId
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_OPTIONAL),
- gShellDebug1HiiHandle,
- INDEX_OF (&(CardBusData->LegacyBase)),
- CardBusData->LegacyBase
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain each meaningful bit of register Status. The definition of Status is
- slightly different depending on the PCI header type.
-
- @param[in] Status Points to the content of register Status.
- @param[in] MainStatus Indicates if this register is main status(not secondary
- status).
- @param[in] HeaderType Header type of this PCI device.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainStatus (
- IN UINT16 *Status,
- IN BOOLEAN MainStatus,
- IN PCI_HEADER_TYPE HeaderType
- )
-{
- if (MainStatus) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status);
- }
-
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES), gShellDebug1HiiHandle, (*Status & PCI_BIT_4) != 0);
-
- //
- // Bit 5 is meaningless for CardBus Bridge
- //
- if (HeaderType == PciCardBusBridge) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE_2), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0);
- }
-
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST_BACK), gShellDebug1HiiHandle, (*Status & PCI_BIT_7) != 0);
-
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MASTER_DATA), gShellDebug1HiiHandle, (*Status & PCI_BIT_8) != 0);
- //
- // Bit 9 and bit 10 together decides the DEVSEL timing
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING), gShellDebug1HiiHandle);
- if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST), gShellDebug1HiiHandle);
-
- } else if ((*Status & PCI_BIT_9) != 0 && (*Status & PCI_BIT_10) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEDIUM), gShellDebug1HiiHandle);
-
- } else if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) != 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SLOW), gShellDebug1HiiHandle);
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED_2), gShellDebug1HiiHandle);
- }
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SIGNALED_TARGET),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_11) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_RECEIVED_TARGET),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_12) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_RECEIVED_MASTER),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_13) != 0
- );
-
- if (MainStatus) {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SIGNALED_ERROR),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_14) != 0
- );
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_RECEIVED_ERROR),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_14) != 0
- );
- }
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_DETECTED_ERROR),
- gShellDebug1HiiHandle,
- (*Status & PCI_BIT_15) != 0
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain each meaningful bit of register Command.
-
- @param[in] Command Points to the content of register Command.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainCommand (
- IN UINT16 *Command
- )
-{
- //
- // Print the binary value of register Command
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_COMMAND), gShellDebug1HiiHandle, INDEX_OF (Command), *Command);
-
- //
- // Explain register Command bit by bit
- //
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_0) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MEMORY_SPACE),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_1) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_2) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_3) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_4) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_5) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_ASSERT_PERR),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_6) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_7) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SERR_DRIVER),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_8) != 0
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_FAST_BACK_2),
- gShellDebug1HiiHandle,
- (*Command & PCI_BIT_9) != 0
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Explain each meaningful bit of register Bridge Control.
-
- @param[in] BridgeControl Points to the content of register Bridge Control.
- @param[in] HeaderType The headertype.
-
- @retval EFI_SUCCESS The command completed successfully.
-**/
-EFI_STATUS
-PciExplainBridgeControl (
- IN UINT16 *BridgeControl,
- IN PCI_HEADER_TYPE HeaderType
- )
-{
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL),
- gShellDebug1HiiHandle,
- INDEX_OF (BridgeControl),
- *BridgeControl
- );
-
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_PARITY_ERROR),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_0) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SERR_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_1) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_ISA_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_2) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_VGA_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_3) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_MASTER_ABORT),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_5) != 0
- );
-
- //
- // Register Bridge Control has some slight differences between P2P bridge
- // and Cardbus bridge from bit 6 to bit 11.
- //
- if (HeaderType == PciP2pBridge) {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_6) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_FAST_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_7) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_8)!=0 ? L"2^10" : L"2^15"
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_9)!=0 ? L"2^10" : L"2^15"
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_10) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_11) != 0
- );
-
- } else {
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_CARDBUS_RESET),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_6) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_IREQ_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_7) != 0
- );
- ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE),
- gShellDebug1HiiHandle,
- (*BridgeControl & PCI_BIT_10) != 0
- );
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Print each capability structure.
-
- @param[in] IoDev The pointer to the deivce.
- @param[in] Address The address to start at.
- @param[in] CapPtr The offset from the address.
- @param[in] EnhancedDump The print format for the dump data.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-PciExplainCapabilityStruct (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN UINT64 Address,
- IN UINT8 CapPtr,
- IN CONST UINT16 EnhancedDump
- )
-{
- UINT8 CapabilityPtr;
- UINT16 CapabilityEntry;
- UINT8 CapabilityID;
- UINT64 RegAddress;
-
- CapabilityPtr = CapPtr;
-
- //
- // Go through the Capability list
- //
- while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) {
- RegAddress = Address + CapabilityPtr;
- IoDev->Pci.Read (IoDev, EfiPciWidthUint16, RegAddress, 1, &CapabilityEntry);
-
- CapabilityID = (UINT8) CapabilityEntry;
-
- //
- // Explain PciExpress data
- //
- if (EFI_PCI_CAPABILITY_ID_PCIEXP == CapabilityID) {
- PciExplainPciExpress (IoDev, Address, CapabilityPtr, EnhancedDump);
- return EFI_SUCCESS;
- }
- //
- // Explain other capabilities here
- //
- CapabilityPtr = (UINT8) (CapabilityEntry >> 8);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieCapReg (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieCapReg;
- CHAR16 *DevicePortType;
-
- PcieCapReg = PciExpressCap->PcieCapReg;
- ShellPrintEx (-1, -1,
- L" Capability Version(3:0): %E0x%04x%N\r\n",
- PCIE_CAP_VERSION (PcieCapReg)
- );
- if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) {
- DevicePortType = DevicePortTypeTable[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg)];
- } else {
- DevicePortType = L"Unknown Type";
- }
- ShellPrintEx (-1, -1,
- L" Device/PortType(7:4): %E%s%N\r\n",
- DevicePortType
- );
- //
- // 'Slot Implemented' is only valid for:
- // a) Root Port of PCI Express Root Complex, or
- // b) Downstream Port of PCI Express Switch
- //
- if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT ||
- PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) {
- ShellPrintEx (-1, -1,
- L" Slot Implemented(8): %E%d%N\r\n",
- PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg)
- );
- }
- ShellPrintEx (-1, -1,
- L" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
- PCIE_CAP_INT_MSG_NUM (PcieCapReg)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieCapReg;
- UINT32 PcieDeviceCap;
- UINT8 DevicePortType;
- UINT8 L0sLatency;
- UINT8 L1Latency;
-
- PcieCapReg = PciExpressCap->PcieCapReg;
- PcieDeviceCap = PciExpressCap->PcieDeviceCap;
- DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg);
- ShellPrintEx (-1, -1, L" Max_Payload_Size Supported(2:0): ");
- if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) {
- ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));
- } else {
- ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
- }
- ShellPrintEx (-1, -1,
- L" Phantom Functions Supported(4:3): %E%d%N\r\n",
- PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap)
- );
- ShellPrintEx (-1, -1,
- L" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
- PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5
- );
- //
- // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
- //
- if (IS_PCIE_ENDPOINT (DevicePortType)) {
- L0sLatency = (UINT8) PCIE_CAP_L0SLATENCY (PcieDeviceCap);
- L1Latency = (UINT8) PCIE_CAP_L1LATENCY (PcieDeviceCap);
- ShellPrintEx (-1, -1, L" Endpoint L0s Acceptable Latency(8:6): ");
- if (L0sLatency < 4) {
- ShellPrintEx (-1, -1, L"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency + 6));
- } else {
- if (L0sLatency < 7) {
- ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L0sLatency - 3));
- } else {
- ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");
- }
- }
- ShellPrintEx (-1, -1, L" Endpoint L1 Acceptable Latency(11:9): ");
- if (L1Latency < 7) {
- ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L1Latency + 1));
- } else {
- ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");
- }
- }
- ShellPrintEx (-1, -1,
- L" Role-based Error Reporting(15): %E%d%N\r\n",
- PCIE_CAP_ERR_REPORTING (PcieDeviceCap)
- );
- //
- // Only valid for Upstream Port:
- // a) Captured Slot Power Limit Value
- // b) Captured Slot Power Scale
- //
- if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) {
- ShellPrintEx (-1, -1,
- L" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
- PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap)
- );
- ShellPrintEx (-1, -1,
- L" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
- SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)]
- );
- }
- //
- // Function Level Reset Capability is only valid for Endpoint
- //
- if (IS_PCIE_ENDPOINT (DevicePortType)) {
- ShellPrintEx (-1, -1,
- L" Function Level Reset Capability(28): %E%d%N\r\n",
- PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap)
- );
- }
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieCapReg;
- UINT16 PcieDeviceControl;
-
- PcieCapReg = PciExpressCap->PcieCapReg;
- PcieDeviceControl = PciExpressCap->DeviceControl;
- ShellPrintEx (-1, -1,
- L" Correctable Error Reporting Enable(0): %E%d%N\r\n",
- PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
- PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Fatal Error Reporting Enable(2): %E%d%N\r\n",
- PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
- PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Enable Relaxed Ordering(4): %E%d%N\r\n",
- PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1, L" Max_Payload_Size(7:5): ");
- if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) {
- ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));
- } else {
- ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
- }
- ShellPrintEx (-1, -1,
- L" Extended Tag Field Enable(8): %E%d%N\r\n",
- PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Phantom Functions Enable(9): %E%d%N\r\n",
- PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
- PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1,
- L" Enable No Snoop(11): %E%d%N\r\n",
- PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl)
- );
- ShellPrintEx (-1, -1, L" Max_Read_Request_Size(14:12): ");
- if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) {
- ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));
- } else {
- ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
- }
- //
- // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
- //
- if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) {
- ShellPrintEx (-1, -1,
- L" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
- PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl)
- );
- }
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieDeviceStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieDeviceStatus;
-
- PcieDeviceStatus = PciExpressCap->DeviceStatus;
- ShellPrintEx (-1, -1,
- L" Correctable Error Detected(0): %E%d%N\r\n",
- PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus)
- );
- ShellPrintEx (-1, -1,
- L" Non-Fatal Error Detected(1): %E%d%N\r\n",
- PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus)
- );
- ShellPrintEx (-1, -1,
- L" Fatal Error Detected(2): %E%d%N\r\n",
- PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus)
- );
- ShellPrintEx (-1, -1,
- L" Unsupported Request Detected(3): %E%d%N\r\n",
- PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus)
- );
- ShellPrintEx (-1, -1,
- L" AUX Power Detected(4): %E%d%N\r\n",
- PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus)
- );
- ShellPrintEx (-1, -1,
- L" Transactions Pending(5): %E%d%N\r\n",
- PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device link information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT32 PcieLinkCap;
- CHAR16 *MaxLinkSpeed;
- CHAR16 *AspmValue;
-
- PcieLinkCap = PciExpressCap->LinkCap;
- switch (PCIE_CAP_MAX_LINK_SPEED (PcieLinkCap)) {
- case 1:
- MaxLinkSpeed = L"2.5 GT/s";
- break;
- case 2:
- MaxLinkSpeed = L"5.0 GT/s";
- break;
- case 3:
- MaxLinkSpeed = L"8.0 GT/s";
- break;
- default:
- MaxLinkSpeed = L"Unknown";
- break;
- }
- ShellPrintEx (-1, -1,
- L" Maximum Link Speed(3:0): %E%s%N\r\n",
- MaxLinkSpeed
- );
- ShellPrintEx (-1, -1,
- L" Maximum Link Width(9:4): %Ex%d%N\r\n",
- PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap)
- );
- switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) {
- case 0:
- AspmValue = L"Not";
- break;
- case 1:
- AspmValue = L"L0s";
- break;
- case 2:
- AspmValue = L"L1";
- break;
- case 3:
- AspmValue = L"L0s and L1";
- break;
- default:
- AspmValue = L"Reserved";
- break;
- }
- ShellPrintEx (-1, -1,
- L" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
- AspmValue
- );
- ShellPrintEx (-1, -1,
- L" L0s Exit Latency(14:12): %E%s%N\r\n",
- L0sLatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
- );
- ShellPrintEx (-1, -1,
- L" L1 Exit Latency(17:15): %E%s%N\r\n",
- L1LatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
- );
- ShellPrintEx (-1, -1,
- L" Clock Power Management(18): %E%d%N\r\n",
- PCIE_CAP_CLOCK_PM (PcieLinkCap)
- );
- ShellPrintEx (-1, -1,
- L" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
- PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap)
- );
- ShellPrintEx (-1, -1,
- L" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
- PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap)
- );
- ShellPrintEx (-1, -1,
- L" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
- PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap)
- );
- ShellPrintEx (-1, -1,
- L" Port Number(31:24): %E0x%02x%N\r\n",
- PCIE_CAP_PORT_NUMBER (PcieLinkCap)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device link control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieLinkControl;
- UINT8 DevicePortType;
-
- PcieLinkControl = PciExpressCap->LinkControl;
- DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg);
- ShellPrintEx (-1, -1,
- L" Active State Power Management Control(1:0): %E%s%N\r\n",
- ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)]
- );
- //
- // RCB is not applicable to switches
- //
- if (!IS_PCIE_SWITCH(DevicePortType)) {
- ShellPrintEx (-1, -1,
- L" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
- 1 << (PCIE_CAP_RCB (PcieLinkControl) + 6)
- );
- }
- //
- // Link Disable is reserved on
- // a) Endpoints
- // b) PCI Express to PCI/PCI-X bridges
- // c) Upstream Ports of Switches
- //
- if (!IS_PCIE_ENDPOINT (DevicePortType) &&
- DevicePortType != PCIE_SWITCH_UPSTREAM_PORT &&
- DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) {
- ShellPrintEx (-1, -1,
- L" Link Disable(4): %E%d%N\r\n",
- PCIE_CAP_LINK_DISABLE (PcieLinkControl)
- );
- }
- ShellPrintEx (-1, -1,
- L" Common Clock Configuration(6): %E%d%N\r\n",
- PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl)
- );
- ShellPrintEx (-1, -1,
- L" Extended Synch(7): %E%d%N\r\n",
- PCIE_CAP_EXT_SYNC (PcieLinkControl)
- );
- ShellPrintEx (-1, -1,
- L" Enable Clock Power Management(8): %E%d%N\r\n",
- PCIE_CAP_CLK_PWR_MNG (PcieLinkControl)
- );
- ShellPrintEx (-1, -1,
- L" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
- PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl)
- );
- ShellPrintEx (-1, -1,
- L" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
- PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl)
- );
- ShellPrintEx (-1, -1,
- L" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
- PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device link status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieLinkStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieLinkStatus;
- CHAR16 *CurLinkSpeed;
-
- PcieLinkStatus = PciExpressCap->LinkStatus;
- switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) {
- case 1:
- CurLinkSpeed = L"2.5 GT/s";
- break;
- case 2:
- CurLinkSpeed = L"5.0 GT/s";
- break;
- case 3:
- CurLinkSpeed = L"8.0 GT/s";
- break;
- default:
- CurLinkSpeed = L"Reserved";
- break;
- }
- ShellPrintEx (-1, -1,
- L" Current Link Speed(3:0): %E%s%N\r\n",
- CurLinkSpeed
- );
- ShellPrintEx (-1, -1,
- L" Negotiated Link Width(9:4): %Ex%d%N\r\n",
- PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus)
- );
- ShellPrintEx (-1, -1,
- L" Link Training(11): %E%d%N\r\n",
- PCIE_CAP_LINK_TRAINING (PcieLinkStatus)
- );
- ShellPrintEx (-1, -1,
- L" Slot Clock Configuration(12): %E%d%N\r\n",
- PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus)
- );
- ShellPrintEx (-1, -1,
- L" Data Link Layer Link Active(13): %E%d%N\r\n",
- PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus)
- );
- ShellPrintEx (-1, -1,
- L" Link Bandwidth Management Status(14): %E%d%N\r\n",
- PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus)
- );
- ShellPrintEx (-1, -1,
- L" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
- PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device slot information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT32 PcieSlotCap;
-
- PcieSlotCap = PciExpressCap->SlotCap;
-
- ShellPrintEx (-1, -1,
- L" Attention Button Present(0): %E%d%N\r\n",
- PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Power Controller Present(1): %E%d%N\r\n",
- PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" MRL Sensor Present(2): %E%d%N\r\n",
- PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Attention Indicator Present(3): %E%d%N\r\n",
- PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Power Indicator Present(4): %E%d%N\r\n",
- PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Hot-Plug Surprise(5): %E%d%N\r\n",
- PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Hot-Plug Capable(6): %E%d%N\r\n",
- PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
- PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Slot Power Limit Scale(16:15): %E%s%N\r\n",
- SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)]
- );
- ShellPrintEx (-1, -1,
- L" Electromechanical Interlock Present(17): %E%d%N\r\n",
- PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" No Command Completed Support(18): %E%d%N\r\n",
- PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap)
- );
- ShellPrintEx (-1, -1,
- L" Physical Slot Number(31:19): %E%d%N\r\n",
- PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device slot control information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieSlotControl;
-
- PcieSlotControl = PciExpressCap->SlotControl;
- ShellPrintEx (-1, -1,
- L" Attention Button Pressed Enable(0): %E%d%N\r\n",
- PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Power Fault Detected Enable(1): %E%d%N\r\n",
- PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" MRL Sensor Changed Enable(2): %E%d%N\r\n",
- PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Presence Detect Changed Enable(3): %E%d%N\r\n",
- PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Command Completed Interrupt Enable(4): %E%d%N\r\n",
- PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
- PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Attention Indicator Control(7:6): %E%s%N\r\n",
- IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)]
- );
- ShellPrintEx (-1, -1,
- L" Power Indicator Control(9:8): %E%s%N\r\n",
- IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)]
- );
- ShellPrintEx (-1, -1, L" Power Controller Control(10): %EPower ");
- if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) {
- ShellPrintEx (-1, -1, L"Off%N\r\n");
- } else {
- ShellPrintEx (-1, -1, L"On%N\r\n");
- }
- ShellPrintEx (-1, -1,
- L" Electromechanical Interlock Control(11): %E%d%N\r\n",
- PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl)
- );
- ShellPrintEx (-1, -1,
- L" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
- PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device slot status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieSlotStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieSlotStatus;
-
- PcieSlotStatus = PciExpressCap->SlotStatus;
-
- ShellPrintEx (-1, -1,
- L" Attention Button Pressed(0): %E%d%N\r\n",
- PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus)
- );
- ShellPrintEx (-1, -1,
- L" Power Fault Detected(1): %E%d%N\r\n",
- PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus)
- );
- ShellPrintEx (-1, -1,
- L" MRL Sensor Changed(2): %E%d%N\r\n",
- PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus)
- );
- ShellPrintEx (-1, -1,
- L" Presence Detect Changed(3): %E%d%N\r\n",
- PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus)
- );
- ShellPrintEx (-1, -1,
- L" Command Completed(4): %E%d%N\r\n",
- PCIE_CAP_COMM_COMPLETED (PcieSlotStatus)
- );
- ShellPrintEx (-1, -1, L" MRL Sensor State(5): %EMRL ");
- if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) {
- ShellPrintEx (-1, -1, L" Opened%N\r\n");
- } else {
- ShellPrintEx (-1, -1, L" Closed%N\r\n");
- }
- ShellPrintEx (-1, -1, L" Presence Detect State(6): ");
- if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) {
- ShellPrintEx (-1, -1, L"%ECard Present in slot%N\r\n");
- } else {
- ShellPrintEx (-1, -1, L"%ESlot Empty%N\r\n");
- }
- ShellPrintEx (-1, -1, L" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
- if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) {
- ShellPrintEx (-1, -1, L"Engaged%N\r\n");
- } else {
- ShellPrintEx (-1, -1, L"Disengaged%N\r\n");
- }
- ShellPrintEx (-1, -1,
- L" Data Link Layer State Changed(8): %E%d%N\r\n",
- PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device root information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootControl (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieRootControl;
-
- PcieRootControl = PciExpressCap->RootControl;
-
- ShellPrintEx (-1, -1,
- L" System Error on Correctable Error Enable(0): %E%d%N\r\n",
- PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl)
- );
- ShellPrintEx (-1, -1,
- L" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
- PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl)
- );
- ShellPrintEx (-1, -1,
- L" System Error on Fatal Error Enable(2): %E%d%N\r\n",
- PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl)
- );
- ShellPrintEx (-1, -1,
- L" PME Interrupt Enable(3): %E%d%N\r\n",
- PCIE_CAP_PME_INT_ENABLE (PcieRootControl)
- );
- ShellPrintEx (-1, -1,
- L" CRS Software Visibility Enable(4): %E%d%N\r\n",
- PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device root capability information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootCap (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT16 PcieRootCap;
-
- PcieRootCap = PciExpressCap->RsvdP;
-
- ShellPrintEx (-1, -1,
- L" CRS Software Visibility(0): %E%d%N\r\n",
- PCIE_CAP_CRS_SW_VIS (PcieRootCap)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Print out information of the device root status information.
-
- @param[in] PciExpressCap The pointer to the structure about the device.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-ExplainPcieRootStatus (
- IN PCIE_CAP_STRUCTURE *PciExpressCap
- )
-{
- UINT32 PcieRootStatus;
-
- PcieRootStatus = PciExpressCap->RootStatus;
-
- ShellPrintEx (-1, -1,
- L" PME Requester ID(15:0): %E0x%04x%N\r\n",
- PCIE_CAP_PME_REQ_ID (PcieRootStatus)
- );
- ShellPrintEx (-1, -1,
- L" PME Status(16): %E%d%N\r\n",
- PCIE_CAP_PME_STATUS (PcieRootStatus)
- );
- ShellPrintEx (-1, -1,
- L" PME Pending(17): %E%d%N\r\n",
- PCIE_CAP_PME_PENDING (PcieRootStatus)
- );
- return EFI_SUCCESS;
-}
-
-/**
- Function to interpret and print out the link control structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityLinkControl (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_LINK_CONTROL),
- gShellDebug1HiiHandle,
- Header->RootComplexLinkCapabilities,
- Header->RootComplexLinkControl,
- Header->RootComplexLinkStatus
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the power budgeting structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityPowerBudgeting (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_POWER),
- gShellDebug1HiiHandle,
- Header->DataSelect,
- Header->Data,
- Header->PowerBudgetCapability
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the ACS structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityAcs (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED *Header;
- UINT16 VectorSize;
- UINT16 LoopCounter;
-
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED*)HeaderAddress;
- VectorSize = 0;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_ACS),
- gShellDebug1HiiHandle,
- Header->AcsCapability,
- Header->AcsControl
- );
- if (PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_CONTROL(Header)) {
- VectorSize = PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_VECTOR_SIZE(Header);
- if (VectorSize == 0) {
- VectorSize = 256;
- }
- for (LoopCounter = 0 ; LoopCounter * 8 < VectorSize ; LoopCounter++) {
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_ACS2),
- gShellDebug1HiiHandle,
- LoopCounter + 1,
- Header->EgressControlVectorArray[LoopCounter]
- );
- }
- }
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED) + (VectorSize / 8) - 1,
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the latency tolerance reporting structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityLatencyToleranceReporting (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_LAT),
- gShellDebug1HiiHandle,
- Header->MaxSnoopLatency,
- Header->MaxNoSnoopLatency
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the serial number structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilitySerialNumber (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_SN),
- gShellDebug1HiiHandle,
- Header->SerialNumber
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the RCRB structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityRcrb (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_RCRB),
- gShellDebug1HiiHandle,
- Header->VendorId,
- Header->DeviceId,
- Header->RcrbCapabilities,
- Header->RcrbControl
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the vendor specific structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityVendorSpecific (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_VEN),
- gShellDebug1HiiHandle,
- Header->VendorSpecificHeader
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_GET_SIZE(Header),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the Event Collector Endpoint Association structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityECEA (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_ECEA),
- gShellDebug1HiiHandle,
- Header->AssociationBitmap
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the ARI structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityAri (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_ARI),
- gShellDebug1HiiHandle,
- Header->AriCapability,
- Header->AriControl
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the DPA structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityDynamicPowerAllocation (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION *Header;
- UINT8 LinkCount;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_DPA),
- gShellDebug1HiiHandle,
- Header->DpaCapability,
- Header->DpaLatencyIndicator,
- Header->DpaStatus,
- Header->DpaControl
- );
- for (LinkCount = 0 ; LinkCount < PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header) + 1 ; LinkCount++) {
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_DPA2),
- gShellDebug1HiiHandle,
- LinkCount+1,
- Header->DpaPowerAllocationArray[LinkCount]
- );
- }
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION) - 1 + PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the link declaration structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityLinkDeclaration (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION *Header;
- UINT8 LinkCount;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR),
- gShellDebug1HiiHandle,
- Header->ElementSelfDescription
- );
-
- for (LinkCount = 0 ; LinkCount < PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header) ; LinkCount++) {
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR2),
- gShellDebug1HiiHandle,
- LinkCount+1,
- Header->LinkEntry[LinkCount]
- );
- }
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION) + (PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header)-1)*sizeof(UINT32),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the Advanced Error Reporting structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityAer (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_AER),
- gShellDebug1HiiHandle,
- Header->UncorrectableErrorStatus,
- Header->UncorrectableErrorMask,
- Header->UncorrectableErrorSeverity,
- Header->CorrectableErrorStatus,
- Header->CorrectableErrorMask,
- Header->AdvancedErrorCapabilitiesAndControl,
- Header->HeaderLog,
- Header->RootErrorCommand,
- Header->RootErrorStatus,
- Header->ErrorSourceIdentification,
- Header->CorrectableErrorSourceIdentification,
- Header->TlpPrefixLog[0],
- Header->TlpPrefixLog[1],
- Header->TlpPrefixLog[2],
- Header->TlpPrefixLog[3]
- );
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING),
- (VOID *) (HeaderAddress)
- );
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the multicast structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
- @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityMulticast (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
- IN CONST PCIE_CAP_STRUCTURE *PciExpressCapPtr
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_MULTICAST),
- gShellDebug1HiiHandle,
- Header->MultiCastCapability,
- Header->MulticastControl,
- Header->McBaseAddress,
- Header->McReceiveAddress,
- Header->McBlockAll,
- Header->McBlockUntranslated,
- Header->McOverlayBar
- );
-
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST),
- (VOID *) (HeaderAddress)
- );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the virtual channel and multi virtual channel structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityVirtualChannel (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY *Header;
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC *CapabilityItem;
- UINT32 ItemCount;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_VC_BASE),
- gShellDebug1HiiHandle,
- Header->ExtendedVcCount,
- Header->PortVcCapability1,
- Header->PortVcCapability2,
- Header->VcArbTableOffset,
- Header->PortVcControl,
- Header->PortVcStatus
- );
- for (ItemCount = 0 ; ItemCount < Header->ExtendedVcCount ; ItemCount++) {
- CapabilityItem = &Header->Capability[ItemCount];
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_VC_ITEM),
- gShellDebug1HiiHandle,
- ItemCount+1,
- CapabilityItem->VcResourceCapability,
- CapabilityItem->PortArbTableOffset,
- CapabilityItem->VcResourceControl,
- CapabilityItem->VcResourceStatus
- );
- }
-
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC) + (Header->ExtendedVcCount - 1) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY),
- (VOID *) (HeaderAddress)
- );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the resizeable bar structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityResizeableBar (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR *Header;
- UINT32 ItemCount;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR*)HeaderAddress;
-
- for (ItemCount = 0 ; ItemCount < (UINT32)GET_NUMBER_RESIZABLE_BARS(Header) ; ItemCount++) {
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_RESIZE_BAR),
- gShellDebug1HiiHandle,
- ItemCount+1,
- Header->Capability[ItemCount].ResizableBarCapability,
- Header->Capability[ItemCount].ResizableBarControl
- );
- }
-
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- (UINT32)GET_NUMBER_RESIZABLE_BARS(Header) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY),
- (VOID *) (HeaderAddress)
- );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the TPH structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilityTph (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_TPH),
- gShellDebug1HiiHandle,
- Header->TphRequesterCapability,
- Header->TphRequesterControl
- );
- DumpHex (
- 8,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)Header->TphStTable - (UINT8*)HeadersBaseAddress),
- GET_TPH_TABLE_SIZE(Header),
- (VOID *)Header->TphStTable
- );
-
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH) + GET_TPH_TABLE_SIZE(Header) - sizeof(UINT16),
- (VOID *) (HeaderAddress)
- );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to interpret and print out the secondary PCIe capability structure
-
- @param[in] HeaderAddress The Address of this capability header.
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
- @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
-**/
-EFI_STATUS
-EFIAPI
-PrintInterpretedExtendedCompatibilitySecondary (
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
- IN CONST PCIE_CAP_STRUCTURE *PciExpressCapPtr
- )
-{
- CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE *Header;
- Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE*)HeaderAddress;
-
- ShellPrintHiiEx(
- -1, -1, NULL,
- STRING_TOKEN (STR_PCI_EXT_CAP_SECONDARY),
- gShellDebug1HiiHandle,
- Header->LinkControl3,
- Header->LaneErrorStatus
- );
- DumpHex (
- 8,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)Header->EqualizationControl - (UINT8*)HeadersBaseAddress),
- PCIE_CAP_MAX_LINK_WIDTH(PciExpressCapPtr->LinkCap),
- (VOID *)Header->EqualizationControl
- );
-
- DumpHex (
- 4,
- EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
- sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH) - sizeof(Header->EqualizationControl) + PCIE_CAP_MAX_LINK_WIDTH(PciExpressCapPtr->LinkCap),
- (VOID *) (HeaderAddress)
- );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Display Pcie extended capability details
-
- @param[in] HeadersBaseAddress The address of all the extended capability headers.
- @param[in] HeaderAddress The address of this capability header.
- @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
-**/
-EFI_STATUS
-EFIAPI
-PrintPciExtendedCapabilityDetails(
- IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
- IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
- IN CONST PCIE_CAP_STRUCTURE *PciExpressCapPtr
- )
-{
- switch (HeaderAddress->CapabilityId){
- case PCI_EXPRESS_EXTENDED_CAPABILITY_ADVANCED_ERROR_REPORTING_ID:
- return PrintInterpretedExtendedCompatibilityAer(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_CONTROL_ID:
- return PrintInterpretedExtendedCompatibilityLinkControl(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_ID:
- return PrintInterpretedExtendedCompatibilityLinkDeclaration(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_SERIAL_NUMBER_ID:
- return PrintInterpretedExtendedCompatibilitySerialNumber(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_POWER_BUDGETING_ID:
- return PrintInterpretedExtendedCompatibilityPowerBudgeting(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_ID:
- return PrintInterpretedExtendedCompatibilityAcs(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID:
- return PrintInterpretedExtendedCompatibilityLatencyToleranceReporting(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_ARI_CAPABILITY_ID:
- return PrintInterpretedExtendedCompatibilityAri(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_RCRB_HEADER_ID:
- return PrintInterpretedExtendedCompatibilityRcrb(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_ID:
- return PrintInterpretedExtendedCompatibilityVendorSpecific(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_ID:
- return PrintInterpretedExtendedCompatibilityDynamicPowerAllocation(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_ID:
- return PrintInterpretedExtendedCompatibilityECEA(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_VIRTUAL_CHANNEL_ID:
- case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTI_FUNCTION_VIRTUAL_CHANNEL_ID:
- return PrintInterpretedExtendedCompatibilityVirtualChannel(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTICAST_ID:
- //
- // should only be present if PCIE_CAP_DEVICEPORT_TYPE(PciExpressCapPtr->PcieCapReg) == 0100b, 0101b, or 0110b
- //
- return PrintInterpretedExtendedCompatibilityMulticast(HeaderAddress, HeadersBaseAddress, PciExpressCapPtr);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_RESIZABLE_BAR_ID:
- return PrintInterpretedExtendedCompatibilityResizeableBar(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_TPH_ID:
- return PrintInterpretedExtendedCompatibilityTph(HeaderAddress, HeadersBaseAddress);
- case PCI_EXPRESS_EXTENDED_CAPABILITY_SECONDARY_PCIE_ID:
- return PrintInterpretedExtendedCompatibilitySecondary(HeaderAddress, HeadersBaseAddress, PciExpressCapPtr);
- default:
- ShellPrintEx (-1, -1,
- L"Unknown PCIe extended capability ID (%04xh). No interpretation available.\r\n",
- HeaderAddress->CapabilityId
- );
- return EFI_SUCCESS;
- };
-
-}
-
-/**
- Display Pcie device structure.
-
- @param[in] IoDev The pointer to the root pci protocol.
- @param[in] Address The Address to start at.
- @param[in] CapabilityPtr The offset from the address to start.
- @param[in] EnhancedDump The print format for the dump data.
-
-**/
-EFI_STATUS
-PciExplainPciExpress (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
- IN UINT64 Address,
- IN UINT8 CapabilityPtr,
- IN CONST UINT16 EnhancedDump
- )
-{
-
- PCIE_CAP_STRUCTURE PciExpressCap;
- EFI_STATUS Status;
- UINT64 CapRegAddress;
- UINT8 Bus;
- UINT8 Dev;
- UINT8 Func;
- UINT8 *ExRegBuffer;
- UINTN ExtendRegSize;
- UINT64 Pciex_Address;
- UINT8 DevicePortType;
- UINTN Index;
- UINT8 *RegAddr;
- UINTN RegValue;
- PCI_EXP_EXT_HDR *ExtHdr;
-
- CapRegAddress = Address + CapabilityPtr;
- IoDev->Pci.Read (
- IoDev,
- EfiPciWidthUint32,
- CapRegAddress,
- sizeof (PciExpressCap) / sizeof (UINT32),
- &PciExpressCap
- );
-
- DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg);
-
- ShellPrintEx (-1, -1, L"\r\nPci Express device capability structure:\r\n");
-
- for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) {
- if (ShellGetExecutionBreakFlag()) {
- goto Done;
- }
- RegAddr = ((UINT8 *) &PciExpressCap) + PcieExplainList[Index].Offset;
- switch (PcieExplainList[Index].Width) {
- case FieldWidthUINT8:
- RegValue = *(UINT8 *) RegAddr;
- break;
- case FieldWidthUINT16:
- RegValue = *(UINT16 *) RegAddr;
- break;
- case FieldWidthUINT32:
- RegValue = *(UINT32 *) RegAddr;
- break;
- default:
- RegValue = 0;
- break;
- }
- ShellPrintHiiEx(-1, -1, NULL,
- PcieExplainList[Index].Token,
- gShellDebug1HiiHandle,
- PcieExplainList[Index].Offset,
- RegValue
- );
- if (PcieExplainList[Index].Func == NULL) {
- continue;
- }
- switch (PcieExplainList[Index].Type) {
- case PcieExplainTypeLink:
- //
- // Link registers should not be used by
- // a) Root Complex Integrated Endpoint
- // b) Root Complex Event Collector
- //
- if (DevicePortType == PCIE_ROOT_COMPLEX_INTEGRATED_PORT ||
- DevicePortType == PCIE_ROOT_COMPLEX_EVENT_COLLECTOR) {
- continue;
- }
- break;
- case PcieExplainTypeSlot:
- //
- // Slot registers are only valid for
- // a) Root Port of PCI Express Root Complex
- // b) Downstream Port of PCI Express Switch
- // and when SlotImplemented bit is set in PCIE cap register.
- //
- if ((DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT &&
- DevicePortType != PCIE_SWITCH_DOWNSTREAM_PORT) ||
- !PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap.PcieCapReg)) {
- continue;
- }
- break;
- case PcieExplainTypeRoot:
- //
- // Root registers are only valid for
- // Root Port of PCI Express Root Complex
- //
- if (DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT) {
- continue;
- }
- break;
- default:
- break;
- }
- PcieExplainList[Index].Func (&PciExpressCap);
- }
-
- Bus = (UINT8) (RShiftU64 (Address, 24));
- Dev = (UINT8) (RShiftU64 (Address, 16));
- Func = (UINT8) (RShiftU64 (Address, 8));
-
- Pciex_Address = CALC_EFI_PCIEX_ADDRESS (Bus, Dev, Func, EFI_PCIE_CAPABILITY_BASE_OFFSET);
-
- ExtendRegSize = 0x1000 - EFI_PCIE_CAPABILITY_BASE_OFFSET;
-
- ExRegBuffer = (UINT8 *) AllocateZeroPool (ExtendRegSize);
-
- //
- // PciRootBridgeIo protocol should support pci express extend space IO
- // (Begins at offset EFI_PCIE_CAPABILITY_BASE_OFFSET)
- //
- Status = IoDev->Pci.Read (
- IoDev,
- EfiPciWidthUint32,
- Pciex_Address,
- (ExtendRegSize) / sizeof (UINT32),
- (VOID *) (ExRegBuffer)
- );
- if (EFI_ERROR (Status) || ExRegBuffer == NULL) {
- SHELL_FREE_NON_NULL(ExRegBuffer);
- return EFI_UNSUPPORTED;
- }
-
- if (EnhancedDump == 0) {
- //
- // Print the PciEx extend space in raw bytes ( 0xFF-0xFFF)
- //
- ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
-
- DumpHex (
- 2,
- EFI_PCIE_CAPABILITY_BASE_OFFSET,
- ExtendRegSize,
- (VOID *) (ExRegBuffer)
- );
- } else {
- ExtHdr = (PCI_EXP_EXT_HDR*)ExRegBuffer;
- while (ExtHdr->CapabilityId != 0 && ExtHdr->CapabilityVersion != 0) {
- //
- // Process this item
- //
- if (EnhancedDump == 0xFFFF || EnhancedDump == ExtHdr->CapabilityId) {
- //
- // Print this item
- //
- PrintPciExtendedCapabilityDetails((PCI_EXP_EXT_HDR*)ExRegBuffer, ExtHdr, &PciExpressCap);
- }
-
- //
- // Advance to the next item if it exists
- //
- if (ExtHdr->NextCapabilityOffset != 0) {
- ExtHdr = (PCI_EXP_EXT_HDR*)((UINT8*)ExRegBuffer + ExtHdr->NextCapabilityOffset);
- } else {
- break;
- }
- }
- }
- SHELL_FREE_NON_NULL(ExRegBuffer);
-
-Done:
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h
deleted file mode 100644
index 1b06154842..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h
+++ /dev/null
@@ -1,463 +0,0 @@
-/** @file
- Header file for Pci shell Debug1 function.
-
- Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _EFI_SHELL_PCI_H_
-#define _EFI_SHELL_PCI_H_
-
-typedef enum {
- PciDevice,
- PciP2pBridge,
- PciCardBusBridge,
- PciUndefined
-} PCI_HEADER_TYPE;
-
-#define HEADER_TYPE_MULTI_FUNCTION 0x80
-
-#define MAX_BUS_NUMBER 255
-#define MAX_DEVICE_NUMBER 31
-#define MAX_FUNCTION_NUMBER 7
-
-#define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10
-#define EFI_PCI_CAPABILITY_ID_PCIX 0x07
-
-#define CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, Reg) \
- ((UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + ((UINTN) Reg)))
-
-#define CALC_EFI_PCIEX_ADDRESS(Bus, Dev, Func, ExReg) ( \
- (UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + (LShiftU64 ((UINT64) ExReg, 32))) \
- );
-
-#define INDEX_OF(Field) ((UINT8 *) (Field) - (UINT8 *) mConfigSpace)
-
-#define PCI_BIT_0 0x00000001
-#define PCI_BIT_1 0x00000002
-#define PCI_BIT_2 0x00000004
-#define PCI_BIT_3 0x00000008
-#define PCI_BIT_4 0x00000010
-#define PCI_BIT_5 0x00000020
-#define PCI_BIT_6 0x00000040
-#define PCI_BIT_7 0x00000080
-#define PCI_BIT_8 0x00000100
-#define PCI_BIT_9 0x00000200
-#define PCI_BIT_10 0x00000400
-#define PCI_BIT_11 0x00000800
-#define PCI_BIT_12 0x00001000
-#define PCI_BIT_13 0x00002000
-#define PCI_BIT_14 0x00004000
-#define PCI_BIT_15 0x00008000
-
-//
-// PCIE device/port types
-//
-#define PCIE_PCIE_ENDPOINT 0
-#define PCIE_LEGACY_PCIE_ENDPOINT 1
-#define PCIE_ROOT_COMPLEX_ROOT_PORT 4
-#define PCIE_SWITCH_UPSTREAM_PORT 5
-#define PCIE_SWITCH_DOWNSTREAM_PORT 6
-#define PCIE_PCIE_TO_PCIX_BRIDGE 7
-#define PCIE_PCIX_TO_PCIE_BRIDGE 8
-#define PCIE_ROOT_COMPLEX_INTEGRATED_PORT 9
-#define PCIE_ROOT_COMPLEX_EVENT_COLLECTOR 10
-#define PCIE_DEVICE_PORT_TYPE_MAX 11
-
-#define IS_PCIE_ENDPOINT(DevicePortType) \
- ((DevicePortType) == PCIE_PCIE_ENDPOINT || \
- (DevicePortType) == PCIE_LEGACY_PCIE_ENDPOINT || \
- (DevicePortType) == PCIE_ROOT_COMPLEX_INTEGRATED_PORT)
-
-#define IS_PCIE_SWITCH(DevicePortType) \
- ((DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) || \
- (DevicePortType == PCIE_SWITCH_DOWNSTREAM_PORT))
-
-//
-// Capabilities Register
-//
-#define PCIE_CAP_VERSION(PcieCapReg) \
- ((PcieCapReg) & 0x0f)
-#define PCIE_CAP_DEVICEPORT_TYPE(PcieCapReg) \
- (((PcieCapReg) >> 4) & 0x0f)
-#define PCIE_CAP_SLOT_IMPLEMENTED(PcieCapReg) \
- (((PcieCapReg) >> 8) & 0x1)
-#define PCIE_CAP_INT_MSG_NUM(PcieCapReg) \
- (((PcieCapReg) >> 9) & 0x1f)
-//
-// Device Capabilities Register
-//
-#define PCIE_CAP_MAX_PAYLOAD(PcieDeviceCap) \
- ((PcieDeviceCap) & 0x7)
-#define PCIE_CAP_PHANTOM_FUNC(PcieDeviceCap) \
- (((PcieDeviceCap) >> 3) & 0x3)
-#define PCIE_CAP_EXTENDED_TAG(PcieDeviceCap) \
- (((PcieDeviceCap) >> 5) & 0x1)
-#define PCIE_CAP_L0SLATENCY(PcieDeviceCap) \
- (((PcieDeviceCap) >> 6) & 0x7)
-#define PCIE_CAP_L1LATENCY(PcieDeviceCap) \
- (((PcieDeviceCap) >> 9) & 0x7)
-#define PCIE_CAP_ERR_REPORTING(PcieDeviceCap) \
- (((PcieDeviceCap) >> 15) & 0x1)
-#define PCIE_CAP_SLOT_POWER_VALUE(PcieDeviceCap) \
- (((PcieDeviceCap) >> 18) & 0x0ff)
-#define PCIE_CAP_SLOT_POWER_SCALE(PcieDeviceCap) \
- (((PcieDeviceCap) >> 26) & 0x3)
-#define PCIE_CAP_FUNC_LEVEL_RESET(PcieDeviceCap) \
- (((PcieDeviceCap) >> 28) & 0x1)
-//
-// Device Control Register
-//
-#define PCIE_CAP_COR_ERR_REPORTING_ENABLE(PcieDeviceControl) \
- ((PcieDeviceControl) & 0x1)
-#define PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 1) & 0x1)
-#define PCIE_CAP_FATAL_ERR_REPORTING_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 2) & 0x1)
-#define PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 3) & 0x1)
-#define PCIE_CAP_RELAXED_ORDERING_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 4) & 0x1)
-#define PCIE_CAP_MAX_PAYLOAD_SIZE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 5) & 0x7)
-#define PCIE_CAP_EXTENDED_TAG_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 8) & 0x1)
-#define PCIE_CAP_PHANTOM_FUNC_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 9) & 0x1)
-#define PCIE_CAP_AUX_PM_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 10) & 0x1)
-#define PCIE_CAP_NO_SNOOP_ENABLE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 11) & 0x1)
-#define PCIE_CAP_MAX_READ_REQ_SIZE(PcieDeviceControl) \
- (((PcieDeviceControl) >> 12) & 0x7)
-#define PCIE_CAP_BRG_CONF_RETRY(PcieDeviceControl) \
- (((PcieDeviceControl) >> 15) & 0x1)
-//
-// Device Status Register
-//
-#define PCIE_CAP_COR_ERR_DETECTED(PcieDeviceStatus) \
- ((PcieDeviceStatus) & 0x1)
-#define PCIE_CAP_NONFAT_ERR_DETECTED(PcieDeviceStatus) \
- (((PcieDeviceStatus) >> 1) & 0x1)
-#define PCIE_CAP_FATAL_ERR_DETECTED(PcieDeviceStatus) \
- (((PcieDeviceStatus) >> 2) & 0x1)
-#define PCIE_CAP_UNSUP_REQ_DETECTED(PcieDeviceStatus) \
- (((PcieDeviceStatus) >> 3) & 0x1)
-#define PCIE_CAP_AUX_POWER_DETECTED(PcieDeviceStatus) \
- (((PcieDeviceStatus) >> 4) & 0x1)
-#define PCIE_CAP_TRANSACTION_PENDING(PcieDeviceStatus) \
- (((PcieDeviceStatus) >> 5) & 0x1)
-//
-// Link Capabilities Register
-//
-#define PCIE_CAP_MAX_LINK_SPEED(PcieLinkCap) \
- ((PcieLinkCap) & 0x0f)
-#define PCIE_CAP_MAX_LINK_WIDTH(PcieLinkCap) \
- (((PcieLinkCap) >> 4) & 0x3f)
-#define PCIE_CAP_ASPM_SUPPORT(PcieLinkCap) \
- (((PcieLinkCap) >> 10) & 0x3)
-#define PCIE_CAP_L0S_LATENCY(PcieLinkCap) \
- (((PcieLinkCap) >> 12) & 0x7)
-#define PCIE_CAP_L1_LATENCY(PcieLinkCap) \
- (((PcieLinkCap) >> 15) & 0x7)
-#define PCIE_CAP_CLOCK_PM(PcieLinkCap) \
- (((PcieLinkCap) >> 18) & 0x1)
-#define PCIE_CAP_SUP_DOWN_ERR_REPORTING(PcieLinkCap) \
- (((PcieLinkCap) >> 19) & 0x1)
-#define PCIE_CAP_LINK_ACTIVE_REPORTING(PcieLinkCap) \
- (((PcieLinkCap) >> 20) & 0x1)
-#define PCIE_CAP_LINK_BWD_NOTIF_CAP(PcieLinkCap) \
- (((PcieLinkCap) >> 21) & 0x1)
-#define PCIE_CAP_PORT_NUMBER(PcieLinkCap) \
- (((PcieLinkCap) >> 24) & 0x0ff)
-//
-// Link Control Register
-//
-#define PCIE_CAP_ASPM_CONTROL(PcieLinkControl) \
- ((PcieLinkControl) & 0x3)
-#define PCIE_CAP_RCB(PcieLinkControl) \
- (((PcieLinkControl) >> 3) & 0x1)
-#define PCIE_CAP_LINK_DISABLE(PcieLinkControl) \
- (((PcieLinkControl) >> 4) & 0x1)
-#define PCIE_CAP_COMMON_CLK_CONF(PcieLinkControl) \
- (((PcieLinkControl) >> 6) & 0x1)
-#define PCIE_CAP_EXT_SYNC(PcieLinkControl) \
- (((PcieLinkControl) >> 7) & 0x1)
-#define PCIE_CAP_CLK_PWR_MNG(PcieLinkControl) \
- (((PcieLinkControl) >> 8) & 0x1)
-#define PCIE_CAP_HW_AUTO_WIDTH_DISABLE(PcieLinkControl) \
- (((PcieLinkControl) >> 9) & 0x1)
-#define PCIE_CAP_LINK_BDW_MNG_INT_EN(PcieLinkControl) \
- (((PcieLinkControl) >> 10) & 0x1)
-#define PCIE_CAP_LINK_AUTO_BDW_INT_EN(PcieLinkControl) \
- (((PcieLinkControl) >> 11) & 0x1)
-//
-// Link Status Register
-//
-#define PCIE_CAP_CUR_LINK_SPEED(PcieLinkStatus) \
- ((PcieLinkStatus) & 0x0f)
-#define PCIE_CAP_NEGO_LINK_WIDTH(PcieLinkStatus) \
- (((PcieLinkStatus) >> 4) & 0x3f)
-#define PCIE_CAP_LINK_TRAINING(PcieLinkStatus) \
- (((PcieLinkStatus) >> 11) & 0x1)
-#define PCIE_CAP_SLOT_CLK_CONF(PcieLinkStatus) \
- (((PcieLinkStatus) >> 12) & 0x1)
-#define PCIE_CAP_DATA_LINK_ACTIVE(PcieLinkStatus) \
- (((PcieLinkStatus) >> 13) & 0x1)
-#define PCIE_CAP_LINK_BDW_MNG_STAT(PcieLinkStatus) \
- (((PcieLinkStatus) >> 14) & 0x1)
-#define PCIE_CAP_LINK_AUTO_BDW_STAT(PcieLinkStatus) \
- (((PcieLinkStatus) >> 15) & 0x1)
-//
-// Slot Capabilities Register
-//
-#define PCIE_CAP_ATT_BUT_PRESENT(PcieSlotCap) \
- ((PcieSlotCap) & 0x1)
-#define PCIE_CAP_PWR_CTRLLER_PRESENT(PcieSlotCap) \
- (((PcieSlotCap) >> 1) & 0x1)
-#define PCIE_CAP_MRL_SENSOR_PRESENT(PcieSlotCap) \
- (((PcieSlotCap) >> 2) & 0x1)
-#define PCIE_CAP_ATT_IND_PRESENT(PcieSlotCap) \
- (((PcieSlotCap) >> 3) & 0x1)
-#define PCIE_CAP_PWD_IND_PRESENT(PcieSlotCap) \
- (((PcieSlotCap) >> 4) & 0x1)
-#define PCIE_CAP_HOTPLUG_SUPPRISE(PcieSlotCap) \
- (((PcieSlotCap) >> 5) & 0x1)
-#define PCIE_CAP_HOTPLUG_CAPABLE(PcieSlotCap) \
- (((PcieSlotCap) >> 6) & 0x1)
-#define PCIE_CAP_SLOT_PWR_LIMIT_VALUE(PcieSlotCap) \
- (((PcieSlotCap) >> 7) & 0x0ff)
-#define PCIE_CAP_SLOT_PWR_LIMIT_SCALE(PcieSlotCap) \
- (((PcieSlotCap) >> 15) & 0x3)
-#define PCIE_CAP_ELEC_INTERLOCK_PRESENT(PcieSlotCap) \
- (((PcieSlotCap) >> 17) & 0x1)
-#define PCIE_CAP_NO_COMM_COMPLETED_SUP(PcieSlotCap) \
- (((PcieSlotCap) >> 18) & 0x1)
-#define PCIE_CAP_PHY_SLOT_NUM(PcieSlotCap) \
- (((PcieSlotCap) >> 19) & 0x1fff)
-//
-// Slot Control Register
-//
-#define PCIE_CAP_ATT_BUT_ENABLE(PcieSlotControl) \
- ((PcieSlotControl) & 0x1)
-#define PCIE_CAP_PWR_FLT_DETECT_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 1) & 0x1)
-#define PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 2) & 0x1)
-#define PCIE_CAP_PRES_DETECT_CHANGE_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 3) & 0x1)
-#define PCIE_CAP_COMM_CMPL_INT_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 4) & 0x1)
-#define PCIE_CAP_HOTPLUG_INT_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 5) & 0x1)
-#define PCIE_CAP_ATT_IND_CTRL(PcieSlotControl) \
- (((PcieSlotControl) >> 6) & 0x3)
-#define PCIE_CAP_PWR_IND_CTRL(PcieSlotControl) \
- (((PcieSlotControl) >> 8) & 0x3)
-#define PCIE_CAP_PWR_CTRLLER_CTRL(PcieSlotControl) \
- (((PcieSlotControl) >> 10) & 0x1)
-#define PCIE_CAP_ELEC_INTERLOCK_CTRL(PcieSlotControl) \
- (((PcieSlotControl) >> 11) & 0x1)
-#define PCIE_CAP_DLINK_STAT_CHANGE_ENABLE(PcieSlotControl) \
- (((PcieSlotControl) >> 12) & 0x1)
-//
-// Slot Status Register
-//
-#define PCIE_CAP_ATT_BUT_PRESSED(PcieSlotStatus) \
- ((PcieSlotStatus) & 0x1)
-#define PCIE_CAP_PWR_FLT_DETECTED(PcieSlotStatus) \
- (((PcieSlotStatus) >> 1) & 0x1)
-#define PCIE_CAP_MRL_SENSOR_CHANGED(PcieSlotStatus) \
- (((PcieSlotStatus) >> 2) & 0x1)
-#define PCIE_CAP_PRES_DETECT_CHANGED(PcieSlotStatus) \
- (((PcieSlotStatus) >> 3) & 0x1)
-#define PCIE_CAP_COMM_COMPLETED(PcieSlotStatus) \
- (((PcieSlotStatus) >> 4) & 0x1)
-#define PCIE_CAP_MRL_SENSOR_STATE(PcieSlotStatus) \
- (((PcieSlotStatus) >> 5) & 0x1)
-#define PCIE_CAP_PRES_DETECT_STATE(PcieSlotStatus) \
- (((PcieSlotStatus) >> 6) & 0x1)
-#define PCIE_CAP_ELEC_INTERLOCK_STATE(PcieSlotStatus) \
- (((PcieSlotStatus) >> 7) & 0x1)
-#define PCIE_CAP_DLINK_STAT_CHANGED(PcieSlotStatus) \
- (((PcieSlotStatus) >> 8) & 0x1)
-//
-// Root Control Register
-//
-#define PCIE_CAP_SYSERR_ON_CORERR_EN(PcieRootControl) \
- ((PcieRootControl) & 0x1)
-#define PCIE_CAP_SYSERR_ON_NONFATERR_EN(PcieRootControl) \
- (((PcieRootControl) >> 1) & 0x1)
-#define PCIE_CAP_SYSERR_ON_FATERR_EN(PcieRootControl) \
- (((PcieRootControl) >> 2) & 0x1)
-#define PCIE_CAP_PME_INT_ENABLE(PcieRootControl) \
- (((PcieRootControl) >> 3) & 0x1)
-#define PCIE_CAP_CRS_SW_VIS_ENABLE(PcieRootControl) \
- (((PcieRootControl) >> 4) & 0x1)
-//
-// Root Capabilities Register
-//
-#define PCIE_CAP_CRS_SW_VIS(PcieRootCap) \
- ((PcieRootCap) & 0x1)
-//
-// Root Status Register
-//
-#define PCIE_CAP_PME_REQ_ID(PcieRootStatus) \
- ((PcieRootStatus) & 0x0ffff)
-#define PCIE_CAP_PME_STATUS(PcieRootStatus) \
- (((PcieRootStatus) >> 16) & 0x1)
-#define PCIE_CAP_PME_PENDING(PcieRootStatus) \
- (((PcieRootStatus) >> 17) & 0x1)
-
-#pragma pack(1)
-//
-// Common part of the PCI configuration space header for devices, P2P bridges,
-// and cardbus bridges
-//
-typedef struct {
- UINT16 VendorId;
- UINT16 DeviceId;
-
- UINT16 Command;
- UINT16 Status;
-
- UINT8 RevisionId;
- UINT8 ClassCode[3];
-
- UINT8 CacheLineSize;
- UINT8 PrimaryLatencyTimer;
- UINT8 HeaderType;
- UINT8 Bist;
-
-} PCI_COMMON_HEADER;
-
-//
-// PCI configuration space header for devices(after the common part)
-//
-typedef struct {
- UINT32 Bar[6]; // Base Address Registers
- UINT32 CardBusCISPtr; // CardBus CIS Pointer
- UINT16 SubVendorId; // Subsystem Vendor ID
- UINT16 SubSystemId; // Subsystem ID
- UINT32 ROMBar; // Expansion ROM Base Address
- UINT8 CapabilitiesPtr; // Capabilities Pointer
- UINT8 Reserved[3];
-
- UINT32 Reserved1;
-
- UINT8 InterruptLine; // Interrupt Line
- UINT8 InterruptPin; // Interrupt Pin
- UINT8 MinGnt; // Min_Gnt
- UINT8 MaxLat; // Max_Lat
-} PCI_DEVICE_HEADER;
-
-//
-// PCI configuration space header for pci-to-pci bridges(after the common part)
-//
-typedef struct {
- UINT32 Bar[2]; // Base Address Registers
- UINT8 PrimaryBus; // Primary Bus Number
- UINT8 SecondaryBus; // Secondary Bus Number
- UINT8 SubordinateBus; // Subordinate Bus Number
- UINT8 SecondaryLatencyTimer; // Secondary Latency Timer
- UINT8 IoBase; // I/O Base
- UINT8 IoLimit; // I/O Limit
- UINT16 SecondaryStatus; // Secondary Status
- UINT16 MemoryBase; // Memory Base
- UINT16 MemoryLimit; // Memory Limit
- UINT16 PrefetchableMemBase; // Pre-fetchable Memory Base
- UINT16 PrefetchableMemLimit; // Pre-fetchable Memory Limit
- UINT32 PrefetchableBaseUpper; // Pre-fetchable Base Upper 32 bits
- UINT32 PrefetchableLimitUpper; // Pre-fetchable Limit Upper 32 bits
- UINT16 IoBaseUpper; // I/O Base Upper 16 bits
- UINT16 IoLimitUpper; // I/O Limit Upper 16 bits
- UINT8 CapabilitiesPtr; // Capabilities Pointer
- UINT8 Reserved[3];
-
- UINT32 ROMBar; // Expansion ROM Base Address
- UINT8 InterruptLine; // Interrupt Line
- UINT8 InterruptPin; // Interrupt Pin
- UINT16 BridgeControl; // Bridge Control
-} PCI_BRIDGE_HEADER;
-
-//
-// PCI configuration space header for cardbus bridges(after the common part)
-//
-typedef struct {
- UINT32 CardBusSocketReg; // Cardus Socket/ExCA Base
- // Address Register
- //
- UINT8 CapabilitiesPtr; // 14h in pci-cardbus bridge.
- UINT8 Reserved;
- UINT16 SecondaryStatus; // Secondary Status
- UINT8 PciBusNumber; // PCI Bus Number
- UINT8 CardBusBusNumber; // CardBus Bus Number
- UINT8 SubordinateBusNumber; // Subordinate Bus Number
- UINT8 CardBusLatencyTimer; // CardBus Latency Timer
- UINT32 MemoryBase0; // Memory Base Register 0
- UINT32 MemoryLimit0; // Memory Limit Register 0
- UINT32 MemoryBase1;
- UINT32 MemoryLimit1;
- UINT32 IoBase0;
- UINT32 IoLimit0; // I/O Base Register 0
- UINT32 IoBase1; // I/O Limit Register 0
- UINT32 IoLimit1;
-
- UINT8 InterruptLine; // Interrupt Line
- UINT8 InterruptPin; // Interrupt Pin
- UINT16 BridgeControl; // Bridge Control
-} PCI_CARDBUS_HEADER;
-
-//
-// Data region after PCI configuration header(for cardbus bridge)
-//
-typedef struct {
- UINT16 SubVendorId; // Subsystem Vendor ID
- UINT16 SubSystemId; // Subsystem ID
- UINT32 LegacyBase; // Optional 16-Bit PC Card Legacy
- // Mode Base Address
- //
- UINT32 Data[46];
-} PCI_CARDBUS_DATA;
-
-typedef union {
- PCI_DEVICE_HEADER Device;
- PCI_BRIDGE_HEADER Bridge;
- PCI_CARDBUS_HEADER CardBus;
-} NON_COMMON_UNION;
-
-typedef struct {
- PCI_COMMON_HEADER Common;
- NON_COMMON_UNION NonCommon;
- UINT32 Data[48];
-} PCI_CONFIG_SPACE;
-
-typedef struct {
- UINT8 PcieCapId;
- UINT8 NextCapPtr;
- UINT16 PcieCapReg;
- UINT32 PcieDeviceCap;
- UINT16 DeviceControl;
- UINT16 DeviceStatus;
- UINT32 LinkCap;
- UINT16 LinkControl;
- UINT16 LinkStatus;
- UINT32 SlotCap;
- UINT16 SlotControl;
- UINT16 SlotStatus;
- UINT16 RootControl;
- UINT16 RsvdP;
- UINT32 RootStatus;
-} PCIE_CAP_STRUCTURE;
-
-#pragma pack()
-
-#endif // _PCI_H_
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c
deleted file mode 100644
index d885677065..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/** @file
- Main file for SerMode shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Library/ShellLib.h>
-#include <Protocol/SerialIo.h>
-
-/**
- Display information about a serial device by it's handle.
-
- If HandleValid is FALSE, do all devices.
-
- @param[in] HandleIdx The handle index for the device.
- @param[in] HandleValid TRUE if HandleIdx is valid.
-
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-DisplaySettings (
- IN UINTN HandleIdx,
- IN BOOLEAN HandleValid
- )
-{
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- UINTN NoHandles;
- EFI_HANDLE *Handles;
- EFI_STATUS Status;
- UINTN Index;
- CHAR16 *StopBits;
- CHAR16 Parity;
- SHELL_STATUS ShellStatus;
-
- Handles = NULL;
- StopBits = NULL;
-
- ShellStatus = SHELL_SUCCESS;
-
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
- return SHELL_INVALID_PARAMETER;
- }
-
- for (Index = 0; Index < NoHandles; Index++) {
- if (HandleValid) {
- if (ConvertHandleIndexToHandle(HandleIdx) != Handles[Index]) {
- continue;
- }
- }
-
- Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
- if (!EFI_ERROR (Status)) {
- switch (SerialIo->Mode->Parity) {
- case DefaultParity:
-
- Parity = 'D';
- break;
-
- case NoParity:
-
- Parity = 'N';
- break;
-
- case EvenParity:
-
- Parity = 'E';
- break;
-
- case OddParity:
-
- Parity = 'O';
- break;
-
- case MarkParity:
-
- Parity = 'M';
- break;
-
- case SpaceParity:
-
- Parity = 'S';
- break;
-
- default:
-
- Parity = 'U';
- }
-
- switch (SerialIo->Mode->StopBits) {
- case DefaultStopBits:
-
- StopBits = L"Default";
- break;
-
- case OneStopBit:
-
- StopBits = L"1";
- break;
-
- case TwoStopBits:
-
- StopBits = L"2";
- break;
-
- case OneFiveStopBits:
-
- StopBits = L"1.5";
- break;
-
- default:
-
- StopBits = L"Unknown";
- }
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SERMODE_DISPLAY),
- gShellDebug1HiiHandle,
- ConvertHandleToHandleIndex (Handles[Index]),
- Handles[Index],
- SerialIo->Mode->BaudRate,
- Parity,
- SerialIo->Mode->DataBits,
- StopBits
- );
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
- ShellStatus = SHELL_NOT_FOUND;
- break;
- }
-
- if (HandleValid) {
- break;
- }
- }
-
- if (Index == NoHandles) {
- if ((NoHandles != 0 && HandleValid) || 0 == NoHandles) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NOT_FOUND), gShellDebug1HiiHandle, L"sermode");
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- return ShellStatus;
-}
-
-/**
- Function for 'sermode' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSerMode (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- UINTN Index;
- UINTN NoHandles;
- EFI_HANDLE *Handles;
- EFI_PARITY_TYPE Parity;
- EFI_STOP_BITS_TYPE StopBits;
- UINTN HandleIdx;
- UINTN BaudRate;
- UINTN DataBits;
- UINTN Value;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Temp;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- HandleIdx = 0;
- Parity = DefaultParity;
- Handles = NULL;
- NoHandles = 0;
- Index = 0;
- Package = NULL;
-
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"sermode", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) < 6 && ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"sermode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 6) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"sermode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Temp = ShellCommandLineGetRawValue(Package, 1);
- if (Temp != NULL) {
- Status = ShellConvertStringToUint64(Temp, &Intermediate, TRUE, FALSE);
- HandleIdx = (UINTN)Intermediate;
- Temp = ShellCommandLineGetRawValue(Package, 2);
- if (Temp == NULL) {
- ShellStatus = DisplaySettings (HandleIdx, TRUE);
- goto Done;
- }
- } else {
- ShellStatus = DisplaySettings (0, FALSE);
- goto Done;
- }
- Temp = ShellCommandLineGetRawValue(Package, 2);
- if (Temp != NULL) {
- BaudRate = ShellStrToUintn(Temp);
- } else {
- ASSERT(FALSE);
- BaudRate = 0;
- }
- Temp = ShellCommandLineGetRawValue(Package, 3);
- if (Temp == NULL || StrLen(Temp)>1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- switch(Temp[0]){
- case 'd':
- case 'D':
- Parity = DefaultParity;
- break;
- case 'n':
- case 'N':
- Parity = NoParity;
- break;
- case 'e':
- case 'E':
- Parity = EvenParity;
- break;
- case 'o':
- case 'O':
- Parity = OddParity;
- break;
- case 'm':
- case 'M':
- Parity = MarkParity;
- break;
- case 's':
- case 'S':
- Parity = SpaceParity;
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- Temp = ShellCommandLineGetRawValue(Package, 4);
- if (Temp != NULL) {
- DataBits = ShellStrToUintn(Temp);
- } else {
- //
- // make sure this is some number not in the list below.
- //
- DataBits = 0;
- }
- switch (DataBits) {
- case 4:
- case 7:
- case 8:
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- Temp = ShellCommandLineGetRawValue(Package, 5);
- Value = ShellStrToUintn(Temp);
- switch (Value) {
- case 0:
- StopBits = DefaultStopBits;
- break;
-
- case 1:
- StopBits = OneStopBit;
- break;
-
- case 2:
- StopBits = TwoStopBits;
- break;
-
- case 15:
- StopBits = OneFiveStopBits;
- break;
-
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_NO_FOUND), gShellDebug1HiiHandle, L"sermode");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- for (Index = 0; Index < NoHandles; Index++) {
- if (ConvertHandleIndexToHandle (HandleIdx) != Handles[Index]) {
- continue;
- }
-
- Status = gBS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
- if (!EFI_ERROR (Status)) {
- Status = SerialIo->SetAttributes (
- SerialIo,
- (UINT64) BaudRate,
- SerialIo->Mode->ReceiveFifoDepth,
- SerialIo->Mode->Timeout,
- Parity,
- (UINT8) DataBits,
- StopBits
- );
- if (EFI_ERROR (Status)) {
- if (Status == EFI_INVALID_PARAMETER) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_UNSUPPORTED), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
- ShellStatus = SHELL_UNSUPPORTED;
- } else if (Status == EFI_DEVICE_ERROR) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_DEV_ERROR), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_FAIL), gShellDebug1HiiHandle, L"sermode", ConvertHandleToHandleIndex(Handles[Index]));
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_SET_HANDLE), gShellDebug1HiiHandle, ConvertHandleToHandleIndex(Handles[Index]));
- }
- break;
- }
- }
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS && Index == NoHandles) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_BAD_HANDLE), gShellDebug1HiiHandle, L"sermode", HandleIdx);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
-
-Done:
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- if (Handles != NULL) {
- FreePool (Handles);
- }
- return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c
deleted file mode 100644
index a33aec12a5..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/** @file
- Main file for SetSize shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-
-/**
- Function for 'setsize' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSetSize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Temp1;
- UINTN NewSize;
- UINTN LoopVar;
- SHELL_FILE_HANDLE FileHandle;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setsize", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setsize");
- ShellStatus = SHELL_INVALID_PARAMETER;
- NewSize = 0;
- } else {
- Temp1 = ShellCommandLineGetRawValue(Package, 1);
- if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
- ShellStatus = SHELL_INVALID_PARAMETER;
- NewSize = 0;
- } else {
- NewSize = ShellStrToUintn(Temp1);
- }
- }
- for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
- Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
- if (EFI_ERROR(Status)) {
- Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- }
- if (EFI_ERROR(Status) && LoopVar == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- } else {
- Status = FileHandleSetSize(FileHandle, NewSize);
- if (Status == EFI_VOLUME_FULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle, L"setsize");
- ShellStatus = SHELL_VOLUME_FULL;
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_DONE), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar));
- }
- ShellCloseFile(&FileHandle);
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
deleted file mode 100644
index bffe047b8a..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/** @file
- Main file for SetVar shell Debug1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-guid", TypeValue},
- {L"-bs", TypeFlag},
- {L"-rt", TypeFlag},
- {L"-nv", TypeFlag},
- {NULL, TypeMax}
- };
-
-
-/**
- Check if the input is a (potentially empty) string of hexadecimal nibbles.
-
- @param[in] String The CHAR16 string to check.
-
- @retval FALSE A character has been found in String for which
- ShellIsHexaDecimalDigitCharacter() returned FALSE.
-
- @retval TRUE Otherwise. (Note that this covers the case when String is
- empty.)
-**/
-BOOLEAN
-EFIAPI
-IsStringOfHexNibbles (
- IN CONST CHAR16 *String
- )
-{
- CONST CHAR16 *Pos;
-
- for (Pos = String; *Pos != L'\0'; ++Pos) {
- if (!ShellIsHexaDecimalDigitCharacter (*Pos)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-
-/**
- Function for 'setvar' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSetVar (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *VariableName;
- CONST CHAR16 *Data;
- EFI_GUID Guid;
- CONST CHAR16 *StringGuid;
- UINT32 Attributes;
- VOID *Buffer;
- UINTN Size;
- UINTN LoopVar;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Buffer = NULL;
- Size = 0;
- Attributes = 0;
- DevPath = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setvar", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"setvar");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- VariableName = ShellCommandLineGetRawValue(Package, 1);
- Data = ShellCommandLineGetRawValue(Package, 2);
- if (!ShellCommandLineGetFlag(Package, L"-guid")){
- CopyGuid(&Guid, &gEfiGlobalVariableGuid);
- } else {
- StringGuid = ShellCommandLineGetValue(Package, L"-guid");
- Status = ConvertStringToGuid(StringGuid, &Guid);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- if (Data == NULL || Data[0] != L'=') {
- //
- // Display what's there
- //
- Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocateZeroPool(Size);
- Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
- }
- if (!EFI_ERROR(Status)&& Buffer != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
- for (LoopVar = 0 ; LoopVar < Size ; LoopVar++) {
- ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]);
- }
- ShellPrintEx(-1, -1, L"\r\n");
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- } else if (StrCmp(Data, L"=") == 0) {
- //
- // Delete what's there!
- //
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, 0, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- } else {
- //
- // Change what's there or create a new one.
- //
-
- ASSERT(Data[0] == L'=');
- Data++;
- ASSERT(Data[0] != L'\0');
-
- //
- // Determine if the variable exists and get the attributes
- //
- Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocateZeroPool(Size);
- Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
- }
-
- if (EFI_ERROR(Status) || Buffer == NULL) {
- //
- // Creating a new variable. determine attributes from command line.
- //
- Attributes = 0;
- if (ShellCommandLineGetFlag(Package, L"-bs")) {
- Attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
- }
- if (ShellCommandLineGetFlag(Package, L"-rt")) {
- Attributes |= EFI_VARIABLE_RUNTIME_ACCESS |
- EFI_VARIABLE_BOOTSERVICE_ACCESS;
- }
- if (ShellCommandLineGetFlag(Package, L"-nv")) {
- Attributes |= EFI_VARIABLE_NON_VOLATILE;
- }
- }
- SHELL_FREE_NON_NULL(Buffer);
-
- //
- // What type is the new data.
- //
- if (IsStringOfHexNibbles(Data)) {
- if (StrLen(Data) % 2 != 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", Data);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // arbitrary buffer
- //
- Buffer = AllocateZeroPool((StrLen(Data) / 2));
- if (Buffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) {
- ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16);
- ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1]));
- }
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- }
- } else if (StrnCmp(Data, L"\"", 1) == 0) {
- //
- // ascii text
- //
- Data++;
- Buffer = AllocateZeroPool(StrSize(Data) / 2);
- if (Buffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data);
- ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] = CHAR_NULL;
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- } else if (StrnCmp(Data, L"L\"", 2) == 0) {
- //
- // ucs2 text
- //
- Data++;
- Data++;
- Buffer = AllocateZeroPool(StrSize(Data));
- if (Buffer == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"setvar");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- UnicodeSPrint(Buffer, StrSize(Data), L"%s", Data);
- ((CHAR16*)Buffer)[StrLen(Buffer)-1] = CHAR_NULL;
-
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrSize(Buffer)-sizeof(CHAR16), Buffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- }
- } else if (StrnCmp(Data, L"--", 2) == 0) {
- //
- // device path in text format
- //
- Data++;
- Data++;
- DevPath = ConvertTextToDevicePath(Data);
- if (DevPath == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, GetDevicePathSize(DevPath), DevPath);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", Data);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
-
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
-
- if (DevPath != NULL) {
- FreePool(DevPath);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c
deleted file mode 100644
index f07a4c4921..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/** @file
- Module for clarifying the content of the smbios structure element info.
-
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "../UefiShellDebug1CommandsLib.h"
-#include "PrintInfo.h"
-#include "QueryTable.h"
-#include "EventLogInfo.h"
-
-/**
- Function to display system event log access information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySELAccessMethod (
- IN CONST UINT8 Key,
- IN CONST UINT8 Option
- )
-{
- //
- // Print prompt
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ACCESS_METHOD), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
-
- //
- // Print value info
- //
- switch (Key) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_EIGHT_BIT), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TWO_EIGHT_BITS), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_SIXTEEN_BIT), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MEM_MAPPED_PHYS), gShellDebug1HiiHandle);
- break;
-
- case 4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_VIA_GENERAL), gShellDebug1HiiHandle);
- break;
-
- default:
- if (Key <= 0x7f) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR_OEM), gShellDebug1HiiHandle);
- }
- }
-}
-
-/**
- Function to display system event log status information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySELLogStatus (
- UINT8 Key,
- UINT8 Option
- )
-{
- //
- // Print prompt
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
-
- //
- // Print value info
- //
- if ((Key & 0x01) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_VALID), gShellDebug1HiiHandle);
- }
-
- if ((Key & 0x02) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_FULL), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_AREA_NOT_FULL), gShellDebug1HiiHandle);
- }
-
- if ((Key & 0xFC) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RES_BITS_NOT_ZERO), gShellDebug1HiiHandle, Key & 0xFC);
- }
-}
-
-/**
- Function to display system event log header format information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogHeaderFormat (
- UINT8 Key,
- UINT8 Option
- )
-{
- //
- // Print prompt
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_FORMAT), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
-
- //
- // Print value info
- //
- if (Key == 0x00) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
- } else if (Key == 0x01) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
- } else if (Key <= 0x7f) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_FUTURE), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display the header information for SEL log items.
-
- @param[in] Key The information key.
- @param[in] Option The option index.
-**/
-VOID
-DisplaySELLogHeaderLen (
- UINT8 Key,
- UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER_LEN), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ONE_VAR_D), gShellDebug1HiiHandle, Key & 0x7F);
-
- //
- // The most-significant bit of the field specifies
- // whether (0) or not (1) the record has been read
- //
- if ((Key & 0x80) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_READ), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_THIS_RECORD_NOT_READ), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display the header information for type 1 items.
-
- @param[in] LogHeader The buffer with the information.
-**/
-VOID
-DisplaySysEventLogHeaderType1 (
- IN UINT8 *LogHeader
- )
-{
- LOG_HEADER_TYPE1_FORMAT *Header;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG), gShellDebug1HiiHandle);
-
- //
- // Print Log Header Type1 Format info
- //
- Header = (LOG_HEADER_TYPE1_FORMAT *) (LogHeader);
-
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_OEM_RESERVED),
- gShellDebug1HiiHandle,
- Header->OEMReserved[0],
- Header->OEMReserved[1],
- Header->OEMReserved[2],
- Header->OEMReserved[3],
- Header->OEMReserved[4]
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_TIME), gShellDebug1HiiHandle, Header->Metw);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULTIPLE_EVENT_COUNT), gShellDebug1HiiHandle, Header->Meci);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_ADDRESS), gShellDebug1HiiHandle, Header->CMOSAddress);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_PREBOOT_INDEX), gShellDebug1HiiHandle, Header->CMOSBitIndex);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUM_STARTING_OFF), gShellDebug1HiiHandle, Header->StartingOffset);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_CHECKSUN_BYTE_COUNT), gShellDebug1HiiHandle, Header->ChecksumOffset);
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_RESERVED),
- gShellDebug1HiiHandle,
- Header->OEMReserved[0],
- Header->OEMReserved[1],
- Header->OEMReserved[2]
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_HEADER_REVISION), gShellDebug1HiiHandle, Header->HeaderRevision);
-}
-
-/**
- Function to display system event log header information.
-
- @param[in] LogHeaderFormat Format identifier.
- @param[in] LogHeader Format informcation.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogHeader (
- UINT8 LogHeaderFormat,
- UINT8 *LogHeader
- )
-{
- //
- // Print prompt
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_LOG_HEADER), gShellDebug1HiiHandle);
-
- //
- // Print value info
- //
- if (LogHeaderFormat == 0x00) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_HEADER), gShellDebug1HiiHandle);
- } else if (LogHeaderFormat == 0x01) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TYPE_LOG_HEADER), gShellDebug1HiiHandle);
- DisplaySysEventLogHeaderType1 (LogHeader);
- } else if (LogHeaderFormat <= 0x7f) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FUTURE_ASSIGN), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_BIOS_VENDOR), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display the El Vdf information.
-
- @param[in] ElVdfType The information type.
- @param[in] VarData The information buffer.
-**/
-VOID
-DisplayElVdfInfo (
- UINT8 ElVdfType,
- UINT8 *VarData
- )
-{
- UINT16 *Word;
- UINT32 *Dword;
-
- //
- // Display Type Name
- //
- DisplaySELVarDataFormatType (ElVdfType, SHOW_DETAIL);
-
- //
- // Display Type description
- //
- switch (ElVdfType) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_NO_STD_FORMAT), gShellDebug1HiiHandle);
- break;
-
- case 1:
- Word = (UINT16 *) (VarData + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
- break;
-
- case 2:
- Dword = (UINT32 *) (VarData + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
- break;
-
- case 3:
- Word = (UINT16 *) (VarData + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SMBIOS_STRUCT_ASSOC), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, *Word);
- //
- // Followed by a multiple-event counter
- //
- Dword = (UINT32 *) (VarData + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
- break;
-
- case 4:
- Dword = (UINT32 *) (VarData + 1);
- DisplayPostResultsBitmapDw1 (*Dword, SHOW_DETAIL);
- Dword++;
- DisplayPostResultsBitmapDw2 (*Dword, SHOW_DETAIL);
- break;
-
- case 5:
- Dword = (UINT32 *) (VarData + 1);
- DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
- break;
-
- case 6:
- Dword = (UINT32 *) (VarData + 1);
- DisplaySELSysManagementTypes (*Dword, SHOW_DETAIL);
- //
- // Followed by a multiple-event counter
- //
- Dword = (UINT32 *) (VarData + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_MULT_EVENT_COUNTER), gShellDebug1HiiHandle, *Dword);
- break;
-
- default:
- if (ElVdfType <= 0x7F) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_UNUSED_AVAIL_FOR_ASSIGN), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_AVAIL_FOR_SYSTEM), gShellDebug1HiiHandle);
- }
- }
-}
-
-/**
- Function to display system event log data.
-
- @param[in] LogData The data information.
- @param[in] LogAreaLength Length of the data.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogData (
- UINT8 *LogData,
- UINT16 LogAreaLength
- )
-{
- LOG_RECORD_FORMAT *Log;
- UINT8 ElVdfType;
- //
- // Event Log Variable Data Format Types
- //
- UINTN Offset;
-
- //
- // Print prompt
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_SYSTEM_EVENT_LOG_2), gShellDebug1HiiHandle);
-
- //
- // Print Log info
- //
- Offset = 0;
- Log = (LOG_RECORD_FORMAT *) LogData;
- while (Log != NULL && Log->Type != END_OF_LOG && Offset < LogAreaLength) {
- //
- // Get a Event Log Record
- //
- Log = (LOG_RECORD_FORMAT *) (LogData + Offset);
-
- if (Log != NULL) {
- //
- // Display Event Log Record Information
- //
- DisplaySELVarDataFormatType (Log->Type, SHOW_DETAIL);
- DisplaySELLogHeaderLen (Log->Length, SHOW_DETAIL);
-
- Offset += Log->Length;
- //
- // Display Log Header Date/Time Fields
- // These fields contain the BCD representation of the date and time
- // (as read from CMOS) of the occurrence of the event
- // So Print as hex and represent decimal
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_DATE), gShellDebug1HiiHandle);
- if (Log != NULL && Log->Year >= 80 && Log->Year <= 99) {
- Print (L"19");
- } else if (Log != NULL && Log->Year <= 79) {
- Print (L"20");
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_ERROR), gShellDebug1HiiHandle);
- continue;
- }
-
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_EVENTLOGINFO_TIME_SIX_VARS),
- gShellDebug1HiiHandle,
- Log->Year,
- Log->Month,
- Log->Day,
- Log->Hour,
- Log->Minute,
- Log->Second
- );
-
- //
- // Display Variable Data Format
- //
- if (Log->Length <= (sizeof (LOG_RECORD_FORMAT) - 1)) {
- continue;
- }
-
- ElVdfType = Log->LogVariableData[0];
- DisplayElVdfInfo (ElVdfType, Log->LogVariableData);
- }
- }
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h
deleted file mode 100644
index b32cfea812..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/EventLogInfo.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/** @file
- Module to clarify system event log of smbios structure.
-
- Copyright (c) 2005-2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _SMBIOS_EVENT_LOG_INFO_H_
-#define _SMBIOS_EVENT_LOG_INFO_H_
-
-#define END_OF_LOG 0xFF
-
-#pragma pack(1)
-
-typedef struct {
- UINT8 Type;
- UINT8 Length;
- UINT8 Year;
- UINT8 Month;
- UINT8 Day;
- UINT8 Hour;
- UINT8 Minute;
- UINT8 Second;
- UINT8 LogVariableData[1];
-} LOG_RECORD_FORMAT;
-
-typedef struct {
- UINT8 OEMReserved[5];
- UINT8 Metw; // Multiple Event Time Window
- UINT8 Meci; // Multiple Event Count Increment
- UINT8 CMOSAddress; // Pre-boot Event Log Reset - CMOS Address
- UINT8 CMOSBitIndex; // Pre-boot Event Log Reset - CMOS Bit Index
- UINT8 StartingOffset; // CMOS Checksum - Starting Offset
- UINT8 ByteCount; // CMOS Checksum - Byte Count
- UINT8 ChecksumOffset; // CMOS Checksum - Checksum Offset
- UINT8 Reserved[3];
- UINT8 HeaderRevision;
-} LOG_HEADER_TYPE1_FORMAT;
-
-#pragma pack()
-//
-// System Event Log (Type 15)
-//
-
-/**
- Function to display system event log access information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySELAccessMethod (
- IN CONST UINT8 Key,
- IN CONST UINT8 Option
- );
-
-/**
- Function to display system event log status information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySELLogStatus (
- UINT8 Key,
- UINT8 Option
- );
-
-/**
- Function to display system event log header format information.
-
- @param[in] Key Additional information to print.
- @param[in] Option Whether to print the additional information.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogHeaderFormat (
- UINT8 Key,
- UINT8 Option
- );
-
-/**
- Function to display system event log header information.
-
- @param[in] LogHeaderFormat Format identifier.
- @param[in] LogHeader Format informcation.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogHeader (
- UINT8 LogHeaderFormat,
- UINT8 *LogHeader
- );
-
-/**
- Function to display system event log data.
-
- @param[in] LogData The data information.
- @param[in] LogAreaLength Length of the data.
-**/
-VOID
-EFIAPI
-DisplaySysEventLogData (
- UINT8 *LogData,
- UINT16 LogAreaLength
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c
deleted file mode 100644
index 6920263c92..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/** @file
- API for SMBIOS table.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "../UefiShellDebug1CommandsLib.h"
-#include <Guid/SmBios.h>
-#include "LibSmbiosView.h"
-#include "SmbiosView.h"
-
-STATIC UINT8 mInit = 0;
-STATIC UINT8 m64Init = 0;
-STATIC SMBIOS_TABLE_ENTRY_POINT *mSmbiosTable = NULL;
-STATIC SMBIOS_TABLE_3_0_ENTRY_POINT *mSmbios64BitTable = NULL;
-STATIC SMBIOS_STRUCTURE_POINTER m_SmbiosStruct;
-STATIC SMBIOS_STRUCTURE_POINTER *mSmbiosStruct = &m_SmbiosStruct;
-STATIC SMBIOS_STRUCTURE_POINTER m_Smbios64BitStruct;
-STATIC SMBIOS_STRUCTURE_POINTER *mSmbios64BitStruct = &m_Smbios64BitStruct;
-
-/**
- Init the SMBIOS VIEW API's environment.
-
- @retval EFI_SUCCESS Successful to init the SMBIOS VIEW Lib.
-**/
-EFI_STATUS
-LibSmbiosInit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Init only once
- //
- if (mInit == 1) {
- return EFI_SUCCESS;
- }
- //
- // Get SMBIOS table from System Configure table
- //
- Status = GetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);
-
- if (mSmbiosTable == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
- return Status;
- }
- //
- // Init SMBIOS structure table address
- //
- mSmbiosStruct->Raw = (UINT8 *) (UINTN) (mSmbiosTable->TableAddress);
-
- mInit = 1;
- return EFI_SUCCESS;
-}
-
-/**
- Init the SMBIOS VIEW API's environment.
-
- @retval EFI_SUCCESS Successful to init the SMBIOS VIEW Lib.
-**/
-EFI_STATUS
-LibSmbios64BitInit (
- VOID
- )
-{
- EFI_STATUS Status;
-
- //
- // Init only once
- //
- if (m64Init == 1) {
- return EFI_SUCCESS;
- }
- //
- // Get SMBIOS table from System Configure table
- //
- Status = GetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID**)&mSmbios64BitTable);
-
- if (mSmbios64BitTable == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
- return Status;
- }
- //
- // Init SMBIOS structure table address
- //
- mSmbios64BitStruct->Raw = (UINT8 *) (UINTN) (mSmbios64BitTable->TableAddress);
-
- m64Init = 1;
- return EFI_SUCCESS;
-}
-
-/**
- Cleanup the Smbios information.
-**/
-VOID
-LibSmbiosCleanup (
- VOID
- )
-{
- //
- // Release resources
- //
- if (mSmbiosTable != NULL) {
- mSmbiosTable = NULL;
- }
-
- mInit = 0;
-}
-
-/**
- Cleanup the Smbios information.
-**/
-VOID
-LibSmbios64BitCleanup (
- VOID
- )
-{
- //
- // Release resources
- //
- if (mSmbios64BitTable != NULL) {
- mSmbios64BitTable = NULL;
- }
-
- m64Init = 0;
-}
-
-/**
- Get the entry point structure for the table.
-
- @param[out] EntryPointStructure The pointer to populate.
-**/
-VOID
-LibSmbiosGetEPS (
- OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
- )
-{
- //
- // return SMBIOS Table address
- //
- *EntryPointStructure = mSmbiosTable;
-}
-
-/**
- Get the entry point structure for the table.
-
- @param[out] EntryPointStructure The pointer to populate.
-**/
-VOID
-LibSmbios64BitGetEPS (
- OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
- )
-{
- //
- // return SMBIOS Table address
- //
- *EntryPointStructure = mSmbios64BitTable;
-}
-
-/**
- Return SMBIOS string for the given string number.
-
- @param[in] Smbios Pointer to SMBIOS structure.
- @param[in] StringNumber String number to return. -1 is used to skip all strings and
- point to the next SMBIOS structure.
-
- @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
-**/
-CHAR8*
-LibGetSmbiosString (
- IN SMBIOS_STRUCTURE_POINTER *Smbios,
- IN UINT16 StringNumber
- )
-{
- UINT16 Index;
- CHAR8 *String;
-
- ASSERT (Smbios != NULL);
-
- //
- // Skip over formatted section
- //
- String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length);
-
- //
- // Look through unformated section
- //
- for (Index = 1; Index <= StringNumber; Index++) {
- if (StringNumber == Index) {
- return String;
- }
- //
- // Skip string
- //
- for (; *String != 0; String++);
- String++;
-
- if (*String == 0) {
- //
- // If double NULL then we are done.
- // Return pointer to next structure in Smbios.
- // if you pass in a -1 you will always get here
- //
- Smbios->Raw = (UINT8 *)++String;
- return NULL;
- }
- }
-
- return NULL;
-}
-
-/**
- Get SMBIOS structure for the given Handle,
- Handle is changed to the next handle or 0xFFFF when the end is
- reached or the handle is not found.
-
- @param[in, out] Handle 0xFFFF: get the first structure
- Others: get a structure according to this value.
- @param[out] Buffer The pointer to the pointer to the structure.
- @param[out] Length Length of the structure.
-
- @retval DMI_SUCCESS Handle is updated with next structure handle or
- 0xFFFF(end-of-list).
-
- @retval DMI_INVALID_HANDLE Handle is updated with first structure handle or
- 0xFFFF(end-of-list).
-**/
-EFI_STATUS
-LibGetSmbiosStructure (
- IN OUT UINT16 *Handle,
- OUT UINT8 **Buffer,
- OUT UINT16 *Length
- )
-{
- SMBIOS_STRUCTURE_POINTER Smbios;
- SMBIOS_STRUCTURE_POINTER SmbiosEnd;
- UINT8 *Raw;
-
- if (*Handle == INVALID_HANDLE) {
- *Handle = mSmbiosStruct->Hdr->Handle;
- return DMI_INVALID_HANDLE;
- }
-
- if ((Buffer == NULL) || (Length == NULL)) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
- return DMI_INVALID_HANDLE;
- }
-
- *Length = 0;
- Smbios.Hdr = mSmbiosStruct->Hdr;
- SmbiosEnd.Raw = Smbios.Raw + mSmbiosTable->TableLength;
- while (Smbios.Raw < SmbiosEnd.Raw) {
- if (Smbios.Hdr->Handle == *Handle) {
- Raw = Smbios.Raw;
- //
- // Walk to next structure
- //
- LibGetSmbiosString (&Smbios, (UINT16) (-1));
- //
- // Length = Next structure head - this structure head
- //
- *Length = (UINT16) (Smbios.Raw - Raw);
- *Buffer = Raw;
- //
- // update with the next structure handle.
- //
- if (Smbios.Raw < SmbiosEnd.Raw) {
- *Handle = Smbios.Hdr->Handle;
- } else {
- *Handle = INVALID_HANDLE;
- }
- return DMI_SUCCESS;
- }
- //
- // Walk to next structure
- //
- LibGetSmbiosString (&Smbios, (UINT16) (-1));
- }
-
- *Handle = INVALID_HANDLE;
- return DMI_INVALID_HANDLE;
-}
-
-/**
- Get SMBIOS structure for the given Handle,
- Handle is changed to the next handle or 0xFFFF when the end is
- reached or the handle is not found.
-
- @param[in, out] Handle 0xFFFF: get the first structure
- Others: get a structure according to this value.
- @param[out] Buffer The pointer to the pointer to the structure.
- @param[out] Length Length of the structure.
-
- @retval DMI_SUCCESS Handle is updated with next structure handle or
- 0xFFFF(end-of-list).
-
- @retval DMI_INVALID_HANDLE Handle is updated with first structure handle or
- 0xFFFF(end-of-list).
-**/
-EFI_STATUS
-LibGetSmbios64BitStructure (
- IN OUT UINT16 *Handle,
- OUT UINT8 **Buffer,
- OUT UINT16 *Length
- )
-{
- SMBIOS_STRUCTURE_POINTER Smbios;
- SMBIOS_STRUCTURE_POINTER SmbiosEnd;
- UINT8 *Raw;
-
- if (*Handle == INVALID_HANDLE) {
- *Handle = mSmbios64BitStruct->Hdr->Handle;
- return DMI_INVALID_HANDLE;
- }
-
- if ((Buffer == NULL) || (Length == NULL)) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_NO_BUFF_LEN_SPEC), gShellDebug1HiiHandle);
- return DMI_INVALID_HANDLE;
- }
-
- *Length = 0;
- Smbios.Hdr = mSmbios64BitStruct->Hdr;
-
- SmbiosEnd.Raw = Smbios.Raw + mSmbios64BitTableLength;
- while (Smbios.Raw < SmbiosEnd.Raw) {
- if (Smbios.Hdr->Handle == *Handle) {
- Raw = Smbios.Raw;
- //
- // Walk to next structure
- //
- LibGetSmbiosString (&Smbios, (UINT16) (-1));
- //
- // Length = Next structure head - this structure head
- //
- *Length = (UINT16) (Smbios.Raw - Raw);
- *Buffer = Raw;
- //
- // update with the next structure handle.
- //
- if (Smbios.Raw < SmbiosEnd.Raw) {
- *Handle = Smbios.Hdr->Handle;
- } else {
- *Handle = INVALID_HANDLE;
- }
- return DMI_SUCCESS;
- }
- //
- // Walk to next structure
- //
- LibGetSmbiosString (&Smbios, (UINT16) (-1));
- }
-
- *Handle = INVALID_HANDLE;
- return DMI_INVALID_HANDLE;
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h
deleted file mode 100644
index 103f022fbe..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/LibSmbiosView.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/** @file
- API for SMBIOS Plug and Play functions, access to SMBIOS table and structures.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _LIB_SMBIOS_VIEW_H_
-#define _LIB_SMBIOS_VIEW_H_
-
-#include <IndustryStandard/SmBios.h>
-
-#define DMI_SUCCESS 0x00
-#define DMI_UNKNOWN_FUNCTION 0x81
-#define DMI_FUNCTION_NOT_SUPPORTED 0x82
-#define DMI_INVALID_HANDLE 0x83
-#define DMI_BAD_PARAMETER 0x84
-#define DMI_INVALID_SUBFUNCTION 0x85
-#define DMI_NO_CHANGE 0x86
-#define DMI_ADD_STRUCTURE_FAILED 0x87
-#define DMI_READ_ONLY 0x8D
-#define DMI_LOCK_NOT_SUPPORTED 0x90
-#define DMI_CURRENTLY_LOCKED 0x91
-#define DMI_INVALID_LOCK 0x92
-
-#define INVALID_HANDLE (UINT16) (-1)
-
-#define EFI_SMBIOSERR(val) EFIERR (0x30000 | val)
-
-#define EFI_SMBIOSERR_FAILURE EFI_SMBIOSERR (1)
-#define EFI_SMBIOSERR_STRUCT_NOT_FOUND EFI_SMBIOSERR (2)
-#define EFI_SMBIOSERR_TYPE_UNKNOWN EFI_SMBIOSERR (3)
-#define EFI_SMBIOSERR_UNSUPPORTED EFI_SMBIOSERR (4)
-
-/**
- Init the SMBIOS VIEW API's environment for the 32-bit table..
-
- @retval EFI_SUCCESS Successful to init the SMBIOS VIEW Lib.
-**/
-EFI_STATUS
-LibSmbiosInit (
- VOID
- );
-
-/**
- Init the SMBIOS VIEW API's environment for the 64-bit table..
-
- @retval EFI_SUCCESS Successful to init the SMBIOS VIEW Lib.
-**/
-EFI_STATUS
-LibSmbios64BitInit (
- VOID
- );
-
-/**
- Cleanup the Smbios information.
-**/
-VOID
-LibSmbiosCleanup (
- VOID
- );
-
-/**
- Cleanup the Smbios information.
-**/
-VOID
-LibSmbios64BitCleanup (
- VOID
- );
-
-/**
- Get the entry point structure for the table.
-
- @param[out] EntryPointStructure The pointer to populate.
-**/
-VOID
-LibSmbiosGetEPS (
- OUT SMBIOS_TABLE_ENTRY_POINT **EntryPointStructure
- );
-
-/**
- Get the entry point structure for the 64-bit table.
-
- @param[out] EntryPointStructure The pointer to populate.
-**/
-VOID
-LibSmbios64BitGetEPS (
- OUT SMBIOS_TABLE_3_0_ENTRY_POINT **EntryPointStructure
- );
-
-/**
- Return SMBIOS string for the given string number.
-
- @param[in] Smbios Pointer to SMBIOS structure.
- @param[in] StringNumber String number to return. -1 is used to skip all strings and
- point to the next SMBIOS structure.
-
- @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == -1
-**/
-CHAR8*
-LibGetSmbiosString (
- IN SMBIOS_STRUCTURE_POINTER *Smbios,
- IN UINT16 StringNumber
- );
-
-/**
- Get SMBIOS structure for the given Handle,
- Handle is changed to the next handle or 0xFFFF when the end is
- reached or the handle is not found.
-
- @param[in, out] Handle 0xFFFF: get the first structure
- Others: get a structure according to this value.
- @param[out] Buffer The pointer to the pointer to the structure.
- @param[out] Length Length of the structure.
-
- @retval DMI_SUCCESS Handle is updated with next structure handle or
- 0xFFFF(end-of-list).
-
- @retval DMI_INVALID_HANDLE Handle is updated with first structure handle or
- 0xFFFF(end-of-list).
-**/
-EFI_STATUS
-LibGetSmbiosStructure (
- IN OUT UINT16 *Handle,
- OUT UINT8 **Buffer,
- OUT UINT16 *Length
- );
-
-/**
- Get SMBIOS structure for the given Handle in 64-bit table,
- Handle is changed to the next handle or 0xFFFF when the end is
- reached or the handle is not found.
-
- @param[in, out] Handle 0xFFFF: get the first structure
- Others: get a structure according to this value.
- @param[out] Buffer The pointer to the pointer to the structure.
- @param[out] Length Length of the structure.
-
- @retval DMI_SUCCESS Handle is updated with next structure handle or
- 0xFFFF(end-of-list).
-
- @retval DMI_INVALID_HANDLE Handle is updated with first structure handle or
- 0xFFFF(end-of-list).
-**/
-EFI_STATUS
-LibGetSmbios64BitStructure (
- IN OUT UINT16 *Handle,
- OUT UINT8 **Buffer,
- OUT UINT16 *Length
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
deleted file mode 100644
index e348c6f25c..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ /dev/null
@@ -1,3227 +0,0 @@
-/** @file
- Module for clarifying the content of the smbios structure element information.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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 "../UefiShellDebug1CommandsLib.h"
-#include "PrintInfo.h"
-#include "LibSmbiosView.h"
-#include "QueryTable.h"
-#include "EventLogInfo.h"
-
-
-//
-// Get the certain bit of 'value'
-//
-#define BIT(value, bit) ((value) & ((UINT64) 1) << (bit))
-
-//
-// Check if above or equal to version
-//
-#define AE_SMBIOS_VERSION(MajorVersion, MinorVersion) \
- (SmbiosMajorVersion > (MajorVersion) || (SmbiosMajorVersion == (MajorVersion) && SmbiosMinorVersion >= (MinorVersion)))
-
-//
-//////////////////////////////////////////////////////////
-// Macros of print structure element, simplify coding.
-//
-#define PRINT_PENDING_STRING(pStruct, type, element) \
- do { \
- CHAR8 *StringBuf; \
- StringBuf = LibGetSmbiosString ((pStruct), (pStruct->type->element)); \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintEx(-1,-1,L": %a\n", (StringBuf != NULL) ? StringBuf: ""); \
- } while (0);
-
-#define PRINT_SMBIOS_STRING(pStruct, stringnumber, element) \
- do { \
- CHAR8 *StringBuf; \
- StringBuf = LibGetSmbiosString ((pStruct), (stringnumber)); \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintEx(-1,-1,L": %a\n", (StringBuf != NULL) ? StringBuf: ""); \
- } while (0);
-
-#define PRINT_STRUCT_VALUE(pStruct, type, element) \
- do { \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \
- } while (0);
-
-#define PRINT_STRUCT_VALUE_H(pStruct, type, element) \
- do { \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintEx(-1,-1,L": 0x%x\n", (pStruct->type->element)); \
- } while (0);
-
-#define PRINT_STRUCT_VALUE_LH(pStruct, type, element) \
- do { \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintEx(-1,-1,L": 0x%lx\n", (pStruct->type->element)); \
- } while (0);
-
-#define PRINT_BIT_FIELD(pStruct, type, element, size) \
- do { \
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DUMP), gShellDebug1HiiHandle); \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE), gShellDebug1HiiHandle, size); \
- DumpHex (0, 0, size, &(pStruct->type->element)); \
- } while (0);
-
-#define PRINT_SMBIOS_BIT_FIELD(pStruct, startaddress, element, size) \
- do { \
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DUMP), gShellDebug1HiiHandle); \
- ShellPrintEx(-1,-1,L"%a",#element); \
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE), gShellDebug1HiiHandle, size); \
- DumpHex (0, 0, size, startaddress); \
- } while (0);
-
-//
-/////////////////////////////////////////
-//
-
-/**
- Copy Length of Src buffer to Dest buffer,
- add a NULL termination to Dest buffer.
-
- @param[in, out] Dest Destination buffer head.
- @param[in] Src Source buffer head.
- @param[in] Length Length of buffer to be copied.
-**/
-VOID
-MemToString (
- IN OUT VOID *Dest,
- IN VOID *Src,
- IN UINTN Length
- )
-{
- UINT8 *SrcBuffer;
- UINT8 *DestBuffer;
- SrcBuffer = (UINT8 *) Src;
- DestBuffer = (UINT8 *) Dest;
- //
- // copy byte by byte
- //
- while ((Length--)!=0) {
- *DestBuffer++ = *SrcBuffer++;
- }
- //
- // append a NULL terminator
- //
- *DestBuffer = '\0';
-}
-
-//
-//////////////////////////////////////////////
-//
-// Functions below is to show the information
-//
-
-/**
- Print the info of EPS(Entry Point Structure).
-
- @param[in] SmbiosTable Pointer to the SMBIOS table entry point.
- @param[in] Option Display option.
-**/
-VOID
-SmbiosPrintEPSInfo (
- IN SMBIOS_TABLE_ENTRY_POINT *SmbiosTable,
- IN UINT8 Option
- )
-{
- UINT8 Anchor[5];
- UINT8 InAnchor[6];
-
- if (SmbiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL), gShellDebug1HiiHandle);
- return ;
- }
-
- if (Option == SHOW_NONE) {
- return ;
- }
-
- if (Option >= SHOW_NORMAL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN), gShellDebug1HiiHandle);
- MemToString (Anchor, SmbiosTable->AnchorString, 4);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle, Anchor);
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EPS_CHECKSUM),
- gShellDebug1HiiHandle,
- SmbiosTable->EntryPointStructureChecksum
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_LEN), gShellDebug1HiiHandle, SmbiosTable->EntryPointLength);
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VERSION),
- gShellDebug1HiiHandle,
- SmbiosTable->MajorVersion,
- SmbiosTable->MinorVersion
- );
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NUMBER_STRUCT),
- gShellDebug1HiiHandle,
- SmbiosTable->NumberOfSmbiosStructures
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MAX_STRUCT_SIZE), gShellDebug1HiiHandle, SmbiosTable->MaxStructureSize);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_ADDR), gShellDebug1HiiHandle, SmbiosTable->TableAddress);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_LENGTH), gShellDebug1HiiHandle, SmbiosTable->TableLength);
-
- }
- //
- // If SHOW_ALL, also print followings.
- //
- if (Option >= SHOW_DETAIL) {
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_REVISION),
- gShellDebug1HiiHandle,
- SmbiosTable->EntryPointRevision
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BCD_REVISION), gShellDebug1HiiHandle, SmbiosTable->SmbiosBcdRevision);
- //
- // Since raw data is not string, add a NULL terminater.
- //
- MemToString (InAnchor, SmbiosTable->IntermediateAnchorString, 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTER_ACHOR), gShellDebug1HiiHandle, InAnchor);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTER_CHECKSUM), gShellDebug1HiiHandle, SmbiosTable->IntermediateChecksum);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FORMATTED_AREA), gShellDebug1HiiHandle);
- DumpHex (2, 0, 5, SmbiosTable->FormattedArea);
- }
-
- Print (L"\n");
-}
-
-/**
- Print the info of 64-bit EPS(Entry Point Structure).
-
- @param[in] SmbiosTable Pointer to the SMBIOS table entry point.
- @param[in] Option Display option.
-**/
-VOID
-Smbios64BitPrintEPSInfo (
- IN SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable,
- IN UINT8 Option
- )
-{
- UINT8 Anchor[5];
-
- if (SmbiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL), gShellDebug1HiiHandle);
- return ;
- }
-
- if (Option == SHOW_NONE) {
- return ;
- }
-
- if (Option >= SHOW_NORMAL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN), gShellDebug1HiiHandle);
-
- MemToString (Anchor, SmbiosTable->AnchorString, 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle, Anchor);
-
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EPS_CHECKSUM),
- gShellDebug1HiiHandle,
- SmbiosTable->EntryPointStructureChecksum
- );
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_LEN), gShellDebug1HiiHandle, SmbiosTable->EntryPointLength);
-
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VERSION),
- gShellDebug1HiiHandle,
- SmbiosTable->MajorVersion,
- SmbiosTable->MinorVersion
- );
-
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DOCREV),
- gShellDebug1HiiHandle,
- SmbiosTable->DocRev
- );
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_MAX_SIZE), gShellDebug1HiiHandle, SmbiosTable->TableMaximumSize);
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TABLE_ADDR), gShellDebug1HiiHandle, SmbiosTable->TableAddress);
-
- }
- //
- // If SHOW_ALL, also print followings.
- //
- if (Option >= SHOW_DETAIL) {
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_REVISION),
- gShellDebug1HiiHandle,
- SmbiosTable->EntryPointRevision
- );
- }
-
- Print (L"\n");
-}
-
-/**
- This function print the content of the structure pointed by Struct.
-
- @param[in] Struct Point to the structure to be printed.
- @param[in] Option Print option of information detail.
-
- @retval EFI_SUCCESS Successfully Printing this function.
- @retval EFI_INVALID_PARAMETER Invalid Structure.
- @retval EFI_UNSUPPORTED Unsupported.
-**/
-EFI_STATUS
-SmbiosPrintStructure (
- IN SMBIOS_STRUCTURE_POINTER *Struct,
- IN UINT8 Option
- )
-{
- UINT8 Index;
- UINT8 *Buffer;
-
- if (Struct == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Option == SHOW_NONE) {
- return EFI_SUCCESS;
- }
-
- Buffer = (UINT8 *) (UINTN) (Struct->Raw);
-
- //
- // Display structure header
- //
- DisplayStructureTypeInfo (Struct->Hdr->Type, SHOW_DETAIL);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FORMAT_PART_LEN), gShellDebug1HiiHandle, Struct->Hdr->Length);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_HANDLE), gShellDebug1HiiHandle, Struct->Hdr->Handle);
-
- if (Option == SHOW_OUTLINE) {
- return EFI_SUCCESS;
- }
-
- switch (Struct->Hdr->Type) {
- //
- // BIOS Information (Type 0)
- //
- case 0:
- PRINT_PENDING_STRING (Struct, Type0, Vendor);
- PRINT_PENDING_STRING (Struct, Type0, BiosVersion);
- PRINT_STRUCT_VALUE (Struct, Type0, BiosSegment);
- PRINT_PENDING_STRING (Struct, Type0, BiosReleaseDate);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), gShellDebug1HiiHandle, 64 * (Struct->Type0->BiosSize + 1));
-
- DisplayBiosCharacteristics (ReadUnaligned64 ((UINT64 *) (UINTN) &(Struct->Type0->BiosCharacteristics)), Option);
-
- if (Struct->Hdr->Length > 0x12) {
- DisplayBiosCharacteristicsExt1 (Struct->Type0->BIOSCharacteristicsExtensionBytes[0], Option);
- }
- if (Struct->Hdr->Length > 0x13) {
- DisplayBiosCharacteristicsExt2 (Struct->Type0->BIOSCharacteristicsExtensionBytes[1], Option);
- }
-
- if (AE_SMBIOS_VERSION (0x2, 0x4) && (Struct->Hdr->Length > 0x14)) {
- PRINT_STRUCT_VALUE (Struct, Type0, SystemBiosMajorRelease);
- PRINT_STRUCT_VALUE (Struct, Type0, SystemBiosMinorRelease);
- PRINT_STRUCT_VALUE (Struct, Type0, EmbeddedControllerFirmwareMajorRelease);
- PRINT_STRUCT_VALUE (Struct, Type0, EmbeddedControllerFirmwareMinorRelease);
- }
-
- break;
-
- //
- // System Information (Type 1)
- //
- case 1:
- PRINT_PENDING_STRING (Struct, Type1, Manufacturer);
- PRINT_PENDING_STRING (Struct, Type1, ProductName);
- PRINT_PENDING_STRING (Struct, Type1, Version);
- PRINT_PENDING_STRING (Struct, Type1, SerialNumber);
- PRINT_BIT_FIELD (Struct, Type1, Uuid, 16);
- DisplaySystemWakeupType (Struct->Type1->WakeUpType, Option);
- if (AE_SMBIOS_VERSION (0x2, 0x4) && (Struct->Hdr->Length > 0x19)) {
- PRINT_PENDING_STRING (Struct, Type1, SKUNumber);
- PRINT_PENDING_STRING (Struct, Type1, Family);
- }
-
- break;
-
- //
- // Baseboard Information (Type 2)
- //
- case 2:
- PRINT_PENDING_STRING (Struct, Type2, Manufacturer);
- PRINT_PENDING_STRING (Struct, Type2, ProductName);
- PRINT_PENDING_STRING (Struct, Type2, Version);
- PRINT_PENDING_STRING (Struct, Type2, SerialNumber);
- if (Struct->Hdr->Length > 0x8) {
- PRINT_PENDING_STRING (Struct, Type2, AssetTag);
- DisplayBaseBoardFeatureFlags (*(UINT8 *) &Struct->Type2->FeatureFlag, Option);
- PRINT_PENDING_STRING (Struct, Type2, LocationInChassis);
- PRINT_STRUCT_VALUE_H (Struct, Type2, ChassisHandle);
- DisplayBaseBoardBoardType (Struct->Type2->BoardType, Option);
- }
- break;
-
- //
- // System Enclosure (Type 3)
- //
- case 3:
- PRINT_PENDING_STRING (Struct, Type3, Manufacturer);
- PRINT_STRUCT_VALUE (Struct, Type3, Type);
- DisplaySystemEnclosureType (Struct->Type3->Type, Option);
- PRINT_PENDING_STRING (Struct, Type3, Version);
- PRINT_PENDING_STRING (Struct, Type3, SerialNumber);
- PRINT_PENDING_STRING (Struct, Type3, AssetTag);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOTUP_STATE), gShellDebug1HiiHandle);
- DisplaySystemEnclosureStatus (Struct->Type3->BootupState, Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_STATE), gShellDebug1HiiHandle);
- DisplaySystemEnclosureStatus (Struct->Type3->PowerSupplyState, Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_THERMAL_STATE), gShellDebug1HiiHandle);
- DisplaySystemEnclosureStatus (Struct->Type3->ThermalState, Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SECURITY_STATUS), gShellDebug1HiiHandle);
- DisplaySESecurityStatus (Struct->Type3->SecurityStatus, Option);
- if (AE_SMBIOS_VERSION (0x2, 0x3) && (Struct->Hdr->Length > 0xD)) {
- PRINT_BIT_FIELD (Struct, Type3, OemDefined, 4);
- }
- break;
-
- //
- // Processor Information (Type 4)
- //
- case 4:
- PRINT_PENDING_STRING (Struct, Type4, Socket);
- DisplayProcessorType (Struct->Type4->ProcessorType, Option);
- if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0x28) &&
- (Struct->Type4->ProcessorFamily == 0xFE)) {
- //
- // Get family from ProcessorFamily2 field
- //
- DisplayProcessorFamily2 (Struct->Type4->ProcessorFamily2, Option);
- } else {
- DisplayProcessorFamily (Struct->Type4->ProcessorFamily, Option);
- }
- PRINT_PENDING_STRING (Struct, Type4, ProcessorManufacture);
- PRINT_BIT_FIELD (Struct, Type4, ProcessorId, 8);
- PRINT_PENDING_STRING (Struct, Type4, ProcessorVersion);
- DisplayProcessorVoltage (*(UINT8 *) &(Struct->Type4->Voltage), Option);
- PRINT_STRUCT_VALUE (Struct, Type4, ExternalClock);
- PRINT_STRUCT_VALUE (Struct, Type4, MaxSpeed);
- PRINT_STRUCT_VALUE (Struct, Type4, CurrentSpeed);
- DisplayProcessorStatus (Struct->Type4->Status, Option);
- DisplayProcessorUpgrade (Struct->Type4->ProcessorUpgrade, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type4, L1CacheHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type4, L2CacheHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type4, L3CacheHandle);
- if (AE_SMBIOS_VERSION (0x2, 0x3) && (Struct->Hdr->Length > 0x20)) {
- PRINT_PENDING_STRING (Struct, Type4, SerialNumber);
- PRINT_PENDING_STRING (Struct, Type4, AssetTag);
- PRINT_PENDING_STRING (Struct, Type4, PartNumber);
- }
- if (AE_SMBIOS_VERSION (0x2, 0x5) && (Struct->Hdr->Length > 0x23)) {
- PRINT_STRUCT_VALUE (Struct, Type4, CoreCount);
- PRINT_STRUCT_VALUE (Struct, Type4, EnabledCoreCount);
- PRINT_STRUCT_VALUE (Struct, Type4, ThreadCount);
- DisplayProcessorCharacteristics (Struct->Type4->ProcessorCharacteristics, Option);
- }
- if ((SmbiosMajorVersion >= 0x3) && (Struct->Hdr->Length > 0x2A)) {
- PRINT_STRUCT_VALUE (Struct, Type4, CoreCount2);
- PRINT_STRUCT_VALUE (Struct, Type4, EnabledCoreCount2);
- PRINT_STRUCT_VALUE (Struct, Type4, ThreadCount2);
- }
- break;
-
- //
- // Memory Controller Information (Type 5)
- //
- case 5:
- {
- UINT8 SlotNum;
- SlotNum = Struct->Type5->AssociatedMemorySlotNum;
-
- DisplayMcErrorDetectMethod (Struct->Type5->ErrDetectMethod, Option);
- DisplayMcErrorCorrectCapability (*(UINT8 *) &(Struct->Type5->ErrCorrectCapability), Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SUPOPRT), gShellDebug1HiiHandle);
- DisplayMcInterleaveSupport (Struct->Type5->SupportInterleave, Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CURRENT), gShellDebug1HiiHandle);
- DisplayMcInterleaveSupport (Struct->Type5->CurrentInterleave, Option);
- DisplayMaxMemoryModuleSize (Struct->Type5->MaxMemoryModuleSize, SlotNum, Option);
- DisplayMcMemorySpeeds (*(UINT16 *) &(Struct->Type5->SupportSpeed), Option);
- DisplayMmMemoryType (Struct->Type5->SupportMemoryType, Option);
- DisplayMemoryModuleVoltage (Struct->Type5->MemoryModuleVoltage, Option);
- PRINT_STRUCT_VALUE (Struct, Type5, AssociatedMemorySlotNum);
- //
- // According to SMBIOS Specification, offset 0x0F
- //
- DisplayMemoryModuleConfigHandles ((UINT16 *) (&Buffer[0x0F]), SlotNum, Option);
- DisplayMcErrorCorrectCapability (Buffer[0x0F + 2 * SlotNum], Option);
- }
- break;
-
- //
- // Memory Module Information (Type 6)
- //
- case 6:
- PRINT_PENDING_STRING (Struct, Type6, SocketDesignation);
- DisplayMmBankConnections (Struct->Type6->BankConnections, Option);
- PRINT_STRUCT_VALUE (Struct, Type6, CurrentSpeed);
- DisplayMmMemoryType (*(UINT16 *) &(Struct->Type6->CurrentMemoryType), Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INSTALLED), gShellDebug1HiiHandle);
- DisplayMmMemorySize (*(UINT8 *) &(Struct->Type6->InstalledSize), Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED), gShellDebug1HiiHandle);
- DisplayMmMemorySize (*(UINT8 *) &(Struct->Type6->EnabledSize), Option);
- DisplayMmErrorStatus (Struct->Type6->ErrorStatus, Option);
- break;
-
- //
- // Cache Information (Type 7)
- //
- case 7:
- PRINT_PENDING_STRING (Struct, Type7, SocketDesignation);
- DisplayCacheConfiguration (Struct->Type7->CacheConfiguration, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type7, MaximumCacheSize);
- PRINT_STRUCT_VALUE_H (Struct, Type7, InstalledSize);
- PRINT_STRUCT_VALUE_H (Struct, Type7, SupportedSRAMType);
- PRINT_STRUCT_VALUE_H (Struct, Type7, CurrentSRAMType);
- DisplayCacheSRAMType (ReadUnaligned16 ((UINT16 *) (UINTN) &(Struct->Type7->CurrentSRAMType)), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type7, CacheSpeed);
- DisplayCacheErrCorrectingType (Struct->Type7->ErrorCorrectionType, Option);
- DisplayCacheSystemCacheType (Struct->Type7->SystemCacheType, Option);
- DisplayCacheAssociativity (Struct->Type7->Associativity, Option);
- break;
-
- //
- // Port Connector Information (Type 8)
- //
- case 8:
- PRINT_PENDING_STRING (Struct, Type8, InternalReferenceDesignator);
- Print (L"Internal ");
- DisplayPortConnectorType (Struct->Type8->InternalConnectorType, Option);
- PRINT_PENDING_STRING (Struct, Type8, ExternalReferenceDesignator);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EXTERNAL), gShellDebug1HiiHandle);
- DisplayPortConnectorType (Struct->Type8->ExternalConnectorType, Option);
- DisplayPortType (Struct->Type8->PortType, Option);
- break;
-
- //
- // System Slots (Type 9)
- //
- case 9:
- PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);
- DisplaySystemSlotType (Struct->Type9->SlotType, Option);
- DisplaySystemSlotDataBusWidth (Struct->Type9->SlotDataBusWidth, Option);
- DisplaySystemSlotCurrentUsage (Struct->Type9->CurrentUsage, Option);
- DisplaySystemSlotLength (Struct->Type9->SlotLength, Option);
- DisplaySystemSlotId (
- Struct->Type9->SlotID,
- Struct->Type9->SlotType,
- Option
- );
- DisplaySlotCharacteristics1 (*(UINT8 *) &(Struct->Type9->SlotCharacteristics1), Option);
- DisplaySlotCharacteristics2 (*(UINT8 *) &(Struct->Type9->SlotCharacteristics2), Option);
- if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0xD)) {
- PRINT_STRUCT_VALUE_H (Struct, Type9, SegmentGroupNum);
- PRINT_STRUCT_VALUE_H (Struct, Type9, BusNum);
- PRINT_STRUCT_VALUE_H (Struct, Type9, DevFuncNum);
- }
- break;
-
- //
- // On Board Devices Information (Type 10)
- //
- case 10:
- {
- UINTN NumOfDevice;
- NumOfDevice = (Struct->Type10->Hdr.Length - sizeof (SMBIOS_STRUCTURE)) / (2 * sizeof (UINT8));
- for (Index = 0; Index < NumOfDevice; Index++) {
- DisplayOnboardDeviceTypes (Struct->Type10->Device[Index].DeviceType, Option);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DESC_STRING), gShellDebug1HiiHandle);
- ShellPrintEx(-1,-1,L"%a\n",LibGetSmbiosString (Struct, Struct->Type10->Device[Index].DescriptionString));
- }
- }
- break;
-
- //
- // Oem Strings (Type 11)
- //
- case 11:
- PRINT_STRUCT_VALUE (Struct, Type11, StringCount);
- for (Index = 1; Index <= Struct->Type11->StringCount; Index++) {
- ShellPrintEx(-1,-1,L"%a\n", LibGetSmbiosString (Struct, Index));
- }
- break;
-
- //
- // System Configuration Options (Type 12)
- //
- case 12:
- PRINT_STRUCT_VALUE (Struct, Type12, StringCount);
- for (Index = 1; Index <= Struct->Type12->StringCount; Index++) {
- ShellPrintEx(-1,-1,L"%a\n", LibGetSmbiosString (Struct, Index));
- }
- break;
-
- //
- // BIOS Language Information (Type 13)
- //
- case 13:
- PRINT_STRUCT_VALUE (Struct, Type13, InstallableLanguages);
- PRINT_STRUCT_VALUE (Struct, Type13, Flags);
- PRINT_BIT_FIELD (Struct, Type13, Reserved, 15);
- PRINT_PENDING_STRING (Struct, Type13, CurrentLanguages);
- break;
-
- //
- // Group Associations (Type 14)
- //
- case 14:
- {
- UINT8 NumOfItem;
- NumOfItem = (Struct->Type14->Hdr.Length - 5) / 3;
- PRINT_PENDING_STRING (Struct, Type14, GroupName);
- for (Index = 0; Index < NumOfItem; Index++) {
- ShellPrintEx(-1,-1,L"ItemType %d: %d\n", Index + 1, Struct->Type14->Group[Index].ItemType);
- ShellPrintEx(-1,-1,L"ItemHandle %d: %d\n", Index + 1, Struct->Type14->Group[Index].ItemHandle);
- }
- }
- break;
-
- //
- // System Event Log (Type 15)
- //
- case 15:
- {
- EVENT_LOG_TYPE *Ptr;
- UINT8 Count;
- UINT8 *AccessMethodAddress;
-
- PRINT_STRUCT_VALUE_H (Struct, Type15, LogAreaLength);
- PRINT_STRUCT_VALUE_H (Struct, Type15, LogHeaderStartOffset);
- PRINT_STRUCT_VALUE_H (Struct, Type15, LogDataStartOffset);
- DisplaySELAccessMethod (Struct->Type15->AccessMethod, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type15, AccessMethodAddress);
- DisplaySELLogStatus (Struct->Type15->LogStatus, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type15, LogChangeToken);
- DisplaySysEventLogHeaderFormat (Struct->Type15->LogHeaderFormat, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type15, NumberOfSupportedLogTypeDescriptors);
- PRINT_STRUCT_VALUE_H (Struct, Type15, LengthOfLogTypeDescriptor);
-
- Count = Struct->Type15->NumberOfSupportedLogTypeDescriptors;
- if (Count > 0) {
- Ptr = Struct->Type15->EventLogTypeDescriptors;
-
- //
- // Display all Event Log type descriptors supported by system
- //
- for (Index = 0; Index < Count; Index++, Ptr++) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SUPOPRTED_EVENT), gShellDebug1HiiHandle, Index + 1);
- DisplaySELTypes (Ptr->LogType, Option);
- DisplaySELVarDataFormatType (Ptr->DataFormatType, Option);
- }
-
- if (Option >= SHOW_DETAIL) {
- switch (Struct->Type15->AccessMethod) {
- case 03:
- AccessMethodAddress = (UINT8 *) (UINTN) (Struct->Type15->AccessMethodAddress);
- break;
-
- case 00:
- case 01:
- case 02:
- case 04:
- default:
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ACCESS_METHOD_NOT_SUPOPRTED),
- gShellDebug1HiiHandle,
- Struct->Type15->AccessMethod
- );
- return EFI_UNSUPPORTED;
- }
- //
- // Display Event Log Header
- //
- // Starting offset (or index) within the nonvolatile storage
- // of the event-log's header, from the Access Method Address
- //
- DisplaySysEventLogHeader (
- Struct->Type15->LogHeaderFormat,
- AccessMethodAddress + Struct->Type15->LogHeaderStartOffset
- );
-
- //
- // Display all Event Log data
- //
- // Starting offset (or index) within the nonvolatile storage
- // of the event-log's first data byte, from the Access Method Address(0x14)
- //
- DisplaySysEventLogData (
- AccessMethodAddress + Struct->Type15->LogDataStartOffset,
- (UINT16)
- (
- Struct->Type15->LogAreaLength -
- (Struct->Type15->LogDataStartOffset - Struct->Type15->LogHeaderStartOffset)
- )
- );
- }
-
- }
- }
- break;
-
- //
- // Physical Memory Array (Type 16)
- //
- case 16:
- DisplayPMALocation (Struct->Type16->Location, Option);
- DisplayPMAUse (Struct->Type16->Use, Option);
- DisplayPMAErrorCorrectionTypes (
- Struct->Type16->MemoryErrorCorrection,
- Option
- );
- PRINT_STRUCT_VALUE_H (Struct, Type16, MaximumCapacity);
- PRINT_STRUCT_VALUE_H (Struct, Type16, MemoryErrorInformationHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type16, NumberOfMemoryDevices);
- if (AE_SMBIOS_VERSION (0x2, 0x7) && Struct->Hdr->Length > 0xF) {
- PRINT_STRUCT_VALUE_LH (Struct, Type16, ExtendedMaximumCapacity);
- }
- break;
-
- //
- // Memory Device (Type 17)
- //
- case 17:
- PRINT_STRUCT_VALUE_H (Struct, Type17, MemoryArrayHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type17, MemoryErrorInformationHandle);
- PRINT_STRUCT_VALUE (Struct, Type17, TotalWidth);
- PRINT_STRUCT_VALUE (Struct, Type17, DataWidth);
- PRINT_STRUCT_VALUE (Struct, Type17, Size);
- DisplayMemoryDeviceFormFactor (Struct->Type17->FormFactor, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type17, DeviceSet);
- PRINT_PENDING_STRING (Struct, Type17, DeviceLocator);
- PRINT_PENDING_STRING (Struct, Type17, BankLocator);
- DisplayMemoryDeviceType (Struct->Type17->MemoryType, Option);
- DisplayMemoryDeviceTypeDetail (ReadUnaligned16 ((UINT16 *) (UINTN) &(Struct->Type17->TypeDetail)), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type17, Speed);
- PRINT_PENDING_STRING (Struct, Type17, Manufacturer);
- PRINT_PENDING_STRING (Struct, Type17, SerialNumber);
- PRINT_PENDING_STRING (Struct, Type17, AssetTag);
- PRINT_PENDING_STRING (Struct, Type17, PartNumber);
- if (AE_SMBIOS_VERSION (0x2, 0x6) && (Struct->Hdr->Length > 0x1B)) {
- PRINT_STRUCT_VALUE_H (Struct, Type17, Attributes);
- }
- if (AE_SMBIOS_VERSION (0x2, 0x7) && (Struct->Hdr->Length > 0x1C)) {
- PRINT_STRUCT_VALUE (Struct, Type17, ExtendedSize);
- PRINT_STRUCT_VALUE (Struct, Type17, ConfiguredMemoryClockSpeed);
- }
- if (AE_SMBIOS_VERSION (0x2, 0x8) && (Struct->Hdr->Length > 0x22)) {
- PRINT_STRUCT_VALUE (Struct, Type17, MinimumVoltage);
- PRINT_STRUCT_VALUE (Struct, Type17, MaximumVoltage);
- PRINT_STRUCT_VALUE (Struct, Type17, ConfiguredVoltage);
- }
- break;
-
- //
- // 32-bit Memory Error Information (Type 18)
- //
- case 18:
- DisplayMemoryErrorType (Struct->Type18->ErrorType, Option);
- DisplayMemoryErrorGranularity (
- Struct->Type18->ErrorGranularity,
- Option
- );
- DisplayMemoryErrorOperation (Struct->Type18->ErrorOperation, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type18, VendorSyndrome);
- PRINT_STRUCT_VALUE_H (Struct, Type18, MemoryArrayErrorAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type18, DeviceErrorAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type18, ErrorResolution);
- break;
-
- //
- // Memory Array Mapped Address (Type 19)
- //
- case 19:
- PRINT_STRUCT_VALUE_H (Struct, Type19, StartingAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type19, EndingAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type19, MemoryArrayHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type19, PartitionWidth);
- if (AE_SMBIOS_VERSION (0x2, 0x7) && (Struct->Hdr->Length > 0xF)) {
- PRINT_STRUCT_VALUE_LH (Struct, Type19, ExtendedStartingAddress);
- PRINT_STRUCT_VALUE_LH (Struct, Type19, ExtendedEndingAddress);
- }
- break;
-
- //
- // Memory Device Mapped Address (Type 20)
- //
- case 20:
- PRINT_STRUCT_VALUE_H (Struct, Type20, StartingAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type20, EndingAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type20, MemoryDeviceHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type20, MemoryArrayMappedAddressHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type20, PartitionRowPosition);
- PRINT_STRUCT_VALUE_H (Struct, Type20, InterleavePosition);
- PRINT_STRUCT_VALUE_H (Struct, Type20, InterleavedDataDepth);
- if (AE_SMBIOS_VERSION (0x2, 0x7) && (Struct->Hdr->Length > 0x13)) {
- PRINT_STRUCT_VALUE_LH (Struct, Type19, ExtendedStartingAddress);
- PRINT_STRUCT_VALUE_LH (Struct, Type19, ExtendedEndingAddress);
- }
- break;
-
- //
- // Built-in Pointing Device (Type 21)
- //
- case 21:
- DisplayPointingDeviceType (Struct->Type21->Type, Option);
- DisplayPointingDeviceInterface (Struct->Type21->Interface, Option);
- PRINT_STRUCT_VALUE (Struct, Type21, NumberOfButtons);
- break;
-
- //
- // Portable Battery (Type 22)
- //
- case 22:
- PRINT_PENDING_STRING (Struct, Type22, Location);
- PRINT_PENDING_STRING (Struct, Type22, Manufacturer);
- PRINT_PENDING_STRING (Struct, Type22, ManufactureDate);
- PRINT_PENDING_STRING (Struct, Type22, SerialNumber);
- PRINT_PENDING_STRING (Struct, Type22, DeviceName);
- DisplayPBDeviceChemistry (
- Struct->Type22->DeviceChemistry,
- Option
- );
- PRINT_STRUCT_VALUE_H (Struct, Type22, DeviceCapacity);
- PRINT_STRUCT_VALUE_H (Struct, Type22, DesignVoltage);
- PRINT_PENDING_STRING (Struct, Type22, SBDSVersionNumber);
- PRINT_STRUCT_VALUE_H (Struct, Type22, MaximumErrorInBatteryData);
- PRINT_STRUCT_VALUE_H (Struct, Type22, SBDSSerialNumber);
- DisplaySBDSManufactureDate (
- Struct->Type22->SBDSManufactureDate,
- Option
- );
- PRINT_PENDING_STRING (Struct, Type22, SBDSDeviceChemistry);
- PRINT_STRUCT_VALUE_H (Struct, Type22, DesignCapacityMultiplier);
- PRINT_STRUCT_VALUE_H (Struct, Type22, OEMSpecific);
- break;
-
- //
- // System Reset (Type 23)
- //
- case 23:
- DisplaySystemResetCapabilities (
- Struct->Type23->Capabilities,
- Option
- );
- PRINT_STRUCT_VALUE_H (Struct, Type23, ResetCount);
- PRINT_STRUCT_VALUE_H (Struct, Type23, ResetLimit);
- PRINT_STRUCT_VALUE_H (Struct, Type23, TimerInterval);
- PRINT_STRUCT_VALUE_H (Struct, Type23, Timeout);
- break;
-
- //
- // Hardware Security (Type 24)
- //
- case 24:
- DisplayHardwareSecuritySettings (
- Struct->Type24->HardwareSecuritySettings,
- Option
- );
- break;
-
- //
- // System Power Controls (Type 25)
- //
- case 25:
- PRINT_STRUCT_VALUE_H (Struct, Type25, NextScheduledPowerOnMonth);
- PRINT_STRUCT_VALUE_H (Struct, Type25, NextScheduledPowerOnDayOfMonth);
- PRINT_STRUCT_VALUE_H (Struct, Type25, NextScheduledPowerOnHour);
- PRINT_STRUCT_VALUE_H (Struct, Type25, NextScheduledPowerOnMinute);
- PRINT_STRUCT_VALUE_H (Struct, Type25, NextScheduledPowerOnSecond);
- break;
-
- //
- // Voltage Probe (Type 26)
- //
- case 26:
- PRINT_PENDING_STRING (Struct, Type26, Description);
- DisplayVPLocation (*(UINT8 *) &(Struct->Type26->LocationAndStatus), Option);
- DisplayVPStatus (*(UINT8 *) &(Struct->Type26->LocationAndStatus), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type26, MaximumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type26, MinimumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type26, Resolution);
- PRINT_STRUCT_VALUE_H (Struct, Type26, Tolerance);
- PRINT_STRUCT_VALUE_H (Struct, Type26, Accuracy);
- PRINT_STRUCT_VALUE_H (Struct, Type26, OEMDefined);
- PRINT_STRUCT_VALUE_H (Struct, Type26, NominalValue);
- break;
-
- //
- // Cooling Device (Type 27)
- //
- case 27:
- PRINT_STRUCT_VALUE_H (Struct, Type27, TemperatureProbeHandle);
- DisplayCoolingDeviceStatus (*(UINT8 *) &(Struct->Type27->DeviceTypeAndStatus), Option);
- DisplayCoolingDeviceType (*(UINT8 *) &(Struct->Type27->DeviceTypeAndStatus), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type27, CoolingUnitGroup);
- PRINT_STRUCT_VALUE_H (Struct, Type27, OEMDefined);
- PRINT_STRUCT_VALUE_H (Struct, Type27, NominalSpeed);
- if (AE_SMBIOS_VERSION (0x2, 0x7) && (Struct->Hdr->Length > 0xE)) {
- PRINT_PENDING_STRING (Struct, Type27, Description);
- }
- break;
-
- //
- // Temperature Probe (Type 28)
- //
- case 28:
- PRINT_PENDING_STRING (Struct, Type28, Description);
- DisplayTemperatureProbeStatus (*(UINT8 *) &(Struct->Type28->LocationAndStatus), Option);
- DisplayTemperatureProbeLoc (*(UINT8 *) &(Struct->Type28->LocationAndStatus), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type28, MaximumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type28, MinimumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type28, Resolution);
- PRINT_STRUCT_VALUE_H (Struct, Type28, Tolerance);
- PRINT_STRUCT_VALUE_H (Struct, Type28, Accuracy);
- PRINT_STRUCT_VALUE_H (Struct, Type28, OEMDefined);
- PRINT_STRUCT_VALUE_H (Struct, Type28, NominalValue);
- break;
-
- //
- // Electrical Current Probe (Type 29)
- //
- case 29:
- PRINT_PENDING_STRING (Struct, Type29, Description);
- DisplayECPStatus (*(UINT8 *) &(Struct->Type29->LocationAndStatus), Option);
- DisplayECPLoc (*(UINT8 *) &(Struct->Type29->LocationAndStatus), Option);
- PRINT_STRUCT_VALUE_H (Struct, Type29, MaximumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type29, MinimumValue);
- PRINT_STRUCT_VALUE_H (Struct, Type29, Resolution);
- PRINT_STRUCT_VALUE_H (Struct, Type29, Tolerance);
- PRINT_STRUCT_VALUE_H (Struct, Type29, Accuracy);
- PRINT_STRUCT_VALUE_H (Struct, Type29, OEMDefined);
- PRINT_STRUCT_VALUE_H (Struct, Type29, NominalValue);
- break;
-
- //
- // Out-of-Band Remote Access (Type 30)
- //
- case 30:
- PRINT_PENDING_STRING (Struct, Type30, ManufacturerName);
- DisplayOBRAConnections (Struct->Type30->Connections, Option);
- break;
-
- //
- // Boot Integrity Services (BIS) Entry Point (Type 31)
- //
- case 31:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_TYPE31), gShellDebug1HiiHandle);
- break;
-
- //
- // System Boot Information (Type 32)
- //
- case 32:
- PRINT_BIT_FIELD (Struct, Type32, Reserved, 6);
- DisplaySystemBootStatus (Struct->Type32->BootStatus, Option);
- break;
-
- //
- // 64-Bit Memory Error Information (Type 33)
- //
- case 33:
- DisplayMemoryErrorType (Struct->Type33->ErrorType, Option);
- DisplayMemoryErrorGranularity (
- Struct->Type33->ErrorGranularity,
- Option
- );
- DisplayMemoryErrorOperation (Struct->Type33->ErrorOperation, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type33, VendorSyndrome);
- PRINT_STRUCT_VALUE_LH (Struct, Type33, MemoryArrayErrorAddress);
- PRINT_STRUCT_VALUE_LH (Struct, Type33, DeviceErrorAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type33, ErrorResolution);
- break;
-
- //
- // Management Device (Type 34)
- //
- case 34:
- PRINT_PENDING_STRING (Struct, Type34, Description);
- DisplayMDType (Struct->Type34->Type, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type34, Address);
- DisplayMDAddressType (Struct->Type34->AddressType, Option);
- break;
-
- //
- // Management Device Component (Type 35)
- //
- case 35:
- PRINT_PENDING_STRING (Struct, Type35, Description);
- PRINT_STRUCT_VALUE_H (Struct, Type35, ManagementDeviceHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type35, ComponentHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type35, ThresholdHandle);
- break;
-
- //
- // Management Device Threshold Data (Type 36)
- //
- case 36:
- PRINT_STRUCT_VALUE_H (Struct, Type36, LowerThresholdNonCritical);
- PRINT_STRUCT_VALUE_H (Struct, Type36, UpperThresholdNonCritical);
- PRINT_STRUCT_VALUE_H (Struct, Type36, LowerThresholdCritical);
- PRINT_STRUCT_VALUE_H (Struct, Type36, UpperThresholdCritical);
- PRINT_STRUCT_VALUE_H (Struct, Type36, LowerThresholdNonRecoverable);
- PRINT_STRUCT_VALUE_H (Struct, Type36, UpperThresholdNonRecoverable);
- break;
-
- //
- // Memory Channel (Type 37)
- //
- case 37:
- {
- UINT8 Count;
- MEMORY_DEVICE *Ptr;
- DisplayMemoryChannelType (Struct->Type37->ChannelType, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type37, MaximumChannelLoad);
- PRINT_STRUCT_VALUE_H (Struct, Type37, MemoryDeviceCount);
-
- Count = Struct->Type37->MemoryDeviceCount;
- Ptr = Struct->Type37->MemoryDevice;
- for (Index = 0; Index < Count; Index++) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_DEVICE), gShellDebug1HiiHandle, Index + 1);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DEV_LOAD), gShellDebug1HiiHandle, Ptr[Index].DeviceLoad);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DEV_HANDLE), gShellDebug1HiiHandle, Ptr[Index].DeviceHandle);
- }
- }
- break;
-
- //
- // IPMI Device Information (Type 38)
- //
- case 38:
- DisplayIPMIDIBMCInterfaceType (Struct->Type38->InterfaceType, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type38, IPMISpecificationRevision);
- PRINT_STRUCT_VALUE_H (Struct, Type38, I2CSlaveAddress);
- PRINT_STRUCT_VALUE_H (Struct, Type38, NVStorageDeviceAddress);
- PRINT_STRUCT_VALUE_LH (Struct, Type38, BaseAddress);
- break;
-
- //
- // System Power Supply (Type 39)
- //
- case 39:
- PRINT_STRUCT_VALUE_H (Struct, Type39, PowerUnitGroup);
- PRINT_PENDING_STRING (Struct, Type39, Location);
- PRINT_PENDING_STRING (Struct, Type39, DeviceName);
- PRINT_PENDING_STRING (Struct, Type39, Manufacturer);
- PRINT_PENDING_STRING (Struct, Type39, SerialNumber);
- PRINT_PENDING_STRING (Struct, Type39, AssetTagNumber);
- PRINT_PENDING_STRING (Struct, Type39, ModelPartNumber);
- PRINT_PENDING_STRING (Struct, Type39, RevisionLevel);
- PRINT_STRUCT_VALUE_H (Struct, Type39, MaxPowerCapacity);
- DisplaySPSCharacteristics (
- *(UINT16 *) &(Struct->Type39->PowerSupplyCharacteristics),
- Option
- );
- PRINT_STRUCT_VALUE_H (Struct, Type39, InputVoltageProbeHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type39, CoolingDeviceHandle);
- PRINT_STRUCT_VALUE_H (Struct, Type39, InputCurrentProbeHandle);
- break;
-
- //
- // Additional Information (Type 40)
- //
- case 40:
- {
- UINT8 NumberOfEntries;
- UINT8 EntryLength;
- ADDITIONAL_INFORMATION_ENTRY *Entries;
-
- EntryLength = 0;
- Entries = Struct->Type40->AdditionalInfoEntries;
- NumberOfEntries = Struct->Type40->NumberOfAdditionalInformationEntries;
-
- PRINT_STRUCT_VALUE_H (Struct, Type40, NumberOfAdditionalInformationEntries);
-
- for (Index = 0; Index < NumberOfEntries; Index++) {
- EntryLength = Entries->EntryLength;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTRYLEN), gShellDebug1HiiHandle, EntryLength);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDHANDLE), gShellDebug1HiiHandle, Entries->ReferencedHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDOFFSET), gShellDebug1HiiHandle, Entries->ReferencedOffset);
- PRINT_SMBIOS_STRING (Struct, Entries->EntryString, String);
- PRINT_SMBIOS_BIT_FIELD (Struct, Entries->Value, Value, EntryLength - 5);
- Entries = (ADDITIONAL_INFORMATION_ENTRY *) ((UINT8 *)Entries + EntryLength);
- }
- }
- break;
-
- //
- // Onboard Devices Extended Information (Type 41)
- //
- case 41:
- PRINT_PENDING_STRING (Struct, Type41, ReferenceDesignation);
- ShellPrintEx(-1,-1,(((Struct->Type41->DeviceType) & 0x80) != 0) ? L"Device Enabled\n": L"Device Disabled\n");
- DisplayOnboardDeviceTypes ((Struct->Type41->DeviceType) & 0x7F, Option);
- PRINT_STRUCT_VALUE_H (Struct, Type41, DeviceTypeInstance);
- PRINT_STRUCT_VALUE_H (Struct, Type41, SegmentGroupNum);
- PRINT_STRUCT_VALUE_H (Struct, Type41, BusNum);
- PRINT_STRUCT_VALUE_H (Struct, Type41, DevFuncNum);
- break;
-
- //
- // Management Controller Host Interface (Type 42)
- //
- case 42:
- PRINT_STRUCT_VALUE_H (Struct, Type42, InterfaceType);
- break;
-
- //
- // Inactive (Type 126)
- //
- case 126:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INACTIVE_STRUCT), gShellDebug1HiiHandle);
- break;
-
- //
- // End-of-Table (Type 127)
- //
- case 127:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_THIS_STRUCT_END_TABLE), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STRUCT_TYPE_UNDEFINED), gShellDebug1HiiHandle);
- break;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Display BIOS Information (Type 0) information.
-
- @param[in] Chara The information bits.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristics (
- IN UINT64 Chara,
- IN UINT8 Option
- )
-{
- //
- // Print header
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR), gShellDebug1HiiHandle);
- //
- // print option
- //
- PRINT_INFO_OPTION (Chara, Option);
-
- //
- // Check all the bits and print information
- // This function does not use Table because table of bits
- // are designed not to deal with UINT64
- //
- if (BIT (Chara, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_BIT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_BIT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 2) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN_BIT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_NOT_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ISA_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MSA_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 6) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EISA_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PCI_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 8) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PC_CARD_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 9) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PLUG_PLAY_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 10) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_APM_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 11) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_UPGRADEABLE), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 12) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SHADOWING), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 13) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VESA_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 14) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ECSD_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 15) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_FORM_CD_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 16) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SELECTED_BOOT_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 17) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_ROM_SOCKETED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 18) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_FROM_PC_CARD), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 19) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_EDD_ENHANCED_DRIVER), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 20) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_NEC), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 21) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_JAPANESE_FLOPPY_TOSHIBA), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 22) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FLOPPY_SERVICES_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 23) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_POINT_TWO_MB), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 24) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_720_KB), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 25) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TWO_POINT_EIGHT_EIGHT_MB), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 26) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRINT_SCREEN_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 27) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_KEYBOARD_SERV_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 28) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SERIAL_SERVICES_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 29) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRINTER_SERVICES_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 30) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MONO_VIDEO_SUPPORT), gShellDebug1HiiHandle);
- }
-
- if (BIT (Chara, 31) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NEC_PC_98), gShellDebug1HiiHandle);
- }
- //
- // Just print the Reserved
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_32_47), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_48_64), gShellDebug1HiiHandle);
-}
-
-/**
- Display Bios Characteristice extensions1 information.
-
- @param[in] Byte1 The information.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristicsExt1 (
- IN UINT8 Byte1,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_EXTENSION), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (Byte1, Option);
-
- //
- // check bit and print
- //
- if (BIT (Byte1, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ACPI_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_USB_LEGACY_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 2) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AGP_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_I2O_BOOT_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LS_120_BOOT_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ATAPI_ZIP_DRIVE), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 6) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_1394_BOOT_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Byte1, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMART_BATTERY_SUPPORTED), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display Bios Characteristice extensions2 information.
-
- @param[in] byte2 The information.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristicsExt2 (
- IN UINT8 byte2,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_CHAR_EXTENSION_2), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (byte2, Option);
-
- if (BIT (byte2, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_BOOT_SPEC_SUPP), gShellDebug1HiiHandle);
- }
-
- if (BIT (byte2, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FUNCTION_KEY_INIT), gShellDebug1HiiHandle);
- }
-
- if (AE_SMBIOS_VERSION (0x2, 0x4)) {
- if (BIT (byte2, 2) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLE_TAR_CONT_DIST), gShellDebug1HiiHandle);
- }
- if (AE_SMBIOS_VERSION (0x2, 0x7)) {
- if (BIT (byte2, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UEFI_SPEC_SUPPORT), gShellDebug1HiiHandle);
- }
- if (BIT (byte2, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VIRTUAL_MACHINE), gShellDebug1HiiHandle);
- }
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RSVD_FOR_FUTURE), gShellDebug1HiiHandle, 5);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RSVD_FOR_FUTURE), gShellDebug1HiiHandle, 3);
- }
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RSVD_FOR_FUTURE), gShellDebug1HiiHandle, 2);
- }
-}
-
-/**
- Display Processor Information (Type 4) information.
-
- @param[in] Family The family value.
- @param[in] Option The option value.
-**/
-VOID
-DisplayProcessorFamily (
- UINT8 Family,
- UINT8 Option
- )
-{
- //
- // Print prompt message
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (Family, Option);
-
- //
- // Use switch to check
- //
- switch (Family) {
- case 0x01:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER), gShellDebug1HiiHandle);
- break;
-
- case 0x02:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
-
- case 0x03:
- Print (L"8086\n");
- break;
-
- case 0x04:
- Print (L"80286\n");
- break;
-
- case 0x05:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL386_PROCESSOR), gShellDebug1HiiHandle);
- break;
-
- case 0x06:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL486_PROCESSOR), gShellDebug1HiiHandle);
- break;
-
- case 0x07:
- Print (L"8087\n");
- break;
-
- case 0x08:
- Print (L"80287\n");
- break;
-
- case 0x09:
- Print (L"80387\n");
- break;
-
- case 0x0A:
- Print (L"80487\n");
- break;
-
- case 0x0B:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PROC_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x0C:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PRO_PROC), gShellDebug1HiiHandle);
- break;
-
- case 0x0D:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_II_PROC), gShellDebug1HiiHandle);
- break;
-
- case 0x0E:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_PROC_MMX), gShellDebug1HiiHandle);
- break;
-
- case 0x0F:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CELERON_PROC), gShellDebug1HiiHandle);
- break;
-
- case 0x10:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_XEON_PROC), gShellDebug1HiiHandle);
- break;
-
- case 0x11:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_III_PROC), gShellDebug1HiiHandle);
- break;
-
- case 0x12:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_M1_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x13:
- Print (L"M2 Family\n");
- break;
-
- case 0x14:
- Print (L"Intel Celeron M\n");
- break;
-
- case 0x15:
- Print (L"Intel Pentium 4 HT\n");
- break;
-
- case 0x18:
- Print (L"AMD Duron\n");
- break;
-
- case 0x19:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_K5_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x1A:
- Print (L"K6 Family\n");
- break;
-
- case 0x1B:
- Print (L"K6-2\n");
- break;
-
- case 0x1C:
- Print (L"K6-3\n");
- break;
-
- case 0x1D:
- Print (L"AMD Althon Processor Family\n");
- break;
-
- case 0x1E:
- Print (L"AMD 29000 Family\n");
- break;
-
- case 0x1F:
- Print (L"K6-2+\n");
- break;
-
- case 0x20:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x21:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_601), gShellDebug1HiiHandle);
- break;
-
- case 0x22:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_603), gShellDebug1HiiHandle);
- break;
-
- case 0x23:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_603_PLUS), gShellDebug1HiiHandle);
- break;
-
- case 0x24:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_604), gShellDebug1HiiHandle);
- break;
-
- case 0x25:
- Print (L"Power PC 620\n");
- break;
-
- case 0x26:
- Print (L"Power PC 704\n");
- break;
-
- case 0x27:
- Print (L"Power PC 750\n");
- break;
-
- case 0x28:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_DUO), gShellDebug1HiiHandle);
- break;
-
- case 0x29:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_DUO_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0x2A:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_SOLO_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0x2B:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_ATOM), gShellDebug1HiiHandle);
- break;
-
- case 0x30:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ALPHA_FAMILY_2), gShellDebug1HiiHandle);
- break;
-
- case 0x31:
- Print (L"Alpha 21064\n");
- break;
-
- case 0x32:
- Print (L"Alpha 21066\n");
- break;
-
- case 0x33:
- Print (L"Alpha 21164\n");
- break;
-
- case 0x34:
- Print (L"Alpha 21164PC\n");
- break;
-
- case 0x35:
- Print (L"Alpha 21164a\n");
- break;
-
- case 0x36:
- Print (L"Alpha 21264\n");
- break;
-
- case 0x37:
- Print (L"Alpha 21364\n");
- break;
-
- case 0x38:
- Print (L"AMD Turion II Ultra Dual-Core Mobile M Processor Family\n");
- break;
-
- case 0x39:
- Print (L"AMD Turion II Dual-Core Mobile M Processor Family\n");
- break;
-
- case 0x3A:
- Print (L"AMD Althon II Dual-Core M Processor Family\n");
- break;
-
- case 0x3B:
- Print (L"AMD Opteron 6100 Series Processor\n");
- break;
-
- case 0x3C:
- Print (L"AMD Opteron 4100 Series Processor\n");
- break;
-
- case 0x3D:
- Print (L"AMD Opteron 6200 Series Processor\n");
- break;
-
- case 0x3E:
- Print (L"AMD Opteron 4200 Series Processor\n");
- break;
-
- case 0x3F:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_FX_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x40:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MIPS_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x41:
- Print (L"MIPS R4000\n");
- break;
-
- case 0x42:
- Print (L"MIPS R4200\n");
- break;
-
- case 0x43:
- Print (L"MIPS R4400\n");
- break;
-
- case 0x44:
- Print (L"MIPS R4600\n");
- break;
-
- case 0x45:
- Print (L"MIPS R10000\n");
- break;
-
- case 0x46:
- Print (L"AMD C-Series Processor\n");
- break;
-
- case 0x47:
- Print (L"AMD E-Series Processor\n");
- break;
-
- case 0x48:
- Print (L"AMD A-Series Processor\n");
- break;
-
- case 0x49:
- Print (L"AMD G-Series Processor\n");
- break;
-
- case 0x4A:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_Z_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x4B:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_R_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x4C:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_4300_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x4D:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_6300_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x4E:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_3300_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x4F:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_FIREPRO_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0x50:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SPARC_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x51:
- Print (L"SuperSparc\n");
- break;
-
- case 0x52:
- Print (L"microSparc II\n");
- break;
-
- case 0x53:
- Print (L"microSparc IIep\n");
- break;
-
- case 0x54:
- Print (L"UltraSparc\n");
- break;
-
- case 0x55:
- Print (L"UltraSparc II\n");
- break;
-
- case 0x56:
- Print (L"UltraSparcIIi\n");
- break;
-
- case 0x57:
- Print (L"UltraSparcIII\n");
- break;
-
- case 0x58:
- Print (L"UltraSparcIIIi\n");
- break;
-
- case 0x60:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_68040_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x61:
- Print (L"68xx\n");
- break;
-
- case 0x62:
- Print (L"68000\n");
- break;
-
- case 0x63:
- Print (L"68010\n");
- break;
-
- case 0x64:
- Print (L"68020\n");
- break;
-
- case 0x65:
- Print (L"68030\n");
- break;
-
- case 0x70:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x78:
- Print (L"Crusoe TM5000\n");
- break;
-
- case 0x79:
- Print (L"Crusoe TM3000\n");
- break;
-
- case 0x7A:
- Print (L"Efficeon TM8000\n");
- break;
-
- case 0x80:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WEITEK), gShellDebug1HiiHandle);
- break;
-
- case 0x82:
- Print (L"Itanium\n");
- break;
-
- case 0x83:
- Print (L"AMD Athlon64\n");
- break;
-
- case 0x84:
- Print (L"AMD Opteron\n");
- break;
-
- case 0x85:
- Print (L"AMD Sempron\n");
- break;
-
- case 0x86:
- Print (L"AMD Turion64 Mobile\n");
- break;
-
- case 0x87:
- Print (L"Dual-Core AMD Opteron\n");
- break;
-
- case 0x88:
- Print (L"AMD Athlon 64X2 DualCore\n");
- break;
-
- case 0x89:
- Print (L"AMD Turion 64X2 Mobile\n");
- break;
-
- case 0x8A:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0x8B:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_THIRD_GENERATION), gShellDebug1HiiHandle);
- break;
-
- case 0x8C:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_FX_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0x8D:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_X4_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0x8E:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_X2_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0x8F:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_ATHLON_X2_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0x90:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PA_RISC_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0x91:
- Print (L"PA-RISC 8500\n");
- break;
-
- case 0x92:
- Print (L"PA-RISC 8000\n");
- break;
-
- case 0x93:
- Print (L"PA-RISC 7300LC\n");
- break;
-
- case 0x94:
- Print (L"PA-RISC 7200\n");
- break;
-
- case 0x95:
- Print (L"PA-RISC 7100LC\n");
- break;
-
- case 0x96:
- Print (L"PA-RISC 7100\n");
- break;
-
- case 0xA0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_V30_FAMILY), gShellDebug1HiiHandle);
- break;
-
- case 0xA1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3200_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3000_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5300_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5100_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5000_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_LV_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_ULV_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA8:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7100_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xA9:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5400_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAA:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAB:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5200_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAC:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7200_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAD:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7300_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAE:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7400_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xAF:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7400_SERIES_MULTI_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xB0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_III_XEON), gShellDebug1HiiHandle);
- break;
-
- case 0xB1:
- Print (L"Pentium III Processorwith Intel SpeedStep Technology\n");
- break;
-
- case 0xB2:
- Print (L"Pentium 4 processor\n");
- break;
-
- case 0xB3:
- Print (L"Intel Xeon Processor\n");
- break;
-
- case 0xB4:
- Print (L"AS400 Family\n");
- break;
-
- case 0xB5:
- Print (L"Intel Xeon processor MP\n");
- break;
-
- case 0xB6:
- Print (L"AMD Althon XP Processor Family\n");
- break;
-
- case 0xB7:
- Print (L"AMD Althon MP Promcessor Family\n");
- break;
-
- case 0xB8:
- Print (L"Intel Itanium 2 processor\n");
- break;
-
- case 0xB9:
- Print (L"Intel Penium M processor\n");
- break;
-
- case 0xBA:
- Print (L"Intel Celeron D processor\n");
- break;
-
- case 0xBB:
- Print (L"Intel Pentium D processor\n");
- break;
-
- case 0xBC:
- Print (L"Intel Pentium Processor Extreme Edition\n");
- break;
-
- case 0xBD:
- Print (L"Intel Core Solo Processor\n");
- break;
-
- case 0xBF:
- Print (L"Intel Core 2 Duo Processor\n");
- break;
-
- case 0xC0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_SOLO), gShellDebug1HiiHandle);
- break;
-
- case 0xC1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_EXTREME), gShellDebug1HiiHandle);
- break;
-
- case 0xC2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_QUAD), gShellDebug1HiiHandle);
- break;
-
- case 0xC3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_EXTREME), gShellDebug1HiiHandle);
- break;
-
- case 0xC4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_DUO_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0xC5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE2_SOLO_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0xC6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CORE_I7), gShellDebug1HiiHandle);
- break;
-
- case 0xC7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_CELERON_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xC8:
- Print (L"IBM 390\n");
- break;
-
- case 0xC9:
- Print (L"G4\n");
- break;
-
- case 0xCA:
- Print (L"G5\n");
- break;
-
- case 0xCB:
- Print (L"G6\n");
- break;
-
- case 0xCC:
- Print (L"zArchitecture\n");
- break;
-
- case 0xCD:
- Print (L"Intel Core i5 processor\n");
- break;
-
- case 0xCE:
- Print (L"Intel Core i3 processor\n");
- break;
-
- case 0xD2:
- Print (L"ViaC7M\n");
- break;
-
- case 0xD3:
- Print (L"ViaC7D\n");
- break;
-
- case 0xD4:
- Print (L"ViaC7\n");
- break;
-
- case 0xD5:
- Print (L"Eden\n");
- break;
-
- case 0xD6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_MULTI_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xD7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xD8:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_3_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xDA:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xDB:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_5_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xDD:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xDE:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xDF:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INTEL_XEON_7_SERIES_MULTI_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xE0:
- Print (L"Multi-Core Intel Xeon processor 3400 Series\n");
- break;
-
- case 0xE4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_OPTERON_3000_SERIES), gShellDebug1HiiHandle);
- break;
-
- case 0xE5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_SEMPRON_II), gShellDebug1HiiHandle);
- break;
-
-
- case 0xE6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_EMBEDDED_OPTERON_QUAD_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xE7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_PHENOM_TRIPLE_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xE8:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_TURION_ULTRA_DUAL_CORE_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0xE9:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_TURION_DUAL_CORE_MOBILE), gShellDebug1HiiHandle);
- break;
-
- case 0xEA:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_ATHLON_DUAL_CORE), gShellDebug1HiiHandle);
- break;
-
- case 0xEB:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AMD_SEMPRON_SI), gShellDebug1HiiHandle);
- break;
-
- case 0xEC:
- Print (L"AMD Phenom II Processor Family\n");
- break;
-
- case 0xED:
- Print (L"AMD Althon II Processor Family\n");
- break;
-
- case 0xEE:
- Print (L"Six-Core AMD Opteron Processor Family\n");
- break;
-
- case 0xEF:
- Print (L"AMD Sempron M Processor Family\n");
- break;
-
- case 0xFA:
- Print (L"i860\n");
- break;
-
- case 0xFB:
- Print (L"i960\n");
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_PROC_FAMILY), gShellDebug1HiiHandle);
- }
- //
- // end switch
- //
-}
-
-/**
- Display processor family information.
-
- @param[in] Family2 The family value.
- @param[in] Option The option value.
-**/
-VOID
-DisplayProcessorFamily2 (
- IN UINT16 Family2,
- IN UINT8 Option
- )
-{
- //
- // Print prompt message
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY), gShellDebug1HiiHandle);
-
- //
- // Print option
- //
- PRINT_INFO_OPTION (Family2, Option);
-
- //
- // Use switch to check
- //
- switch (Family2) {
- case 0x104:
- Print (L"SH-3\n");
- break;
-
- case 0x105:
- Print (L"SH-4\n");
- break;
-
- case 0x118:
- Print (L"ARM\n");
- break;
-
- case 0x119:
- Print (L"StrongARM\n");
- break;
-
- case 0x12C:
- Print (L"6x86\n");
- break;
-
- case 0x12D:
- Print (L"MediaGX\n");
- break;
-
- case 0x12E:
- Print (L"MII\n");
- break;
-
- case 0x140:
- Print (L"WinChip\n");
- break;
-
- case 0x15E:
- Print (L"DSP\n");
- break;
-
- case 0x1F4:
- Print (L"Video Processor\n");
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_PROC_FAMILY), gShellDebug1HiiHandle);
- }
-
-}
-
-/**
- Display processor voltage information.
-
- @param[in] Voltage The Voltage.
- Bit 7 Set to 0, indicating 'legacy' mode for processor voltage
- Bits 6:4 Reserved, must be zero
- Bits 3:0 Voltage Capability.
- A Set bit indicates that the voltage is supported.
- Bit 0 - 5V
- Bit 1 - 3.3V
- Bit 2 - 2.9V
- Bit 3 - Reserved, must be zero.
-
- Note:
- Setting of multiple bits indicates the socket is configurable
- If bit 7 is set to 1, the remaining seven bits of the field are set to
- contain the processor's current voltage times 10.
- For example, the field value for a processor voltage of 1.8 volts would be
- 92h = 80h + (1.8 * 10) = 80h + 18 = 80h +12h.
-
- @param[in] Option The option.
-**/
-VOID
-DisplayProcessorVoltage (
- IN UINT8 Voltage,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_INFO), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (Voltage, Option);
-
- if (BIT (Voltage, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_CURRENT_VOLTAGE), gShellDebug1HiiHandle, (Voltage - 0x80));
- } else {
- if (BIT (Voltage, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_5V_SUPOPRTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Voltage, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_33V_SUPPORTED), gShellDebug1HiiHandle);
- }
-
- if (BIT (Voltage, 2) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_29V_SUPPORTED), gShellDebug1HiiHandle);
- }
- //
- // check the reserved zero bits:
- //
- if (BIT (Voltage, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT3_NOT_ZERO), gShellDebug1HiiHandle);
- }
-
- if (BIT (Voltage, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT4_NOT_ZERO), gShellDebug1HiiHandle);
- }
-
- if (BIT (Voltage, 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT5_NOT_ZERO), gShellDebug1HiiHandle);
- }
-
- if (BIT (Voltage, 6) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT6_NOT_ZERO), gShellDebug1HiiHandle);
- }
- }
-}
-
-/**
- Display processor information.
-
- @param[in] Status The status.
-Bit 7 Reserved, must be 0
-Bit 6 CPU Socket Populated
- 1 - CPU Socket Populated
- 0 - CPU Socket Unpopulated
-Bits 5:3 Reserved, must be zero
-Bits 2:0 CPU Status
- 0h - Unknown
- 1h - CPU Enabled
- 2h - CPU Disabled by User via BIOS Setup
- 3h - CPU Disabled By BIOS (POST Error)
- 4h - CPU is Idle, waiting to be enabled.
- 5-6h - Reserved
- 7h - Other
-
- @param[in] Option The option
-**/
-VOID
-DisplayProcessorStatus (
- IN UINT8 Status,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROC_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
-
- if (BIT (Status, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT7_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (Status, 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT5_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (Status, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT4_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (Status, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT3_NOT_ZERO), gShellDebug1HiiHandle);
- }
- //
- // Check BIT 6
- //
- if (BIT (Status, 6) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_SOCKET_POPULATED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_SOCKET_UNPOPULATED), gShellDebug1HiiHandle);
- }
- //
- // Check BITs 2:0
- //
- switch (Status & 0x07) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_ENABLED), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_DISABLED_BY_USER), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_DIABLED_BY_BIOS), gShellDebug1HiiHandle);
- break;
-
- case 4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CPU_IDLE), gShellDebug1HiiHandle);
- break;
-
- case 7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHERS), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display information about Memory Controller Information (Type 5).
-
- @param[in] Size Memory size.
- @param[in] SlotNum Which slot is this about.
- @param[in] Option Option for the level of detail output required.
-**/
-VOID
-DisplayMaxMemoryModuleSize (
- IN UINT8 Size,
- IN UINT8 SlotNum,
- IN UINT8 Option
- )
-{
- UINTN MaxSize;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE_LARGEST_MEM), gShellDebug1HiiHandle);
- //
- // MaxSize is determined by follow formula
- //
- MaxSize = (UINTN) 1 << Size;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), gShellDebug1HiiHandle, MaxSize);
-
- if (Option >= SHOW_DETAIL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MAX_AMOUNT_MEM), gShellDebug1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), gShellDebug1HiiHandle, MaxSize, SlotNum, MaxSize * SlotNum);
- }
-}
-
-/**
- Display information about memory configuration handles.
-
- @param[in] Handles The buffer of handles to output info on.
- @param[in] SlotNum The number of handles in the above buffer.
- @param[in] Option Option for the level of detail output required.
-**/
-VOID
-DisplayMemoryModuleConfigHandles (
- IN UINT16 *Handles,
- IN UINT8 SlotNum,
- IN UINT8 Option
- )
-{
- UINT8 Index;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLES_CONTROLLED), gShellDebug1HiiHandle, SlotNum);
-
- if (Option >= SHOW_DETAIL) {
- //
- // No handle, Handles is INVALID.
- //
- if (SlotNum == 0) {
- return ;
- }
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLES_LIST_CONTROLLED), gShellDebug1HiiHandle);
- for (Index = 0; Index < SlotNum; Index++) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HANDLE), gShellDebug1HiiHandle, Index + 1, Handles[Index]);
- }
- }
-}
-
-/**
- Display Memory Module Information (Type 6).
-
- @param[in] BankConnections
- @param[in] Option
-**/
-VOID
-DisplayMmBankConnections (
- IN UINT8 BankConnections,
- IN UINT8 Option
- )
-{
- UINT8 High;
- UINT8 Low;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_CONNECTIONS), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (BankConnections, Option);
-
- //
- // Divide it to high and low
- //
- High = (UINT8) (BankConnections & 0xF0);
- Low = (UINT8) (BankConnections & 0x0F);
- if (High != 0xF) {
- if (Low != 0xF) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS), gShellDebug1HiiHandle, High, Low, High, Low);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS_2), gShellDebug1HiiHandle, High, High);
- }
- } else {
- if (Low != 0xF) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BANK_RAS_2), gShellDebug1HiiHandle, Low, Low);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_BANKS_CONNECTED), gShellDebug1HiiHandle);
- }
- }
-}
-
-/**
- Display memory informcation.
-
- Bits 0:6 Size (n),
- where 2**n is the size in MB with three special-case values:
- 7Dh Not determinable (Installed Size only)
- 7Eh Module is installed, but no memory has been enabled
- 7Fh Not installed
- Bit 7 Defines whether the memory module has a single- (0)
- or double-bank (1) connection.
-
- @param[in] Size - The size
- @param[in] Option - The option
-**/
-VOID
-DisplayMmMemorySize (
- IN UINT8 Size,
- IN UINT8 Option
- )
-{
- UINT8 Value;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEMORY_SIZE), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (Size, Option);
-
- //
- // Get the low bits(0-6 bit)
- //
- Value = (UINT8) (Size & 0x7F);
- if (Value == 0x7D) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_SIZE_NOT_DETERMINABLE), gShellDebug1HiiHandle);
- } else if (Value == 0x7E) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MODULE_INSTALLED), gShellDebug1HiiHandle);
- } else if (Value == 0x7F) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_INSTALLED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_SIZE), gShellDebug1HiiHandle, 1 << Value);
- }
-
- if (BIT (Size, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_MODULE_DOUBLE_BANK), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MEM_MODULE_SINGLE_BANK), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display Cache Configuration.
-
- @param[in] CacheConfiguration Cache Configuration.
-Bits 15:10 Reserved, must be 0
-Bits 9:8 Operational Mode
- 0h - Write Through
- 1h - Write Back
- 2h - Varies with Memory Address
- 3h - Unknown
-Bit 7 Enabled/Disabled
- 1 - Enabled
- 0 - Disabled
-Bits 6:5 Location
- 0h - Internal
- 1h - External
- 2h - Reserved
- 3h - Unknown
-Bit 4 Reserved, must be zero
-Bit 3 Cache Socketed
- 1 - Socketed
- 0 - Unsocketed
-Bits 2:0 Cache Level
- 1 through 8 (For example, an L1 cache would
- use value 000b and an L3 cache would use 010b.)
-
- @param[in] Option The option
-**/
-VOID
-DisplayCacheConfiguration (
- IN UINT16 CacheConfiguration,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_CONFIGURATION), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (CacheConfiguration, Option);
-
- if (BIT (CacheConfiguration, 15) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT15_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 14) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT14_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 13) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT13_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 12) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT12_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 11) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT11_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 10) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT10_NOT_ZERO), gShellDebug1HiiHandle);
- } else if (BIT (CacheConfiguration, 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIT4_NOT_ZERO), gShellDebug1HiiHandle);
- }
-
- //
- // Check BITs 9:8
- //
- switch ((CacheConfiguration & 0x300) >> 8) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_WRITE_THROUGH), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_WRITE_BACK), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_VARIES_WITH_MEM_ADDR), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
-
- //
- // Check BIT 7
- //
- if (BIT (CacheConfiguration, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle);
- }
-
- //
- // Check BITs 6:5
- //
- switch ((CacheConfiguration & 0x60) >> 5) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_INTERNAL), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_EXTERNAL), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
-
- //
- // Check BIT 3
- //
- if (BIT (CacheConfiguration, 3) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_SOCKETED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_NOT_SOCKETED), gShellDebug1HiiHandle);
- }
-
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CACHE_LEVEL), gShellDebug1HiiHandle, (CacheConfiguration & 0x07) + 1);
-}
-
-/**
- The Slot ID field of the System Slot structure provides a mechanism to
- correlate the physical attributes of the slot to its logical access method
- (which varies based on the Slot Type field).
-
- @param[in] SlotId - The slot ID
- @param[in] SlotType - The slot type
- @param[in] Option - The Option
-**/
-VOID
-DisplaySystemSlotId (
- IN UINT16 SlotId,
- IN UINT8 SlotType,
- IN UINT8 Option
- )
-{
- //
- // Display slot type first
- //
- DisplaySystemSlotType (SlotType, Option);
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SLOT_ID), gShellDebug1HiiHandle);
- //
- // print option
- //
- PRINT_INFO_OPTION (SlotType, Option);
-
- switch (SlotType) {
- //
- // Slot Type: MCA
- //
- case 0x04:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LOGICAL_MICRO_CHAN), gShellDebug1HiiHandle);
- if (SlotId > 0 && SlotId < 15) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_D), gShellDebug1HiiHandle, SlotId);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_NOT_1_15), gShellDebug1HiiHandle);
- }
- break;
-
- //
- // EISA
- //
- case 0x05:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LOGICAL_EISA_NUM), gShellDebug1HiiHandle);
- if (SlotId > 0 && SlotId < 15) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_D), gShellDebug1HiiHandle, SlotId);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_NOT_1_15), gShellDebug1HiiHandle);
- }
- break;
-
- //
- // Slot Type: PCI
- //
- case 0x06:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId);
- break;
-
- //
- // PCMCIA
- //
- case 0x07:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_IDENTIFIES_ADAPTER_NUM), gShellDebug1HiiHandle, SlotId);
- break;
-
- //
- // Slot Type: PCI-E
- //
- case 0xA5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId);
- break;
-
- default:
- if ((SlotType >= 0x0E && SlotType <= 0x12) || (SlotType >= 0xA6 && SlotType <= 0xB6)){
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VALUE_PRESENT), gShellDebug1HiiHandle, SlotId);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_SLOT_ID), gShellDebug1HiiHandle);
- }
- }
-}
-
-/**
- Display System Boot Information (Type 32) information.
-
- @param[in] Parameter The parameter.
- @param[in] Option The options.
-**/
-VOID
-DisplaySystemBootStatus (
- IN UINT8 Parameter,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_BOOT_STATUS), gShellDebug1HiiHandle);
- //
- // Print option
- //
- PRINT_INFO_OPTION (Parameter, Option);
-
- //
- // Check value and print
- //
- if (Parameter == 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_ERRORS_DETECTED), gShellDebug1HiiHandle);
- } else if (Parameter == 1) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NO_BOOTABLE_MEDIA), gShellDebug1HiiHandle);
- } else if (Parameter == 2) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NORMAL_OP_SYSTEM), gShellDebug1HiiHandle);
- } else if (Parameter == 3) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FIRMWARE_DETECTED), gShellDebug1HiiHandle);
- } else if (Parameter == 4) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM), gShellDebug1HiiHandle);
- } else if (Parameter == 5) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_USER_REQUESTED_BOOT), gShellDebug1HiiHandle);
- } else if (Parameter == 6) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_SECURITY_VIOLATION), gShellDebug1HiiHandle);
- } else if (Parameter == 7) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PREV_REQ_IMAGE), gShellDebug1HiiHandle);
- } else if (Parameter == 8) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WATCHDOG_TIMER), gShellDebug1HiiHandle);
- } else if (Parameter >= 9 && Parameter <= 127) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FUTURE_ASSIGNMENT), gShellDebug1HiiHandle);
- } else if (Parameter >= 128 && Parameter <= 191) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_VENDOR_OEM_SPECIFIC), gShellDebug1HiiHandle);
- } else if (Parameter >= 192) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PRODUCT_SPEC_IMPLMENTATION), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ERROR_VALUE), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display Portable Battery (Type 22) information.
-
- The date the cell pack was manufactured, in packed format:
- Bits 15:9 Year, biased by 1980, in the range 0 to 127.
- Bits 8:5 Month, in the range 1 to 12.
- Bits 4:0 Date, in the range 1 to 31.
- For example, 01 February 2000 would be identified as
- 0010 1000 0100 0001b (0x2841).
-
- @param[in] Date The date
- @param[in] Option The option
-**/
-VOID
-DisplaySBDSManufactureDate (
- IN UINT16 Date,
- IN UINT8 Option
- )
-{
- UINTN Day;
- UINTN Month;
- UINTN Year;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SBDS_MANUFACTURE_DATE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Date, Option);
- //
- // Print date
- //
- Day = Date & 0x001F;
- Month = (Date & 0x01E0) >> 5;
- Year = ((Date & 0xFE00) >> 9) + 1980;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MONTH_DAY_YEAR), gShellDebug1HiiHandle, Day, Month, Year);
-
-}
-
-/**
- Display System Reset (Type 23) information.
-
-
-Identifies the system-reset capabilities for the system.
- Bits 7:6 Reserved for future assignment via this specification, set to 00b.
- Bit 5 System contains a watchdog timer, either True (1) or False (0).
- Bits 4:3 Boot Option on Limit.
- Identifies the system action to be taken when the Reset Limit is reached, one of:
- 00b Reserved, do not use.
- 01b Operating system
- 10b System utilities
- 11b Do not rebootBits
- 2:1 Boot Option. Indicates the action to be taken following a watchdog reset, one of:
- 00b Reserved, do not use.
- 01b Operating system
- 10b System utilities
- 11b Do not reboot
- Bit 0 Status.
- 1b The system reset is enabled by the user
- 0b The system reset is not enabled by the user
-
- @param[in] Reset Reset
- @param[in] Option The option
-**/
-VOID
-DisplaySystemResetCapabilities (
- IN UINT8 Reset,
- IN UINT8 Option
- )
-{
- UINTN Temp;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_RESET_CAPABILITIES), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Reset, Option);
-
- //
- // Check reserved bits 7:6
- //
- if ((Reset & 0xC0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RESERVED_ZERO), gShellDebug1HiiHandle);
- }
- //
- // Watch dog
- //
- if (BIT (Reset, 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WATCHDOG_TIMER_2), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_NOT_CONTAIN_TIMER), gShellDebug1HiiHandle);
- }
- //
- // Boot Option on Limit
- //
- Temp = (Reset & 0x18) >> 3;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_OPTION_LIMIT), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM_2), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_UTIL), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DO_NOT_REBOOT_BITS), gShellDebug1HiiHandle);
- break;
- }
- //
- // Boot Option
- //
- Temp = (Reset & 0x06) >> 1;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BOOT_OPTION), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OP_SYSTEM_2), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SYSTEM_UTIL), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DO_NOT_REBOOT), gShellDebug1HiiHandle);
- break;
- }
- //
- // Reset enable flag
- //
- if ((Reset & 0x01) != 0) {
- Print (L"The system reset is enabled by the user\n");
- } else {
- Print (L"The system reset is disabled by the user\n");
- }
-}
-
-/**
- Display Hardware Security (Type 24) information.
-
-
-Identifies the password and reset status for the system:
-
-Bits 7:6 Power-on Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
-Bits 5:4 Keyboard Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
-Bits 3:2 Administrator Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
-Bits 1:0 Front Panel Reset Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
-
- @param[in] Settings The device settings.
- @param[in] Option The device options.
-**/
-VOID
-DisplayHardwareSecuritySettings (
- IN UINT8 Settings,
- IN UINT8 Option
- )
-{
- UINTN Temp;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HARDWARE_SECURITY_SET), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Settings, Option);
-
- //
- // Power-on Password Status
- //
- Temp = (Settings & 0xC0) >> 6;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_ON_PASSWORD), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
- //
- // Keyboard Password Status
- //
- Temp = (Settings & 0x30) >> 4;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_KEYBOARD_PASSWORD), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
- //
- // Administrator Password Status
- //
- Temp = (Settings & 0x0C) >> 2;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ADMIN_PASSWORD_STATUS), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
- //
- // Front Panel Reset Status
- //
- Temp = Settings & 0x3;
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_FRONT_PANEL_RESET), gShellDebug1HiiHandle);
- switch (Temp) {
- case 0:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DISABLED), gShellDebug1HiiHandle);
- break;
-
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENABLED_NEWLINE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_IMPLEMENTED), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
- }
-}
-
-/**
- Display Out-of-Band Remote Access (Type 30) information.
-
- @param[in] Connections The device characteristics.
- @param[in] Option The device options.
-**/
-VOID
-DisplayOBRAConnections (
- IN UINT8 Connections,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CONNECTIONS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Connections, Option);
-
- //
- // Check reserved bits 7:2
- //
- if ((Connections & 0xFC) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_RESERVED_ZERO_2), gShellDebug1HiiHandle);
- }
- //
- // Outbound Connection
- //
- if (BIT (Connections, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OUTBOUND_CONN_ENABLED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTUBOUND_CONN_DISABLED), gShellDebug1HiiHandle);
- }
- //
- // Inbound Connection
- //
- if (BIT (Connections, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INBOIUND_CONN_ENABLED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INBOUND_CONN_DISABLED), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display System Power Supply (Type 39) information.
-
- @param[in] Characteristics The device characteristics.
- @param[in] Option The device options.
-**/
-VOID
-DisplaySPSCharacteristics (
- IN UINT16 Characteristics,
- IN UINT8 Option
- )
-{
- UINTN Temp;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_CHAR), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Characteristics, Option);
-
- //
- // Check reserved bits 15:14
- //
- if ((Characteristics & 0xC000) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BITS_15_14_RSVD), gShellDebug1HiiHandle);
- }
- //
- // Bits 13:10 - DMTF Power Supply Type
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_TYPE), gShellDebug1HiiHandle);
- Temp = (Characteristics & 0x1C00) << 10;
- switch (Temp) {
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_LINEAR), gShellDebug1HiiHandle);
- break;
-
- case 4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SWITCHING), gShellDebug1HiiHandle);
- break;
-
- case 5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BATTERY), gShellDebug1HiiHandle);
- break;
-
- case 6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UPS), gShellDebug1HiiHandle);
- break;
-
- case 7:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CONVERTER), gShellDebug1HiiHandle);
- break;
-
- case 8:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_REGULATOR), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_2), gShellDebug1HiiHandle);
- }
- //
- // Bits 9:7 - Status
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_STATUS_DASH), gShellDebug1HiiHandle);
- Temp = (Characteristics & 0x380) << 7;
- switch (Temp) {
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OK), gShellDebug1HiiHandle);
- break;
-
- case 4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NON_CRITICAL), gShellDebug1HiiHandle);
- break;
-
- case 5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_CRITICAL_POWER_SUPPLY), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED), gShellDebug1HiiHandle);
- }
- //
- // Bits 6:3 - DMTF Input Voltage Range Switching
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INPUT_VOLTAGE_RANGE), gShellDebug1HiiHandle);
- Temp = (Characteristics & 0x78) << 3;
- switch (Temp) {
- case 1:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_OTHER_SPACE), gShellDebug1HiiHandle);
- break;
-
- case 2:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNKNOWN), gShellDebug1HiiHandle);
- break;
-
- case 3:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MANUAL), gShellDebug1HiiHandle);
- break;
-
- case 4:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_AUTO_SWITCH), gShellDebug1HiiHandle);
- break;
-
- case 5:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WIDE_RANGE), gShellDebug1HiiHandle);
- break;
-
- case 6:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_NOT_APPLICABLE), gShellDebug1HiiHandle);
- break;
-
- default:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RESERVED_3), gShellDebug1HiiHandle);
- break;
- }
- //
- // Power supply is unplugged from the wall
- //
- if (BIT (Characteristics, 2) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_UNPLUGGED), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_PLUGGED), gShellDebug1HiiHandle);
- }
- //
- // Power supply is present
- //
- if (BIT (Characteristics, 1) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_PRESENT), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_NOT_PRESENT), gShellDebug1HiiHandle);
- }
- //
- // hot replaceable
- //
- if (BIT (Characteristics, 0) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_REPLACE), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_SUPPLY_NOT_REPLACE), gShellDebug1HiiHandle);
- }
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h
deleted file mode 100644
index 50667b684c..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.h
+++ /dev/null
@@ -1,423 +0,0 @@
-/** @file
- Module to clarify the element info of the smbios structure.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _SMBIOS_PRINT_INFO_H_
-#define _SMBIOS_PRINT_INFO_H_
-
-#include <IndustryStandard/SmBios.h>
-
-extern UINT8 SmbiosMajorVersion;
-extern UINT8 SmbiosMinorVersion;
-
-#define SHOW_NONE 0x00
-#define SHOW_OUTLINE 0x01
-#define SHOW_NORMAL 0x02
-#define SHOW_DETAIL 0x03
-//
-// SHOW_ALL: WaitEnter() not wait input.
-//
-#define SHOW_ALL 0x04
-#define SHOW_STATISTICS 0x05
-
-#define AS_UINT16(pData) (*((UINT16 *) pData))
-#define AS_UINT32(pData) (*((UINT32 *) pData))
-#define AS_UINT64(pData) (*((UINT64 *) pData))
-
-/**
- Print the info of EPS(Entry Point Structure).
-
- @param[in] SmbiosTable Pointer to the SMBIOS table entry point.
- @param[in] Option Display option.
-**/
-VOID
-SmbiosPrintEPSInfo (
- IN SMBIOS_TABLE_ENTRY_POINT *SmbiosTable,
- IN UINT8 Option
- );
-
-/**
- Print the info of 64-bit EPS(Entry Point Structure).
-
- @param[in] SmbiosTable Pointer to the SMBIOS table entry point.
- @param[in] Option Display option.
-**/
-VOID
-Smbios64BitPrintEPSInfo (
- IN SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable,
- IN UINT8 Option
- );
-
-/**
- This function print the content of the structure pointed by Struct.
-
- @param[in] Struct Point to the structure to be printed.
- @param[in] Option Print option of information detail.
-
- @retval EFI_SUCCESS Successfully Printing this function.
- @retval EFI_INVALID_PARAMETER Invalid Structure.
- @retval EFI_UNSUPPORTED Unsupported.
-**/
-EFI_STATUS
-SmbiosPrintStructure (
- IN SMBIOS_STRUCTURE_POINTER *Struct,
- IN UINT8 Option
- );
-
-/**
- Display BIOS Information (Type 0) information.
-
- @param[in] Chara The information bits.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristics (
- IN UINT64 Chara,
- IN UINT8 Option
- );
-
-/**
- Display Bios Characteristice extensions1 information.
-
- @param[in] Byte1 The information.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristicsExt1 (
- IN UINT8 Byte1,
- IN UINT8 Option
- );
-
-/**
- Display Bios Characteristice extensions2 information.
-
- @param[in] Byte2 The information.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBiosCharacteristicsExt2 (
- IN UINT8 Byte2,
- IN UINT8 Option
- );
-
-/**
- Display Processor Information (Type 4) information.
-
- @param[in] Family The family value.
- @param[in] Option The option value.
-**/
-VOID
-DisplayProcessorFamily (
- UINT8 Family,
- UINT8 Option
- );
-
-/**
- Display processor family information.
-
- @param[in] Family2 The family value.
- @param[in] Option The option value.
-**/
-VOID
-DisplayProcessorFamily2 (
- IN UINT16 Family2,
- IN UINT8 Option
- );
-
-/**
- Display processor voltage information.
-
- @param[in] Voltage The Voltage.
- Bit 7 Set to 0, indicating 'legacy' mode for processor voltage
- Bits 6:4 Reserved, must be zero
- Bits 3:0 Voltage Capability.
- A Set bit indicates that the voltage is supported.
- Bit 0 - 5V
- Bit 1 - 3.3V
- Bit 2 - 2.9V
- Bit 3 - Reserved, must be zero.
-
- Note:
- Setting of multiple bits indicates the socket is configurable
- If bit 7 is set to 1, the remaining seven bits of the field are set to
- contain the processor's current voltage times 10.
- For example, the field value for a processor voltage of 1.8 volts would be
- 92h = 80h + (1.8 * 10) = 80h + 18 = 80h +12h.
-
- @param[in] Option The option.
-**/
-VOID
-DisplayProcessorVoltage (
- IN UINT8 Voltage,
- IN UINT8 Option
- );
-
-/**
- Display processor information.
-
- @param[in] Status The status.
-Bit 7 Reserved, must be 0
-Bit 6 CPU Socket Populated
- 1 - CPU Socket Populated
- 0 - CPU Socket Unpopulated
-Bits 5:3 Reserved, must be zero
-Bits 2:0 CPU Status
- 0h - Unknown
- 1h - CPU Enabled
- 2h - CPU Disabled by User via BIOS Setup
- 3h - CPU Disabled By BIOS (POST Error)
- 4h - CPU is Idle, waiting to be enabled.
- 5-6h - Reserved
- 7h - Other
-
- @param[in] Option The option
-**/
-VOID
-DisplayProcessorStatus (
- IN UINT8 Status,
- IN UINT8 Option
- );
-
-/**
- Display information about Memory Controller Information (Type 5).
-
- @param[in] Size Memory size.
- @param[in] SlotNum Which slot is this about.
- @param[in] Option Option for the level of detail output required.
-**/
-VOID
-DisplayMaxMemoryModuleSize (
- IN UINT8 Size,
- IN UINT8 SlotNum,
- IN UINT8 Option
- );
-
-/**
- Display information about memory configuration handles.
-
- @param[in] Handles The buffer of handles to output info on.
- @param[in] SlotNum The number of handles in the above buffer.
- @param[in] Option Option for the level of detail output required.
-**/
-VOID
-DisplayMemoryModuleConfigHandles (
- IN UINT16 *Handles,
- IN UINT8 SlotNum,
- IN UINT8 Option
- );
-
-/**
- Display Memory Module Information (Type 6).
-
- @param[in] BankConnections
- @param[in] Option
-**/
-VOID
-DisplayMmBankConnections (
- IN UINT8 BankConnections,
- IN UINT8 Option
- );
-
-/**
- Display memory informcation.
-
- Bits 0:6 Size (n),
- where 2**n is the size in MB with three special-case values:
- 7Dh Not determinable (Installed Size only)
- 7Eh Module is installed, but no memory has been enabled
- 7Fh Not installed
- Bit 7 Defines whether the memory module has a single- (0)
- or double-bank (1) connection.
-
- @param[in] Size - The size
- @param[in] Option - The option
-**/
-VOID
-DisplayMmMemorySize (
- IN UINT8 Size,
- IN UINT8 Option
- );
-
-/**
- Display Cache Configuration.
-
- @param[in] CacheConfiguration Cache Configuration.
-Bits 15:10 Reserved, must be 0
-Bits 9:8 Operational Mode
- 0h - Write Through
- 1h - Write Back
- 2h - Varies with Memory Address
- 3h - Unknown
-Bit 7 Enabled/Disabled
- 1 - Enabled
- 0 - Disabled
-Bits 6:5 Location
- 0h - Internal
- 1h - External
- 2h - Reserved
- 3h - Unknown
-Bit 4 Reserved, must be zero
-Bit 3 Cache Socketed
- 1 - Socketed
- 0 - Unsocketed
-Bits 2:0 Cache Level
- 1 through 8 (For example, an L1 cache would
- use value 000b and an L3 cache would use 010b.)
-
- @param[in] Option The option
-**/
-VOID
-DisplayCacheConfiguration (
- IN UINT16 CacheConfiguration,
- IN UINT8 Option
- );
-
-/**
- The Slot ID field of the System Slot structure provides a mechanism to
- correlate the physical attributes of the slot to its logical access method
- (which varies based on the Slot Type field).
-
- @param[in] SlotId - The slot ID
- @param[in] SlotType - The slot type
- @param[in] Option - The Option
-**/
-VOID
-DisplaySystemSlotId (
- IN UINT16 SlotId,
- IN UINT8 SlotType,
- IN UINT8 Option
- );
-
-/**
- Display Portable Battery (Type 22) information.
-
- The date the cell pack was manufactured, in packed format:
- Bits 15:9 Year, biased by 1980, in the range 0 to 127.
- Bits 8:5 Month, in the range 1 to 12.
- Bits 4:0 Date, in the range 1 to 31.
- For example, 01 February 2000 would be identified as
- 0010 1000 0100 0001b (0x2841).
-
- @param[in] Date The date
- @param[in] Option The option
-**/
-VOID
-DisplaySBDSManufactureDate (
- IN UINT16 Date,
- IN UINT8 Option
- );
-
-/**
- Display System Reset (Type 23) information.
-
- Routine Description:
- Identifies the system-reset capabilities for the system.
- Bits 7:6 Reserved for future assignment via this specification, set to 00b.
- Bit 5 System contains a watchdog timer, either True (1) or False (0).
- Bits 4:3 Boot Option on Limit.
- Identifies the system action to be taken when the Reset Limit is reached, one of:
- 00b Reserved, do not use.
- 01b Operating system
- 10b System utilities
- 11b Do not rebootBits
- 2:1 Boot Option. Indicates the action to be taken following a watchdog reset, one of:
- 00b Reserved, do not use.
- 01b Operating system
- 10b System utilities
- 11b Do not reboot
- Bit 0 Status.
- 1b The system reset is enabled by the user
- 0b The system reset is not enabled by the user
-
- @param[in] Reset Reset
- @param[in] Option The option
-**/
-VOID
-DisplaySystemResetCapabilities (
- IN UINT8 Reset,
- IN UINT8 Option
- );
-
-/**
- Display Hardware Security (Type 24) information.
-
- Routine Description:
- Identifies the password and reset status for the system:
-
- Bits 7:6 Power-on Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
- Bits 5:4 Keyboard Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
- Bits 3:2 Administrator Password Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
- Bits 1:0 Front Panel Reset Status, one of:
- 00b Disabled
- 01b Enabled
- 10b Not Implemented
- 11b Unknown
-
- @param[in] Settings The device settings.
- @param[in] Option The device options.
-**/
-VOID
-DisplayHardwareSecuritySettings (
- IN UINT8 Settings,
- IN UINT8 Option
- );
-
-/**
- Display Out-of-Band Remote Access (Type 30) information.
-
- @param[in] Connections The device characteristics.
- @param[in] Option The device options.
-**/
-VOID
-DisplayOBRAConnections (
- IN UINT8 Connections,
- IN UINT8 Option
- );
-
-/**
- Display System Boot Information (Type 32) information.
-
- @param[in] Parameter The parameter.
- @param[in] Option The options.
-**/
-VOID
-DisplaySystemBootStatus (
- IN UINT8 Parameter,
- IN UINT8 Option
- );
-
-/**
- Display System Power Supply (Type 39) information.
-
- @param[in] Characteristics The device characteristics.
- @param[in] Option The device options.
-**/
-VOID
-DisplaySPSCharacteristics (
- IN UINT16 Characteristics,
- IN UINT8 Option
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
deleted file mode 100644
index 759f486a32..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ /dev/null
@@ -1,4380 +0,0 @@
-/** @file
- Build a table, each item is (Key, Info) pair.
- And give a interface of query a string out of a table.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "../UefiShellDebug1CommandsLib.h"
-#include "QueryTable.h"
-#include "PrintInfo.h"
-
-TABLE_ITEM SystemWakeupTypeTable[] = {
- {
- 0x0,
- L" Reserved"
- },
- {
- 0x1,
- L" Other"
- },
- {
- 0x2,
- L" Unknown"
- },
- {
- 0x3,
- L" APM Timer"
- },
- {
- 0x4,
- L" Modem Ring"
- },
- {
- 0x5,
- L" LAN Remote"
- },
- {
- 0x6,
- L" Power Switch"
- },
- {
- 0x7,
- L" AC Power Restored"
- }
-};
-
-TABLE_ITEM BaseBoardFeatureFlagsTable[] = {
- {
- 0,
- L" Hosting board"
- },
- {
- 1,
- L" Requires at least one daughter board or auxiliary card"
- },
- {
- 2,
- L" Removable"
- },
- {
- 3,
- L" Replaceable"
- },
- {
- 4,
- L" Hot swappable"
- }
-};
-
-TABLE_ITEM BaseBoardBoardTypeTable[] = {
- {
- 0x01,
- L" Unknown"
- },
- {
- 0x02,
- L" Other"
- },
- {
- 0x03,
- L" Server Blade"
- },
- {
- 0x04,
- L" Connectivity Switch"
- },
- {
- 0x05,
- L" System Management Module"
- },
- {
- 0x06,
- L" Processor Module"
- },
- {
- 0x07,
- L" I/O Module"
- },
- {
- 0x08,
- L" Memory Module"
- },
- {
- 0x09,
- L" Daughter board"
- },
- {
- 0x0A,
- L" Motherboard"
- },
- {
- 0x0B,
- L" Processor/Memory Module"
- },
- {
- 0x0C,
- L" Processor/IO Module"
- },
- {
- 0x0D,
- L" Interconnect Board"
- }
-};
-
-TABLE_ITEM SystemEnclosureTypeTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Desktop"
- },
- {
- 0x04,
- L" Low Profile Desktop"
- },
- {
- 0x05,
- L" Pizza Box"
- },
- {
- 0x06,
- L" Mini Tower"
- },
- {
- 0x07,
- L" Tower"
- },
- {
- 0x08,
- L" Portable"
- },
- {
- 0x09,
- L" LapTop"
- },
- {
- 0x0A,
- L" Notebook"
- },
- {
- 0x0B,
- L" Hand Held"
- },
- {
- 0x0C,
- L" Docking Station"
- },
- {
- 0x0D,
- L" All in One"
- },
- {
- 0x0E,
- L" Sub Notebook"
- },
- {
- 0x0F,
- L" Space-saving"
- },
- {
- 0x10,
- L" Main Server Chassis"
- },
- {
- 0x11,
- L" Expansion Chassis"
- },
- {
- 0x12,
- L" SubChassis"
- },
- {
- 0x13,
- L" Sub Notebook"
- },
- {
- 0x14,
- L" Bus Expansion Chassis"
- },
- {
- 0x15,
- L" Peripheral Chassis"
- },
- {
- 0x16,
- L" RAID Chassis"
- },
- {
- 0x17,
- L" Rack Mount Chassis"
- },
- {
- 0x18,
- L" Sealed-case PC"
- },
- {
- 0x19,
- L" Multi-system Chassis"
- },
- {
- 0x1A,
- L" CompactPCI"
- },
- {
- 0x1B,
- L" AdvancedTCA"
- },
- {
- 0x1C,
- L" Blade"
- },
- {
- 0x1D,
- L" Blade Enclosure"
- },
-};
-
-TABLE_ITEM SystemEnclosureStatusTable[] = {
- {
- 0x1,
- L" Other"
- },
- {
- 0x2,
- L" Unknown"
- },
- {
- 0x3,
- L" Safe"
- },
- {
- 0x4,
- L" Warning"
- },
- {
- 0x5,
- L" Critical"
- },
- {
- 0x6,
- L" Non-recoverable"
- }
-};
-
-TABLE_ITEM SESecurityStatusTable[] = {
- {
- 0x1,
- L" Other"
- },
- {
- 0x2,
- L" Unknown"
- },
- {
- 0x3,
- L" None"
- },
- {
- 0x4,
- L" External interface locked out"
- },
- {
- 0x5,
- L" External interface enabled"
- }
-};
-
-TABLE_ITEM ProcessorTypeTable[] = {
- {
- 0x1,
- L" Other"
- },
- {
- 0x2,
- L" Unknown"
- },
- {
- 0x3,
- L" Central Processor"
- },
- {
- 0x4,
- L" Math Processor"
- },
- {
- 0x5,
- L" DSP Processor"
- },
- {
- 0x6,
- L" Video Processor "
- },
-};
-
-TABLE_ITEM ProcessorUpgradeTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"Daughter Board"
- },
- {
- 0x04,
- L"ZIF Socket"
- },
- {
- 0x05,
- L"Replaceable Piggy Back"
- },
- {
- 0x06,
- L"None"
- },
- {
- 0x07,
- L"LIF Socket"
- },
- {
- 0x08,
- L"Slot 1"
- },
- {
- 0x09,
- L"Slot 2"
- },
- {
- 0x0A,
- L"370-pin socket"
- },
- {
- 0x0B,
- L"Slot A"
- },
- {
- 0x0C,
- L"Slot M"
- },
- {
- 0x0D,
- L"Socket 423"
- },
- {
- 0x0E,
- L"Socket A"
- },
- {
- 0x0F,
- L"Socket 478"
- },
- {
- 0x10,
- L"Socket 754"
- },
- {
- 0x11,
- L"Socket 940"
- },
- {
- 0x12,
- L"Socket 939"
- },
- {
- 0x13,
- L"Socket mPGA604"
- },
- {
- 0x14,
- L"Socket LGA771"
- },
- {
- 0x15,
- L"Socket LGA775"
- },
- {
- 0x16,
- L"Socket S1"
- },
- {
- 0x17,
- L"Socket AM2"
- },
- {
- 0x18,
- L"Socket F"
- },
- {
- 0x19,
- L"Socket LGA1366"
- },
- {
- 0x1A,
- L"Socket G34"
- },
- {
- 0x1B,
- L"Socket AM3"
- },
- {
- 0x1C,
- L"Socket C32"
- },
- {
- 0x1D,
- L"Socket LGA1156"
- },
- {
- 0x1E,
- L"Socket LGA1567"
- },
- {
- 0x1F,
- L"Socket PGA988A"
- },
- {
- 0x20,
- L"Socket BGA1288"
- },
- {
- 0x21,
- L"Socket rPGA988B"
- },
- {
- 0x22,
- L"Socket BGA1023"
- },
- {
- 0x23,
- L"Socket BGA1224"
- },
- {
- 0x24,
- L"Socket LGA1155"
- },
- {
- 0x25,
- L"Socket LGA1356"
- },
- {
- 0x26,
- L"Socket LGA2011"
- },
- {
- 0x27,
- L"Socket FS1"
- },
- {
- 0x28,
- L"Socket FS2"
- },
- {
- 0x29,
- L"Socket FM1"
- },
- {
- 0x2A,
- L"Socket FM2"
- },
- {
- 0x2B,
- L"Socket LGA2011-3"
- },
- {
- 0x2C,
- L"Socket LGA1356-3"
- }
-};
-
-TABLE_ITEM ProcessorCharacteristicsTable[] = {
- {
- 1,
- L" Unknown"
- },
- {
- 2,
- L" 64-bit Capable"
- },
- {
- 3,
- L" Multi-Core"
- },
- {
- 4,
- L" Hardware Thread"
- },
- {
- 5,
- L" Execute Protection"
- },
- {
- 6,
- L" Enhanced Virtualization"
- },
- {
- 7,
- L" Power/Performance Control"
- }
-};
-
-
-TABLE_ITEM McErrorDetectMethodTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"None"
- },
- {
- 0x04,
- L"8-bit Parity"
- },
- {
- 0x05,
- L"32-bit ECC"
- },
- {
- 0x06,
- L"64-bit ECC"
- },
- {
- 0x07,
- L"128-bit ECC"
- },
- {
- 0x08,
- L"CRC"
- },
-};
-
-TABLE_ITEM McErrorCorrectCapabilityTable[] = {
- {
- 0,
- L"Other"
- },
- {
- 1,
- L"Unknown"
- },
- {
- 2,
- L"None"
- },
- {
- 3,
- L"Single Bit Error Correcting"
- },
- {
- 4,
- L"Double Bit Error Correcting"
- },
- {
- 5,
- L"Error Scrubbing"
- },
-};
-
-TABLE_ITEM McInterleaveSupportTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"One Way Interleave"
- },
- {
- 0x04,
- L"Two Way Interleave"
- },
- {
- 0x05,
- L"Four Way Interleave"
- },
- {
- 0x06,
- L"Eight Way Interleave"
- },
- {
- 0x07,
- L"Sixteen Way Interleave"
- }
-};
-
-TABLE_ITEM McMemorySpeedsTable[] = {
- {
- 0,
- L" Other"
- },
- {
- 1,
- L" Unknown"
- },
- {
- 2,
- L" 70ns"
- },
- {
- 3,
- L" 60ns"
- },
- {
- 4,
- L" 50ns"
- },
-};
-
-TABLE_ITEM MemoryModuleVoltageTable[] = {
- {
- 0,
- L" 5V"
- },
- {
- 1,
- L" 3.3V"
- },
- {
- 2,
- L" 2.9V"
- },
-};
-
-TABLE_ITEM MmMemoryTypeTable[] = {
- {
- 0,
- L" Other"
- },
- {
- 1,
- L" Unknown"
- },
- {
- 2,
- L" Standard"
- },
- {
- 3,
- L" Fast Page Mode"
- },
- {
- 4,
- L" EDO"
- },
- {
- 5,
- L" Parity"
- },
- {
- 6,
- L" ECC "
- },
- {
- 7,
- L" SIMM"
- },
- {
- 8,
- L" DIMM"
- },
- {
- 9,
- L" Burst EDO"
- },
- {
- 10,
- L" SDRAM"
- }
-};
-
-TABLE_ITEM MmErrorStatusTable[] = {
- {
- 0,
- L" Uncorrectable errors received"
- },
- {
- 1,
- L" Correctable errors received"
- },
- {
- 2,
- L" Error Status obtained from the event log"
- }
-};
-
-TABLE_ITEM CacheSRAMTypeTable[] = {
- {
- 0,
- L" Other"
- },
- {
- 1,
- L" Unknown"
- },
- {
- 2,
- L" Non-Burst"
- },
- {
- 3,
- L" Burst"
- },
- {
- 4,
- L" Pipeline Burst"
- },
- {
- 5,
- L" Synchronous"
- },
- {
- 6,
- L" Asynchronous"
- },
-};
-
-TABLE_ITEM CacheErrCorrectingTypeTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"None"
- },
- {
- 0x04,
- L"Parity"
- },
- {
- 0x05,
- L"Single-bit ECC"
- },
- {
- 0x06,
- L"Multi-bit ECC"
- }
-};
-
-TABLE_ITEM CacheSystemCacheTypeTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"Instruction"
- },
- {
- 0x04,
- L"Data"
- },
- {
- 0x05,
- L"Unified"
- }
-};
-
-TABLE_ITEM CacheAssociativityTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"Direct Mapped"
- },
- {
- 0x04,
- L"2-way Set-Associative"
- },
- {
- 0x05,
- L"4-way Set-Associative"
- },
- {
- 0x06,
- L"Fully Associative"
- },
- {
- 0x07,
- L"8-way Set-Associative"
- },
- {
- 0x08,
- L"16-way Set-Associative"
- },
- {
- 0x09,
- L"12-way Set-Associative"
- },
- {
- 0x0A,
- L"24-way Set-Associative"
- },
- {
- 0x0B,
- L"32-way Set-Associative"
- },
- {
- 0x0C,
- L"48-way Set-Associative"
- },
- {
- 0x0D,
- L"64-way Set-Associative"
- },
- {
- 0x0E,
- L"20-way Set-Associative"
- }
-};
-
-TABLE_ITEM PortConnectorTypeTable[] = {
- {
- 0x00,
- L"None"
- },
- {
- 0x01,
- L"Centronics"
- },
- {
- 0x02,
- L"Mini Centronics"
- },
- {
- 0x03,
- L"Proprietary"
- },
- {
- 0x04,
- L"DB-25 pin male"
- },
- {
- 0x05,
- L"DB-25 pin female"
- },
- {
- 0x06,
- L"DB-15 pin male"
- },
- {
- 0x07,
- L"DB-15 pin female"
- },
- {
- 0x08,
- L"DB-9 pin male"
- },
- {
- 0x09,
- L"DB-9 pin female"
- },
- {
- 0x0A,
- L"RJ-11"
- },
- {
- 0x0B,
- L"RJ-45"
- },
- {
- 0x0C,
- L"50 Pin MiniSCSI"
- },
- {
- 0x0D,
- L"Mini-DIN"
- },
- {
- 0x0E,
- L"Micro-DIN"
- },
- {
- 0x0F,
- L"PS/2"
- },
- {
- 0x10,
- L"Infrared"
- },
- {
- 0x11,
- L"HP-HIL"
- },
- {
- 0x12,
- L"Access Bus (USB)"
- },
- {
- 0x13,
- L"SSA SCSI"
- },
- {
- 0x14,
- L"Circular DIN-8 male"
- },
- {
- 0x15,
- L"Circular DIN-8 female"
- },
- {
- 0x16,
- L"On Board IDE"
- },
- {
- 0x17,
- L"On Board Floppy"
- },
- {
- 0x18,
- L"9 Pin Dual Inline (pin 10 cut)"
- },
- {
- 0x19,
- L"25 Pin Dual Inline (pin 26 cut)"
- },
- {
- 0x1A,
- L"50 Pin Dual Inline"
- },
- {
- 0x1B,
- L"68 Pin Dual Inline"
- },
- {
- 0x1C,
- L"On Board Sound Input from CD-ROM"
- },
- {
- 0x1D,
- L"Mini-Centronics Type-14"
- },
- {
- 0x1E,
- L"Mini-Centronics Type-26"
- },
- {
- 0x1F,
- L"Mini-jack (headphones)"
- },
- {
- 0x20,
- L"BNC"
- },
- {
- 0x21,
- L"1394"
- },
- {
- 0x22,
- L"SAS/SATA Plug Receptacle"
- },
- {
- 0xA0,
- L"PC-98"
- },
- {
- 0xA1,
- L"PC-98Hireso"
- },
- {
- 0xA2,
- L"PC-H98"
- },
- {
- 0xA3,
- L"PC-98Note"
- },
- {
- 0xA4,
- L"PC-98Full"
- },
- {
- 0xFF,
- L"Other"
- },
-};
-
-TABLE_ITEM PortTypeTable[] = {
- {
- 0x00,
- L"None"
- },
- {
- 0x01,
- L"Parallel Port XT/AT Compatible"
- },
- {
- 0x02,
- L"Parallel Port PS/2"
- },
- {
- 0x03,
- L"Parallel Port ECP"
- },
- {
- 0x04,
- L"Parallel Port EPP"
- },
- {
- 0x05,
- L"Parallel Port ECP/EPP"
- },
- {
- 0x06,
- L"Serial Port XT/AT Compatible"
- },
- {
- 0x07,
- L"Serial Port 16450 Compatible"
- },
- {
- 0x08,
- L"Serial Port 16550 Compatible"
- },
- {
- 0x09,
- L"Serial Port 16550A Compatible"
- },
- {
- 0x0A,
- L"SCSI Port"
- },
- {
- 0x0B,
- L"MIDI Port"
- },
- {
- 0x0C,
- L"Joy Stick Port"
- },
- {
- 0x0D,
- L"Keyboard Port"
- },
- {
- 0x0E,
- L"Mouse Port"
- },
- {
- 0x0F,
- L"SSA SCSI"
- },
- {
- 0x10,
- L"USB"
- },
- {
- 0x11,
- L"FireWire (IEEE P1394)"
- },
- {
- 0x12,
- L"PCMCIA Type II"
- },
- {
- 0x13,
- L"PCMCIA Type II"
- },
- {
- 0x14,
- L"PCMCIA Type III"
- },
- {
- 0x15,
- L"Cardbus"
- },
- {
- 0x16,
- L"Access Bus Port"
- },
- {
- 0x17,
- L"SCSI II"
- },
- {
- 0x18,
- L"SCSI Wide"
- },
- {
- 0x19,
- L"PC-98"
- },
- {
- 0x1A,
- L"PC-98-Hireso"
- },
- {
- 0x1B,
- L"PC-H98"
- },
- {
- 0x1C,
- L"Video Port"
- },
- {
- 0x1D,
- L"Audio Port"
- },
- {
- 0x1E,
- L"Modem Port"
- },
- {
- 0x1F,
- L"Network Port"
- },
- {
- 0x20,
- L"SATA Port"
- },
- {
- 0x21,
- L"SAS Port"
- },
- {
- 0xA0,
- L"8251 Compatible"
- },
- {
- 0xA1,
- L"8251 FIFO Compatible"
- },
- {
- 0xFF,
- L"Other "
- },
-};
-
-TABLE_ITEM SystemSlotTypeTable[] = {
- {
- 0x01,
- L"Other"
- },
- {
- 0x02,
- L"Unknown"
- },
- {
- 0x03,
- L"ISA"
- },
- {
- 0x04,
- L"MCA"
- },
- {
- 0x05,
- L"EISA"
- },
- {
- 0x06,
- L"PCI"
- },
- {
- 0x07,
- L"PC Card (PCMCIA)"
- },
- {
- 0x08,
- L"VL-VESA"
- },
- {
- 0x09,
- L"Proprietary"
- },
- {
- 0x0A,
- L"Processor Card Slot"
- },
- {
- 0x0B,
- L"Proprietary Memory Card Slot"
- },
- {
- 0x0C,
- L"I/O Riser Card Slot"
- },
- {
- 0x0D,
- L"NuBus"
- },
- {
- 0x0E,
- L"PCI - 66MHz Capable"
- },
- {
- 0x0F,
- L"AGP"
- },
- {
- 0x10,
- L"AGP 2X"
- },
- {
- 0x11,
- L"AGP 4X"
- },
- {
- 0x12,
- L"PCI-X"
- },
- {
- 0xA0,
- L"PC-98/C20 "
- },
- {
- 0xA1,
- L"PC-98/C24 "
- },
- {
- 0xA2,
- L"PC-98/E "
- },
- {
- 0xA3,
- L"PC-98/Local Bus "
- },
- {
- 0xA4,
- L"PC-98/Card "
- },
- {
- 0xA5,
- L"PCI Express "
- },
- {
- 0xA6,
- L"PCI Express X1"
- },
- {
- 0xA7,
- L"PCI Express X2"
- },
- {
- 0xA8,
- L"PCI Express X4"
- },
- {
- 0xA9,
- L"PCI Express X8"
- },
- {
- 0xAA,
- L"PCI Express X16"
- },
- {
- 0xAB,
- L"PCI Express Gen 2"
- },
- {
- 0xAC,
- L"PCI Express Gen 2 X1"
- },
- {
- 0xAD,
- L"PCI Express Gen 2 X2"
- },
- {
- 0xAE,
- L"PCI Express Gen 2 X4"
- },
- {
- 0xAF,
- L"PCI Express Gen 2 X8"
- },
- {
- 0xB0,
- L"PCI Express Gen 2 X16"
- },
- {
- 0xB1,
- L"PCI Express Gen 3"
- },
- {
- 0xB2,
- L"PCI Express Gen 3 X1"
- },
- {
- 0xB3,
- L"PCI Express Gen 3 X2"
- },
- {
- 0xB4,
- L"PCI Express Gen 3 X4"
- },
- {
- 0xB5,
- L"PCI Express Gen 3 X8"
- },
- {
- 0xB6,
- L"PCI Express Gen 3 X16"
- }
-};
-
-TABLE_ITEM SystemSlotDataBusWidthTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" 8 bit"
- },
- {
- 0x04,
- L" 16 bit"
- },
- {
- 0x05,
- L" 32 bit"
- },
- {
- 0x06,
- L" 64 bit"
- },
- {
- 0x07,
- L" 128 bit"
- },
- {
- 0x08,
- L" 1x or x1"
- },
- {
- 0x09,
- L" 2x or x2"
- },
- {
- 0x0A,
- L" 4x or x4"
- },
- {
- 0x0B,
- L" 8x or x8"
- },
- {
- 0x0C,
- L" 12x or x12"
- },
- {
- 0x0D,
- L" 16x or x16"
- },
- {
- 0x0E,
- L" 32x or x32"
- }
-};
-
-TABLE_ITEM SystemSlotCurrentUsageTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Available"
- },
- {
- 0x04,
- L" In use"
- },
-};
-
-TABLE_ITEM SystemSlotLengthTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Short length"
- },
- {
- 0x04,
- L" Long Length"
- },
-};
-
-TABLE_ITEM SlotCharacteristics1Table[] = {
- {
- 0,
- L" Characteristics Unknown"
- },
- {
- 1,
- L" Provides 5.0 Volts"
- },
- {
- 2,
- L" Provides 3.3 Volts"
- },
- {
- 3,
- L" Slot's opening is shared with another slot, e.g. PCI/EISA shared slot."
- },
-
- {
- 4,
- L" PC Card slot supports PC Card-16"
- },
- {
- 5,
- L" PC Card slot supports CardBus"
- },
- {
- 6,
- L" PC Card slot supports Zoom Video "
- },
- {
- 7,
- L" PC Card slot supports Modem Ring Resume "
- }
-};
-
-TABLE_ITEM SlotCharacteristics2Table[] = {
- {
- 0,
- L" PCI slot supports Power Management Enable (PME#) signal"
- },
- {
- 1,
- L" Slot supports hot-plug devices"
- },
- {
- 2,
- L" PCI slot supports SMBus signal"
- }
-};
-
-TABLE_ITEM OnboardDeviceTypesTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Video"
- },
- {
- 0x04,
- L" SCSI Controller"
- },
- {
- 0x05,
- L" Ethernet"
- },
- {
- 0x06,
- L" Token Ring"
- },
- {
- 0x07,
- L" Sound"
- },
- {
- 0x08,
- L" Pata Controller"
- },
- {
- 0x09,
- L" Sata Controller"
- },
- {
- 0x0A,
- L" Sas Controller"
- },
-};
-
-TABLE_ITEM SELTypesTable[] = {
- {
- 0x00,
- L" Reserved."
- },
- {
- 0x01,
- L" Single-bit ECC memory error"
- },
- {
- 0x02,
- L" Multi-bit ECC memory error"
- },
- {
- 0x03,
- L" Parity memory error"
- },
- {
- 0x04,
- L" Bus time-out"
- },
- {
- 0x05,
- L" I/O Channel Check"
- },
- {
- 0x06,
- L" Software NMI"
- },
- {
- 0x07,
- L" POST Memory Resize"
- },
- {
- 0x08,
- L" POST Error"
- },
- {
- 0x09,
- L" PCI Parity Error"
- },
- {
- 0x0A,
- L" PCI System Error"
- },
- {
- 0x0B,
- L" CPU Failure"
- },
- {
- 0x0C,
- L" EISA FailSafe Timer time-out"
- },
- {
- 0x0D,
- L" Correctable memory log disabled"
- },
- {
- 0x0E,
- L" Logging disabled for a specific Event Type"
- },
- {
- 0x0F,
- L" Reserved"
- },
- {
- 0x10,
- L" System Limit Exceeded"
- },
- {
- 0x11,
- L" Asynchronous hardware timer expired and issued a system reset"
- },
- {
- 0x12,
- L" System configuration information"
- },
- {
- 0x13,
- L" Hard-disk information"
- },
- {
- 0x14,
- L" System reconfigured"
- },
- {
- 0x15,
- L" Uncorrectable CPU-complex error"
- },
- {
- 0x16,
- L" Log Area Reset/Cleared"
- },
- {
- 0x17,
- L" System boot"
- },
- {
- 0x7F18,
- L" Unused by SMBIOS specification"
- },
- {
- 0xFE80,
- L" System and OEM specified"
- },
- {
- 0xFF,
- L" End-of-log"
- },
-};
-
-TABLE_ITEM SELVarDataFormatTypeTable[] = {
- {
- 0x00,
- L" None "
- },
- {
- 0x01,
- L" Handle "
- },
- {
- 0x02,
- L" Multiple-Event "
- },
- {
- 0x03,
- L" Multiple-Event Handle "
- },
- {
- 0x04,
- L" POST Results Bitmap "
- },
- //
- // Defined below
- //
- {
- 0x05,
- L" System Management Type"
- },
- //
- // Defined below
- //
- {
- 0x06,
- L" Multiple-Event System Management Type "
- },
- {
- 0x7F07,
- L" Unused "
- },
- {
- 0xFF80,
- L" OEM assigned "
- },
-};
-
-TABLE_ITEM PostResultsBitmapDw1Table[] = {
- {
- 0,
- L" Channel 2 Timer error "
- },
- {
- 1,
- L" Master PIC (8259 #1) error "
- },
- {
- 2,
- L" Slave PIC (8259 #2) error "
- },
- {
- 3,
- L" CMOS Battery Failure "
- },
- {
- 4,
- L" CMOS System Options Not Set "
- },
- {
- 5,
- L" CMOS Checksum Error "
- },
- {
- 6,
- L" CMOS Configuration Error "
- },
- {
- 7,
- L" Mouse and Keyboard Swapped "
- },
- {
- 8,
- L" Keyboard Locked "
- },
- {
- 9,
- L" Keyboard Not Functional "
- },
- {
- 10,
- L" Keyboard Controller Not Functional "
- },
- {
- 11,
- L" CMOS Memory Size Different "
- },
- {
- 12,
- L" Memory Decreased in Size "
- },
- {
- 13,
- L" Cache Memory Error "
- },
- {
- 14,
- L" Floppy Drive 0 Error "
- },
- {
- 15,
- L" Floppy Drive 1 Error "
- },
- {
- 16,
- L" Floppy Controller Failure "
- },
- {
- 17,
- L" Number of ATA Drives Reduced Error "
- },
- {
- 18,
- L" CMOS Time Not Set "
- },
- {
- 19,
- L" DDC Monitor Configuration Change "
- },
- {
- 20,
- L" Reserved, set to 0 "
- },
- {
- 21,
- L" Reserved, set to 0 "
- },
- {
- 22,
- L" Reserved, set to 0 "
- },
- {
- 23,
- L" Reserved, set to 0 "
- },
- {
- 24,
- L" Second DWORD has valid data "
- },
- {
- 25,
- L" Reserved, set to 0 "
- },
- {
- 26,
- L" Reserved, set to 0 "
- },
- {
- 27,
- L" Reserved, set to 0 "
- },
- {
- 28,
- L" Normally 0; available for OEM assignment "
- },
- {
- 29,
- L" Normally 0; available for OEM assignment "
- },
- {
- 30,
- L" Normally 0; available for OEM assignment "
- },
- {
- 31,
- L" Normally 0; available for OEM assignment "
- },
-};
-
-TABLE_ITEM PostResultsBitmapDw2Table[] = {
- {
- 0,
- L" Normally 0; available for OEM assignment "
- },
- {
- 1,
- L" Normally 0; available for OEM assignment "
- },
- {
- 2,
- L" Normally 0; available for OEM assignment "
- },
- {
- 3,
- L" Normally 0; available for OEM assignment "
- },
- {
- 4,
- L" Normally 0; available for OEM assignment "
- },
- {
- 5,
- L" Normally 0; available for OEM assignment "
- },
- {
- 6,
- L" Normally 0; available for OEM assignment "
- },
- {
- 7,
- L" PCI Memory Conflict "
- },
- {
- 8,
- L" PCI I/O Conflict "
- },
- {
- 9,
- L" PCI IRQ Conflict "
- },
- {
- 10,
- L" PNP Memory Conflict "
- },
- {
- 11,
- L" PNP 32 bit Memory Conflict "
- },
- {
- 12,
- L" PNP I/O Conflict "
- },
- {
- 13,
- L" PNP IRQ Conflict "
- },
- {
- 14,
- L" PNP DMA Conflict "
- },
- {
- 15,
- L" Bad PNP Serial ID Checksum "
- },
- {
- 16,
- L" Bad PNP Resource Data Checksum "
- },
- {
- 17,
- L" Static Resource Conflict "
- },
- {
- 18,
- L" NVRAM Checksum Error, NVRAM Cleared "
- },
- {
- 19,
- L" System Board Device Resource Conflict "
- },
- {
- 20,
- L" Primary Output Device Not Found "
- },
- {
- 21,
- L" Primary Input Device Not Found "
- },
- {
- 22,
- L" Primary Boot Device Not Found "
- },
- {
- 23,
- L" NVRAM Cleared By Jumper "
- },
- {
- 24,
- L" NVRAM Data Invalid, NVRAM Cleared "
- },
- {
- 25,
- L" FDC Resource Conflict "
- },
- {
- 26,
- L" Primary ATA Controller Resource Conflict "
- },
- {
- 27,
- L" Secondary ATA Controller Resource Conflict "
- },
- {
- 28,
- L" Parallel Port Resource Conflict "
- },
- {
- 29,
- L" Serial Port 1 Resource Conflict "
- },
- {
- 30,
- L" Serial Port 2 Resource Conflict "
- },
- {
- 31,
- L" Audio Resource Conflict "
- },
-};
-
-TABLE_ITEM SELSysManagementTypesTable[] = {
- {
- 0x01,
- L" +2.5V Out of range, #2 "
- },
- {
- 0x02,
- L" +3.3V Out of range "
- },
- {
- 0x03,
- L" +5V Out of range "
- },
- {
- 0x04,
- L" -5V Out of range "
- },
- {
- 0x05,
- L" +12V Out of range "
- },
- {
- 0x06,
- L" -12V Out of range "
- },
- {
- 0x0F07,
- L" Reserved for future out-of-range voltage levels "
- },
- {
- 0x10,
- L" System board temperature out of range "
- },
- {
- 0x11,
- L" Processor #1 temperature out of range "
- },
- {
- 0x12,
- L" Processor #2 temperature out of range "
- },
- {
- 0x13,
- L" Processor #3 temperature out of range "
- },
- {
- 0x14,
- L" Processor #4 temperature out of range "
- },
- {
- 0x1F15,
- L" Reserved for future out-of-range temperatures"
- },
- {
- 0x2720,
- L" Fan n (n = 0 to 7) Out of range "
- },
- {
- 0x2F28,
- L" Reserved for future assignment via this specification "
- },
- {
- 0x30,
- L" Chassis secure switch activated "
- },
-};
-
-TABLE_ITEM PMALocationTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" System board or motherboard"
- },
- {
- 0x04,
- L" ISA add-on card"
- },
- {
- 0x05,
- L" EISA add-on card"
- },
- {
- 0x06,
- L" PCI add-on card"
- },
- {
- 0x07,
- L" MCA add-on card"
- },
- {
- 0x08,
- L" PCMCIA add-on card"
- },
- {
- 0x09,
- L" Proprietary add-on card"
- },
- {
- 0x0A,
- L" NuBus"
- },
- {
- 0xA0,
- L" PC-98/C20 add-on card"
- },
- {
- 0xA1,
- L" PC-98/C24 add-on card"
- },
- {
- 0xA2,
- L" PC-98/E add-on card"
- },
- {
- 0xA3,
- L" PC-98/Local bus add-on card"
- }
-};
-
-TABLE_ITEM PMAUseTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" System memory"
- },
- {
- 0x04,
- L" Video memory"
- },
- {
- 0x05,
- L" Flash memory"
- },
- {
- 0x06,
- L" Non-volatile RAM"
- },
- {
- 0x07,
- L" Cache memory"
- }
-};
-
-TABLE_ITEM PMAErrorCorrectionTypesTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" None"
- },
- {
- 0x04,
- L" Parity"
- },
- {
- 0x05,
- L" Single-bit ECC"
- },
- {
- 0x06,
- L" Multi-bit ECC"
- },
- {
- 0x07,
- L" CRC"
- }
-};
-
-TABLE_ITEM MemoryDeviceFormFactorTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" SIMM"
- },
- {
- 0x04,
- L" SIP"
- },
- {
- 0x05,
- L" Chip"
- },
- {
- 0x06,
- L" DIP"
- },
- {
- 0x07,
- L" ZIP"
- },
- {
- 0x08,
- L" Proprietary Card"
- },
- {
- 0x09,
- L" DIMM"
- },
- {
- 0x0A,
- L" TSOP"
- },
- {
- 0x0B,
- L" Row of chips"
- },
- {
- 0x0C,
- L" RIMM"
- },
- {
- 0x0D,
- L" SODIMM"
- },
- {
- 0x0E,
- L" SRIMM"
- },
- {
- 0x0F,
- L" FB-DIMM"
- }
-};
-
-TABLE_ITEM MemoryDeviceTypeTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" DRAM"
- },
- {
- 0x04,
- L" EDRAM"
- },
- {
- 0x05,
- L" VRAM"
- },
- {
- 0x06,
- L" SRAM"
- },
- {
- 0x07,
- L" RAM"
- },
- {
- 0x08,
- L" ROM"
- },
- {
- 0x09,
- L" FLASH"
- },
- {
- 0x0A,
- L" EEPROM"
- },
- {
- 0x0B,
- L" FEPROM"
- },
- {
- 0x0C,
- L" EPROM"
- },
- {
- 0x0D,
- L" CDRAM"
- },
- {
- 0x0E,
- L" 3DRAM"
- },
- {
- 0x0F,
- L" SDRAM"
- },
- {
- 0x10,
- L" SGRAM"
- },
- {
- 0x11,
- L" RDRAM"
- },
- {
- 0x12,
- L" DDR"
- },
- {
- 0x13,
- L" DDR2"
- },
- {
- 0x14,
- L" DDR2 FB-DIMM"
- },
- {
- 0x18,
- L" DDR3"
- },
- {
- 0x19,
- L" FBD2"
- }
-};
-
-TABLE_ITEM MemoryDeviceTypeDetailTable[] = {
- {
- 1,
- L" Other"
- },
- {
- 2,
- L" Unknown"
- },
- {
- 3,
- L" Fast-paged"
- },
- {
- 4,
- L" Static column"
- },
- {
- 5,
- L" Pseudo-STATIC"
- },
- {
- 6,
- L" RAMBUS "
- },
- {
- 7,
- L" Synchronous"
- },
- {
- 8,
- L" CMOS"
- },
- {
- 9,
- L" EDO"
- },
- {
- 10,
- L" Window DRAM"
- },
- {
- 11,
- L" Cache DRAM"
- },
- {
- 12,
- L" Non-volatile"
- },
- {
- 13,
- L" Registered(Buffered)"
- },
- {
- 14,
- L" Unbuffered(Unregistered)"
- }
-};
-
-TABLE_ITEM MemoryErrorTypeTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" OK"
- },
- {
- 0x04,
- L" Bad read"
- },
- {
- 0x05,
- L" Parity error"
- },
- {
- 0x06,
- L" Single-bit error"
- },
- {
- 0x07,
- L" Double-bit error"
- },
- {
- 0x08,
- L" Multi-bit error"
- },
- {
- 0x09,
- L" Nibble error"
- },
- {
- 0x0A,
- L" Checksum error"
- },
- {
- 0x0B,
- L" CRC error"
- },
- {
- 0x0C,
- L" Corrected single-bit error"
- },
- {
- 0x0D,
- L" Corrected error"
- },
- {
- 0x0E,
- L" Uncorrectable error"
- },
-};
-
-TABLE_ITEM MemoryErrorGranularityTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Device level"
- },
- {
- 0x04,
- L" Memory partition level"
- },
-};
-
-TABLE_ITEM MemoryErrorOperationTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Read"
- },
- {
- 0x04,
- L" Write"
- },
- {
- 0x05,
- L" Partial Write"
- },
-};
-
-TABLE_ITEM PointingDeviceTypeTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Mouse"
- },
- {
- 0x04,
- L" Track Ball"
- },
- {
- 0x05,
- L" Track Point"
- },
- {
- 0x06,
- L" Glide Point"
- },
- {
- 0x07,
- L" Touch Pad"
- },
-};
-
-TABLE_ITEM PointingDeviceInterfaceTable[] = {
- {
- 0x01,
- L" Other"
- },
- {
- 0x02,
- L" Unknown"
- },
- {
- 0x03,
- L" Serial"
- },
- {
- 0x04,
- L" PS/2"
- },
- {
- 0x05,
- L" Infrared"
- },
- {
- 0x06,
- L" HP-HIL"
- },
- {
- 0x07,
- L" Bus mouse"
- },
- {
- 0x08,
- L" ADB(Apple Desktop Bus"
- },
- {
- 0xA0,
- L" Bus mouse DB-9"
- },
- {
- 0xA1,
- L" Bus mouse mirco-DIN"
- },
- {
- 0xA2,
- L" USB"
- },
-};
-
-TABLE_ITEM PBDeviceChemistryTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" Lead Acid "
- },
- {
- 0x04,
- L" Nickel Cadmium "
- },
- {
- 0x05,
- L" Nickel metal hydride "
- },
- {
- 0x06,
- L" Lithium-ion "
- },
- {
- 0x07,
- L" Zinc air "
- },
- {
- 0x08,
- L" Lithium Polymer "
- },
-};
-
-TABLE_ITEM VPLocationTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" OK "
- },
- {
- 0x04,
- L" Non-critical "
- },
- {
- 0x05,
- L" Critical "
- },
- {
- 0x06,
- L" Non-recoverable "
- },
-};
-
-TABLE_ITEM VPStatusTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" Processor "
- },
- {
- 0x04,
- L" Disk "
- },
- {
- 0x05,
- L" Peripheral Bay "
- },
- {
- 0x06,
- L" System Management Module "
- },
- {
- 0x07,
- L" Motherboard "
- },
- {
- 0x08,
- L" Memory Module "
- },
- {
- 0x09,
- L" Processor Module "
- },
- {
- 0x0A,
- L" Power Unit "
- },
- {
- 0x0B,
- L" Add-in Card "
- },
-};
-
-TABLE_ITEM CoolingDeviceStatusTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" OK "
- },
- {
- 0x04,
- L" Non-critical "
- },
- {
- 0x05,
- L" Critical "
- },
- {
- 0x06,
- L" Non-recoverable "
- },
-};
-
-TABLE_ITEM CoolingDeviceTypeTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" Fan "
- },
- {
- 0x04,
- L" Centrifugal Blower "
- },
- {
- 0x05,
- L" Chip Fan "
- },
- {
- 0x06,
- L" Cabinet Fan "
- },
- {
- 0x07,
- L" Power Supply Fan "
- },
- {
- 0x08,
- L" Heat Pipe "
- },
- {
- 0x09,
- L" Integrated Refrigeration "
- },
- {
- 0x10,
- L" Active Cooling "
- },
- {
- 0x11,
- L" Passive Cooling "
- },
-};
-
-TABLE_ITEM TemperatureProbeStatusTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" OK "
- },
- {
- 0x04,
- L" Non-critical "
- },
- {
- 0x05,
- L" Critical "
- },
- {
- 0x06,
- L" Non-recoverable "
- },
-};
-
-TABLE_ITEM TemperatureProbeLocTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" Processor "
- },
- {
- 0x04,
- L" Disk "
- },
- {
- 0x05,
- L" Peripheral Bay "
- },
- {
- 0x06,
- L" System Management Module "
- },
- {
- 0x07,
- L" Motherboard "
- },
- {
- 0x08,
- L" Memory Module "
- },
- {
- 0x09,
- L" Processor Module "
- },
- {
- 0x0A,
- L" Power Unit "
- },
- {
- 0x0B,
- L" Add-in Card "
- },
-};
-
-TABLE_ITEM ECPStatusTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" OK "
- },
- {
- 0x04,
- L" Non-critical "
- },
- {
- 0x05,
- L" Critical "
- },
- {
- 0x06,
- L" Non-recoverable "
- },
-};
-
-TABLE_ITEM ECPLocTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" Processor "
- },
- {
- 0x04,
- L" Disk "
- },
- {
- 0x05,
- L" Peripheral Bay "
- },
- {
- 0x06,
- L" System Management Module "
- },
- {
- 0x07,
- L" Motherboard "
- },
- {
- 0x08,
- L" Memory Module "
- },
- {
- 0x09,
- L" Processor Module "
- },
- {
- 0x0A,
- L" Power Unit "
- },
- {
- 0x0B,
- L" Add-in Card "
- },
-};
-
-TABLE_ITEM MDTypeTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" National Semiconductor LM75 "
- },
- {
- 0x04,
- L" National Semiconductor LM78 "
- },
- {
- 0x05,
- L" National Semiconductor LM79 "
- },
- {
- 0x06,
- L" National Semiconductor LM80 "
- },
- {
- 0x07,
- L" National Semiconductor LM81 "
- },
- {
- 0x08,
- L" Analog Devices ADM9240 "
- },
- {
- 0x09,
- L" Dallas Semiconductor DS1780 "
- },
- {
- 0x0A,
- L" Maxim 1617 "
- },
- {
- 0x0B,
- L" Genesys GL518SM "
- },
- {
- 0x0C,
- L" Winbond W83781D "
- },
- {
- 0x0D,
- L" Holtek HT82H791 "
- },
-};
-
-TABLE_ITEM MDAddressTypeTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" I/O Port "
- },
- {
- 0x04,
- L" Memory "
- },
- {
- 0x05,
- L" SM Bus "
- },
-};
-
-TABLE_ITEM MemoryChannelTypeTable[] = {
- {
- 0x01,
- L" Other "
- },
- {
- 0x02,
- L" Unknown "
- },
- {
- 0x03,
- L" RamBus "
- },
- {
- 0x04,
- L" SyncLink "
- },
-};
-
-TABLE_ITEM IPMIDIBMCInterfaceTypeTable[] = {
- {
- 0x00,
- L" Unknown "
- },
- {
- 0x01,
- L" KCS: Keyboard Controller Style "
- },
- {
- 0x02,
- L" SMIC: Server Management Interface Chip "
- },
- {
- 0x03,
- L" BT: Block Transfer "
- },
- {
- 0xFF04,
- L" Reserved for future assignment by this specification "
- },
-};
-
-TABLE_ITEM StructureTypeInfoTable[] = {
- {
- 0,
- L" BIOS Information"
- },
- {
- 1,
- L" System Information"
- },
- {
- 2,
- L" Base Board Information"
- },
- {
- 3,
- L" System Enclosure"
- },
- {
- 4,
- L" Processor Information"
- },
- {
- 5,
- L" Memory Controller Information "
- },
- {
- 6,
- L" Memory Module Information "
- },
- {
- 7,
- L" Cache Information "
- },
- {
- 8,
- L" Port Connector Information "
- },
- {
- 9,
- L" System Slots "
- },
- {
- 10,
- L" On Board Devices Information "
- },
- {
- 11,
- L" OEM Strings"
- },
- {
- 12,
- L" System Configuration Options "
- },
- {
- 13,
- L" BIOS Language Information "
- },
- {
- 14,
- L" Group Associations "
- },
- {
- 15,
- L" System Event Log "
- },
- {
- 16,
- L" Physical Memory Array "
- },
- {
- 17,
- L" Memory Device "
- },
- {
- 18,
- L" 32-bit Memory Error Information "
- },
- {
- 19,
- L" Memory Array Mapped Address "
- },
- {
- 20,
- L" Memory Device Mapped Address "
- },
- {
- 21,
- L" Built-in Pointing Device "
- },
- {
- 22,
- L" Portable Battery "
- },
- {
- 23,
- L" System Reset "
- },
- {
- 24,
- L" Hardware Security "
- },
- {
- 25,
- L" System Power Controls "
- },
- {
- 26,
- L" Voltage Probe "
- },
- {
- 27,
- L" Cooling Device "
- },
- {
- 28,
- L" Temperature Probe "
- },
- {
- 29,
- L" Electrical Current Probe "
- },
- {
- 30,
- L" Out-of-Band Remote Access "
- },
- {
- 31,
- L" Boot Integrity Services (BIS) Entry Point"
- },
- {
- 32,
- L" System Boot Information "
- },
- {
- 33,
- L" 64-bit Memory Error Information "
- },
- {
- 34,
- L" Management Device "
- },
- {
- 35,
- L" Management Device Component "
- },
- {
- 36,
- L" Management Device Threshold Data "
- },
- {
- 37,
- L" Memory Channel "
- },
- {
- 38,
- L" IPMI Device Information "
- },
- {
- 39,
- L" System Power Supply"
- },
- {
- 40,
- L" Additional Information"
- },
- {
- 41,
- L" Onboard Devices Extended Information"
- },
- {
- 42,
- L" Management Controller Host Interface"
- },
- {
- 0x7E,
- L" Inactive"
- },
- {
- 0x7F,
- L" End-of-Table "
- },
-};
-
-
-/**
- Given a table and a Key, return the responding info.
-
- Notes:
- Table[Index].Key is change from UINT8 to UINT16,
- in order to deal with "0xaa - 0xbb".
-
- For example:
- DisplaySELVariableDataFormatTypes(UINT8 Type, UINT8 Option)
- has a item:
- "0x07-0x7F, Unused"
- Now define Key = 0x7F07, that is to say: High = 0x7F, Low = 0x07.
- Then all the Key Value between Low and High gets the same string
- L"Unused".
-
- @param[in] Table The begin address of table.
- @param[in] Number The number of table items.
- @param[in] Key The query Key.
- @param[in, out] Info Input as empty buffer; output as data buffer.
- @param[in] InfoLen The max number of characters for Info.
-
- @return the found Key and Info is valid.
- @retval QUERY_TABLE_UNFOUND and Info should be NULL.
-**/
-UINT8
-QueryTable (
- IN TABLE_ITEM *Table,
- IN UINTN Number,
- IN UINT8 Key,
- IN OUT CHAR16 *Info,
- IN UINTN InfoLen
- )
-{
- UINTN Index;
- //
- // High byte and Low byte of word
- //
- UINT8 High;
- UINT8 Low;
-
- for (Index = 0; Index < Number; Index++) {
- High = (UINT8) (Table[Index].Key >> 8);
- Low = (UINT8) (Table[Index].Key & 0x00FF);
-
- //
- // Check if Key is in the range
- // or if Key == Value in the table
- //
- if ((High > Low && Key >= Low && Key <= High)
- || (Table[Index].Key == Key)) {
- StrnCpyS (Info, InfoLen, Table[Index].Info, InfoLen - 1);
- StrnCatS (Info, InfoLen, L"\n", InfoLen - 1 - StrLen(Info));
- return Key;
- }
- }
-
- StrCpyS (Info, InfoLen, L"Undefined Value\n");
- return QUERY_TABLE_UNFOUND;
-}
-
-/**
- Given a table of bit info and a Key, return the responding info to the Key.
-
- @param[in] Table Point to a table which maintains a map of 'bit' to 'message'.
- @param[in] Number Number of table items.
- @param[in] Bits The Key of query the bit map information.
-**/
-VOID
-PrintBitsInfo (
- IN TABLE_ITEM *Table,
- IN UINTN Number,
- IN UINT32 Bits
- )
-{
- //
- // Get certain bit of 'Value':
- //
-#define BIT(Value, bit) ((Value) & ((UINT32) 1) << (bit))
- //
- // Clear certain bit of 'Value':
- //
-#define CLR_BIT(Value, bit) ((Value) -= (BIT (Value, bit)))
-
- UINTN Index;
- UINT32 Value;
- BOOLEAN NoInfo;
-
- NoInfo = TRUE;
- Value = Bits;
- //
- // query the table and print information
- //
- for (Index = 0; Index < Number; Index++) {
- if (BIT (Value, Table[Index].Key) != 0) {
- Print (Table[Index].Info);
- Print (L" | ");
-
- NoInfo = FALSE;
- //
- // clear the bit, for reserved bits test
- //
- CLR_BIT (Value, Table[Index].Key);
- }
- }
-
- if (NoInfo) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_NO_INFO), gShellDebug1HiiHandle);
- }
-
- if (Value != 0) {
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_BITS_SET),
- gShellDebug1HiiHandle,
- Value
- );
- }
-
- Print (L"\n");
-}
-//
-// //////////////////////////////////////////////////////////////////
-//
-// Following uses QueryTable functions to simplify the coding.
-// QueryTable(), PrintBitsInfo()
-//
-//
-#define PRINT_TABLE_ITEM(Table, Key) \
- do { \
- UINTN Num; \
- CHAR16 Info[66]; \
- Num = sizeof (Table) / sizeof (TABLE_ITEM); \
- ZeroMem (Info, sizeof (Info)); \
- QueryTable (Table, Num, Key, Info, sizeof(Info)/sizeof(Info[0])); \
- Print (Info); \
- } while (0);
-
-#define PRINT_BITS_INFO(Table, bits) \
- do { \
- UINTN Num; \
- Num = sizeof (Table) / sizeof (TABLE_ITEM); \
- PrintBitsInfo (Table, Num, (UINT32) bits); \
- } while (0);
-
-/**
- Display System Information (Type 1) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemWakeupType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_WAKEUP_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (SystemWakeupTypeTable, Type);
-}
-
-/**
- Display Base Board (Type 2) Feature Flags.
-
- @param[in] FeatureFlags The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBaseBoardFeatureFlags (
- IN UINT8 FeatureFlags,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_BASE_BOARD_FEATURE_FLAGS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (FeatureFlags, Option);
- PRINT_BITS_INFO (BaseBoardFeatureFlagsTable, FeatureFlags);
-}
-
-/**
- Display Base Board (Type 2) Board Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBaseBoardBoardType(
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_BASE_BOARD_BOARD_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (BaseBoardBoardTypeTable, Type);
-}
-
-/**
- Display System Enclosure (Type 3) Enclosure Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemEnclosureType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- //
- // query table and print info
- //
- PRINT_TABLE_ITEM (SystemEnclosureTypeTable, Type);
-
- if (BIT (Type, 7) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CHASSIS_LOCK_PRESENT), gShellDebug1HiiHandle);
- }
-}
-
-/**
- Display System Enclosure (Type 3) Enclosure Status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemEnclosureStatus (
- IN UINT8 Status,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (SystemEnclosureStatusTable, Status);
-}
-
-/**
- Display System Enclosure (Type 3) Security Status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySESecurityStatus (
- IN UINT8 Status,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_CHASSIS_SECURITY), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (SESecurityStatusTable, Status);
-}
-
-/**
- Display Processor Information (Type 4) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PROC_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (ProcessorTypeTable, Type);
-}
-
-/**
- Display Processor Information (Type 4) Upgrade.
-
- @param[in] Upgrade The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorUpgrade (
- IN UINT8 Upgrade,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PROC_UPDATE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Upgrade, Option);
- PRINT_TABLE_ITEM (ProcessorUpgradeTable, Upgrade);
-}
-
-/**
- Display Processor Information (Type 4) Characteristics.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorCharacteristics (
- IN UINT16 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PROC_CHARACTERISTICS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_BITS_INFO (ProcessorCharacteristicsTable, Type);
-}
-
-/**
- Display Memory Controller Information (Type 5) method.
-
- @param[in] Method The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcErrorDetectMethod (
- IN UINT8 Method,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DETECTMETHOD), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Method, Option);
- PRINT_TABLE_ITEM (McErrorDetectMethodTable, Method);
-}
-
-/**
- Display Memory Controller Information (Type 5) Capability.
-
- @param[in] Capability The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcErrorCorrectCapability (
- IN UINT8 Capability,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_CORRECT_CAPABILITY), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Capability, Option);
- PRINT_BITS_INFO (McErrorCorrectCapabilityTable, Capability);
-}
-
-/**
- Display Memory Controller Information (Type 5) Support.
-
- @param[in] Support The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcInterleaveSupport (
- IN UINT8 Support,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_INTERLEAVE_SUPPORT), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Support, Option);
- PRINT_TABLE_ITEM (McInterleaveSupportTable, Support);
-}
-
-/**
- Display Memory Controller Information (Type 5) speeds.
-
- @param[in] Speed The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcMemorySpeeds (
- IN UINT16 Speed,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MEMORY_SPEED), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Speed, Option);
- PRINT_BITS_INFO (McMemorySpeedsTable, Speed);
-}
-
-/**
- Display Memory Controller Information (Type 5) voltage.
-
- @param[in] Voltage The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryModuleVoltage (
- IN UINT8 Voltage,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_REQUIRED_VOLTAGES), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Voltage, Option);
- PRINT_BITS_INFO (MemoryModuleVoltageTable, Voltage);
-}
-
-/**
- Display Memory Module Information (Type 6) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMmMemoryType (
- IN UINT16 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MODULE_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_BITS_INFO (MmMemoryTypeTable, Type);
-}
-
-/**
- Display Memory Module Information (Type 6) status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMmErrorStatus (
- IN UINT8 Status,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_MODULE_ERROR_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_BITS_INFO (MmErrorStatusTable, Status);
-}
-
-/**
- Display Cache Information (Type 7) SRAM Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheSRAMType (
- IN UINT16 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_SRAM_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION ((UINT8) Type, Option);
- PRINT_BITS_INFO (CacheSRAMTypeTable, (UINT8) Type);
-}
-
-/**
- Display Cache Information (Type 7) correcting Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheErrCorrectingType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_ERROR_CORRECTING), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (CacheErrCorrectingTypeTable, Type);
-}
-
-/**
- Display Cache Information (Type 7) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheSystemCacheType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_SYSTEM_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (CacheSystemCacheTypeTable, Type);
-}
-
-/**
- Display Cache Information (Type 7) Associativity.
-
- @param[in] Associativity The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheAssociativity (
- IN UINT8 Associativity,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_CACHE_ASSOCIATIVITY), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Associativity, Option);
- PRINT_TABLE_ITEM (CacheAssociativityTable, Associativity);
-}
-
-/**
- Display Port Connector Information (Type 8) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPortConnectorType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORT_CONNECTOR_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (PortConnectorTypeTable, Type);
-}
-
-/**
- Display Port Connector Information (Type 8) port type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPortType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORT_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (PortTypeTable, Type);
-}
-
-/**
- Display System Slots (Type 9) slot type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (SystemSlotTypeTable, Type);
-}
-
-/**
- Display System Slots (Type 9) data bus width.
-
- @param[in] Width The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotDataBusWidth (
- IN UINT8 Width,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_DATA), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Width, Option);
- PRINT_TABLE_ITEM (SystemSlotDataBusWidthTable, Width);
-}
-
-/**
- Display System Slots (Type 9) usage information.
-
- @param[in] Usage The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotCurrentUsage (
- IN UINT8 Usage,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_CURRENT_USAGE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Usage, Option);
- PRINT_TABLE_ITEM (SystemSlotCurrentUsageTable, Usage);
-}
-
-/**
- Display System Slots (Type 9) slot length.
-
- @param[in] Length The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotLength (
- IN UINT8 Length,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_SLOT_LENGTH), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Length, Option);
- PRINT_TABLE_ITEM (SystemSlotLengthTable, Length);
-}
-
-/**
- Display System Slots (Type 9) characteristics.
-
- @param[in] Chara1 The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySlotCharacteristics1 (
- IN UINT8 Chara1,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SLOT_CHARACTERISTICS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Chara1, Option);
- PRINT_BITS_INFO (SlotCharacteristics1Table, Chara1);
-}
-
-/**
- Display System Slots (Type 9) characteristics.
-
- @param[in] Chara2 The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySlotCharacteristics2 (
- IN UINT8 Chara2,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SLOT_CHARACTERISTICS_2), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Chara2, Option);
- PRINT_BITS_INFO (SlotCharacteristics2Table, Chara2);
-}
-
-/**
- Display On Board Devices Information (Type 10) types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayOnboardDeviceTypes (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ONBOARD_DEVICE_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (OnboardDeviceTypesTable, Type);
-}
-
-/**
- Display System Event Log (Type 15) types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELTypes (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_EVENT_LOG_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (SELTypesTable, Type);
-}
-
-/**
- Display System Event Log (Type 15) format type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELVarDataFormatType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_EVENT_LOG_VAR_DATA_FORMAT), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (SELVarDataFormatTypeTable, Type);
-}
-
-/**
- Display System Event Log (Type 15) dw1.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPostResultsBitmapDw1 (
- IN UINT32 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POST_RESULTS_BITMAP), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_BITS_INFO (PostResultsBitmapDw1Table, Key);
-}
-
-/**
- Display System Event Log (Type 15) dw2.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPostResultsBitmapDw2 (
- IN UINT32 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POST_RESULTS_SECOND_DWORD), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_BITS_INFO (PostResultsBitmapDw2Table, Key);
-}
-
-/**
- Display System Event Log (Type 15) type.
-
- @param[in] SMType The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELSysManagementTypes (
- IN UINT32 SMType,
- IN UINT8 Option
- )
-{
- UINT8 Temp;
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_MANAGEMENT_TYPES), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (SMType, Option);
-
- //
- // Deal with wide range Value
- //
- if (SMType >= 0x80000000) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_OEM_ASSIGNED), gShellDebug1HiiHandle);
- } else if (SMType >= 0x00020000) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle);
- } else if (SMType >= 0x00010000) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_SYSTEM_MANAGEMENT_PROBE), gShellDebug1HiiHandle);
- } else if (SMType >= 0x31) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_RSVD_FOR_FUTURE_ASSIGN), gShellDebug1HiiHandle);
- } else {
- //
- // Deal with One byte data
- //
- Temp = (UINT8) (SMType & 0x3F);
- PRINT_TABLE_ITEM (SELSysManagementTypesTable, Temp);
- }
-}
-
-/**
- Display Physical Memory Array (Type 16) Location.
-
- @param[in] Location The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMALocation (
- IN UINT8 Location,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_LOCATION), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Location, Option);
- PRINT_TABLE_ITEM (PMALocationTable, Location);
-}
-
-/**
- Display Physical Memory Array (Type 16) Use.
-
- @param[in] Use The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMAUse (
- IN UINT8 Use,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_USE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Use, Option);
- PRINT_TABLE_ITEM (PMAUseTable, Use);
-}
-
-/**
- Display Physical Memory Array (Type 16) Types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMAErrorCorrectionTypes (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PHYS_MEM_ARRAY_ERROR), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (PMAErrorCorrectionTypesTable, Type);
-}
-
-/**
- Display Memory Device (Type 17) form factor.
-
- @param[in] FormFactor The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceFormFactor (
- IN UINT8 FormFactor,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_FORM_FACTOR), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (FormFactor, Option);
- PRINT_TABLE_ITEM (MemoryDeviceFormFactorTable, FormFactor);
-}
-
-/**
- Display Memory Device (Type 17) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (MemoryDeviceTypeTable, Type);
-}
-
-/**
- Display Memory Device (Type 17) details.
-
- @param[in] Para The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceTypeDetail (
- IN UINT16 Para,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_DEVICE_TYPE_DETAIL), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Para, Option);
- PRINT_BITS_INFO (MemoryDeviceTypeDetailTable, Para);
-}
-
-/**
- Display 32-bit Memory Error Information (Type 18) type.
-
- @param[in] ErrorType The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorType (
- IN UINT8 ErrorType,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_INFO), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (ErrorType, Option);
- PRINT_TABLE_ITEM (MemoryErrorTypeTable, ErrorType);
-}
-
-/**
- Display 32-bit Memory Error Information (Type 18) error granularity.
-
- @param[in] Granularity The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorGranularity (
- IN UINT8 Granularity,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_GRANULARITY), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Granularity, Option);
- PRINT_TABLE_ITEM (MemoryErrorGranularityTable, Granularity);
-}
-
-/**
- Display 32-bit Memory Error Information (Type 18) error information.
-
- @param[in] Operation The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorOperation (
- IN UINT8 Operation,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_ERROR_OP), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Operation, Option);
- PRINT_TABLE_ITEM (MemoryErrorOperationTable, Operation);
-}
-
-/**
- Display Built-in Pointing Device (Type 21) type information.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPointingDeviceType (
- IN UINT8 Type,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POINTING_DEVICE_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (PointingDeviceTypeTable, Type);
-}
-
-/**
- Display Built-in Pointing Device (Type 21) information.
-
- @param[in] Interface The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPointingDeviceInterface (
- IN UINT8 Interface,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_POINTING_DEVICE_INTERFACE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Interface, Option);
- PRINT_TABLE_ITEM (PointingDeviceInterfaceTable, Interface);
-}
-
-/**
- Display Portable Battery (Type 22) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPBDeviceChemistry (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_PORTABLE_BATT_DEV_CHEM), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (PBDeviceChemistryTable, Key);
-}
-
-/**
- Display Voltage Probe (Type 26) location information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayVPLocation (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Loc;
-
- Loc = (UINT8) ((Key & 0xE0) >> 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_LOC), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Loc, Option);
- PRINT_TABLE_ITEM (VPLocationTable, Loc);
-}
-
-/**
- Display Voltage Probe (Type 26) status ype information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayVPStatus (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Status;
-
- Status = (UINT8) (Key & 0x1F);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (VPStatusTable, Status);
-}
-
-/**
- Display Cooling (Type 27) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCoolingDeviceStatus (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Status;
-
- Status = (UINT8) ((Key & 0xE0) >> 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_COOLING_DEV_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (CoolingDeviceStatusTable, Status);
-}
-
-/**
- Display Cooling (Type 27) type information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCoolingDeviceType (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Type;
-
- Type = (UINT8) (Key & 0x1F);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_COOLING_DEV_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Type, Option);
- PRINT_TABLE_ITEM (CoolingDeviceTypeTable, Type);
-}
-
-/**
- Display Temperature Probe (Type 28) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayTemperatureProbeStatus (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Status;
-
- Status = (UINT8) ((Key & 0xE0) >> 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_TEMP_PROBE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (TemperatureProbeStatusTable, Status);
-}
-
-/**
- Display Temperature Probe (Type 28) location information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayTemperatureProbeLoc (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Loc;
-
- Loc = (UINT8) (Key & 0x1F);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_VOLTAGE_PROBE_LOC), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Loc, Option);
- PRINT_TABLE_ITEM (TemperatureProbeLocTable, Loc);
-}
-
-/**
- Display Electrical Current Probe (Type 29) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayECPStatus (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Status;
-
- Status = (UINT8) ((Key & 0xE0) >> 5);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ELEC_PROBE_STATUS), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Status, Option);
- PRINT_TABLE_ITEM (ECPStatusTable, Status);
-}
-
-/**
- Display Type 29 information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayECPLoc (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- UINT8 Loc;
-
- Loc = (UINT8) (Key & 0x1F);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_ELEC_PROBE_LOC), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Loc, Option);
- PRINT_TABLE_ITEM (ECPLocTable, Loc);
-}
-
-/**
- Display Management Device (Type 34) Type.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMDType (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MANAGEMENT_DEV_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (MDTypeTable, Key);
-}
-
-/**
- Display Management Device (Type 34) Address Type.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMDAddressType (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MANAGEMENT_DEV_ADDR_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (MDAddressTypeTable, Key);
-}
-
-/**
- Display Memory Channel (Type 37) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryChannelType (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_MEM_CHANNEL_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (MemoryChannelTypeTable, Key);
-}
-
-/**
- Display IPMI Device Information (Type 38) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayIPMIDIBMCInterfaceType (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_BMC_INTERFACE_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (IPMIDIBMCInterfaceTypeTable, Key);
-}
-
-/**
- Display the structure type information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayStructureTypeInfo (
- IN UINT8 Key,
- IN UINT8 Option
- )
-{
- //
- // display
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_QUERYTABLE_STRUCT_TYPE), gShellDebug1HiiHandle);
- PRINT_INFO_OPTION (Key, Option);
- PRINT_TABLE_ITEM (StructureTypeInfoTable, Key);
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h
deleted file mode 100644
index 9cae7094fb..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.h
+++ /dev/null
@@ -1,782 +0,0 @@
-/** @file
- Build a table, each item is (key, info) pair.
- and give a interface of query a string out of a table.
-
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _SMBIOS_QUERY_TABLE_H_
-#define _SMBIOS_QUERY_TABLE_H_
-
-#define QUERY_TABLE_UNFOUND 0xFF
-
-typedef struct TABLE_ITEM {
- UINT16 Key;
- CHAR16 *Info;
-} TABLE_ITEM;
-
-//
-// Print info by option
-//
-#define PRINT_INFO_OPTION(Value, Option) \
- do { \
- if (Option == SHOW_NONE) { \
- return ; \
- } \
- if (Option < SHOW_DETAIL) { \
- Print (L"0x%x\n", Value); \
- return ; \
- } \
- } while (0);
-
-/**
- Given a table and a Key, return the responding info.
-
- Notes:
- Table[Index].Key is change from UINT8 to UINT16,
- in order to deal with "0xaa - 0xbb".
-
- For example:
- DisplaySELVariableDataFormatTypes(UINT8 Type, UINT8 Option)
- has a item:
- "0x07-0x7F, Unused"
- Now define Key = 0x7F07, that is to say: High = 0x7F, Low = 0x07.
- Then all the Key Value between Low and High gets the same string
- L"Unused".
-
- @param[in] Table The begin address of table.
- @param[in] Number The number of table items.
- @param[in] Key The query Key.
- @param[in, out] Info Input as empty buffer; output as data buffer.
- @param[in] InfoLen The max number of characters for Info.
-
- @return the found Key and Info is valid.
- @retval QUERY_TABLE_UNFOUND and Info should be NULL.
-**/
-UINT8
-QueryTable (
- IN TABLE_ITEM *Table,
- IN UINTN Number,
- IN UINT8 Key,
- IN OUT CHAR16 *Info,
- IN UINTN InfoLen
- );
-
-/**
- Display the structure type information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayStructureTypeInfo (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display System Information (Type 1) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemWakeupType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Base Board (Type 2) Feature Flags.
-
- @param[in] FeatureFlags The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBaseBoardFeatureFlags (
- IN UINT8 FeatureFlags,
- IN UINT8 Option
- );
-
-/**
- Display Base Board (Type 2) Board Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayBaseBoardBoardType(
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Enclosure (Type 3) Enclosure Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemEnclosureType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Enclosure (Type 3) Enclosure Status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemEnclosureStatus (
- IN UINT8 Status,
- IN UINT8 Option
- );
-
-/**
- Display System Enclosure (Type 3) Security Status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySESecurityStatus (
- IN UINT8 Status,
- IN UINT8 Option
- )
-;
-
-/**
- Display Processor Information (Type 4) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Processor Information (Type 4) Upgrade.
-
- @param[in] Upgrade The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorUpgrade (
- IN UINT8 Upgrade,
- IN UINT8 Option
- );
-
-/**
- Display Processor Information (Type 4) Characteristics.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayProcessorCharacteristics (
- IN UINT16 Type,
- IN UINT8 Option
- );
-
-/**
- Display Memory Controller Information (Type 5) method.
-
- @param[in] Method The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcErrorDetectMethod (
- IN UINT8 Method,
- IN UINT8 Option
- );
-
-/**
- Display Memory Controller Information (Type 5) Capability.
-
- @param[in] Capability The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcErrorCorrectCapability (
- IN UINT8 Capability,
- IN UINT8 Option
- );
-
-/**
- Display Memory Controller Information (Type 5) Support.
-
- @param[in] Support The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcInterleaveSupport (
- IN UINT8 Support,
- IN UINT8 Option
- );
-
-/**
- Display Memory Controller Information (Type 5) speeds.
-
- @param[in] Speed The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMcMemorySpeeds (
- IN UINT16 Speed,
- IN UINT8 Option
- );
-
-/**
- Display Memory Controller Information (Type 5) voltage.
-
- @param[in] Voltage The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryModuleVoltage (
- IN UINT8 Voltage,
- IN UINT8 Option
- );
-
-/**
- Display Memory Module Information (Type 6) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMmMemoryType (
- IN UINT16 Type,
- IN UINT8 Option
- );
-
-/**
- Display Memory Module Information (Type 6) status.
-
- @param[in] Status The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMmErrorStatus (
- IN UINT8 Status,
- IN UINT8 Option
- );
-
-/**
- Display Cache Information (Type 7) SRAM Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheSRAMType (
- IN UINT16 Type,
- IN UINT8 Option
- );
-
-/**
- Display Cache Information (Type 7) correcting Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheErrCorrectingType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Cache Information (Type 7) Type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheSystemCacheType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Cache Information (Type 7) Associativity.
-
- @param[in] Associativity The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCacheAssociativity (
- IN UINT8 Associativity,
- IN UINT8 Option
- );
-
-/**
- Display Port Connector Information (Type 8) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPortConnectorType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Port Connector Information (Type 8) port type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPortType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) slot type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) data bus width.
-
- @param[in] Width The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotDataBusWidth (
- IN UINT8 Width,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) usage information.
-
- @param[in] Usage The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotCurrentUsage (
- IN UINT8 Usage,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) slot length.
-
- @param[in] Length The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySystemSlotLength (
- IN UINT8 Length,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) characteristics.
-
- @param[in] Chara1 The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySlotCharacteristics1 (
- IN UINT8 Chara1,
- IN UINT8 Option
- );
-
-/**
- Display System Slots (Type 9) characteristics.
-
- @param[in] Chara2 The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySlotCharacteristics2 (
- IN UINT8 Chara2,
- IN UINT8 Option
- );
-
-/**
- Display On Board Devices Information (Type 10) types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayOnboardDeviceTypes (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Event Log (Type 15) types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELTypes (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Event Log (Type 15) format type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELVarDataFormatType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display System Event Log (Type 15) dw1.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPostResultsBitmapDw1 (
- IN UINT32 Key,
- IN UINT8 Option
- );
-
-/**
- Display System Event Log (Type 15) dw2.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPostResultsBitmapDw2 (
- IN UINT32 Key,
- IN UINT8 Option
- );
-
-/**
- Display System Event Log (Type 15) type.
-
- @param[in] SMType The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplaySELSysManagementTypes (
- IN UINT32 SMType,
- IN UINT8 Option
- );
-
-/**
- Display Physical Memory Array (Type 16) Location.
-
- @param[in] Location The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMALocation (
- IN UINT8 Location,
- IN UINT8 Option
- );
-
-/**
- Display Physical Memory Array (Type 16) Use.
-
- @param[in] Use The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMAUse (
- IN UINT8 Use,
- IN UINT8 Option
- );
-
-/**
- Display Physical Memory Array (Type 16) Types.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPMAErrorCorrectionTypes (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Memory Device (Type 17) form factor.
-
- @param[in] FormFactor The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceFormFactor (
- IN UINT8 FormFactor,
- IN UINT8 Option
- );
-
-/**
- Display Memory Device (Type 17) type.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Memory Device (Type 17) details.
-
- @param[in] Para The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryDeviceTypeDetail (
- IN UINT16 Para,
- IN UINT8 Option
- );
-
-/**
- Display 32-bit Memory Error Information (Type 18) type.
-
- @param[in] ErrorType The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorType (
- IN UINT8 ErrorType,
- IN UINT8 Option
- );
-
-/**
- Display 32-bit Memory Error Information (Type 18) error granularity.
-
- @param[in] Granularity The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorGranularity (
- IN UINT8 Granularity,
- IN UINT8 Option
- );
-
-/**
- Display 32-bit Memory Error Information (Type 18) error information.
-
- @param[in] Operation The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryErrorOperation (
- IN UINT8 Operation,
- IN UINT8 Option
- );
-
-/**
- Display Built-in Pointing Device (Type 21) type information.
-
- @param[in] Type The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPointingDeviceType (
- IN UINT8 Type,
- IN UINT8 Option
- );
-
-/**
- Display Built-in Pointing Device (Type 21) information.
-
- @param[in] Interface The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPointingDeviceInterface (
- IN UINT8 Interface,
- IN UINT8 Option
- );
-
-/**
- Display Portable Battery (Type 22) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayPBDeviceChemistry (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Voltage Probe (Type 26) location information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayVPLocation (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Voltage Probe (Type 26) status ype information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayVPStatus (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Cooling (Type 27) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCoolingDeviceStatus (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Cooling (Type 27) type information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayCoolingDeviceType (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Temperature Probe (Type 28) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayTemperatureProbeStatus (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Temperature Probe (Type 28) location information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayTemperatureProbeLoc (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Electrical Current Probe (Type 29) status information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayECPStatus (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Electrical Current Probe (Type 29) location information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayECPLoc (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Management Device (Type 34) Type.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMDType (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Management Device (Type 34) Address Type.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMDAddressType (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display Memory Channel (Type 37) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayMemoryChannelType (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-/**
- Display IPMI Device Information (Type 38) information.
-
- @param[in] Key The key of the structure.
- @param[in] Option The optional information.
-**/
-VOID
-DisplayIPMIDIBMCInterfaceType (
- IN UINT8 Key,
- IN UINT8 Option
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
deleted file mode 100644
index a06339452a..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
+++ /dev/null
@@ -1,1013 +0,0 @@
-/** @file
- Tools of clarify the content of the smbios table.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "../UefiShellDebug1CommandsLib.h"
-#include "LibSmbiosView.h"
-#include "SmbiosView.h"
-#include "PrintInfo.h"
-#include "QueryTable.h"
-
-UINT8 gShowType = SHOW_DETAIL;
-STATIC STRUCTURE_STATISTICS *mStatisticsTable = NULL;
-STATIC STRUCTURE_STATISTICS *mSmbios64BitStatisticsTable = NULL;
-
-UINT8 SmbiosMajorVersion;
-UINT8 SmbiosMinorVersion;
-
-UINTN mNumberOfSmbios64BitStructures;
-UINTN mSmbios64BitTableLength;
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-t", TypeValue},
- {L"-h", TypeValue},
- {L"-s", TypeFlag},
- {L"-a", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'smbiosview' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSmbiosView (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT8 StructType;
- UINT16 StructHandle;
- EFI_STATUS Status;
- EFI_STATUS Status1;
- EFI_STATUS Status2;
- BOOLEAN RandomView;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Temp;
-
- mStatisticsTable = NULL;
- mSmbios64BitStatisticsTable = NULL;
- Package = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"smbiosview", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"smbiosview");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetValue(Package, L"-t") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"smbiosview", L"-t");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetValue(Package, L"-h") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"smbiosview", L"-h");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (
- (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-h")) ||
- (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-s")) ||
- (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-a")) ||
- (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-s")) ||
- (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-a")) ||
- (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-a"))
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"smbiosview");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
-
- //
- // Init Lib
- //
- Status1 = LibSmbiosInit ();
- Status2 = LibSmbios64BitInit ();
- if (EFI_ERROR (Status1) && EFI_ERROR (Status2)) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), gShellDebug1HiiHandle);
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
-
- StructType = STRUCTURE_TYPE_RANDOM;
- RandomView = TRUE;
-
- Temp = ShellCommandLineGetValue(Package, L"-t");
- if (Temp != NULL) {
- StructType = (UINT8) ShellStrToUintn (Temp);
- }
-
- if (ShellCommandLineGetFlag(Package, L"-a")) {
- gShowType = SHOW_ALL;
- }
-
- if (!EFI_ERROR (Status1)) {
- //
- // Initialize the StructHandle to be the first handle
- //
- StructHandle = INVALID_HANDLE;
- LibGetSmbiosStructure (&StructHandle, NULL, NULL);
-
- Temp = ShellCommandLineGetValue(Package, L"-h");
- if (Temp != NULL) {
- RandomView = FALSE;
- StructHandle = (UINT16) ShellStrToUintn(Temp);
- }
- //
- // build statistics table
- //
- Status = InitSmbiosTableStatistics ();
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
-
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- Status = DisplayStatisticsTable (SHOW_DETAIL);
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- goto Show64Bit;
- }
-
- //
- // Show SMBIOS structure information
- //
- Status = SMBiosView (StructType, StructHandle, gShowType, RandomView);
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- }
-
-Show64Bit:
- if (!EFI_ERROR (Status2)) {
- //
- // build statistics table
- //
- Status = InitSmbios64BitTableStatistics ();
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- //
- // Initialize the StructHandle to be the first handle
- //
- StructHandle = INVALID_HANDLE;
- LibGetSmbios64BitStructure (&StructHandle, NULL, NULL);
-
- Temp = ShellCommandLineGetValue(Package, L"-h");
- if (Temp != NULL) {
- RandomView = FALSE;
- StructHandle = (UINT16) ShellStrToUintn(Temp);
- }
-
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- Status = DisplaySmbios64BitStatisticsTable (SHOW_DETAIL);
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- goto Done;
- }
-
- //
- // Show SMBIOS structure information
- //
- Status = SMBios64View (StructType, StructHandle, gShowType, RandomView);
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- }
- }
-Done:
- //
- // Release resources
- //
- if (mStatisticsTable != NULL) {
- //
- // Release statistics table
- //
- FreePool (mStatisticsTable);
- mStatisticsTable = NULL;
- }
-
- if (mSmbios64BitStatisticsTable != NULL) {
- //
- // Release statistics table
- //
- FreePool (mSmbios64BitStatisticsTable);
- mSmbios64BitStatisticsTable = NULL;
- }
-
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
-
- LibSmbiosCleanup ();
- LibSmbios64BitCleanup ();
-
- return ShellStatus;
-}
-
-/**
- Query all structures Data from SMBIOS table and Display
- the information to users as required display option.
-
- @param[in] QueryType Structure type to view.
- @param[in] QueryHandle Structure handle to view.
- @param[in] Option Display option: none,outline,normal,detail.
- @param[in] RandomView Support for -h parameter.
-
- @retval EFI_SUCCESS print is successful.
- @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
-**/
-EFI_STATUS
-EFIAPI
-SMBiosView (
- IN UINT8 QueryType,
- IN UINT16 QueryHandle,
- IN UINT8 Option,
- IN BOOLEAN RandomView
- )
-{
- UINT16 Handle;
- UINT8 *Buffer;
- UINT16 Length;
- UINTN Index;
-
- SMBIOS_STRUCTURE_POINTER SmbiosStruct;
- SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
-
- SMBiosTable = NULL;
- LibSmbiosGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) {
- //
- // Have got SMBIOS table
- //
- SmbiosPrintEPSInfo (SMBiosTable, Option);
-
- SmbiosMajorVersion = SMBiosTable->MajorVersion;
- SmbiosMinorVersion = SMBiosTable->MinorVersion;
-
- ShellPrintEx(-1,-1,L"=========================================================\n");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), gShellDebug1HiiHandle);
-
- if (QueryType == STRUCTURE_TYPE_RANDOM) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE), gShellDebug1HiiHandle, QueryType);
- }
-
- if (RandomView) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE), gShellDebug1HiiHandle, QueryHandle);
- }
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE), gShellDebug1HiiHandle);
- ShellPrintEx(-1,-1,GetShowTypeString (gShowType));
- ShellPrintEx(-1,-1,L"\n\n");
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
-
- //
- // Searching and display structure info
- //
- Handle = QueryHandle;
- for (Index = 0; Index < SMBiosTable->NumberOfSmbiosStructures; Index++) {
- //
- // if reach the end of table, break..
- //
- if (Handle == INVALID_HANDLE) {
- break;
- }
- //
- // handle then point to the next!
- //
- if (LibGetSmbiosStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
- break;
- }
-
- SmbiosStruct.Raw = Buffer;
-
- //
- // if QueryType==Random, print this structure.
- // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
- // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
- //
- if (QueryType != STRUCTURE_TYPE_RANDOM && SmbiosStruct.Hdr->Type != QueryType) {
- continue;
- }
-
- ShellPrintEx(-1,-1,L"\n=========================================================\n");
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT),
- gShellDebug1HiiHandle,
- SmbiosStruct.Hdr->Type,
- SmbiosStruct.Hdr->Handle
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length);
- //
- // Addr of structure in structure in table
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR), gShellDebug1HiiHandle, (UINTN) Buffer);
- DumpHex (0, 0, Length, Buffer);
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
-
- if (gShowType != SHOW_NONE) {
- //
- // Print structure information
- //
- SmbiosPrintStructure (&SmbiosStruct, gShowType);
- ShellPrintEx(-1,-1,L"\n");
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
- }
- if (!RandomView) {
- break;
- }
- //
- // Support Execution Interrupt.
- //
- if (ShellGetExecutionBreakFlag ()) {
- return EFI_ABORTED;
- }
- }
-
- ShellPrintEx(-1,-1,L"\n=========================================================\n");
- return EFI_SUCCESS;
- }
-
- return EFI_BAD_BUFFER_SIZE;
-}
-
-/**
- Query all structures Data from SMBIOS table and Display
- the information to users as required display option.
-
- @param[in] QueryType Structure type to view.
- @param[in] QueryHandle Structure handle to view.
- @param[in] Option Display option: none,outline,normal,detail.
- @param[in] RandomView Support for -h parameter.
-
- @retval EFI_SUCCESS print is successful.
- @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
-**/
-EFI_STATUS
-EFIAPI
-SMBios64View (
- IN UINT8 QueryType,
- IN UINT16 QueryHandle,
- IN UINT8 Option,
- IN BOOLEAN RandomView
- )
-{
- UINT16 Handle;
- UINT8 *Buffer;
- UINT16 Length;
- UINTN Index;
- SMBIOS_STRUCTURE_POINTER SmbiosStruct;
- SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
-
- SMBiosTable = NULL;
- LibSmbios64BitGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) == 0) {
- //
- // Have got SMBIOS table
- //
- Smbios64BitPrintEPSInfo (SMBiosTable, Option);
-
- SmbiosMajorVersion = SMBiosTable->MajorVersion;
- SmbiosMinorVersion = SMBiosTable->MinorVersion;
-
- ShellPrintEx(-1,-1,L"=========================================================\n");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), gShellDebug1HiiHandle);
-
- if (QueryType == STRUCTURE_TYPE_RANDOM) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE_RANDOM), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYTYPE), gShellDebug1HiiHandle, QueryType);
- }
-
- if (RandomView) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE_RANDOM), gShellDebug1HiiHandle);
- } else {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERYHANDLE), gShellDebug1HiiHandle, QueryHandle);
- }
-
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SHOWTYPE), gShellDebug1HiiHandle);
- ShellPrintEx(-1,-1,GetShowTypeString (gShowType));
- ShellPrintEx(-1,-1,L"\n\n");
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
-
- //
- // Searching and display structure info
- //
- Handle = QueryHandle;
- for (Index = 0; Index < mNumberOfSmbios64BitStructures; Index++) {
- //
- // if reach the end of table, break..
- //
- if (Handle == INVALID_HANDLE) {
- break;
- }
- //
- // handle then point to the next!
- //
- if (LibGetSmbios64BitStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
- break;
- }
-
- SmbiosStruct.Raw = Buffer;
-
- //
- // if QueryType==Random, print this structure.
- // if QueryType!=Random, but Hdr->Type==QueryType, also print it.
- // only if QueryType != Random and Hdr->Type != QueryType, skiped it.
- //
- if (QueryType != STRUCTURE_TYPE_RANDOM && SmbiosStruct.Hdr->Type != QueryType) {
- continue;
- }
-
- ShellPrintEx(-1,-1,L"\n=========================================================\n");
- ShellPrintHiiEx(-1,-1,NULL,
- STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT),
- gShellDebug1HiiHandle,
- SmbiosStruct.Hdr->Type,
- SmbiosStruct.Hdr->Handle
- );
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length);
- //
- // Addr of structure in structure in table
- //
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ADDR), gShellDebug1HiiHandle, (UINTN) Buffer);
- DumpHex (0, 0, Length, Buffer);
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
-
- if (gShowType != SHOW_NONE) {
- //
- // Print structure information
- //
- SmbiosPrintStructure (&SmbiosStruct, gShowType);
- ShellPrintEx(-1,-1,L"\n");
-
-/*
- //
- // Get internal commands, such as change options.
- //
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
-*/
- }
- if (!RandomView) {
- break;
- }
- //
- // Support Execution Interrupt.
- //
- if (ShellGetExecutionBreakFlag ()) {
- return EFI_ABORTED;
- }
- }
-
- ShellPrintEx(-1,-1,L"\n=========================================================\n");
- return EFI_SUCCESS;
- }
-
- return EFI_BAD_BUFFER_SIZE;
-}
-
-/**
- Function to initialize the global mStatisticsTable object.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-InitSmbiosTableStatistics (
- VOID
- )
-{
- UINT16 Handle;
- UINT8 *Buffer;
- UINT16 Length;
- UINT16 Offset;
- UINT16 Index;
-
- SMBIOS_STRUCTURE_POINTER SmbiosStruct;
- SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
- STRUCTURE_STATISTICS *StatisticsPointer;
-
- SMBiosTable = NULL;
- LibSmbiosGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_NOT_FOUND;
- }
-
- if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
- return EFI_INVALID_PARAMETER;
- }
- //
- // Allocate memory to mStatisticsTable
- //
- if (mStatisticsTable != NULL) {
- FreePool (mStatisticsTable);
- mStatisticsTable = NULL;
- }
-
- mStatisticsTable = (STRUCTURE_STATISTICS *) AllocateZeroPool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS));
-
- if (mStatisticsTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle);
- return EFI_OUT_OF_RESOURCES;
- }
-
- Offset = 0;
- StatisticsPointer = mStatisticsTable;
-
- //
- // search from the first one
- //
- Handle = INVALID_HANDLE;
- LibGetSmbiosStructure (&Handle, NULL, NULL);
- for (Index = 1; Index <= SMBiosTable->NumberOfSmbiosStructures; Index++) {
- //
- // If reach the end of table, break..
- //
- if (Handle == INVALID_HANDLE) {
- break;
- }
- //
- // After LibGetSmbiosStructure(), handle then point to the next!
- //
- if (LibGetSmbiosStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
- break;
- }
-
- SmbiosStruct.Raw = Buffer;
-
- //
- // general statistics
- //
- StatisticsPointer->Index = Index;
- StatisticsPointer->Type = SmbiosStruct.Hdr->Type;
- StatisticsPointer->Handle = SmbiosStruct.Hdr->Handle;
- StatisticsPointer->Length = Length;
- StatisticsPointer->Addr = Offset;
-
- Offset = (UINT16) (Offset + Length);
-
- StatisticsPointer = &mStatisticsTable[Index];
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- @param[in] Smbios64EntryPoint SMBIOS 64-bit entry point.
- @param[out] NumberOfSmbios64Structures The number of structures in 64-bit SMBIOS table.
- @param[out] Smbios64TableLength The total length of 64-bit SMBIOS table.
-
- @retval EFI_SUCCESS Calculation was successful.
-**/
-EFI_STATUS
-EFIAPI
-CalculateSmbios64BitStructureCountAndLength (
- SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios64EntryPoint,
- UINTN *NumberOfSmbios64Structures,
- UINTN *Smbios64TableLength
-)
-{
- SMBIOS_STRUCTURE_POINTER Smbios;
- UINT8 *Raw;
-
- *Smbios64TableLength = 0;
- *NumberOfSmbios64Structures = 0;
-
- Smbios.Raw = (UINT8 *)(UINTN)(Smbios64EntryPoint->TableAddress);
- while (TRUE) {
- if (Smbios.Hdr->Type == 127) {
- //
- // Reach the end of table type 127
- //
- (*NumberOfSmbios64Structures)++;
- (*Smbios64TableLength) += sizeof (SMBIOS_STRUCTURE);
- return EFI_SUCCESS;
- }
-
- Raw = Smbios.Raw;
- //
- // Walk to next structure
- //
- LibGetSmbiosString (&Smbios, (UINT16) (-1));
- //
- // Length = Next structure head - this structure head
- //
- (*Smbios64TableLength) += (UINTN) (Smbios.Raw - Raw);
- if ((*Smbios64TableLength) > Smbios64EntryPoint->TableMaximumSize) {
- //
- // The actual table length exceeds maximum table size,
- // There should be something wrong with SMBIOS table.
- //
- return EFI_INVALID_PARAMETER;
- }
- (*NumberOfSmbios64Structures)++;
- }
-}
-
-/**
- Function to initialize the global mSmbios64BitStatisticsTable object.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-InitSmbios64BitTableStatistics (
- VOID
- )
-{
- UINT16 Handle;
- UINT8 *Buffer;
- UINT16 Length;
- UINT16 Offset;
- UINT16 Index;
- EFI_STATUS Status;
- SMBIOS_STRUCTURE_POINTER SmbiosStruct;
- SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
- STRUCTURE_STATISTICS *StatisticsPointer;
-
- SMBiosTable = NULL;
- LibSmbios64BitGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_NOT_FOUND;
- }
-
- if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) != 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
- return EFI_INVALID_PARAMETER;
- }
- //
- // Allocate memory to mSmbios64BitStatisticsTable
- //
- if (mSmbios64BitStatisticsTable != NULL) {
- FreePool (mSmbios64BitStatisticsTable);
- mSmbios64BitStatisticsTable = NULL;
- }
- //
- // Calculate number of smbios structures
- //
- Status = CalculateSmbios64BitStructureCountAndLength (SMBiosTable, &mNumberOfSmbios64BitStructures, &mSmbios64BitTableLength);
- if ((EFI_ERROR (Status)) || (mSmbios64BitTableLength > SMBiosTable->TableMaximumSize)) {
- return EFI_INVALID_PARAMETER;
- }
-
- mSmbios64BitStatisticsTable = (STRUCTURE_STATISTICS *) AllocateZeroPool (mNumberOfSmbios64BitStructures * sizeof (STRUCTURE_STATISTICS));
-
- if (mSmbios64BitStatisticsTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle);
- return EFI_OUT_OF_RESOURCES;
- }
-
- Offset = 0;
- StatisticsPointer = mSmbios64BitStatisticsTable;
-
- //
- // search from the first one
- //
- Handle = INVALID_HANDLE;
- LibGetSmbios64BitStructure (&Handle, NULL, NULL);
- for (Index = 1; Index <= mNumberOfSmbios64BitStructures; Index++) {
- //
- // If reach the end of table, break..
- //
- if (Handle == INVALID_HANDLE) {
- break;
- }
- //
- // After LibGetSmbios64BitStructure(), handle then point to the next!
- //
- if (LibGetSmbios64BitStructure (&Handle, &Buffer, &Length) != DMI_SUCCESS) {
- break;
- }
-
- SmbiosStruct.Raw = Buffer;
-
- //
- // general statistics
- //
- StatisticsPointer->Index = Index;
- StatisticsPointer->Type = SmbiosStruct.Hdr->Type;
- StatisticsPointer->Handle = SmbiosStruct.Hdr->Handle;
- StatisticsPointer->Length = Length;
- StatisticsPointer->Addr = Offset;
-
- Offset = (UINT16) (Offset + Length);
-
- StatisticsPointer = &mSmbios64BitStatisticsTable[Index];
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to display the global mStatisticsTable object.
-
- @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-DisplayStatisticsTable (
- IN UINT8 Option
- )
-{
- UINTN Index;
- UINTN Num;
- STRUCTURE_STATISTICS *StatisticsPointer;
- SMBIOS_TABLE_ENTRY_POINT *SMBiosTable;
-
- SMBiosTable = NULL;
- if (Option < SHOW_OUTLINE) {
- return EFI_SUCCESS;
- }
- //
- // display EPS information firstly
- //
- LibSmbiosGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_UNSUPPORTED;
- }
-
- ShellPrintEx(-1,-1,L"\n============================================================\n");
- SmbiosPrintEPSInfo (SMBiosTable, Option);
-
- if (Option < SHOW_NORMAL) {
- return EFI_SUCCESS;
- }
-
- if (mStatisticsTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS), gShellDebug1HiiHandle);
- return EFI_NOT_FOUND;
- }
-
- ShellPrintEx(-1,-1,L"============================================================\n");
- StatisticsPointer = &mStatisticsTable[0];
- Num = SMBiosTable->NumberOfSmbiosStructures;
- //
- // display statistics table content
- //
- for (Index = 1; Index <= Num; Index++) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);
- if (Option >= SHOW_DETAIL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);
- }
-
- ShellPrintEx(-1,-1,L"\n");
- StatisticsPointer = &mStatisticsTable[Index];
-/*
- //
- // Display 20 lines and wait for a page break
- //
- if (Index % 20 == 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
- }
-*/
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to display the global mSmbios64BitStatisticsTable object.
-
- @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-DisplaySmbios64BitStatisticsTable (
- IN UINT8 Option
- )
-{
- UINTN Index;
- UINTN Num;
- STRUCTURE_STATISTICS *StatisticsPointer;
- SMBIOS_TABLE_3_0_ENTRY_POINT *SMBiosTable;
-
- SMBiosTable = NULL;
- if (Option < SHOW_OUTLINE) {
- return EFI_SUCCESS;
- }
- //
- // display EPS information firstly
- //
- LibSmbios64BitGetEPS (&SMBiosTable);
- if (SMBiosTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_TABLE), gShellDebug1HiiHandle);
- return EFI_UNSUPPORTED;
- }
-
- ShellPrintEx(-1,-1,L"\n============================================================\n");
- Smbios64BitPrintEPSInfo (SMBiosTable, Option);
-
- if (Option < SHOW_NORMAL) {
- return EFI_SUCCESS;
- }
-
- if (mSmbios64BitStatisticsTable == NULL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_CANNOT_ACCESS_STATS), gShellDebug1HiiHandle);
- return EFI_NOT_FOUND;
- }
-
- ShellPrintEx(-1,-1,L"============================================================\n");
- StatisticsPointer = &mSmbios64BitStatisticsTable[0];
- Num = mNumberOfSmbios64BitStructures;
- //
- // display statistics table content
- //
- for (Index = 1; Index <= Num; Index++) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);
- if (Option >= SHOW_DETAIL) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);
- }
-
- ShellPrintEx(-1,-1,L"\n");
- StatisticsPointer = &mSmbios64BitStatisticsTable[Index];
-/*
- //
- // Display 20 lines and wait for a page break
- //
- if (Index % 20 == 0) {
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTER_CONTINUE), gShellDebug1HiiHandle);
- Status = WaitEnter ();
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- return Status;
- }
- }
-*/
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- function to return a string of the detail level.
-
- @param[in] ShowType The detail level whose name is desired in clear text.
-
- @return A pointer to a string representing the ShowType (or 'undefined type' if not known).
-**/
-CHAR16 *
-EFIAPI
-GetShowTypeString (
- UINT8 ShowType
- )
-{
- //
- // show type
- //
- switch (ShowType) {
-
- case SHOW_NONE:
- return L"SHOW_NONE";
-
- case SHOW_OUTLINE:
- return L"SHOW_OUTLINE";
-
- case SHOW_NORMAL:
- return L"SHOW_NORMAL";
-
- case SHOW_DETAIL:
- return L"SHOW_DETAIL";
-
- case SHOW_ALL:
- return L"SHOW_ALL";
-
- default:
- return L"Undefined type";
- }
-}
-
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.h
deleted file mode 100644
index 647fd5fe26..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/** @file
- Tools of clarify the content of the smbios table.
-
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _SMBIOS_VIEW_H_
-#define _SMBIOS_VIEW_H_
-
-#define STRUCTURE_TYPE_RANDOM (UINT8) 0xFE
-#define STRUCTURE_TYPE_INVALID (UINT8) 0xFF
-
-typedef struct {
- UINT16 Index;
- UINT8 Type;
- UINT16 Handle;
- UINT16 Addr; // offset from table head
- UINT16 Length; // total structure length
-} STRUCTURE_STATISTICS;
-
-/**
- Query all structures Data from SMBIOS table and Display
- the information to users as required display option.
-
- @param[in] QueryType Structure type to view.
- @param[in] QueryHandle Structure handle to view.
- @param[in] Option Display option: none,outline,normal,detail.
- @param[in] RandomView Support for -h parameter.
-
- @retval EFI_SUCCESS print is successful.
- @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
-**/
-EFI_STATUS
-EFIAPI
-SMBiosView (
- IN UINT8 QueryType,
- IN UINT16 QueryHandle,
- IN UINT8 Option,
- IN BOOLEAN RandomView
- );
-
-/**
- Query all structures Data from SMBIOS table and Display
- the information to users as required display option.
-
- @param[in] QueryType Structure type to view.
- @param[in] QueryHandle Structure handle to view.
- @param[in] Option Display option: none,outline,normal,detail.
- @param[in] RandomView Support for -h parameter.
-
- @retval EFI_SUCCESS print is successful.
- @retval EFI_BAD_BUFFER_SIZE structure is out of the range of SMBIOS table.
-**/
-EFI_STATUS
-EFIAPI
-SMBios64View (
- IN UINT8 QueryType,
- IN UINT16 QueryHandle,
- IN UINT8 Option,
- IN BOOLEAN RandomView
- );
-
-/**
- Function to initialize the global mStatisticsTable object.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-InitSmbiosTableStatistics (
- VOID
- );
-
-/**
- Function to initialize the global mSmbios64BitStatisticsTable object.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-InitSmbios64BitTableStatistics (
- VOID
- );
-
-/**
- Function to display the global mStatisticsTable object.
-
- @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-DisplayStatisticsTable (
- IN UINT8 Option
- );
-
-/**
- Function to display the global mSmbios64BitStatisticsTable object.
-
- @param[in] Option ECHO, NORMAL, or DETAIL control the amount of detail displayed.
-
- @retval EFI_SUCCESS print is successful.
-**/
-EFI_STATUS
-EFIAPI
-DisplaySmbios64BitStatisticsTable (
- IN UINT8 Option
- );
-
-/**
- function to return a string of the detail level.
-
- @param[in] ShowType The detail level whose name is desired in clear text.
-
- @return A pointer to a string representing the ShowType (or 'undefined type' if not known).
-**/
-CHAR16*
-EFIAPI
-GetShowTypeString (
- UINT8 ShowType
- );
-
-extern UINT8 gShowType;
-
-extern UINTN mSmbios64BitTableLength;
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
deleted file mode 100644
index f36882573a..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
deleted file mode 100644
index 5f8f8a9dd9..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
+++ /dev/null
@@ -1,644 +0,0 @@
-/** @file
- Main file for NULL named library for debug1 profile shell command functions.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDebug1CommandsLib.h"
-#include <Library/BcfgCommandLib.h>
-
-STATIC CONST CHAR16 mFileName[] = L"Debug1Commands";
-EFI_HANDLE gShellDebug1HiiHandle = NULL;
-
-/**
- Gets the debug file name. This will be used if HII is not working.
-
- @retval NULL No file is available.
- @return The NULL-terminated filename to get help from.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameDebug1 (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Debug1 Commands library.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-UefiShellDebug1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT1) == 0) {
- return (EFI_SUCCESS);
- }
-
- //
- // install the HII stuff.
- //
- gShellDebug1HiiHandle = HiiAddPackages (&gShellDebug1HiiGuid, gImageHandle, UefiShellDebug1CommandsLibStrings, NULL);
- if (gShellDebug1HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"setsize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) );
- ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) );
- ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) );
- ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) );
- ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) );
- ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) );
- ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) );
- ShellCommandRegisterCommandName(L"loadpcirom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) );
- ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) );
- ShellCommandRegisterCommandName(L"setvar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) );
- ShellCommandRegisterCommandName(L"sermode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) );
- ShellCommandRegisterCommandName(L"pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) );
- ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) );
- ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) );
- ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) );
- ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) );
- ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT) );
-
- ShellCommandRegisterAlias(L"dmem", L"mem");
-
- BcfgLibraryRegisterBcfgCommand(ImageHandle, SystemTable, L"Debug1");
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-UefiShellDebug1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellDebug1HiiHandle != NULL) {
- HiiRemovePackages(gShellDebug1HiiHandle);
- }
-
- BcfgLibraryUnregisterBcfgCommand(ImageHandle, SystemTable);
- return (EFI_SUCCESS);
-}
-
-STATIC CONST CHAR8 Hex[] = {
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- 'A',
- 'B',
- 'C',
- 'D',
- 'E',
- 'F'
-};
-
-/**
- Dump some hexadecimal data to the screen.
-
- @param[in] Indent How many spaces to indent the output.
- @param[in] Offset The offset of the printing.
- @param[in] DataSize The size in bytes of UserData.
- @param[in] UserData The data to print out.
-**/
-VOID
-DumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
- )
-{
- UINT8 *Data;
-
- CHAR8 Val[50];
-
- CHAR8 Str[20];
-
- UINT8 TempByte;
- UINTN Size;
- UINTN Index;
-
- Data = UserData;
- while (DataSize != 0) {
- Size = 16;
- if (Size > DataSize) {
- Size = DataSize;
- }
-
- for (Index = 0; Index < Size; Index += 1) {
- TempByte = Data[Index];
- Val[Index * 3 + 0] = Hex[TempByte >> 4];
- Val[Index * 3 + 1] = Hex[TempByte & 0xF];
- Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
- Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
- }
-
- Val[Index * 3] = 0;
- Str[Index] = 0;
- ShellPrintEx(-1, -1, L"%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str);
-
- Data += Size;
- Offset += Size;
- DataSize -= Size;
- }
-}
-
-/**
- Convert a Unicode character to upper case only if
- it maps to a valid small-case ASCII character.
-
- This internal function only deal with Unicode character
- which maps to a valid small-case ASCII character, i.e.
- L'a' to L'z'. For other Unicode character, the input character
- is returned directly.
-
- @param Char The character to convert.
-
- @retval LowerCharacter If the Char is with range L'a' to L'z'.
- @retval Unchanged Otherwise.
-
-
- //Stolen from MdePkg Baselib
-**/
-CHAR16
-EFIAPI
-CharToUpper (
- IN CHAR16 Char
- )
-{
- if (Char >= L'a' && Char <= L'z') {
- return (CHAR16) (Char - (L'a' - L'A'));
- }
-
- return Char;
-}
-
-/**
- Function returns a system configuration table that is stored in the
- EFI System Table based on the provided GUID.
-
- @param[in] TableGuid A pointer to the table's GUID type.
- @param[in, out] Table On exit, a pointer to a system configuration table.
-
- @retval EFI_SUCCESS A configuration table matching TableGuid was found.
- @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.
-**/
-EFI_STATUS
-EFIAPI
-GetSystemConfigurationTable (
- IN EFI_GUID *TableGuid,
- IN OUT VOID **Table
- )
-{
- UINTN Index;
- ASSERT (Table != NULL);
-
- for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
- if (CompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
- *Table = gST->ConfigurationTable[Index].VendorTable;
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- Convert a Unicode character to numerical value.
-
- This internal function only deal with Unicode character
- which maps to a valid hexadecimal ASII character, i.e.
- L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
- Unicode character, the value returned does not make sense.
-
- @param Char The character to convert.
-
- @return The numerical value converted.
-
-**/
-UINTN
-EFIAPI
-HexCharToUintn (
- IN CHAR16 Char
- )
-{
- if (Char >= L'0' && Char <= L'9') {
- return Char - L'0';
- }
-
- return (UINTN) (10 + CharToUpper (Char) - L'A');
-}
-
-/**
- Convert a string representation of a guid to a Guid value.
-
- @param[in] StringGuid The pointer to the string of a guid.
- @param[in, out] Guid The pointer to the GUID structure to populate.
-
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_SUCCESS The conversion was successful.
-**/
-EFI_STATUS
-EFIAPI
-ConvertStringToGuid (
- IN CONST CHAR16 *StringGuid,
- IN OUT EFI_GUID *Guid
- )
-{
- CHAR16 *TempCopy;
- CHAR16 *TempSpot;
- CHAR16 *Walker;
- UINT64 TempVal;
- EFI_STATUS Status;
-
- if (StringGuid == NULL) {
- return (EFI_INVALID_PARAMETER);
- } else if (StrLen(StringGuid) != 36) {
- return (EFI_INVALID_PARAMETER);
- }
- TempCopy = NULL;
- TempCopy = StrnCatGrow(&TempCopy, NULL, StringGuid, 0);
- if (TempCopy == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Walker = TempCopy;
- TempSpot = StrStr(Walker, L"-");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- FreePool(TempCopy);
- return (Status);
- }
- Guid->Data1 = (UINT32)TempVal;
- Walker += 9;
- TempSpot = StrStr(Walker, L"-");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- FreePool(TempCopy);
- return (Status);
- }
- Guid->Data2 = (UINT16)TempVal;
- Walker += 5;
- TempSpot = StrStr(Walker, L"-");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- FreePool(TempCopy);
- return (Status);
- }
- Guid->Data3 = (UINT16)TempVal;
- Walker += 5;
- Guid->Data4[0] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[0] = (UINT8)(Guid->Data4[0]+ (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[1] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[1] = (UINT8)(Guid->Data4[1] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 3;
- Guid->Data4[2] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[2] = (UINT8)(Guid->Data4[2] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[3] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[3] = (UINT8)(Guid->Data4[3] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[4] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[4] = (UINT8)(Guid->Data4[4] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[5] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[5] = (UINT8)(Guid->Data4[5] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[6] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[6] = (UINT8)(Guid->Data4[6] + (UINT8)HexCharToUintn(Walker[1]));
- Walker += 2;
- Guid->Data4[7] = (UINT8)(HexCharToUintn(Walker[0]) * 16);
- Guid->Data4[7] = (UINT8)(Guid->Data4[7] + (UINT8)HexCharToUintn(Walker[1]));
- FreePool(TempCopy);
- return (EFI_SUCCESS);
-}
-
-/**
- Clear the line at the specified Row.
-
- @param[in] Row The row number to be cleared ( start from 1 )
- @param[in] LastCol The last printable column.
- @param[in] LastRow The last printable row.
-**/
-VOID
-EFIAPI
-EditorClearLine (
- IN UINTN Row,
- IN UINTN LastCol,
- IN UINTN LastRow
- )
-{
- CHAR16 Line[200];
-
- if (Row == 0) {
- Row = 1;
- }
-
- //
- // prepare a blank line
- //
- SetMem16(Line, LastCol*sizeof(CHAR16), L' ');
-
- if (Row == LastRow) {
- //
- // if CHAR_NULL is still at position 80, it will cause first line error
- //
- Line[LastCol - 1] = CHAR_NULL;
- } else {
- Line[LastCol] = CHAR_NULL;
- }
-
- //
- // print out the blank line
- //
- ShellPrintEx (0, ((INT32)Row) - 1, Line);
-}
-
-/**
- Determine if the character is valid for a filename.
-
- @param[in] Ch The character to test.
-
- @retval TRUE The character is valid.
- @retval FALSE The character is not valid.
-**/
-BOOLEAN
-EFIAPI
-IsValidFileNameChar (
- IN CONST CHAR16 Ch
- )
-{
- //
- // See if there are any illegal characters within the name
- //
- if (Ch < 0x20 || Ch == L'\"' || Ch == L'*' || Ch == L'/' || Ch == L'<' || Ch == L'>' || Ch == L'?' || Ch == L'|') {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- Check if file name has illegal characters.
-
- @param Name The filename to check.
-
- @retval TRUE The filename is ok.
- @retval FALSE The filename is not ok.
-**/
-BOOLEAN
-EFIAPI
-IsValidFileName (
- IN CONST CHAR16 *Name
- )
-{
-
- UINTN Index;
- UINTN Len;
-
- //
- // check the length of Name
- //
- for (Len = 0, Index = StrLen (Name) - 1; Index + 1 != 0; Index--, Len++) {
- if (Name[Index] == '\\' || Name[Index] == ':') {
- break;
- }
- }
-
- if (Len == 0 || Len > 255) {
- return FALSE;
- }
- //
- // check whether any char in Name not appears in valid file name char
- //
- for (Index = 0; Index < StrLen (Name); Index++) {
- if (!IsValidFileNameChar (Name[Index])) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/**
- Find a filename that is valid (not taken) with the given extension.
-
- @param[in] Extension The file extension.
-
- @retval NULL Something went wrong.
- @return the valid filename.
-**/
-CHAR16 *
-EFIAPI
-EditGetDefaultFileName (
- IN CONST CHAR16 *Extension
- )
-{
- EFI_STATUS Status;
- UINTN Suffix;
- CHAR16 *FileNameTmp;
-
- Suffix = 0;
-
- do {
- FileNameTmp = CatSPrint (NULL, L"NewFile%d.%s", Suffix, Extension);
-
- //
- // after that filename changed to path
- //
- Status = ShellFileExists (FileNameTmp);
-
- if (Status == EFI_NOT_FOUND) {
- return FileNameTmp;
- }
-
- FreePool (FileNameTmp);
- FileNameTmp = NULL;
- Suffix++;
- } while (Suffix != 0);
-
- FreePool (FileNameTmp);
- return NULL;
-}
-
-/**
- Read a file into an allocated buffer. The buffer is the responsibility
- of the caller to free.
-
- @param[in] FileName The filename of the file to open.
- @param[out] Buffer Upon successful return, the pointer to the
- address of the allocated buffer.
- @param[out] BufferSize If not NULL, then the pointer to the size
- of the allocated buffer.
- @param[out] ReadOnly Upon successful return TRUE if the file is
- read only. FALSE otherwise.
-
- @retval EFI_NOT_FOUND The filename did not represent a file in the
- file system.
- @retval EFI_SUCCESS The file was read into the buffer.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR The file read operation failed.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_INVALID_PARAMETER FileName was NULL.
- @retval EFI_INVALID_PARAMETER FileName was a directory.
-**/
-EFI_STATUS
-EFIAPI
-ReadFileIntoBuffer (
- IN CONST CHAR16 *FileName,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize OPTIONAL,
- OUT BOOLEAN *ReadOnly
- )
-{
- VOID *InternalBuffer;
- UINTN FileSize;
- SHELL_FILE_HANDLE FileHandle;
- BOOLEAN CreateFile;
- EFI_STATUS Status;
- EFI_FILE_INFO *Info;
-
- InternalBuffer = NULL;
- FileSize = 0;
- FileHandle = NULL;
- CreateFile = FALSE;
- Status = EFI_SUCCESS;
- Info = NULL;
-
- if (FileName == NULL || Buffer == NULL || ReadOnly == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // try to open the file
- //
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
-
- if (!EFI_ERROR(Status)) {
- ASSERT(CreateFile == FALSE);
- if (FileHandle == NULL) {
- return EFI_LOAD_ERROR;
- }
-
- Info = ShellGetFileInfo(FileHandle);
-
- if (Info->Attribute & EFI_FILE_DIRECTORY) {
- FreePool (Info);
- return EFI_INVALID_PARAMETER;
- }
-
- if (Info->Attribute & EFI_FILE_READ_ONLY) {
- *ReadOnly = TRUE;
- } else {
- *ReadOnly = FALSE;
- }
- //
- // get file size
- //
- FileSize = (UINTN) Info->FileSize;
-
- FreePool (Info);
- } else if (Status == EFI_NOT_FOUND) {
- //
- // file not exists. add create and try again
- //
- Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR (Status)) {
- return Status;
- } else {
- //
- // it worked. now delete it and move on with the name (now validated)
- //
- Status = ShellDeleteFile (&FileHandle);
- if (Status == EFI_WARN_DELETE_FAILURE) {
- Status = EFI_ACCESS_DENIED;
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
- //
- // file doesn't exist, so set CreateFile to TRUE and can't be read-only
- //
- CreateFile = TRUE;
- *ReadOnly = FALSE;
- }
-
- //
- // the file exists
- //
- if (!CreateFile) {
- //
- // allocate buffer to read file
- //
- InternalBuffer = AllocateZeroPool (FileSize);
- if (InternalBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // read file into InternalBuffer
- //
- Status = ShellReadFile (FileHandle, &FileSize, InternalBuffer);
- ShellCloseFile(&FileHandle);
- FileHandle = NULL;
- if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL (InternalBuffer);
- return EFI_LOAD_ERROR;
- }
- }
- *Buffer = InternalBuffer;
- if (BufferSize != NULL) {
- *BufferSize = FileSize;
- }
- return (EFI_SUCCESS);
-
-}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h
deleted file mode 100644
index d8755bfefc..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h
+++ /dev/null
@@ -1,436 +0,0 @@
-/** @file
- Main file for NULL named library for Profile1 shell command functions.
-
- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_
-#define _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/GlobalVariable.h>
-#include <Guid/ConsoleInDevice.h>
-#include <Guid/ConsoleOutDevice.h>
-#include <Guid/FileSystemInfo.h>
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/DriverDiagnostics2.h>
-#include <Protocol/DriverDiagnostics.h>
-#include <Protocol/PlatformDriverOverride.h>
-#include <Protocol/BusSpecificDriverOverride.h>
-#include <Protocol/PlatformToDriverConfiguration.h>
-#include <Protocol/DriverSupportedEfiVersion.h>
-#include <Protocol/DriverFamilyOverride.h>
-#include <Protocol/DriverHealth.h>
-#include <Protocol/SimplePointer.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HandleParsingLib.h>
-
-
-extern EFI_HANDLE gShellDebug1HiiHandle;
-
-/**
- Function printing hex output to the console.
-
- @param[in] Indent Number of spaces to indent.
- @param[in] Offset Offset to start with.
- @param[in] DataSize Length of data.
- @param[in] UserData Pointer to some data.
-**/
-VOID
-DumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
- );
-
-/**
- Function returns a system configuration table that is stored in the
- EFI System Table based on the provided GUID.
-
- @param[in] TableGuid A pointer to the table's GUID type.
- @param[in, out] Table On exit, a pointer to a system configuration table.
-
- @retval EFI_SUCCESS A configuration table matching TableGuid was found.
- @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.
-**/
-EFI_STATUS
-EFIAPI
-GetSystemConfigurationTable (
- IN EFI_GUID *TableGuid,
- IN OUT VOID **Table
- );
-
-/**
- Convert a string representation of a GUID to the GUID value.
-
- @param[in] StringGuid The pointer to the string containing a GUID printed.
- @param[in, out] Guid The pointer to the buffer to get the GUID value.
-**/
-EFI_STATUS
-EFIAPI
-ConvertStringToGuid (
- IN CONST CHAR16 *StringGuid,
- IN OUT EFI_GUID *Guid
- );
-
-/**
- Convert a Unicode character to numerical value.
-
- This internal function only deal with Unicode character
- which maps to a valid hexadecimal ASII character, i.e.
- L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
- Unicode character, the value returned does not make sense.
-
- @param Char The character to convert.
-
- @return The numerical value converted.
-
-**/
-UINTN
-EFIAPI
-HexCharToUintn (
- IN CHAR16 Char
- );
-
-/**
- Function for 'setsize' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSetSize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'comp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunComp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'mode' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMode (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'memmap' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMemMap (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'compress' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEfiCompress (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'decompress' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEfiDecompress (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'dmem' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDmem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'loadpcirom' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLoadPciRom (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'mm' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMm (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'setvar' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSetVar (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'sermode' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSerMode (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'bcfg' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunBcfg (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'pci' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPci (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'smbiosview' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSmbiosView (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'dmpstore' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDmpStore (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'dblk' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDblk (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'edit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEdit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'hexedit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunHexEdit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Clear the line at the specified Row.
-
- @param[in] Row The row number to be cleared ( start from 1 )
- @param[in] LastCol The last printable column.
- @param[in] LastRow The last printable row.
-**/
-VOID
-EFIAPI
-EditorClearLine (
- IN UINTN Row,
- IN UINTN LastCol,
- IN UINTN LastRow
- );
-
-/**
- Check if file name has illegal characters.
-
- @param Name The filename to check.
-
- @retval TRUE The filename is ok.
- @retval FALSE The filename is not ok.
-**/
-BOOLEAN
-EFIAPI
-IsValidFileName (
- IN CONST CHAR16 *Name
- );
-
-/**
- Find a filename that is valid (not taken) with the given extension.
-
- @param[in] Extension The file extension.
-
- @retval NULL Something went wrong.
- @return the valid filename.
-**/
-CHAR16 *
-EFIAPI
-EditGetDefaultFileName (
- IN CONST CHAR16 *Extension
- );
-
-/**
- Read a file into an allocated buffer. The buffer is the responsibility
- of the caller to free.
-
- @param[in] FileName The filename of the file to open.
- @param[out] Buffer Upon successful return, the pointer to the
- address of the allocated buffer.
- @param[out] BufferSize If not NULL, then the pointer to the size
- of the allocated buffer.
- @param[out] ReadOnly Upon successful return TRUE if the file is
- read only. FALSE otherwise.
-
- @retval EFI_NOT_FOUND The filename did not represent a file in the
- file system. Directories cannot be read with
- this method.
- @retval EFI_SUCCESS The file was read into the buffer.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_LOAD_ERROR The file read operation failed.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_INVALID_PARAMETER FileName was NULL.
- @retval EFI_INVALID_PARAMETER FileName was a directory.
-**/
-EFI_STATUS
-EFIAPI
-ReadFileIntoBuffer (
- IN CONST CHAR16 *FileName,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize OPTIONAL,
- OUT BOOLEAN *ReadOnly
- );
-
-#endif
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
deleted file mode 100644
index 55371eb371..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+++ /dev/null
@@ -1,137 +0,0 @@
-## @file
-# Provides shell Debug1 profile functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellDebug1CommandsLib
- FILE_GUID = 90330D51-A99B-4cc8-A2EB-AE22542A3F45
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = UefiShellDebug1CommandsLibConstructor
- DESTRUCTOR = UefiShellDebug1CommandsLibDestructor
-
-[Sources]
- SetSize.c
- Comp.c
- Mode.c
- MemMap.c
- Compress.h
- Compress.c
- EfiCompress.c
- EfiDecompress.c
- Dmem.c
- LoadPciRom.c
- Mm.c
- SetVar.c
- SerMode.c
- Pci.c
- Pci.h
- DmpStore.c
- Dblk.c
- SmbiosView/EventLogInfo.c
- SmbiosView/EventLogInfo.h
- SmbiosView/PrintInfo.c
- SmbiosView/QueryTable.c
- SmbiosView/SmbiosView.c
- SmbiosView/SmbiosViewStrings.uni
- SmbiosView/LibSmbiosView.c
- SmbiosView/PrintInfo.h
- SmbiosView/LibSmbiosView.h
- SmbiosView/QueryTable.h
- SmbiosView/SmbiosView.h
- UefiShellDebug1CommandsLib.c
- UefiShellDebug1CommandsLib.h
- UefiShellDebug1CommandsLib.uni
-
-## Files shared by both editors
- EditTitleBar.h
- EditTitleBar.c
- EditInputBar.h
- EditInputBar.c
- EditStatusBar.h
- EditStatusBar.c
- EditMenuBar.h
- EditMenuBar.c
-
-## Files specific to the text editor
- Edit/Edit.c
- Edit/TextEditor.h
- Edit/TextEditorTypes.h
- Edit/FileBuffer.h
- Edit/FileBuffer.c
- Edit/MainTextEditor.h
- Edit/MainTextEditor.c
- Edit/Misc.h
- Edit/Misc.c
- Edit/TextEditStrings.uni
-
-## Files specific to the HEX editor
- HexEdit/BufferImage.h
- HexEdit/BufferImage.c
- HexEdit/Clipboard.h
- HexEdit/Clipboard.c
- HexEdit/DiskImage.h
- HexEdit/DiskImage.c
- HexEdit/FileImage.h
- HexEdit/FileImage.c
- HexEdit/HexEdit.c
- HexEdit/HexEditor.h
- HexEdit/HexEditorTypes.h
- HexEdit/HexeditStrings.uni
- HexEdit/MainHexEditor.h
- HexEdit/MainHexEditor.c
- HexEdit/MemImage.h
- HexEdit/MemImage.c
- HexEdit/Misc.h
- HexEdit/Misc.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
- BcfgCommandLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## CONSUMES
-
-[Protocols]
- gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
- gEfiBlockIoProtocolGuid ## CONSUMES
- gEfiSimplePointerProtocolGuid ## CONSUMES
-
-[Guids]
- gEfiGlobalVariableGuid ## SOMETIMES_CONSUMES ## GUID
- gEfiSmbiosTableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gEfiSmbios3TableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gEfiMpsTableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gEfiSalSystemTableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable
- gShellDebug1HiiGuid ## SOMETIMES_CONSUMES ## HII
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
deleted file mode 100644
index e16175a617..0000000000
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
deleted file mode 100644
index 5d61c2f601..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/** @file
- Main file for connect shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-/**
- Create all handles associate with every device path node.
-
- @param DevicePathToConnect The device path which will be connected.
-
- @retval EFI_SUCCESS All handles associate with every device path node
- have been created.
- @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.
- @retval EFI_NOT_FOUND Create the handle associate with one device path
- node failed
-
-**/
-EFI_STATUS
-ShellConnectDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_HANDLE PreviousHandle;
-
- if (DevicePathToConnect == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- PreviousHandle = NULL;
- do{
- RemainingDevicePath = DevicePathToConnect;
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
-
- if (!EFI_ERROR (Status) && (Handle != NULL)) {
- if (PreviousHandle == Handle) {
- Status = EFI_NOT_FOUND;
- } else {
- PreviousHandle = Handle;
- Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
- }
- }
-
- } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath) );
-
- return Status;
-
-}
-
-/**
- Connect drivers for PCI root bridge.
-
- @retval EFI_SUCCESS Connect drivers successfully.
- @retval EFI_NOT_FOUND Cannot find PCI root bridge device.
-
-**/
-EFI_STATUS
-ShellConnectPciRootBridge (
- VOID
- )
-{
- UINTN RootBridgeHandleCount;
- EFI_HANDLE *RootBridgeHandleBuffer;
- UINTN RootBridgeIndex;
- EFI_STATUS Status;
-
- RootBridgeHandleCount = 0;
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &RootBridgeHandleCount,
- &RootBridgeHandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
- gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, FALSE);
- }
-
- FreePool (RootBridgeHandleBuffer);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Connect controller(s) and driver(s).
-
- @param[in] ControllerHandle The handle to the controller. Should have driver binding on it.
- @param[in] DriverHandle The handle to the driver. Should have driver binding.
- @param[in] Recursive TRUE to connect recursively, FALSE otherwise.
- @param[in] Output TRUE to have info on the screen, FALSE otherwise.
- @param[in] AlwaysOutput Override Output for errors.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ConnectControllers (
- IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
- IN CONST EFI_HANDLE DriverHandle OPTIONAL,
- IN CONST BOOLEAN Recursive,
- IN CONST BOOLEAN Output,
- IN CONST BOOLEAN AlwaysOutput
- )
-{
- EFI_STATUS Status;
- EFI_STATUS Status2;
- EFI_HANDLE *ControllerHandleList;
- EFI_HANDLE *DriverHandleList;
- EFI_HANDLE *HandleWalker;
-
- ControllerHandleList = NULL;
- Status = EFI_NOT_FOUND;
- Status2 = EFI_NOT_FOUND;
-
- //
- // If we have a single handle to connect make that a 'list'
- //
- if (DriverHandle == NULL) {
- DriverHandleList = NULL;
- } else {
- DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- if (DriverHandleList == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- DriverHandleList[0] = DriverHandle;
- DriverHandleList[1] = NULL;
- }
-
- //
- // do we connect all controllers (with a loop) or a single one...
- // This is where we call the gBS->ConnectController function.
- //
- if (ControllerHandle == NULL) {
- ControllerHandleList = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);
- for (HandleWalker = ControllerHandleList
- ; HandleWalker != NULL && *HandleWalker != NULL
- ; HandleWalker++
- ){
- Status = gBS->ConnectController(*HandleWalker, DriverHandleList, NULL, Recursive);
- if (!EFI_ERROR(Status)) {
- Status2 = EFI_SUCCESS;
- }
- if ((Output && !EFI_ERROR(Status)) || AlwaysOutput) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(*HandleWalker), Status);
- }
- }
- } else {
- Status = gBS->ConnectController(ControllerHandle, DriverHandleList, NULL, Recursive);
- if (!EFI_ERROR(Status)) {
- Status2 = EFI_SUCCESS;
- }
- if ((Output && !EFI_ERROR(Status)) || AlwaysOutput) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(ControllerHandle), Status);
- }
- }
-
- //
- // Free any memory we allocated.
- //
- if (ControllerHandleList != NULL) {
- FreePool(ControllerHandleList);
- }
- if (DriverHandleList != NULL) {
- FreePool(DriverHandleList);
- }
- return (Status2);
-}
-
-/**
- Do a connect from an EFI variable via it's key name.
-
- @param[in] Key The name of the EFI Variable.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellConnectFromDevPaths (
- IN CONST CHAR16 *Key
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_DEVICE_PATH_PROTOCOL *CopyOfDevPath;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- EFI_DEVICE_PATH_PROTOCOL *Next;
- UINTN Length;
- UINTN Index;
- UINTN HandleArrayCount;
- UINTN Size;
- EFI_HANDLE *HandleArray;
- EFI_STATUS Status;
- BOOLEAN AtLeastOneConnected;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 Class[3];
-
- DevPath = NULL;
- Length = 0;
- AtLeastOneConnected = FALSE;
-
- //
- // Get the DevicePath buffer from the variable...
- //
- Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- DevPath = AllocateZeroPool(Length);
- if (DevPath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
- if (EFI_ERROR (Status)) {
- if (DevPath != NULL) {
- FreePool (DevPath);
- }
- return Status;
- }
- } else if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = EFI_NOT_FOUND;
-
- CopyOfDevPath = DevPath;
- //
- // walk the list of devices and connect them
- //
- do {
- //
- // Check every instance of the console variable
- //
- Instance = GetNextDevicePathInstance (&CopyOfDevPath, &Size);
- if (Instance == NULL) {
- if (DevPath != NULL) {
- FreePool (DevPath);
- }
- return EFI_UNSUPPORTED;
- }
-
- Next = Instance;
- while (!IsDevicePathEndType (Next)) {
- Next = NextDevicePathNode (Next);
- }
-
- SetDevicePathEndNode (Next);
- //
- // connect short form device path
- //
- if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
- ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
- || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
- )) {
-
- Status = ShellConnectPciRootBridge ();
- if (EFI_ERROR(Status)) {
- FreePool(Instance);
- FreePool(DevPath);
- return Status;
- }
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
- NULL,
- &HandleArrayCount,
- &HandleArray
- );
-
- if (!EFI_ERROR (Status)) {
- for (Index = 0; Index < HandleArrayCount; Index++) {
- Status = gBS->HandleProtocol (
- HandleArray[Index],
- &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo
- );
-
- if (!EFI_ERROR (Status)) {
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
- if (!EFI_ERROR (Status)) {
- if ((PCI_CLASS_SERIAL == Class[2]) &&
- (PCI_CLASS_SERIAL_USB == Class[1])) {
- Status = gBS->ConnectController (
- HandleArray[Index],
- NULL,
- Instance,
- FALSE
- );
- if (!EFI_ERROR(Status)) {
- AtLeastOneConnected = TRUE;
- }
- }
- }
- }
- }
- }
-
- if (HandleArray != NULL) {
- FreePool (HandleArray);
- }
- } else {
- //
- // connect the entire device path
- //
- Status = ShellConnectDevicePath (Instance);
- if (!EFI_ERROR (Status)) {
- AtLeastOneConnected = TRUE;
- }
- }
- FreePool (Instance);
-
- } while (CopyOfDevPath != NULL);
-
- if (DevPath != NULL) {
- FreePool(DevPath);
- }
-
- if (AtLeastOneConnected) {
- return EFI_SUCCESS;
- } else {
- return EFI_NOT_FOUND;
- }
-
-}
-
-/**
- Convert the handle identifiers from strings and then connect them.
-
- One of them should have driver binding and either can be NULL.
-
- @param[in] Handle1 The first handle.
- @param[in] Handle2 The second handle.
- @param[in] Recursive TRUE to do connect recursively. FALSE otherwise.
- @param[in] Output TRUE to have output to screen. FALSE otherwise.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ConvertAndConnectControllers (
- IN EFI_HANDLE *Handle1 OPTIONAL,
- IN EFI_HANDLE *Handle2 OPTIONAL,
- IN CONST BOOLEAN Recursive,
- IN CONST BOOLEAN Output
- )
-{
- //
- // if only one is NULL verify it's the proper one...
- //
- if ( (Handle1 == NULL && Handle2 != NULL)
- || (Handle1 != NULL && Handle2 == NULL)
- ){
- //
- // Figure out which one should be NULL and move the handle to the right place.
- // If Handle1 is NULL then test Handle2 and vise versa.
- // The one that DOES has driver binding must be Handle2
- //
- if (Handle1 == NULL) {
- if (EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- // swap
- Handle1 = Handle2;
- Handle2 = NULL;
- } else {
- // We're all good...
- }
- } else {
- if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- // We're all good...
- } else {
- // swap
- Handle2 = Handle1;
- Handle1 = NULL;
- }
- }
- }
-
- return (ConnectControllers(Handle1, Handle2, Recursive, Output, (BOOLEAN)(Handle2 != NULL && Handle1 != NULL)));
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-c", TypeFlag},
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'connect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunConnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CONST CHAR16 *Param2;
- UINTN Count;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"connect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 2 'value' parameters (plus the name one) or either -r or -c with any value parameters we have too many parameters
- //
- Count = (gInReconnect?0x4:0x3);
- if ((ShellCommandLineGetCount(Package) > Count)
- ||((ShellCommandLineGetFlag(Package, L"-r") || ShellCommandLineGetFlag(Package, L"-c")) && ShellCommandLineGetCount(Package)>1)
- ||(ShellCommandLineGetFlag(Package, L"-r") && ShellCommandLineGetFlag(Package, L"-c") )
- ){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"connect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-c")) {
- //
- // do the conin and conout from EFI variables
- // if the first fails dont 'loose' the error
- //
- Status = ShellConnectFromDevPaths(L"ConInDev");
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConOutDev");
- } else {
- Status = ShellConnectFromDevPaths(L"ConOutDev");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ErrOutDev");
- } else {
- Status = ShellConnectFromDevPaths(L"ErrOutDev");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ErrOut");
- } else {
- Status = ShellConnectFromDevPaths(L"ErrOut");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConIn");
- } else {
- Status = ShellConnectFromDevPaths(L"ConIn");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConOut");
- } else {
- Status = ShellConnectFromDevPaths(L"ConOut");
- }
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- //
- // 0, 1, or 2 specific handles and possibly recursive
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
- Count = ShellCommandLineGetCount(Package);
-
- if (Param1 != NULL) {
- Status = ShellConvertStringToUint64(Param1, &Intermediate, TRUE, FALSE);
- Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- Handle1 = NULL;
- }
-
- if (Param2 != NULL) {
- Status = ShellConvertStringToUint64(Param2, &Intermediate, TRUE, FALSE);
- Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- Handle2 = NULL;
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- if (Param1 != NULL && Handle1 == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param2 != NULL && Handle2 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Handle2 != NULL && Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ConvertAndConnectControllers(Handle1, Handle2, ShellCommandLineGetFlag(Package, L"-r"), (BOOLEAN)(Count!=0));
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CONNECT_NONE), gShellDriver1HiiHandle);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
deleted file mode 100644
index fb9de10a54..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Main file for DevTree shell Driver1 function.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-d", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Display a tree starting from this handle.
-
- @param[in] TheHandle The handle to start with.
- @param[in] Lang Optionally, a UEFI defined language code.
- @param[in] UseDevPaths TRUE to display info from DevPath as identifiers.
- FALSE will use component name protocol instead.
- @param[in] IndentCharCount How many characters to indent (allows for recursion).
- @param[in] HiiString The string from HII to use for output.
-
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-DoDevTreeForHandle(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST CHAR8 *Lang OPTIONAL,
- IN CONST BOOLEAN UseDevPaths,
- IN CONST UINTN IndentCharCount,
- IN CONST CHAR16 *HiiString
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- CHAR16 *FormatString;
- CHAR16 *Name;
- EFI_HANDLE *ChildHandleBuffer;
- UINTN ChildCount;
- UINTN LoopVar;
-
- Status = EFI_SUCCESS;
- ShellStatus = SHELL_SUCCESS;
- Name = NULL;
- ChildHandleBuffer = NULL;
- ChildCount = 0;
-
- ASSERT(TheHandle != NULL);
-
- if (ShellGetExecutionBreakFlag()) {
- ShellStatus = SHELL_ABORTED;
- return ShellStatus;
- }
-
- //
- // We want controller handles. they will not have LoadedImage or DriverBinding (or others...)
- //
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiDriverBindingProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return SHELL_SUCCESS;
- }
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return SHELL_SUCCESS;
- }
-
- FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
-
- ASSERT(HiiString != NULL);
- ASSERT(FormatString != NULL);
-
- //
- // we generate the format string on the fly so that we can control the
- // number of space characters that the first (empty) string has. this
- // handles the indenting.
- //
-
- UnicodeSPrint(FormatString, StrSize(HiiString) + (10)*sizeof(FormatString[0]), L"%%%ds %s", IndentCharCount, HiiString);
- gEfiShellProtocol->GetDeviceName((EFI_HANDLE)TheHandle, !UseDevPaths?EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH:EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Lang, &Name);
- //
- // print out the information for ourselves
- //
- ShellPrintEx(
- -1,
- -1,
- FormatString,
- L"",
- ConvertHandleToHandleIndex(TheHandle),
- Name==NULL?L"Unknown":Name);
-
- FreePool(FormatString);
- if (Name != NULL) {
- FreePool(Name);
- }
-
- //
- // recurse on each child handle with IndentCharCount + 2
- //
- ParseHandleDatabaseForChildControllers(TheHandle, &ChildCount, &ChildHandleBuffer);
- for (LoopVar = 0 ; LoopVar < ChildCount && ShellStatus == SHELL_SUCCESS; LoopVar++){
- ShellStatus = DoDevTreeForHandle(ChildHandleBuffer[LoopVar], Lang, UseDevPaths, IndentCharCount+2, HiiString);
- if (ShellStatus == SHELL_ABORTED) {
- break;
- }
- }
-
- if (ChildHandleBuffer != NULL) {
- FreePool(ChildHandleBuffer);
- }
-
- return (ShellStatus);
-}
-
-/**
- Function for 'devtree' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDevTree (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CHAR16 *HiiString;
- UINTN LoopVar;
- EFI_HANDLE TheHandle;
- BOOLEAN FlagD;
- UINT64 Intermediate;
- UINTN ParentControllerHandleCount;
- EFI_HANDLE *ParentControllerHandleBuffer;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"devtree", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"devtree");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- ASSERT(Language == NULL);
-// Language = AllocateZeroPool(10);
-// AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"devtree", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- FlagD = ShellCommandLineGetFlag(Package, L"-d");
-
- Lang = ShellCommandLineGetRawValue(Package, 1);
- HiiString = HiiGetString(gShellDriver1HiiHandle, STRING_TOKEN (STR_DEV_TREE_OUTPUT), Language);
-
- if (Lang == NULL) {
- for (LoopVar = 1 ; ; LoopVar++){
- TheHandle = ConvertHandleIndexToHandle(LoopVar);
- if (TheHandle == NULL){
- break;
- }
-
- //
- // Skip handles that do not have device path protocol
- //
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiDevicePathProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- //
- // Skip handles that do have parents
- //
- ParentControllerHandleBuffer = NULL;
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- TheHandle,
- &ParentControllerHandleCount,
- &ParentControllerHandleBuffer
- );
- SHELL_FREE_NON_NULL (ParentControllerHandleBuffer);
- if (ParentControllerHandleCount > 0) {
- continue;
- }
-
- //
- // Start a devtree from TheHandle that has a device path and no parents
- //
- ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
- }
- } else {
- Status = ShellConvertStringToUint64(Lang, &Intermediate, TRUE, FALSE);
- if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"devtree", Lang);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = DoDevTreeForHandle(ConvertHandleIndexToHandle((UINTN)Intermediate), Language, FlagD, 0, HiiString);
- }
- }
-
- if (HiiString != NULL) {
- FreePool(HiiString);
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c
deleted file mode 100644
index d229b352c8..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/** @file
- Main file for devices shell Driver1 function.
-
- (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-/**
- Get lots of info about a device from its handle.
-
- @param[in] TheHandle The device handle to get info on.
- @param[in, out] Type On successful return R, B, or D (root, bus, or
- device) will be placed in this buffer.
- @param[in, out] Cfg On successful return this buffer will be
- TRUE if the handle has configuration, FALSE
- otherwise.
- @param[in, out] Diag On successful return this buffer will be
- TRUE if the handle has disgnostics, FALSE
- otherwise.
- @param[in, out] Parents On successful return this buffer will be
- contain the number of parent handles.
- @param[in, out] Devices On successful return this buffer will be
- contain the number of devices controlled.
- @param[in, out] Children On successful return this buffer will be
- contain the number of child handles.
- @param[out] Name The pointer to a buffer that will be allocated
- and contain the string name of the handle.
- The caller must free this memory.
- @param[in] Language The language code as defined by the UEFI spec.
-
- @retval EFI_SUCCESS The info is there.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
-**/
-EFI_STATUS
-EFIAPI
-GetDeviceHandleInfo (
- IN EFI_HANDLE TheHandle,
- IN OUT CHAR16 *Type,
- IN OUT BOOLEAN *Cfg,
- IN OUT BOOLEAN *Diag,
- IN OUT UINTN *Parents,
- IN OUT UINTN *Devices,
- IN OUT UINTN *Children,
- OUT CHAR16 **Name,
- IN CONST CHAR8 *Language
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN Count;
-
- if (TheHandle == NULL
- || Type == NULL
- || Cfg == NULL
- || Diag == NULL
- || Parents == NULL
- || Devices == NULL
- || Children == NULL
- || Name == NULL ) {
- return (EFI_INVALID_PARAMETER);
- }
-
- *Cfg = FALSE;
- *Diag = FALSE;
- *Children = 0;
- *Parents = 0;
- *Devices = 0;
- *Type = L' ';
- *Name = CHAR_NULL;
- HandleBuffer = NULL;
- Status = EFI_SUCCESS;
-
- gEfiShellProtocol->GetDeviceName(TheHandle, EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, Name);
-
- Status = ParseHandleDatabaseForChildControllers(TheHandle, Children, NULL);
-// if (!EFI_ERROR(Status)) {
- Status = PARSE_HANDLE_DATABASE_PARENTS(TheHandle, Parents, NULL);
- if (/*!EFI_ERROR(Status) && */Parents != NULL && Children != NULL) {
- if (*Parents == 0) {
- *Type = L'R';
- } else if (*Children > 0) {
- *Type = L'B';
- } else {
- *Type = L'D';
- }
- }
-// }
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS(TheHandle, Devices, &HandleBuffer);
- if (!EFI_ERROR(Status) && Devices != NULL && HandleBuffer != NULL) {
- for (Count = 0 ; Count < *Devices ; Count++) {
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverConfigurationProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Cfg = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverDiagnosticsProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Diag = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverDiagnostics2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Diag = TRUE;
- }
- }
- SHELL_FREE_NON_NULL(HandleBuffer);
- }
-
- return (Status);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'devices' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDevices (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- EFI_HANDLE *HandleList;
- EFI_HANDLE *HandleListWalker;
- CHAR16 Type;
- BOOLEAN Cfg;
- BOOLEAN Diag;
- UINTN Parents;
- UINTN Devices;
- UINTN Children;
- CHAR16 *Name;
- CONST CHAR16 *Lang;
- BOOLEAN SfoFlag;
-
- ShellStatus = SHELL_SUCCESS;
- Language = NULL;
- SfoFlag = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"devices", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 0 'value' parameters we have too many parameters
- //
- if (ShellCommandLineGetRawValue(Package, 1) != NULL){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"devices");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // get the language if necessary
- //
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- ASSERT(Language == NULL);
-// Language = AllocateZeroPool(10);
-// AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"devices", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
-
- //
- // Print Header
-
- //
- if (ShellCommandLineGetFlag (Package, L"-sfo")) {
- ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDriver1HiiHandle, L"devices");
- SfoFlag = TRUE;
- } else {
- ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_DEVICES_HEADER_LINES), gShellDriver1HiiHandle);
- }
-
- //
- // loop through each handle
- //
- HandleList = GetHandleListByProtocol(NULL);
- ASSERT(HandleList != NULL);
- for (HandleListWalker = HandleList
- ; HandleListWalker != NULL && *HandleListWalker != NULL /*&& !EFI_ERROR(Status)*/
- ; HandleListWalker++
- ){
-
- //
- // get all the info on each handle
- //
- Name = NULL;
- Status = GetDeviceHandleInfo(*HandleListWalker, &Type, &Cfg, &Diag, &Parents, &Devices, &Children, &Name, Language);
- if (Name != NULL && (Parents != 0 || Devices != 0 || Children != 0)) {
- ShellPrintHiiEx (
- -1,
- -1,
- Language,
- SfoFlag?STRING_TOKEN (STR_DEVICES_ITEM_LINE_SFO):STRING_TOKEN (STR_DEVICES_ITEM_LINE),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (*HandleListWalker),
- Type,
- Cfg?(SfoFlag?L'Y':L'X'):(SfoFlag?L'N':L'-'),
- Diag?(SfoFlag?L'Y':L'X'):(SfoFlag?L'N':L'-'),
- Parents,
- Devices,
- Children,
- Name!=NULL?Name:L"<UNKNOWN>");
- }
- if (Name != NULL) {
- FreePool(Name);
- }
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
-
- }
-
- if (HandleList != NULL) {
- FreePool(HandleList);
- }
-
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
deleted file mode 100644
index 0a1b9a9206..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ /dev/null
@@ -1,984 +0,0 @@
-/** @file
- Main file for Dh shell Driver1 function.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-p", TypeValue},
- {L"-d", TypeFlag},
- {L"-v", TypeFlag},
- {L"-verbose", TypeFlag},
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-STATIC CONST EFI_GUID *UefiDriverModelProtocolsGuidArray[] = {
- &gEfiDriverBindingProtocolGuid,
- &gEfiPlatformDriverOverrideProtocolGuid,
- &gEfiBusSpecificDriverOverrideProtocolGuid,
- &gEfiDriverDiagnosticsProtocolGuid,
- &gEfiDriverDiagnostics2ProtocolGuid,
- &gEfiComponentNameProtocolGuid,
- &gEfiComponentName2ProtocolGuid,
- &gEfiPlatformToDriverConfigurationProtocolGuid,
- &gEfiDriverSupportedEfiVersionProtocolGuid,
- &gEfiDriverFamilyOverrideProtocolGuid,
- &gEfiDriverHealthProtocolGuid,
- &gEfiLoadedImageProtocolGuid,
- NULL
-};
-
-/**
- Get the name of a driver by it's handle.
-
- If a name is found the memory must be callee freed.
-
- @param[in] TheHandle The driver's handle.
- @param[in] Language The language to use.
- @param[in] NameFound Upon a successful return the name found.
-
- @retval EFI_SUCCESS The name was found.
-**/
-EFI_STATUS
-EFIAPI
-GetDriverName (
- IN EFI_HANDLE TheHandle,
- IN CONST CHAR8 *Language,
- IN CHAR16 **NameFound
- )
-{
- CHAR8 *Lang;
- EFI_STATUS Status;
- EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
- CHAR16 *NameToReturn;
- //
- // Go through those handles until we get one that passes for GetComponentName
- //
- Status = gBS->OpenProtocol(
- TheHandle,
- &gEfiComponentName2ProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol(
- TheHandle,
- &gEfiComponentNameProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- }
-
- if (EFI_ERROR(Status)) {
- return (EFI_NOT_FOUND);
- }
- Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
- Status = CompName2->GetDriverName(CompName2, Lang, &NameToReturn);
- FreePool(Lang);
-
- if (!EFI_ERROR(Status) && NameToReturn != NULL) {
- *NameFound = NULL;
- StrnCatGrow(NameFound, NULL, NameToReturn, 0);
- }
- return (Status);
-}
-
-/**
- Discover if a protocol guid is one of the UEFI Driver Model Protocols.
-
- @param[in] Guid The guid to test.
-
- @retval TRUE The guid does represent a driver model protocol.
- @retval FALSE The guid does not represent a driver model protocol.
-**/
-BOOLEAN
-EFIAPI
-IsDriverProt (
- IN CONST EFI_GUID *Guid
- )
-{
- CONST EFI_GUID **GuidWalker;
- BOOLEAN GuidFound;
- GuidFound = FALSE;
- for (GuidWalker = UefiDriverModelProtocolsGuidArray
- ; GuidWalker != NULL && *GuidWalker != NULL
- ; GuidWalker++
- ){
- if (CompareGuid(*GuidWalker, Guid)) {
- GuidFound = TRUE;
- break;
- }
- }
- return (GuidFound);
-}
-
-/**
- Get information for a handle.
-
- @param[in] TheHandle The handles to show info on.
- @param[in] Language Language string per UEFI specification.
- @param[in] Seperator Separator string between information blocks.
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @param[in] ExtraInfo TRUE for extra info, FALSE otherwise.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-CHAR16*
-EFIAPI
-GetProtocolInfoString(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST CHAR8 *Language,
- IN CONST CHAR16 *Seperator,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN ExtraInfo
- )
-{
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- UINTN Size;
- CHAR16 *Temp;
-
- ProtocolGuidArray = NULL;
- RetVal = NULL;
- Size = 0;
-
- Status = gBS->ProtocolsPerHandle (
- TheHandle,
- &ProtocolGuidArray,
- &ArrayCount
- );
- if (!EFI_ERROR (Status)) {
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language);
- if (Temp != NULL) {
- ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
- if (Size != 0) {
- StrnCatGrow(&RetVal, &Size, Seperator, 0);
- }
- StrnCatGrow(&RetVal, &Size, L"%H", 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- StrnCatGrow(&RetVal, &Size, L"%N", 0);
- FreePool(Temp);
- }
- if (ExtraInfo) {
- Temp = GetProtocolInformationDump(TheHandle, ProtocolGuidArray[ProtocolIndex], Verbose);
- if (Temp != NULL) {
- ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
- if (!Verbose) {
- StrnCatGrow(&RetVal, &Size, L"(", 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- StrnCatGrow(&RetVal, &Size, L")\r\n", 0);
- } else {
- StrnCatGrow(&RetVal, &Size, Seperator, 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- }
- FreePool(Temp);
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(ProtocolGuidArray);
-
- if (RetVal == NULL) {
- return (NULL);
- }
-
- ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
- StrnCatGrow(&RetVal, &Size, Seperator, 0);
- return (RetVal);
-}
-
-/**
- Gets the name of the loaded image.
-
- @param[in] TheHandle The handle of the driver to get info on.
- @param[out] Name The pointer to the pointer. Valid upon a successful return.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-GetDriverImageName (
- IN EFI_HANDLE TheHandle,
- OUT CHAR16 **Name
- )
-{
- // get loaded image and devicepathtotext on image->Filepath
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- if (TheHandle == NULL || Name == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- return (Status);
- }
- DevicePath = LoadedImage->FilePath;
- *Name = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
- return (EFI_SUCCESS);
-}
-
-/**
- Display driver model information for a given handle.
-
- @param[in] Handle The handle to display info on.
- @param[in] BestName Use the best name?
- @param[in] Language The language to output in.
-**/
-EFI_STATUS
-EFIAPI
-DisplayDriverModelHandle (
- IN EFI_HANDLE Handle,
- IN BOOLEAN BestName,
- IN CONST CHAR8 *Language OPTIONAL
- )
-{
- EFI_STATUS Status;
- BOOLEAN ConfigurationStatus;
- BOOLEAN DiagnosticsStatus;
- UINTN DriverBindingHandleCount;
- EFI_HANDLE *DriverBindingHandleBuffer;
- UINTN ParentControllerHandleCount;
- EFI_HANDLE *ParentControllerHandleBuffer;
- UINTN ChildControllerHandleCount;
- EFI_HANDLE *ChildControllerHandleBuffer;
- CHAR16 *TempStringPointer;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN Index;
- CHAR16 *DriverName;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- UINTN NumberOfChildren;
- UINTN HandleIndex;
- UINTN ControllerHandleCount;
- EFI_HANDLE *ControllerHandleBuffer;
- UINTN ChildIndex;
- BOOLEAN Image;
-
- DriverName = NULL;
-
- //
- // See if Handle is a device handle and display its details.
- //
- DriverBindingHandleBuffer = NULL;
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
- Handle,
- &DriverBindingHandleCount,
- &DriverBindingHandleBuffer
- );
-
- ParentControllerHandleBuffer = NULL;
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- Handle,
- &ParentControllerHandleCount,
- &ParentControllerHandleBuffer
- );
-
- ChildControllerHandleBuffer = NULL;
- Status = ParseHandleDatabaseForChildControllers (
- Handle,
- &ChildControllerHandleCount,
- &ChildControllerHandleBuffer
- );
-
- DiagnosticsStatus = FALSE;
- ConfigurationStatus = FALSE;
-
- if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverConfigurationProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ConfigurationStatus = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverConfiguration2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ConfigurationStatus = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverDiagnosticsProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- DiagnosticsStatus = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverDiagnostics2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- DiagnosticsStatus = TRUE;
- }
-
- Status = EFI_SUCCESS;
-
- if (DriverBindingHandleCount > 0 || ParentControllerHandleCount > 0 || ChildControllerHandleCount > 0) {
-
-
-
- DevicePath = NULL;
- TempStringPointer = NULL;
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevicePath);
-
- Status = gEfiShellProtocol->GetDeviceName(Handle, EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_DRIVER1), gShellDriver1HiiHandle, TempStringPointer!=NULL?TempStringPointer:L"<Unknown>");
- SHELL_FREE_NON_NULL(TempStringPointer);
-
- TempStringPointer = ConvertDevicePathToText(DevicePath, TRUE, FALSE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER2),
- gShellDriver1HiiHandle,
- TempStringPointer!=NULL?TempStringPointer:L"<None>",
- ParentControllerHandleCount == 0?L"ROOT":(ChildControllerHandleCount > 0)?L"BUS":L"DEVICE",
- ConfigurationStatus?L"YES":L"NO",
- DiagnosticsStatus?L"YES":L"NO"
- );
-
- SHELL_FREE_NON_NULL(TempStringPointer);
-
- if (DriverBindingHandleCount == 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER3),
- gShellDriver1HiiHandle,
- L"<None>"
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER3),
- gShellDriver1HiiHandle,
- L""
- );
- for (Index = 0; Index < DriverBindingHandleCount; Index++) {
- Image = FALSE;
- Status = GetDriverName (
- DriverBindingHandleBuffer[Index],
- Language,
- &DriverName
- );
- if (EFI_ERROR (Status)) {
- Status = GetDriverImageName (
- DriverBindingHandleBuffer[Index],
- &DriverName
- );
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
- }
-
- if (Image) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER4A),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (DriverBindingHandleBuffer[Index]),
- DriverName!=NULL?DriverName:L"<Unknown>"
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER4B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (DriverBindingHandleBuffer[Index]),
- DriverName!=NULL?DriverName:L"<Unknown>"
- );
- }
- SHELL_FREE_NON_NULL(DriverName);
- }
- }
-
- if (ParentControllerHandleCount == 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER5),
- gShellDriver1HiiHandle,
- L"<None>"
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER5),
- gShellDriver1HiiHandle,
- L""
- );
- for (Index = 0; Index < ParentControllerHandleCount; Index++) {
- Status = gEfiShellProtocol->GetDeviceName(ParentControllerHandleBuffer[Index], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER5B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (ParentControllerHandleBuffer[Index]),
- TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(TempStringPointer);
- }
- }
-
- if (ChildControllerHandleCount == 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
- gShellDriver1HiiHandle,
- L"<None>"
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
- gShellDriver1HiiHandle,
- L""
- );
- for (Index = 0; Index < ChildControllerHandleCount; Index++) {
- Status = gEfiShellProtocol->GetDeviceName(ChildControllerHandleBuffer[Index], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (ChildControllerHandleBuffer[Index]),
- TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(TempStringPointer);
- }
- }
- }
-
- SHELL_FREE_NON_NULL(DriverBindingHandleBuffer);
-
- SHELL_FREE_NON_NULL(ParentControllerHandleBuffer);
-
- SHELL_FREE_NON_NULL(ChildControllerHandleBuffer);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // See if Handle is a driver binding handle and display its details.
- //
- Status = gBS->OpenProtocol (
- Handle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
-
- NumberOfChildren = 0;
- ControllerHandleBuffer = NULL;
- Status = PARSE_HANDLE_DATABASE_DEVICES (
- Handle,
- &ControllerHandleCount,
- &ControllerHandleBuffer
- );
- if (ControllerHandleCount > 0) {
- for (HandleIndex = 0; HandleIndex < ControllerHandleCount; HandleIndex++) {
- Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
- Handle,
- ControllerHandleBuffer[HandleIndex],
- &ChildControllerHandleCount,
- NULL
- );
- NumberOfChildren += ChildControllerHandleCount;
- }
- }
-
- Status = GetDriverName (Handle, Language, &DriverName);
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle),
- DriverName!=NULL?DriverName:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(DriverName);
- Status = GetDriverImageName (
- Handle,
- &DriverName
- );
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER7B),
- gShellDriver1HiiHandle,
- DriverName!=NULL?DriverName:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(DriverName);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER8),
- gShellDriver1HiiHandle,
- DriverBinding->Version,
- NumberOfChildren > 0?L"Bus":ControllerHandleCount > 0?L"Device":L"<Unknown>",
- ConfigurationStatus?L"YES":L"NO",
- DiagnosticsStatus?L"YES":L"NO"
- );
-
- if (ControllerHandleCount == 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
- gShellDriver1HiiHandle,
- L"None"
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
- gShellDriver1HiiHandle,
- L""
- );
- for (HandleIndex = 0; HandleIndex < ControllerHandleCount; HandleIndex++) {
- Status = gEfiShellProtocol->GetDeviceName(ControllerHandleBuffer[HandleIndex], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER9B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(ControllerHandleBuffer[HandleIndex]),
- TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(TempStringPointer);
-
- Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
- Handle,
- ControllerHandleBuffer[HandleIndex],
- &ChildControllerHandleCount,
- &ChildControllerHandleBuffer
- );
- if (!EFI_ERROR (Status)) {
- for (ChildIndex = 0; ChildIndex < ChildControllerHandleCount; ChildIndex++) {
- Status = gEfiShellProtocol->GetDeviceName(ChildControllerHandleBuffer[ChildIndex], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(ChildControllerHandleBuffer[ChildIndex]),
- TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(TempStringPointer);
- }
-
- SHELL_FREE_NON_NULL (ChildControllerHandleBuffer);
- }
- }
-
- SHELL_FREE_NON_NULL (ControllerHandleBuffer);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Display information for a handle.
-
- @param[in] TheHandle The handles to show info on.
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @param[in] Sfo TRUE to output in standard format output (spec).
- @param[in] Language Language string per UEFI specification.
- @param[in] DriverInfo TRUE to show all info about the handle.
- @param[in] Multiple TRUE indicates more than will be output,
- FALSE for a single one.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhByHandle(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo,
- IN CONST BOOLEAN Multiple
- )
-{
- CHAR16 *ProtocolInfoString;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
- ProtocolInfoString = NULL;
-
- if (!Sfo) {
- if (Multiple) {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L" ", Verbose, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(TheHandle),
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
- } else {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n", Verbose, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_SINGLE),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(TheHandle),
- TheHandle,
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
- }
-
- if (DriverInfo) {
- DisplayDriverModelHandle ((EFI_HANDLE)TheHandle, TRUE, Language);
- }
- } else {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L";", FALSE, FALSE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_SFO),
- gShellDriver1HiiHandle,
- Multiple ?L"HandlesInfo":L"HandleInfo",
- L"DriverName",
- L"ControllerName",
- ConvertHandleToHandleIndex(TheHandle),
- L"DevPath",
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
-
-
- }
-
-
- if (ProtocolInfoString != NULL) {
- FreePool(ProtocolInfoString);
- }
- return (ShellStatus);
-}
-
-/**
- Display information for all handles on a list.
-
- @param[in] HandleList The NULL-terminated list of handles.
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @param[in] Sfo TRUE to output in standard format output (spec).
- @param[in] Language Language string per UEFI specification.
- @param[in] DriverInfo TRUE to show all info about the handle.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhForHandleList(
- IN CONST EFI_HANDLE *HandleList,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- CONST EFI_HANDLE *HandleWalker;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
-
- for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker != NULL && ShellStatus == SHELL_SUCCESS; HandleWalker++) {
- ShellStatus = DoDhByHandle(
- *HandleWalker,
- Verbose,
- Sfo,
- Language,
- DriverInfo,
- TRUE
- );
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- }
- return (ShellStatus);
-}
-
-/**
- Display information for all handles.
-
- @param[in] Sfo TRUE to output in standard format output (spec).
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @param[in] Language Language string per UEFI specification.
- @param[in] DriverInfo TRUE to show all info about the handle.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhForAll(
- IN CONST BOOLEAN Sfo,
- IN CONST BOOLEAN Verbose,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- EFI_HANDLE *HandleList;
- SHELL_STATUS ShellStatus;
-
- HandleList = GetHandleListByProtocol(NULL);
-
- ShellStatus = DoDhForHandleList(
- HandleList,
- Verbose,
- Sfo,
- Language,
- DriverInfo);
-
- FreePool(HandleList);
-
- return (ShellStatus);
-}
-
-/**
- Display information for all handles which have a specific protocol.
-
- @param[in] ProtocolName The pointer to the name of the protocol.
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @param[in] Sfo TRUE to output in standard format output (spec).
- @param[in] Language Language string per UEFI specification.
- @param[in] DriverInfo TRUE to show all info about the handle.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhByProtocol(
- IN CONST CHAR16 *ProtocolName,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- EFI_GUID *Guid;
- EFI_STATUS Status;
- EFI_HANDLE *HandleList;
- SHELL_STATUS ShellStatus;
-
- if (ProtocolName == NULL) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = GetGuidFromStringName(ProtocolName, Language, &Guid);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DH_NO_GUID_FOUND), gShellDriver1HiiHandle, ProtocolName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- HandleList = GetHandleListByProtocol(Guid);
-
- ShellStatus = DoDhForHandleList(
- HandleList,
- Verbose,
- Sfo,
- Language,
- DriverInfo);
-
- SHELL_FREE_NON_NULL(HandleList);
-
- return (ShellStatus);
-}
-
-/**
- Function for 'dh' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDh (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CONST CHAR16 *Temp2;
- BOOLEAN SfoMode;
- BOOLEAN FlagD;
- BOOLEAN Verbose;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"dh", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- Language = AllocateZeroPool(10);
- AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
- SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
- FlagD = ShellCommandLineGetFlag(Package, L"-d");
- Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose"));
-
- if (ShellCommandLineGetFlag(Package, L"-p")) {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-p");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // print by protocol
- //
- ShellStatus = DoDhByProtocol(
- ShellCommandLineGetValue(Package, L"-p"),
- Verbose,
- SfoMode,
- Lang==NULL?NULL:Language,
- FlagD
- );
- }
- } else {
- Temp2 = ShellCommandLineGetRawValue(Package, 1);
- if (Temp2 == NULL) {
- //
- // Print everything
- //
- ShellStatus = DoDhForAll(
- SfoMode,
- Verbose,
- Lang==NULL?NULL:Language,
- FlagD
- );
- } else {
- Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE, FALSE);
- if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", Temp2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // print 1 handle
- //
- ShellStatus = DoDhByHandle(
- ConvertHandleIndexToHandle((UINTN)Intermediate),
- Verbose,
- SfoMode,
- Lang==NULL?NULL:Language,
- FlagD,
- FALSE
- );
- }
- }
- }
-
-
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(Language);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
deleted file mode 100644
index 9afbf07329..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/** @file
- Main file for Disconnect shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Disconnect everything.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-DisconnectAll(
- VOID
- )
-{
- //
- // Stolen from UEFI 2.3 spec (May 2009 version)
- // Pages 171/172
- // Removed gBS local definition
- //
-
- //
- // Disconnect All Handles Example
- // The following example recusively disconnects all drivers from all
- // controllers in a platform.
- //
- EFI_STATUS Status;
-// EFI_BOOT_SERVICES *gBS;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleIndex;
- //
- // Retrieve the list of all handles from the handle database
- //
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (!EFI_ERROR (Status)) {
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- Status = gBS->DisconnectController (
- HandleBuffer[HandleIndex],
- NULL,
- NULL
- );
- }
- gBS->FreePool(HandleBuffer);
- //
- // end of stealing
- //
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Function for 'disconnect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDisconnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CONST CHAR16 *Param2;
- CONST CHAR16 *Param3;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- UINT64 Intermediate1;
- UINT64 Intermediate2;
- UINT64 Intermediate3;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"disconnect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetFlag(Package, L"-r")){
- if (ShellCommandLineGetCount(Package) > 1){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = DisconnectAll();
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 4){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // must have between 1 and 3 handles passed in ...
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
- Param3 = ShellCommandLineGetRawValue(Package, 3);
- ShellConvertStringToUint64(Param1, &Intermediate1, TRUE, FALSE);
- Handle1 = Param1!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate1):NULL;
- ShellConvertStringToUint64(Param2, &Intermediate2, TRUE, FALSE);
- Handle2 = Param2!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate2):NULL;
- ShellConvertStringToUint64(Param3, &Intermediate3, TRUE, FALSE);
- Handle3 = Param3!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate3):NULL;
-
- if (Param1 != NULL && Handle1 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param2 != NULL && Handle2 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param3 != NULL && Handle3 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param3);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ASSERT(Param2 != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, L"disconnect", ShellStrToUintn(Param2), L"driver handle");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(Param1 != NULL);
- Status = gBS->DisconnectController(Handle1, Handle2, Handle3);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_3P_RESULT), gShellDriver1HiiHandle, L"Disconnect", (UINTN)Intermediate1, (UINTN)Intermediate2, (UINTN)Intermediate3, Status);
- }
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c
deleted file mode 100644
index d6d75f0625..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/** @file
- Main file for Drivers shell Driver1 function.
-
- (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-#define MAX_LEN_DRIVER_NAME 35
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Get a device path (in text format) for a given handle.
-
- @param[in] TheHandle The handle to get the device path for.
-
- @retval NULL An error occured.
- @return A pointer to the driver path as a string. The callee must
- free this memory.
-**/
-CHAR16*
-EFIAPI
-GetDevicePathTextForHandle(
- IN EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *FinalPath;
- CHAR16 *RetVal;
-
- FinalPath = NULL;
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&ImageDevicePath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- FinalPath = AppendDevicePath (ImageDevicePath, LoadedImage->FilePath);
- gBS->CloseProtocol(
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- gImageHandle,
- NULL);
- }
- gBS->CloseProtocol(
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- gImageHandle,
- NULL);
- }
-
- if (FinalPath == NULL) {
- return (NULL);
- }
- RetVal = gEfiShellProtocol->GetFilePathFromDevicePath(FinalPath);
- if (RetVal == NULL) {
- RetVal = ConvertDevicePathToText(FinalPath, TRUE, TRUE);
- }
- FreePool(FinalPath);
- return (RetVal);
-}
-
-/**
- Determine if the given handle has Driver Configuration protocol.
-
- @param[in] TheHandle The handle to the driver to test.
-
- @retval TRUE The driver does have Driver Configuration.
- @retval FALSE The driver does not have Driver Configuration.
-**/
-BOOLEAN
-EFIAPI
-ReturnDriverConfig(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverConfigurationProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-/**
- Determine if the given handle has DriverDiagnostics protocol.
-
- @param[in] TheHandle The handle to the driver to test.
-
- @retval TRUE The driver does have Driver Diasgnostics.
- @retval FALSE The driver does not have Driver Diagnostics.
-**/
-BOOLEAN
-EFIAPI
-ReturnDriverDiag(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverDiagnostics2ProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverDiagnosticsProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- return (FALSE);
- }
- }
- return (TRUE);
-}
-
-/**
- Finds and returns the version of the driver specified by TheHandle.
-
- @param[in] TheHandle The driver handle to get the version of.
-
- @return The version of the driver.
- @retval 0xFFFFFFFF An error ocurred.
-**/
-UINT32
-EFIAPI
-ReturnDriverVersion(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_STATUS Status;
- UINT32 RetVal;
-
- RetVal = (UINT32)-1;
-
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverBindingProtocolGuid, (VOID**)&DriverBinding, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- RetVal = DriverBinding->Version;
- gBS->CloseProtocol(TheHandle, &gEfiDriverBindingProtocolGuid, gImageHandle, NULL);
- }
- return (RetVal);
-}
-
-/**
- Function for 'drivers' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrivers (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- EFI_HANDLE *HandleList;
- EFI_HANDLE *HandleWalker;
- UINTN ChildCount;
- UINTN DeviceCount;
- CHAR16 *Temp2;
- CONST CHAR16 *FullDriverName;
- CHAR16 *TruncatedDriverName;
- CHAR16 *FormatString;
- UINT32 DriverVersion;
- BOOLEAN DriverConfig;
- BOOLEAN DriverDiag;
- BOOLEAN SfoFlag;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
- FormatString = NULL;
- SfoFlag = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"drivers", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drivers");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellCommandLineGetFlag(Package, L"-l")){
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drivers", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- }
-
- if (ShellCommandLineGetFlag (Package, L"-sfo")) {
- SfoFlag = TRUE;
- FormatString = HiiGetString (gShellDriver1HiiHandle, STRING_TOKEN (STR_DRIVERS_ITEM_LINE_SFO), Language);
- //
- // print the SFO header
- //
- ShellPrintHiiEx (
- -1,
- -1,
- Language,
- STRING_TOKEN (STR_GEN_SFO_HEADER),
- gShellDriver1HiiHandle,
- L"drivers");
- } else {
- FormatString = HiiGetString (gShellDriver1HiiHandle, STRING_TOKEN (STR_DRIVERS_ITEM_LINE), Language);
- //
- // print the header row
- //
- ShellPrintHiiEx(
- -1,
- -1,
- Language,
- STRING_TOKEN (STR_DRIVERS_HEADER_LINES),
- gShellDriver1HiiHandle);
- }
-
- HandleList = GetHandleListByProtocol(&gEfiDriverBindingProtocolGuid);
- for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker != NULL ; HandleWalker++){
- ChildCount = 0;
- DeviceCount = 0;
- Status = ParseHandleDatabaseForChildDevices (*HandleWalker, &ChildCount , NULL);
- Status = PARSE_HANDLE_DATABASE_DEVICES (*HandleWalker, &DeviceCount, NULL);
- Temp2 = GetDevicePathTextForHandle(*HandleWalker);
- DriverVersion = ReturnDriverVersion(*HandleWalker);
- DriverConfig = ReturnDriverConfig(*HandleWalker);
- DriverDiag = ReturnDriverDiag (*HandleWalker);
- FullDriverName = GetStringNameFromHandle(*HandleWalker, Language);
-
- TruncatedDriverName = NULL;
- if (!SfoFlag && (FullDriverName != NULL)) {
- TruncatedDriverName = AllocateZeroPool ((MAX_LEN_DRIVER_NAME + 1) * sizeof (CHAR16));
- StrnCpyS (TruncatedDriverName, MAX_LEN_DRIVER_NAME + 1, FullDriverName, MAX_LEN_DRIVER_NAME);
- }
-
- ShellPrintEx(
- -1,
- -1,
- FormatString,
- ConvertHandleToHandleIndex(*HandleWalker),
- DriverVersion,
- ChildCount > 0?L'B':(DeviceCount > 0?L'D':L'?'),
- DriverConfig?L'Y':L'N',
- DriverDiag?L'Y':L'N',
- DeviceCount,
- ChildCount,
- SfoFlag?FullDriverName:TruncatedDriverName,
- Temp2==NULL?L"":Temp2
- );
- if (TruncatedDriverName != NULL) {
- FreePool (TruncatedDriverName);
- }
- if (Temp2 != NULL) {
- FreePool(Temp2);
- }
-
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- }
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(FormatString);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
deleted file mode 100644
index 609d076da0..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
+++ /dev/null
@@ -1,1407 +0,0 @@
-/** @file
- Main file for DrvCfg shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/HiiDatabase.h>
-
-STATIC CONST EFI_GUID *CfgGuidList[] = {&gEfiDriverConfigurationProtocolGuid, &gEfiDriverConfiguration2ProtocolGuid, NULL};
-
-/**
- Find the EFI_HII_HANDLE by device path.
-
- @param[in] DevPath1 The Device Path to match.
- @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
- @param[in] HiiDb The Hii database protocol
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND There was no EFI_HII_HANDLE found for that deviec path.
-**/
-EFI_STATUS
-EFIAPI
-FindHiiHandleViaDevPath(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath1,
- OUT EFI_HII_HANDLE *HiiHandle,
- IN EFI_HII_DATABASE_PROTOCOL *HiiDb
- )
-{
- EFI_HII_HANDLE *HandleBuffer;
- UINTN HandleBufferSize;
- VOID *MainBuffer;
- UINTN MainBufferSize;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
- EFI_HII_PACKAGE_HEADER *PackageHeader;
- UINTN LoopVariable;
- EFI_DEVICE_PATH_PROTOCOL *DevPath2;
- EFI_STATUS Status;
-
- ASSERT(DevPath1 != NULL);
- ASSERT(HiiHandle != NULL);
- ASSERT(*HiiHandle == NULL);
- ASSERT(HiiDb != NULL);
-
- HandleBufferSize = 0;
- HandleBuffer = NULL;
- Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(HandleBufferSize);
- ASSERT (HandleBuffer != NULL);
- Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
- }
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- return (Status);
- }
-
- if (HandleBuffer == NULL) {
- return EFI_NOT_FOUND;
- }
-
- for (LoopVariable = 0 ; LoopVariable < (HandleBufferSize/sizeof(HandleBuffer[0])) && *HiiHandle == NULL ; LoopVariable++) {
- MainBufferSize = 0;
- MainBuffer = NULL;
- Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- MainBuffer = AllocateZeroPool(MainBufferSize);
- ASSERT (MainBuffer != NULL);
- Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
- }
- //
- // Enumerate through the block of returned memory.
- // This should actually be a small block, but we need to be sure.
- //
- for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
- ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && *HiiHandle == NULL
- ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
- for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
- ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END && *HiiHandle == NULL
- ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
- if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
- DevPath2 = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
- if (DevicePathCompare(&DevPath1, &DevPath2) == 0) {
- *HiiHandle = HandleBuffer[LoopVariable];
- break;
- }
- }
- }
- }
- SHELL_FREE_NON_NULL(MainBuffer);
- }
- SHELL_FREE_NON_NULL(HandleBuffer);
-
- if (*HiiHandle == NULL) {
- return (EFI_NOT_FOUND);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Convert a EFI_HANDLE to a EFI_HII_HANDLE.
-
- @param[in] Handle The EFI_HANDLE to convert.
- @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
- @param[in] HiiDb The Hii database protocol
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ConvertHandleToHiiHandle(
- IN CONST EFI_HANDLE Handle,
- OUT EFI_HII_HANDLE *HiiHandle,
- IN EFI_HII_DATABASE_PROTOCOL *HiiDb
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevPath1;
-
- if (HiiHandle == NULL || HiiDb == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- *HiiHandle = NULL;
-
- if (Handle == NULL) {
- return (EFI_SUCCESS);
- }
-
- DevPath1 = NULL;
- Status = gBS->OpenProtocol(Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath1, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status) || DevPath1 == NULL) {
- return (EFI_NOT_FOUND);
- }
-
- return (FindHiiHandleViaDevPath(DevPath1, HiiHandle, HiiDb));
-}
-
-/**
- Function to print out all HII configuration information to a file.
-
- @param[in] Handle The handle to get info on. NULL to do all handles.
- @param[in] FileName The filename to rwite the info to.
-**/
-SHELL_STATUS
-EFIAPI
-ConfigToFile(
- IN CONST EFI_HANDLE Handle,
- IN CONST CHAR16 *FileName
- )
-{
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_STATUS Status;
- VOID *MainBuffer;
- UINTN MainBufferSize;
- EFI_HII_HANDLE HiiHandle;
- SHELL_FILE_HANDLE FileHandle;
-
- HiiDatabase = NULL;
- MainBufferSize = 0;
- MainBuffer = NULL;
- FileHandle = NULL;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_FILE_OPEN_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName,
- Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Locate HII Database protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID **) &HiiDatabase
- );
-
- if (EFI_ERROR(Status) || HiiDatabase == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_PROTOCOL_NF),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"EfiHiiDatabaseProtocol",
- &gEfiHiiDatabaseProtocolGuid);
- ShellCloseFile(&FileHandle);
- return (SHELL_NOT_FOUND);
- }
-
- HiiHandle = NULL;
- Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_HANDLE_NOT),
- gShellDriver1HiiHandle,
- L"drvcfg",
- ConvertHandleToHandleIndex(Handle),
- L"Device");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
-
- Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- MainBuffer = AllocateZeroPool(MainBufferSize);
- Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
- }
-
- Status = ShellWriteFile(FileHandle, &MainBufferSize, MainBuffer);
-
- ShellCloseFile(&FileHandle);
- SHELL_FREE_NON_NULL(MainBuffer);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_WRITE_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
- return (SHELL_DEVICE_ERROR);
- }
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_COMP),
- gShellDriver1HiiHandle);
-
- return (SHELL_SUCCESS);
-}
-
-/**
- Function to read in HII configuration information from a file.
-
- @param[in] Handle The handle to get info for.
- @param[in] FileName The filename to read the info from.
-**/
-SHELL_STATUS
-EFIAPI
-ConfigFromFile(
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *FileName
- )
-{
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_STATUS Status;
- VOID *MainBuffer;
- UINT64 Temp;
- UINTN MainBufferSize;
- EFI_HII_HANDLE HiiHandle;
- SHELL_FILE_HANDLE FileHandle;
- CHAR16 *TempDevPathString;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
- EFI_HII_PACKAGE_HEADER *PackageHeader;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- UINTN HandleIndex;
-
- HiiDatabase = NULL;
- MainBufferSize = 0;
- MainBuffer = NULL;
- FileHandle = NULL;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_FILE_OPEN_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName,
- Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Locate HII Database protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID **) &HiiDatabase
- );
-
- if (EFI_ERROR(Status) || HiiDatabase == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_PROTOCOL_NF),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"EfiHiiDatabaseProtocol",
- &gEfiHiiDatabaseProtocolGuid);
- ShellCloseFile(&FileHandle);
- return (SHELL_NOT_FOUND);
- }
-
- Status = ShellGetFileSize(FileHandle, &Temp);
- MainBufferSize = (UINTN)Temp;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_READ_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
-
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- MainBuffer = AllocateZeroPool((UINTN)MainBufferSize);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_OUT_MEM),
- gShellDriver1HiiHandle, L"drvcfg");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- Status = ShellReadFile(FileHandle, &MainBufferSize, MainBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_READ_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
-
- ShellCloseFile(&FileHandle);
- SHELL_FREE_NON_NULL(MainBuffer);
- return (SHELL_DEVICE_ERROR);
- }
-
- ShellCloseFile(&FileHandle);
-
- if (Handle != NULL) {
- //
- // User override in place. Just do it.
- //
- HiiHandle = NULL;
- Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_HANDLE_NOT),
- gShellDriver1HiiHandle, L"drvcfg",
- ConvertHandleToHandleIndex(Handle),
- L"Device");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, MainBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_UEFI_FUNC_WARN),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"HiiDatabase->UpdatePackageList",
- Status);
- return (SHELL_DEVICE_ERROR);
- }
- } else {
- //
- // we need to parse the buffer and try to match the device paths for each item to try to find it's device path.
- //
-
- for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
- ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize)
- ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
- for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
- ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END
- ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
- if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
- HiiHandle = NULL;
- Status = FindHiiHandleViaDevPath((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- //
- // print out an error.
- //
- TempDevPathString = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), TRUE, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_IN_FILE_NF),
- gShellDriver1HiiHandle,
- TempDevPathString);
- SHELL_FREE_NON_NULL(TempDevPathString);
- } else {
- Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, PackageListHeader);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_UEFI_FUNC_WARN),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"HiiDatabase->UpdatePackageList",
- Status);
- return (SHELL_DEVICE_ERROR);
- } else {
- DevPath = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
- gBS->LocateDevicePath(&gEfiHiiConfigAccessProtocolGuid, &DevPath, &Handle);
- HandleIndex = ConvertHandleToHandleIndex(Handle);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_DONE_HII),
- gShellDriver1HiiHandle,
- HandleIndex);
- }
- }
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(MainBuffer);
-
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_COMP),
- gShellDriver1HiiHandle);
- return (SHELL_SUCCESS);
-}
-
-/**
- Present a requested action to the user.
-
- @param[in] DriverImageHandle The handle for the driver to configure.
- @param[in] ControllerHandle The handle of the device being managed by the Driver specified.
- @param[in] ChildHandle The handle of a child device of the specified device.
- @param[in] ActionRequired The required HII action.
-
- @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
-**/
-EFI_STATUS
-EFIAPI
-ShellCmdDriverConfigurationProcessActionRequired (
- EFI_HANDLE DriverImageHandle,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired
- )
-{
- EFI_HANDLE ConnectControllerContextOverride[2];
-
- switch (ActionRequired) {
- case EfiDriverConfigurationActionNone:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_NONE), gShellDriver1HiiHandle);
- break;
-
- case EfiDriverConfigurationActionStopController:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_STOP), gShellDriver1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"stop controller");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"stopped");
- break;
-
- case EfiDriverConfigurationActionRestartController:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"controller");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart controller");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
- ConnectControllerContextOverride[0] = DriverImageHandle;
- ConnectControllerContextOverride[1] = NULL;
- gBS->ConnectController (ControllerHandle, ConnectControllerContextOverride, NULL, TRUE);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"restarted");
- break;
-
- case EfiDriverConfigurationActionRestartPlatform:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"platform");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart platform");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- break;
-
- default:
- return (EFI_INVALID_PARAMETER);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Do the configuration in an environment without HII.
-
- @param[in] Language The language code.
- @param[in] ForceDefaults TRUE to force defaults, FALSE otherwise.
- @param[in] DefaultType If ForceDefaults is TRUE, specifies the default type.
- @param[in] AllChildren TRUE to configure all children, FALSE otherwise.
- @param[in] ValidateOptions TRUE to validate existing options, FALSE otherwise.
- @param[in] SetOptions TRUE to set options, FALSE otherwise.
- @param[in] DriverImageHandle The handle for the driver to configure.
- @param[in] DeviceHandle The handle of the device being managed by the Driver specified.
- @param[in] ChildHandle The handle of a child device of the specified device.
-
- @retval SHELL_NOT_FOUND A specified handle could not be found.
- @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
-**/
-SHELL_STATUS
-EFIAPI
-PreHiiDrvCfg (
- IN CONST CHAR8 *Language,
- IN BOOLEAN ForceDefaults,
- IN UINT32 DefaultType,
- IN BOOLEAN AllChildren,
- IN BOOLEAN ValidateOptions,
- IN BOOLEAN SetOptions,
- IN EFI_HANDLE DriverImageHandle,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_HANDLE ChildHandle
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- UINTN OuterLoopCounter;
- CHAR8 *BestLanguage;
- UINTN DriverImageHandleCount;
- EFI_HANDLE *DriverImageHandleBuffer;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN *HandleType;
- UINTN LoopCounter;
- UINTN ChildIndex;
- UINTN ChildHandleCount;
- EFI_HANDLE *ChildHandleBuffer;
- UINTN *ChildHandleType;
- EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired;
- EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- BOOLEAN Iso639Language;
- UINTN HandleIndex1;
- UINTN HandleIndex2;
- UINTN HandleIndex3;
-
- ShellStatus = SHELL_SUCCESS;
-
- if (ChildHandle == NULL && AllChildren) {
- SetOptions = FALSE;
- }
-
- if (ForceDefaults) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_D),
- gShellDriver1HiiHandle,
- DefaultType);
- } else if (ValidateOptions) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_VALIDATE),
- gShellDriver1HiiHandle);
- } else if (SetOptions) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_SET),
- gShellDriver1HiiHandle);
- }
-
- if (DriverImageHandle == 0) {
- DriverImageHandleBuffer = GetHandleListByProtocolList(CfgGuidList);
- if (DriverImageHandleBuffer == NULL) {
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- for (
- HandleBuffer = DriverImageHandleBuffer, DriverImageHandleCount = 0
- ; HandleBuffer != NULL && *HandleBuffer != NULL
- ; HandleBuffer++,DriverImageHandleCount++);
- } else {
- DriverImageHandleCount = 1;
- //
- // Allocate buffer to hold the image handle so as to
- // keep consistent with the above clause
- //
- DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
- ASSERT (DriverImageHandleBuffer);
- DriverImageHandleBuffer[0] = DriverImageHandle;
- }
-
- for (OuterLoopCounter = 0; OuterLoopCounter < DriverImageHandleCount; OuterLoopCounter++) {
- Iso639Language = FALSE;
- Status = gBS->OpenProtocol (
- DriverImageHandleBuffer[OuterLoopCounter],
- &gEfiDriverConfiguration2ProtocolGuid,
- (VOID **) &DriverConfiguration,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- Iso639Language = TRUE;
- Status = gBS->OpenProtocol (
- DriverImageHandleBuffer[OuterLoopCounter],
- &gEfiDriverConfigurationProtocolGuid,
- (VOID **) &DriverConfiguration,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- }
- if (EFI_ERROR (Status)) {
-// ShellPrintHiiEx(
-// -1,
-// -1,
-// NULL,
-// STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
-// gShellDriver1HiiHandle,
-// ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter])
-// );
- ShellStatus = SHELL_UNSUPPORTED;
- continue;
- }
-
- BestLanguage = GetBestLanguage (
- DriverConfiguration->SupportedLanguages,
- Iso639Language,
- Language!=NULL?Language:"",
- DriverConfiguration->SupportedLanguages,
- NULL
- );
- if (BestLanguage == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_NO_VALUE),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"-l"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- continue;
- }
-
- Status = ParseHandleDatabaseByRelationshipWithType (
- DriverImageHandleBuffer[OuterLoopCounter],
- NULL,
- &HandleCount,
- &HandleBuffer,
- &HandleType
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (SetOptions && DeviceHandle == NULL) {
-
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- NULL,
- NULL,
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_ALL_LANG),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]),
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
- for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
- if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) == HR_CONTROLLER_HANDLE) {
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
- }
- }
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- }
- continue;
- }
-
- for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
- if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) != HR_CONTROLLER_HANDLE) {
- continue;
- }
- if (DeviceHandle != NULL && DeviceHandle != HandleBuffer[LoopCounter]) {
- continue;
- }
- if (ChildHandle == NULL) {
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- DriverConfiguration->SupportedLanguages
- );
-
- if (ForceDefaults) {
- Status = DriverConfiguration->ForceDefaults (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL,
- DefaultType,
- &ActionRequired
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
- gShellDriver1HiiHandle);
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (ValidateOptions) {
- Status = DriverConfiguration->OptionsValid (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
- gShellDriver1HiiHandle);
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (SetOptions) {
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL,
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- Print (L"\n");
- }
- }
-
- if (ChildHandle == NULL && !AllChildren) {
- continue;
- }
-
- Status = ParseHandleDatabaseByRelationshipWithType (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- &ChildHandleCount,
- &ChildHandleBuffer,
- &ChildHandleType
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
-
- if ((ChildHandleType[ChildIndex] & HR_CHILD_HANDLE) != HR_CHILD_HANDLE) {
- continue;
- }
-
- if (ChildHandle != NULL && ChildHandle != ChildHandleBuffer[ChildIndex]) {
- continue;
- }
-
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- HandleIndex3,
- DriverConfiguration->SupportedLanguages);
-
- if (ForceDefaults) {
- Status = DriverConfiguration->ForceDefaults (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- DefaultType,
- &ActionRequired
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (ValidateOptions) {
- Status = DriverConfiguration->OptionsValid (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex]
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
- gShellDriver1HiiHandle);
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (SetOptions) {
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- HandleIndex3,
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- Print (L"\n");
- }
- }
-
- FreePool (ChildHandleBuffer);
- FreePool (ChildHandleType);
- }
-
- FreePool (BestLanguage);
- FreePool (HandleBuffer);
- FreePool (HandleType);
- }
-
- if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
- FreePool (DriverImageHandleBuffer);
- }
-
-Done:
- return ShellStatus;
-}
-
-/**
- Function to print out configuration information on all configurable handles.
-
- @param[in] ChildrenToo TRUE to tewst for children.
- @param[in] Language ASCII string for language code.
- @param[in] UseHii TRUE to check for Hii and DPC, FALSE for DCP only.
-
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-PrintConfigInfoOnAll(
- IN CONST BOOLEAN ChildrenToo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN UseHii
- )
-{
- EFI_HANDLE *HandleList;
- EFI_HANDLE *CurrentHandle;
- BOOLEAN Found;
- UINTN Index2;
-
-
- Found = FALSE;
- HandleList = NULL;
- CurrentHandle = NULL;
-
- if (UseHii) {
- //
- // HII method
- //
- HandleList = GetHandleListByProtocol(&gEfiHiiConfigAccessProtocolGuid);
- for (CurrentHandle = HandleList ; CurrentHandle != NULL && *CurrentHandle != NULL; CurrentHandle++){
- Found = TRUE;
- Index2 = *CurrentHandle == NULL ? 0 : ConvertHandleToHandleIndex(*CurrentHandle);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_LINE_HII),
- gShellDriver1HiiHandle,
- Index2
- );
- }
- SHELL_FREE_NON_NULL(HandleList);
- }
-
- if (PreHiiDrvCfg (
- Language,
- FALSE,
- 0,
- ChildrenToo,
- FALSE,
- FALSE,
- 0,
- 0,
- 0) == SHELL_SUCCESS) {
- Found = TRUE;
- }
-
- if (!Found) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE_FOUND), gShellDriver1HiiHandle);
- return (SHELL_SUCCESS);
- }
-
- return (SHELL_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamListHii[] = {
- {L"-s", TypeFlag},
- {L"-l", TypeValue},
- {L"-f", TypeValue},
- {L"-o", TypeValue},
- {L"-i", TypeValue},
- {NULL, TypeMax}
- };
-STATIC CONST SHELL_PARAM_ITEM ParamListPreHii[] = {
- {L"-c", TypeFlag},
- {L"-s", TypeFlag},
- {L"-v", TypeFlag},
- {L"-l", TypeValue},
- {L"-f", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'drvcfg' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrvCfg (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CONST CHAR16 *HandleIndex1;
- CONST CHAR16 *HandleIndex2;
- CONST CHAR16 *HandleIndex3;
- CONST CHAR16 *ForceTypeString;
- BOOLEAN Force;
- BOOLEAN Set;
- BOOLEAN Validate;
- BOOLEAN InFromFile;
- BOOLEAN OutToFile;
- BOOLEAN AllChildren;
- BOOLEAN UseHii;
- UINT32 ForceType;
- UINT64 Intermediate;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- CONST CHAR16 *FileName;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
- UseHii = TRUE;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamListHii, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status) || ShellCommandLineGetCount(Package) > 2) {
- UseHii = FALSE;
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- SHELL_FREE_NON_NULL(ProblemParam);
- Status = ShellCommandLineParse (ParamListPreHii, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"drvcfg", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else {
- ASSERT(FALSE);
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (ShellCommandLineGetFlag(Package, L"-l")){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-l");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- Set = ShellCommandLineGetFlag (Package, L"-s");
- Validate = ShellCommandLineGetFlag (Package, L"-v");
- InFromFile = ShellCommandLineGetFlag (Package, L"-i");
- OutToFile = ShellCommandLineGetFlag (Package, L"-o");
- AllChildren = ShellCommandLineGetFlag (Package, L"-c");
- Force = ShellCommandLineGetFlag (Package, L"-f");
- ForceTypeString = ShellCommandLineGetValue(Package, L"-f");
-
- if (OutToFile) {
- FileName = ShellCommandLineGetValue(Package, L"-o");
- } else if (InFromFile) {
- FileName = ShellCommandLineGetValue(Package, L"-i");
- } else {
- FileName = NULL;
- }
-
- if (InFromFile && EFI_ERROR(ShellFileExists(FileName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL), gShellDriver1HiiHandle, L"drvcfg", FileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile && !EFI_ERROR(ShellFileExists(FileName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_EXIST), gShellDriver1HiiHandle, L"drvcfg", FileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Force && ForceTypeString == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Force) {
- Status = ShellConvertStringToUint64(ForceTypeString, &Intermediate, FALSE, FALSE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDriver1HiiHandle, L"drvcfg", ForceTypeString, L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- ForceType = (UINT32)Intermediate;
- } else {
- ForceType = 0;
- }
- HandleIndex1 = ShellCommandLineGetRawValue(Package, 1);
- Handle1 = NULL;
- if (HandleIndex1 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex1, &Intermediate, TRUE, FALSE))) {
- Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle1 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- HandleIndex2 = ShellCommandLineGetRawValue(Package, 2);
- Handle2 = NULL;
- if (HandleIndex2 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex2, &Intermediate, TRUE, FALSE))) {
- Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle2 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- HandleIndex3 = ShellCommandLineGetRawValue(Package, 3);
- Handle3 = NULL;
- if (HandleIndex3 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex3, &Intermediate, TRUE, FALSE))) {
- Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle3 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex3);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- if ((InFromFile || OutToFile) && (FileName == NULL)) {
- if (FileName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", InFromFile?L"-i":L"-o");
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_REQ), gShellDriver1HiiHandle, L"drvcfg");
- }
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (!UseHii && (InFromFile || OutToFile)) {
- if (InFromFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-i");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-o");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- if (Validate && Force) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Validate && Set) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Set && Force) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-s", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile && InFromFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-i", L"-o");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- //
- // We do HII first.
- //
- if (UseHii) {
- if (Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- //
- // no HII on this handle.
- //
- ShellStatus = SHELL_UNSUPPORTED;
- } else if (Validate) {
- } else if (Force) {
- } else if (Set) {
- } else if (InFromFile) {
- ShellStatus = ConfigFromFile(Handle1, FileName);
- if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
- goto Done;
- }
- } else if (OutToFile) {
- ShellStatus = ConfigToFile(Handle1, FileName);
- if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
- goto Done;
- }
- } else if (HandleIndex1 == NULL) {
- //
- // display all that are configurable
- //
- ShellStatus = PrintConfigInfoOnAll(AllChildren, Language, UseHii);
- goto Done;
- } else {
- if (!EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_LINE_HII),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle1)
- );
- goto Done;
- }
- }
- }
-
- //
- // We allways need to do this one since it does both by default.
- //
- if (!InFromFile && !OutToFile) {
- ShellStatus = PreHiiDrvCfg (
- Language,
- Force,
- ForceType,
- AllChildren,
- Validate,
- Set,
- Handle1,
- Handle2,
- Handle3);
- }
-
- if (ShellStatus == SHELL_UNSUPPORTED) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle1)
- );
- }
- }
-
-Done:
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(Language);
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
deleted file mode 100644
index 271271120b..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/** @file
- Main file for DrvDiag shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST EFI_GUID *DiagGuidList[] = {&gEfiDriverDiagnosticsProtocolGuid, &gEfiDriverDiagnostics2ProtocolGuid, NULL};
-//
-// We need 1 more item on the list...
-//
-typedef enum {
- TestModeStandard = EfiDriverDiagnosticTypeStandard,
- TestModeExtended = EfiDriverDiagnosticTypeExtended,
- TestModeManufacturing = EfiDriverDiagnosticTypeManufacturing,
- TestModeList,
- TestModeMax
-} DRV_DIAG_TEST_MODE;
-
-/**
- Do the diagnostics call for some set of handles.
-
- @param[in] Mode The type of diagnostic test to run.
- @param[in] Lang The language code to use.
- @param[in] AllChilds Should the test be on all children.
- @param[in] DriverHandle The driver handle to test with.
- @param[in] ControllerHandle The specific controller handle to test.
- @param[in] ChildHandle The specific child handle to test.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_INVALID_PARAMETER A parameter had an invalid value.
- @retval EFI_NOT_FOUND No diagnostic handle could be found.
-**/
-EFI_STATUS
-EFIAPI
-DoDiagnostics (
- IN CONST DRV_DIAG_TEST_MODE Mode,
- IN CONST CHAR8 *Lang,
- IN CONST BOOLEAN AllChilds,
- IN CONST EFI_HANDLE DriverHandle,
- IN CONST EFI_HANDLE ControllerHandle,
- IN CONST EFI_HANDLE ChildHandle
- )
-{
- EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
- EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
- EFI_HANDLE *DriverHandleList;
- EFI_HANDLE *ControllerHandleList;
- EFI_HANDLE *ChildHandleList;
- EFI_HANDLE *Walker;
- UINTN DriverHandleListCount;
- UINTN ControllerHandleListCount;
- UINTN ChildHandleListCount;
- UINTN DriverHandleListLoop;
- UINTN ControllerHandleListLoop;
- UINTN ChildHandleListLoop;
- EFI_STATUS Status;
- EFI_STATUS Status2;
- EFI_GUID *ErrorType;
- UINTN OutBufferSize;
- CHAR16 *OutBuffer;
- UINTN HandleIndex1;
- UINTN HandleIndex2;
- CHAR8 *Language;
- BOOLEAN Found;
-
- if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
- return (EFI_INVALID_PARAMETER);
- }
-
- DriverDiagnostics = NULL;
- DriverDiagnostics2 = NULL;
- Status = EFI_SUCCESS;
- Status2 = EFI_SUCCESS;
- DriverHandleList = NULL;
- ControllerHandleList = NULL;
- ChildHandleList = NULL;
- Language = NULL;
- OutBuffer = NULL;
- ErrorType = NULL;
- DriverHandleListCount = 0;
- ControllerHandleListCount = 0;
- ChildHandleListCount = 0;
-
- if (DriverHandle != NULL) {
- DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(DriverHandleList!=NULL);
- DriverHandleList[0] = DriverHandle;
- DriverHandleListCount = 1;
- } else {
- DriverHandleList = GetHandleListByProtocolList(DiagGuidList);
- if (DriverHandleList == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"drvdiag", L"gEfiDriverDiagnosticsProtocolGuid", &gEfiDriverDiagnosticsProtocolGuid);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"drvdiag", L"gEfiDriverDiagnostics2ProtocolGuid", &gEfiDriverDiagnostics2ProtocolGuid);
- return (EFI_NOT_FOUND);
- }
- for (Walker = DriverHandleList ; Walker != NULL && *Walker != NULL ; DriverHandleListCount++, Walker++);
- }
-
- if (ControllerHandle != NULL) {
- ControllerHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(ControllerHandleList!=NULL);
- ControllerHandleList[0] = ControllerHandle;
- ControllerHandleListCount = 1;
- } else {
- ControllerHandleList = NULL;
- }
-
- if (ChildHandle != NULL) {
- ChildHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(ChildHandleList!=NULL);
- ChildHandleList[0] = ChildHandle;
- ChildHandleListCount = 1;
- } else if (AllChilds) {
- ChildHandleList = NULL;
- //
- // This gets handled in the loop below.
- //
- } else {
- ChildHandleList = NULL;
- }
-
- if (Mode == TestModeList) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_HEADER), gShellDriver1HiiHandle);
- }
- for (DriverHandleListLoop = 0
- ; DriverHandleListLoop < DriverHandleListCount
- ; DriverHandleListLoop++
- ){
- if (Mode == TestModeList) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_DRIVER_HEADER), gShellDriver1HiiHandle, ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]));
- }
- if (ControllerHandle == NULL) {
- PARSE_HANDLE_DATABASE_DEVICES(DriverHandleList[DriverHandleListLoop], &ControllerHandleListCount, &ControllerHandleList);
- }
- if (ControllerHandleListCount == 0) {
- if (Mode == TestModeList) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_DRIVER_NO_HANDLES), gShellDriver1HiiHandle);
- }
- } else {
- if (Mode == TestModeList) {
- ShellPrintEx(-1, -1, L"\r\n");
- }
- for (ControllerHandleListLoop = 0
- ; ControllerHandleListLoop < ControllerHandleListCount
- ; ControllerHandleListLoop++
- ){
- if (AllChilds) {
- ASSERT(ChildHandleList == NULL);
- PARSE_HANDLE_DATABASE_MANAGED_CHILDREN(
- DriverHandleList[DriverHandleListLoop],
- ControllerHandleList[ControllerHandleListLoop],
- &ChildHandleListCount,
- &ChildHandleList);
- }
- for (ChildHandleListLoop = 0
- ; (ChildHandleListLoop < ChildHandleListCount || ChildHandleList == NULL)
- ; ChildHandleListLoop++
- ){
- Found = FALSE;
- if (Mode != TestModeList) {
- if (Lang == NULL || Lang[2] == '-') {
- //
- // Get the protocol pointer and call the function
- //
- Status = gBS->OpenProtocol(
- DriverHandleList[DriverHandleListLoop],
- &gEfiDriverDiagnostics2ProtocolGuid,
- (VOID**)&DriverDiagnostics2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status) && (DriverDiagnostics2 != NULL)) {
- Language = GetBestLanguageForDriver(DriverDiagnostics2->SupportedLanguages, Lang, FALSE);
- Found = TRUE;
- Status = DriverDiagnostics2->RunDiagnostics(
- DriverDiagnostics2,
- ControllerHandleList[ControllerHandleListLoop],
- ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
- (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
- Language,
- &ErrorType,
- &OutBufferSize,
- &OutBuffer);
- FreePool(Language);
- }
- }
- if (!Found && (Lang == NULL||(Lang!=NULL&&(Lang[2]!='-')))){
- Status = gBS->OpenProtocol(
- DriverHandleList[DriverHandleListLoop],
- &gEfiDriverDiagnosticsProtocolGuid,
- (VOID**)&DriverDiagnostics,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- Language = GetBestLanguageForDriver(DriverDiagnostics->SupportedLanguages, Lang, FALSE);
- Status = DriverDiagnostics->RunDiagnostics(
- DriverDiagnostics,
- ControllerHandleList[ControllerHandleListLoop],
- ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
- (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
- Language,
- &ErrorType,
- &OutBufferSize,
- &OutBuffer);
- FreePool(Language);
- }
- }
- if (EFI_ERROR(Status)) {
- Status2 = Status;
- }
- HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
- HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_3P_RESULT),
- gShellDriver1HiiHandle,
- L"DrvDiag",
- HandleIndex1,
- HandleIndex2,
- ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop]),
- Status);
- if (OutBuffer!=NULL) {
- FreePool(OutBuffer);
- OutBuffer = NULL;
- }
- if (ErrorType!=NULL) {
- FreePool(ErrorType);
- ErrorType = NULL;
- }
- } else {
- HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
- HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
- //
- // Print out the information that this set can be tested
- //
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRV_DIAG_ITEM_LINE),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop])
- );
- }
-
- //
- // If we are doing a single pass with NULL child jump out after a single loop
- //
- if (ChildHandleList == NULL) {
- break;
- }
- }
- if (AllChilds) {
- SHELL_FREE_NON_NULL(ChildHandleList);
- ChildHandleList = NULL;
- ChildHandleListCount = 0;
- }
- }
- if (ControllerHandle == NULL) {
- SHELL_FREE_NON_NULL(ControllerHandleList);
- ControllerHandleList = NULL;
- ControllerHandleListCount = 0;
- }
- }
- }
-
- if (DriverHandleList != NULL) {
- FreePool(DriverHandleList);
- }
- if (ControllerHandleList != NULL) {
- FreePool(ControllerHandleList);
- }
- if (ChildHandleList != NULL) {
- FreePool(ChildHandleList);
- }
- return (Status2);
-}
-
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-c", TypeFlag},
- {L"-s", TypeFlag},
- {L"-e", TypeFlag},
- {L"-m", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'drvdiag' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrvDiag (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- DRV_DIAG_TEST_MODE Mode;
- CHAR8 *Language;
- CONST CHAR16 *DriverHandleStr;
- CONST CHAR16 *ControllerHandleStr;
- CONST CHAR16 *ChildHandleStr;
- CONST CHAR16 *Lang;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- Mode = TestModeMax;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"drvdiag", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 3 'value' parameters (plus the name one) or we have any 2 mode flags
- //
- if ((ShellCommandLineGetCount(Package) > 4)
- ||(ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-e"))
- ||(ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-m"))
- ||(ShellCommandLineGetFlag(Package, L"-e") && ShellCommandLineGetFlag(Package, L"-m"))
- ){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drvdiag");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((ShellCommandLineGetFlag(Package, L"-s"))
- || (ShellCommandLineGetFlag(Package, L"-e"))
- || (ShellCommandLineGetFlag(Package, L"-m"))
- ){
- //
- // Run the apropriate test
- //
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- Mode = TestModeStandard;
- } else if (ShellCommandLineGetFlag(Package, L"-e")) {
- Mode = TestModeExtended;
- } else if (ShellCommandLineGetFlag(Package, L"-m")) {
- Mode = TestModeManufacturing;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // Do a listing of what's available to test
- //
- Mode = TestModeList;
- }
-
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (ShellCommandLineGetFlag(Package, L"-l") && Lang == NULL) {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvdiag", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- } else if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- }
-
- DriverHandleStr = ShellCommandLineGetRawValue(Package, 1);
- ControllerHandleStr = ShellCommandLineGetRawValue(Package, 2);
- ChildHandleStr = ShellCommandLineGetRawValue(Package, 3);
-
- if (DriverHandleStr == NULL) {
- Handle1 = NULL;
- } else {
- ShellConvertStringToUint64(DriverHandleStr, &Intermediate, TRUE, FALSE);
- Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
- if (ControllerHandleStr == NULL) {
- Handle2 = NULL;
- } else {
- ShellConvertStringToUint64(ControllerHandleStr, &Intermediate, TRUE, FALSE);
- Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
- if (ChildHandleStr == NULL) {
- Handle3 = NULL;
- } else {
- ShellConvertStringToUint64(ChildHandleStr, &Intermediate, TRUE, FALSE);
- Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
-
- Status = DoDiagnostics (
- Mode,
- Language,
- ShellCommandLineGetFlag(Package, L"-c"),
- Handle1,
- Handle2,
- Handle3
- );
-
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
-
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Status == EFI_NOT_FOUND) {
- ShellStatus = SHELL_NOT_FOUND;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
deleted file mode 100644
index e11873aa10..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/** @file
- Main file for OpenInfo shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST CHAR16 StringHandProt[] = L"HandProt ";
-STATIC CONST CHAR16 StringGetProt[] = L"GetProt ";
-STATIC CONST CHAR16 StringTestProt[] = L"TestProt ";
-STATIC CONST CHAR16 StringChild[] = L"Child ";
-STATIC CONST CHAR16 StringDriver[] = L"Driver ";
-STATIC CONST CHAR16 StringExclusive[] = L"Exclusive";
-STATIC CONST CHAR16 StringDriverEx[] = L"DriverEx ";
-STATIC CONST CHAR16 StringUnknown[] = L"Unknown ";
-
-/**
- Open the database and print out all the info about TheHandle.
-
- @param[in] TheHandle The handle to print info on.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_INVALID_PARAMETER TheHandle was NULL.
-**/
-EFI_STATUS
-EFIAPI
-TraverseHandleDatabase (
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
- UINTN OpenInfoCount;
- UINTN OpenInfoIndex;
- CONST CHAR16 *OpenTypeString;
- CHAR16 *TempString;
- UINTN HandleIndex;
- CONST CHAR16 *Name;
- UINTN ControllerIndex;
-
- if (TheHandle == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // Retrieve the list of all the protocols on the handle
- //
- Status = gBS->ProtocolsPerHandle (
- TheHandle,
- &ProtocolGuidArray,
- &ArrayCount
- );
- ASSERT_EFI_ERROR(Status);
- if (!EFI_ERROR (Status)) {
-
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- //
- // print out the human readable name for this one.
- //
- TempString = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], NULL);
- if (TempString == NULL) {
- continue;
- }
- ShellPrintEx(-1, -1, L"%H%s%N\r\n", TempString);
- FreePool(TempString);
-
- //
- // Retrieve the list of agents that have opened each protocol
- //
- Status = gBS->OpenProtocolInformation (
- TheHandle,
- ProtocolGuidArray[ProtocolIndex],
- &OpenInfo,
- &OpenInfoCount
- );
- ASSERT_EFI_ERROR(Status);
- if (!EFI_ERROR (Status)) {
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- switch (OpenInfo[OpenInfoIndex].Attributes) {
- case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL: OpenTypeString = StringHandProt; break;
- case EFI_OPEN_PROTOCOL_GET_PROTOCOL: OpenTypeString = StringGetProt; break;
- case EFI_OPEN_PROTOCOL_TEST_PROTOCOL: OpenTypeString = StringTestProt; break;
- case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER: OpenTypeString = StringChild; break;
- case EFI_OPEN_PROTOCOL_BY_DRIVER: OpenTypeString = StringDriver; break;
- case EFI_OPEN_PROTOCOL_EXCLUSIVE: OpenTypeString = StringExclusive; break;
- case EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE:
- OpenTypeString = StringDriverEx; break;
- default: OpenTypeString = StringUnknown; break;
- }
- HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
- Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
- ControllerIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle);
- if (ControllerIndex != 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_OPENINFO_LINE),
- gShellDriver1HiiHandle,
- HandleIndex,
- ControllerIndex,
- OpenInfo[OpenInfoIndex].OpenCount,
- OpenTypeString,
- Name
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_OPENINFO_MIN_LINE),
- gShellDriver1HiiHandle,
- HandleIndex,
- OpenInfo[OpenInfoIndex].OpenCount,
- OpenTypeString,
- Name
- );
- }
- }
- FreePool (OpenInfo);
- }
- }
- FreePool (ProtocolGuidArray);
- }
-
- return Status;
-}
-
-/**
- Function for 'openinfo' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunOpenInfo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- EFI_HANDLE TheHandle;
- CONST CHAR16 *Param1;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"openinfo", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"openinfo");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"openinfo");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Status = ShellConvertStringToUint64(Param1, &Intermediate, TRUE, FALSE);
- if (EFI_ERROR(Status) || Param1 == NULL || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"openinfo", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TheHandle = ConvertHandleIndexToHandle((UINTN)Intermediate);
- ASSERT(TheHandle != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_OPENINFO_HEADER_LINE), gShellDriver1HiiHandle, (UINTN)Intermediate, TheHandle);
-
- Status = TraverseHandleDatabase (TheHandle);
- if (!EFI_ERROR(Status)) {
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"openinfo", Param1);
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- }
- }
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
deleted file mode 100644
index d2ae8e8271..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/** @file
- Main file for Reconnect shell Driver1 function.
-
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Connect all the possible console devices.
-
-**/
-VOID
-ConnectAllConsoles (
- VOID
- )
-{
- ShellConnectFromDevPaths(L"ConInDev");
- ShellConnectFromDevPaths(L"ConOutDev");
- ShellConnectFromDevPaths(L"ErrOutDev");
-
- ShellConnectFromDevPaths(L"ErrOut");
- ShellConnectFromDevPaths(L"ConIn");
- ShellConnectFromDevPaths(L"ConOut");
-}
-
-
-/**
- Function for 'reconnect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunReconnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SHELL_STATUS ShellStatus;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- EFI_STATUS Status;
-
- gInReconnect = TRUE;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"reconnect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- ShellStatus = ShellCommandRunDisconnect(ImageHandle, SystemTable);
- if (ShellStatus == SHELL_SUCCESS) {
- if (ShellCommandLineGetFlag(Package, L"-r")) {
- ConnectAllConsoles();
- }
- ShellStatus = ShellCommandRunConnect(ImageHandle, SystemTable);
- }
- }
-
- gInReconnect = FALSE;
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c
deleted file mode 100644
index 95cd9a0ca8..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/** @file
- Main file for NULL named library for level 1 shell command functions.
-
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST CHAR16 mFileName[] = L"Driver1Commands";
-EFI_HANDLE gShellDriver1HiiHandle = NULL;
-BOOLEAN gInReconnect = FALSE;
-
-/**
- Function to return the name of the file containing help if HII will not be used.
-
- @return The filename.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameDriver1 (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Driver1 Commands library.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-UefiShellDriver1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT0) == 0) {
- return (EFI_SUCCESS);
- }
-
- //
- // install the HII stuff.
- //
- gShellDriver1HiiHandle = HiiAddPackages (&gShellDriver1HiiGuid, gImageHandle, UefiShellDriver1CommandsLibStrings, NULL);
- if (gShellDriver1HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"connect", ShellCommandRunConnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_CONNECT) );
- ShellCommandRegisterCommandName(L"devices", ShellCommandRunDevices , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DEVICES) );
- ShellCommandRegisterCommandName(L"openinfo", ShellCommandRunOpenInfo , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_OPENINFO) );
- ShellCommandRegisterCommandName(L"disconnect", ShellCommandRunDisconnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DISCONNECT));
- ShellCommandRegisterCommandName(L"reconnect", ShellCommandRunReconnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_RECONNECT) );
- ShellCommandRegisterCommandName(L"unload", ShellCommandRunUnload , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_UNLOAD) );
- ShellCommandRegisterCommandName(L"drvdiag", ShellCommandRunDrvDiag , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRVDIAG) );
- ShellCommandRegisterCommandName(L"dh", ShellCommandRunDh , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DH) );
- ShellCommandRegisterCommandName(L"drivers", ShellCommandRunDrivers , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRIVERS) );
- ShellCommandRegisterCommandName(L"devtree", ShellCommandRunDevTree , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DEVTREE) );
- ShellCommandRegisterCommandName(L"drvcfg", ShellCommandRunDrvCfg , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRVCFG) );
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-UefiShellDriver1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellDriver1HiiHandle != NULL) {
- HiiRemovePackages(gShellDriver1HiiHandle);
- }
- return (EFI_SUCCESS);
-}
-
-
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
deleted file mode 100644
index c65d0ed695..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/** @file
- Main file for NULL named library for Profile1 shell command functions.
-
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_
-#define _UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/GlobalVariable.h>
-#include <Guid/ConsoleInDevice.h>
-#include <Guid/ConsoleOutDevice.h>
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <IndustryStandard/Pci.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/DriverDiagnostics2.h>
-#include <Protocol/DriverDiagnostics.h>
-#include <Protocol/PlatformDriverOverride.h>
-#include <Protocol/BusSpecificDriverOverride.h>
-#include <Protocol/PlatformToDriverConfiguration.h>
-#include <Protocol/DriverSupportedEfiVersion.h>
-#include <Protocol/DriverFamilyOverride.h>
-#include <Protocol/DriverHealth.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/HandleParsingLib.h>
-
-
-extern EFI_HANDLE gShellDriver1HiiHandle;
-extern BOOLEAN gInReconnect;
-
-/**
- Function for 'connect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunConnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'devices' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDevices (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'openinfo' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunOpenInfo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'devtree' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDevTree (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'dh' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDh (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'disconnect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDisconnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'drivers' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrivers (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'drvcfg' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrvCfg (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'drvdiag' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDrvDiag (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'reconnect' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunReconnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'unload' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunUnload (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Do a connect from an EFI variable via it's key name.
-
- @param[in] Key The name of the EFI Variable.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellConnectFromDevPaths (
- IN CONST CHAR16 *Key
- );
-
-
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
deleted file mode 100644
index f2a2e4c581..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
+++ /dev/null
@@ -1,73 +0,0 @@
-## @file
-# Provides shell driver1 profile functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellDriver1CommandsLib
- FILE_GUID = 313D3674-3ED4-48fd-BF97-7DB35D4190D1
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = UefiShellDriver1CommandsLibConstructor
- DESTRUCTOR = UefiShellDriver1CommandsLibDestructor
-
-[Sources]
- Connect.c
- Devices.c
- OpenInfo.c
- Disconnect.c
- Reconnect.c
- Unload.c
- DrvDiag.c
- Dh.c
- Drivers.c
- DevTree.c
- DrvCfg.c
- UefiShellDriver1CommandsLib.c
- UefiShellDriver1CommandsLib.h
- UefiShellDriver1CommandsLib.uni
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
- PeCoffGetEntryPointLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
-[Protocols]
- gEfiDriverHealthProtocolGuid ## CONSUMES
- gEfiDriverFamilyOverrideProtocolGuid ## CONSUMES
- gEfiHiiConfigAccessProtocolGuid ## CONSUMES
- gEfiHiiDatabaseProtocolGuid ## CONSUMES
-
-[Guids]
- gEfiGlobalVariableGuid ## CONSUMES ## GUID
- gEfiConsoleInDeviceGuid ## CONSUMES ## GUID
- gEfiConsoleOutDeviceGuid ## CONSUMES ## GUID
- gShellDriver1HiiGuid ## PRODUCES ## HII
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
deleted file mode 100644
index a28985300e..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c
deleted file mode 100644
index 0d48f9d5d7..0000000000
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/** @file
- Main file for Unload shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellDriver1CommandsLib.h"
-
-/**
- Function to dump LoadedImage info from TheHandle.
-
- @param[in] TheHandle The handle to dump info from.
-
- @retval EFI_SUCCESS The info was dumped.
- @retval EFI_INVALID_PARAMETER The handle did not have LoadedImage
-**/
-EFI_STATUS
-EFIAPI
-DumpLoadedImageProtocolInfo (
- IN EFI_HANDLE TheHandle
- )
-{
- CHAR16 *TheString;
-
- TheString = GetProtocolInformationDump(TheHandle, &gEfiLoadedImageProtocolGuid, TRUE);
-
- ShellPrintEx(-1, -1, L"%s", TheString);
-
- SHELL_FREE_NON_NULL(TheString);
-
- return (EFI_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-n", TypeFlag},
- {L"-v", TypeFlag},
- {L"-verbose", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'unload' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunUnload (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- EFI_HANDLE TheHandle;
- CONST CHAR16 *Param1;
- SHELL_PROMPT_RESPONSE *Resp;
- UINT64 Value;
-
- ShellStatus = SHELL_SUCCESS;
- Package = NULL;
- Resp = NULL;
- Value = 0;
- TheHandle = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle,L"unload", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"unload");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"unload");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 != NULL) {
- Status = ShellConvertStringToUint64(Param1, &Value, TRUE, FALSE);
- TheHandle = ConvertHandleIndexToHandle((UINTN)Value);
- }
-
- if (EFI_ERROR(Status) || Param1 == NULL || TheHandle == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"unload", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(TheHandle != NULL);
- if (ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose")) {
- DumpLoadedImageProtocolInfo(TheHandle);
- }
-
- if (!ShellCommandLineGetFlag(Package, L"-n")) {
- Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_UNLOAD_CONF), gShellDriver1HiiHandle, (UINTN)TheHandle);
- Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);
- }
- if (ShellCommandLineGetFlag(Package, L"-n") || (Resp != NULL && *Resp == ShellPromptResponseYes)) {
- Status = gBS->UnloadImage(TheHandle);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Unload", (UINTN)TheHandle, Status);
- }
- SHELL_FREE_NON_NULL(Resp);
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- if (Package != NULL) {
- ShellCommandLineFreeVarList(Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c b/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c
deleted file mode 100644
index e26a86283e..0000000000
--- a/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file
- Main file for NULL named library for install1 shell command functions.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 <Library/BcfgCommandLib.h>
-
-/**
- Constructor for the Shell Level 1 Commands library.
-
- Install the handlers for level 1 UEFI Shell 2.0 commands.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellInstall1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
- return (EFI_SUCCESS);
- }
-
- return (BcfgLibraryRegisterBcfgCommand(ImageHandle, SystemTable, L"Install1"));
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellInstall1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return (BcfgLibraryUnregisterBcfgCommand(ImageHandle, SystemTable));
-}
diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf b/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
deleted file mode 100644
index dc1b6223e7..0000000000
--- a/ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+++ /dev/null
@@ -1,51 +0,0 @@
-## @file
-# Provides shell install1 functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellInstall1CommandsLib
- FILE_GUID = D250E364-51C6-49ed-AEBF-6D83F5130F74
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellInstall1CommandsLibConstructor
- DESTRUCTOR = ShellInstall1CommandsLibDestructor
-
-[Sources.common]
- UefiShellInstall1CommandsLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
- BcfgCommandLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
-[Guids]
- gShellInstall1HiiGuid ## UNDEFINED
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
deleted file mode 100644
index 08e40dfc05..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file
- Main file for exit shell level 1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"/b", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'exit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunExit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINT64 RetVal;
- CONST CHAR16 *Return;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"exit", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
-
- //
- // return the specified error code
- //
- Return = ShellCommandLineGetRawValue(Package, 1);
- if (Return != NULL) {
- Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // If we are in a batch file and /b then pass TRUE otherwise false...
- //
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);
-
- ShellStatus = SHELL_SUCCESS;
- }
- } else {
- // If we are in a batch file and /b then pass TRUE otherwise false...
- //
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);
-
- ShellStatus = SHELL_SUCCESS;
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
deleted file mode 100644
index cbf0517013..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/** @file
- Main file for endfor and for shell level 1 functions.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-#include <Library/PrintLib.h>
-
-/**
- Determine if a valid string is a valid number for the 'for' command.
-
- @param[in] Number The pointer to the string representation of the number to test.
-
- @retval TRUE The number is valid.
- @retval FALSE The number is not valid.
-**/
-BOOLEAN
-EFIAPI
-ShellIsValidForNumber (
- IN CONST CHAR16 *Number
- )
-{
- if (Number == NULL || *Number == CHAR_NULL) {
- return (FALSE);
- }
-
- if (*Number == L'-') {
- Number++;
- }
-
- if (StrLen(Number) == 0) {
- return (FALSE);
- }
-
- if (StrLen(Number) >= 7) {
- if ((StrStr(Number, L" ") == NULL) || (((StrStr(Number, L" ") != NULL) && (StrStr(Number, L" ") - Number) >= 7))) {
- return (FALSE);
- }
- }
-
- if (!ShellIsDecimalDigitCharacter(*Number)) {
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-/**
- Function for 'endfor' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEndFor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- BOOLEAN Found;
- SCRIPT_FILE *CurrentScriptFile;
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor");
- return (SHELL_UNSUPPORTED);
- }
-
- if (gEfiShellParametersProtocol->Argc > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"endfor");
- return (SHELL_INVALID_PARAMETER);
- }
-
- Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
-
- if (!Found) {
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"For",
- L"EndFor",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_NOT_FOUND);
- }
- return (SHELL_SUCCESS);
-}
-
-typedef struct {
- UINT32 Signature;
- INTN Current;
- INTN End;
- INTN Step;
- CHAR16 *ReplacementName;
- CHAR16 *CurrentValue;
- BOOLEAN RemoveSubstAlias;
- CHAR16 Set[1];
- } SHELL_FOR_INFO;
-#define SIZE_OF_SHELL_FOR_INFO OFFSET_OF (SHELL_FOR_INFO, Set)
-#define SHELL_FOR_INFO_SIGNATURE SIGNATURE_32 ('S', 'F', 'I', 's')
-
-/**
- Update the value of a given alias on the list. If the alias is not there then add it.
-
- @param[in] Alias The alias to test for.
- @param[in] CommandString The updated command string.
- @param[in, out] List The list to search.
-
- @retval EFI_SUCCESS The operation was completed successfully.
- @retval EFI_OUT_OF_RESOURCES There was not enough free memory.
-**/
-EFI_STATUS
-EFIAPI
-InternalUpdateAliasOnList(
- IN CONST CHAR16 *Alias,
- IN CONST CHAR16 *CommandString,
- IN OUT LIST_ENTRY *List
- )
-{
- ALIAS_LIST *Node;
- BOOLEAN Found;
-
- //
- // assert for NULL parameter
- //
- ASSERT(Alias != NULL);
-
- //
- // check for the Alias
- //
- for ( Node = (ALIAS_LIST *)GetFirstNode(List), Found = FALSE
- ; !IsNull(List, &Node->Link)
- ; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- ASSERT(Node->Alias != NULL);
- if (StrCmp(Node->Alias, Alias)==0) {
- FreePool(Node->CommandString);
- Node->CommandString = NULL;
- Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
- Found = TRUE;
- break;
- }
- }
- if (!Found) {
- Node = AllocateZeroPool(sizeof(ALIAS_LIST));
- if (Node == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- ASSERT(Node->Alias == NULL);
- Node->Alias = StrnCatGrow(&Node->Alias, NULL, Alias, 0);
- ASSERT(Node->CommandString == NULL);
- Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
- InsertTailList(List, &Node->Link);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Find out if an alias is on the given list.
-
- @param[in] Alias The alias to test for.
- @param[in] List The list to search.
-
- @retval TRUE The alias is on the list.
- @retval FALSE The alias is not on the list.
-**/
-BOOLEAN
-EFIAPI
-InternalIsAliasOnList(
- IN CONST CHAR16 *Alias,
- IN CONST LIST_ENTRY *List
- )
-{
- ALIAS_LIST *Node;
-
- //
- // assert for NULL parameter
- //
- ASSERT(Alias != NULL);
-
- //
- // check for the Alias
- //
- for ( Node = (ALIAS_LIST *)GetFirstNode(List)
- ; !IsNull(List, &Node->Link)
- ; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- ASSERT(Node->Alias != NULL);
- if (StrCmp(Node->Alias, Alias)==0) {
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Remove an alias from the given list.
-
- @param[in] Alias The alias to remove.
- @param[in, out] List The list to search.
-**/
-BOOLEAN
-EFIAPI
-InternalRemoveAliasFromList(
- IN CONST CHAR16 *Alias,
- IN OUT LIST_ENTRY *List
- )
-{
- ALIAS_LIST *Node;
-
- //
- // assert for NULL parameter
- //
- ASSERT(Alias != NULL);
-
- //
- // check for the Alias
- //
- for ( Node = (ALIAS_LIST *)GetFirstNode(List)
- ; !IsNull(List, &Node->Link)
- ; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
- ){
- ASSERT(Node->CommandString != NULL);
- ASSERT(Node->Alias != NULL);
- if (StrCmp(Node->Alias, Alias)==0) {
- RemoveEntryList(&Node->Link);
- FreePool(Node->Alias);
- FreePool(Node->CommandString);
- FreePool(Node);
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Function to determine whether a string is decimal or hex representation of a number
- and return the number converted from the string.
-
- @param[in] String String representation of a number
-
- @return the number
- @retval (UINTN)(-1) An error ocurred.
-**/
-UINTN
-EFIAPI
-ReturnUintn(
- IN CONST CHAR16 *String
- )
-{
- UINT64 RetVal;
-
- if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, TRUE))) {
- return ((UINTN)RetVal);
- }
- return ((UINTN)(-1));
-}
-
-/**
- Function for 'for' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunFor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- SCRIPT_FILE *CurrentScriptFile;
- CHAR16 *ArgSet;
- CHAR16 *ArgSetWalker;
- CHAR16 *Parameter;
- UINTN ArgSize;
- UINTN LoopVar;
- SHELL_FOR_INFO *Info;
- CHAR16 *TempString;
- CHAR16 *TempSpot;
- BOOLEAN FirstPass;
- EFI_SHELL_FILE_INFO *Node;
- EFI_SHELL_FILE_INFO *FileList;
- UINTN NewSize;
-
- ArgSet = NULL;
- ArgSize = 0;
- ShellStatus = SHELL_SUCCESS;
- ArgSetWalker = NULL;
- TempString = NULL;
- Parameter = NULL;
- FirstPass = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"for");
- return (SHELL_UNSUPPORTED);
- }
-
- if (gEfiShellParametersProtocol->Argc < 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"for");
- return (SHELL_INVALID_PARAMETER);
- }
-
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- ASSERT(CurrentScriptFile != NULL);
-
- if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) {
- FirstPass = TRUE;
-
- //
- // Make sure that an End exists.
- //
- if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"EndFor",
- L"For",
- CurrentScriptFile->CurrentCommand->Line);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Process the line.
- //
- if (gEfiShellParametersProtocol->Argv[1][0] != L'%' || gEfiShellParametersProtocol->Argv[1][2] != CHAR_NULL
- ||!((gEfiShellParametersProtocol->Argv[1][1] >= L'a' && gEfiShellParametersProtocol->Argv[1][1] <= L'z')
- ||(gEfiShellParametersProtocol->Argv[1][1] >= L'A' && gEfiShellParametersProtocol->Argv[1][1] <= L'Z'))
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_VAR), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[1]);
- return (SHELL_INVALID_PARAMETER);
- }
-
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- L"in",
- gEfiShellParametersProtocol->Argv[2]) == 0) {
- for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
- ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
- if (StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"*") != NULL
- ||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"?") != NULL
- ||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"[") != NULL
- ||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"]") != NULL) {
- FileList = NULL;
- Status = ShellOpenFileMetaArg ((CHAR16*)gEfiShellParametersProtocol->Argv[LoopVar], EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
- } else {
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Node->FullName, 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
- }
- ShellCloseFileMetaArg(&FileList);
- }
- } else {
- Parameter = gEfiShellParametersProtocol->Argv[LoopVar];
- if (Parameter[0] == L'\"' && Parameter[StrLen(Parameter)-1] == L'\"') {
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);
- } else {
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
- }
- }
- }
- if (ArgSet == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- //
- // set up for an 'in' for loop
- //
- NewSize = StrSize(ArgSet);
- NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);
- Info = AllocateZeroPool(NewSize);
- ASSERT(Info != NULL);
- Info->Signature = SHELL_FOR_INFO_SIGNATURE;
- CopyMem(Info->Set, ArgSet, StrSize(ArgSet));
- NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);
- CopyMem(Info->Set+(StrSize(ArgSet)/sizeof(Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize);
- Info->ReplacementName = Info->Set+StrSize(ArgSet)/sizeof(Info->Set[0]);
- Info->CurrentValue = (CHAR16*)Info->Set;
- Info->Step = 0;
- Info->Current = 0;
- Info->End = 0;
-
- if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
- Info->RemoveSubstAlias = FALSE;
- } else {
- Info->RemoveSubstAlias = TRUE;
- }
- CurrentScriptFile->CurrentCommand->Data = Info;
- }
- } else if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- L"run",
- gEfiShellParametersProtocol->Argv[2]) == 0) {
- for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
- ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
- if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L")") != NULL &&
- (LoopVar + 1) < gEfiShellParametersProtocol->Argc
- ) {
- return (SHELL_INVALID_PARAMETER);
- }
- if (ArgSet == NULL) {
-// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
- } else {
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
- }
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
-// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
- }
- if (ArgSet == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- //
- // set up for a 'run' for loop
- //
- Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));
- ASSERT(Info != NULL);
- Info->Signature = SHELL_FOR_INFO_SIGNATURE;
- CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
- Info->ReplacementName = Info->Set;
- Info->CurrentValue = NULL;
- ArgSetWalker = ArgSet;
- if (ArgSetWalker[0] != L'(') {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TempSpot = StrStr(ArgSetWalker, L")");
- if (TempSpot != NULL) {
- TempString = TempSpot+1;
- if (*(TempString) != CHAR_NULL) {
- while(TempString != NULL && *TempString == L' ') {
- TempString++;
- }
- if (StrLen(TempString) > 0) {
- TempSpot = NULL;
- }
- }
- }
- if (TempSpot == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- *TempSpot = CHAR_NULL;
- ArgSetWalker++;
- while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
- ArgSetWalker++;
- }
- if (!ShellIsValidForNumber(ArgSetWalker)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ArgSetWalker[0] == L'-') {
- Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
- } else {
- Info->Current = (INTN)ReturnUintn(ArgSetWalker);
- }
- ArgSetWalker = StrStr(ArgSetWalker, L" ");
- while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
- ArgSetWalker++;
- }
- if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ArgSetWalker[0] == L'-') {
- Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
- } else {
- Info->End = (INTN)ReturnUintn(ArgSetWalker);
- }
- if (Info->Current < Info->End) {
- Info->Step = 1;
- } else {
- Info->Step = -1;
- }
-
- ArgSetWalker = StrStr(ArgSetWalker, L" ");
- while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
- ArgSetWalker++;
- }
- if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
- if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (*ArgSetWalker == L')') {
- ASSERT(Info->Step == 1 || Info->Step == -1);
- } else {
- if (ArgSetWalker[0] == L'-') {
- Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
- } else {
- Info->Step = (INTN)ReturnUintn(ArgSetWalker);
- }
-
- if (StrStr(ArgSetWalker, L" ") != NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile->CurrentCommand->Line);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
-
- }
- }
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
- Info->RemoveSubstAlias = FALSE;
- } else {
- Info->RemoveSubstAlias = TRUE;
- }
- }
- if (CurrentScriptFile->CurrentCommand != NULL) {
- CurrentScriptFile->CurrentCommand->Data = Info;
- }
- }
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
- gShellLevel1HiiHandle,
- ArgSet,
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- //
- // These need to be NULL since they are used to determine if this is the first pass later on...
- //
- ASSERT(ArgSetWalker == NULL);
- ASSERT(ArgSet == NULL);
- }
-
- if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) {
- Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;
- if (CurrentScriptFile->CurrentCommand->Reset) {
- Info->CurrentValue = (CHAR16*)Info->Set;
- FirstPass = TRUE;
- CurrentScriptFile->CurrentCommand->Reset = FALSE;
- }
- } else {
- ShellStatus = SHELL_UNSUPPORTED;
- Info = NULL;
- }
- if (ShellStatus == SHELL_SUCCESS) {
- ASSERT(Info != NULL);
- if (Info->Step != 0) {
- //
- // only advance if not the first pass
- //
- if (!FirstPass) {
- //
- // sequence version of for loop...
- //
- Info->Current += Info->Step;
- }
-
- TempString = AllocateZeroPool(50*sizeof(CHAR16));
- UnicodeSPrint(TempString, 50*sizeof(CHAR16), L"%d", Info->Current);
- InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
- FreePool(TempString);
-
- if ((Info->Step > 0 && Info->Current > Info->End) || (Info->Step < 0 && Info->Current < Info->End)) {
- CurrentScriptFile->CurrentCommand->Data = NULL;
- //
- // find the matching endfor (we're done with the loop)
- //
- if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"EndFor",
- L"For",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- if (Info->RemoveSubstAlias) {
- //
- // remove item from list
- //
- InternalRemoveAliasFromList(Info->ReplacementName, &CurrentScriptFile->SubstList);
- }
- FreePool(Info);
- }
- } else {
- //
- // Must be in 'in' version of for loop...
- //
- ASSERT(Info->Set != NULL);
- if (Info->CurrentValue != NULL && *Info->CurrentValue != CHAR_NULL) {
- if (Info->CurrentValue[0] == L' ') {
- Info->CurrentValue++;
- }
- if (Info->CurrentValue[0] == L'\"') {
- Info->CurrentValue++;
- }
- //
- // do the next one of the set
- //
- ASSERT(TempString == NULL);
- TempString = StrnCatGrow(&TempString, NULL, Info->CurrentValue, 0);
- if (TempString == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- TempSpot = StrStr(TempString, L"\" \"");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- while (TempString[StrLen(TempString)-1] == L'\"') {
- TempString[StrLen(TempString)-1] = CHAR_NULL;
- }
- InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
- Info->CurrentValue += StrLen(TempString);
-
- if (Info->CurrentValue[0] == L'\"') {
- Info->CurrentValue++;
- }
- FreePool(TempString);
- }
- } else {
- CurrentScriptFile->CurrentCommand->Data = NULL;
- //
- // find the matching endfor (we're done with the loop)
- //
- if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"EndFor",
- L"For",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- if (Info->RemoveSubstAlias) {
- //
- // remove item from list
- //
- InternalRemoveAliasFromList(Info->ReplacementName, &CurrentScriptFile->SubstList);
- }
- FreePool(Info);
- }
- }
- }
- if (ArgSet != NULL) {
- FreePool(ArgSet);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
deleted file mode 100644
index 88e290daa7..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/** @file
- Main file for goto shell level 1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-
-/**
- Function for 'goto' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunGoto (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR16 *CompareString;
- UINTN Size;
- SCRIPT_FILE *CurrentScriptFile;
-
- ShellStatus = SHELL_SUCCESS;
- CompareString = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Goto");
- return (SHELL_UNSUPPORTED);
- }
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"goto", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"goto");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"goto");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Size = 0;
- ASSERT((CompareString == NULL && Size == 0) || (CompareString != NULL));
- CompareString = StrnCatGrow(&CompareString, &Size, L":", 0);
- CompareString = StrnCatGrow(&CompareString, &Size, ShellCommandLineGetRawValue(Package, 1), 0);
- //
- // Check forwards and then backwards for a label...
- //
- if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- CompareString,
- L"Goto",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- ShellStatus = SHELL_NOT_FOUND;
- }
- FreePool(CompareString);
- }
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
deleted file mode 100644
index 7abfd8944b..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ /dev/null
@@ -1,1099 +0,0 @@
-/** @file
- Main file for If and else shell level 1 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-#include <Library/PrintLib.h>
-
-typedef enum {
- EndTagOr,
- EndTagAnd,
- EndTagThen,
- EndTagMax
-} END_TAG_TYPE;
-
-typedef enum {
- OperatorGreaterThan,
- OperatorLessThan,
- OperatorEqual,
- OperatorNotEqual,
- OperatorGreatorOrEqual,
- OperatorLessOrEqual,
- OperatorUnisgnedGreaterThan,
- OperatorUnsignedLessThan,
- OperatorUnsignedGreaterOrEqual,
- OperatorUnsignedLessOrEqual,
- OperatorMax
-} BIN_OPERATOR_TYPE;
-
-/**
- Extract the next fragment, if there is one.
-
- @param[in, out] Statement The current remaining statement.
- @param[in] Fragment The current fragment.
-
- @retval FALSE There is not another fragment.
- @retval TRUE There is another fragment.
-**/
-BOOLEAN
-EFIAPI
-IsNextFragment (
- IN OUT CONST CHAR16 **Statement,
- IN CONST CHAR16 *Fragment
- )
-{
- CHAR16 *Tester;
-
- Tester = NULL;
-
- Tester = StrnCatGrow(&Tester, NULL, *Statement, StrLen(Fragment));
- ASSERT(Tester != NULL);
- Tester[StrLen(Fragment)] = CHAR_NULL;
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)Fragment,
- Tester) == 0) {
- //
- // increment the string pointer to the end of what we found and then chop off spaces...
- //
- *Statement+=StrLen(Fragment);
- while (*Statement[0] == L' ') {
- (*Statement)++;
- }
- FreePool(Tester);
- return (TRUE);
- }
- FreePool(Tester);
- return (FALSE);
-}
-
-/**
- Determine if String represents a valid profile.
-
- @param[in] String The pointer to the string to test.
-
- @retval TRUE String is a valid profile.
- @retval FALSE String is not a valid profile.
-**/
-BOOLEAN
-EFIAPI
-IsValidProfile (
- IN CONST CHAR16 *String
- )
-{
- CONST CHAR16 *ProfilesString;
- CONST CHAR16 *TempLocation;
-
- ProfilesString = ShellGetEnvironmentVariable(L"profiles");
- ASSERT(ProfilesString != NULL);
- TempLocation = StrStr(ProfilesString, String);
- if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen(String)) == L';')) {
- return (TRUE);
- }
- return (FALSE);
-}
-
-/**
- Do a comparison between 2 things.
-
- @param[in] Compare1 The first item to compare.
- @param[in] Compare2 The second item to compare.
- @param[in] BinOp The type of comparison to perform.
- @param[in] CaseInsensitive TRUE to do non-case comparison, FALSE otherwise.
- @param[in] ForceStringCompare TRUE to force string comparison, FALSE otherwise.
-
- @return The result of the comparison.
-**/
-BOOLEAN
-EFIAPI
-TestOperation (
- IN CONST CHAR16 *Compare1,
- IN CONST CHAR16 *Compare2,
- IN CONST BIN_OPERATOR_TYPE BinOp,
- IN CONST BOOLEAN CaseInsensitive,
- IN CONST BOOLEAN ForceStringCompare
- )
-{
- INTN Cmp1;
- INTN Cmp2;
-
- //
- // "Compare1 BinOp Compare2"
- //
- switch (BinOp) {
- case OperatorUnisgnedGreaterThan:
- case OperatorGreaterThan:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) > 0) || (StringCompare(&Compare1, &Compare2) > 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (BinOp == OperatorGreaterThan) {
- if (Cmp1 > Cmp2) {
- return (TRUE);
- }
- } else {
- if ((UINTN)Cmp1 > (UINTN)Cmp2) {
- return (TRUE);
- }
- }
- }
- return (FALSE);
- case OperatorUnsignedLessThan:
- case OperatorLessThan:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) < 0) || (StringCompare(&Compare1, &Compare2) < 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (BinOp == OperatorLessThan) {
- if (Cmp1 < Cmp2) {
- return (TRUE);
- }
- } else {
- if ((UINTN)Cmp1 < (UINTN)Cmp2) {
- return (TRUE);
- }
- }
-
- }
- return (FALSE);
- case OperatorEqual:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) == 0) || (StringCompare(&Compare1, &Compare2) == 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (Cmp1 == Cmp2) {
- return (TRUE);
- }
- }
- return (FALSE);
- case OperatorNotEqual:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) != 0) || (StringCompare(&Compare1, &Compare2) != 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (Cmp1 != Cmp2) {
- return (TRUE);
- }
- }
- return (FALSE);
- case OperatorUnsignedGreaterOrEqual:
- case OperatorGreatorOrEqual:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) >= 0) || (StringCompare(&Compare1, &Compare2) >= 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (BinOp == OperatorGreatorOrEqual) {
- if (Cmp1 >= Cmp2) {
- return (TRUE);
- }
- } else {
- if ((UINTN)Cmp1 >= (UINTN)Cmp2) {
- return (TRUE);
- }
- }
- }
- return (FALSE);
- case OperatorLessOrEqual:
- case OperatorUnsignedLessOrEqual:
- if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {
- //
- // string compare
- //
- if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) <= 0) || (StringCompare(&Compare1, &Compare2) <= 0)) {
- return (TRUE);
- }
- } else {
- //
- // numeric compare
- //
- if (Compare1[0] == L'-') {
- Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);
- } else {
- Cmp1 = (INTN)ShellStrToUintn(Compare1);
- }
- if (Compare2[0] == L'-') {
- Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);
- } else {
- Cmp2 = (INTN)ShellStrToUintn(Compare2);
- }
- if (BinOp == OperatorLessOrEqual) {
- if (Cmp1 <= Cmp2) {
- return (TRUE);
- }
- } else {
- if ((UINTN)Cmp1 <= (UINTN)Cmp2) {
- return (TRUE);
- }
- }
- }
- return (FALSE);
- default:
- ASSERT(FALSE);
- return (FALSE);
- }
-}
-
-/**
- Process an if statement and determine if its is valid or not.
-
- @param[in, out] PassingState Opon entry, the current state. Upon exit,
- the new state.
- @param[in] StartParameterNumber The number of the first parameter of
- this statement.
- @param[in] EndParameterNumber The number of the final parameter of
- this statement.
- @param[in] OperatorToUse The type of termination operator.
- @param[in] CaseInsensitive TRUE for case insensitive, FALSE otherwise.
- @param[in] ForceStringCompare TRUE for all string based, FALSE otherwise.
-
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ProcessStatement (
- IN OUT BOOLEAN *PassingState,
- IN UINTN StartParameterNumber,
- IN UINTN EndParameterNumber,
- IN CONST END_TAG_TYPE OperatorToUse,
- IN CONST BOOLEAN CaseInsensitive,
- IN CONST BOOLEAN ForceStringCompare
- )
-{
- EFI_STATUS Status;
- BOOLEAN OperationResult;
- BOOLEAN NotPresent;
- CHAR16 *StatementWalker;
- BIN_OPERATOR_TYPE BinOp;
- CHAR16 *Compare1;
- CHAR16 *Compare2;
- CHAR16 HexString[20];
- CHAR16 *TempSpot;
-
- ASSERT((END_TAG_TYPE)OperatorToUse != EndTagThen);
-
- Status = EFI_SUCCESS;
- BinOp = OperatorMax;
- OperationResult = FALSE;
- StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not")) {
- NotPresent = TRUE;
- StatementWalker = gEfiShellParametersProtocol->Argv[++StartParameterNumber];
- } else {
- NotPresent = FALSE;
- }
-
- //
- // now check for 'boolfunc' operators
- //
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"isint")) {
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {
- StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;
- OperationResult = ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE);
- } else {
- Status = EFI_INVALID_PARAMETER;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"isint");
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exists") || IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exist")) {
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {
- StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;
- //
- // is what remains a file in CWD???
- //
- OperationResult = (BOOLEAN)(ShellFileExists(StatementWalker)==EFI_SUCCESS);
- } else if (StatementWalker[0] == CHAR_NULL && StartParameterNumber+1 == EndParameterNumber) {
- OperationResult = (BOOLEAN)(ShellFileExists(gEfiShellParametersProtocol->Argv[++StartParameterNumber])==EFI_SUCCESS);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"exist(s)");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"available")) {
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {
- StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;
- //
- // is what remains a file in the CWD or path???
- //
- OperationResult = (BOOLEAN)(ShellIsFileInPath(StatementWalker)==EFI_SUCCESS);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"available");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"profile")) {
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {
- //
- // Chop off that ')'
- //
- StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;
- OperationResult = IsValidProfile(StatementWalker);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"profile");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (StartParameterNumber+1 >= EndParameterNumber) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[StartParameterNumber]);
- Status = EFI_INVALID_PARAMETER;
- } else {
- //
- // must be 'item binop item' style
- //
- Compare1 = NULL;
- Compare2 = NULL;
- BinOp = OperatorMax;
-
- //
- // get the first item
- //
- StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT);
- ASSERT(Compare1 == NULL);
- Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2));
- ASSERT(Compare1 == NULL);
- Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1));
- ASSERT(Compare1 == NULL);
- Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ASSERT(Compare1 == NULL);
- if (EndParameterNumber - StartParameterNumber > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_STARTING), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[StartParameterNumber+2]);
- Status = EFI_INVALID_PARAMETER;
- } else {
- //
- // must be a raw string
- //
- Compare1 = StrnCatGrow(&Compare1, NULL, StatementWalker, 0);
- }
- }
-
- //
- // get the operator
- //
- ASSERT(StartParameterNumber+1<EndParameterNumber);
- StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+1];
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt")) {
- BinOp = OperatorGreaterThan;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt")) {
- BinOp = OperatorLessThan;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq")) {
- BinOp = OperatorEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne")) {
- BinOp = OperatorNotEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge")) {
- BinOp = OperatorGreatorOrEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le")) {
- BinOp = OperatorLessOrEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) {
- BinOp = OperatorEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) {
- BinOp = OperatorUnisgnedGreaterThan;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) {
- BinOp = OperatorUnsignedLessThan;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge")) {
- BinOp = OperatorUnsignedGreaterOrEqual;
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule")) {
- BinOp = OperatorUnsignedLessOrEqual;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_INVALID_BINOP), gShellLevel1HiiHandle, StatementWalker);
- Status = EFI_INVALID_PARAMETER;
- }
-
- //
- // get the second item
- //
- ASSERT(StartParameterNumber+2<=EndParameterNumber);
- StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+2];
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT);
- ASSERT(Compare2 == NULL);
- Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror");
- Status = EFI_INVALID_PARAMETER;
- }
- //
- // can this be collapsed into the above?
- //
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2));
- ASSERT(Compare2 == NULL);
- Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) {
- TempSpot = StrStr(StatementWalker, L")");
- if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {
- TempSpot = CHAR_NULL;
- if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {
- UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1));
- ASSERT(Compare2 == NULL);
- Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0);
- StatementWalker += StrLen(StatementWalker) + 1;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror");
- Status = EFI_INVALID_PARAMETER;
- }
- } else {
- //
- // must be a raw string
- //
- ASSERT(Compare2 == NULL);
- Compare2 = StrnCatGrow(&Compare2, NULL, StatementWalker, 0);
- }
-
- if (Compare1 != NULL && Compare2 != NULL && BinOp != OperatorMax) {
- OperationResult = TestOperation(Compare1, Compare2, BinOp, CaseInsensitive, ForceStringCompare);
- }
-
- SHELL_FREE_NON_NULL(Compare1);
- SHELL_FREE_NON_NULL(Compare2);
- }
-
- //
- // done processing do result...
- //
-
- if (!EFI_ERROR(Status)) {
- if (NotPresent) {
- OperationResult = (BOOLEAN)(!OperationResult);
- }
- switch(OperatorToUse) {
- case EndTagOr:
- *PassingState = (BOOLEAN)(*PassingState || OperationResult);
- break;
- case EndTagAnd:
- *PassingState = (BOOLEAN)(*PassingState && OperationResult);
- break;
- case EndTagMax:
- *PassingState = (BOOLEAN)(OperationResult);
- break;
- default:
- ASSERT(FALSE);
- }
- }
- return (Status);
-}
-
-/**
- Break up the next part of the if statement (until the next 'and', 'or', or 'then').
-
- @param[in] ParameterNumber The current parameter number.
- @param[out] EndParameter Upon successful return, will point to the
- parameter to start the next iteration with.
- @param[out] EndTag Upon successful return, will point to the
- type that was found at the end of this statement.
-
- @retval TRUE A valid statement was found.
- @retval FALSE A valid statement was not found.
-**/
-BOOLEAN
-EFIAPI
-BuildNextStatement (
- IN UINTN ParameterNumber,
- OUT UINTN *EndParameter,
- OUT END_TAG_TYPE *EndTag
- )
-{
- *EndTag = EndTagMax;
-
- for(
- ; ParameterNumber < gEfiShellParametersProtocol->Argc
- ; ParameterNumber++
- ) {
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[ParameterNumber],
- L"or") == 0) {
- *EndParameter = ParameterNumber - 1;
- *EndTag = EndTagOr;
- break;
- } else if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[ParameterNumber],
- L"and") == 0) {
- *EndParameter = ParameterNumber - 1;
- *EndTag = EndTagAnd;
- break;
- } else if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[ParameterNumber],
- L"then") == 0) {
- *EndParameter = ParameterNumber - 1;
- *EndTag = EndTagThen;
- break;
- }
- }
- if (*EndTag == EndTagMax) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-/**
- Move the script file pointer to a different place in the script file.
- This one is special since it handles the if/else/endif syntax.
-
- @param[in] ScriptFile The script file from GetCurrnetScriptFile().
-
- @retval TRUE The move target was found and the move was successful.
- @retval FALSE Something went wrong.
-**/
-BOOLEAN
-EFIAPI
-MoveToTagSpecial (
- IN SCRIPT_FILE *ScriptFile
- )
-{
- SCRIPT_COMMAND_LIST *CommandNode;
- BOOLEAN Found;
- UINTN TargetCount;
- CHAR16 *CommandName;
- CHAR16 *CommandWalker;
- CHAR16 *TempLocation;
-
- TargetCount = 1;
- Found = FALSE;
-
- if (ScriptFile == NULL) {
- return FALSE;
- }
-
- for (CommandNode = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &ScriptFile->CurrentCommand->Link), Found = FALSE
- ; !IsNull(&ScriptFile->CommandList, &CommandNode->Link) && !Found
- ; CommandNode = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &CommandNode->Link)
- ){
-
- //
- // get just the first part of the command line...
- //
- CommandName = NULL;
- CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
- if (CommandName == NULL) {
- continue;
- }
- CommandWalker = CommandName;
-
- //
- // Skip leading spaces and tabs.
- //
- while ((CommandWalker[0] == L' ') || (CommandWalker[0] == L'\t')) {
- CommandWalker++;
- }
- TempLocation = StrStr(CommandWalker, L" ");
-
- if (TempLocation != NULL) {
- *TempLocation = CHAR_NULL;
- }
-
- //
- // did we find a nested item ?
- //
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandWalker,
- L"If") == 0) {
- TargetCount++;
- } else if (TargetCount == 1 && gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandWalker,
- (CHAR16*)L"else") == 0) {
- //
- // else can only decrement the last part... not an nested if
- // hence the TargetCount compare added
- //
- TargetCount--;
- } else if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandWalker,
- (CHAR16*)L"endif") == 0) {
- TargetCount--;
- }
- if (TargetCount == 0) {
- ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &CommandNode->Link);
- Found = TRUE;
- }
-
- //
- // Free the memory for this loop...
- //
- SHELL_FREE_NON_NULL(CommandName);
- }
- return (Found);
-}
-
-/**
- Deal with the result of the if operation.
-
- @param[in] Result The result of the if.
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND The ending tag could not be found.
-**/
-EFI_STATUS
-EFIAPI
-PerformResultOperation (
- IN CONST BOOLEAN Result
- )
-{
- if (Result || MoveToTagSpecial(ShellCommandGetCurrentScriptFile())) {
- return (EFI_SUCCESS);
- }
- return (EFI_NOT_FOUND);
-}
-
-/**
- Function for 'if' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunIf (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- BOOLEAN CaseInsensitive;
- BOOLEAN ForceString;
- UINTN CurrentParameter;
- UINTN EndParameter;
- BOOLEAN CurrentValue;
- END_TAG_TYPE Ending;
- END_TAG_TYPE PreviousEnding;
- SCRIPT_FILE *CurrentScriptFile;
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"if");
- return (SHELL_UNSUPPORTED);
- }
-
- if (gEfiShellParametersProtocol->Argc < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"if");
- return (SHELL_INVALID_PARAMETER);
- }
-
- //
- // Make sure that an End exists.
- //
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"EndIf",
- L"If",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- CurrentParameter = 1;
- EndParameter = 0;
-
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[1],
- L"/i") == 0 ||
- gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[2],
- L"/i") == 0 ||
- (gEfiShellParametersProtocol->Argc > 3 && gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[3],
- L"/i") == 0)) {
- CaseInsensitive = TRUE;
- CurrentParameter++;
- } else {
- CaseInsensitive = FALSE;
- }
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[1],
- L"/s") == 0 ||
- gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[2],
- L"/s") == 0 ||
- (gEfiShellParametersProtocol->Argc > 3 && gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[3],
- L"/s") == 0)) {
- ForceString = TRUE;
- CurrentParameter++;
- } else {
- ForceString = FALSE;
- }
-
- for ( ShellStatus = SHELL_SUCCESS, CurrentValue = FALSE, Ending = EndTagMax
- ; CurrentParameter < gEfiShellParametersProtocol->Argc && ShellStatus == SHELL_SUCCESS
- ; CurrentParameter++) {
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- gEfiShellParametersProtocol->Argv[CurrentParameter],
- L"then") == 0) {
- //
- // we are at the then
- //
- if (CurrentParameter+1 != gEfiShellParametersProtocol->Argc) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TEXT_AFTER_THEN), gShellLevel1HiiHandle, L"if");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = PerformResultOperation(CurrentValue);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- } else {
- PreviousEnding = Ending;
- //
- // build up the next statement for analysis
- //
- if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"Then",
- L"If",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Analyze the statement
- //
- Status = ProcessStatement(&CurrentValue, CurrentParameter, EndParameter, PreviousEnding, CaseInsensitive, ForceString);
- if (EFI_ERROR(Status)) {
-// ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_STARTING), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Optomize to get out of the loop early...
- //
- if ((Ending == EndTagOr && CurrentValue) || (Ending == EndTagAnd && !CurrentValue)) {
- Status = PerformResultOperation(CurrentValue);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- break;
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS){
- CurrentParameter = EndParameter;
- //
- // Skip over the or or and parameter.
- //
- if (Ending == EndTagOr || Ending == EndTagAnd) {
- CurrentParameter++;
- }
- }
- }
- }
- return (ShellStatus);
-}
-
-/**
- Function for 'else' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunElse (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SCRIPT_FILE *CurrentScriptFile;
- ASSERT_EFI_ERROR(CommandInit());
-
- if (gEfiShellParametersProtocol->Argc > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");
- return (SHELL_INVALID_PARAMETER);
- }
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Else");
- return (SHELL_UNSUPPORTED);
- }
-
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
-
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"If",
- L"Else",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_DEVICE_ERROR);
- }
- if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"If",
- L"Else",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_DEVICE_ERROR);
- }
-
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"EndIf",
- "Else",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_DEVICE_ERROR);
- }
-
- return (SHELL_SUCCESS);
-}
-
-/**
- Function for 'endif' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEndIf (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SCRIPT_FILE *CurrentScriptFile;
- ASSERT_EFI_ERROR(CommandInit());
-
- if (gEfiShellParametersProtocol->Argc > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");
- return (SHELL_INVALID_PARAMETER);
- }
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Endif");
- return (SHELL_UNSUPPORTED);
- }
-
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
- gShellLevel1HiiHandle,
- L"If",
- L"EndIf",
- CurrentScriptFile!=NULL
- && CurrentScriptFile->CurrentCommand!=NULL
- ? CurrentScriptFile->CurrentCommand->Line:0);
- return (SHELL_DEVICE_ERROR);
- }
-
- return (SHELL_SUCCESS);
-}
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
deleted file mode 100644
index 08c54f8f7a..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file
- Main file for Shift shell level 1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-
-/**
- Function for 'shift' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunShift (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- SCRIPT_FILE *CurrentScriptFile;
- UINTN LoopVar;
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
- return (SHELL_UNSUPPORTED);
- }
-
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- ASSERT(CurrentScriptFile != NULL);
-
- if (CurrentScriptFile->Argc < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
- return (SHELL_UNSUPPORTED);
- }
-
- for (LoopVar = 0 ; LoopVar < CurrentScriptFile->Argc ; LoopVar++) {
- if (LoopVar == 0) {
- SHELL_FREE_NON_NULL(CurrentScriptFile->Argv[LoopVar]);
- }
- if (LoopVar < CurrentScriptFile->Argc -1) {
- CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];
- } else {
- CurrentScriptFile->Argv[LoopVar] = NULL;
- }
- }
- CurrentScriptFile->Argc--;
- return (SHELL_SUCCESS);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c
deleted file mode 100644
index 476b1bc47f..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @file
- Main file for stall shell level 1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-
-/**
- Function for 'stall' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunStall (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"stall", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"stall");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"stall");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);
- if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"stall", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = gBS->Stall((UINTN)Intermediate);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, L"stall");
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- }
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
deleted file mode 100644
index 80d0dfe652..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/** @file
- Main file for NULL named library for level 1 shell command functions.
-
- (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel1CommandsLib.h"
-
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
-EFI_HANDLE gShellLevel1HiiHandle = NULL;
-
-/**
- Return the help text filename. Only used if no HII information found.
-
- @retval the filename.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameLevel1 (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Level 1 Commands library.
-
- Install the handlers for level 1 UEFI Shell 2.0 commands.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // if shell level is less than 2 do nothing
- //
- if (PcdGet8(PcdShellSupportLevel) < 1) {
- return (EFI_SUCCESS);
- }
-
- gShellLevel1HiiHandle = HiiAddPackages (&gShellLevel1HiiGuid, gImageHandle, UefiShellLevel1CommandsLibStrings, NULL);
- if (gShellLevel1HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"stall", ShellCommandRunStall , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_STALL) ));
- ShellCommandRegisterCommandName(L"for", ShellCommandRunFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_FOR) ));
- ShellCommandRegisterCommandName(L"goto", ShellCommandRunGoto , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_GOTO) ));
- ShellCommandRegisterCommandName(L"if", ShellCommandRunIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_IF) ));
- ShellCommandRegisterCommandName(L"shift", ShellCommandRunShift , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_SHIFT) ));
- ShellCommandRegisterCommandName(L"exit", ShellCommandRunExit , ShellCommandGetManFileNameLevel1, 1, L"", TRUE , gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_EXIT) ));
- ShellCommandRegisterCommandName(L"else", ShellCommandRunElse , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ELSE) ));
- ShellCommandRegisterCommandName(L"endif", ShellCommandRunEndIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDIF) ));
- ShellCommandRegisterCommandName(L"endfor", ShellCommandRunEndFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDFOR)));
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellLevel1HiiHandle != NULL) {
- HiiRemovePackages(gShellLevel1HiiHandle);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Test a node to see if meets the criterion.
-
- It functions so that count starts at 1 and it increases or decreases when it
- hits the specified tags. when it hits zero the location has been found.
-
- DecrementerTag and IncrementerTag are used to get around for/endfor and
- similar paired types where the entire middle should be ignored.
-
- If label is used it will be used instead of the count.
-
- @param[in] Function The function to use to enumerate through the
- list. Normally GetNextNode or GetPreviousNode.
- @param[in] DecrementerTag The tag to decrement the count at.
- @param[in] IncrementerTag The tag to increment the count at.
- @param[in] Label A label to look for.
- @param[in, out] ScriptFile The pointer to the current script file structure.
- @param[in] MovePast TRUE makes function return 1 past the found
- location.
- @param[in] FindOnly TRUE to not change the ScriptFile.
- @param[in] CommandNode The pointer to the Node to test.
- @param[in, out] TargetCount The pointer to the current count.
-**/
-BOOLEAN
-EFIAPI
-TestNodeForMove (
- IN CONST LIST_MANIP_FUNC Function,
- IN CONST CHAR16 *DecrementerTag,
- IN CONST CHAR16 *IncrementerTag,
- IN CONST CHAR16 *Label OPTIONAL,
- IN OUT SCRIPT_FILE *ScriptFile,
- IN CONST BOOLEAN MovePast,
- IN CONST BOOLEAN FindOnly,
- IN CONST SCRIPT_COMMAND_LIST *CommandNode,
- IN OUT UINTN *TargetCount
- )
-{
- BOOLEAN Found;
- CHAR16 *CommandName;
- CHAR16 *CommandNameWalker;
- CHAR16 *TempLocation;
-
- Found = FALSE;
-
- //
- // get just the first part of the command line...
- //
- CommandName = NULL;
- CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
- if (CommandName == NULL) {
- return (FALSE);
- }
-
- CommandNameWalker = CommandName;
-
- //
- // Skip leading spaces and tabs.
- //
- while ((CommandNameWalker[0] == L' ') || (CommandNameWalker[0] == L'\t')) {
- CommandNameWalker++;
- }
- TempLocation = StrStr(CommandNameWalker, L" ");
-
- if (TempLocation != NULL) {
- *TempLocation = CHAR_NULL;
- }
-
- //
- // did we find a nested item ?
- //
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandNameWalker,
- (CHAR16*)IncrementerTag) == 0) {
- (*TargetCount)++;
- } else if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandNameWalker,
- (CHAR16*)DecrementerTag) == 0) {
- if (*TargetCount > 0) {
- (*TargetCount)--;
- }
- }
-
- //
- // did we find the matching one...
- //
- if (Label == NULL) {
- if (*TargetCount == 0) {
- Found = TRUE;
- if (!FindOnly) {
- if (MovePast) {
- ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link);
- } else {
- ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)CommandNode;
- }
- }
- }
- } else {
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)CommandNameWalker,
- (CHAR16*)Label) == 0
- && (*TargetCount) == 0) {
- Found = TRUE;
- if (!FindOnly) {
- //
- // we found the target label without loops
- //
- if (MovePast) {
- ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link);
- } else {
- ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)CommandNode;
- }
- }
- }
- }
-
- //
- // Free the memory for this loop...
- //
- FreePool(CommandName);
- return (Found);
-}
-
-/**
- Move the script pointer from 1 tag (line) to another.
-
- It functions so that count starts at 1 and it increases or decreases when it
- hits the specified tags. when it hits zero the location has been found.
-
- DecrementerTag and IncrementerTag are used to get around for/endfor and
- similar paired types where the entire middle should be ignored.
-
- If label is used it will be used instead of the count.
-
- @param[in] Function The function to use to enumerate through the
- list. Normally GetNextNode or GetPreviousNode.
- @param[in] DecrementerTag The tag to decrement the count at.
- @param[in] IncrementerTag The tag to increment the count at.
- @param[in] Label A label to look for.
- @param[in, out] ScriptFile The pointer to the current script file structure.
- @param[in] MovePast TRUE makes function return 1 past the found
- location.
- @param[in] FindOnly TRUE to not change the ScriptFile.
- @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in
- searching.
-**/
-BOOLEAN
-EFIAPI
-MoveToTag (
- IN CONST LIST_MANIP_FUNC Function,
- IN CONST CHAR16 *DecrementerTag,
- IN CONST CHAR16 *IncrementerTag,
- IN CONST CHAR16 *Label OPTIONAL,
- IN OUT SCRIPT_FILE *ScriptFile,
- IN CONST BOOLEAN MovePast,
- IN CONST BOOLEAN FindOnly,
- IN CONST BOOLEAN WrapAroundScript
- )
-{
- SCRIPT_COMMAND_LIST *CommandNode;
- BOOLEAN Found;
- UINTN TargetCount;
-
- if (Label == NULL) {
- TargetCount = 1;
- } else {
- TargetCount = 0;
- }
-
- if (ScriptFile == NULL) {
- return FALSE;
- }
-
- for (CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &ScriptFile->CurrentCommand->Link), Found = FALSE
- ; !IsNull(&ScriptFile->CommandList, &CommandNode->Link)&& !Found
- ; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
- ){
- Found = TestNodeForMove(
- Function,
- DecrementerTag,
- IncrementerTag,
- Label,
- ScriptFile,
- MovePast,
- FindOnly,
- CommandNode,
- &TargetCount);
- }
-
- if (WrapAroundScript && !Found) {
- for (CommandNode = (SCRIPT_COMMAND_LIST *)GetFirstNode(&ScriptFile->CommandList), Found = FALSE
- ; CommandNode != ScriptFile->CurrentCommand && !Found
- ; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
- ){
- Found = TestNodeForMove(
- Function,
- DecrementerTag,
- IncrementerTag,
- Label,
- ScriptFile,
- MovePast,
- FindOnly,
- CommandNode,
- &TargetCount);
- }
- }
- return (Found);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h
deleted file mode 100644
index c4ef536202..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/** @file
- Main file for NULL named library for level 1 shell command functions.
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_
-#define _UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-
-extern EFI_HANDLE gShellLevel1HiiHandle;
-
-/**
- Function for 'stall' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunStall (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'exit' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunExit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'endif' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEndIf (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'for' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunFor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'endfor' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEndFor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'if' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunIf (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'goto' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunGoto (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'shift' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunShift (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-
-/**
- Function for 'else' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunElse (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-///
-/// Function prototype for BOTH GetNextNode and GetPreviousNode...
-/// This is used to control the MoveToTag function direction...
-///
-typedef
-LIST_ENTRY *
-(EFIAPI *LIST_MANIP_FUNC)(
- IN CONST LIST_ENTRY *List,
- IN CONST LIST_ENTRY *Node
- );
-
-/**
- Move the script pointer from 1 tag (line) to another.
-
- It functions so that count starts at 1 and it increases or decreases when it
- hits the specified tags. when it hits zero the location has been found.
-
- DecrementerTag and IncrementerTag are used to get around for/endfor and
- similar paired types where the entire middle should be ignored.
-
- If label is used it will be used instead of the count.
-
- @param[in] Function The function to use to enumerate through the
- list. Normally GetNextNode or GetPreviousNode.
- @param[in] DecrementerTag The tag to decrement the count at.
- @param[in] IncrementerTag The tag to increment the count at.
- @param[in] Label A label to look for.
- @param[in, out] ScriptFile The pointer to the current script file structure.
- @param[in] MovePast TRUE makes function return 1 past the found
- location.
- @param[in] FindOnly TRUE to not change the ScriptFile.
- @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in
- searching.
-**/
-BOOLEAN
-EFIAPI
-MoveToTag (
- IN CONST LIST_MANIP_FUNC Function,
- IN CONST CHAR16 *DecrementerTag,
- IN CONST CHAR16 *IncrementerTag,
- IN CONST CHAR16 *Label OPTIONAL,
- IN OUT SCRIPT_FILE *ScriptFile,
- IN CONST BOOLEAN MovePast,
- IN CONST BOOLEAN FindOnly,
- IN CONST BOOLEAN WrapAroundScript
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
deleted file mode 100644
index 4d3713b460..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file
-# Provides shell level 1 functions
-#
-# Copyright (c) 2009-2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellLevel1CommandsLib
- FILE_GUID = 50cb6037-1102-47af-b2dd-9944b6eb1abe
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellLevel1CommandsLibConstructor
- DESTRUCTOR = ShellLevel1CommandsLibDestructor
-
-[Sources.common]
- UefiShellLevel1CommandsLib.c
- UefiShellLevel1CommandsLib.h
- UefiShellLevel1CommandsLib.uni
- Exit.c
- Goto.c
- If.c
- For.c
- Shift.c
- Stall.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
-
-[Guids]
- gShellLevel1HiiGuid ## SOMETIMES_CONSUMES ## HII
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni
deleted file mode 100644
index 40fa57eb02..0000000000
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c
deleted file mode 100644
index 30d643431f..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-STATIC CONST CHAR16 AllFiles[] = L"*";
-
-STATIC CONST SHELL_PARAM_ITEM AttribParamList[] = {
- {L"-a", TypeFlag},
- {L"+a", TypeFlag},
- {L"-s", TypeFlag},
- {L"+s", TypeFlag},
- {L"-h", TypeFlag},
- {L"+h", TypeFlag},
- {L"-r", TypeFlag},
- {L"+r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'attrib' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAttrib (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- UINT64 FileAttributesToAdd;
- UINT64 FileAttributesToRemove;
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamNumberCount;
- CONST CHAR16 *FileName;
- EFI_SHELL_FILE_INFO *ListOfFiles;
- EFI_SHELL_FILE_INFO *FileNode;
- EFI_FILE_INFO *FileInfo;
-
- ListOfFiles = NULL;
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (AttribParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"attrib", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
-
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else {
- FileAttributesToAdd = 0;
- FileAttributesToRemove = 0;
-
- //
- // apply or remove each flag
- //
- if (ShellCommandLineGetFlag(Package, L"+a")) {
- FileAttributesToAdd |= EFI_FILE_ARCHIVE;
- }
- if (ShellCommandLineGetFlag(Package, L"-a")) {
- FileAttributesToRemove |= EFI_FILE_ARCHIVE;
- }
- if (ShellCommandLineGetFlag(Package, L"+s")) {
- FileAttributesToAdd |= EFI_FILE_SYSTEM;
- }
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- FileAttributesToRemove |= EFI_FILE_SYSTEM;
- }
- if (ShellCommandLineGetFlag(Package, L"+h")) {
- FileAttributesToAdd |= EFI_FILE_HIDDEN;
- }
- if (ShellCommandLineGetFlag(Package, L"-h")) {
- FileAttributesToRemove |= EFI_FILE_HIDDEN;
- }
- if (ShellCommandLineGetFlag(Package, L"+r")) {
- FileAttributesToAdd |= EFI_FILE_READ_ONLY;
- }
- if (ShellCommandLineGetFlag(Package, L"-r")) {
- FileAttributesToRemove |= EFI_FILE_READ_ONLY;
- }
-
- if (FileAttributesToRemove == 0 && FileAttributesToAdd == 0) {
- //
- // Do display as we have no attributes to change
- //
- for ( ParamNumberCount = 1
- ;
- ; ParamNumberCount++
- ){
- FileName = ShellCommandLineGetRawValue(Package, ParamNumberCount);
- // if we dont have anything left, move on...
- if (FileName == NULL && ParamNumberCount == 1) {
- FileName = (CHAR16*)AllFiles;
- } else if (FileName == NULL) {
- break;
- }
- ASSERT(ListOfFiles == NULL);
- Status = ShellOpenFileMetaArg((CHAR16*)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- for (FileNode = (EFI_SHELL_FILE_INFO*)GetFirstNode(&ListOfFiles->Link)
- ; !IsNull(&ListOfFiles->Link, &FileNode->Link)
- ; FileNode = (EFI_SHELL_FILE_INFO*)GetNextNode(&ListOfFiles->Link, &FileNode->Link)
- ){
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_ATTRIB_OUTPUT_LINE),
- gShellLevel2HiiHandle,
- FileNode->Info->Attribute&EFI_FILE_DIRECTORY? L'D':L' ',
- FileNode->Info->Attribute&EFI_FILE_ARCHIVE? L'A':L' ',
- FileNode->Info->Attribute&EFI_FILE_SYSTEM? L'S':L' ',
- FileNode->Info->Attribute&EFI_FILE_HIDDEN? L'H':L' ',
- FileNode->Info->Attribute&EFI_FILE_READ_ONLY? L'R':L' ',
- FileNode->FileName
- );
-
- if (ShellGetExecutionBreakFlag()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- }
- Status = ShellCloseFileMetaArg(&ListOfFiles);
- ListOfFiles = NULL;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_NOT_FOUND;
- }
- } // for loop for handling wildcard filenames
- } // for loop for printing out the info
- } else if ((FileAttributesToRemove & FileAttributesToAdd) != 0) {
- //
- // fail as we have conflcting params.
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"attrib");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // enumerate through all the files/directories and apply the attributes
- //
- for ( ParamNumberCount = 1
- ;
- ; ParamNumberCount++
- ){
- FileName = ShellCommandLineGetRawValue(Package, ParamNumberCount);
- // if we dont have anything left, move on...
- if (FileName == NULL) {
- //
- // make sure we are not failing on the first one we do... if yes that's an error...
- //
- if (ParamNumberCount == 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"attrib");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- break;
- }
-
- //
- // OpenFileByName / GetFileInfo / Change attributes / SetFileInfo / CloseFile / free memory
- // for each file or directory on the line.
- //
-
- //
- // Open the file(s)
- //
- ASSERT(ListOfFiles == NULL);
- Status = ShellOpenFileMetaArg((CHAR16*)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- for (FileNode = (EFI_SHELL_FILE_INFO*)GetFirstNode(&ListOfFiles->Link)
- ; !IsNull(&ListOfFiles->Link, &FileNode->Link)
- ; FileNode = (EFI_SHELL_FILE_INFO*)GetNextNode(&ListOfFiles->Link, &FileNode->Link)
- ){
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(FileNode->FileName, L".") == 0 || StrCmp(FileNode->FileName, L"..") == 0) {
- continue;
- }
-
- FileInfo = gEfiShellProtocol->GetFileInfo(FileNode->Handle);
-
- //
- // if we are removing Read-Only we need to do that alone
- //
- if ((FileAttributesToRemove & EFI_FILE_READ_ONLY) == EFI_FILE_READ_ONLY) {
- FileInfo->Attribute &= ~EFI_FILE_READ_ONLY;
- //
- // SetFileInfo
- //
- Status = ShellSetFileInfo(FileNode->Handle, FileInfo);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- }
-
- //
- // change the attribute
- //
- FileInfo->Attribute &= ~FileAttributesToRemove;
- FileInfo->Attribute |= FileAttributesToAdd;
-
- //
- // SetFileInfo
- //
- Status = ShellSetFileInfo(FileNode->Handle, FileInfo);
- if (EFI_ERROR(Status)) {;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_ACCESS_DENIED;
- }
-
- SHELL_FREE_NON_NULL(FileInfo);
- }
- Status = ShellCloseFileMetaArg(&ListOfFiles);
- ListOfFiles = NULL;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
- ShellStatus = SHELL_NOT_FOUND;
- }
- } // for loop for handling wildcard filenames
- }
- }
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
deleted file mode 100644
index 10bc185dba..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- Function for 'cd' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCd (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CONST CHAR16 *Directory;
- CHAR16 *Path;
- CHAR16 *Drive;
- UINTN DriveSize;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- SHELL_FILE_HANDLE Handle;
- CONST CHAR16 *Param1;
- CHAR16 *Param1Copy;
- CHAR16* Walker;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- Drive = NULL;
- DriveSize = 0;
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cd", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- }
-
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // remember that param 0 is the command name
- // If there are 0 value parameters, then print the current directory
- // else If there are 2 value parameters, then print the error message
- // else If there is 1 value paramerer , then change the directory
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 == NULL) {
- //
- // display the current directory
- //
- Directory = ShellGetCurrentDir(NULL);
- if (Directory != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_PRINT), gShellLevel2HiiHandle, Directory);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- }
- } else {
- Param1Copy = CatSPrint(NULL, L"%s", Param1, NULL);
- for (Walker = Param1Copy; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
- if (*Walker == L'\"') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
- }
- }
-
- if (Param1Copy != NULL) {
- Param1Copy = PathCleanUpDirectories(Param1Copy);
- }
- if (Param1Copy != NULL) {
- if (StrCmp(Param1Copy, L".") == 0) {
- //
- // nothing to do... change to current directory
- //
- } else if (StrCmp(Param1Copy, L"..") == 0) {
- //
- // Change up one directory...
- //
- Directory = ShellGetCurrentDir(NULL);
- if (Directory == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Drive = GetFullyQualifiedPath(Directory);
- PathRemoveLastItem(Drive);
- }
- if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {
- //
- // change directory on current drive letter
- //
- Status = gEfiShellProtocol->SetCurDir(NULL, Drive);
- if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- } else if (StrCmp(Param1Copy, L"\\") == 0) {
- //
- // Move to root of current drive
- //
- Directory = ShellGetCurrentDir(NULL);
- if (Directory == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Drive = GetFullyQualifiedPath(Directory);
- while (PathRemoveLastItem(Drive)) ;
- }
- if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {
- //
- // change directory on current drive letter
- //
- Status = gEfiShellProtocol->SetCurDir(NULL, Drive);
- if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- } else if (StrStr(Param1Copy, L":") == NULL) {
- //
- // change directory without a drive identifier
- //
- if (ShellGetCurrentDir(NULL) == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));
- Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);
- if (*Param1Copy == L'\\') {
- while (PathRemoveLastItem(Drive)) ;
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);
- } else {
- Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy, 0);
- }
- //
- // Verify that this is a valid directory
- //
- Status = gEfiShellProtocol->OpenFileByName(Drive, &Handle, EFI_FILE_MODE_READ);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Drive);
- ShellStatus = SHELL_NOT_FOUND;
- } else if (EFI_ERROR(FileHandleIsDirectory(Handle))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Drive);
- ShellStatus = SHELL_NOT_FOUND;
- }
- if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {
- //
- // change directory on current drive letter
- //
- Status = gEfiShellProtocol->SetCurDir(NULL, Drive);
- if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- if (Handle != NULL) {
- gEfiShellProtocol->CloseFile(Handle);
- DEBUG_CODE(Handle = NULL;);
- }
- }
- } else {
- //
- // change directory with a drive letter
- //
- Drive = AllocateCopyPool(StrSize(Param1Copy), Param1Copy);
- if (Drive == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- Path = StrStr(Drive, L":");
- ASSERT(Path != NULL);
- if (EFI_ERROR(ShellIsDirectory(Param1Copy))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Param1Copy);
- ShellStatus = SHELL_NOT_FOUND;
- } else if (*(Path+1) == CHAR_NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- *(Path+1) = CHAR_NULL;
- if (Path == Drive + StrLen(Drive)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- Status = gEfiShellProtocol->SetCurDir(Drive, Path+2);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_PRINT), gShellLevel2HiiHandle, ShellGetCurrentDir(Drive));
- }
- }
- if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"cd");
- Status = SHELL_NOT_FOUND;
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Param1Copy);
- Status = SHELL_NOT_FOUND;
- }
- }
- }
- }
- FreePool(Param1Copy);
- }
- }
-
- if (Drive != NULL) {
- FreePool(Drive);
- }
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
deleted file mode 100644
index deff42e049..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/** @file
- Main file for cp shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-#include <Guid/FileSystemInfo.h>
-#include <Guid/FileSystemVolumeLabelInfo.h>
-
-/**
- Function to take a list of files to copy and a destination location and do
- the verification and copying of those files to that location. This function
- will report any errors to the user and halt.
-
- @param[in] FileList A LIST_ENTRY* based list of files to move.
- @param[in] DestDir The destination location.
- @param[in] SilentMode TRUE to eliminate screen output.
- @param[in] RecursiveMode TRUE to copy directories.
- @param[in] Resp The response to the overwrite query (if always).
-
- @retval SHELL_SUCCESS the files were all moved.
- @retval SHELL_INVALID_PARAMETER a parameter was invalid
- @retval SHELL_SECURITY_VIOLATION a security violation ocurred
- @retval SHELL_WRITE_PROTECTED the destination was write protected
- @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
-**/
-SHELL_STATUS
-EFIAPI
-ValidateAndCopyFiles(
- IN CONST EFI_SHELL_FILE_INFO *FileList,
- IN CONST CHAR16 *DestDir,
- IN BOOLEAN SilentMode,
- IN BOOLEAN RecursiveMode,
- IN VOID **Resp
- );
-
-/**
- Function to Copy one file to another location
-
- If the destination exists the user will be prompted and the result put into *resp
-
- @param[in] Source pointer to source file name
- @param[in] Dest pointer to destination file name
- @param[out] Resp pointer to response from question. Pass back on looped calling
- @param[in] SilentMode whether to run in quiet mode or not
- @param[in] CmdName Source command name requesting single file copy
-
- @retval SHELL_SUCCESS The source file was copied to the destination
-**/
-SHELL_STATUS
-EFIAPI
-CopySingleFile(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Dest,
- OUT VOID **Resp,
- IN BOOLEAN SilentMode,
- IN CONST CHAR16 *CmdName
- )
-{
- VOID *Response;
- UINTN ReadSize;
- SHELL_FILE_HANDLE SourceHandle;
- SHELL_FILE_HANDLE DestHandle;
- EFI_STATUS Status;
- VOID *Buffer;
- CHAR16 *TempName;
- UINTN Size;
- EFI_SHELL_FILE_INFO *List;
- SHELL_STATUS ShellStatus;
- UINT64 SourceFileSize;
- UINT64 DestFileSize;
- EFI_FILE_PROTOCOL *DestVolumeFP;
- EFI_FILE_SYSTEM_INFO *DestVolumeInfo;
- UINTN DestVolumeInfoSize;
-
- ASSERT(Resp != NULL);
-
- SourceHandle = NULL;
- DestHandle = NULL;
- Response = *Resp;
- List = NULL;
- DestVolumeInfo = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- ReadSize = PcdGet32(PcdShellFileOperationSize);
- // Why bother copying a file to itself
- if (StrCmp(Source, Dest) == 0) {
- return (SHELL_SUCCESS);
- }
-
- //
- // if the destination file existed check response and possibly prompt user
- //
- if (ShellFileExists(Dest) == EFI_SUCCESS) {
- if (Response == NULL && !SilentMode) {
- Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
- }
- //
- // possibly return based on response
- //
- if (!SilentMode) {
- switch (*(SHELL_PROMPT_RESPONSE*)Response) {
- case ShellPromptResponseNo:
- //
- // return success here so we dont stop the process
- //
- return (SHELL_SUCCESS);
- case ShellPromptResponseCancel:
- *Resp = Response;
- //
- // indicate to stop everything
- //
- return (SHELL_ABORTED);
- case ShellPromptResponseAll:
- *Resp = Response;
- case ShellPromptResponseYes:
- break;
- default:
- return SHELL_ABORTED;
- }
- }
- }
-
- if (ShellIsDirectory(Source) == EFI_SUCCESS) {
- Status = ShellCreateDirectory(Dest, &DestHandle);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
- return (SHELL_ACCESS_DENIED);
- }
-
- //
- // Now copy all the files under the directory...
- //
- TempName = NULL;
- Size = 0;
- StrnCatGrow(&TempName, &Size, Source, 0);
- StrnCatGrow(&TempName, &Size, L"\\*", 0);
- if (TempName != NULL) {
- ShellOpenFileMetaArg((CHAR16*)TempName, EFI_FILE_MODE_READ, &List);
- *TempName = CHAR_NULL;
- StrnCatGrow(&TempName, &Size, Dest, 0);
- StrnCatGrow(&TempName, &Size, L"\\", 0);
- ShellStatus = ValidateAndCopyFiles(List, TempName, SilentMode, TRUE, Resp);
- ShellCloseFileMetaArg(&List);
- SHELL_FREE_NON_NULL(TempName);
- Size = 0;
- }
- } else {
- Status = ShellDeleteFileByName(Dest);
-
- //
- // open file with create enabled
- //
- Status = ShellOpenFileByName(Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
- return (SHELL_ACCESS_DENIED);
- }
-
- //
- // open source file
- //
- Status = ShellOpenFileByName (Source, &SourceHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SRC_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Source);
- return (SHELL_ACCESS_DENIED);
- }
-
- //
- //get file size of source file and freespace available on destination volume
- //
- ShellGetFileSize(SourceHandle, &SourceFileSize);
- ShellGetFileSize(DestHandle, &DestFileSize);
-
- //
- //if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space
- //
- if(DestFileSize < SourceFileSize){
- SourceFileSize -= DestFileSize;
- } else {
- SourceFileSize = 0;
- }
-
- //
- //get the system volume info to check the free space
- //
- DestVolumeFP = ConvertShellHandleToEfiFileProtocol(DestHandle);
- DestVolumeInfo = NULL;
- DestVolumeInfoSize = 0;
- Status = DestVolumeFP->GetInfo(
- DestVolumeFP,
- &gEfiFileSystemInfoGuid,
- &DestVolumeInfoSize,
- DestVolumeInfo
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- DestVolumeInfo = AllocateZeroPool(DestVolumeInfoSize);
- Status = DestVolumeFP->GetInfo(
- DestVolumeFP,
- &gEfiFileSystemInfoGuid,
- &DestVolumeInfoSize,
- DestVolumeInfo
- );
- }
-
- //
- //check if enough space available on destination drive to complete copy
- //
- if (DestVolumeInfo!= NULL && (DestVolumeInfo->FreeSpace < SourceFileSize)) {
- //
- //not enough space on destination directory to copy file
- //
- SHELL_FREE_NON_NULL(DestVolumeInfo);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName);
- return(SHELL_VOLUME_FULL);
- } else {
- //
- // copy data between files
- //
- Buffer = AllocateZeroPool(ReadSize);
- ASSERT(Buffer != NULL);
- while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) {
- Status = ShellReadFile(SourceHandle, &ReadSize, Buffer);
- if (!EFI_ERROR(Status)) {
- Status = ShellWriteFile(DestHandle, &ReadSize, Buffer);
- if (EFI_ERROR(Status)) {
- ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest);
- break;
- }
- } else {
- ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source);
- break;
- }
- }
- }
- SHELL_FREE_NON_NULL(DestVolumeInfo);
- }
-
- //
- // close files
- //
- if (DestHandle != NULL) {
- ShellCloseFile(&DestHandle);
- DestHandle = NULL;
- }
- if (SourceHandle != NULL) {
- ShellCloseFile(&SourceHandle);
- SourceHandle = NULL;
- }
-
- //
- // return
- //
- return ShellStatus;
-}
-
-/**
- function to take a list of files to copy and a destination location and do
- the verification and copying of those files to that location. This function
- will report any errors to the user and halt.
-
- The key is to have this function called ONLY once. this allows for the parameter
- verification to happen correctly.
-
- @param[in] FileList A LIST_ENTRY* based list of files to move.
- @param[in] DestDir The destination location.
- @param[in] SilentMode TRUE to eliminate screen output.
- @param[in] RecursiveMode TRUE to copy directories.
- @param[in] Resp The response to the overwrite query (if always).
-
- @retval SHELL_SUCCESS the files were all moved.
- @retval SHELL_INVALID_PARAMETER a parameter was invalid
- @retval SHELL_SECURITY_VIOLATION a security violation ocurred
- @retval SHELL_WRITE_PROTECTED the destination was write protected
- @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
-**/
-SHELL_STATUS
-EFIAPI
-ValidateAndCopyFiles(
- IN CONST EFI_SHELL_FILE_INFO *FileList,
- IN CONST CHAR16 *DestDir,
- IN BOOLEAN SilentMode,
- IN BOOLEAN RecursiveMode,
- IN VOID **Resp
- )
-{
- CHAR16 *HiiOutput;
- CHAR16 *HiiResultOk;
- CONST EFI_SHELL_FILE_INFO *Node;
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- CHAR16 *DestPath;
- VOID *Response;
- UINTN PathSize;
- CONST CHAR16 *Cwd;
- UINTN NewSize;
- CHAR16 *CleanFilePathStr;
-
- if (Resp == NULL) {
- Response = NULL;
- } else {
- Response = *Resp;
- }
-
- DestPath = NULL;
- ShellStatus = SHELL_SUCCESS;
- PathSize = 0;
- Cwd = ShellGetCurrentDir(NULL);
- CleanFilePathStr = NULL;
-
- ASSERT(FileList != NULL);
- ASSERT(DestDir != NULL);
-
-
- Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr);
- if (EFI_ERROR (Status)) {
- if (Status == EFI_OUT_OF_RESOURCES) {
- return SHELL_OUT_OF_RESOURCES;
- } else {
- return SHELL_INVALID_PARAMETER;
- }
- }
-
- ASSERT (CleanFilePathStr != NULL);
-
- //
- // If we are trying to copy multiple files... make sure we got a directory for the target...
- //
- if (EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {
- //
- // Error for destination not a directory
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool (CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
- continue;
- }
-
- NewSize = StrSize(CleanFilePathStr);
- NewSize += StrSize(Node->FullName);
- NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);
- if (NewSize > PathSize) {
- PathSize = NewSize;
- }
-
- //
- // Make sure got -r if required
- //
- if (!RecursiveMode && !EFI_ERROR(ShellIsDirectory(Node->FullName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp");
- FreePool (CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
-
- //
- // make sure got dest as dir if needed
- //
- if (!EFI_ERROR(ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(CleanFilePathStr))) {
- //
- // Error for destination not a directory
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool (CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
- }
-
- HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_CP_OUTPUT), NULL);
- HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
- DestPath = AllocateZeroPool(PathSize);
-
- if (DestPath == NULL || HiiOutput == NULL || HiiResultOk == NULL) {
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- FreePool (CleanFilePathStr);
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- //
- // Go through the list of files to copy...
- //
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
- ASSERT(Node->FileName != NULL);
- ASSERT(Node->FullName != NULL);
-
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
- continue;
- }
-
- if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item
- && EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) // not an existing directory
- ) {
- if (StrStr(CleanFilePathStr, L":") == NULL) {
- //
- // simple copy of a single file
- //
- if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool (CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
- if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {
- StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
- }
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- } else {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- }
- } else {
- //
- // we have multiple files or a directory in the DestDir
- //
-
- //
- // Check for leading slash
- //
- if (CleanFilePathStr[0] == L'\\') {
- //
- // Copy to the root of CWD
- //
- if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool(CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
- while (PathRemoveLastItem(DestPath));
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr+1);
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
- } else if (StrStr(CleanFilePathStr, L":") == NULL) {
- if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool(CleanFilePathStr);
- return (SHELL_INVALID_PARAMETER);
- }
- if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
- }
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
- }
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
-
- } else {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {
- ((CHAR16*)CleanFilePathStr)[StrLen(CleanFilePathStr)-1] = CHAR_NULL;
- }
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
- }
- }
-
- //
- // Make sure the path exists
- //
- if (EFI_ERROR(VerifyIntermediateDirectories(DestPath))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath);
- ShellStatus = SHELL_DEVICE_ERROR;
- break;
- }
-
- if ( !EFI_ERROR(ShellIsDirectory(Node->FullName))
- && !EFI_ERROR(ShellIsDirectory(DestPath))
- && StrniCmp(Node->FullName, DestPath, StrLen(DestPath)) == NULL
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- }
- if (StringNoCaseCompare(&Node->FullName, &DestPath) == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- }
-
- if ((StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName)) == 0)
- && (DestPath[StrLen(Node->FullName)] == CHAR_NULL || DestPath[StrLen(Node->FullName)] == L'\\')
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- }
-
- PathCleanUpDirectories(DestPath);
-
- if (!SilentMode) {
- ShellPrintEx(-1, -1, HiiOutput, Node->FullName, DestPath);
- }
-
- //
- // copy single file...
- //
- ShellStatus = CopySingleFile(Node->FullName, DestPath, &Response, SilentMode, L"cp");
- if (ShellStatus != SHELL_SUCCESS) {
- break;
- }
- }
- if (ShellStatus == SHELL_SUCCESS && Resp == NULL) {
- ShellPrintEx(-1, -1, L"%s", HiiResultOk);
- }
-
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- SHELL_FREE_NON_NULL(CleanFilePathStr);
- if (Resp == NULL) {
- SHELL_FREE_NON_NULL(Response);
- }
-
- return (ShellStatus);
-
-}
-
-/**
- Validate and if successful copy all the files from the list into
- destination directory.
-
- @param[in] FileList The list of files to copy.
- @param[in] DestDir The directory to copy files to.
- @param[in] SilentMode TRUE to eliminate screen output.
- @param[in] RecursiveMode TRUE to copy directories.
-
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-ProcessValidateAndCopyFiles(
- IN EFI_SHELL_FILE_INFO *FileList,
- IN CONST CHAR16 *DestDir,
- IN BOOLEAN SilentMode,
- IN BOOLEAN RecursiveMode
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *List;
- EFI_FILE_INFO *FileInfo;
- CHAR16 *FullName;
-
- List = NULL;
- FullName = NULL;
- FileInfo = NULL;
-
- ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_READ, &List);
- if (List != NULL && List->Link.ForwardLink != List->Link.BackLink) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"cp", DestDir);
- ShellStatus = SHELL_INVALID_PARAMETER;
- ShellCloseFileMetaArg(&List);
- } else if (List != NULL) {
- ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);
- ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);
- FileInfo = gEfiShellProtocol->GetFileInfo(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle);
- ASSERT(FileInfo != NULL);
- StrnCatGrow(&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0);
- ShellCloseFileMetaArg(&List);
- if ((FileInfo->Attribute & EFI_FILE_READ_ONLY) == 0) {
- ShellStatus = ValidateAndCopyFiles(FileList, FullName, SilentMode, RecursiveMode, NULL);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_ERROR), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- } else {
- ShellCloseFileMetaArg(&List);
- ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode, RecursiveMode, NULL);
- }
-
- SHELL_FREE_NON_NULL(FileInfo);
- SHELL_FREE_NON_NULL(FullName);
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {L"-q", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'cp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- UINTN LoopCounter;
- EFI_SHELL_FILE_INFO *FileList;
- BOOLEAN SilentMode;
- BOOLEAN RecursiveMode;
- CONST CHAR16 *Cwd;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
-
- //
- // Initialize SilentMode and RecursiveMode
- //
- if (gEfiShellProtocol->BatchIsActive()) {
- SilentMode = TRUE;
- } else {
- SilentMode = ShellCommandLineGetFlag(Package, L"-q");
- }
- RecursiveMode = ShellCommandLineGetFlag(Package, L"-r");
-
- switch (ParamCount = ShellCommandLineGetCount(Package)) {
- case 0:
- case 1:
- //
- // we have insufficient parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- case 2:
- //
- // must have valid CWD for single parameter...
- //
- Cwd = ShellGetCurrentDir(NULL);
- if (Cwd == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- ShellStatus = ProcessValidateAndCopyFiles(FileList, Cwd, SilentMode, RecursiveMode);
- }
- }
-
- break;
- default:
- //
- // Make a big list of all the files...
- //
- for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS ; LoopCounter++) {
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, LoopCounter));
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- if (ShellStatus != SHELL_SUCCESS) {
- Status = ShellCloseFileMetaArg(&FileList);
- } else {
- //
- // now copy them all...
- //
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- ShellStatus = ProcessValidateAndCopyFiles(FileList, PathCleanUpDirectories((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount)), SilentMode, RecursiveMode);
- Status = ShellCloseFileMetaArg(&FileList);
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, ParamCount), ShellStatus|MAX_BIT);
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- }
- }
- break;
- } // switch on parameter count
-
- if (FileList != NULL) {
- ShellCloseFileMetaArg(&FileList);
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- if (ShellGetExecutionBreakFlag()) {
- return (SHELL_ABORTED);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
deleted file mode 100644
index ff7c8187c2..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-// This function was from from the BdsLib implementation in
-// IntelFrameworkModulePkg\Library\GenericBdsLib\BdsConnect.c
-// function name: BdsLibConnectAllEfi
-/**
- This function will connect all current system handles recursively. The
- connection will finish until every handle's child handle created if it have.
-
- @retval EFI_SUCCESS All handles and it's child handle have been
- connected
- @retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
-
-**/
-EFI_STATUS
-EFIAPI
-ConnectAllEfi (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
-
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
- }
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- function to load a .EFI driver into memory and possible connect the driver.
-
- if FileName is NULL then ASSERT.
-
- @param[in] FileName FileName of the driver to load
- @param[in] Connect Whether to connect or not
-
- @retval EFI_SUCCESS the driver was loaded and if Connect was
- true then connect was attempted. Connection may
- have failed.
- @retval EFI_OUT_OF_RESOURCES there was insufficient memory
-**/
-EFI_STATUS
-EFIAPI
-LoadDriver(
- IN CONST CHAR16 *FileName,
- IN CONST BOOLEAN Connect
- )
-{
- EFI_HANDLE LoadedDriverHandle;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedDriverImage;
-
- LoadedDriverImage = NULL;
- FilePath = NULL;
- LoadedDriverHandle = NULL;
- Status = EFI_SUCCESS;
-
- ASSERT (FileName != NULL);
-
- //
- // Fix local copies of the protocol pointers
- //
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // Convert to DEVICE_PATH
- //
- FilePath = gEfiShellProtocol->GetDevicePathFromFilePath(FileName);
-
- if (FilePath == NULL) {
- ASSERT(FALSE);
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // Use LoadImage to get it into memory
- //
- Status = gBS->LoadImage(
- FALSE,
- gImageHandle,
- FilePath,
- NULL,
- 0,
- &LoadedDriverHandle);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_IMAGE), gShellLevel2HiiHandle, FileName, Status);
- } else {
- //
- // Make sure it is a driver image
- //
- Status = gBS->HandleProtocol (LoadedDriverHandle, &gEfiLoadedImageProtocolGuid, (VOID *) &LoadedDriverImage);
-
- ASSERT (LoadedDriverImage != NULL);
-
- if ( EFI_ERROR(Status)
- || ( LoadedDriverImage->ImageCodeType != EfiBootServicesCode
- && LoadedDriverImage->ImageCodeType != EfiRuntimeServicesCode)
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_DRIVER), gShellLevel2HiiHandle, FileName);
-
- //
- // Exit and unload the non-driver image
- //
- gBS->Exit(LoadedDriverHandle, EFI_INVALID_PARAMETER, 0, NULL);
- Status = EFI_INVALID_PARAMETER;
- }
- }
-
- if (!EFI_ERROR(Status)) {
- //
- // Start the image
- //
- Status = gBS->StartImage(LoadedDriverHandle, NULL, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_ERROR), gShellLevel2HiiHandle, FileName, Status);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_LOADED), gShellLevel2HiiHandle, FileName, LoadedDriverImage->ImageBase, Status);
- }
- }
-
- if (!EFI_ERROR(Status) && Connect) {
- //
- // Connect it...
- //
- Status = ConnectAllEfi();
- }
-
- //
- // clean up memory...
- //
- if (FilePath != NULL) {
- FreePool(FilePath);
- }
-
- return (Status);
-}
-
-STATIC CONST SHELL_PARAM_ITEM LoadParamList[] = {
- {L"-nc", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'load' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLoad (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *ListHead;
- EFI_SHELL_FILE_INFO *Node;
-
- ListHead = NULL;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (LoadParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"load", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // we didnt get a single file to load parameter
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"load");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- for ( ParamCount = 1
- ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL
- ; ParamCount++
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount), EFI_FILE_MODE_READ, &ListHead);
- if (!EFI_ERROR(Status)) {
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
- ; !IsNull(&ListHead->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
- //
- // once we have an error preserve that value, but finish the loop.
- //
- if (EFI_ERROR(Status)) {
- LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
- } else {
- Status = LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
- }
- } // for loop for multi-open
- if (EFI_ERROR(Status)) {
- ShellCloseFileMetaArg(&ListHead);
- } else {
- Status = ShellCloseFileMetaArg(&ListHead);;
- }
- } else {
- //
- // no files found.
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"load", (CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount));
- ShellStatus = SHELL_NOT_FOUND;
- }
- } // for loop for params
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
- ShellStatus = SHELL_DEVICE_ERROR;
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
deleted file mode 100644
index c1e2887aa1..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ /dev/null
@@ -1,754 +0,0 @@
-/** @file
- Main file for ls shell level 2 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-#include <Guid/FileSystemInfo.h>
-
-/**
- print out the standard format output volume entry.
-
- @param[in] TheList a list of files from the volume.
-**/
-EFI_STATUS
-EFIAPI
-PrintSfoVolumeInfoTableEntry(
- IN CONST EFI_SHELL_FILE_INFO *TheList
- )
-{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *Node;
- CHAR16 *DirectoryName;
- EFI_FILE_SYSTEM_INFO *SysInfo;
- UINTN SysInfoSize;
- SHELL_FILE_HANDLE ShellFileHandle;
- EFI_FILE_PROTOCOL *EfiFpHandle;
-
- //
- // Get the first valid handle (directories)
- //
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&TheList->Link)
- ; !IsNull(&TheList->Link, &Node->Link) && Node->Handle == NULL
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&TheList->Link, &Node->Link)
- );
-
- if (Node->Handle == NULL) {
- DirectoryName = GetFullyQualifiedPath(((EFI_SHELL_FILE_INFO *)GetFirstNode(&TheList->Link))->FullName);
-
- //
- // We need to open something up to get system information
- //
- Status = gEfiShellProtocol->OpenFileByName(
- DirectoryName,
- &ShellFileHandle,
- EFI_FILE_MODE_READ
- );
-
- ASSERT_EFI_ERROR(Status);
- FreePool(DirectoryName);
-
- //
- // Get the Volume Info from ShellFileHandle
- //
- SysInfo = NULL;
- SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(ShellFileHandle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
- }
-
- ASSERT_EFI_ERROR(Status);
-
- gEfiShellProtocol->CloseFile(ShellFileHandle);
- } else {
- //
- // Get the Volume Info from Node->Handle
- //
- SysInfo = NULL;
- SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(Node->Handle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
- }
-
- ASSERT_EFI_ERROR(Status);
- }
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_SFO_HEADER),
- gShellLevel2HiiHandle,
- L"ls"
- );
- //
- // print VolumeInfo table
- //
- ASSERT(SysInfo != NULL);
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_LS_SFO_VOLINFO),
- gShellLevel2HiiHandle,
- SysInfo->VolumeLabel,
- SysInfo->VolumeSize,
- SysInfo->ReadOnly?L"TRUE":L"FALSE",
- SysInfo->FreeSpace,
- SysInfo->BlockSize
- );
-
- SHELL_FREE_NON_NULL(SysInfo);
-
- return (Status);
-}
-
-/**
- print out the info on a single file.
-
- @param[in] Sfo TRUE if in SFO, false otherwise.
- @param[in] TheNode the EFI_SHELL_FILE_INFO node to print out information on.
- @param[in] Files incremented if a file is printed.
- @param[in] Size incremented by file size.
- @param[in] Dirs incremented if a directory is printed.
-
-**/
-VOID
-EFIAPI
-PrintFileInformation(
- IN CONST BOOLEAN Sfo,
- IN CONST EFI_SHELL_FILE_INFO *TheNode,
- IN UINT64 *Files,
- IN UINT64 *Size,
- IN UINT64 *Dirs
- )
-{
- ASSERT(Files != NULL);
- ASSERT(Size != NULL);
- ASSERT(Dirs != NULL);
- ASSERT(TheNode != NULL);
-
- if (Sfo) {
- //
- // Print the FileInfo Table
- //
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_LS_SFO_FILEINFO),
- gShellLevel2HiiHandle,
- TheNode->FullName,
- TheNode->Info->FileSize,
- TheNode->Info->PhysicalSize,
- (TheNode->Info->Attribute & EFI_FILE_ARCHIVE) != 0?L"a":L"",
- (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0?L"d":L"",
- (TheNode->Info->Attribute & EFI_FILE_HIDDEN) != 0?L"h":L"",
- (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0?L"r":L"",
- (TheNode->Info->Attribute & EFI_FILE_SYSTEM) != 0?L"s":L"",
- TheNode->Info->CreateTime.Hour,
- TheNode->Info->CreateTime.Minute,
- TheNode->Info->CreateTime.Second,
- TheNode->Info->CreateTime.Day,
- TheNode->Info->CreateTime.Month,
- TheNode->Info->CreateTime.Year,
- TheNode->Info->LastAccessTime.Hour,
- TheNode->Info->LastAccessTime.Minute,
- TheNode->Info->LastAccessTime.Second,
- TheNode->Info->LastAccessTime.Day,
- TheNode->Info->LastAccessTime.Month,
- TheNode->Info->LastAccessTime.Year,
- TheNode->Info->ModificationTime.Hour,
- TheNode->Info->ModificationTime.Minute,
- TheNode->Info->ModificationTime.Second,
- TheNode->Info->ModificationTime.Day,
- TheNode->Info->ModificationTime.Month,
- TheNode->Info->ModificationTime.Year
- );
- } else {
- //
- // print this one out...
- // first print the universal start, next print the type specific name format, last print the CRLF
- //
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_LS_LINE_START_ALL),
- gShellLevel2HiiHandle,
- &TheNode->Info->ModificationTime,
- (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0?L"<DIR>":L"",
- (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0?L'r':L' ',
- TheNode->Info->FileSize
- );
- if (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) {
- (*Dirs)++;
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_LS_LINE_END_DIR),
- gShellLevel2HiiHandle,
- TheNode->FileName
- );
- } else {
- (*Files)++;
- (*Size) += TheNode->Info->FileSize;
- if ( (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".nsh", (CHAR16*)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
- || (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".efi", (CHAR16*)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
- ){
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_LS_LINE_END_EXE),
- gShellLevel2HiiHandle,
- TheNode->FileName
- );
- } else {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_LS_LINE_END_FILE),
- gShellLevel2HiiHandle,
- TheNode->FileName
- );
- }
- }
- }
-}
-
-/**
- print out the header when not using standard format output.
-
- @param[in] Path String with starting path.
-**/
-VOID
-EFIAPI
-PrintNonSfoHeader(
- IN CONST CHAR16 *Path
- )
-{
- CHAR16 *DirectoryName;
-
- //
- // get directory name from path...
- //
- DirectoryName = GetFullyQualifiedPath(Path);
-
- if (DirectoryName != NULL) {
- //
- // print header
- //
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_LS_HEADER_LINE1),
- gShellLevel2HiiHandle,
- DirectoryName
- );
-
- SHELL_FREE_NON_NULL(DirectoryName);
- }
-}
-
-/**
- print out the footer when not using standard format output.
-
- @param[in] Files The number of files.
- @param[in] Size The size of files in bytes.
- @param[in] Dirs The number of directories.
-**/
-VOID
-EFIAPI
-PrintNonSfoFooter(
- IN UINT64 Files,
- IN UINT64 Size,
- IN UINT64 Dirs
- )
-{
- //
- // print footer
- //
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_LS_FOOTER_LINE),
- gShellLevel2HiiHandle,
- Files,
- Size,
- Dirs
- );
-}
-
-/**
- print out the list of files and directories from the LS command
-
- @param[in] Rec TRUE to automatically recurse into each found directory
- FALSE to only list the specified directory.
- @param[in] Attribs List of required Attribute for display.
- If 0 then all non-system and non-hidden files will be printed.
- @param[in] Sfo TRUE to use Standard Format Output, FALSE otherwise
- @param[in] RootPath String with starting path to search in.
- @param[in] SearchString String with search string.
- @param[in] Found Set to TRUE, if anyone were found.
- @param[in] Count The count of bits enabled in Attribs.
- @param[in] TimeZone The current time zone offset.
-
- @retval SHELL_SUCCESS the printing was sucessful.
-**/
-SHELL_STATUS
-EFIAPI
-PrintLsOutput(
- IN CONST BOOLEAN Rec,
- IN CONST UINT64 Attribs,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR16 *RootPath,
- IN CONST CHAR16 *SearchString,
- IN BOOLEAN *Found,
- IN CONST UINTN Count,
- IN CONST INT16 TimeZone
- )
-{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *ListHead;
- EFI_SHELL_FILE_INFO *Node;
- SHELL_STATUS ShellStatus;
- UINT64 FileCount;
- UINT64 DirCount;
- UINT64 FileSize;
- UINTN LongestPath;
- CHAR16 *CorrectedPath;
- BOOLEAN FoundOne;
- BOOLEAN HeaderPrinted;
-
- HeaderPrinted = FALSE;
- FileCount = 0;
- DirCount = 0;
- FileSize = 0;
- ListHead = NULL;
- ShellStatus = SHELL_SUCCESS;
- LongestPath = 0;
- CorrectedPath = NULL;
-
- if (Found != NULL) {
- FoundOne = *Found;
- } else {
- FoundOne = FALSE;
- }
-
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);
- if (CorrectedPath == NULL) {
- return SHELL_OUT_OF_RESOURCES;
- }
- if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'
- &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);
- }
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, SearchString, 0);
- if (CorrectedPath == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- PathCleanUpDirectories(CorrectedPath);
-
- Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
- if (!EFI_ERROR(Status)) {
- if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
- SHELL_FREE_NON_NULL(CorrectedPath);
- return (SHELL_SUCCESS);
- }
-
- if (Sfo && Found == NULL) {
- PrintSfoVolumeInfoTableEntry(ListHead);
- }
-
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link), LongestPath = 0
- ; !IsNull(&ListHead->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- ASSERT(Node != NULL);
- if (LongestPath < StrSize(Node->FullName)) {
- LongestPath = StrSize(Node->FullName);
- }
- ASSERT(Node->Info != NULL);
- ASSERT((Node->Info->Attribute & EFI_FILE_VALID_ATTR) == Node->Info->Attribute);
- if (Attribs == 0) {
- //
- // NOT system & NOT hidden
- //
- if ( (Node->Info->Attribute & EFI_FILE_SYSTEM)
- || (Node->Info->Attribute & EFI_FILE_HIDDEN)
- ){
- continue;
- }
- } else if ((Attribs != EFI_FILE_VALID_ATTR) ||
- (Count == 5)) {
- //
- // Only matches the bits which "Attribs" contains, not
- // all files/directories with any of the bits.
- // Count == 5 is used to tell the difference between a user
- // specifying all bits (EX: -arhsda) and just specifying
- // -a (means display all files with any attribute).
- //
- if ( (Node->Info->Attribute & Attribs) != Attribs) {
- continue;
- }
- }
-
- if (!Sfo && !HeaderPrinted) {
- PrintNonSfoHeader(CorrectedPath);
- }
- PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount);
- FoundOne = TRUE;
- HeaderPrinted = TRUE;
- }
-
- if (!Sfo && ShellStatus != SHELL_ABORTED) {
- PrintNonSfoFooter(FileCount, FileSize, DirCount);
- }
- }
-
- if (Rec && ShellStatus != SHELL_ABORTED) {
- //
- // Re-Open all the files under the starting path for directories that didnt necessarily match our file filter
- //
- ShellCloseFileMetaArg(&ListHead);
- CorrectedPath[0] = CHAR_NULL;
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);
- if (CorrectedPath == NULL) {
- return SHELL_OUT_OF_RESOURCES;
- }
- if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'
- &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);
- }
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"*", 0);
- Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
-
- if (!EFI_ERROR(Status)) {
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
- ; !IsNull(&ListHead->Link, &Node->Link) && ShellStatus == SHELL_SUCCESS
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
-
- //
- // recurse on any directory except the traversing ones...
- //
- if (((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)
- && StrCmp(Node->FileName, L".") != 0
- && StrCmp(Node->FileName, L"..") != 0
- ){
- ShellStatus = PrintLsOutput(
- Rec,
- Attribs,
- Sfo,
- Node->FullName,
- SearchString,
- &FoundOne,
- Count,
- TimeZone);
-
- //
- // Since it's running recursively, we have to break immediately when returned SHELL_ABORTED
- //
- if (ShellStatus == SHELL_ABORTED) {
- break;
- }
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(CorrectedPath);
- ShellCloseFileMetaArg(&ListHead);
-
- if (Found == NULL && !FoundOne) {
- return (SHELL_NOT_FOUND);
- }
-
- if (Found != NULL) {
- *Found = FoundOne;
- }
-
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM LsParamList[] = {
- {L"-r", TypeFlag},
- {L"-a", TypeStart},
- {L"-sfo", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'ls' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLs (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Attribs;
- SHELL_STATUS ShellStatus;
- UINT64 RequiredAttributes;
- CONST CHAR16 *PathName;
- CONST CHAR16 *CurDir;
- UINTN Count;
- CHAR16 *FullPath;
- UINTN Size;
- EFI_TIME TheTime;
- CHAR16 *SearchString;
-
- Size = 0;
- FullPath = NULL;
- ProblemParam = NULL;
- Attribs = NULL;
- ShellStatus = SHELL_SUCCESS;
- RequiredAttributes = 0;
- PathName = NULL;
- SearchString = NULL;
- CurDir = NULL;
- Count = 0;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // Fix local copies of the protocol pointers
- //
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (LsParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"ls", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
-
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"ls");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // check for -a
- //
- if (ShellCommandLineGetFlag(Package, L"-a")) {
- for ( Attribs = ShellCommandLineGetValue(Package, L"-a")
- ; Attribs != NULL && *Attribs != CHAR_NULL && ShellStatus == SHELL_SUCCESS
- ; Attribs++
- ){
- switch (*Attribs) {
- case L'a':
- case L'A':
- RequiredAttributes |= EFI_FILE_ARCHIVE;
- Count++;
- continue;
- case L's':
- case L'S':
- RequiredAttributes |= EFI_FILE_SYSTEM;
- Count++;
- continue;
- case L'h':
- case L'H':
- RequiredAttributes |= EFI_FILE_HIDDEN;
- Count++;
- continue;
- case L'r':
- case L'R':
- RequiredAttributes |= EFI_FILE_READ_ONLY;
- Count++;
- continue;
- case L'd':
- case L'D':
- RequiredAttributes |= EFI_FILE_DIRECTORY;
- Count++;
- continue;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, L"ls", ShellCommandLineGetValue(Package, L"-a"));
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- } // switch
- } // for loop
- //
- // if nothing is specified all are specified
- //
- if (RequiredAttributes == 0) {
- RequiredAttributes = EFI_FILE_VALID_ATTR;
- }
- } // if -a present
- if (ShellStatus == SHELL_SUCCESS) {
- PathName = ShellCommandLineGetRawValue(Package, 1);
- if (PathName == NULL) {
- //
- // Nothing specified... must start from current directory
- //
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
- if (CurDir == NULL) {
- ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
- }
- //
- // Copy to the 2 strings for starting path and file search string
- //
- ASSERT(SearchString == NULL);
- ASSERT(FullPath == NULL);
- StrnCatGrow(&SearchString, NULL, L"*", 0);
- StrnCatGrow(&FullPath, NULL, CurDir, 0);
- } else {
- if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {
- //
- // If we got something and it doesnt have a fully qualified path, then we needed to have a CWD.
- //
- ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
- } else {
- //
- // We got a valid fully qualified path or we have a CWD
- //
- ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));
- if (StrStr(PathName, L":") == NULL) {
- StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);
- if (FullPath == NULL) {
- ShellCommandLineFreeVarList (Package);
- return SHELL_OUT_OF_RESOURCES;
- }
- }
- StrnCatGrow(&FullPath, &Size, PathName, 0);
- if (FullPath == NULL) {
- ShellCommandLineFreeVarList (Package);
- return SHELL_OUT_OF_RESOURCES;
- }
-
- if (ShellIsDirectory(PathName) == EFI_SUCCESS) {
- //
- // is listing ends with a directory, then we list all files in that directory
- //
- StrnCatGrow(&SearchString, NULL, L"*", 0);
- } else {
- //
- // must split off the search part that applies to files from the end of the directory part
- //
- for (StrnCatGrow(&SearchString, NULL, PathName, 0)
- ; SearchString != NULL && StrStr(SearchString, L"\\") != NULL
- ; CopyMem(SearchString, StrStr(SearchString, L"\\") + 1, 1 + StrSize(StrStr(SearchString, L"\\") + 1))) ;
- FullPath[StrLen(FullPath) - StrLen(SearchString)] = CHAR_NULL;
- }
- }
- }
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"ls", L"gRT->GetTime", Status);
- TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PrintLsOutput(
- ShellCommandLineGetFlag(Package, L"-r"),
- RequiredAttributes,
- ShellCommandLineGetFlag(Package, L"-sfo"),
- FullPath,
- SearchString,
- NULL,
- Count,
- TheTime.TimeZone
- );
- if (ShellStatus == SHELL_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath);
- } else if (ShellStatus == SHELL_INVALID_PARAMETER) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
- } else if (ShellStatus == SHELL_ABORTED) {
- //
- // Ignore aborting.
- //
- } else if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
- }
- }
- }
- }
- }
-
- //
- // Free memory allocated
- //
- SHELL_FREE_NON_NULL(SearchString);
- SHELL_FREE_NON_NULL(FullPath);
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
deleted file mode 100644
index a41a5f1cf6..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ /dev/null
@@ -1,1257 +0,0 @@
-/** @file
- Main file for map shell level 2 command.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/BlockIo.h>
-#include <Library/DevicePathLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/SortLib.h>
-
-/**
- Determine if a string has only numbers and letters.
-
- This is useful for such things as Map names which can only be letters and numbers.
-
- @param[in] String pointer to the string to analyze,
- @param[in] Len Number of characters to analyze.
-
- @retval TRUE String has only numbers and letters
- @retval FALSE String has at least one other character.
-**/
-BOOLEAN
-EFIAPI
-IsNumberLetterOnly(
- IN CONST CHAR16 *String,
- IN CONST UINTN Len
- )
-{
- UINTN Count;
- for (Count = 0 ; Count < Len && String != NULL && *String != CHAR_NULL ; String++,Count++) {
- if (! ((*String >= L'a' && *String <= L'z') ||
- (*String >= L'A' && *String <= L'Z') ||
- (*String >= L'0' && *String <= L'9'))
- ){
- return (FALSE);
- }
- }
- return (TRUE);
-}
-
-/**
- Do a search in the Target delimited list.
-
- @param[in] List The list to seatch in.
- @param[in] MetaTarget The item to search for. MetaMatching supported.
- @param[out] FullName Optional pointer to an allocated buffer containing
- the match.
- @param[in] Meta TRUE to use MetaMatching.
- @param[in] SkipTrailingNumbers TRUE to allow for numbers after the MetaTarget.
- @param[in] Target The single character that delimits list
- items (";" normally).
-**/
-BOOLEAN
-EFIAPI
-SearchList(
- IN CONST CHAR16 *List,
- IN CONST CHAR16 *MetaTarget,
- OUT CHAR16 **FullName OPTIONAL,
- IN CONST BOOLEAN Meta,
- IN CONST BOOLEAN SkipTrailingNumbers,
- IN CONST CHAR16 *Target
-
- )
-{
- CHAR16 *TempList;
- CONST CHAR16 *ListWalker;
- BOOLEAN Result;
- CHAR16 *TempSpot;
-
- for (ListWalker = List , TempList = NULL
- ; ListWalker != NULL && *ListWalker != CHAR_NULL
- ;
- ) {
- TempList = StrnCatGrow(&TempList, NULL, ListWalker, 0);
- ASSERT(TempList != NULL);
- TempSpot = StrStr(TempList, Target);
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
-
- while (SkipTrailingNumbers && (ShellIsDecimalDigitCharacter(TempList[StrLen(TempList)-1]) || TempList[StrLen(TempList)-1] == L':')) {
- TempList[StrLen(TempList)-1] = CHAR_NULL;
- }
-
- ListWalker = StrStr(ListWalker, Target);
- while(ListWalker != NULL && *ListWalker == *Target) {
- ListWalker++;
- }
- if (Meta) {
- Result = gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)TempList, (CHAR16*)MetaTarget);
- } else {
- Result = (BOOLEAN)(StrCmp(TempList, MetaTarget)==0);
- }
- if (Result) {
- if (FullName != NULL) {
- *FullName = TempList;
- } else {
- FreePool(TempList);
- }
- return (TRUE);
- }
- FreePool(TempList);
- TempList = NULL;
- }
-
- return (FALSE);
-}
-
-/**
- Determine what type of device is represented and return it's string. The
- string is in allocated memory and must be callee freed. The HII is is listed below.
- The actual string cannot be determined.
-
- @param[in] DevicePath The device to analyze.
-
- @retval STR_MAP_MEDIA_UNKNOWN The media type is unknown.
- @retval STR_MAP_MEDIA_HARDDISK The media is a hard drive.
- @retval STR_MAP_MEDIA_CDROM The media is a CD ROM.
- @retval STR_MAP_MEDIA_FLOPPY The media is a floppy drive.
-**/
-CHAR16*
-EFIAPI
-GetDeviceMediaType (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- ACPI_HID_DEVICE_PATH *Acpi;
-
- //
- // Parse the device path:
- // Devicepath sub type mediatype
- // MEDIA_HANRDDRIVE_DP -> Hard Disk
- // MEDIA_CDROM_DP -> CD Rom
- // Acpi.HID = 0X0604 -> Floppy
- //
- if (NULL == DevicePath) {
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
- }
-
- for (;!IsDevicePathEndType (DevicePath) ;DevicePath = NextDevicePathNode (DevicePath)) {
- if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) {
- switch (DevicePathSubType (DevicePath)) {
- case MEDIA_HARDDRIVE_DP:
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_HARDDISK), NULL);
- case MEDIA_CDROM_DP:
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_CDROM), NULL);
- }
- } else if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH) {
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
- if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_FLOPPY), NULL);
- }
- }
- }
-
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
-}
-
-/**
- Function to detemine if a handle has removable storage.
-
- @param[in] DevicePath DevicePath to test.
-
- @retval TRUE The handle has removable storage.
- @retval FALSE The handle does not have removable storage.
-**/
-BOOLEAN
-EFIAPI
-IsRemoveableDevice (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- if (NULL == DevicePath) {
- return FALSE;
- }
-
- while (!IsDevicePathEndType (DevicePath)) {
- if (DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) {
- switch (DevicePathSubType (DevicePath)) {
- case MSG_USB_DP:
- case MSG_SCSI_DP:
- return TRUE;
- default:
- return FALSE;
- }
- }
- DevicePath = NextDevicePathNode (DevicePath);
- }
- return FALSE;
-}
-
-/**
- Function to detemine if a something on the map list matches.
-
- @param[in] MapList The pointer to the list to test.
- @param[in] Specific The pointer to a specific name to test for.
- @param[in] TypeString The pointer to the list of types.
- @param[in] Normal Always show normal mappings.
- @param[in] Consist Always show consistent mappings.
-
- @retval TRUE The map should be displayed.
- @retval FALSE The map should not be displayed.
-**/
-BOOLEAN
-EFIAPI
-MappingListHasType(
- IN CONST CHAR16 *MapList,
- IN CONST CHAR16 *Specific,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN Normal,
- IN CONST BOOLEAN Consist
- )
-{
- CHAR16 *NewSpecific;
- RETURN_STATUS Status;
-
- //
- // specific has priority
- //
- if (Specific != NULL) {
- NewSpecific = AllocateCopyPool(StrSize(Specific) + sizeof(CHAR16), Specific);
- if (NewSpecific == NULL){
- return FALSE;
- }
- if (NewSpecific[StrLen(NewSpecific)-1] != L':') {
- Status = StrnCatS(NewSpecific, (StrSize(Specific) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
- if (EFI_ERROR (Status)) {
- FreePool(NewSpecific);
- return FALSE;
- }
- }
-
- if (SearchList(MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
- FreePool(NewSpecific);
- return (TRUE);
- }
- FreePool(NewSpecific);
- }
- if ( Consist
- && Specific == NULL
- && (SearchList(MapList, L"HD*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"CD*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"F*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"FP*", NULL, TRUE, TRUE, L";"))){
- return (TRUE);
- }
-
- if ( Normal
- && Specific == NULL
- && (SearchList(MapList, L"FS", NULL, FALSE, TRUE, L";")
- ||SearchList(MapList, L"BLK", NULL, FALSE, TRUE, L";"))){
- return (TRUE);
- }
-
- if (TypeString != NULL && SearchList(MapList, TypeString, NULL, TRUE, TRUE, L";")) {
- return (TRUE);
- }
- return (FALSE);
-}
-
-
-/**
- Display a single map line for device Handle if conditions are met.
-
- @param[in] Verbose TRUE to display (extra) verbose information.
- @param[in] Consist TRUE to display consistent mappings.
- @param[in] Normal TRUE to display normal (not consist) mappings.
- @param[in] TypeString pointer to string of filter types.
- @param[in] SFO TRUE to display output in Standard Output Format.
- @param[in] Specific pointer to string for specific map to display.
- @param[in] Handle The handle to display from.
-
- @retval EFI_SUCCESS The mapping was displayed.
-**/
-EFI_STATUS
-EFIAPI
-PerformSingleMappingDisplay(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL,
- IN CONST EFI_HANDLE Handle
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
- CONST CHAR16 *MapList;
- CHAR16 *CurrentName;
- CHAR16 *MediaType;
- CHAR16 *DevPathString;
- CHAR16 *TempSpot;
- CHAR16 *Alias;
- UINTN TempLen;
- BOOLEAN Removable;
- CONST CHAR16 *TempSpot2;
-
- Alias = NULL;
- TempSpot2 = NULL;
- CurrentName = NULL;
- DevPath = DevicePathFromHandle(Handle);
- DevPathCopy = DevPath;
- MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
- if (MapList == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (!MappingListHasType(MapList, Specific, TypeString, Normal, Consist)){
- return EFI_NOT_FOUND;
- }
-
- if (Normal || !Consist) {
- //
- // need the Normal here since people can use both on command line. otherwise unused.
- //
-
- //
- // Allocate a name
- //
- CurrentName = NULL;
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
- if (CurrentName == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- //
- // Chop off the other names that become "Alias(s)"
- // leaving just the normal name
- //
- TempSpot = StrStr(CurrentName, L";");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- } else {
- CurrentName = NULL;
-
- //
- // Skip the first name. This is the standard name.
- //
- TempSpot = StrStr(MapList, L";");
- if (TempSpot != NULL) {
- TempSpot++;
- }
- SearchList(TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
- if (CurrentName == NULL) {
- SearchList(TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
- }
- if (CurrentName == NULL) {
- SearchList(TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
- }
- if (CurrentName == NULL) {
- SearchList(TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
- }
- if (CurrentName == NULL) {
- //
- // We didnt find anything, so just the first one in the list...
- //
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
- if (CurrentName == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- TempSpot = StrStr(CurrentName, L";");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- } else {
- Alias = StrnCatGrow(&Alias, 0, MapList, 0);
- if (Alias == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- TempSpot = StrStr(Alias, CurrentName);
- if (TempSpot != NULL) {
- TempSpot2 = StrStr(TempSpot, L";");
- if (TempSpot2 != NULL) {
- TempSpot2++; // Move past ";" from CurrentName
- CopyMem(TempSpot, TempSpot2, StrSize(TempSpot2));
- } else {
- *TempSpot = CHAR_NULL;
- }
- }
- if (Alias[StrLen(Alias)-1] == L';') {
- Alias[StrLen(Alias)-1] = CHAR_NULL;
- }
- }
- }
- DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
- TempLen = StrLen(CurrentName);
- if (!SFO) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_MAP_ENTRY),
- gShellLevel2HiiHandle,
- CurrentName,
- Alias!=NULL?Alias:(TempLen < StrLen(MapList)?MapList + TempLen+1:L""),
- DevPathString
- );
- if (Verbose) {
- //
- // also print handle, media type, removable (y/n), and current directory
- //
- MediaType = GetDeviceMediaType(DevPath);
- if ((TypeString != NULL &&MediaType != NULL && StrStr(TypeString, MediaType) != NULL) || TypeString == NULL) {
- Removable = IsRemoveableDevice(DevPath);
- TempSpot2 = ShellGetCurrentDir(CurrentName);
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_MAP_ENTRY_VERBOSE),
- gShellLevel2HiiHandle,
- ConvertHandleToHandleIndex(Handle),
- MediaType,
- Removable?L"Yes":L"No",
- TempSpot2
- );
- }
- SHELL_FREE_NON_NULL(MediaType);
- }
- } else {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_MAP_SFO_MAPPINGS),
- gShellLevel2HiiHandle,
- CurrentName,
- DevPathString,
- Consist?L"":(TempLen < StrLen(MapList)?MapList + TempLen+1:L"")
- );
- }
- SHELL_FREE_NON_NULL(DevPathString);
- SHELL_FREE_NON_NULL(CurrentName);
- SHELL_FREE_NON_NULL(Alias);
- return EFI_SUCCESS;
-}
-
-/**
- Delete Specific from the list of maps for device Handle.
-
- @param[in] Specific The name to delete.
- @param[in] Handle The device to look on.
-
- @retval EFI_SUCCESS The delete was successful.
- @retval EFI_NOT_FOUND Name was not a map on Handle.
-**/
-EFI_STATUS
-EFIAPI
-PerformSingleMappingDelete(
- IN CONST CHAR16 *Specific,
- IN CONST EFI_HANDLE Handle
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
- CONST CHAR16 *MapList;
- CHAR16 *CurrentName;
-
- DevPath = DevicePathFromHandle(Handle);
- DevPathCopy = DevPath;
- MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
- CurrentName = NULL;
-
- if (MapList == NULL) {
- return (EFI_NOT_FOUND);
- }
- //
- // if there is a specific and its not on the list...
- //
- if (!SearchList(MapList, Specific, &CurrentName, TRUE, FALSE, L";")) {
- return (EFI_NOT_FOUND);
- }
- return (gEfiShellProtocol->SetMap(NULL, CurrentName));
-}
-
-CONST CHAR16 Cd[] = L"cd*";
-CONST CHAR16 Hd[] = L"hd*";
-CONST CHAR16 Fp[] = L"fp*";
-CONST CHAR16 AnyF[] = L"F*";
-/**
- Function to display mapping information to the user.
-
- If Specific is specified then Consist and Normal will be ignored since information will
- be printed for the specific item only.
-
- @param[in] Verbose TRUE to display (extra) verbose information.
- @param[in] Consist TRUE to display consistent mappings.
- @param[in] Normal TRUE to display normal (not consist) mappings.
- @param[in] TypeString Pointer to string of filter types.
- @param[in] SFO TRUE to display output in Standard Output Format.
- @param[in] Specific Pointer to string for specific map to display.
- @param[in] Header TRUE to print the header block.
-
- @retval SHELL_SUCCESS The display was printed.
- @retval SHELL_INVALID_PARAMETER One of Consist or Normal must be TRUE if no Specific.
-
-**/
-SHELL_STATUS
-EFIAPI
-PerformMappingDisplay(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL,
- IN CONST BOOLEAN Header
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN BufferSize;
- UINTN LoopVar;
- CHAR16 *Test;
- BOOLEAN Found;
-
- if (!Consist && !Normal && Specific == NULL && TypeString == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
- return (SHELL_INVALID_PARAMETER);
- }
-
- if (TypeString != NULL) {
- Test = (CHAR16*)Cd;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- Test = (CHAR16*)Hd;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- Test = (CHAR16*)Fp;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", TypeString);
- return (SHELL_INVALID_PARAMETER);
- }
- } else if (Test == NULL) {
- Test = (CHAR16*)AnyF;
- }
- }
- } else {
- Test = NULL;
- }
-
- if (Header) {
- //
- // Print the header
- //
- if (!SFO) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_HEADER), gShellLevel2HiiHandle);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"map");
- }
- }
-
- BufferSize = 0;
- HandleBuffer = NULL;
-
- //
- // Look up all SimpleFileSystems in the platform
- //
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(BufferSize);
- if (HandleBuffer == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- }
-
- //
- // Get the map name(s) for each one.
- //
- for ( LoopVar = 0, Found = FALSE
- ; LoopVar < (BufferSize / sizeof(EFI_HANDLE)) && HandleBuffer != NULL
- ; LoopVar ++
- ){
- Status = PerformSingleMappingDisplay(
- Verbose,
- Consist,
- Normal,
- Test,
- SFO,
- Specific,
- HandleBuffer[LoopVar]);
- if (!EFI_ERROR(Status)) {
- Found = TRUE;
- }
- }
-
- //
- // Look up all BlockIo in the platform
- //
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- HandleBuffer = AllocateZeroPool(BufferSize);
- if (HandleBuffer == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- }
- if (!EFI_ERROR(Status) && HandleBuffer != NULL) {
- //
- // Get the map name(s) for each one.
- //
- for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
- //
- // Skip any that were already done...
- //
- if (gBS->OpenProtocol(
- HandleBuffer[LoopVar],
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
- continue;
- }
- Status = PerformSingleMappingDisplay(
- Verbose,
- Consist,
- Normal,
- Test,
- SFO,
- Specific,
- HandleBuffer[LoopVar]);
- if (!EFI_ERROR(Status)) {
- Found = TRUE;
- }
- }
- FreePool(HandleBuffer);
- }
- if (!Found) {
- if (Specific != NULL) {
- ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", Specific);
- } else {
- ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"map");
- }
- }
- return (SHELL_SUCCESS);
-}
-
-/**
- Perform a mapping display and parse for multiple types in the TypeString.
-
- @param[in] Verbose TRUE to use verbose output.
- @param[in] Consist TRUE to display consistent names.
- @param[in] Normal TRUE to display normal names.
- @param[in] TypeString An optional comma-delimited list of types.
- @param[in] SFO TRUE to display in SFO format. See Spec.
- @param[in] Specific An optional specific map name to display alone.
-
- @retval SHELL_INVALID_PARAMETER A parameter was invalid.
- @retval SHELL_SUCCESS The display was successful.
- @sa PerformMappingDisplay
-**/
-SHELL_STATUS
-EFIAPI
-PerformMappingDisplay2(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL
- )
-{
- CONST CHAR16 *TypeWalker;
- SHELL_STATUS ShellStatus;
- CHAR16 *Comma;
-
-
- if (TypeString == NULL) {
- return (PerformMappingDisplay(Verbose, Consist, Normal, NULL, SFO, Specific, TRUE));
- }
- ShellStatus = SHELL_SUCCESS;
- for (TypeWalker = TypeString ; TypeWalker != NULL && *TypeWalker != CHAR_NULL ;) {
- Comma = StrStr(TypeWalker, L",");
- if (Comma == NULL) {
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
- } else {
- PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
- }
- break;
- } else {
- *Comma = CHAR_NULL;
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
- } else {
- PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
- }
- *Comma = L',';
- TypeWalker = Comma + 1;
- }
- }
-
- return (ShellStatus);
-}
-
-/**
- Delete a specific map.
-
- @param[in] Specific The pointer to the name of the map to delete.
-
- @retval EFI_INVALID_PARAMETER Specific was NULL.
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND Specific could not be found.
-**/
-EFI_STATUS
-EFIAPI
-PerformMappingDelete(
- IN CONST CHAR16 *Specific
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN BufferSize;
- UINTN LoopVar;
- BOOLEAN Deleted;
-
- if (Specific == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- BufferSize = 0;
- HandleBuffer = NULL;
- Deleted = FALSE;
-
- //
- // Look up all SimpleFileSystems in the platform
- //
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiDevicePathProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(BufferSize);
- if (HandleBuffer == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiDevicePathProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- }
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- return (Status);
- }
-
- if (HandleBuffer != NULL) {
- //
- // Get the map name(s) for each one.
- //
- for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
- Deleted = TRUE;
- }
- }
- }
- //
- // Look up all BlockIo in the platform
- //
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- FreePool(HandleBuffer);
- HandleBuffer = AllocateZeroPool(BufferSize);
- if (HandleBuffer == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
- }
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- return (Status);
- }
-
- if (HandleBuffer != NULL) {
- //
- // Get the map name(s) for each one.
- //
- for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
- //
- // Skip any that were already done...
- //
- if (gBS->OpenProtocol(
- HandleBuffer[LoopVar],
- &gEfiDevicePathProtocolGuid,
- NULL,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
- continue;
- }
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
- Deleted = TRUE;
- }
- }
- }
- SHELL_FREE_NON_NULL(HandleBuffer);
- if (!Deleted) {
- return (EFI_NOT_FOUND);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- function to add a mapping from mapping.
-
- This function will get the device path associated with the mapping and call SetMap.
-
- @param[in] Map The Map to add a mapping for
- @param[in] SName The name of the new mapping
-
- @retval SHELL_SUCCESS the mapping was added
- @retval SHELL_INVALID_PARAMETER the device path for Map could not be retrieved.
- @return Shell version of a return value from EfiShellProtocol->SetMap
-
-**/
-SHELL_STATUS
-EFIAPI
-AddMappingFromMapping(
- IN CONST CHAR16 *Map,
- IN CONST CHAR16 *SName
- )
-{
- CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_STATUS Status;
- CHAR16 *NewSName;
- RETURN_STATUS StrRetStatus;
-
- NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
- if (NewSName == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- if (NewSName[StrLen(NewSName)-1] != L':') {
- StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
- if (EFI_ERROR(StrRetStatus)) {
- FreePool(NewSName);
- return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
- }
- }
-
- if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
- FreePool(NewSName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- DevPath = gEfiShellProtocol->GetDevicePathFromMap(Map);
- if (DevPath == NULL) {
- FreePool(NewSName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
- FreePool(NewSName);
- if (EFI_ERROR(Status)) {
- return (SHELL_DEVICE_ERROR);
- }
- return (SHELL_SUCCESS);
-}
-
-/**
- function to add a mapping from an EFI_HANDLE.
-
- This function will get the device path associated with the Handle and call SetMap.
-
- @param[in] Handle The handle to add a mapping for
- @param[in] SName The name of the new mapping
-
- @retval SHELL_SUCCESS the mapping was added
- @retval SHELL_INVALID_PARAMETER SName was not valid for a map name.
- @return Shell version of a return value from either
- gBS->OpenProtocol or EfiShellProtocol->SetMap
-
-**/
-SHELL_STATUS
-EFIAPI
-AddMappingFromHandle(
- IN CONST EFI_HANDLE Handle,
- IN CONST CHAR16 *SName
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_STATUS Status;
- CHAR16 *NewSName;
- RETURN_STATUS StrRetStatus;
-
- NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
- if (NewSName == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- if (NewSName[StrLen(NewSName)-1] != L':') {
- StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
- if (EFI_ERROR(StrRetStatus)) {
- FreePool(NewSName);
- return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
- }
- }
-
- if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
- FreePool(NewSName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gBS->OpenProtocol(
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&DevPath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- FreePool(NewSName);
- return (SHELL_DEVICE_ERROR);
- }
- Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
- FreePool(NewSName);
- if (EFI_ERROR(Status)) {
- return (SHELL_DEVICE_ERROR);
- }
- return (SHELL_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM MapParamList[] = {
- {L"-d", TypeValue},
- {L"-r", TypeFlag},
- {L"-v", TypeFlag},
- {L"-c", TypeFlag},
- {L"-f", TypeFlag},
- {L"-u", TypeFlag},
- {L"-t", TypeValue},
- {L"-sfo", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'map' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMap (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *SName;
- CONST CHAR16 *Mapping;
- EFI_HANDLE MapAsHandle;
- SHELL_STATUS ShellStatus;
- BOOLEAN SfoMode;
- BOOLEAN ConstMode;
- BOOLEAN NormlMode;
- CONST CHAR16 *Param1;
- CONST CHAR16 *TypeString;
- UINTN TempStringLength;
-
- ProblemParam = NULL;
- Mapping = NULL;
- SName = NULL;
- ShellStatus = SHELL_SUCCESS;
- MapAsHandle = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (MapParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"map", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
- ConstMode = ShellCommandLineGetFlag(Package, L"-c");
- NormlMode = ShellCommandLineGetFlag(Package, L"-f");
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 3) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"map");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Deleting a map name...
- //
- if (ShellCommandLineGetFlag(Package, L"-d")) {
- if ( ShellCommandLineGetFlag(Package, L"-r")
- || ShellCommandLineGetFlag(Package, L"-v")
- || ConstMode
- || NormlMode
- || ShellCommandLineGetFlag(Package, L"-u")
- || ShellCommandLineGetFlag(Package, L"-t")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"map");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- SName = ShellCommandLineGetValue(Package, L"-d");
- if (SName != NULL) {
- Status = PerformMappingDelete(SName);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_ACCESS_DENIED) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
- ShellStatus = SHELL_ACCESS_DENIED;
- } else if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", SName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
- ShellStatus = SHELL_UNSUPPORTED;
- }
- }
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- } else if ( ShellCommandLineGetFlag(Package, L"-r")
-// || ShellCommandLineGetFlag(Package, L"-v")
- || ConstMode
- || NormlMode
- || ShellCommandLineGetFlag(Package, L"-u")
- || ShellCommandLineGetFlag(Package, L"-t")
- ){
- if ( ShellCommandLineGetFlag(Package, L"-r")) {
- //
- // Do the reset
- //
- Status = ShellCommandCreateInitialMappingsAndPaths();
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
- ShellStatus = SHELL_UNSUPPORTED;
- }
- }
- if ( ShellStatus == SHELL_SUCCESS && ShellCommandLineGetFlag(Package, L"-u")) {
- //
- // Do the Update
- //
- Status = ShellCommandUpdateMapping ();
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
- ShellStatus = SHELL_UNSUPPORTED;
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- TypeString = ShellCommandLineGetValue(Package, L"-t");
- if (!ConstMode
- &&!NormlMode
- &&TypeString == NULL
- ) {
- //
- // now do the display...
- //
- ShellStatus = PerformMappingDisplay(
- ShellCommandLineGetFlag(Package, L"-v"),
- TRUE,
- TRUE,
- NULL,
- SfoMode,
- Param1,
- TRUE
- );
- } else {
- //
- // now do the display...
- //
- ShellStatus = PerformMappingDisplay2(
- ShellCommandLineGetFlag(Package, L"-v"),
- ConstMode,
- NormlMode,
- TypeString,
- SfoMode,
- Param1
- );
- }
- }
- } else {
- //
- // adding or displaying (there were no flags)
- //
- SName = ShellCommandLineGetRawValue(Package, 1);
- Mapping = ShellCommandLineGetRawValue(Package, 2);
- if ( SName == NULL
- && Mapping == NULL
- ){
- //
- // display only since no flags
- //
- ShellStatus = PerformMappingDisplay(
- ShellCommandLineGetFlag(Package, L"-v"),
- TRUE,
- TRUE,
- NULL,
- SfoMode,
- NULL,
- TRUE
- );
- } else if ( SName == NULL
- || Mapping == NULL
- ){
- //
- // Display only the one specified
- //
- ShellStatus = PerformMappingDisplay(
- FALSE,
- FALSE,
- FALSE,
- NULL,
- SfoMode,
- SName, // note the variable here...
- TRUE
- );
- } else {
- if (ShellIsHexOrDecimalNumber(Mapping, TRUE, FALSE)) {
- MapAsHandle = ConvertHandleIndexToHandle(ShellStrToUintn(Mapping));
- } else {
- MapAsHandle = NULL;
- }
- if (MapAsHandle == NULL && Mapping[StrLen(Mapping)-1] != L':') {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (MapAsHandle != NULL) {
- TempStringLength = StrLen(SName);
- if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = AddMappingFromHandle(MapAsHandle, SName);
- }
- } else {
- TempStringLength = StrLen(SName);
- if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = AddMappingFromMapping(Mapping, SName);
- }
- }
- if (ShellStatus != SHELL_SUCCESS) {
- switch (ShellStatus) {
- case SHELL_ACCESS_DENIED:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
- break;
- case SHELL_INVALID_PARAMETER:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
- break;
- case SHELL_DEVICE_ERROR:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
- }
- } else {
- //
- // now do the display...
- //
- ShellStatus = PerformMappingDisplay(
- FALSE,
- FALSE,
- FALSE,
- NULL,
- SfoMode,
- SName,
- TRUE
- );
- } // we were sucessful so do an output
- } // got a valid map target
- } // got 2 variables
- } // we are adding a mapping
- } // got valid parameters
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c
deleted file mode 100644
index 4aade13aac..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- Function for 'mkdir' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMkDir (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- CONST CHAR16 *NewDirName;
- UINTN DirCreateCount;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_FILE_HANDLE FileHandle;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mkdir", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
-
- //
- // create a set of directories
- //
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // we didnt get a single parameter
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mkdir");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- for ( DirCreateCount = 1
- ;
- ; DirCreateCount++
- ){
- //
- // loop through each directory specified
- //
-
- NewDirName = ShellCommandLineGetRawValue(Package, DirCreateCount);
- if (NewDirName == NULL) {
- break;
- }
- //
- // check if that already exists... if yes fail
- //
- FileHandle = NULL;
- Status = ShellOpenFileByName(NewDirName,
- &FileHandle,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
- EFI_FILE_DIRECTORY
- );
- if (!EFI_ERROR(Status)) {
- ShellCloseFile(&FileHandle);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_ALREADY), gShellLevel2HiiHandle, NewDirName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- } else {
- ASSERT(FileHandle == NULL);
- //
- // create the directory named NewDirName
- //
- Status = ShellCreateDirectory(NewDirName, &FileHandle);
- if (FileHandle != NULL) {
- gEfiShellProtocol->CloseFile(FileHandle);
- }
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_CREATEFAIL), gShellLevel2HiiHandle, NewDirName);
- ShellStatus = SHELL_ACCESS_DENIED;
- break;
- }
- }
- }
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
deleted file mode 100644
index fa67533743..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/** @file
- Main file for mv shell level 2 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- function to determine if a move is between file systems.
-
- @param FullName [in] The name of the file to move.
- @param Cwd [in] The current working directory
- @param DestPath [in] The target location to move to
-
- @retval TRUE The move is across file system.
- @retval FALSE The move is within a file system.
-**/
-BOOLEAN
-EFIAPI
-IsBetweenFileSystem(
- IN CONST CHAR16 *FullName,
- IN CONST CHAR16 *Cwd,
- IN CONST CHAR16 *DestPath
- )
-{
- CHAR16 *Test;
- CHAR16 *Test1;
- UINTN Result;
-
- Test = StrStr(FullName, L":");
- if (Test == NULL && Cwd != NULL) {
- Test = StrStr(Cwd, L":");
- }
- Test1 = StrStr(DestPath, L":");
- if (Test1 == NULL && Cwd != NULL) {
- Test1 = StrStr(Cwd, L":");
- }
- if (Test1 != NULL && Test != NULL) {
- *Test = CHAR_NULL;
- *Test1 = CHAR_NULL;
- Result = StringNoCaseCompare(&FullName, &DestPath);
- *Test = L':';
- *Test1 = L':';
- if (Result != 0) {
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-/**
- Function to validate that moving a specific file (FileName) to a specific
- location (DestPath) is valid.
-
- This function will verify that the destination is not a subdirectory of
- FullName, that the Current working Directory is not being moved, and that
- the directory is not read only.
-
- if the move is invalid this function will report the error to StdOut.
-
- @param SourcePath [in] The name of the file to move.
- @param Cwd [in] The current working directory
- @param DestPath [in] The target location to move to
- @param Attribute [in] The Attribute of the file
- @param DestAttr [in] The Attribute of the destination
- @param FileStatus [in] The Status of the file when opened
-
- @retval TRUE The move is valid
- @retval FALSE The move is not
-**/
-BOOLEAN
-EFIAPI
-IsValidMove(
- IN CONST CHAR16 *SourcePath,
- IN CONST CHAR16 *Cwd,
- IN CONST CHAR16 *DestPath,
- IN CONST UINT64 Attribute,
- IN CONST UINT64 DestAttr,
- IN CONST EFI_STATUS FileStatus
- )
-{
- CHAR16 *DestPathCopy;
- CHAR16 *DestPathWalker;
-
- if (Cwd != NULL && StrCmp(SourcePath, Cwd) == 0) {
- //
- // Invalid move
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);
- return (FALSE);
- }
-
- //
- // invalid to move read only or move to a read only destination
- //
- if (((Attribute & EFI_FILE_READ_ONLY) != 0)
- || (FileStatus == EFI_WRITE_PROTECTED)
- || ((DestAttr & EFI_FILE_READ_ONLY) != 0)
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);
- return (FALSE);
- }
-
- DestPathCopy = AllocateCopyPool(StrSize(DestPath), DestPath);
- if (DestPathCopy == NULL) {
- return (FALSE);
- }
-
- for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) ;
-
- while(DestPathWalker != NULL && DestPathWalker[StrLen(DestPathWalker)-1] == L'\\') {
- DestPathWalker[StrLen(DestPathWalker)-1] = CHAR_NULL;
- }
-
- ASSERT(DestPathWalker != NULL);
- ASSERT(SourcePath != NULL);
-
- //
- // If they're the same, or if source is "above" dest on file path tree
- //
- if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||
- ((StrStr(DestPathWalker, SourcePath) == DestPathWalker) &&
- (DestPathWalker[StrLen(SourcePath)] == '\\')
- )
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
- FreePool(DestPathCopy);
- return (FALSE);
- }
- FreePool(DestPathCopy);
-
- return (TRUE);
-}
-
-/**
- Function to take a destination path that might contain wildcards and verify
- that there is only a single possible target (IE we cant have wildcards that
- have 2 possible destination).
-
- if the result is sucessful the caller must free *DestPathPointer.
-
- @param[in] DestParameter The original path to the destination.
- @param[in, out] DestPathPointer A pointer to the callee allocated final path.
- @param[in] Cwd A pointer to the current working directory.
- @param[in] SingleSource TRUE to have only one source file.
- @param[in, out] DestAttr A pointer to the destination information attribute.
-
- @retval SHELL_INVALID_PARAMETER The DestParameter could not be resolved to a location.
- @retval SHELL_INVALID_PARAMETER The DestParameter could be resolved to more than 1 location.
- @retval SHELL_INVALID_PARAMETER Cwd is required and is NULL.
- @retval SHELL_SUCCESS The operation was sucessful.
-**/
-SHELL_STATUS
-EFIAPI
-GetDestinationLocation(
- IN CONST CHAR16 *DestParameter,
- IN OUT CHAR16 **DestPathPointer,
- IN CONST CHAR16 *Cwd,
- IN CONST BOOLEAN SingleSource,
- IN OUT UINT64 *DestAttr
- )
-{
- EFI_SHELL_FILE_INFO *DestList;
- EFI_SHELL_FILE_INFO *Node;
- CHAR16 *DestPath;
- UINTN NewSize;
- UINTN CurrentSize;
-
- DestList = NULL;
- DestPath = NULL;
-
- ASSERT(DestAttr != NULL);
-
- if (StrStr(DestParameter, L"\\") == DestParameter) {
- if (Cwd == NULL) {
- return SHELL_INVALID_PARAMETER;
- }
- DestPath = AllocateZeroPool(StrSize(Cwd));
- if (DestPath == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- StrCpyS(DestPath, StrSize(Cwd) / sizeof(CHAR16), Cwd);
- while (PathRemoveLastItem(DestPath)) ;
-
- //
- // Append DestParameter beyond '\' which may be present
- //
- CurrentSize = StrSize(DestPath);
- StrnCatGrow(&DestPath, &CurrentSize, &DestParameter[1], 0);
-
- *DestPathPointer = DestPath;
- return (SHELL_SUCCESS);
- }
- //
- // get the destination path
- //
- ShellOpenFileMetaArg((CHAR16*)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
- if (DestList == NULL || IsListEmpty(&DestList->Link)) {
- //
- // Not existing... must be renaming
- //
- if (StrStr(DestParameter, L":") == NULL) {
- if (Cwd == NULL) {
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
- return (SHELL_INVALID_PARAMETER);
- }
- NewSize = StrSize(Cwd);
- NewSize += StrSize(DestParameter);
- DestPath = AllocateZeroPool(NewSize);
- if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
- return (SHELL_OUT_OF_RESOURCES);
- }
- StrCpyS(DestPath, NewSize / sizeof(CHAR16), Cwd);
- if (DestPath[StrLen(DestPath)-1] != L'\\' && DestParameter[0] != L'\\') {
- StrCatS(DestPath, NewSize / sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestParameter[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
- }
- StrCatS(DestPath, NewSize / sizeof(CHAR16), DestParameter);
- } else {
- ASSERT(DestPath == NULL);
- DestPath = StrnCatGrow(&DestPath, NULL, DestParameter, 0);
- if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
- return (SHELL_OUT_OF_RESOURCES);
- }
- }
- } else {
- Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
- *DestAttr = Node->Info->Attribute;
- //
- // Make sure there is only 1 node in the list.
- //
- if (!IsNodeAtEnd(&DestList->Link, &Node->Link)) {
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
- return (SHELL_INVALID_PARAMETER);
- }
-
- //
- // If we are a directory or a single file, then one node is fine.
- //
- if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS || SingleSource) {
- DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
- if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
- return (SHELL_OUT_OF_RESOURCES);
- }
- StrCpyS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), Node->FullName);
- StrCatS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), L"\\");
- } else {
- //
- // cant move multiple files onto a single file.
- //
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
- return (SHELL_INVALID_PARAMETER);
- }
- }
-
- *DestPathPointer = DestPath;
- ShellCloseFileMetaArg(&DestList);
-
- return (SHELL_SUCCESS);
-}
-
-/**
- Function to do a move across file systems.
-
- @param[in] Node A pointer to the file to be removed.
- @param[in] DestPath A pointer to the destination file path.
- @param[out] Resp A pointer to response from question. Pass back on looped calling
-
- @retval SHELL_SUCCESS The source file was moved to the destination.
-**/
-EFI_STATUS
-EFIAPI
-MoveBetweenFileSystems(
- IN EFI_SHELL_FILE_INFO *Node,
- IN CONST CHAR16 *DestPath,
- OUT VOID **Resp
- )
-{
- SHELL_STATUS ShellStatus;
-
- //
- // First we copy the file
- //
- ShellStatus = CopySingleFile (Node->FullName, DestPath, Resp, TRUE, L"mv");
-
- //
- // Check our result
- //
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // The copy was successful. delete the source file.
- //
- CascadeDelete(Node, TRUE);
- Node->Handle = NULL;
- } else if (ShellStatus == SHELL_ABORTED) {
- return EFI_ABORTED;
- } else if (ShellStatus == SHELL_ACCESS_DENIED) {
- return EFI_ACCESS_DENIED;
- } else if (ShellStatus == SHELL_VOLUME_FULL) {
- return EFI_VOLUME_FULL;
- } else {
- return EFI_UNSUPPORTED;
- }
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to take the destination path and target file name to generate the full destination path.
-
- @param[in] DestPath A pointer to the destination file path string.
- @param[out] FullDestPath A pointer to the full destination path string.
- @param[in] FileName Name string of the targe file.
-
- @retval SHELL_SUCCESS the files were all moved.
- @retval SHELL_INVALID_PARAMETER a parameter was invalid
- @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
-**/
-EFI_STATUS
-EFIAPI
-CreateFullDestPath(
- IN CONST CHAR16 **DestPath,
- OUT CHAR16 **FullDestPath,
- IN CONST CHAR16 *FileName
- )
-{
- UINTN Size;
- if (FullDestPath == NULL || FileName == NULL || DestPath == NULL || *DestPath == NULL){
- return (EFI_INVALID_PARAMETER);
- }
-
- Size = StrSize(*DestPath) + StrSize(FileName);
-
- *FullDestPath = AllocateZeroPool(Size);
- if (*FullDestPath == NULL){
- return (EFI_OUT_OF_RESOURCES);
- }
-
- StrCpyS(*FullDestPath, Size / sizeof(CHAR16), *DestPath);
- if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {
- StrCatS(*FullDestPath, Size / sizeof(CHAR16), L"\\");
- }
- StrCatS(*FullDestPath, Size / sizeof(CHAR16), FileName);
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to do a move within a file system.
-
- @param[in] Node A pointer to the file to be removed.
- @param[in] DestPath A pointer to the destination file path.
- @param[out] Resp A pointer to response from question. Pass back on looped calling.
-
- @retval SHELL_SUCCESS The source file was moved to the destination.
- @retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-MoveWithinFileSystems(
- IN EFI_SHELL_FILE_INFO *Node,
- IN CHAR16 *DestPath,
- OUT VOID **Resp
- )
-{
- EFI_FILE_INFO *NewFileInfo;
- CHAR16 *TempLocation;
- UINTN NewSize;
- UINTN Length;
- EFI_STATUS Status;
-
- //
- // Chop off map info from DestPath
- //
- if ((TempLocation = StrStr(DestPath, L":")) != NULL) {
- CopyMem(DestPath, TempLocation+1, StrSize(TempLocation+1));
- }
-
- //
- // construct the new file info block
- //
- NewSize = StrSize(DestPath);
- NewSize += StrSize(Node->FileName) + SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
- NewFileInfo = AllocateZeroPool(NewSize);
- if (NewFileInfo == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
- Status = EFI_OUT_OF_RESOURCES;
- } else {
- CopyMem(NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);
- if (DestPath[0] != L'\\') {
- StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), L"\\");
- StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
- } else {
- StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
- }
- Length = StrLen(NewFileInfo->FileName);
- if (Length > 0) {
- Length--;
- }
- if (NewFileInfo->FileName[Length] == L'\\') {
- if (Node->FileName[0] == L'\\') {
- //
- // Don't allow for double slashes. Eliminate one of them.
- //
- NewFileInfo->FileName[Length] = CHAR_NULL;
- }
- StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), Node->FileName);
- }
- NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);
-
- //
- // Perform the move operation
- //
- Status = ShellSetFileInfo(Node->Handle, NewFileInfo);
-
- //
- // Free the info object we used...
- //
- FreePool(NewFileInfo);
- }
-
- return (Status);
-}
-/**
- function to take a list of files to move and a destination location and do
- the verification and moving of those files to that location. This function
- will report any errors to the user and continue to move the rest of the files.
-
- @param[in] FileList A LIST_ENTRY* based list of files to move
- @param[out] Resp pointer to response from question. Pass back on looped calling
- @param[in] DestParameter the originally specified destination location
-
- @retval SHELL_SUCCESS the files were all moved.
- @retval SHELL_INVALID_PARAMETER a parameter was invalid
- @retval SHELL_SECURITY_VIOLATION a security violation ocurred
- @retval SHELL_WRITE_PROTECTED the destination was write protected
- @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
-**/
-SHELL_STATUS
-EFIAPI
-ValidateAndMoveFiles(
- IN EFI_SHELL_FILE_INFO *FileList,
- OUT VOID **Resp,
- IN CONST CHAR16 *DestParameter
- )
-{
- EFI_STATUS Status;
- CHAR16 *HiiOutput;
- CHAR16 *HiiResultOk;
- CHAR16 *DestPath;
- CHAR16 *FullDestPath;
- CONST CHAR16 *Cwd;
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *Node;
- VOID *Response;
- UINT64 Attr;
- CHAR16 *CleanFilePathStr;
-
- ASSERT(FileList != NULL);
- ASSERT(DestParameter != NULL);
-
- DestPath = NULL;
- FullDestPath = NULL;
- Cwd = ShellGetCurrentDir(NULL);
- Response = *Resp;
- Attr = 0;
- CleanFilePathStr = NULL;
-
- Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
- if (EFI_ERROR (Status)) {
- if (Status == EFI_OUT_OF_RESOURCES) {
- return SHELL_OUT_OF_RESOURCES;
- } else {
- return SHELL_INVALID_PARAMETER;
- }
- }
-
- ASSERT (CleanFilePathStr != NULL);
-
- //
- // Get and validate the destination location
- //
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
- FreePool (CleanFilePathStr);
-
- if (ShellStatus != SHELL_SUCCESS) {
- return (ShellStatus);
- }
- DestPath = PathCleanUpDirectories(DestPath);
- if (DestPath == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
- HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
- if (HiiOutput == NULL || HiiResultOk == NULL) {
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- //
- // Go through the list of files and directories to move...
- //
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
-
- //
- // These should never be NULL
- //
- ASSERT(Node->FileName != NULL);
- ASSERT(Node->FullName != NULL);
- ASSERT(Node->Info != NULL);
-
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
- continue;
- }
-
- SHELL_FREE_NON_NULL(FullDestPath);
- FullDestPath = NULL;
- if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {
- CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
- }
-
- //
- // Validate that the move is valid
- //
- if (!IsValidMove(Node->FullName, Cwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- continue;
- }
-
- ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);
-
- //
- // See if destination exists
- //
- if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {
- if (Response == NULL) {
- ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
- }
- switch (*(SHELL_PROMPT_RESPONSE*)Response) {
- case ShellPromptResponseNo:
- FreePool(Response);
- Response = NULL;
- continue;
- case ShellPromptResponseCancel:
- *Resp = Response;
- //
- // indicate to stop everything
- //
- return (SHELL_ABORTED);
- case ShellPromptResponseAll:
- *Resp = Response;
- break;
- case ShellPromptResponseYes:
- FreePool(Response);
- Response = NULL;
- break;
- default:
- FreePool(Response);
- return SHELL_ABORTED;
- }
- Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);
- }
-
- if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {
- while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
- DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
- }
- Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
- } else {
- Status = MoveWithinFileSystems(Node, DestPath, &Response);
- //
- // Display error status
- //
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
- }
- }
-
- //
- // Check our result
- //
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_WRITE_PROTECTED) {
- ShellStatus = SHELL_WRITE_PROTECTED;
- } else if (Status == EFI_OUT_OF_RESOURCES) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else if (Status == EFI_DEVICE_ERROR) {
- ShellStatus = SHELL_DEVICE_ERROR;
- } else if (Status == EFI_ACCESS_DENIED) {
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- } else {
- ShellPrintEx(-1, -1, L"%s", HiiResultOk);
- }
-
- } // main for loop
-
- SHELL_FREE_NON_NULL(FullDestPath);
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- return (ShellStatus);
-}
-
-/**
- Function for 'mv' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMv (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- UINTN LoopCounter;
- EFI_SHELL_FILE_INFO *FileList;
- VOID *Response;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
- Response = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
-
- switch (ParamCount = ShellCommandLineGetCount(Package)) {
- case 0:
- case 1:
- //
- // we have insufficient parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- case 2:
- //
- // must have valid CWD for single parameter...
- //
- if (ShellGetCurrentDir(NULL) == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- //
- // ValidateAndMoveFiles will report errors to the screen itself
- //
- ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));
- }
- }
-
- break;
- default:
- ///@todo make sure this works with error half way through and continues...
- for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- //
- // ValidateAndMoveFiles will report errors to the screen itself
- // Only change ShellStatus if it's sucessful
- //
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
- } else {
- ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
- }
- }
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- Status = ShellCloseFileMetaArg(&FileList);
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
- ShellStatus = SHELL_ACCESS_DENIED;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);
- }
- }
- }
- break;
- } // switch on parameter count
-
- if (FileList != NULL) {
- ShellCloseFileMetaArg(&FileList);
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- SHELL_FREE_NON_NULL(Response);
-
- if (ShellGetExecutionBreakFlag()) {
- return (SHELL_ABORTED);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c
deleted file mode 100644
index 12fe87750c..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/** @file
- Main file for Parse shell level 2 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- Check if data is coming from StdIn output.
-
- @param[in] None
-
- @retval TRUE StdIn stream data available to parse
- @retval FALSE StdIn stream data is not available to parse.
-**/
-BOOLEAN
-IsStdInDataAvailable (
- VOID
- )
-{
- SHELL_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
- CHAR16 CharBuffer;
- UINTN CharSize;
- UINT64 OriginalFilePosition;
-
- Status = EFI_SUCCESS;
- FileHandle = NULL;
- OriginalFilePosition = 0;
-
- if (ShellOpenFileByName (L">i", &FileHandle, EFI_FILE_MODE_READ, 0) == EFI_SUCCESS) {
- CharSize = sizeof(CHAR16);
- gEfiShellProtocol->GetFilePosition (FileHandle, &OriginalFilePosition);
- Status = gEfiShellProtocol->ReadFile (FileHandle, &CharSize, &CharBuffer);
- if (EFI_ERROR (Status) || (CharSize != sizeof(CHAR16))) {
- return FALSE;
- }
- gEfiShellProtocol->SetFilePosition(FileHandle, OriginalFilePosition);
- }
-
- if (FileHandle == NULL) {
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-/**
- Function to read a single line (up to but not including the \n) using StdIn data from a SHELL_FILE_HANDLE.
-
- If the position upon start is 0, then the Ascii Boolean will be set. This should be
- maintained and not changed for all operations with the same file.
-
- @param[in] Handle SHELL_FILE_HANDLE to read from.
- @param[in, out] Buffer The pointer to buffer to read into.
- @param[in, out] Size The pointer to number of bytes in Buffer.
- @param[in] Truncate If the buffer is large enough, this has no effect.
- If the buffer is is too small and Truncate is TRUE,
- the line will be truncated.
- If the buffer is is too small and Truncate is FALSE,
- then no read will occur.
-
- @retval EFI_SUCCESS The operation was successful. The line is stored in
- Buffer.
- @retval EFI_INVALID_PARAMETER Handle was NULL.
- @retval EFI_INVALID_PARAMETER Size was NULL.
- @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.
- Size was updated to the minimum space required.
-**/
-EFI_STATUS
-EFIAPI
-ShellFileHandleReadStdInLine(
- IN SHELL_FILE_HANDLE Handle,
- IN OUT CHAR16 *Buffer,
- IN OUT UINTN *Size,
- IN BOOLEAN Truncate
- )
-{
- EFI_STATUS Status;
- CHAR16 CharBuffer;
- UINTN CharSize;
- UINTN CountSoFar;
- UINT64 OriginalFilePosition;
-
-
- if (Handle == NULL
- ||Size == NULL
- ){
- return (EFI_INVALID_PARAMETER);
- }
- if (Buffer == NULL) {
- ASSERT(*Size == 0);
- } else {
- *Buffer = CHAR_NULL;
- }
- gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
-
- for (CountSoFar = 0;;CountSoFar++){
- CharBuffer = 0;
- CharSize = sizeof(CHAR16);
- Status = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
- if ( EFI_ERROR(Status)
- || CharSize == 0
- || (CharBuffer == L'\n')
- ){
- break;
- }
- //
- // if we have space save it...
- //
- if ((CountSoFar+1)*sizeof(CHAR16) < *Size){
- ASSERT(Buffer != NULL);
- ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
- ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
- }
- }
-
- //
- // if we ran out of space tell when...
- //
- if ((CountSoFar+1)*sizeof(CHAR16) > *Size){
- *Size = (CountSoFar+1)*sizeof(CHAR16);
- if (!Truncate) {
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- } else {
- DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));
- }
- return (EFI_BUFFER_TOO_SMALL);
- }
- while(Buffer[StrLen(Buffer)-1] == L'\r') {
- Buffer[StrLen(Buffer)-1] = CHAR_NULL;
- }
-
- return (Status);
-}
-
-
-/**
- Function to read a single line using StdIn from a SHELL_FILE_HANDLE. The \n is not included in the returned
- buffer. The returned buffer must be callee freed.
-
- If the position upon start is 0, then the Ascii Boolean will be set. This should be
- maintained and not changed for all operations with the same file.
-
- @param[in] Handle SHELL_FILE_HANDLE to read from.
-
- @return The line of text from the file.
- @retval NULL There was not enough memory available.
-
- @sa ShellFileHandleReadLine
-**/
-CHAR16*
-EFIAPI
-ParseReturnStdInLine (
- IN SHELL_FILE_HANDLE Handle
- )
-{
- CHAR16 *RetVal;
- UINTN Size;
- EFI_STATUS Status;
-
- Size = 0;
- RetVal = NULL;
-
- Status = ShellFileHandleReadStdInLine (Handle, RetVal, &Size, FALSE);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- RetVal = AllocateZeroPool(Size);
- if (RetVal == NULL) {
- return (NULL);
- }
- Status = ShellFileHandleReadStdInLine (Handle, RetVal, &Size, FALSE);
-
- }
- if (EFI_ERROR(Status) && (RetVal != NULL)) {
- FreePool(RetVal);
- RetVal = NULL;
- }
- return (RetVal);
-}
-
-/**
- Handle stings for SFO Output with escape character ^ in a string
- 1. Quotation marks in the string must be escaped by using a ^ character (i.e. ^").
- 2. The ^ character may be inserted using ^^.
-
- @param[in] String The Unicode NULL-terminated string.
-
- @retval NewString The new string handled for SFO.
-**/
-EFI_STRING
-HandleStringWithEscapeCharForParse (
- IN CHAR16 *String
- )
-{
- EFI_STRING NewStr;
- EFI_STRING StrWalker;
- EFI_STRING ReturnStr;
-
- if (String == NULL) {
- return NULL;
- }
-
- //
- // start to parse the input string.
- //
- NewStr = AllocateZeroPool (StrSize (String));
- if (NewStr == NULL) {
- return NULL;
- }
- ReturnStr = NewStr;
- StrWalker = String;
- while (*StrWalker != CHAR_NULL) {
- if (*StrWalker == L'^' && (*(StrWalker + 1) == L'^' || *(StrWalker + 1) == L'"')) {
- *NewStr = *(StrWalker + 1);
- StrWalker++;
- } else {
- *NewStr = *StrWalker;
- }
- StrWalker++;
- NewStr++;
- }
-
- return ReturnStr;
-}
-
-
-/**
- Do the actual parsing of the file. the file should be SFO output from a
- shell command or a similar format.
-
- @param[in] FileName The filename to open.
- @param[in] TableName The name of the table to find.
- @param[in] ColumnIndex The column number to get.
- @param[in] TableNameInstance Which instance of the table to get (row).
- @param[in] ShellCommandInstance Which instance of the command to get.
- @param[in] StreamingUnicode Indicates Input file is StdIn Unicode streaming data or not
-
- @retval SHELL_NOT_FOUND The requested instance was not found.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-PerformParsing(
- IN CONST CHAR16 *FileName,
- IN CONST CHAR16 *TableName,
- IN CONST UINTN ColumnIndex,
- IN CONST UINTN TableNameInstance,
- IN CONST UINTN ShellCommandInstance,
- IN BOOLEAN StreamingUnicode
- )
-{
- SHELL_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
- BOOLEAN Ascii;
- UINTN LoopVariable;
- UINTN ColumnLoop;
- CHAR16 *TempLine;
- CHAR16 *ColumnPointer;
- SHELL_STATUS ShellStatus;
- CHAR16 *TempSpot;
- CHAR16 *SfoString;
-
- ASSERT(FileName != NULL);
- ASSERT(TableName != NULL);
-
- ShellStatus = SHELL_SUCCESS;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"parse", FileName);
- ShellStatus = SHELL_NOT_FOUND;
- } else if (!EFI_ERROR (FileHandleIsDirectory (FileHandle))) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_FILE), gShellLevel2HiiHandle, L"parse", FileName);
- ShellStatus = SHELL_NOT_FOUND;
- } else {
- for (LoopVariable = 0 ; LoopVariable < ShellCommandInstance && !ShellFileHandleEof(FileHandle);) {
- if (StreamingUnicode) {
- TempLine = ParseReturnStdInLine (FileHandle);
- } else {
- TempLine = ShellFileHandleReturnLine (FileHandle, &Ascii);
- }
-
- if ((TempLine == NULL) || (*TempLine == CHAR_NULL && StreamingUnicode)) {
- break;
- }
-
- //
- // Search for "ShellCommand," in the file to start the SFO table
- // for a given ShellCommand. The UEFI Shell spec does not specify
- // a space after the comma.
- //
- if (StrStr (TempLine, L"ShellCommand,") == TempLine) {
- LoopVariable++;
- }
- SHELL_FREE_NON_NULL(TempLine);
- }
- if (LoopVariable == ShellCommandInstance) {
- LoopVariable = 0;
- while(1) {
- if (StreamingUnicode) {
- TempLine = ParseReturnStdInLine (FileHandle);
- } else {
- TempLine = ShellFileHandleReturnLine (FileHandle, &Ascii);
- }
- if (TempLine == NULL
- || *TempLine == CHAR_NULL
- || StrStr (TempLine, L"ShellCommand,") == TempLine) {
- SHELL_FREE_NON_NULL(TempLine);
- break;
- }
- if (StrStr (TempLine, TableName) == TempLine) {
- LoopVariable++;
- if (LoopVariable == TableNameInstance
- || (TableNameInstance == (UINTN)-1)) {
- for (ColumnLoop = 1, ColumnPointer = TempLine; ColumnLoop < ColumnIndex && ColumnPointer != NULL && *ColumnPointer != CHAR_NULL; ColumnLoop++) {
- ColumnPointer = StrStr (ColumnPointer, L",\"");
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL){
- ColumnPointer++;
- }
- }
- if (ColumnLoop == ColumnIndex) {
- if (ColumnPointer == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"parse", L"Column Index");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TempSpot = StrStr (ColumnPointer, L",\"");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- while (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[0] == L' '){
- ColumnPointer++;
- }
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[0] == L'\"'){
- ColumnPointer++;
- }
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[StrLen (ColumnPointer) - 1] == L'\"'){
- ColumnPointer[StrLen (ColumnPointer) - 1] = CHAR_NULL;
- }
- SfoString = HandleStringWithEscapeCharForParse (ColumnPointer);
- if (SfoString != NULL) {
- ShellPrintEx (-1, -1, L"%s\r\n", SfoString);
- SHELL_FREE_NON_NULL (SfoString);
- }
- }
- }
- }
- }
- SHELL_FREE_NON_NULL(TempLine);
- }
- }
- }
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeValue},
- {L"-s", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'parse' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunParse (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *FileName;
- CONST CHAR16 *TableName;
- CONST CHAR16 *ColumnString;
- SHELL_STATUS ShellStatus;
- UINTN ShellCommandInstance;
- UINTN TableNameInstance;
- BOOLEAN StreamingUnicode;
-
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
- StreamingUnicode = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"parse", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- StreamingUnicode = IsStdInDataAvailable ();
- if ((!StreamingUnicode && (ShellCommandLineGetCount(Package) < 4)) ||
- (ShellCommandLineGetCount(Package) < 3)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"parse");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((StreamingUnicode && (ShellCommandLineGetCount(Package) > 3)) ||
- (ShellCommandLineGetCount(Package) > 4)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"parse");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (StreamingUnicode) {
- FileName = L">i";
- TableName = ShellCommandLineGetRawValue(Package, 1);
- ColumnString = ShellCommandLineGetRawValue(Package, 2);
- } else {
- FileName = ShellCommandLineGetRawValue(Package, 1);
- TableName = ShellCommandLineGetRawValue(Package, 2);
- ColumnString = ShellCommandLineGetRawValue(Package, 3);
- }
- if (ShellCommandLineGetValue(Package, L"-i") == NULL) {
- TableNameInstance = (UINTN)-1;
- } else {
- TableNameInstance = ShellStrToUintn(ShellCommandLineGetValue(Package, L"-i"));
- }
- if (ShellCommandLineGetValue(Package, L"-s") == NULL) {
- ShellCommandInstance = 1;
- } else {
- ShellCommandInstance = ShellStrToUintn(ShellCommandLineGetValue(Package, L"-s"));
- }
-
- ShellStatus = PerformParsing(FileName, TableName, ShellStrToUintn(ColumnString), TableNameInstance, ShellCommandInstance, StreamingUnicode);
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
deleted file mode 100644
index 7d4cfb470e..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {
- {L"-w", TypeValue},
- {L"-s", TypeValue},
- {L"-c", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'reset' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunReset (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CONST CHAR16 *String;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ResetParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"reset", ProblemParam);
- FreePool(ProblemParam);
- return (SHELL_INVALID_PARAMETER);
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag
- //
- if (ShellCommandLineGetFlag(Package, L"-w")) {
- if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-c")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- String = ShellCommandLineGetValue(Package, L"-w");
- if (String != NULL) {
- gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, StrSize(String), (VOID*)String);
- } else {
- gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);
- }
- }
- } else if (ShellCommandLineGetFlag(Package, L"-s")) {
- if (ShellCommandLineGetFlag(Package, L"-c")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- String = ShellCommandLineGetValue(Package, L"-s");
- DEBUG_CODE(ShellPrintEx(-1,-1,L"Reset with %s (%d bytes)", String, String!=NULL?StrSize(String):0););
- if (String != NULL) {
- gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, StrSize(String), (VOID*)String);
- } else {
- gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
- }
- }
- } else {
- //
- // this is default so dont worry about flag...
- //
- String = ShellCommandLineGetValue(Package, L"-c");
- if (String != NULL) {
- gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, StrSize(String), (VOID*)String);
- } else {
- gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
- }
- }
- }
- }
-
- //
- // we should never get here... so the free and return are for formality more than use
- // as the ResetSystem function should not return...
- //
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
deleted file mode 100644
index ed9940d827..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-q", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Determine if a directory has no files in it.
-
- @param[in] FileHandle The EFI_HANDLE to the directory.
-
- @retval TRUE The directory has no files (or directories).
- @retval FALSE The directory has at least 1 file or directory in it.
-**/
-BOOLEAN
-EFIAPI
-IsDirectoryEmpty (
- IN EFI_HANDLE FileHandle
- )
-{
- EFI_FILE_INFO *FileInfo;
- BOOLEAN NoFile;
- BOOLEAN RetVal;
-
- RetVal = TRUE;
- NoFile = FALSE;
- FileInfo = NULL;
-
- for (FileHandleFindFirstFile(FileHandle, &FileInfo)
- ; !NoFile
- ; FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)
- ){
- if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName
- &&StrStr(FileInfo->FileName, L"..") != FileInfo->FileName) {
- RetVal = FALSE;
- }
- }
- return (RetVal);
-}
-
-/**
- Delete a node and all nodes under it (including sub directories).
-
- @param[in] Node The node to start deleting with.
- @param[in] Quiet TRUE to print no messages.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_ACCESS_DENIED A file was read only.
- @retval SHELL_ABORTED The abort message was received.
- @retval SHELL_DEVICE_ERROR A device error occured reading this Node.
-**/
-SHELL_STATUS
-EFIAPI
-CascadeDelete(
- IN EFI_SHELL_FILE_INFO *Node,
- IN CONST BOOLEAN Quiet
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *List;
- EFI_SHELL_FILE_INFO *Node2;
- EFI_STATUS Status;
- SHELL_PROMPT_RESPONSE *Resp;
- CHAR16 *TempName;
- UINTN NewSize;
-
- Resp = NULL;
- ShellStatus = SHELL_SUCCESS;
- List = NULL;
- Status = EFI_SUCCESS;
-
- if ((Node->Info->Attribute & EFI_FILE_READ_ONLY) == EFI_FILE_READ_ONLY) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DETELE_RO), gShellLevel2HiiHandle, L"rm", Node->FullName);
- return (SHELL_ACCESS_DENIED);
- }
-
- if ((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
- if (!IsDirectoryEmpty(Node->Handle)) {
- if (!Quiet) {
- Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);
- Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);
- ASSERT(Resp != NULL);
- if (EFI_ERROR(Status) || *Resp != ShellPromptResponseYes) {
- SHELL_FREE_NON_NULL(Resp);
- return (SHELL_ABORTED);
- }
- SHELL_FREE_NON_NULL(Resp);
- }
- //
- // empty out the directory
- //
- Status = gEfiShellProtocol->FindFilesInDir(Node->Handle, &List);
- if (EFI_ERROR(Status)) {
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
- }
- return (SHELL_DEVICE_ERROR);
- }
- for (Node2 = (EFI_SHELL_FILE_INFO *)GetFirstNode(&List->Link)
- ; !IsNull(&List->Link, &Node2->Link)
- ; Node2 = (EFI_SHELL_FILE_INFO *)GetNextNode(&List->Link, &Node2->Link)
- ){
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(Node2->FileName, L".") == 0 || StrCmp(Node2->FileName, L"..") == 0) {
- continue;
- }
- Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
- if (EFI_ERROR(Node2->Status) && StrStr(Node2->FileName, L":") == NULL) {
- //
- // Update the node filename to have full path with file system identifier
- //
- NewSize = StrSize(Node->FullName) + StrSize(Node2->FullName);
- TempName = AllocateZeroPool(NewSize);
- if (TempName == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- } else {
- StrCpyS(TempName, NewSize/sizeof(CHAR16), Node->FullName);
- TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;
- StrCatS(TempName, NewSize/sizeof(CHAR16), Node2->FullName);
- FreePool((VOID*)Node2->FullName);
- Node2->FullName = TempName;
-
- //
- // Now try again to open the file
- //
- Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
- }
- }
- if (!EFI_ERROR(Node2->Status)) {
- ShellStatus = CascadeDelete(Node2, Quiet);
- } else if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = (SHELL_STATUS)(Node2->Status&(~0x80000000));
- }
- if (ShellStatus != SHELL_SUCCESS) {
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
- }
- return (ShellStatus);
- }
- }
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
- }
- }
- }
-
- if (!(StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0)) {
- //
- // now delete the current node...
- //
- if (!Quiet) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE), gShellLevel2HiiHandle, Node->FullName);
- }
- Status = gEfiShellProtocol->DeleteFile(Node->Handle);
- Node->Handle = NULL;
- }
-
- //
- // We cant allow for the warning here! (Dont use EFI_ERROR Macro).
- //
- if (Status != EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR), gShellLevel2HiiHandle, Status);
- return (SHELL_ACCESS_DENIED);
- } else {
- if (!Quiet) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_COMP), gShellLevel2HiiHandle);
- }
- return (SHELL_SUCCESS);
- }
-}
-
-/**
- Determines if a Node is a valid delete target. Will prevent deleting the root directory.
-
- @param[in] List RESERVED. Not used.
- @param[in] Node The node to analyze.
- @param[in] Package RESERVED. Not used.
-**/
-BOOLEAN
-EFIAPI
-IsValidDeleteTarget(
- IN CONST EFI_SHELL_FILE_INFO *List,
- IN CONST EFI_SHELL_FILE_INFO *Node,
- IN CONST LIST_ENTRY *Package
- )
-{
- CONST CHAR16 *TempLocation;
- BOOLEAN RetVal;
- CHAR16 *SearchString;
- CHAR16 *Pattern;
- UINTN Size;
-
- if (Node == NULL || Node->FullName == NULL) {
- return (FALSE);
- }
-
- TempLocation = StrStr(Node->FullName, L":");
- if (StrLen(TempLocation) <= 2) {
- //
- // Deleting the root directory is invalid.
- //
- return (FALSE);
- }
-
- TempLocation = ShellGetCurrentDir(NULL);
- if (TempLocation == NULL) {
- //
- // No working directory is specified so whatever is left is ok.
- //
- return (TRUE);
- }
-
- Pattern = NULL;
- SearchString = NULL;
- Size = 0;
- Pattern = StrnCatGrow(&Pattern , NULL, TempLocation , 0);
- SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);
- if (!EFI_ERROR(ShellIsDirectory(SearchString))) {
- SearchString = StrnCatGrow(&SearchString, &Size, L"\\", 0);
- SearchString = StrnCatGrow(&SearchString, &Size, L"*", 0);
- }
-
- if (Pattern == NULL || SearchString == NULL) {
- RetVal = FALSE;
- } else {
- RetVal = TRUE;
- if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Pattern, SearchString)) {
- RetVal = FALSE;
- }
- }
-
- SHELL_FREE_NON_NULL(Pattern );
- SHELL_FREE_NON_NULL(SearchString);
-
- return (RetVal);
-}
-
-/**
- Function for 'rm' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunRm (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Param;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *Node;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"rm", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // we insufficient parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"rm");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // get a list with each file specified by parameters
- // if parameter is a directory then add all the files below it to the list
- //
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ; Param != NULL
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"rm", (CHAR16*)Param);
- ShellStatus = SHELL_NOT_FOUND;
- break;
- }
- }
-
- if (ShellStatus == SHELL_SUCCESS){
- //
- // loop through the list and make sure we are not aborting...
- //
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
- ){
- //
- // skip the directory traversing stuff...
- //
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
- continue;
- }
-
- //
- // do the deleting of nodes
- //
- if (EFI_ERROR(Node->Status)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR2), gShellLevel2HiiHandle, Node->Status);
- ShellStatus = SHELL_ACCESS_DENIED;
- break;
- }
- if (!IsValidDeleteTarget(FileList, Node, Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR3), gShellLevel2HiiHandle, Node->FullName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- }
-
- ShellStatus = CascadeDelete(Node, ShellCommandLineGetFlag(Package, L"-q"));
- }
- }
- //
- // Free the fileList
- //
- if (FileList != NULL) {
- Status = ShellCloseFileMetaArg(&FileList);
- }
- FileList = NULL;
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c
deleted file mode 100644
index 45948e1275..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- Print out each environment variable registered with the Shell 2.0 GUID.
-
- If you spawn a pre 2.0 shell from the Shell 2.0 the environment variable may not carry through.
-
- @retval STATUS_SUCCESS the printout was sucessful
- @return any return code from GetNextVariableName except EFI_NOT_FOUND
-**/
-SHELL_STATUS
-EFIAPI
-PrintAllShellEnvVars(
- VOID
- )
-{
- CONST CHAR16 *Value;
- CONST CHAR16 *ConstEnvNameList;
-
- ConstEnvNameList = gEfiShellProtocol->GetEnv(NULL);
- if (ConstEnvNameList == NULL) {
- return (SHELL_SUCCESS);
- }
- while (*ConstEnvNameList != CHAR_NULL){
- Value = gEfiShellProtocol->GetEnv(ConstEnvNameList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, ConstEnvNameList, Value);
- ConstEnvNameList += StrLen(ConstEnvNameList)+1;
- }
-
- return (SHELL_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM SetParamList[] = {
- {L"-d", TypeValue},
- {L"-v", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'set' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSet (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CONST CHAR16 *KeyName;
- CONST CHAR16 *Value;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // Make sure globals are good...
- //
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (SetParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"set", ProblemParam);
- FreePool(ProblemParam);
- return (SHELL_INVALID_PARAMETER);
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 3) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL && ShellCommandLineGetFlag(Package, L"-d")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-d")) {
- //
- // delete a environment variable
- //
- KeyName = ShellCommandLineGetValue(Package, L"-d");
- if (KeyName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"set", L"-d");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ShellSetEnvironmentVariable(KeyName, L"", ShellCommandLineGetFlag(Package, L"-v"));
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_ND), gShellLevel2HiiHandle, L"set", KeyName);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // print out all current environment variables
- //
- return(PrintAllShellEnvVars());
- } else {
- //
- // we are either printing one or assigning one
- //
- KeyName = ShellCommandLineGetRawValue(Package, 1);
- Value = ShellCommandLineGetRawValue(Package, 2);
- if (KeyName != NULL && Value != NULL) {
- //
- // assigning one
- //
- Status = ShellSetEnvironmentVariable(KeyName, Value, ShellCommandLineGetFlag(Package, L"-v"));
- } else {
- if (KeyName != NULL) {
- //
- // print out value for this one only.
- //
- Value = ShellGetEnvironmentVariable(KeyName);
- if (Value == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_NF), gShellLevel2HiiHandle, L"set", KeyName);
- ShellStatus = SHELL_SUCCESS;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, KeyName, Value);
- ShellStatus = SHELL_SUCCESS;
- }
- } else {
- ASSERT(FALSE);
- }
- }
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
deleted file mode 100644
index 533519d49d..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
+++ /dev/null
@@ -1,976 +0,0 @@
-/** @file
- Main file for time, timezone, and date shell level 2 and shell level 3 functions.
-
- (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-/**
- Determine if String is a valid representation for a time or date.
-
- @param[in] String The pointer to the string to test.
- @param[in] Char The delimeter character.
- @param[in] Min The minimum value allowed.
- @param[in] Max The maximum value allowed.
- @param[in] MinusOk Whether negative numbers are permitted.
-
- @retval TRUE String is a valid representation.
- @retval FALSE String is invalid.
-**/
-BOOLEAN
-EFIAPI
-InternalIsTimeLikeString (
- IN CONST CHAR16 *String,
- IN CONST CHAR16 Char,
- IN CONST UINTN Min,
- IN CONST UINTN Max,
- IN CONST BOOLEAN MinusOk
- )
-{
- UINTN Count;
- Count = 0;
-
- if (MinusOk) {
- //
- // A single minus is ok.
- //
- if (*String == L'-') {
- String++;
- }
- }
-
- //
- // the first char must be numeric.
- //
- if (!ShellIsDecimalDigitCharacter(*String)) {
- return (FALSE);
- }
- //
- // loop through the characters and use the lib function
- //
- for ( ; String != NULL && *String != CHAR_NULL ; String++){
- if (*String == Char) {
- Count++;
- if (Count > Max) {
- return (FALSE);
- }
- continue;
- }
- if (!ShellIsDecimalDigitCharacter(*String)) {
- return (FALSE);
- }
- }
- if (Count < Min) {
- return (FALSE);
- }
- return (TRUE);
-}
-
-/**
- Verify that the DateString is valid and if so set that as the current
- date.
-
- @param[in] DateString The pointer to a string representation of the date.
-
- @retval SHELL_INVALID_PARAMETER DateString was NULL.
- @retval SHELL_INVALID_PARAMETER DateString was mis-formatted.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-CheckAndSetDate (
- IN CONST CHAR16 *DateString
- )
-{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *DateStringCopy;
- CHAR16 *Walker;
- CHAR16 *Walker1;
-
- if (!InternalIsTimeLikeString(DateString, L'/', 2, 2, FALSE)) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- DateStringCopy = NULL;
- DateStringCopy = StrnCatGrow(&DateStringCopy, NULL, DateString, 0);
- if (DateStringCopy == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- Walker = DateStringCopy;
-
- TheTime.Month = 0xFF;
- TheTime.Day = 0xFF;
- TheTime.Year = 0xFFFF;
-
- Walker1 = StrStr(Walker, L"/");
- if (Walker1 != NULL && *Walker1 == L'/') {
- *Walker1 = CHAR_NULL;
- }
-
- TheTime.Month = (UINT8)ShellStrToUintn (Walker);
- if (Walker1 != NULL) {
- Walker = Walker1 + 1;
- }
- Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;
- if (Walker1 != NULL && *Walker1 == L'/') {
- *Walker1 = CHAR_NULL;
- }
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
- TheTime.Day = (UINT8)ShellStrToUintn (Walker);
- if (Walker1 != NULL) {
- Walker = Walker1 + 1;
- }
- Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;
- if (Walker1 != NULL && *Walker1 == L'/') {
- *Walker1 = CHAR_NULL;
- }
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
- TheTime.Year = (UINT16)ShellStrToUintn (Walker);
- }
- }
-
- if (TheTime.Year < 100) {
- if (TheTime.Year >= 98) {
- TheTime.Year = (UINT16)(1900 + TheTime.Year);
- } else {
- TheTime.Year = (UINT16)(2000 + TheTime.Year);
- }
- }
-
- Status = gRT->SetTime(&TheTime);
-
- if (!EFI_ERROR(Status)){
- return (SHELL_SUCCESS);
- }
- return (SHELL_INVALID_PARAMETER);
-}
-
-/**
- Function for 'date' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDate (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- EFI_TIME TheTime;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
-
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"date", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // If there are 0 value parameters, then print the current date
- // else If there are any value paramerers, then print error
- //
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // get the current date
- //
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // ShellPrintEx the date in SFO or regular format
- //
- if (ShellCommandLineGetFlag(Package, L"-sfo")) {
- //
- // Match UEFI Shell spec:
- // ShellCommand,"date"
- // Date,"DD","MM","YYYY"
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"date");
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Day, TheTime.Month, TheTime.Year);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
- }
- } else {
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // perform level 3 operation here.
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 == NULL) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = CheckAndSetDate(Param1);
- }
- if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"date", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- }
- }
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
-
-//
-// Note "-tz" is invalid for this (non-interactive) version of 'time'.
-//
-STATIC CONST SHELL_PARAM_ITEM TimeParamList2[] = {
- {L"-d", TypeValue},
- {NULL, TypeMax}
- };
-
-STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
- {L"-d", TypeValue},
- {L"-tz", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Verify that the TimeString is valid and if so set that as the current
- time.
-
- @param[in] TimeString The pointer to a string representation of the time.
- @param[in] Tz The value to set for TimeZone.
- @param[in] Daylight The value to set for Daylight.
-
- @retval SHELL_INVALID_PARAMETER TimeString was NULL.
- @retval SHELL_INVALID_PARAMETER TimeString was mis-formatted.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-CheckAndSetTime (
- IN CONST CHAR16 *TimeString,
- IN CONST INT16 Tz,
- IN CONST UINT8 Daylight
- )
-{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *TimeStringCopy;
- CHAR16 *Walker1;
- CHAR16 *Walker2;
-
- if (TimeString != NULL && !InternalIsTimeLikeString(TimeString, L':', 1, 2, FALSE)) {
- return (SHELL_INVALID_PARAMETER);
- }
- if (Daylight != 0xFF &&((Daylight & (EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT)) != Daylight)) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- if (TimeString != NULL) {
- TimeStringCopy = NULL;
- TimeStringCopy = StrnCatGrow(&TimeStringCopy, NULL, TimeString, 0);
- Walker1 = TimeStringCopy;
- TheTime.Hour = 0xFF;
- TheTime.Minute = 0xFF;
-
- Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;
- if (Walker2 != NULL && *Walker2 == L':') {
- *Walker2 = CHAR_NULL;
- }
- TheTime.Hour = (UINT8)ShellStrToUintn (Walker1);
- if (Walker2 != NULL) {
- Walker1 = Walker2 + 1;
- }
- Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;
- if (Walker2 != NULL && *Walker2 == L':') {
- *Walker2 = CHAR_NULL;
- TheTime.Second = (UINT8)0;
- }
- else if (Walker2 == NULL) {
- TheTime.Second = (UINT8)0;
- }
- if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
- TheTime.Minute = (UINT8)ShellStrToUintn (Walker1);
- if (Walker2 != NULL) {
- Walker1 = Walker2 + 1;
- if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
- TheTime.Second = (UINT8)ShellStrToUintn (Walker1);
- }
- }
- }
- SHELL_FREE_NON_NULL(TimeStringCopy);
- }
-
-
- if (Tz >= -1440 && Tz <= 1440) {
- //
- // EFI_TIME TimeZone is stored to meet the following calculation (see UEFI Spec):
- // Localtime = UTC - TimeZone
- // This means the sign must be changed for the user provided Tz.
- // EX: User wants to set TimeZone to Pacific Standard Time, so runs
- // time -tz -480 # set to UTC-08:00
- // To meet the calculation, the sign must be changed.
- //
- TheTime.TimeZone = -Tz;
- } else if (Tz == EFI_UNSPECIFIED_TIMEZONE) {
- TheTime.TimeZone = Tz;
- }
-
- if (Daylight != 0xFF) {
- TheTime.Daylight = Daylight;
- }
-
- Status = gRT->SetTime(&TheTime);
-
- if (!EFI_ERROR(Status)){
- return (SHELL_SUCCESS);
- }
-
- return (SHELL_INVALID_PARAMETER);
-}
-
-/**
- Function for 'time' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTime (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- EFI_TIME TheTime;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- INT16 Tz;
- UINT8 Daylight;
- CONST CHAR16 *TempLocation;
- UINTN TzMinutes;
-
- //
- // Initialize variables
- //
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- Status = ShellCommandLineParseEx (TimeParamList2, &Package, &ProblemParam, TRUE, TRUE);
- } else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
- Status = ShellCommandLineParseEx (TimeParamList3, &Package, &ProblemParam, TRUE, TRUE);
- }
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // If there are no parameters, then print the current time
- //
- if (ShellCommandLineGetRawValue(Package, 1) == NULL
- && !ShellCommandLineGetFlag(Package, L"-d")
- && !ShellCommandLineGetFlag(Package, L"-tz")) {
- //
- // ShellPrintEx the current time
- //
- if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
- TzMinutes = 0;
- } else {
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
- }
-
- if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_TIME_FORMAT),
- gShellLevel2HiiHandle,
- TheTime.Hour,
- TheTime.Minute,
- TheTime.Second,
- (TheTime.TimeZone > 0?L"-":L"+"),
- ((ABS(TheTime.TimeZone)) / 60),
- TzMinutes
- );
- } else {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_TIME_FORMAT_LOCAL),
- gShellLevel2HiiHandle,
- TheTime.Hour,
- TheTime.Minute,
- TheTime.Second
- );
- }
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel2HiiHandle);
- } else if (ShellCommandLineGetFlag(Package, L"-d") && ShellCommandLineGetValue(Package, L"-d") == NULL) {
- if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_TIME_FORMAT_LOCAL),
- gShellLevel2HiiHandle,
- TheTime.Hour,
- TheTime.Minute,
- TheTime.Second
- );
- } else {
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_TIME_FORMAT),
- gShellLevel2HiiHandle,
- TheTime.Hour,
- TheTime.Minute,
- TheTime.Second,
- (TheTime.TimeZone > 0?L"-":L"+"),
- ((ABS(TheTime.TimeZone)) / 60),
- TzMinutes
- );
- }
- switch (TheTime.Daylight) {
- case 0:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST0), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_ADJUST_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST1), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_IN_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST2), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle);
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);
- }
- } else {
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // perform level 3 operation here.
- //
- if ((TempLocation = ShellCommandLineGetValue(Package, L"-tz")) != NULL) {
- if (StrniCmp (TempLocation, L"_local", StrLen (TempLocation)) == NULL) {
- Tz = EFI_UNSPECIFIED_TIMEZONE;
- } else if (TempLocation[0] == L'-') {
-
- Tz = (INT16) ShellStrToUintn (++TempLocation);
- //
- // When the argument of "time [-tz tz]" is not numeric, ShellStrToUintn() returns "-1".
- // Here we can detect the argument error by checking the return of ShellStrToUintn().
- //
- if (Tz == -1) {
- Tz = 1441; //make it to be out of bounds value
- } else {
- Tz *= (-1); //sign convert
- }
- } else {
- if (TempLocation[0] == L'+') {
- Tz = (INT16)ShellStrToUintn (++TempLocation);
- } else {
- Tz = (INT16)ShellStrToUintn (TempLocation);
- }
- //
- // Detect the return of ShellStrToUintn() to make sure the argument is valid.
- //
- if (Tz == -1) {
- Tz = 1441; //make it to be out of bounds value
- }
- }
- if (!(Tz >= -1440 && Tz <= 1440) && Tz != EFI_UNSPECIFIED_TIMEZONE) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-tz");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- //
- // intentionally out of bounds value will prevent changing it...
- //
- Tz = 1441;
- }
- TempLocation = ShellCommandLineGetValue(Package, L"-d");
- if (TempLocation != NULL) {
- Daylight = (UINT8)ShellStrToUintn(TempLocation);
- //
- // The argument of "time [-d dl]" is unsigned, if the first character is '-',
- // the argument is incorrect. That's because ShellStrToUintn() will skip past
- // any '-' sign and convert what's next, forgetting the sign is here.
- //
- if (TempLocation[0] == '-') {
- Daylight = 0xff; //make it invalid = will not use
- }
- if (Daylight != 0 && Daylight != 1 && Daylight != 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-d");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- //
- // invalid = will not use
- //
- Daylight = 0xFF;
- }
- if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = CheckAndSetTime(ShellCommandLineGetRawValue(Package, 1), Tz, Daylight);
- if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"time", ShellCommandLineGetRawValue(Package, 1));
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- }
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
-
-typedef struct {
- INT16 TimeZone;
- EFI_STRING_ID StringId;
-} TIME_ZONE_ITEM;
-
-STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2[] = {
- {L"-l", TypeFlag},
- {L"-f", TypeFlag},
- {NULL, TypeMax}
- };
-STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
- {L"-l", TypeFlag},
- {L"-f", TypeFlag},
- {L"-s", TypeTimeValue},
- {NULL, TypeMax}
- };
-
- STATIC CONST TIME_ZONE_ITEM TimeZoneList[] = {
- {720, STRING_TOKEN (STR_TIMEZONE_M12)},
- {660, STRING_TOKEN (STR_TIMEZONE_M11)},
- {600, STRING_TOKEN (STR_TIMEZONE_M10)},
- {540, STRING_TOKEN (STR_TIMEZONE_M9)},
- {480, STRING_TOKEN (STR_TIMEZONE_M8)},
- {420, STRING_TOKEN (STR_TIMEZONE_M7)},
- {360, STRING_TOKEN (STR_TIMEZONE_M6)},
- {300, STRING_TOKEN (STR_TIMEZONE_M5)},
- {270, STRING_TOKEN (STR_TIMEZONE_M430)},
- {240, STRING_TOKEN (STR_TIMEZONE_M4)},
- {210, STRING_TOKEN (STR_TIMEZONE_M330)},
- {180, STRING_TOKEN (STR_TIMEZONE_M3)},
- {120, STRING_TOKEN (STR_TIMEZONE_M2)},
- {60 , STRING_TOKEN (STR_TIMEZONE_M1)},
- {0 , STRING_TOKEN (STR_TIMEZONE_0)},
- {-60 , STRING_TOKEN (STR_TIMEZONE_P1)},
- {-120 , STRING_TOKEN (STR_TIMEZONE_P2)},
- {-180 , STRING_TOKEN (STR_TIMEZONE_P3)},
- {-210 , STRING_TOKEN (STR_TIMEZONE_P330)},
- {-240 , STRING_TOKEN (STR_TIMEZONE_P4)},
- {-270 , STRING_TOKEN (STR_TIMEZONE_P430)},
- {-300 , STRING_TOKEN (STR_TIMEZONE_P5)},
- {-330 , STRING_TOKEN (STR_TIMEZONE_P530)},
- {-345 , STRING_TOKEN (STR_TIMEZONE_P545)},
- {-360 , STRING_TOKEN (STR_TIMEZONE_P6)},
- {-390 , STRING_TOKEN (STR_TIMEZONE_P630)},
- {-420 , STRING_TOKEN (STR_TIMEZONE_P7)},
- {-480 , STRING_TOKEN (STR_TIMEZONE_P8)},
- {-540 , STRING_TOKEN (STR_TIMEZONE_P9)},
- {-570 , STRING_TOKEN (STR_TIMEZONE_P930)},
- {-600 , STRING_TOKEN (STR_TIMEZONE_P10)},
- {-660 , STRING_TOKEN (STR_TIMEZONE_P11)},
- {-720 , STRING_TOKEN (STR_TIMEZONE_P12)},
- {-780 , STRING_TOKEN (STR_TIMEZONE_P13)},
- {-840 , STRING_TOKEN (STR_TIMEZONE_P14)},
- {EFI_UNSPECIFIED_TIMEZONE, STRING_TOKEN (STR_TIMEZONE_LOCAL)}
-};
-
-/**
- Verify that the TimeZoneString is valid and if so set that as the current
- timezone.
-
- @param[in] TimeZoneString The pointer to a string representation of the timezone.
-
- @retval SHELL_INVALID_PARAMETER TimeZoneString was NULL.
- @retval SHELL_INVALID_PARAMETER TimeZoneString was mis-formatted.
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-CheckAndSetTimeZone (
- IN CONST CHAR16 *TimeZoneString
- )
-{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *TimeZoneCopy;
- CHAR16 *Walker;
- CHAR16 *Walker2;
- UINTN LoopVar;
-
- if (TimeZoneString == NULL) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- if (StrniCmp (TimeZoneString, L"_local", StrLen (TimeZoneString)) == NULL) {
- Status = gRT->GetTime (&TheTime, NULL);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- Status = gRT->SetTime (&TheTime);
- if (!EFI_ERROR(Status)){
- return (SHELL_SUCCESS);
- }
- return (SHELL_INVALID_PARAMETER);
- }
- if (TimeZoneString != NULL && !InternalIsTimeLikeString(TimeZoneString, L':', 1, 1, TRUE)) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- TimeZoneCopy = NULL;
- TimeZoneCopy = StrnCatGrow(&TimeZoneCopy, NULL, TimeZoneString, 0);
- if (TimeZoneCopy == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- Walker = TimeZoneCopy;
- Walker2 = StrStr(Walker, L":");
- if (Walker2 != NULL && *Walker2 == L':') {
- *Walker2 = CHAR_NULL;
- }
- if (*Walker == L'-') {
- TheTime.TimeZone = (INT16)((ShellStrToUintn (++Walker)) * 60);
- } else {
- TheTime.TimeZone = (INT16)((INT16)(ShellStrToUintn (Walker)) * -60);
- }
- if (Walker2 != NULL) {
- Walker = Walker2 + 1;
- }
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
- if (TheTime.TimeZone < 0) {
- TheTime.TimeZone = (INT16)(TheTime.TimeZone - (UINT8)ShellStrToUintn (Walker));
- } else {
- TheTime.TimeZone = (INT16)(TheTime.TimeZone + (UINT8)ShellStrToUintn (Walker));
- }
- }
-
- Status = EFI_INVALID_PARAMETER;
-
- for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
- if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
- Status = gRT->SetTime(&TheTime);
- break;
- }
- }
-
- FreePool(TimeZoneCopy);
-
- if (!EFI_ERROR(Status)){
- return (SHELL_SUCCESS);
- }
- return (SHELL_INVALID_PARAMETER);
-}
-
-
-/**
- Function for 'timezone' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTimeZone (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // non interactive
- //
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINT8 LoopVar;
- EFI_TIME TheTime;
- BOOLEAN Found;
- UINTN TzMinutes;
-
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- Status = ShellCommandLineParse (TimeZoneParamList2, &Package, &ProblemParam, TRUE);
- } else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
- Status = ShellCommandLineParseEx (TimeZoneParamList3, &Package, &ProblemParam, TRUE, TRUE);
- }
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"timezone", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"timezone");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetFlag(Package, L"-s")) {
- if ((ShellCommandLineGetFlag(Package, L"-l")) || (ShellCommandLineGetFlag(Package, L"-f"))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", L"-l or -f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
- if (ShellCommandLineGetValue(Package, L"-s") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"timezone", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Set the time zone
- //
- ShellStatus = CheckAndSetTimeZone(ShellCommandLineGetValue(Package, L"-s"));
- if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", ShellCommandLineGetValue(Package, L"-s"));
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- }
- }
- } else if (ShellCommandLineGetFlag(Package, L"-l")) {
- //
- // Print a list of all time zones
- //
- for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
- ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle);
- }
- } else {
- //
- // Get Current Time Zone Info
- //
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
- Found = FALSE;
- for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
- if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
- if (ShellCommandLineGetFlag(Package, L"-f")) {
- //
- // Print all info about current time zone
- //
- ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle);
- } else {
- //
- // Print basic info only
- //
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_TIMEZONE_SIMPLE),
- gShellLevel2HiiHandle,
- (TheTime.TimeZone > 0?L"-":L"+"),
- (ABS(TheTime.TimeZone)) / 60,
- TzMinutes);
- }
- Found = TRUE;
- break;
- }
- }
- if (!Found) {
- //
- // Print basic info only
- //
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_TIMEZONE_SIMPLE),
- gShellLevel2HiiHandle,
- (TheTime.TimeZone > 0?L"-":L"+"),
- (ABS(TheTime.TimeZone)) / 60,
- TzMinutes);
-
- if (ShellCommandLineGetFlag(Package, L"-f")) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_TIMEZONE_NI), gShellLevel2HiiHandle);
- }
- }
- } else {
- //
- // TimeZone was EFI_UNSPECIFIED_TIMEZONE (local) from GetTime()
- //
- if (ShellCommandLineGetFlag (Package, L"-f")) {
- for ( LoopVar = 0
- ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
- ; LoopVar++
- ){
- if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
- //
- // Print all info about current time zone
- //
- ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle);
- break;
- }
- }
- } else {
- //
- // Print basic info only
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIMEZONE_SIMPLE_LOCAL), gShellLevel2HiiHandle);
- }
- }
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
deleted file mode 100644
index 4ac7e67007..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/** @file
- Main file for NULL named library for level 2 shell command functions.
-
- these functions are:
- attrib,
- cd,
- cp,
- date*,
- time*,
- load,
- ls,
- map,
- mkdir,
- mv,
- parse,
- rm,
- reset,
- set,
- timezone*,
- vol
-
- * functions are non-interactive only
-
- Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-
-CONST CHAR16 mFileName[] = L"ShellCommands";
-EFI_HANDLE gShellLevel2HiiHandle = NULL;
-
-/**
- Get the filename to get help text from if not using HII.
-
- @retval The filename.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameLevel2 (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Level 2 Commands library.
-
- Install the handlers for level 2 UEFI Shell 2.0 commands.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel2CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // if shell level is less than 2 do nothing
- //
- if (PcdGet8(PcdShellSupportLevel) < 2) {
- return (EFI_SUCCESS);
- }
-
- gShellLevel2HiiHandle = HiiAddPackages (&gShellLevel2HiiGuid, gImageHandle, UefiShellLevel2CommandsLibStrings, NULL);
- if (gShellLevel2HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"attrib", ShellCommandRunAttrib , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_ATTRIB) );
- ShellCommandRegisterCommandName(L"cd", ShellCommandRunCd , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CD) );
- ShellCommandRegisterCommandName(L"cp", ShellCommandRunCp , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CP) );
- ShellCommandRegisterCommandName(L"load", ShellCommandRunLoad , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD) );
- ShellCommandRegisterCommandName(L"map", ShellCommandRunMap , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MAP) );
- ShellCommandRegisterCommandName(L"mkdir", ShellCommandRunMkDir , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MKDIR) );
- ShellCommandRegisterCommandName(L"mv", ShellCommandRunMv , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MV) );
- ShellCommandRegisterCommandName(L"parse", ShellCommandRunParse , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_PARSE) );
- ShellCommandRegisterCommandName(L"reset", ShellCommandRunReset , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RESET) );
- ShellCommandRegisterCommandName(L"set", ShellCommandRunSet , ShellCommandGetManFileNameLevel2, 2, L"",FALSE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_SET) );
- ShellCommandRegisterCommandName(L"ls", ShellCommandRunLs , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LS) );
- ShellCommandRegisterCommandName(L"rm", ShellCommandRunRm , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RM) );
- ShellCommandRegisterCommandName(L"vol", ShellCommandRunVol , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_VOL) );
-
- //
- // support for permenant (built in) aliases
- //
- ShellCommandRegisterAlias(L"rm", L"del");
- ShellCommandRegisterAlias(L"ls", L"dir");
- ShellCommandRegisterAlias(L"cp", L"copy");
- ShellCommandRegisterAlias(L"mkdir", L"md");
- ShellCommandRegisterAlias(L"cd ..", L"cd..");
- ShellCommandRegisterAlias(L"cd \\", L"cd\\");
- ShellCommandRegisterAlias(L"mv", L"ren");
- ShellCommandRegisterAlias(L"mv", L"move");
- ShellCommandRegisterAlias(L"map", L"mount");
- //
- // These are installed in level 2 or 3...
- //
- if (PcdGet8(PcdShellSupportLevel) == 2 || PcdGet8(PcdShellSupportLevel) == 3) {
- ShellCommandRegisterCommandName(L"date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE) );
- ShellCommandRegisterCommandName(L"time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME) );
- ShellCommandRegisterCommandName(L"timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));
- } else {
- DEBUG_CODE_BEGIN();
- //
- // we want to be able to test these so install them under a different name in debug mode...
- //
- ShellCommandRegisterCommandName(L"l2date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE) );
- ShellCommandRegisterCommandName(L"l2time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME) );
- ShellCommandRegisterCommandName(L"l2timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));
- DEBUG_CODE_END();
- }
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-
- @retval EFI_SUCCESS Always returned.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel2CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellLevel2HiiHandle != NULL) {
- HiiRemovePackages(gShellLevel2HiiHandle);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- returns a fully qualified directory (contains a map drive at the begining)
- path from a unknown directory path.
-
- If Path is already fully qualified this will return a duplicat otherwise this
- will use get the current directory and use that to build the fully qualified
- version.
-
- if the return value is not NULL it must be caller freed.
-
- @param[in] Path The unknown Path Value
-
- @retval NULL A memory allocation failed
- @retval NULL A fully qualified path could not be discovered.
- @retval other An allocated pointer to a fuly qualified path.
-**/
-CHAR16*
-EFIAPI
-GetFullyQualifiedPath(
- IN CONST CHAR16* Path
- )
-{
- CHAR16 *PathToReturn;
- UINTN Size;
- CONST CHAR16 *CurDir;
-
- PathToReturn = NULL;
- Size = 0;
-
- ASSERT((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
- //
- // convert a local path to an absolute path
- //
- if (StrStr(Path, L":") == NULL) {
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
- StrnCatGrow(&PathToReturn, &Size, CurDir, 0);
- if (*Path == L'\\') {
- Path++;
- }
- }
- StrnCatGrow(&PathToReturn, &Size, Path, 0);
-
- PathCleanUpDirectories(PathToReturn);
-
- if (PathToReturn == NULL) {
- return NULL;
- }
-
- while (PathToReturn[StrLen(PathToReturn)-1] == L'*') {
- PathToReturn[StrLen(PathToReturn)-1] = CHAR_NULL;
- }
-
- return (PathToReturn);
-}
-
-/**
- Function to verify all intermediate directories in the path.
-
- @param[in] Path The pointer to the path to fix.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-VerifyIntermediateDirectories (
- IN CONST CHAR16 *Path
- )
-{
- EFI_STATUS Status;
- CHAR16 *PathCopy;
- CHAR16 *TempSpot;
- SHELL_FILE_HANDLE FileHandle;
-
- ASSERT(Path != NULL);
-
- Status = EFI_SUCCESS;
- PathCopy = NULL;
- PathCopy = StrnCatGrow(&PathCopy, NULL, Path, 0);
- FileHandle = NULL;
-
- if (PathCopy == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- for (TempSpot = &PathCopy[StrLen(PathCopy)-1] ; *TempSpot != CHAR_NULL && *TempSpot != L'\\' ; TempSpot = &PathCopy[StrLen(PathCopy)-1]){
- *TempSpot = CHAR_NULL;
- }
- if (*TempSpot == L'\\') {
- *TempSpot = CHAR_NULL;
- }
-
- if (PathCopy != NULL && *PathCopy != CHAR_NULL) {
- Status = VerifyIntermediateDirectories(PathCopy);
-
- if (PathCopy[StrLen(PathCopy)-1] != L':') {
- if (!EFI_ERROR(Status)) {
- Status = ShellOpenFileByName(PathCopy, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (FileHandle != NULL) {
- ShellCloseFile(&FileHandle);
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(PathCopy);
-
- return (Status);
-}
-
-/**
- Be lazy and borrow from baselib.
-
- @param[in] Char The character to convert to upper case.
-
- @return Char as an upper case character.
-**/
-CHAR16
-EFIAPI
-InternalCharToUpper (
- IN CONST CHAR16 Char
- );
-
-/**
- String comparison without regard to case for a limited number of characters.
-
- @param[in] Source The first item to compare.
- @param[in] Target The second item to compare.
- @param[in] Count How many characters to compare.
-
- @retval NULL Source and Target are identical strings without regard to case.
- @return The location in Source where there is a difference.
-**/
-CONST CHAR16*
-EFIAPI
-StrniCmp(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Target,
- IN CONST UINTN Count
- )
-{
- UINTN LoopCount;
- CHAR16 Char1;
- CHAR16 Char2;
-
- ASSERT(Source != NULL);
- ASSERT(Target != NULL);
-
- for (LoopCount = 0 ; LoopCount < Count ; LoopCount++) {
- Char1 = InternalCharToUpper(Source[LoopCount]);
- Char2 = InternalCharToUpper(Target[LoopCount]);
- if (Char1 != Char2) {
- return (&Source[LoopCount]);
- }
- }
- return (NULL);
-}
-
-
-/**
- Cleans off all the quotes in the string.
-
- @param[in] OriginalString pointer to the string to be cleaned.
- @param[out] CleanString The new string with all quotes removed.
- Memory allocated in the function and free
- by caller.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel2StripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
- )
-{
- CHAR16 *Walker;
-
- if (OriginalString == NULL || CleanString == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);
- if (*CleanString == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
- if (*Walker == L'\"') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
deleted file mode 100644
index 634515e493..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
+++ /dev/null
@@ -1,374 +0,0 @@
-/** @file
- Main file for NULL named library for level 2 shell command functions.
-
- these functions are:
- attrib, cd, cp, date*, time*, rm, reset,
- load, ls, map, mkdir, mv, parse, set, timezone*
-
-
- * functions are non-interactive only
-
-
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
-#define _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/SortLib.h>
-#include <Library/FileHandleLib.h>
-
-extern CONST CHAR16 mFileName[];
-extern EFI_HANDLE gShellLevel2HiiHandle;
-
-/**
- Function for 'attrib' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAttrib (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'date' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDate (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'time' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTime (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'load' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLoad (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'ls' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunLs (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'map' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMap (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'reset' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunReset (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'timezone' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTimeZone (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'set' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunSet (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'mkdir' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMkDir (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'cd' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCd (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'cp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'parse' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunParse (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'rm' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunRm (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'mv' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunMv (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- returns a fully qualified directory (contains a map drive at the begining)
- path from a unknown directory path.
-
- If Path is already fully qualified this will return a duplicat otherwise this
- will use get the current directory and use that to build the fully qualified
- version.
-
- if the return value is not NULL it must be caller freed.
-
- @param[in] Path The unknown Path Value
-
- @retval NULL A memory allocation failed
- @retval NULL a fully qualified path could not be discovered.
- @retval other pointer to a fuly qualified path.
-**/
-CHAR16*
-EFIAPI
-GetFullyQualifiedPath(
- IN CONST CHAR16* Path
- );
-
-/**
- Function to verify all intermediate directories in the path.
-
- @param[in] Path The pointer to the path to fix.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-VerifyIntermediateDirectories (
- IN CONST CHAR16 *Path
- );
-
-/**
- CaseInsensitive length limited string comparison.
-
- @param[in] Source Pointer to first string.
- @param[in] Target Pointer to second string.
- @param[in] Count Number of characters to compare.
-
- @retval 0 The strings are the same.
- @return non-zero if the strings are different.
-**/
-CONST CHAR16*
-EFIAPI
-StrniCmp(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Target,
- IN CONST UINTN Count
- );
-
-/**
- Cleans off all the quotes in the string.
-
- @param[in] OriginalString pointer to the string to be cleaned.
- @param[out] CleanString The new string with all quotes removed.
- Memory allocated in the function and free
- by caller.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel2StripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
- );
-
-/**
- Function for 'Vol' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunVol (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function to Copy one file to another location
-
- If the destination exists the user will be prompted and the result put into *resp
-
- @param[in] Source pointer to source file name
- @param[in] Dest pointer to destination file name
- @param[out] Resp pointer to response from question. Pass back on looped calling
- @param[in] SilentMode whether to run in quiet mode or not
- @param[in] CmdName Source command name requesting single file copy
-
- @retval SHELL_SUCCESS The source file was copied to the destination
-**/
-SHELL_STATUS
-EFIAPI
-CopySingleFile(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Dest,
- OUT VOID **Resp,
- IN BOOLEAN SilentMode,
- IN CONST CHAR16 *CmdName
- );
-
-/**
- Delete a node and all nodes under it (including sub directories).
-
- @param[in] Node The node to start deleting with.
- @param[in] Quiet TRUE to print no messages.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_ACCESS_DENIED A file was read only.
- @retval SHELL_ABORTED The abort message was received.
- @retval SHELL_DEVICE_ERROR A device error occured reading this Node.
-**/
-SHELL_STATUS
-EFIAPI
-CascadeDelete(
- IN EFI_SHELL_FILE_INFO *Node,
- IN CONST BOOLEAN Quiet
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
deleted file mode 100644
index 76540fb3a3..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
+++ /dev/null
@@ -1,84 +0,0 @@
-## @file
-# Provides shell level 2 functions
-#
-# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellLevel2CommandsLib
- FILE_GUID = CBF3931C-A2DF-40e5-B77E-CCA9555E9755
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellLevel2CommandsLibConstructor
- DESTRUCTOR = ShellLevel2CommandsLibDestructor
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- UefiShellLevel2CommandsLib.c
- UefiShellLevel2CommandsLib.h
- UefiShellLevel2CommandsLib.uni
- TimeDate.c
- Load.c
- Ls.c
- Map.c
- Reset.c
- Set.c
- MkDir.c
- Cd.c
- Cp.c
- Parse.c
- Rm.c
- Mv.c
- Attrib.c
- Vol.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- PcdLib
- HiiLib
- HandleParsingLib
- DevicePathLib
-
-[Protocols]
- gEfiUnicodeCollation2ProtocolGuid ## CONSUMES
- gEfiShellProtocolGuid ## CONSUMES
- gEfiShellParametersProtocolGuid ## CONSUMES
- gEfiDevicePathProtocolGuid ## CONSUMES
- gEfiLoadedImageProtocolGuid ## CONSUMES
- gEfiSimpleFileSystemProtocolGuid ## CONSUMES
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize ## CONSUMES
-
-[Guids]
- gEfiFileSystemInfoGuid ## CONSUMES ## GUID
- gEfiFileInfoGuid ## UNDEFINED
- gShellLevel2HiiGuid ## SOMETIMES_CONSUMES ## HII
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
deleted file mode 100644
index 29563d2e21..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
deleted file mode 100644
index a6f0296d76..0000000000
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/** @file
- Main file for vol shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel2CommandsLib.h"
-#include <Guid/FileSystemInfo.h>
-#include <Guid/FileSystemVolumeLabelInfo.h>
-
-/**
- Print the info or change the volume info.
-
- @param[in] Path String with starting path.
- @param[in] Delete TRUE to delete the volume label. FALSE otherwise.
- @param[in] Name New name to set to the volume label.
-
- @retval SHELL_SUCCESS The operation was sucessful.
-**/
-SHELL_STATUS
-EFIAPI
-HandleVol(
- IN CONST CHAR16 *Path,
- IN CONST BOOLEAN Delete,
- IN CONST CHAR16 *Name OPTIONAL
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- EFI_FILE_SYSTEM_INFO *SysInfo;
- UINTN SysInfoSize;
- SHELL_FILE_HANDLE ShellFileHandle;
- EFI_FILE_PROTOCOL *EfiFpHandle;
- UINTN Size1;
- UINTN Size2;
-
- ShellStatus = SHELL_SUCCESS;
-
- if (
- Name != NULL && (
- StrStr(Name, L"%") != NULL ||
- StrStr(Name, L"^") != NULL ||
- StrStr(Name, L"*") != NULL ||
- StrStr(Name, L"+") != NULL ||
- StrStr(Name, L"=") != NULL ||
- StrStr(Name, L"[") != NULL ||
- StrStr(Name, L"]") != NULL ||
- StrStr(Name, L"|") != NULL ||
- StrStr(Name, L":") != NULL ||
- StrStr(Name, L";") != NULL ||
- StrStr(Name, L"\"") != NULL ||
- StrStr(Name, L"<") != NULL ||
- StrStr(Name, L">") != NULL ||
- StrStr(Name, L"?") != NULL ||
- StrStr(Name, L"/") != NULL ||
- StrStr(Name, L" ") != NULL )
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"vol", Name);
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = gEfiShellProtocol->OpenFileByName(
- Path,
- &ShellFileHandle,
- Name != NULL?EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE:EFI_FILE_MODE_READ);
-
- if (EFI_ERROR(Status) || ShellFileHandle == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"vol", Path);
- return (SHELL_ACCESS_DENIED);
- }
-
- //
- // Get the Volume Info from ShellFileHandle
- //
- SysInfo = NULL;
- SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(ShellFileHandle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
- }
-
- ASSERT(SysInfo != NULL);
-
- if (Delete) {
- *((CHAR16 *) SysInfo->VolumeLabel) = CHAR_NULL;
- SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(SysInfo->VolumeLabel);
- Status = EfiFpHandle->SetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- (UINTN)SysInfo->Size,
- SysInfo);
- } else if (Name != NULL) {
- Size1 = StrSize(Name);
- Size2 = StrSize(SysInfo->VolumeLabel);
- if (Size1 > Size2) {
- SysInfo = ReallocatePool((UINTN)SysInfo->Size, (UINTN)SysInfo->Size + Size1 - Size2, SysInfo);
- if (SysInfo == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"vol");
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- }
- }
- if (SysInfo != NULL) {
- StrCpyS ( (CHAR16 *) SysInfo->VolumeLabel,
- (Size1>Size2? Size1/sizeof(CHAR16) : Size2/sizeof(CHAR16)),
- Name
- );
- SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
- Status = EfiFpHandle->SetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- (UINTN)SysInfo->Size,
- SysInfo);
- }
- }
-
- FreePool(SysInfo);
-
- if (Delete || Name != NULL) {
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"vol", Path);
- ShellStatus = SHELL_ACCESS_DENIED;
- }
- }
-
- SysInfoSize = 0;
- SysInfo = NULL;
-
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
- }
-
- gEfiShellProtocol->CloseFile(ShellFileHandle);
-
- ASSERT(SysInfo != NULL);
-
- if (SysInfo != NULL) {
- //
- // print VolumeInfo table
- //
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_VOL_VOLINFO),
- gShellLevel2HiiHandle,
- SysInfo->VolumeLabel,
- SysInfo->ReadOnly?L"r":L"rw",
- SysInfo->VolumeSize,
- SysInfo->FreeSpace,
- SysInfo->BlockSize
- );
- SHELL_FREE_NON_NULL(SysInfo);
- }
-
- return (ShellStatus);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-d", TypeFlag},
- {L"-n", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'Vol' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunVol (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *PathName;
- CONST CHAR16 *CurDir;
- BOOLEAN DeleteMode;
- CHAR16 *FullPath;
- CHAR16 *TempSpot;
- UINTN Length;
- CONST CHAR16 *NewName;
-
- Length = 0;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- PathName = NULL;
- CurDir = NULL;
- FullPath = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // Fix local copies of the protocol pointers
- //
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"vol", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
-
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"vol");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- PathName = ShellCommandLineGetRawValue(Package, 1);
- if (PathName == NULL) {
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
- if (CurDir == NULL) {
- ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"vol");
- } else {
- PathName = CurDir;
- }
- }
- if (PathName != NULL) {
- TempSpot = StrStr(PathName, L":");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- TempSpot = StrStr(PathName, L"\\");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- StrnCatGrow(&FullPath, &Length, PathName, 0);
- StrnCatGrow(&FullPath, &Length, L":\\", 0);
- DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
- NewName = ShellCommandLineGetValue(Package, L"-n");
- if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel2HiiHandle, L"vol", L"-d", L"-n");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-n") && NewName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"vol", L"-n");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (NewName != NULL && StrLen(NewName) > 11) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"vol", NewName, L"-n");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = HandleVol(
- FullPath,
- DeleteMode,
- NewName
- );
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(FullPath);
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c
deleted file mode 100644
index 1161746cc7..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Alias.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/** @file
- Main file for Alias shell level 3 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-/**
- Print out each alias registered with the Shell.
-
- @retval STATUS_SUCCESS the printout was sucessful
- @return any return code from GetNextVariableName except EFI_NOT_FOUND
-**/
-SHELL_STATUS
-EFIAPI
-PrintAllShellAlias(
- VOID
- )
-{
- CONST CHAR16 *ConstAllAliasList;
- CHAR16 *Alias;
- CONST CHAR16 *Command;
- CHAR16 *Walker;
- BOOLEAN Volatile;
-
- Volatile = FALSE;
-
- ConstAllAliasList = gEfiShellProtocol->GetAlias(NULL, NULL);
- if (ConstAllAliasList == NULL) {
- return (SHELL_SUCCESS);
- }
- Alias = AllocateZeroPool(StrSize(ConstAllAliasList));
- if (Alias == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- Walker = (CHAR16*)ConstAllAliasList;
-
- do {
- CopyMem(Alias, Walker, StrSize(Walker));
- Walker = StrStr(Alias, L";");
- if (Walker != NULL) {
- Walker[0] = CHAR_NULL;
- Walker = Walker + 1;
- }
- Command = gEfiShellProtocol->GetAlias(Alias, &Volatile);
- if (ShellCommandIsOnAliasList(Alias)) {
- Volatile = FALSE;
- }
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ALIAS_OUTPUT), gShellLevel3HiiHandle, !Volatile?L' ':L'*', Alias, Command);
- } while (Walker != NULL && Walker[0] != CHAR_NULL);
-
- FreePool(Alias);
-
- return (SHELL_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-v", TypeFlag},
- {L"-d", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'alias' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAlias (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CONST CHAR16 *Param2;
- CHAR16 *CleanParam2;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- CleanParam2 = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"alias", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
-
- if (Param2 != NULL) {
- CleanParam2 = AllocateCopyPool (StrSize(Param2), Param2);
- if (CleanParam2 == NULL) {
- return SHELL_OUT_OF_RESOURCES;
- }
-
- if (CleanParam2[0] == L'\"' && CleanParam2[StrLen(CleanParam2)-1] == L'\"') {
- CleanParam2[StrLen(CleanParam2)-1] = L'\0';
- CopyMem (CleanParam2, CleanParam2 + 1, StrSize(CleanParam2) - sizeof(CleanParam2[0]));
- }
- }
-
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- if (ShellCommandLineGetCount(Package) == 1) {
- //
- // print out alias'
- //
- Status = PrintAllShellAlias();
- } else if (ShellCommandLineGetFlag(Package, L"-d")) {
- //
- // delete an alias
- //
- Status = gEfiShellProtocol->SetAlias(Param1, NULL, TRUE, FALSE);
- } else if (ShellCommandLineGetCount(Package) == 3) {
- //
- // must be adding an alias
- //
- Status = gEfiShellProtocol->SetAlias(CleanParam2, Param1, FALSE, ShellCommandLineGetFlag(Package, L"-v"));
- if (EFI_ERROR(Status)) {
- if (Status == EFI_ACCESS_DENIED) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel3HiiHandle, L"alias");
- ShellStatus = SHELL_ACCESS_DENIED;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel3HiiHandle, L"alias", Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- }
- } else if (ShellCommandLineGetCount(Package) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"alias");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"alias");
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- SHELL_FREE_NON_NULL (CleanParam2);
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
deleted file mode 100644
index 61b9ef854e..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/** @file
- Main file for attrib shell level 2 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-/**
- Function for 'cls' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCls (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- UINTN Background;
- UINTN ForeColor;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
-
- //
- // Initialize variables
- //
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
- Background = 0;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"cls", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else {
- //
- // If there are 0 value parameters, clear sceen
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 == NULL) {
- //
- // clear screen
- //
- gST->ConOut->ClearScreen (gST->ConOut);
- } else if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- switch (ShellStrToUintn(Param1)) {
- case 0:
- Background = EFI_BACKGROUND_BLACK;
- break;
- case 1:
- Background = EFI_BACKGROUND_BLUE;
- break;
- case 2:
- Background = EFI_BACKGROUND_GREEN;
- break;
- case 3:
- Background = EFI_BACKGROUND_CYAN;
- break;
- case 4:
- Background = EFI_BACKGROUND_RED;
- break;
- case 5:
- Background = EFI_BACKGROUND_MAGENTA;
- break;
- case 6:
- Background = EFI_BACKGROUND_BROWN;
- break;
- case 7:
- Background = EFI_BACKGROUND_LIGHTGRAY;
- break;
- }
- ForeColor = (~ShellStrToUintn(Param1)) & 0xF;
- Status = gST->ConOut->SetAttribute (gST->ConOut, (ForeColor | Background) & 0x7F );
- ASSERT_EFI_ERROR(Status);
- Status = gST->ConOut->ClearScreen (gST->ConOut);
- ASSERT_EFI_ERROR(Status);
- }
- }
- }
- }
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
-
- //
- // return the status
- //
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
deleted file mode 100644
index a638de8ce2..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/** @file
- Main file for Echo shell level 3 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-on", TypeFlag},
- {L"-off", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'echo' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEcho (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- CHAR16 *ProblemParam;
- UINTN Size;
- CHAR16 *PrintString;
-
- Size = 0;
- ProblemParam = NULL;
- PrintString = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"echo", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- if (ShellCommandLineGetFlag(Package, L"-on")) {
- //
- // Turn it on
- //
- ShellCommandSetEchoState(TRUE);
- } else if (ShellCommandLineGetFlag(Package, L"-off")) {
- //
- // turn it off
- //
- ShellCommandSetEchoState(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // output its current state
- //
- if (ShellCommandGetEchoState()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_ON), gShellLevel3HiiHandle);
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_OFF), gShellLevel3HiiHandle);
- }
- } else {
- //
- // print the line
- //
- for ( ParamCount = 1
- ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL
- ; ParamCount++
- ) {
- StrnCatGrow(&PrintString, &Size, ShellCommandLineGetRawValue(Package, ParamCount), 0);
- if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {
- StrnCatGrow(&PrintString, &Size, L" ", 0);
- }
- }
- ShellPrintEx(-1, -1, L"%s\r\n", PrintString);
- SHELL_FREE_NON_NULL(PrintString);
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
deleted file mode 100644
index 21c5bc81eb..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file
- Main file for GetMtc shell level 3 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-/**
- Function for 'getmtc' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunGetMtc (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINT64 Mtc;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"getmtc", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"getmtc");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Get the monotonic counter count
- //
- Status = gBS->GetNextMonotonicCount(&Mtc);
- if (Status == EFI_DEVICE_ERROR) {
- ShellStatus = SHELL_DEVICE_ERROR;
- } else if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_DEVICE_ERROR;
- }
-
- //
- // print it...
- //
- if (ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GET_MTC_OUTPUT), gShellLevel3HiiHandle, Mtc);
- }
- }
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
deleted file mode 100644
index c8d0e7887c..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/** @file
- Main file for Help shell level 3 function.
-
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
- Copyright (c) 2014, ARM Limited. All rights reserved. <BR>
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-#include <Library/HandleParsingLib.h>
-
-#include <Protocol/EfiShellDynamicCommand.h>
-
-/**
- function to insert string items into a list in the correct alphabetical place
-
- the resultant list is a double NULL terminated list of NULL terminated strings.
-
- upon successful return the memory must be caller freed (unless passed back in
- via a loop where it will get reallocated).
-
- @param[in,out] DestList double pointer to the list. may be NULL.
- @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
- @param[in] Item the item to insert.
-
- @retval EFI_SUCCESS the operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-LexicalInsertIntoList(
- IN OUT CHAR16 **DestList,
- IN OUT UINTN *DestSize,
- IN CONST CHAR16 *Item
- )
-{
- CHAR16 *NewList;
- INTN LexicalMatchValue;
- CHAR16 *LexicalSpot;
- UINTN SizeOfAddedNameInBytes;
-
- //
- // If there are none, then just return with success
- //
- if (Item == NULL || *Item == CHAR_NULL || StrLen(Item)==0) {
- return (EFI_SUCCESS);
- }
-
- NewList = *DestList;
-
- SizeOfAddedNameInBytes = StrSize(Item);
- NewList = ReallocatePool(*DestSize, (*DestSize) + SizeOfAddedNameInBytes, NewList);
- (*DestSize) = (*DestSize) + SizeOfAddedNameInBytes;
-
- //
- // Find the correct spot in the list
- //
- for (LexicalSpot = NewList
- ; LexicalSpot != NULL && LexicalSpot < NewList + (*DestSize)
- ; LexicalSpot += StrLen(LexicalSpot) + 1
- ) {
- //
- // Get Lexical Comparison Value between PrevCommand and Command list entry
- //
- LexicalMatchValue = gUnicodeCollation->StriColl (
- gUnicodeCollation,
- (CHAR16 *)LexicalSpot,
- (CHAR16 *)Item
- );
- //
- // The new item goes before this one.
- //
- if (LexicalMatchValue > 0 || StrLen(LexicalSpot) == 0) {
- if (StrLen(LexicalSpot) != 0) {
- //
- // Move this and all other items out of the way
- //
- CopyMem(
- LexicalSpot + (SizeOfAddedNameInBytes/sizeof(CHAR16)),
- LexicalSpot,
- (*DestSize) - SizeOfAddedNameInBytes - ((LexicalSpot - NewList) * sizeof(CHAR16))
- );
- }
-
- //
- // Stick this one in place
- //
- StrCpyS(LexicalSpot, SizeOfAddedNameInBytes/sizeof(CHAR16), Item);
- break;
- }
- }
-
- *DestList = NewList;
- return (EFI_SUCCESS);
-}
-
-/**
- function to add each command name from the linked list to the string list.
-
- the resultant list is a double NULL terminated list of NULL terminated strings.
-
- @param[in,out] DestList double pointer to the list. may be NULL.
- @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
- @param[in] SourceList the double linked list of commands.
-
- @retval EFI_SUCCESS the operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-CopyListOfCommandNames(
- IN OUT CHAR16 **DestList,
- IN OUT UINTN *DestSize,
- IN CONST COMMAND_LIST *SourceList
- )
-{
- CONST COMMAND_LIST *Node;
-
- for ( Node = (COMMAND_LIST*)GetFirstNode(&SourceList->Link)
- ; SourceList != NULL && !IsListEmpty(&SourceList->Link) && !IsNull(&SourceList->Link, &Node->Link)
- ; Node = (COMMAND_LIST*)GetNextNode(&SourceList->Link, &Node->Link)
- ) {
- LexicalInsertIntoList(DestList, DestSize, Node->CommandString);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- function to add each dynamic command name to the string list.
-
- the resultant list is a double NULL terminated list of NULL terminated strings.
-
- @param[in,out] DestList double pointer to the list. may be NULL.
- @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.
-
- @retval EFI_SUCCESS the operation was successful.
- @return an error from HandleProtocol
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-CopyListOfCommandNamesWithDynamic(
- IN OUT CHAR16** DestList,
- IN OUT UINTN *DestSize
- )
-{
- EFI_HANDLE *CommandHandleList;
- CONST EFI_HANDLE *NextCommand;
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
- EFI_STATUS Status;
-
- CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid);
-
- //
- // If there are none, then just return with success
- //
- if (CommandHandleList == NULL) {
- return (EFI_SUCCESS);
- }
-
- Status = EFI_SUCCESS;
-
- //
- // Append those to the list.
- //
- for (NextCommand = CommandHandleList ; *NextCommand != NULL && !EFI_ERROR(Status) ; NextCommand++) {
- Status = gBS->HandleProtocol(
- *NextCommand,
- &gEfiShellDynamicCommandProtocolGuid,
- (VOID **)&DynamicCommand
- );
-
- if (EFI_ERROR(Status)) {
- continue;
- }
-
- Status = LexicalInsertIntoList(DestList, DestSize, DynamicCommand->CommandName);
- }
-
- SHELL_FREE_NON_NULL(CommandHandleList);
- return (Status);
-}
-
-
-/**
- Attempt to print help from a dynamically added command.
-
- @param[in] CommandToGetHelpOn The unicode name of the command that help is
- requested on.
- @param[in] SectionToGetHelpOn Pointer to the section specifier(s).
- @param[in] PrintCommandText Print the command followed by the help content
- or just help.
-
- @retval EFI_SUCCESS The help was displayed
- @retval EFI_NOT_FOUND The command name could not be found
- @retval EFI_DEVICE_ERROR The help data format was incorrect.
-**/
-EFI_STATUS
-EFIAPI
-PrintDynamicCommandHelp(
- IN CONST CHAR16 *CommandToGetHelpOn,
- IN CONST CHAR16 *SectionToGetHelpOn,
- IN BOOLEAN PrintCommandText
- )
-{
- EFI_STATUS Status;
- BOOLEAN Found;
- EFI_HANDLE *CommandHandleList;
- EFI_HANDLE *NextCommand;
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;
-
- Status = EFI_NOT_FOUND;
- Found = FALSE;
- CommandHandleList = NULL;
-
- CommandHandleList = GetHandleListByProtocol(&gEfiShellDynamicCommandProtocolGuid);
-
- if (CommandHandleList == NULL) {
- //
- // not found or out of resources
- //
- return Status;
- }
-
- for (NextCommand = CommandHandleList; *NextCommand != NULL; NextCommand++) {
- Status = gBS->HandleProtocol(
- *NextCommand,
- &gEfiShellDynamicCommandProtocolGuid,
- (VOID **)&DynamicCommand
- );
-
- if (EFI_ERROR(Status)) {
- continue;
- }
-
- //
- // Check execution break flag when printing multiple command help information.
- //
- if (ShellGetExecutionBreakFlag ()) {
- break;
- }
-
- if ((gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16*)CommandToGetHelpOn)) ||
- (gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
- // Print as Shell Help if in ManPage format.
- Status = ShellPrintHelp (DynamicCommand->CommandName, SectionToGetHelpOn,
- PrintCommandText);
- if (Status == EFI_DEVICE_ERROR) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV),
- gShellLevel3HiiHandle, DynamicCommand->CommandName);
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF),
- gShellLevel3HiiHandle, DynamicCommand->CommandName);
- } else {
- Found = TRUE;
- }
- }
- }
-
- SHELL_FREE_NON_NULL(CommandHandleList);
-
- return (Found ? EFI_SUCCESS : Status);
-
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-usage", TypeFlag},
- {L"-section", TypeMaxValue},
- {L"-verbose", TypeFlag},
- {L"-v", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'help' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunHelp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR16 *SortedCommandList;
- CONST CHAR16 *CurrentCommand;
- CHAR16 *CommandToGetHelpOn;
- CHAR16 *SectionToGetHelpOn;
- CHAR16 *HiiString;
- BOOLEAN Found;
- BOOLEAN PrintCommandText;
- UINTN SortedCommandListSize;
-
- PrintCommandText = TRUE;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- CommandToGetHelpOn = NULL;
- SectionToGetHelpOn = NULL;
- Found = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"help", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // Check for conflicting parameters.
- //
- if (ShellCommandLineGetFlag(Package, L"-usage")
- &&ShellCommandLineGetFlag(Package, L"-section")
- &&(ShellCommandLineGetFlag(Package, L"-verbose") || ShellCommandLineGetFlag(Package, L"-v"))
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel3HiiHandle, L"help");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"help");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // Get the command name we are getting help on
- //
- ASSERT(CommandToGetHelpOn == NULL);
- StrnCatGrow(&CommandToGetHelpOn, NULL, ShellCommandLineGetRawValue(Package, 1), 0);
- if (CommandToGetHelpOn == NULL && ShellCommandLineGetFlag(Package, L"-?")) {
- //
- // If we dont have a command and we got a simple -?
- // we are looking for help on help command.
- //
- StrnCatGrow(&CommandToGetHelpOn, NULL, L"help", 0);
- }
-
- if (CommandToGetHelpOn == NULL) {
- StrnCatGrow(&CommandToGetHelpOn, NULL, L"*", 0);
- ASSERT(SectionToGetHelpOn == NULL);
- StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME", 0);
- } else {
- PrintCommandText = FALSE;
- ASSERT(SectionToGetHelpOn == NULL);
- //
- // Get the section name for the given command name
- //
- if (ShellCommandLineGetFlag(Package, L"-section")) {
- StrnCatGrow(&SectionToGetHelpOn, NULL, ShellCommandLineGetValue(Package, L"-section"), 0);
- } else if (ShellCommandLineGetFlag(Package, L"-usage")) {
- StrnCatGrow(&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS", 0);
- } else if (ShellCommandLineGetFlag(Package, L"-verbose") || ShellCommandLineGetFlag(Package, L"-v")) {
- } else {
- //
- // The output of help <command> will display NAME, SYNOPSIS, OPTIONS, DESCRIPTION, and EXAMPLES sections.
- //
- StrnCatGrow (&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS,OPTIONS,DESCRIPTION,EXAMPLES", 0);
- }
- }
-
- if (gUnicodeCollation->StriColl(gUnicodeCollation, CommandToGetHelpOn, L"special") == 0) {
- //
- // we need info on the special characters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_SC_HEADER), gShellLevel3HiiHandle);
- HiiString = HiiGetString(gShellLevel3HiiHandle, STRING_TOKEN(STR_HELP_SC_DATA), NULL);
- ShellPrintEx(-1, -1, L"%s", HiiString);
- FreePool(HiiString);
- Found = TRUE;
- } else {
- SortedCommandList = NULL;
- SortedCommandListSize = 0;
- CopyListOfCommandNames(&SortedCommandList, &SortedCommandListSize, ShellCommandGetCommandList(TRUE));
- CopyListOfCommandNamesWithDynamic(&SortedCommandList, &SortedCommandListSize);
-
- for (CurrentCommand = SortedCommandList
- ; CurrentCommand != NULL && *CurrentCommand != CHAR_NULL && CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16)
- ; CurrentCommand += StrLen(CurrentCommand) + 1
- ) {
- //
- // Checking execution break flag when print multiple command help information.
- //
- if (ShellGetExecutionBreakFlag ()) {
- break;
- }
-
- if ((gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)CurrentCommand, CommandToGetHelpOn)) ||
- (gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)CurrentCommand, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
- //
- // We have a command to look for help on.
- //
- Status = ShellPrintHelp(CurrentCommand, SectionToGetHelpOn, PrintCommandText);
- if (EFI_ERROR(Status)) {
- //
- // now try to match against the dynamic command list and print help
- //
- Status = PrintDynamicCommandHelp (CurrentCommand, SectionToGetHelpOn, PrintCommandText);
- }
- if (Status == EFI_DEVICE_ERROR) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CurrentCommand);
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CurrentCommand);
- } else {
- Found = TRUE;
- }
- }
- }
-
- //
- // Search the .man file for Shell applications (Shell external commands).
- //
- if (!Found) {
- Status = ShellPrintHelp(CommandToGetHelpOn, SectionToGetHelpOn, FALSE);
- if (Status == EFI_DEVICE_ERROR) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CommandToGetHelpOn);
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn);
- } else {
- Found = TRUE;
- }
- }
- }
-
- if (!Found) {
- ShellStatus = SHELL_NOT_FOUND;
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
- }
-
- if (CommandToGetHelpOn != NULL && StrCmp(CommandToGetHelpOn, L"*") == 0){
- //
- // If '*' then the command entered was 'Help' without qualifiers, This footer
- // provides additional info on help switches
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_FOOTER), gShellLevel3HiiHandle);
- }
- if (CommandToGetHelpOn != NULL) {
- FreePool(CommandToGetHelpOn);
- }
- if (SectionToGetHelpOn != NULL) {
- FreePool(SectionToGetHelpOn);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c
deleted file mode 100644
index ab597060e2..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
- Main file for Pause shell level 3 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-q", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'pause' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPause (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- SHELL_PROMPT_RESPONSE *Resp;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- Resp = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- if (!gEfiShellProtocol->BatchIsActive()) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel3HiiHandle, L"pause");
- return (SHELL_UNSUPPORTED);
- }
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"pause", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"pause");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (!ShellCommandLineGetFlag(Package, L"-q")) {
- Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp);
- } else {
- Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp);
- }
-
- if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {
- ShellCommandRegisterExit(TRUE, 0);
- ShellStatus = SHELL_ABORTED;
- }
-
- if (Resp != NULL) {
- FreePool(Resp);
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
deleted file mode 100644
index 88c5d750e0..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/** @file
- Main file for Touch shell level 3 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-/**
- Do the touch operation on a single handle.
-
- @param[in] Handle The handle to update the date/time on.
-
- @retval EFI_ACCESS_DENIED The file referenced by Handle is read only.
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-TouchFileByHandle (
- IN EFI_HANDLE Handle
- )
-{
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
-
- FileInfo = gEfiShellProtocol->GetFileInfo(Handle);
- if ((FileInfo->Attribute & EFI_FILE_READ_ONLY) != 0){
- return (EFI_ACCESS_DENIED);
- }
- Status = gRT->GetTime(&FileInfo->ModificationTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"gRT->GetTime", Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, sizeof(EFI_TIME));
-
- Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);
-
- FreePool(FileInfo);
-
- return (Status);
-}
-
-/**
- Touch a given file and potantially recurse down if it was a directory.
-
- @param[in] Name The name of this file.
- @param[in] FS The name of the file system this file is on.
- @param[in] Handle The handle of this file already opened.
- @param[in] Rec TRUE to recurse if possible.
-
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-DoTouchByHandle (
- IN CONST CHAR16 *Name,
- IN CHAR16 *FS,
- IN SHELL_FILE_HANDLE Handle,
- IN BOOLEAN Rec
- )
-{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *Walker;
- CHAR16 *TempSpot;
-
- Status = EFI_SUCCESS;
- FileList = NULL;
- Walker = NULL;
-
- if (FS == NULL) {
- FS = StrnCatGrow(&FS, NULL, Name, 0);
- if (FS != NULL) {
- TempSpot = StrStr(FS, L"\\");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
- }
- }
- }
- if (FS == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // do it
- //
- Status = TouchFileByHandle(Handle);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Name);
- return (Status);
- }
-
- //
- // if it's a directory recurse...
- //
- if (FileHandleIsDirectory(Handle) == EFI_SUCCESS && Rec) {
- //
- // get each file under this directory
- //
- if (EFI_ERROR(gEfiShellProtocol->FindFilesInDir(Handle, &FileList))) {
- Status = EFI_INVALID_PARAMETER;
- }
-
- //
- // recurse on each
- //
- for (Walker = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; FileList != NULL && !IsNull(&FileList->Link, &Walker->Link) && !EFI_ERROR(Status)
- ; Walker = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Walker->Link)
- ){
- if ( (StrCmp(Walker->FileName, L".") != 0)
- && (StrCmp(Walker->FileName, L"..") != 0)
- ){
- //
- // Open the file since we need that handle.
- //
- Status = gEfiShellProtocol->OpenFileByName (Walker->FullName, &Walker->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Walker->FullName);
- Status = EFI_ACCESS_DENIED;
- } else {
- Status = DoTouchByHandle(Walker->FullName, FS, Walker->Handle, TRUE);
- gEfiShellProtocol->CloseFile(Walker->Handle);
- Walker->Handle = NULL;
- }
- }
- }
-
- //
- // free stuff
- //
- if (FileList != NULL && EFI_ERROR(gEfiShellProtocol->FreeFileList(&FileList))) {
- Status = EFI_INVALID_PARAMETER;
- }
- }
-
- return (Status);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'touch' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTouch (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Param;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *Node;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"touch", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // we insufficient parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"touch");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // get a list with each file specified by parameters
- // if parameter is a directory then add all the files below it to the list
- //
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ; Param != NULL
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param);
- ShellStatus = SHELL_NOT_FOUND;
- break;
- }
- //
- // make sure we completed the param parsing sucessfully...
- // Also make sure that any previous action was sucessful
- //
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // check that we have at least 1 file
- //
- if (FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"touch", Param);
- continue;
- } else {
- //
- // loop through the list and make sure we are not aborting...
- //
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
- ){
- //
- // make sure the file opened ok
- //
- if (EFI_ERROR(Node->Status)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);
- ShellStatus = SHELL_NOT_FOUND;
- continue;
- }
-
- Status = DoTouchByHandle(Node->FullName, NULL, Node->Handle, ShellCommandLineGetFlag(Package, L"-r"));
- if (EFI_ERROR(Status) && Status != EFI_ACCESS_DENIED) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- }
- }
- //
- // Free the fileList
- //
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- Status = ShellCloseFileMetaArg(&FileList);
- ASSERT_EFI_ERROR(Status);
- }
- FileList = NULL;
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- if (ShellGetExecutionBreakFlag()) {
- return (SHELL_ABORTED);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
deleted file mode 100644
index ccd1199bd1..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/** @file
- Main file for Type shell level 3 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-/**
- Display a single file to StdOut.
-
- If both Ascii and UCS2 are FALSE attempt to discover the file type.
-
- @param[in] Handle The handle to the file to display.
- @param[in] Ascii TRUE to force ASCII, FALSE othewise.
- @param[in] UCS2 TRUE to force UCS2, FALSE othewise.
-
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-TypeFileByHandle (
- IN SHELL_FILE_HANDLE Handle,
- IN BOOLEAN Ascii,
- IN BOOLEAN UCS2
- )
-{
- UINTN ReadSize;
- VOID *Buffer;
- VOID *AllocatedBuffer;
- EFI_STATUS Status;
- UINTN LoopVar;
- UINTN LoopSize;
- CHAR16 AsciiChar;
- CHAR16 Ucs2Char;
-
- ReadSize = PcdGet32(PcdShellFileOperationSize);
- AllocatedBuffer = AllocateZeroPool(ReadSize);
- if (AllocatedBuffer == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- Status = ShellSetFilePosition(Handle, 0);
- ASSERT_EFI_ERROR(Status);
-
- while (ReadSize == ((UINTN)PcdGet32(PcdShellFileOperationSize))) {
- Buffer = AllocatedBuffer;
- ZeroMem(Buffer, ReadSize);
- Status = ShellReadFile(Handle, &ReadSize, Buffer);
- if (EFI_ERROR(Status)){
- break;
- }
-
- if (!(Ascii|UCS2)) {
- if (*(UINT16*)Buffer == gUnicodeFileTag) {
- UCS2 = TRUE;
- } else {
- Ascii = TRUE;
- }
- }
-
- if (Ascii) {
- LoopSize = ReadSize;
- for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
- //
- // The valid range of ASCII characters is 0x20-0x7E.
- // Display "." when there is an invalid character.
- //
- AsciiChar = CHAR_NULL;
- AsciiChar = ((CHAR8*)Buffer)[LoopVar];
- if (AsciiChar == '\r' || AsciiChar == '\n') {
- //
- // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
- // characters to be displayed as is.
- //
- if (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r') {
- //
- // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
- // was not the previous character, print CR and LF. This is because
- // Shell 2.0 requires carriage return with line feed for displaying
- // each new line from left.
- //
- ShellPrintEx (-1, -1, L"\r\n");
- continue;
- }
- } else {
- //
- // For all other characters which are not printable, display '.'
- //
- if (AsciiChar < 0x20 || AsciiChar >= 0x7F) {
- AsciiChar = '.';
- }
- }
- ShellPrintEx (-1, -1, L"%c", AsciiChar);
- }
- } else {
- if (*(UINT16*)Buffer == gUnicodeFileTag) {
- //
- // For unicode files, skip displaying the byte order marker.
- //
- Buffer = ((UINT16*)Buffer) + 1;
- LoopSize = (ReadSize / (sizeof (CHAR16))) - 1;
- } else {
- LoopSize = ReadSize / (sizeof (CHAR16));
- }
-
- for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
- //
- // An invalid range of characters is 0x0-0x1F.
- // Display "." when there is an invalid character.
- //
- Ucs2Char = CHAR_NULL;
- Ucs2Char = ((CHAR16*)Buffer)[LoopVar];
- if (Ucs2Char == '\r' || Ucs2Char == '\n') {
- //
- // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
- // characters to be displayed as is.
- //
- if (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r') {
- //
- // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
- // was not the previous character, print CR and LF. This is because
- // Shell 2.0 requires carriage return with line feed for displaying
- // each new line from left.
- //
- ShellPrintEx (-1, -1, L"\r\n");
- continue;
- }
- }
- else if (Ucs2Char < 0x20) {
- //
- // For all other characters which are not printable, display '.'
- //
- Ucs2Char = L'.';
- }
- ShellPrintEx (-1, -1, L"%c", Ucs2Char);
- }
- }
-
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
- }
- FreePool (AllocatedBuffer);
- ShellPrintEx (-1, -1, L"\r\n");
- return (Status);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-a", TypeFlag},
- {L"-u", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'type' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunType (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Param;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *Node;
- BOOLEAN AsciiMode;
- BOOLEAN UnicodeMode;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"type", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- AsciiMode = ShellCommandLineGetFlag(Package, L"-a");
- UnicodeMode = ShellCommandLineGetFlag(Package, L"-u");
-
- if (AsciiMode && UnicodeMode) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"type", L"-a & -u");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
- //
- // we insufficient parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"type");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // get a list with each file specified by parameters
- // if parameter is a directory then add all the files below it to the list
- //
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ; Param != NULL
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", (CHAR16*)Param);
- ShellStatus = SHELL_NOT_FOUND;
- break;
- }
- //
- // make sure we completed the param parsing sucessfully...
- // Also make sure that any previous action was sucessful
- //
- if (ShellStatus == SHELL_SUCCESS) {
- //
- // check that we have at least 1 file
- //
- if (FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"type", Param);
- continue;
- } else {
- //
- // loop through the list and make sure we are not aborting...
- //
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
- ){
-
- if (ShellGetExecutionBreakFlag()) {
- break;
- }
-
- //
- // make sure the file opened ok
- //
- if (EFI_ERROR(Node->Status)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", Node->FileName);
- ShellStatus = SHELL_NOT_FOUND;
- continue;
- }
-
- //
- // make sure its not a directory
- //
- if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, L"type", Node->FileName);
- ShellStatus = SHELL_NOT_FOUND;
- continue;
- }
-
- //
- // do it
- //
- Status = TypeFileByHandle (Node->Handle, AsciiMode, UnicodeMode);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, L"type", Node->FileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- ASSERT(ShellStatus == SHELL_SUCCESS);
- }
- }
- }
- //
- // Free the fileList
- //
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- Status = ShellCloseFileMetaArg(&FileList);
- }
- ASSERT_EFI_ERROR(Status);
- FileList = NULL;
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- if (ShellGetExecutionBreakFlag()) {
- return (SHELL_ABORTED);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c
deleted file mode 100644
index 448f7234dd..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file
- Main file for NULL named library for level 3 shell command functions.
-
- (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-CONST CHAR16 gShellLevel3FileName[] = L"ShellCommands";
-EFI_HANDLE gShellLevel3HiiHandle = NULL;
-
-/**
- return the filename to get help from is not using HII.
-
- @retval The filename.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameLevel3 (
- VOID
- )
-{
- return (gShellLevel3FileName);
-}
-
-/**
- Constructor for the Shell Level 3 Commands library.
-
- Install the handlers for level 3 UEFI Shell 2.0 commands.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel3CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- gShellLevel3HiiHandle = NULL;
- //
- // if shell level is less than 3 do nothing
- //
- if (PcdGet8(PcdShellSupportLevel) < 3) {
- return (EFI_SUCCESS);
- }
-
- gShellLevel3HiiHandle = HiiAddPackages (&gShellLevel3HiiGuid, gImageHandle, UefiShellLevel3CommandsLibStrings, NULL);
- if (gShellLevel3HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
- //
- // install our shell command handlers that are always installed
- //
- // Note: that Time, Timezone, and Date are part of level 2 library
- //
- ShellCommandRegisterCommandName(L"type", ShellCommandRunType , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TYPE));
- ShellCommandRegisterCommandName(L"touch", ShellCommandRunTouch , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TOUCH));
- ShellCommandRegisterCommandName(L"ver", ShellCommandRunVer , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_VER));
- ShellCommandRegisterCommandName(L"alias", ShellCommandRunAlias , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ALIAS));
- ShellCommandRegisterCommandName(L"cls", ShellCommandRunCls , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_CLS));
- ShellCommandRegisterCommandName(L"echo", ShellCommandRunEcho , ShellCommandGetManFileNameLevel3, 3, L"", FALSE, gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ECHO));
- ShellCommandRegisterCommandName(L"pause", ShellCommandRunPause , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_PAUSE));
- ShellCommandRegisterCommandName(L"getmtc", ShellCommandRunGetMtc , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_GETMTC));
- ShellCommandRegisterCommandName(L"help", ShellCommandRunHelp , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_HELP));
-
- ShellCommandRegisterAlias(L"type", L"cat");
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellLevel3CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellLevel3HiiHandle != NULL) {
- HiiRemovePackages(gShellLevel3HiiHandle);
- }
- return (EFI_SUCCESS);
-}
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h
deleted file mode 100644
index bd5b9bec9c..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/** @file
- header file for NULL named library for level 3 shell command functions.
-
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_
-#define _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-
-extern EFI_HANDLE gShellLevel3HiiHandle;
-
-/**
- Function for 'type' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunType (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'touch' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTouch (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'ver' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunVer (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'alias' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAlias (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'cls' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunCls (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'echo' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunEcho (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'pause' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPause (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'getmtc' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunGetMtc (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'help' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunHelp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
deleted file mode 100644
index a13cd9babf..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file
-# Provides shell level 3 functions
-# Note that the interactive versions of the time, date, and timezone functions are handled in the level 2 library.
-#
-# (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
-# Copyright (c) 2009-2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellLevel3CommandsLib
- FILE_GUID = 71374B42-85D7-4753-AD17-AA84C3A0EB93
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellLevel3CommandsLibConstructor
- DESTRUCTOR = ShellLevel3CommandsLibDestructor
-
-[Sources.common]
-# note that time, timezone, and date are part of the level 2 library
- Type.c
- Touch.c
- Ver.c
- UefiShellLevel3CommandsLib.uni
- UefiShellLevel3CommandsLib.c
- UefiShellLevel3CommandsLib.h
- Cls.c
- Alias.c
- Echo.c
- Pause.c
- GetMtc.c
- Help.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- PcdLib
- HiiLib
- FileHandleLib
- HandleParsingLib
-
-[Guids]
- gEfiFileInfoGuid ## UNDEFINED
- gShellLevel3HiiGuid ## SOMETIMES_CONSUMES ## HII
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize ## SOMETIMES_CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellSupplier ## SOMETIMES_CONSUMES
-
-[Protocols]
- gEfiShellDynamicCommandProtocolGuid ## SOMETIMES_CONSUMES
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
deleted file mode 100644
index f4473ada5f..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
deleted file mode 100644
index deefaf0bb2..0000000000
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/** @file
- Main file for Ver shell level 3 function.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLevel3CommandsLib.h"
-
-#include <Library/ShellLib.h>
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-s", TypeFlag},
- {L"-terse", TypeFlag},
- {L"-t", TypeFlag},
- {L"-_pa", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'ver' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunVer (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINT8 Level;
-
- Level = PcdGet8(PcdShellSupportLevel);
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"ver", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // check for "-?"
- //
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- }
- if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
- //
- // we have too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"ver");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
- gShellLevel3HiiHandle,
- gEfiShellProtocol->MajorVersion,
- gEfiShellProtocol->MinorVersion
- );
- } else {
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_VER_OUTPUT_SHELL),
- gShellLevel3HiiHandle,
- SupportLevel[Level],
- gEfiShellProtocol->MajorVersion,
- gEfiShellProtocol->MinorVersion
- );
- if (!ShellCommandLineGetFlag(Package, L"-terse") && !ShellCommandLineGetFlag(Package, L"-t")){
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
- gShellLevel3HiiHandle,
- (CHAR16 *) PcdGetPtr (PcdShellSupplier)
- );
-
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_VER_OUTPUT_UEFI),
- gShellLevel3HiiHandle,
- (gST->Hdr.Revision&0xffff0000)>>16,
- (gST->Hdr.Revision&0x0000ffff),
- gST->FirmwareVendor,
- gST->FirmwareRevision
- );
- }
- }
- //
- // implementation specific support for displaying processor architecture
- //
- if (ShellCommandLineGetFlag(Package, L"-_pa")) {
- ShellPrintEx(-1, -1, L"%d\r\n", sizeof(UINTN)==sizeof(UINT64)?64:32);
- }
- }
-
- //
- // free the command line package
- //
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
deleted file mode 100644
index 6e0f61130f..0000000000
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ /dev/null
@@ -1,4322 +0,0 @@
-/** @file
- Provides interface to shell functionality for shell commands and applications.
-
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
- 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 "UefiShellLib.h"
-#include <ShellBase.h>
-#include <Library/SortLib.h>
-#include <Library/BaseLib.h>
-
-#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
-
-//
-// globals...
-//
-SHELL_PARAM_ITEM EmptyParamList[] = {
- {NULL, TypeMax}
- };
-SHELL_PARAM_ITEM SfoParamList[] = {
- {L"-sfo", TypeFlag},
- {NULL, TypeMax}
- };
-EFI_SHELL_ENVIRONMENT2 *mEfiShellEnvironment2;
-EFI_SHELL_INTERFACE *mEfiShellInterface;
-EFI_SHELL_PROTOCOL *gEfiShellProtocol;
-EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;
-EFI_HANDLE mEfiShellEnvironment2Handle;
-FILE_HANDLE_FUNCTION_MAP FileFunctionMap;
-
-/**
- Check if a Unicode character is a hexadecimal character.
-
- This internal function checks if a Unicode character is a
- numeric character. The valid hexadecimal characters are
- L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
-
- @param Char The character to check against.
-
- @retval TRUE If the Char is a hexadecmial character.
- @retval FALSE If the Char is not a hexadecmial character.
-
-**/
-BOOLEAN
-EFIAPI
-ShellIsHexaDecimalDigitCharacter (
- IN CHAR16 Char
- )
-{
- return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F') || (Char >= L'a' && Char <= L'f'));
-}
-
-/**
- Check if a Unicode character is a decimal character.
-
- This internal function checks if a Unicode character is a
- decimal character. The valid characters are
- L'0' to L'9'.
-
-
- @param Char The character to check against.
-
- @retval TRUE If the Char is a hexadecmial character.
- @retval FALSE If the Char is not a hexadecmial character.
-
-**/
-BOOLEAN
-EFIAPI
-ShellIsDecimalDigitCharacter (
- IN CHAR16 Char
- )
-{
- return (BOOLEAN) (Char >= L'0' && Char <= L'9');
-}
-
-/**
- Helper function to find ShellEnvironment2 for constructor.
-
- @param[in] ImageHandle A copy of the calling image's handle.
-
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
-**/
-EFI_STATUS
-EFIAPI
-ShellFindSE2 (
- IN EFI_HANDLE ImageHandle
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *Buffer;
- UINTN BufferSize;
- UINTN HandleIndex;
-
- BufferSize = 0;
- Buffer = NULL;
- Status = gBS->OpenProtocol(ImageHandle,
- &gEfiShellEnvironment2Guid,
- (VOID **)&mEfiShellEnvironment2,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- //
- // look for the mEfiShellEnvironment2 protocol at a higher level
- //
- if (EFI_ERROR (Status) || !(CompareGuid (&mEfiShellEnvironment2->SESGuid, &gEfiShellEnvironment2ExtGuid))){
- //
- // figure out how big of a buffer we need.
- //
- Status = gBS->LocateHandle (ByProtocol,
- &gEfiShellEnvironment2Guid,
- NULL, // ignored for ByProtocol
- &BufferSize,
- Buffer
- );
- //
- // maybe it's not there???
- //
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = (EFI_HANDLE*)AllocateZeroPool(BufferSize);
- if (Buffer == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle (ByProtocol,
- &gEfiShellEnvironment2Guid,
- NULL, // ignored for ByProtocol
- &BufferSize,
- Buffer
- );
- }
- if (!EFI_ERROR (Status) && Buffer != NULL) {
- //
- // now parse the list of returned handles
- //
- Status = EFI_NOT_FOUND;
- for (HandleIndex = 0; HandleIndex < (BufferSize/sizeof(Buffer[0])); HandleIndex++) {
- Status = gBS->OpenProtocol(Buffer[HandleIndex],
- &gEfiShellEnvironment2Guid,
- (VOID **)&mEfiShellEnvironment2,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (CompareGuid (&mEfiShellEnvironment2->SESGuid, &gEfiShellEnvironment2ExtGuid)) {
- mEfiShellEnvironment2Handle = Buffer[HandleIndex];
- Status = EFI_SUCCESS;
- break;
- }
- }
- }
- }
- if (Buffer != NULL) {
- FreePool (Buffer);
- }
- return (Status);
-}
-
-/**
- Function to do most of the work of the constructor. Allows for calling
- multiple times without complete re-initialization.
-
- @param[in] ImageHandle A copy of the ImageHandle.
- @param[in] SystemTable A pointer to the SystemTable for the application.
-
- @retval EFI_SUCCESS The operationw as successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellLibConstructorWorker (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // UEFI 2.0 shell interfaces (used preferentially)
- //
- Status = gBS->OpenProtocol(
- ImageHandle,
- &gEfiShellProtocolGuid,
- (VOID **)&gEfiShellProtocol,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- //
- // Search for the shell protocol
- //
- Status = gBS->LocateProtocol(
- &gEfiShellProtocolGuid,
- NULL,
- (VOID **)&gEfiShellProtocol
- );
- if (EFI_ERROR(Status)) {
- gEfiShellProtocol = NULL;
- }
- }
- Status = gBS->OpenProtocol(
- ImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID **)&gEfiShellParametersProtocol,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- gEfiShellParametersProtocol = NULL;
- }
-
- if (gEfiShellParametersProtocol == NULL || gEfiShellProtocol == NULL) {
- //
- // Moved to seperate function due to complexity
- //
- Status = ShellFindSE2(ImageHandle);
-
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "Status: 0x%08x\r\n", Status));
- mEfiShellEnvironment2 = NULL;
- }
- Status = gBS->OpenProtocol(ImageHandle,
- &gEfiShellInterfaceGuid,
- (VOID **)&mEfiShellInterface,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- mEfiShellInterface = NULL;
- }
- }
-
- //
- // only success getting 2 of either the old or new, but no 1/2 and 1/2
- //
- if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface != NULL) ||
- (gEfiShellProtocol != NULL && gEfiShellParametersProtocol != NULL) ) {
- if (gEfiShellProtocol != NULL) {
- FileFunctionMap.GetFileInfo = gEfiShellProtocol->GetFileInfo;
- FileFunctionMap.SetFileInfo = gEfiShellProtocol->SetFileInfo;
- FileFunctionMap.ReadFile = gEfiShellProtocol->ReadFile;
- FileFunctionMap.WriteFile = gEfiShellProtocol->WriteFile;
- FileFunctionMap.CloseFile = gEfiShellProtocol->CloseFile;
- FileFunctionMap.DeleteFile = gEfiShellProtocol->DeleteFile;
- FileFunctionMap.GetFilePosition = gEfiShellProtocol->GetFilePosition;
- FileFunctionMap.SetFilePosition = gEfiShellProtocol->SetFilePosition;
- FileFunctionMap.FlushFile = gEfiShellProtocol->FlushFile;
- FileFunctionMap.GetFileSize = gEfiShellProtocol->GetFileSize;
- } else {
- FileFunctionMap.GetFileInfo = (EFI_SHELL_GET_FILE_INFO)FileHandleGetInfo;
- FileFunctionMap.SetFileInfo = (EFI_SHELL_SET_FILE_INFO)FileHandleSetInfo;
- FileFunctionMap.ReadFile = (EFI_SHELL_READ_FILE)FileHandleRead;
- FileFunctionMap.WriteFile = (EFI_SHELL_WRITE_FILE)FileHandleWrite;
- FileFunctionMap.CloseFile = (EFI_SHELL_CLOSE_FILE)FileHandleClose;
- FileFunctionMap.DeleteFile = (EFI_SHELL_DELETE_FILE)FileHandleDelete;
- FileFunctionMap.GetFilePosition = (EFI_SHELL_GET_FILE_POSITION)FileHandleGetPosition;
- FileFunctionMap.SetFilePosition = (EFI_SHELL_SET_FILE_POSITION)FileHandleSetPosition;
- FileFunctionMap.FlushFile = (EFI_SHELL_FLUSH_FILE)FileHandleFlush;
- FileFunctionMap.GetFileSize = (EFI_SHELL_GET_FILE_SIZE)FileHandleGetSize;
- }
- return (EFI_SUCCESS);
- }
- return (EFI_NOT_FOUND);
-}
-/**
- Constructor for the Shell library.
-
- Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the initialization was complete sucessfully
- @return others an error ocurred during initialization
-**/
-EFI_STATUS
-EFIAPI
-ShellLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- mEfiShellEnvironment2 = NULL;
- gEfiShellProtocol = NULL;
- gEfiShellParametersProtocol = NULL;
- mEfiShellInterface = NULL;
- mEfiShellEnvironment2Handle = NULL;
-
- //
- // verify that auto initialize is not set false
- //
- if (PcdGetBool(PcdShellLibAutoInitialize) == 0) {
- return (EFI_SUCCESS);
- }
-
- return (ShellLibConstructorWorker(ImageHandle, SystemTable));
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param[in] ImageHandle A copy of the ImageHandle.
- @param[in] SystemTable A pointer to the SystemTable for the application.
-
- @retval EFI_SUCCESS The operation was successful.
- @return An error from the CloseProtocol function.
-**/
-EFI_STATUS
-EFIAPI
-ShellLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (mEfiShellEnvironment2 != NULL) {
- gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,
- &gEfiShellEnvironment2Guid,
- ImageHandle,
- NULL);
- mEfiShellEnvironment2 = NULL;
- }
- if (mEfiShellInterface != NULL) {
- gBS->CloseProtocol(ImageHandle,
- &gEfiShellInterfaceGuid,
- ImageHandle,
- NULL);
- mEfiShellInterface = NULL;
- }
- if (gEfiShellProtocol != NULL) {
- gBS->CloseProtocol(ImageHandle,
- &gEfiShellProtocolGuid,
- ImageHandle,
- NULL);
- gEfiShellProtocol = NULL;
- }
- if (gEfiShellParametersProtocol != NULL) {
- gBS->CloseProtocol(ImageHandle,
- &gEfiShellParametersProtocolGuid,
- ImageHandle,
- NULL);
- gEfiShellParametersProtocol = NULL;
- }
- mEfiShellEnvironment2Handle = NULL;
-
- return (EFI_SUCCESS);
-}
-
-/**
- This function causes the shell library to initialize itself. If the shell library
- is already initialized it will de-initialize all the current protocol poitners and
- re-populate them again.
-
- When the library is used with PcdShellLibAutoInitialize set to true this function
- will return EFI_SUCCESS and perform no actions.
-
- This function is intended for internal access for shell commands only.
-
- @retval EFI_SUCCESS the initialization was complete sucessfully
-
-**/
-EFI_STATUS
-EFIAPI
-ShellInitialize (
- )
-{
- //
- // if auto initialize is not false then skip
- //
- if (PcdGetBool(PcdShellLibAutoInitialize) != 0) {
- return (EFI_SUCCESS);
- }
-
- //
- // deinit the current stuff
- //
- ASSERT_EFI_ERROR(ShellLibDestructor(gImageHandle, gST));
-
- //
- // init the new stuff
- //
- return (ShellLibConstructorWorker(gImageHandle, gST));
-}
-
-/**
- This function will retrieve the information about the file for the handle
- specified and store it in allocated pool memory.
-
- This function allocates a buffer to store the file's information. It is the
- caller's responsibility to free the buffer
-
- @param FileHandle The file handle of the file for which information is
- being requested.
-
- @retval NULL information could not be retrieved.
-
- @return the information about the file
-**/
-EFI_FILE_INFO*
-EFIAPI
-ShellGetFileInfo (
- IN SHELL_FILE_HANDLE FileHandle
- )
-{
- return (FileFunctionMap.GetFileInfo(FileHandle));
-}
-
-/**
- This function sets the information about the file for the opened handle
- specified.
-
- @param[in] FileHandle The file handle of the file for which information
- is being set.
-
- @param[in] FileInfo The information to set.
-
- @retval EFI_SUCCESS The information was set.
- @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.
- @retval EFI_UNSUPPORTED The FileHandle does not support FileInfo.
- @retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened read only.
- @retval EFI_VOLUME_FULL The volume is full.
-**/
-EFI_STATUS
-EFIAPI
-ShellSetFileInfo (
- IN SHELL_FILE_HANDLE FileHandle,
- IN EFI_FILE_INFO *FileInfo
- )
-{
- return (FileFunctionMap.SetFileInfo(FileHandle, FileInfo));
-}
-
- /**
- This function will open a file or directory referenced by DevicePath.
-
- This function opens a file with the open mode according to the file path. The
- Attributes is valid only for EFI_FILE_MODE_CREATE.
-
- @param FilePath on input the device path to the file. On output
- the remaining device path.
- @param DeviceHandle pointer to the system device handle.
- @param FileHandle pointer to the file handle.
- @param OpenMode the mode to open the file with.
- @param Attributes the file's file attributes.
-
- @retval EFI_SUCCESS The information was set.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED Could not open the file path.
- @retval EFI_NOT_FOUND The specified file could not be found on the
- device or the file system could not be found on
- the device.
- @retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
- medium is no longer supported.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened read only.
- @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
- file.
- @retval EFI_VOLUME_FULL The volume is full.
-**/
-EFI_STATUS
-EFIAPI
-ShellOpenFileByDevicePath(
- IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
- OUT EFI_HANDLE *DeviceHandle,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
- )
-{
- CHAR16 *FileName;
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *EfiSimpleFileSystemProtocol;
- EFI_FILE_PROTOCOL *Handle1;
- EFI_FILE_PROTOCOL *Handle2;
- CHAR16 *FnafPathName;
- UINTN PathLen;
-
- if (FilePath == NULL || FileHandle == NULL || DeviceHandle == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // which shell interface should we use
- //
- if (gEfiShellProtocol != NULL) {
- //
- // use UEFI Shell 2.0 method.
- //
- FileName = gEfiShellProtocol->GetFilePathFromDevicePath(*FilePath);
- if (FileName == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- Status = ShellOpenFileByName(FileName, FileHandle, OpenMode, Attributes);
- FreePool(FileName);
- return (Status);
- }
-
-
- //
- // use old shell method.
- //
- Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid,
- FilePath,
- DeviceHandle);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = gBS->OpenProtocol(*DeviceHandle,
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&EfiSimpleFileSystemProtocol,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = EfiSimpleFileSystemProtocol->OpenVolume(EfiSimpleFileSystemProtocol, &Handle1);
- if (EFI_ERROR (Status)) {
- FileHandle = NULL;
- return Status;
- }
-
- //
- // go down directories one node at a time.
- //
- while (!IsDevicePathEnd (*FilePath)) {
- //
- // For file system access each node should be a file path component
- //
- if (DevicePathType (*FilePath) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP
- ) {
- FileHandle = NULL;
- return (EFI_INVALID_PARAMETER);
- }
- //
- // Open this file path node
- //
- Handle2 = Handle1;
- Handle1 = NULL;
-
- //
- // File Name Alignment Fix (FNAF)
- // Handle2->Open may be incapable of handling a unaligned CHAR16 data.
- // The structure pointed to by FilePath may be not CHAR16 aligned.
- // This code copies the potentially unaligned PathName data from the
- // FilePath structure to the aligned FnafPathName for use in the
- // calls to Handl2->Open.
- //
-
- //
- // Determine length of PathName, in bytes.
- //
- PathLen = DevicePathNodeLength (*FilePath) - SIZE_OF_FILEPATH_DEVICE_PATH;
-
- //
- // Allocate memory for the aligned copy of the string Extra allocation is to allow for forced alignment
- // Copy bytes from possibly unaligned location to aligned location
- //
- FnafPathName = AllocateCopyPool(PathLen, (UINT8 *)((FILEPATH_DEVICE_PATH*)*FilePath)->PathName);
- if (FnafPathName == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Try to test opening an existing file
- //
- Status = Handle2->Open (
- Handle2,
- &Handle1,
- FnafPathName,
- OpenMode &~EFI_FILE_MODE_CREATE,
- 0
- );
-
- //
- // see if the error was that it needs to be created
- //
- if ((EFI_ERROR (Status)) && (OpenMode != (OpenMode &~EFI_FILE_MODE_CREATE))) {
- Status = Handle2->Open (
- Handle2,
- &Handle1,
- FnafPathName,
- OpenMode,
- Attributes
- );
- }
-
- //
- // Free the alignment buffer
- //
- FreePool(FnafPathName);
-
- //
- // Close the last node
- //
- Handle2->Close (Handle2);
-
- if (EFI_ERROR(Status)) {
- return (Status);
- }
-
- //
- // Get the next node
- //
- *FilePath = NextDevicePathNode (*FilePath);
- }
-
- //
- // This is a weak spot since if the undefined SHELL_FILE_HANDLE format changes this must change also!
- //
- *FileHandle = (VOID*)Handle1;
- return (EFI_SUCCESS);
-}
-
-/**
- This function will open a file or directory referenced by filename.
-
- If return is EFI_SUCCESS, the Filehandle is the opened file's handle;
- otherwise, the Filehandle is NULL. The Attributes is valid only for
- EFI_FILE_MODE_CREATE.
-
- if FileName is NULL then ASSERT()
-
- @param FileName pointer to file name
- @param FileHandle pointer to the file handle.
- @param OpenMode the mode to open the file with.
- @param Attributes the file's file attributes.
-
- @retval EFI_SUCCESS The information was set.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED Could not open the file path.
- @retval EFI_NOT_FOUND The specified file could not be found on the
- device or the file system could not be found
- on the device.
- @retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
- medium is no longer supported.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened read only.
- @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
- file.
- @retval EFI_VOLUME_FULL The volume is full.
-**/
-EFI_STATUS
-EFIAPI
-ShellOpenFileByName(
- IN CONST CHAR16 *FileName,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
- )
-{
- EFI_HANDLE DeviceHandle;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
- CHAR16 *FileNameCopy;
-
- //
- // ASSERT if FileName is NULL
- //
- ASSERT(FileName != NULL);
-
- if (FileName == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- if (gEfiShellProtocol != NULL) {
- if ((OpenMode & EFI_FILE_MODE_CREATE) == EFI_FILE_MODE_CREATE) {
-
- //
- // Create only a directory
- //
- if ((Attributes & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
- return ShellCreateDirectory(FileName, FileHandle);
- }
-
- //
- // Create the directory to create the file in
- //
- FileNameCopy = AllocateCopyPool (StrSize (FileName), FileName);
- if (FileName == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- PathCleanUpDirectories (FileNameCopy);
- if (PathRemoveLastItem (FileNameCopy)) {
- if (!EFI_ERROR(ShellCreateDirectory (FileNameCopy, FileHandle))) {
- ShellCloseFile (FileHandle);
- }
- }
- SHELL_FREE_NON_NULL (FileNameCopy);
- }
-
- //
- // Use UEFI Shell 2.0 method to create the file
- //
- Status = gEfiShellProtocol->OpenFileByName(FileName,
- FileHandle,
- OpenMode);
- if (StrCmp(FileName, L"NUL") != 0 && !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){
- FileInfo = FileFunctionMap.GetFileInfo(*FileHandle);
- ASSERT(FileInfo != NULL);
- FileInfo->Attribute = Attributes;
- Status = FileFunctionMap.SetFileInfo(*FileHandle, FileInfo);
- FreePool(FileInfo);
- }
- return (Status);
- }
- //
- // Using EFI Shell version
- // this means convert name to path and call that function
- // since this will use EFI method again that will open it.
- //
- ASSERT(mEfiShellEnvironment2 != NULL);
- FilePath = mEfiShellEnvironment2->NameToPath ((CHAR16*)FileName);
- if (FilePath != NULL) {
- return (ShellOpenFileByDevicePath(&FilePath,
- &DeviceHandle,
- FileHandle,
- OpenMode,
- Attributes));
- }
- return (EFI_DEVICE_ERROR);
-}
-/**
- This function create a directory
-
- If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;
- otherwise, the Filehandle is NULL. If the directory already existed, this
- function opens the existing directory.
-
- @param DirectoryName pointer to directory name
- @param FileHandle pointer to the file handle.
-
- @retval EFI_SUCCESS The information was set.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED Could not open the file path.
- @retval EFI_NOT_FOUND The specified file could not be found on the
- device or the file system could not be found
- on the device.
- @retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
- medium is no longer supported.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened read only.
- @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
- file.
- @retval EFI_VOLUME_FULL The volume is full.
- @sa ShellOpenFileByName
-**/
-EFI_STATUS
-EFIAPI
-ShellCreateDirectory(
- IN CONST CHAR16 *DirectoryName,
- OUT SHELL_FILE_HANDLE *FileHandle
- )
-{
- if (gEfiShellProtocol != NULL) {
- //
- // Use UEFI Shell 2.0 method
- //
- return (gEfiShellProtocol->CreateFile(DirectoryName,
- EFI_FILE_DIRECTORY,
- FileHandle
- ));
- } else {
- return (ShellOpenFileByName(DirectoryName,
- FileHandle,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
- EFI_FILE_DIRECTORY
- ));
- }
-}
-
-/**
- This function reads information from an opened file.
-
- If FileHandle is not a directory, the function reads the requested number of
- bytes from the file at the file's current position and returns them in Buffer.
- If the read goes beyond the end of the file, the read length is truncated to the
- end of the file. The file's current position is increased by the number of bytes
- returned. If FileHandle is a directory, the function reads the directory entry
- at the file's current position and returns the entry in Buffer. If the Buffer
- is not large enough to hold the current directory entry, then
- EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.
- BufferSize is set to be the size of the buffer needed to read the entry. On
- success, the current position is updated to the next directory entry. If there
- are no more directory entries, the read returns a zero-length buffer.
- EFI_FILE_INFO is the structure returned as the directory entry.
-
- @param FileHandle the opened file handle
- @param BufferSize on input the size of buffer in bytes. on return
- the number of bytes written.
- @param Buffer the buffer to put read data into.
-
- @retval EFI_SUCCESS Data was read.
- @retval EFI_NO_MEDIA The device has no media.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required
- size.
-
-**/
-EFI_STATUS
-EFIAPI
-ShellReadFile(
- IN SHELL_FILE_HANDLE FileHandle,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- )
-{
- return (FileFunctionMap.ReadFile(FileHandle, BufferSize, Buffer));
-}
-
-
-/**
- Write data to a file.
-
- This function writes the specified number of bytes to the file at the current
- file position. The current file position is advanced the actual number of bytes
- written, which is returned in BufferSize. Partial writes only occur when there
- has been a data error during the write attempt (such as "volume space full").
- The file is automatically grown to hold the data if required. Direct writes to
- opened directories are not supported.
-
- @param FileHandle The opened file for writing
- @param BufferSize on input the number of bytes in Buffer. On output
- the number of bytes written.
- @param Buffer the buffer containing data to write is stored.
-
- @retval EFI_SUCCESS Data was written.
- @retval EFI_UNSUPPORTED Writes to an open directory are not supported.
- @retval EFI_NO_MEDIA The device has no media.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The device is write-protected.
- @retval EFI_ACCESS_DENIED The file was open for read only.
- @retval EFI_VOLUME_FULL The volume is full.
-**/
-EFI_STATUS
-EFIAPI
-ShellWriteFile(
- IN SHELL_FILE_HANDLE FileHandle,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- )
-{
- return (FileFunctionMap.WriteFile(FileHandle, BufferSize, Buffer));
-}
-
-/**
- Close an open file handle.
-
- This function closes a specified file handle. All "dirty" cached file data is
- flushed to the device, and the file is closed. In all cases the handle is
- closed.
-
-@param FileHandle the file handle to close.
-
-@retval EFI_SUCCESS the file handle was closed sucessfully.
-**/
-EFI_STATUS
-EFIAPI
-ShellCloseFile (
- IN SHELL_FILE_HANDLE *FileHandle
- )
-{
- return (FileFunctionMap.CloseFile(*FileHandle));
-}
-
-/**
- Delete a file and close the handle
-
- This function closes and deletes a file. In all cases the file handle is closed.
- If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is
- returned, but the handle is still closed.
-
- @param FileHandle the file handle to delete
-
- @retval EFI_SUCCESS the file was closed sucessfully
- @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not
- deleted
- @retval INVALID_PARAMETER One of the parameters has an invalid value.
-**/
-EFI_STATUS
-EFIAPI
-ShellDeleteFile (
- IN SHELL_FILE_HANDLE *FileHandle
- )
-{
- return (FileFunctionMap.DeleteFile(*FileHandle));
-}
-
-/**
- Set the current position in a file.
-
- This function sets the current file position for the handle to the position
- supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only
- absolute positioning is supported, and seeking past the end of the file is
- allowed (a subsequent write would grow the file). Seeking to position
- 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.
- If FileHandle is a directory, the only position that may be set is zero. This
- has the effect of starting the read process of the directory entries over.
-
- @param FileHandle The file handle on which the position is being set
- @param Position Byte position from begining of file
-
- @retval EFI_SUCCESS Operation completed sucessfully.
- @retval EFI_UNSUPPORTED the seek request for non-zero is not valid on
- directories.
- @retval INVALID_PARAMETER One of the parameters has an invalid value.
-**/
-EFI_STATUS
-EFIAPI
-ShellSetFilePosition (
- IN SHELL_FILE_HANDLE FileHandle,
- IN UINT64 Position
- )
-{
- return (FileFunctionMap.SetFilePosition(FileHandle, Position));
-}
-
-/**
- Gets a file's current position
-
- This function retrieves the current file position for the file handle. For
- directories, the current file position has no meaning outside of the file
- system driver and as such the operation is not supported. An error is returned
- if FileHandle is a directory.
-
- @param FileHandle The open file handle on which to get the position.
- @param Position Byte position from begining of file.
-
- @retval EFI_SUCCESS the operation completed sucessfully.
- @retval INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED the request is not valid on directories.
-**/
-EFI_STATUS
-EFIAPI
-ShellGetFilePosition (
- IN SHELL_FILE_HANDLE FileHandle,
- OUT UINT64 *Position
- )
-{
- return (FileFunctionMap.GetFilePosition(FileHandle, Position));
-}
-/**
- Flushes data on a file
-
- This function flushes all modified data associated with a file to a device.
-
- @param FileHandle The file handle on which to flush data
-
- @retval EFI_SUCCESS The data was flushed.
- @retval EFI_NO_MEDIA The device has no media.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened for read only.
-**/
-EFI_STATUS
-EFIAPI
-ShellFlushFile (
- IN SHELL_FILE_HANDLE FileHandle
- )
-{
- return (FileFunctionMap.FlushFile(FileHandle));
-}
-
-/** Retrieve first entry from a directory.
-
- This function takes an open directory handle and gets information from the
- first entry in the directory. A buffer is allocated to contain
- the information and a pointer to the buffer is returned in *Buffer. The
- caller can use ShellFindNextFile() to get subsequent directory entries.
-
- The buffer will be freed by ShellFindNextFile() when the last directory
- entry is read. Otherwise, the caller must free the buffer, using FreePool,
- when finished with it.
-
- @param[in] DirHandle The file handle of the directory to search.
- @param[out] Buffer The pointer to the buffer for the file's information.
-
- @retval EFI_SUCCESS Found the first file.
- @retval EFI_NOT_FOUND Cannot find the directory.
- @retval EFI_NO_MEDIA The device has no media.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @return Others status of ShellGetFileInfo, ShellSetFilePosition,
- or ShellReadFile
-**/
-EFI_STATUS
-EFIAPI
-ShellFindFirstFile (
- IN SHELL_FILE_HANDLE DirHandle,
- OUT EFI_FILE_INFO **Buffer
- )
-{
- //
- // pass to file handle lib
- //
- return (FileHandleFindFirstFile(DirHandle, Buffer));
-}
-/** Retrieve next entries from a directory.
-
- To use this function, the caller must first call the ShellFindFirstFile()
- function to get the first directory entry. Subsequent directory entries are
- retrieved by using the ShellFindNextFile() function. This function can
- be called several times to get each entry from the directory. If the call of
- ShellFindNextFile() retrieved the last directory entry, the next call of
- this function will set *NoFile to TRUE and free the buffer.
-
- @param[in] DirHandle The file handle of the directory.
- @param[out] Buffer The pointer to buffer for file's information.
- @param[out] NoFile The pointer to boolean when last file is found.
-
- @retval EFI_SUCCESS Found the next file, or reached last file
- @retval EFI_NO_MEDIA The device has no media.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-**/
-EFI_STATUS
-EFIAPI
-ShellFindNextFile(
- IN SHELL_FILE_HANDLE DirHandle,
- OUT EFI_FILE_INFO *Buffer,
- OUT BOOLEAN *NoFile
- )
-{
- //
- // pass to file handle lib
- //
- return (FileHandleFindNextFile(DirHandle, Buffer, NoFile));
-}
-/**
- Retrieve the size of a file.
-
- if FileHandle is NULL then ASSERT()
- if Size is NULL then ASSERT()
-
- This function extracts the file size info from the FileHandle's EFI_FILE_INFO
- data.
-
- @param FileHandle file handle from which size is retrieved
- @param Size pointer to size
-
- @retval EFI_SUCCESS operation was completed sucessfully
- @retval EFI_DEVICE_ERROR cannot access the file
-**/
-EFI_STATUS
-EFIAPI
-ShellGetFileSize (
- IN SHELL_FILE_HANDLE FileHandle,
- OUT UINT64 *Size
- )
-{
- return (FileFunctionMap.GetFileSize(FileHandle, Size));
-}
-/**
- Retrieves the status of the break execution flag
-
- this function is useful to check whether the application is being asked to halt by the shell.
-
- @retval TRUE the execution break is enabled
- @retval FALSE the execution break is not enabled
-**/
-BOOLEAN
-EFIAPI
-ShellGetExecutionBreakFlag(
- VOID
- )
-{
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
-
- //
- // We are using UEFI Shell 2.0; see if the event has been triggered
- //
- if (gBS->CheckEvent(gEfiShellProtocol->ExecutionBreak) != EFI_SUCCESS) {
- return (FALSE);
- }
- return (TRUE);
- }
-
- //
- // using EFI Shell; call the function to check
- //
- if (mEfiShellEnvironment2 != NULL) {
- return (mEfiShellEnvironment2->GetExecutionBreak());
- }
-
- return (FALSE);
-}
-/**
- return the value of an environment variable
-
- this function gets the value of the environment variable set by the
- ShellSetEnvironmentVariable function
-
- @param EnvKey The key name of the environment variable.
-
- @retval NULL the named environment variable does not exist.
- @return != NULL pointer to the value of the environment variable
-**/
-CONST CHAR16*
-EFIAPI
-ShellGetEnvironmentVariable (
- IN CONST CHAR16 *EnvKey
- )
-{
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- return (gEfiShellProtocol->GetEnv(EnvKey));
- }
-
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- return (mEfiShellEnvironment2->GetEnv((CHAR16*)EnvKey));
- }
-
- return NULL;
-}
-/**
- set the value of an environment variable
-
-This function changes the current value of the specified environment variable. If the
-environment variable exists and the Value is an empty string, then the environment
-variable is deleted. If the environment variable exists and the Value is not an empty
-string, then the value of the environment variable is changed. If the environment
-variable does not exist and the Value is an empty string, there is no action. If the
-environment variable does not exist and the Value is a non-empty string, then the
-environment variable is created and assigned the specified value.
-
- This is not supported pre-UEFI Shell 2.0.
-
- @param EnvKey The key name of the environment variable.
- @param EnvVal The Value of the environment variable
- @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
-
- @retval EFI_SUCCESS the operation was completed sucessfully
- @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments
-**/
-EFI_STATUS
-EFIAPI
-ShellSetEnvironmentVariable (
- IN CONST CHAR16 *EnvKey,
- IN CONST CHAR16 *EnvVal,
- IN BOOLEAN Volatile
- )
-{
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- return (gEfiShellProtocol->SetEnv(EnvKey, EnvVal, Volatile));
- }
-
- //
- // This feature does not exist under EFI shell
- //
- return (EFI_UNSUPPORTED);
-}
-
-/**
- Cause the shell to parse and execute a command line.
-
- This function creates a nested instance of the shell and executes the specified
- command (CommandLine) with the specified environment (Environment). Upon return,
- the status code returned by the specified command is placed in StatusCode.
- If Environment is NULL, then the current environment is used and all changes made
- by the commands executed will be reflected in the current environment. If the
- Environment is non-NULL, then the changes made will be discarded.
- The CommandLine is executed from the current working directory on the current
- device.
-
- The EnvironmentVariables pararemeter is ignored in a pre-UEFI Shell 2.0
- environment. The values pointed to by the parameters will be unchanged by the
- ShellExecute() function. The Output parameter has no effect in a
- UEFI Shell 2.0 environment.
-
- @param[in] ParentHandle The parent image starting the operation.
- @param[in] CommandLine The pointer to a NULL terminated command line.
- @param[in] Output True to display debug output. False to hide it.
- @param[in] EnvironmentVariables Optional pointer to array of environment variables
- in the form "x=y". If NULL, the current set is used.
- @param[out] Status The status of the run command line.
-
- @retval EFI_SUCCESS The operation completed sucessfully. Status
- contains the status code returned.
- @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.
- @retval EFI_OUT_OF_RESOURCES Out of resources.
- @retval EFI_UNSUPPORTED The operation is not allowed.
-**/
-EFI_STATUS
-EFIAPI
-ShellExecute (
- IN EFI_HANDLE *ParentHandle,
- IN CHAR16 *CommandLine OPTIONAL,
- IN BOOLEAN Output OPTIONAL,
- IN CHAR16 **EnvironmentVariables OPTIONAL,
- OUT EFI_STATUS *Status OPTIONAL
- )
-{
- EFI_STATUS CmdStatus;
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- //
- // Call UEFI Shell 2.0 version (not using Output parameter)
- //
- return (gEfiShellProtocol->Execute(ParentHandle,
- CommandLine,
- EnvironmentVariables,
- Status));
- }
-
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- //
- // Call EFI Shell version.
- // Due to oddity in the EFI shell we want to dereference the ParentHandle here
- //
- CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle,
- CommandLine,
- Output));
- //
- // No Status output parameter so just use the returned status
- //
- if (Status != NULL) {
- *Status = CmdStatus;
- }
- //
- // If there was an error, we can't tell if it was from the command or from
- // the Execute() function, so we'll just assume the shell ran successfully
- // and the error came from the command.
- //
- return EFI_SUCCESS;
- }
-
- return (EFI_UNSUPPORTED);
-}
-
-/**
- Retreives the current directory path
-
- If the DeviceName is NULL, it returns the current device's current directory
- name. If the DeviceName is not NULL, it returns the current directory name
- on specified drive.
-
- @param DeviceName the name of the drive to get directory on
-
- @retval NULL the directory does not exist
- @return != NULL the directory
-**/
-CONST CHAR16*
-EFIAPI
-ShellGetCurrentDir (
- IN CHAR16 * CONST DeviceName OPTIONAL
- )
-{
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- return (gEfiShellProtocol->GetCurDir(DeviceName));
- }
-
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- return (mEfiShellEnvironment2->CurDir(DeviceName));
- }
-
- return (NULL);
-}
-/**
- sets (enabled or disabled) the page break mode
-
- when page break mode is enabled the screen will stop scrolling
- and wait for operator input before scrolling a subsequent screen.
-
- @param CurrentState TRUE to enable and FALSE to disable
-**/
-VOID
-EFIAPI
-ShellSetPageBreakMode (
- IN BOOLEAN CurrentState
- )
-{
- //
- // check for enabling
- //
- if (CurrentState != 0x00) {
- //
- // check for UEFI Shell 2.0
- //
- if (gEfiShellProtocol != NULL) {
- //
- // Enable with UEFI 2.0 Shell
- //
- gEfiShellProtocol->EnablePageBreak();
- return;
- } else {
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- //
- // Enable with EFI Shell
- //
- mEfiShellEnvironment2->EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
- return;
- }
- }
- } else {
- //
- // check for UEFI Shell 2.0
- //
- if (gEfiShellProtocol != NULL) {
- //
- // Disable with UEFI 2.0 Shell
- //
- gEfiShellProtocol->DisablePageBreak();
- return;
- } else {
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- //
- // Disable with EFI Shell
- //
- mEfiShellEnvironment2->DisablePageBreak ();
- return;
- }
- }
- }
-}
-
-///
-/// version of EFI_SHELL_FILE_INFO struct, except has no CONST pointers.
-/// This allows for the struct to be populated.
-///
-typedef struct {
- LIST_ENTRY Link;
- EFI_STATUS Status;
- CHAR16 *FullName;
- CHAR16 *FileName;
- SHELL_FILE_HANDLE Handle;
- EFI_FILE_INFO *Info;
-} EFI_SHELL_FILE_INFO_NO_CONST;
-
-/**
- Converts a EFI shell list of structures to the coresponding UEFI Shell 2.0 type of list.
-
- if OldStyleFileList is NULL then ASSERT()
-
- this function will convert a SHELL_FILE_ARG based list into a callee allocated
- EFI_SHELL_FILE_INFO based list. it is up to the caller to free the memory via
- the ShellCloseFileMetaArg function.
-
- @param[in] FileList the EFI shell list type
- @param[in, out] ListHead the list to add to
-
- @retval the resultant head of the double linked new format list;
-**/
-LIST_ENTRY*
-EFIAPI
-InternalShellConvertFileListType (
- IN LIST_ENTRY *FileList,
- IN OUT LIST_ENTRY *ListHead
- )
-{
- SHELL_FILE_ARG *OldInfo;
- LIST_ENTRY *Link;
- EFI_SHELL_FILE_INFO_NO_CONST *NewInfo;
-
- //
- // ASSERTs
- //
- ASSERT(FileList != NULL);
- ASSERT(ListHead != NULL);
-
- //
- // enumerate through each member of the old list and copy
- //
- for (Link = FileList->ForwardLink; Link != FileList; Link = Link->ForwardLink) {
- OldInfo = CR (Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE);
- ASSERT(OldInfo != NULL);
-
- //
- // Skip ones that failed to open...
- //
- if (OldInfo->Status != EFI_SUCCESS) {
- continue;
- }
-
- //
- // make sure the old list was valid
- //
- ASSERT(OldInfo->Info != NULL);
- ASSERT(OldInfo->FullName != NULL);
- ASSERT(OldInfo->FileName != NULL);
-
- //
- // allocate a new EFI_SHELL_FILE_INFO object
- //
- NewInfo = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
- if (NewInfo == NULL) {
- ShellCloseFileMetaArg((EFI_SHELL_FILE_INFO**)(&ListHead));
- ListHead = NULL;
- break;
- }
-
- //
- // copy the simple items
- //
- NewInfo->Handle = OldInfo->Handle;
- NewInfo->Status = OldInfo->Status;
-
- // old shell checks for 0 not NULL
- OldInfo->Handle = 0;
-
- //
- // allocate new space to copy strings and structure
- //
- NewInfo->FullName = AllocateCopyPool(StrSize(OldInfo->FullName), OldInfo->FullName);
- NewInfo->FileName = AllocateCopyPool(StrSize(OldInfo->FileName), OldInfo->FileName);
- NewInfo->Info = AllocateCopyPool((UINTN)OldInfo->Info->Size, OldInfo->Info);
-
- //
- // make sure all the memory allocations were sucessful
- //
- if (NULL == NewInfo->FullName || NewInfo->FileName == NULL || NewInfo->Info == NULL) {
- //
- // Free the partially allocated new node
- //
- SHELL_FREE_NON_NULL(NewInfo->FullName);
- SHELL_FREE_NON_NULL(NewInfo->FileName);
- SHELL_FREE_NON_NULL(NewInfo->Info);
- SHELL_FREE_NON_NULL(NewInfo);
-
- //
- // Free the previously converted stuff
- //
- ShellCloseFileMetaArg((EFI_SHELL_FILE_INFO**)(&ListHead));
- ListHead = NULL;
- break;
- }
-
- //
- // add that to the list
- //
- InsertTailList(ListHead, &NewInfo->Link);
- }
- return (ListHead);
-}
-/**
- Opens a group of files based on a path.
-
- This function uses the Arg to open all the matching files. Each matched
- file has a SHELL_FILE_INFO structure to record the file information. These
- structures are placed on the list ListHead. Users can get the SHELL_FILE_INFO
- structures from ListHead to access each file. This function supports wildcards
- and will process '?' and '*' as such. the list must be freed with a call to
- ShellCloseFileMetaArg().
-
- If you are NOT appending to an existing list *ListHead must be NULL. If
- *ListHead is NULL then it must be callee freed.
-
- @param Arg pointer to path string
- @param OpenMode mode to open files with
- @param ListHead head of linked list of results
-
- @retval EFI_SUCCESS the operation was sucessful and the list head
- contains the list of opened files
- @return != EFI_SUCCESS the operation failed
-
- @sa InternalShellConvertFileListType
-**/
-EFI_STATUS
-EFIAPI
-ShellOpenFileMetaArg (
- IN CHAR16 *Arg,
- IN UINT64 OpenMode,
- IN OUT EFI_SHELL_FILE_INFO **ListHead
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY mOldStyleFileList;
- CHAR16 *CleanFilePathStr;
-
- //
- // ASSERT that Arg and ListHead are not NULL
- //
- ASSERT(Arg != NULL);
- ASSERT(ListHead != NULL);
-
- CleanFilePathStr = NULL;
-
- Status = InternalShellStripQuotes (Arg, &CleanFilePathStr);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- if (*ListHead == NULL) {
- *ListHead = (EFI_SHELL_FILE_INFO*)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
- if (*ListHead == NULL) {
- FreePool(CleanFilePathStr);
- return (EFI_OUT_OF_RESOURCES);
- }
- InitializeListHead(&((*ListHead)->Link));
- }
- Status = gEfiShellProtocol->OpenFileList(CleanFilePathStr,
- OpenMode,
- ListHead);
- if (EFI_ERROR(Status)) {
- gEfiShellProtocol->RemoveDupInFileList(ListHead);
- } else {
- Status = gEfiShellProtocol->RemoveDupInFileList(ListHead);
- }
- if (*ListHead != NULL && IsListEmpty(&(*ListHead)->Link)) {
- FreePool(*ListHead);
- FreePool(CleanFilePathStr);
- *ListHead = NULL;
- return (EFI_NOT_FOUND);
- }
- FreePool(CleanFilePathStr);
- return (Status);
- }
-
- //
- // Check for EFI shell
- //
- if (mEfiShellEnvironment2 != NULL) {
- //
- // make sure the list head is initialized
- //
- InitializeListHead(&mOldStyleFileList);
-
- //
- // Get the EFI Shell list of files
- //
- Status = mEfiShellEnvironment2->FileMetaArg(CleanFilePathStr, &mOldStyleFileList);
- if (EFI_ERROR(Status)) {
- *ListHead = NULL;
- FreePool(CleanFilePathStr);
- return (Status);
- }
-
- if (*ListHead == NULL) {
- *ListHead = (EFI_SHELL_FILE_INFO *)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
- if (*ListHead == NULL) {
- FreePool(CleanFilePathStr);
- return (EFI_OUT_OF_RESOURCES);
- }
- InitializeListHead(&((*ListHead)->Link));
- }
-
- //
- // Convert that to equivalent of UEFI Shell 2.0 structure
- //
- InternalShellConvertFileListType(&mOldStyleFileList, &(*ListHead)->Link);
-
- //
- // Free the EFI Shell version that was converted.
- //
- mEfiShellEnvironment2->FreeFileList(&mOldStyleFileList);
-
- if ((*ListHead)->Link.ForwardLink == (*ListHead)->Link.BackLink && (*ListHead)->Link.BackLink == &((*ListHead)->Link)) {
- FreePool(*ListHead);
- *ListHead = NULL;
- Status = EFI_NOT_FOUND;
- }
- FreePool(CleanFilePathStr);
- return (Status);
- }
-
- FreePool(CleanFilePathStr);
- return (EFI_UNSUPPORTED);
-}
-/**
- Free the linked list returned from ShellOpenFileMetaArg.
-
- if ListHead is NULL then ASSERT().
-
- @param ListHead the pointer to free.
-
- @retval EFI_SUCCESS the operation was sucessful.
-**/
-EFI_STATUS
-EFIAPI
-ShellCloseFileMetaArg (
- IN OUT EFI_SHELL_FILE_INFO **ListHead
- )
-{
- LIST_ENTRY *Node;
-
- //
- // ASSERT that ListHead is not NULL
- //
- ASSERT(ListHead != NULL);
-
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellProtocol != NULL) {
- return (gEfiShellProtocol->FreeFileList(ListHead));
- } else if (mEfiShellEnvironment2 != NULL) {
- //
- // Since this is EFI Shell version we need to free our internally made copy
- // of the list
- //
- for ( Node = GetFirstNode(&(*ListHead)->Link)
- ; *ListHead != NULL && !IsListEmpty(&(*ListHead)->Link)
- ; Node = GetFirstNode(&(*ListHead)->Link)) {
- RemoveEntryList(Node);
- ((EFI_FILE_PROTOCOL*)((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle)->Close(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle);
- FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FullName);
- FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FileName);
- FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Info);
- FreePool((EFI_SHELL_FILE_INFO_NO_CONST*)Node);
- }
- SHELL_FREE_NON_NULL(*ListHead);
- return EFI_SUCCESS;
- }
-
- return (EFI_UNSUPPORTED);
-}
-
-/**
- Find a file by searching the CWD and then the path.
-
- If FileName is NULL then ASSERT.
-
- If the return value is not NULL then the memory must be caller freed.
-
- @param FileName Filename string.
-
- @retval NULL the file was not found
- @return !NULL the full path to the file.
-**/
-CHAR16 *
-EFIAPI
-ShellFindFilePath (
- IN CONST CHAR16 *FileName
- )
-{
- CONST CHAR16 *Path;
- SHELL_FILE_HANDLE Handle;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- CHAR16 *TestPath;
- CONST CHAR16 *Walker;
- UINTN Size;
- CHAR16 *TempChar;
-
- RetVal = NULL;
-
- //
- // First make sure its not an absolute path.
- //
- Status = ShellOpenFileByName(FileName, &Handle, EFI_FILE_MODE_READ, 0);
- if (!EFI_ERROR(Status)){
- if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
- ASSERT(RetVal == NULL);
- RetVal = StrnCatGrow(&RetVal, NULL, FileName, 0);
- ShellCloseFile(&Handle);
- return (RetVal);
- } else {
- ShellCloseFile(&Handle);
- }
- }
-
- Path = ShellGetEnvironmentVariable(L"cwd");
- if (Path != NULL) {
- Size = StrSize(Path);
- Size += StrSize(FileName);
- TestPath = AllocateZeroPool(Size);
- if (TestPath == NULL) {
- return (NULL);
- }
- StrCpyS(TestPath, Size/sizeof(CHAR16), Path);
- StrCatS(TestPath, Size/sizeof(CHAR16), FileName);
- Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);
- if (!EFI_ERROR(Status)){
- if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
- ASSERT(RetVal == NULL);
- RetVal = StrnCatGrow(&RetVal, NULL, TestPath, 0);
- ShellCloseFile(&Handle);
- FreePool(TestPath);
- return (RetVal);
- } else {
- ShellCloseFile(&Handle);
- }
- }
- FreePool(TestPath);
- }
- Path = ShellGetEnvironmentVariable(L"path");
- if (Path != NULL) {
- Size = StrSize(Path)+sizeof(CHAR16);
- Size += StrSize(FileName);
- TestPath = AllocateZeroPool(Size);
- if (TestPath == NULL) {
- return (NULL);
- }
- Walker = (CHAR16*)Path;
- do {
- CopyMem(TestPath, Walker, StrSize(Walker));
- if (TestPath != NULL) {
- TempChar = StrStr(TestPath, L";");
- if (TempChar != NULL) {
- *TempChar = CHAR_NULL;
- }
- if (TestPath[StrLen(TestPath)-1] != L'\\') {
- StrCatS(TestPath, Size/sizeof(CHAR16), L"\\");
- }
- if (FileName[0] == L'\\') {
- FileName++;
- }
- StrCatS(TestPath, Size/sizeof(CHAR16), FileName);
- if (StrStr(Walker, L";") != NULL) {
- Walker = StrStr(Walker, L";") + 1;
- } else {
- Walker = NULL;
- }
- Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);
- if (!EFI_ERROR(Status)){
- if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
- ASSERT(RetVal == NULL);
- RetVal = StrnCatGrow(&RetVal, NULL, TestPath, 0);
- ShellCloseFile(&Handle);
- break;
- } else {
- ShellCloseFile(&Handle);
- }
- }
- }
- } while (Walker != NULL && Walker[0] != CHAR_NULL);
- FreePool(TestPath);
- }
- return (RetVal);
-}
-
-/**
- Find a file by searching the CWD and then the path with a variable set of file
- extensions. If the file is not found it will append each extension in the list
- in the order provided and return the first one that is successful.
-
- If FileName is NULL, then ASSERT.
- If FileExtension is NULL, then behavior is identical to ShellFindFilePath.
-
- If the return value is not NULL then the memory must be caller freed.
-
- @param[in] FileName Filename string.
- @param[in] FileExtension Semi-colon delimeted list of possible extensions.
-
- @retval NULL The file was not found.
- @retval !NULL The path to the file.
-**/
-CHAR16 *
-EFIAPI
-ShellFindFilePathEx (
- IN CONST CHAR16 *FileName,
- IN CONST CHAR16 *FileExtension
- )
-{
- CHAR16 *TestPath;
- CHAR16 *RetVal;
- CONST CHAR16 *ExtensionWalker;
- UINTN Size;
- CHAR16 *TempChar;
- CHAR16 *TempChar2;
-
- ASSERT(FileName != NULL);
- if (FileExtension == NULL) {
- return (ShellFindFilePath(FileName));
- }
- RetVal = ShellFindFilePath(FileName);
- if (RetVal != NULL) {
- return (RetVal);
- }
- Size = StrSize(FileName);
- Size += StrSize(FileExtension);
- TestPath = AllocateZeroPool(Size);
- if (TestPath == NULL) {
- return (NULL);
- }
- for (ExtensionWalker = FileExtension, TempChar2 = (CHAR16*)FileExtension; TempChar2 != NULL ; ExtensionWalker = TempChar2 + 1){
- StrCpyS(TestPath, Size/sizeof(CHAR16), FileName);
- if (ExtensionWalker != NULL) {
- StrCatS(TestPath, Size/sizeof(CHAR16), ExtensionWalker);
- }
- TempChar = StrStr(TestPath, L";");
- if (TempChar != NULL) {
- *TempChar = CHAR_NULL;
- }
- RetVal = ShellFindFilePath(TestPath);
- if (RetVal != NULL) {
- break;
- }
- ASSERT(ExtensionWalker != NULL);
- TempChar2 = StrStr(ExtensionWalker, L";");
- }
- FreePool(TestPath);
- return (RetVal);
-}
-
-typedef struct {
- LIST_ENTRY Link;
- CHAR16 *Name;
- SHELL_PARAM_TYPE Type;
- CHAR16 *Value;
- UINTN OriginalPosition;
-} SHELL_PARAM_PACKAGE;
-
-/**
- Checks the list of valid arguments and returns TRUE if the item was found. If the
- return value is TRUE then the type parameter is set also.
-
- if CheckList is NULL then ASSERT();
- if Name is NULL then ASSERT();
- if Type is NULL then ASSERT();
-
- @param Name pointer to Name of parameter found
- @param CheckList List to check against
- @param Type pointer to type of parameter if it was found
-
- @retval TRUE the Parameter was found. Type is valid.
- @retval FALSE the Parameter was not found. Type is not valid.
-**/
-BOOLEAN
-EFIAPI
-InternalIsOnCheckList (
- IN CONST CHAR16 *Name,
- IN CONST SHELL_PARAM_ITEM *CheckList,
- OUT SHELL_PARAM_TYPE *Type
- )
-{
- SHELL_PARAM_ITEM *TempListItem;
- CHAR16 *TempString;
-
- //
- // ASSERT that all 3 pointer parameters aren't NULL
- //
- ASSERT(CheckList != NULL);
- ASSERT(Type != NULL);
- ASSERT(Name != NULL);
-
- //
- // question mark and page break mode are always supported
- //
- if ((StrCmp(Name, L"-?") == 0) ||
- (StrCmp(Name, L"-b") == 0)
- ) {
- *Type = TypeFlag;
- return (TRUE);
- }
-
- //
- // Enumerate through the list
- //
- for (TempListItem = (SHELL_PARAM_ITEM*)CheckList ; TempListItem->Name != NULL ; TempListItem++) {
- //
- // If the Type is TypeStart only check the first characters of the passed in param
- // If it matches set the type and return TRUE
- //
- if (TempListItem->Type == TypeStart) {
- if (StrnCmp(Name, TempListItem->Name, StrLen(TempListItem->Name)) == 0) {
- *Type = TempListItem->Type;
- return (TRUE);
- }
- TempString = NULL;
- TempString = StrnCatGrow(&TempString, NULL, Name, StrLen(TempListItem->Name));
- if (TempString != NULL) {
- if (StringNoCaseCompare(&TempString, &TempListItem->Name) == 0) {
- *Type = TempListItem->Type;
- FreePool(TempString);
- return (TRUE);
- }
- FreePool(TempString);
- }
- } else if (StringNoCaseCompare(&Name, &TempListItem->Name) == 0) {
- *Type = TempListItem->Type;
- return (TRUE);
- }
- }
-
- return (FALSE);
-}
-/**
- Checks the string for indicators of "flag" status. this is a leading '/', '-', or '+'
-
- @param[in] Name pointer to Name of parameter found
- @param[in] AlwaysAllowNumbers TRUE to allow numbers, FALSE to not.
- @param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
-
- @retval TRUE the Parameter is a flag.
- @retval FALSE the Parameter not a flag.
-**/
-BOOLEAN
-EFIAPI
-InternalIsFlag (
- IN CONST CHAR16 *Name,
- IN CONST BOOLEAN AlwaysAllowNumbers,
- IN CONST BOOLEAN TimeNumbers
- )
-{
- //
- // ASSERT that Name isn't NULL
- //
- ASSERT(Name != NULL);
-
- //
- // If we accept numbers then dont return TRUE. (they will be values)
- //
- if (((Name[0] == L'-' || Name[0] == L'+') && InternalShellIsHexOrDecimalNumber(Name+1, FALSE, FALSE, TimeNumbers)) && AlwaysAllowNumbers) {
- return (FALSE);
- }
-
- //
- // If the Name has a /, +, or - as the first character return TRUE
- //
- if ((Name[0] == L'/') ||
- (Name[0] == L'-') ||
- (Name[0] == L'+')
- ) {
- return (TRUE);
- }
- return (FALSE);
-}
-
-/**
- Checks the command line arguments passed against the list of valid ones.
-
- If no initialization is required, then return RETURN_SUCCESS.
-
- @param[in] CheckList pointer to list of parameters to check
- @param[out] CheckPackage pointer to pointer to list checked values
- @param[out] ProblemParam optional pointer to pointer to unicode string for
- the paramater that caused failure. If used then the
- caller is responsible for freeing the memory.
- @param[in] AutoPageBreak will automatically set PageBreakEnabled for "b" parameter
- @param[in] Argv pointer to array of parameters
- @param[in] Argc Count of parameters in Argv
- @param[in] AlwaysAllowNumbers TRUE to allow numbers always, FALSE otherwise.
-
- @retval EFI_SUCCESS The operation completed sucessfully.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed
- @retval EFI_INVALID_PARAMETER A parameter was invalid
- @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was
- duplicated. the duplicated command line argument
- was returned in ProblemParam if provided.
- @retval EFI_NOT_FOUND a argument required a value that was missing.
- the invalid command line argument was returned in
- ProblemParam if provided.
-**/
-EFI_STATUS
-EFIAPI
-InternalCommandLineParse (
- IN CONST SHELL_PARAM_ITEM *CheckList,
- OUT LIST_ENTRY **CheckPackage,
- OUT CHAR16 **ProblemParam OPTIONAL,
- IN BOOLEAN AutoPageBreak,
- IN CONST CHAR16 **Argv,
- IN UINTN Argc,
- IN BOOLEAN AlwaysAllowNumbers
- )
-{
- UINTN LoopCounter;
- SHELL_PARAM_TYPE CurrentItemType;
- SHELL_PARAM_PACKAGE *CurrentItemPackage;
- UINTN GetItemValue;
- UINTN ValueSize;
- UINTN Count;
- CONST CHAR16 *TempPointer;
- UINTN CurrentValueSize;
-
- CurrentItemPackage = NULL;
- GetItemValue = 0;
- ValueSize = 0;
- Count = 0;
-
- //
- // If there is only 1 item we dont need to do anything
- //
- if (Argc < 1) {
- *CheckPackage = NULL;
- return (EFI_SUCCESS);
- }
-
- //
- // ASSERTs
- //
- ASSERT(CheckList != NULL);
- ASSERT(Argv != NULL);
-
- //
- // initialize the linked list
- //
- *CheckPackage = (LIST_ENTRY*)AllocateZeroPool(sizeof(LIST_ENTRY));
- if (*CheckPackage == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
-
- InitializeListHead(*CheckPackage);
-
- //
- // loop through each of the arguments
- //
- for (LoopCounter = 0 ; LoopCounter < Argc ; ++LoopCounter) {
- if (Argv[LoopCounter] == NULL) {
- //
- // do nothing for NULL argv
- //
- } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType)) {
- //
- // We might have leftover if last parameter didnt have optional value
- //
- if (GetItemValue != 0) {
- GetItemValue = 0;
- InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
- }
- //
- // this is a flag
- //
- CurrentItemPackage = AllocateZeroPool(sizeof(SHELL_PARAM_PACKAGE));
- if (CurrentItemPackage == NULL) {
- ShellCommandLineFreeVarList(*CheckPackage);
- *CheckPackage = NULL;
- return (EFI_OUT_OF_RESOURCES);
- }
- CurrentItemPackage->Name = AllocateCopyPool(StrSize(Argv[LoopCounter]), Argv[LoopCounter]);
- if (CurrentItemPackage->Name == NULL) {
- ShellCommandLineFreeVarList(*CheckPackage);
- *CheckPackage = NULL;
- return (EFI_OUT_OF_RESOURCES);
- }
- CurrentItemPackage->Type = CurrentItemType;
- CurrentItemPackage->OriginalPosition = (UINTN)(-1);
- CurrentItemPackage->Value = NULL;
-
- //
- // Does this flag require a value
- //
- switch (CurrentItemPackage->Type) {
- //
- // possibly trigger the next loop(s) to populate the value of this item
- //
- case TypeValue:
- case TypeTimeValue:
- GetItemValue = 1;
- ValueSize = 0;
- break;
- case TypeDoubleValue:
- GetItemValue = 2;
- ValueSize = 0;
- break;
- case TypeMaxValue:
- GetItemValue = (UINTN)(-1);
- ValueSize = 0;
- break;
- default:
- //
- // this item has no value expected; we are done
- //
- InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
- ASSERT(GetItemValue == 0);
- break;
- }
- } else if (GetItemValue != 0 && CurrentItemPackage != NULL && !InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, (BOOLEAN)(CurrentItemPackage->Type == TypeTimeValue))) {
- //
- // get the item VALUE for a previous flag
- //
- CurrentValueSize = ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
- CurrentItemPackage->Value = ReallocatePool(ValueSize, CurrentValueSize, CurrentItemPackage->Value);
- ASSERT(CurrentItemPackage->Value != NULL);
- if (ValueSize == 0) {
- StrCpyS( CurrentItemPackage->Value,
- CurrentValueSize/sizeof(CHAR16),
- Argv[LoopCounter]
- );
- } else {
- StrCatS( CurrentItemPackage->Value,
- CurrentValueSize/sizeof(CHAR16),
- L" "
- );
- StrCatS( CurrentItemPackage->Value,
- CurrentValueSize/sizeof(CHAR16),
- Argv[LoopCounter]
- );
- }
- ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
-
- GetItemValue--;
- if (GetItemValue == 0) {
- InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
- }
- } else if (!InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, FALSE)){
- //
- // add this one as a non-flag
- //
-
- TempPointer = Argv[LoopCounter];
- if ((*TempPointer == L'^' && *(TempPointer+1) == L'-')
- || (*TempPointer == L'^' && *(TempPointer+1) == L'/')
- || (*TempPointer == L'^' && *(TempPointer+1) == L'+')
- ){
- TempPointer++;
- }
- CurrentItemPackage = AllocateZeroPool(sizeof(SHELL_PARAM_PACKAGE));
- if (CurrentItemPackage == NULL) {
- ShellCommandLineFreeVarList(*CheckPackage);
- *CheckPackage = NULL;
- return (EFI_OUT_OF_RESOURCES);
- }
- CurrentItemPackage->Name = NULL;
- CurrentItemPackage->Type = TypePosition;
- CurrentItemPackage->Value = AllocateCopyPool(StrSize(TempPointer), TempPointer);
- if (CurrentItemPackage->Value == NULL) {
- ShellCommandLineFreeVarList(*CheckPackage);
- *CheckPackage = NULL;
- return (EFI_OUT_OF_RESOURCES);
- }
- CurrentItemPackage->OriginalPosition = Count++;
- InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
- } else {
- //
- // this was a non-recognised flag... error!
- //
- if (ProblemParam != NULL) {
- *ProblemParam = AllocateCopyPool(StrSize(Argv[LoopCounter]), Argv[LoopCounter]);
- }
- ShellCommandLineFreeVarList(*CheckPackage);
- *CheckPackage = NULL;
- return (EFI_VOLUME_CORRUPTED);
- }
- }
- if (GetItemValue != 0) {
- GetItemValue = 0;
- InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
- }
- //
- // support for AutoPageBreak
- //
- if (AutoPageBreak && ShellCommandLineGetFlag(*CheckPackage, L"-b")) {
- ShellSetPageBreakMode(TRUE);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Checks the command line arguments passed against the list of valid ones.
- Optionally removes NULL values first.
-
- If no initialization is required, then return RETURN_SUCCESS.
-
- @param[in] CheckList The pointer to list of parameters to check.
- @param[out] CheckPackage The package of checked values.
- @param[out] ProblemParam Optional pointer to pointer to unicode string for
- the paramater that caused failure.
- @param[in] AutoPageBreak Will automatically set PageBreakEnabled.
- @param[in] AlwaysAllowNumbers Will never fail for number based flags.
-
- @retval EFI_SUCCESS The operation completed sucessfully.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @retval EFI_VOLUME_CORRUPTED The command line was corrupt.
- @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One
- of the command line arguments was returned in
- ProblemParam if provided.
- @retval EFI_NOT_FOUND A argument required a value that was missing.
- The invalid command line argument was returned in
- ProblemParam if provided.
-**/
-EFI_STATUS
-EFIAPI
-ShellCommandLineParseEx (
- IN CONST SHELL_PARAM_ITEM *CheckList,
- OUT LIST_ENTRY **CheckPackage,
- OUT CHAR16 **ProblemParam OPTIONAL,
- IN BOOLEAN AutoPageBreak,
- IN BOOLEAN AlwaysAllowNumbers
- )
-{
- //
- // ASSERT that CheckList and CheckPackage aren't NULL
- //
- ASSERT(CheckList != NULL);
- ASSERT(CheckPackage != NULL);
-
- //
- // Check for UEFI Shell 2.0 protocols
- //
- if (gEfiShellParametersProtocol != NULL) {
- return (InternalCommandLineParse(CheckList,
- CheckPackage,
- ProblemParam,
- AutoPageBreak,
- (CONST CHAR16**) gEfiShellParametersProtocol->Argv,
- gEfiShellParametersProtocol->Argc,
- AlwaysAllowNumbers));
- }
-
- //
- // ASSERT That EFI Shell is not required
- //
- ASSERT (mEfiShellInterface != NULL);
- return (InternalCommandLineParse(CheckList,
- CheckPackage,
- ProblemParam,
- AutoPageBreak,
- (CONST CHAR16**) mEfiShellInterface->Argv,
- mEfiShellInterface->Argc,
- AlwaysAllowNumbers));
-}
-
-/**
- Frees shell variable list that was returned from ShellCommandLineParse.
-
- This function will free all the memory that was used for the CheckPackage
- list of postprocessed shell arguments.
-
- this function has no return value.
-
- if CheckPackage is NULL, then return
-
- @param CheckPackage the list to de-allocate
- **/
-VOID
-EFIAPI
-ShellCommandLineFreeVarList (
- IN LIST_ENTRY *CheckPackage
- )
-{
- LIST_ENTRY *Node;
-
- //
- // check for CheckPackage == NULL
- //
- if (CheckPackage == NULL) {
- return;
- }
-
- //
- // for each node in the list
- //
- for ( Node = GetFirstNode(CheckPackage)
- ; !IsListEmpty(CheckPackage)
- ; Node = GetFirstNode(CheckPackage)
- ){
- //
- // Remove it from the list
- //
- RemoveEntryList(Node);
-
- //
- // if it has a name free the name
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {
- FreePool(((SHELL_PARAM_PACKAGE*)Node)->Name);
- }
-
- //
- // if it has a value free the value
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Value != NULL) {
- FreePool(((SHELL_PARAM_PACKAGE*)Node)->Value);
- }
-
- //
- // free the node structure
- //
- FreePool((SHELL_PARAM_PACKAGE*)Node);
- }
- //
- // free the list head node
- //
- FreePool(CheckPackage);
-}
-/**
- Checks for presence of a flag parameter
-
- flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key
-
- if CheckPackage is NULL then return FALSE.
- if KeyString is NULL then ASSERT()
-
- @param CheckPackage The package of parsed command line arguments
- @param KeyString the Key of the command line argument to check for
-
- @retval TRUE the flag is on the command line
- @retval FALSE the flag is not on the command line
- **/
-BOOLEAN
-EFIAPI
-ShellCommandLineGetFlag (
- IN CONST LIST_ENTRY * CONST CheckPackage,
- IN CONST CHAR16 * CONST KeyString
- )
-{
- LIST_ENTRY *Node;
- CHAR16 *TempString;
-
- //
- // return FALSE for no package or KeyString is NULL
- //
- if (CheckPackage == NULL || KeyString == NULL) {
- return (FALSE);
- }
-
- //
- // enumerate through the list of parametrs
- //
- for ( Node = GetFirstNode(CheckPackage)
- ; !IsNull (CheckPackage, Node)
- ; Node = GetNextNode(CheckPackage, Node)
- ){
- //
- // If the Name matches, return TRUE (and there may be NULL name)
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {
- //
- // If Type is TypeStart then only compare the begining of the strings
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Type == TypeStart) {
- if (StrnCmp(KeyString, ((SHELL_PARAM_PACKAGE*)Node)->Name, StrLen(KeyString)) == 0) {
- return (TRUE);
- }
- TempString = NULL;
- TempString = StrnCatGrow(&TempString, NULL, KeyString, StrLen(((SHELL_PARAM_PACKAGE*)Node)->Name));
- if (TempString != NULL) {
- if (StringNoCaseCompare(&KeyString, &((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {
- FreePool(TempString);
- return (TRUE);
- }
- FreePool(TempString);
- }
- } else if (StringNoCaseCompare(&KeyString, &((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {
- return (TRUE);
- }
- }
- }
- return (FALSE);
-}
-/**
- Returns value from command line argument.
-
- Value parameters are in the form of "-<Key> value" or "/<Key> value".
-
- If CheckPackage is NULL, then return NULL.
-
- @param[in] CheckPackage The package of parsed command line arguments.
- @param[in] KeyString The Key of the command line argument to check for.
-
- @retval NULL The flag is not on the command line.
- @retval !=NULL The pointer to unicode string of the value.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandLineGetValue (
- IN CONST LIST_ENTRY *CheckPackage,
- IN CHAR16 *KeyString
- )
-{
- LIST_ENTRY *Node;
- CHAR16 *TempString;
-
- //
- // return NULL for no package or KeyString is NULL
- //
- if (CheckPackage == NULL || KeyString == NULL) {
- return (NULL);
- }
-
- //
- // enumerate through the list of parametrs
- //
- for ( Node = GetFirstNode(CheckPackage)
- ; !IsNull (CheckPackage, Node)
- ; Node = GetNextNode(CheckPackage, Node)
- ){
- //
- // If the Name matches, return TRUE (and there may be NULL name)
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {
- //
- // If Type is TypeStart then only compare the begining of the strings
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->Type == TypeStart) {
- if (StrnCmp(KeyString, ((SHELL_PARAM_PACKAGE*)Node)->Name, StrLen(KeyString)) == 0) {
- return (((SHELL_PARAM_PACKAGE*)Node)->Name + StrLen(KeyString));
- }
- TempString = NULL;
- TempString = StrnCatGrow(&TempString, NULL, KeyString, StrLen(((SHELL_PARAM_PACKAGE*)Node)->Name));
- if (TempString != NULL) {
- if (StringNoCaseCompare(&KeyString, &((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {
- FreePool(TempString);
- return (((SHELL_PARAM_PACKAGE*)Node)->Name + StrLen(KeyString));
- }
- FreePool(TempString);
- }
- } else if (StringNoCaseCompare(&KeyString, &((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {
- return (((SHELL_PARAM_PACKAGE*)Node)->Value);
- }
- }
- }
- return (NULL);
-}
-
-/**
- Returns raw value from command line argument.
-
- Raw value parameters are in the form of "value" in a specific position in the list.
-
- If CheckPackage is NULL, then return NULL.
-
- @param[in] CheckPackage The package of parsed command line arguments.
- @param[in] Position The position of the value.
-
- @retval NULL The flag is not on the command line.
- @retval !=NULL The pointer to unicode string of the value.
- **/
-CONST CHAR16*
-EFIAPI
-ShellCommandLineGetRawValue (
- IN CONST LIST_ENTRY * CONST CheckPackage,
- IN UINTN Position
- )
-{
- LIST_ENTRY *Node;
-
- //
- // check for CheckPackage == NULL
- //
- if (CheckPackage == NULL) {
- return (NULL);
- }
-
- //
- // enumerate through the list of parametrs
- //
- for ( Node = GetFirstNode(CheckPackage)
- ; !IsNull (CheckPackage, Node)
- ; Node = GetNextNode(CheckPackage, Node)
- ){
- //
- // If the position matches, return the value
- //
- if (((SHELL_PARAM_PACKAGE*)Node)->OriginalPosition == Position) {
- return (((SHELL_PARAM_PACKAGE*)Node)->Value);
- }
- }
- return (NULL);
-}
-
-/**
- returns the number of command line value parameters that were parsed.
-
- this will not include flags.
-
- @param[in] CheckPackage The package of parsed command line arguments.
-
- @retval (UINTN)-1 No parsing has ocurred
- @return other The number of value parameters found
-**/
-UINTN
-EFIAPI
-ShellCommandLineGetCount(
- IN CONST LIST_ENTRY *CheckPackage
- )
-{
- LIST_ENTRY *Node1;
- UINTN Count;
-
- if (CheckPackage == NULL) {
- return (0);
- }
- for ( Node1 = GetFirstNode(CheckPackage), Count = 0
- ; !IsNull (CheckPackage, Node1)
- ; Node1 = GetNextNode(CheckPackage, Node1)
- ){
- if (((SHELL_PARAM_PACKAGE*)Node1)->Name == NULL) {
- Count++;
- }
- }
- return (Count);
-}
-
-/**
- Determines if a parameter is duplicated.
-
- If Param is not NULL then it will point to a callee allocated string buffer
- with the parameter value if a duplicate is found.
-
- If CheckPackage is NULL, then ASSERT.
-
- @param[in] CheckPackage The package of parsed command line arguments.
- @param[out] Param Upon finding one, a pointer to the duplicated parameter.
-
- @retval EFI_SUCCESS No parameters were duplicated.
- @retval EFI_DEVICE_ERROR A duplicate was found.
- **/
-EFI_STATUS
-EFIAPI
-ShellCommandLineCheckDuplicate (
- IN CONST LIST_ENTRY *CheckPackage,
- OUT CHAR16 **Param
- )
-{
- LIST_ENTRY *Node1;
- LIST_ENTRY *Node2;
-
- ASSERT(CheckPackage != NULL);
-
- for ( Node1 = GetFirstNode(CheckPackage)
- ; !IsNull (CheckPackage, Node1)
- ; Node1 = GetNextNode(CheckPackage, Node1)
- ){
- for ( Node2 = GetNextNode(CheckPackage, Node1)
- ; !IsNull (CheckPackage, Node2)
- ; Node2 = GetNextNode(CheckPackage, Node2)
- ){
- if ((((SHELL_PARAM_PACKAGE*)Node1)->Name != NULL) && (((SHELL_PARAM_PACKAGE*)Node2)->Name != NULL) && StrCmp(((SHELL_PARAM_PACKAGE*)Node1)->Name, ((SHELL_PARAM_PACKAGE*)Node2)->Name) == 0) {
- if (Param != NULL) {
- *Param = NULL;
- *Param = StrnCatGrow(Param, NULL, ((SHELL_PARAM_PACKAGE*)Node1)->Name, 0);
- }
- return (EFI_DEVICE_ERROR);
- }
- }
- }
- return (EFI_SUCCESS);
-}
-
-/**
- This is a find and replace function. Upon successful return the NewString is a copy of
- SourceString with each instance of FindTarget replaced with ReplaceWith.
-
- If SourceString and NewString overlap the behavior is undefined.
-
- If the string would grow bigger than NewSize it will halt and return error.
-
- @param[in] SourceString The string with source buffer.
- @param[in, out] NewString The string with resultant buffer.
- @param[in] NewSize The size in bytes of NewString.
- @param[in] FindTarget The string to look for.
- @param[in] ReplaceWith The string to replace FindTarget with.
- @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'
- immediately before it.
- @param[in] ParameterReplacing If TRUE will add "" around items with spaces.
-
- @retval EFI_INVALID_PARAMETER SourceString was NULL.
- @retval EFI_INVALID_PARAMETER NewString was NULL.
- @retval EFI_INVALID_PARAMETER FindTarget was NULL.
- @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.
- @retval EFI_INVALID_PARAMETER FindTarget had length < 1.
- @retval EFI_INVALID_PARAMETER SourceString had length < 1.
- @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold
- the new string (truncation occurred).
- @retval EFI_SUCCESS The string was successfully copied with replacement.
-**/
-EFI_STATUS
-EFIAPI
-ShellCopySearchAndReplace(
- IN CHAR16 CONST *SourceString,
- IN OUT CHAR16 *NewString,
- IN UINTN NewSize,
- IN CONST CHAR16 *FindTarget,
- IN CONST CHAR16 *ReplaceWith,
- IN CONST BOOLEAN SkipPreCarrot,
- IN CONST BOOLEAN ParameterReplacing
- )
-{
- UINTN Size;
- CHAR16 *Replace;
-
- if ( (SourceString == NULL)
- || (NewString == NULL)
- || (FindTarget == NULL)
- || (ReplaceWith == NULL)
- || (StrLen(FindTarget) < 1)
- || (StrLen(SourceString) < 1)
- ){
- return (EFI_INVALID_PARAMETER);
- }
- Replace = NULL;
- if (StrStr(ReplaceWith, L" ") == NULL || !ParameterReplacing) {
- Replace = StrnCatGrow(&Replace, NULL, ReplaceWith, 0);
- } else {
- Replace = AllocateZeroPool(StrSize(ReplaceWith) + 2*sizeof(CHAR16));
- if (Replace != NULL) {
- UnicodeSPrint(Replace, StrSize(ReplaceWith) + 2*sizeof(CHAR16), L"\"%s\"", ReplaceWith);
- }
- }
- if (Replace == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- NewString = ZeroMem(NewString, NewSize);
- while (*SourceString != CHAR_NULL) {
- //
- // if we find the FindTarget and either Skip == FALSE or Skip and we
- // dont have a carrot do a replace...
- //
- if (StrnCmp(SourceString, FindTarget, StrLen(FindTarget)) == 0
- && ((SkipPreCarrot && *(SourceString-1) != L'^') || !SkipPreCarrot)
- ){
- SourceString += StrLen(FindTarget);
- Size = StrSize(NewString);
- if ((Size + (StrLen(Replace)*sizeof(CHAR16))) > NewSize) {
- FreePool(Replace);
- return (EFI_BUFFER_TOO_SMALL);
- }
- StrCatS(NewString, NewSize/sizeof(CHAR16), Replace);
- } else {
- Size = StrSize(NewString);
- if (Size + sizeof(CHAR16) > NewSize) {
- FreePool(Replace);
- return (EFI_BUFFER_TOO_SMALL);
- }
- StrnCatS(NewString, NewSize/sizeof(CHAR16), SourceString, 1);
- SourceString++;
- }
- }
- FreePool(Replace);
- return (EFI_SUCCESS);
-}
-
-/**
- Internal worker function to output a string.
-
- This function will output a string to the correct StdOut.
-
- @param[in] String The string to print out.
-
- @retval EFI_SUCCESS The operation was sucessful.
- @retval !EFI_SUCCESS The operation failed.
-**/
-EFI_STATUS
-EFIAPI
-InternalPrintTo (
- IN CONST CHAR16 *String
- )
-{
- UINTN Size;
- Size = StrSize(String) - sizeof(CHAR16);
- if (Size == 0) {
- return (EFI_SUCCESS);
- }
- if (gEfiShellParametersProtocol != NULL) {
- return (gEfiShellProtocol->WriteFile(gEfiShellParametersProtocol->StdOut, &Size, (VOID*)String));
- }
- if (mEfiShellInterface != NULL) {
- if (mEfiShellInterface->RedirArgc == 0) {
- //
- // Divide in half for old shell. Must be string length not size.
- //
- Size /=2; // Divide in half only when no redirection.
- }
- return (mEfiShellInterface->StdOut->Write(mEfiShellInterface->StdOut, &Size, (VOID*)String));
- }
- ASSERT(FALSE);
- return (EFI_UNSUPPORTED);
-}
-
-/**
- Print at a specific location on the screen.
-
- This function will move the cursor to a given screen location and print the specified string
-
- If -1 is specified for either the Row or Col the current screen location for BOTH
- will be used.
-
- if either Row or Col is out of range for the current console, then ASSERT
- if Format is NULL, then ASSERT
-
- In addition to the standard %-based flags as supported by UefiLib Print() this supports
- the following additional flags:
- %N - Set output attribute to normal
- %H - Set output attribute to highlight
- %E - Set output attribute to error
- %B - Set output attribute to blue color
- %V - Set output attribute to green color
-
- Note: The background color is controlled by the shell command cls.
-
- @param[in] Col the column to print at
- @param[in] Row the row to print at
- @param[in] Format the format string
- @param[in] Marker the marker for the variable argument list
-
- @return EFI_SUCCESS The operation was successful.
- @return EFI_DEVICE_ERROR The console device reported an error.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellPrintWorker(
- IN INT32 Col OPTIONAL,
- IN INT32 Row OPTIONAL,
- IN CONST CHAR16 *Format,
- IN VA_LIST Marker
- )
-{
- EFI_STATUS Status;
- CHAR16 *ResumeLocation;
- CHAR16 *FormatWalker;
- UINTN OriginalAttribute;
- CHAR16 *mPostReplaceFormat;
- CHAR16 *mPostReplaceFormat2;
-
- mPostReplaceFormat = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
- mPostReplaceFormat2 = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
-
- if (mPostReplaceFormat == NULL || mPostReplaceFormat2 == NULL) {
- SHELL_FREE_NON_NULL(mPostReplaceFormat);
- SHELL_FREE_NON_NULL(mPostReplaceFormat2);
- return (EFI_OUT_OF_RESOURCES);
- }
-
- Status = EFI_SUCCESS;
- OriginalAttribute = gST->ConOut->Mode->Attribute;
-
- //
- // Back and forth each time fixing up 1 of our flags...
- //
- Status = ShellCopySearchAndReplace(Format, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%N", L"%%N", FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
- Status = ShellCopySearchAndReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%E", L"%%E", FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
- Status = ShellCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%H", L"%%H", FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
- Status = ShellCopySearchAndReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%B", L"%%B", FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
- Status = ShellCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%V", L"%%V", FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
-
- //
- // Use the last buffer from replacing to print from...
- //
- UnicodeVSPrint (mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), mPostReplaceFormat, Marker);
-
- if (Col != -1 && Row != -1) {
- Status = gST->ConOut->SetCursorPosition(gST->ConOut, Col, Row);
- }
-
- FormatWalker = mPostReplaceFormat2;
- while (*FormatWalker != CHAR_NULL) {
- //
- // Find the next attribute change request
- //
- ResumeLocation = StrStr(FormatWalker, L"%");
- if (ResumeLocation != NULL) {
- *ResumeLocation = CHAR_NULL;
- }
- //
- // print the current FormatWalker string
- //
- if (StrLen(FormatWalker)>0) {
- Status = InternalPrintTo(FormatWalker);
- if (EFI_ERROR(Status)) {
- break;
- }
- }
-
- //
- // update the attribute
- //
- if (ResumeLocation != NULL) {
- if (*(ResumeLocation-1) == L'^') {
- //
- // Move cursor back 1 position to overwrite the ^
- //
- gST->ConOut->SetCursorPosition(gST->ConOut, gST->ConOut->Mode->CursorColumn - 1, gST->ConOut->Mode->CursorRow);
-
- //
- // Print a simple '%' symbol
- //
- Status = InternalPrintTo(L"%");
- ResumeLocation = ResumeLocation - 1;
- } else {
- switch (*(ResumeLocation+1)) {
- case (L'N'):
- gST->ConOut->SetAttribute(gST->ConOut, OriginalAttribute);
- break;
- case (L'E'):
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_YELLOW, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));
- break;
- case (L'H'):
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_WHITE, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));
- break;
- case (L'B'):
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_BLUE, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));
- break;
- case (L'V'):
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_GREEN, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));
- break;
- default:
- //
- // Print a simple '%' symbol
- //
- Status = InternalPrintTo(L"%");
- if (EFI_ERROR(Status)) {
- break;
- }
- ResumeLocation = ResumeLocation - 1;
- break;
- }
- }
- } else {
- //
- // reset to normal now...
- //
- break;
- }
-
- //
- // update FormatWalker to Resume + 2 (skip the % and the indicator)
- //
- FormatWalker = ResumeLocation + 2;
- }
-
- gST->ConOut->SetAttribute(gST->ConOut, OriginalAttribute);
-
- SHELL_FREE_NON_NULL(mPostReplaceFormat);
- SHELL_FREE_NON_NULL(mPostReplaceFormat2);
- return (Status);
-}
-
-/**
- Print at a specific location on the screen.
-
- This function will move the cursor to a given screen location and print the specified string.
-
- If -1 is specified for either the Row or Col the current screen location for BOTH
- will be used.
-
- If either Row or Col is out of range for the current console, then ASSERT.
- If Format is NULL, then ASSERT.
-
- In addition to the standard %-based flags as supported by UefiLib Print() this supports
- the following additional flags:
- %N - Set output attribute to normal
- %H - Set output attribute to highlight
- %E - Set output attribute to error
- %B - Set output attribute to blue color
- %V - Set output attribute to green color
-
- Note: The background color is controlled by the shell command cls.
-
- @param[in] Col the column to print at
- @param[in] Row the row to print at
- @param[in] Format the format string
- @param[in] ... The variable argument list.
-
- @return EFI_SUCCESS The printing was successful.
- @return EFI_DEVICE_ERROR The console device reported an error.
-**/
-EFI_STATUS
-EFIAPI
-ShellPrintEx(
- IN INT32 Col OPTIONAL,
- IN INT32 Row OPTIONAL,
- IN CONST CHAR16 *Format,
- ...
- )
-{
- VA_LIST Marker;
- EFI_STATUS RetVal;
- if (Format == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- VA_START (Marker, Format);
- RetVal = InternalShellPrintWorker(Col, Row, Format, Marker);
- VA_END(Marker);
- return(RetVal);
-}
-
-/**
- Print at a specific location on the screen.
-
- This function will move the cursor to a given screen location and print the specified string.
-
- If -1 is specified for either the Row or Col the current screen location for BOTH
- will be used.
-
- If either Row or Col is out of range for the current console, then ASSERT.
- If Format is NULL, then ASSERT.
-
- In addition to the standard %-based flags as supported by UefiLib Print() this supports
- the following additional flags:
- %N - Set output attribute to normal.
- %H - Set output attribute to highlight.
- %E - Set output attribute to error.
- %B - Set output attribute to blue color.
- %V - Set output attribute to green color.
-
- Note: The background color is controlled by the shell command cls.
-
- @param[in] Col The column to print at.
- @param[in] Row The row to print at.
- @param[in] Language The language of the string to retrieve. If this parameter
- is NULL, then the current platform language is used.
- @param[in] HiiFormatStringId The format string Id for getting from Hii.
- @param[in] HiiFormatHandle The format string Handle for getting from Hii.
- @param[in] ... The variable argument list.
-
- @return EFI_SUCCESS The printing was successful.
- @return EFI_DEVICE_ERROR The console device reported an error.
-**/
-EFI_STATUS
-EFIAPI
-ShellPrintHiiEx(
- IN INT32 Col OPTIONAL,
- IN INT32 Row OPTIONAL,
- IN CONST CHAR8 *Language OPTIONAL,
- IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
- ...
- )
-{
- VA_LIST Marker;
- CHAR16 *HiiFormatString;
- EFI_STATUS RetVal;
-
- VA_START (Marker, HiiFormatHandle);
- HiiFormatString = HiiGetString(HiiFormatHandle, HiiFormatStringId, Language);
- ASSERT(HiiFormatString != NULL);
-
- RetVal = InternalShellPrintWorker(Col, Row, HiiFormatString, Marker);
-
- SHELL_FREE_NON_NULL(HiiFormatString);
- VA_END(Marker);
-
- return (RetVal);
-}
-
-/**
- Function to determine if a given filename represents a file or a directory.
-
- @param[in] DirName Path to directory to test.
-
- @retval EFI_SUCCESS The Path represents a directory
- @retval EFI_NOT_FOUND The Path does not represent a directory
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @return The path failed to open
-**/
-EFI_STATUS
-EFIAPI
-ShellIsDirectory(
- IN CONST CHAR16 *DirName
- )
-{
- EFI_STATUS Status;
- SHELL_FILE_HANDLE Handle;
- CHAR16 *TempLocation;
- CHAR16 *TempLocation2;
-
- ASSERT(DirName != NULL);
-
- Handle = NULL;
- TempLocation = NULL;
-
- Status = ShellOpenFileByName(DirName, &Handle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- //
- // try good logic first.
- //
- if (gEfiShellProtocol != NULL) {
- TempLocation = StrnCatGrow(&TempLocation, NULL, DirName, 0);
- if (TempLocation == NULL) {
- ShellCloseFile(&Handle);
- return (EFI_OUT_OF_RESOURCES);
- }
- TempLocation2 = StrStr(TempLocation, L":");
- if (TempLocation2 != NULL && StrLen(StrStr(TempLocation, L":")) == 2) {
- *(TempLocation2+1) = CHAR_NULL;
- }
- if (gEfiShellProtocol->GetDevicePathFromMap(TempLocation) != NULL) {
- FreePool(TempLocation);
- return (EFI_SUCCESS);
- }
- FreePool(TempLocation);
- } else {
- //
- // probably a map name?!?!!?
- //
- TempLocation = StrStr(DirName, L"\\");
- if (TempLocation != NULL && *(TempLocation+1) == CHAR_NULL) {
- return (EFI_SUCCESS);
- }
- }
- return (Status);
- }
-
- if (FileHandleIsDirectory(Handle) == EFI_SUCCESS) {
- ShellCloseFile(&Handle);
- return (EFI_SUCCESS);
- }
- ShellCloseFile(&Handle);
- return (EFI_NOT_FOUND);
-}
-
-/**
- Function to determine if a given filename represents a file.
-
- @param[in] Name Path to file to test.
-
- @retval EFI_SUCCESS The Path represents a file.
- @retval EFI_NOT_FOUND The Path does not represent a file.
- @retval other The path failed to open.
-**/
-EFI_STATUS
-EFIAPI
-ShellIsFile(
- IN CONST CHAR16 *Name
- )
-{
- EFI_STATUS Status;
- SHELL_FILE_HANDLE Handle;
-
- ASSERT(Name != NULL);
-
- Handle = NULL;
-
- Status = ShellOpenFileByName(Name, &Handle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- return (Status);
- }
-
- if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
- ShellCloseFile(&Handle);
- return (EFI_SUCCESS);
- }
- ShellCloseFile(&Handle);
- return (EFI_NOT_FOUND);
-}
-
-/**
- Function to determine if a given filename represents a file.
-
- This will search the CWD and then the Path.
-
- If Name is NULL, then ASSERT.
-
- @param[in] Name Path to file to test.
-
- @retval EFI_SUCCESS The Path represents a file.
- @retval EFI_NOT_FOUND The Path does not represent a file.
- @retval other The path failed to open.
-**/
-EFI_STATUS
-EFIAPI
-ShellIsFileInPath(
- IN CONST CHAR16 *Name
- )
-{
- CHAR16 *NewName;
- EFI_STATUS Status;
-
- if (!EFI_ERROR(ShellIsFile(Name))) {
- return (EFI_SUCCESS);
- }
-
- NewName = ShellFindFilePath(Name);
- if (NewName == NULL) {
- return (EFI_NOT_FOUND);
- }
- Status = ShellIsFile(NewName);
- FreePool(NewName);
- return (Status);
-}
-
-/**
- Function return the number converted from a hex representation of a number.
-
- Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
- result. Use ShellConvertStringToUint64 instead.
-
- @param[in] String String representation of a number.
-
- @return The unsigned integer result of the conversion.
- @retval (UINTN)(-1) An error occured.
-**/
-UINTN
-EFIAPI
-ShellHexStrToUintn(
- IN CONST CHAR16 *String
- )
-{
- UINT64 RetVal;
-
- if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, TRUE, TRUE))) {
- return ((UINTN)RetVal);
- }
-
- return ((UINTN)(-1));
-}
-
-/**
- Function to determine whether a string is decimal or hex representation of a number
- and return the number converted from the string. Spaces are always skipped.
-
- @param[in] String String representation of a number
-
- @return the number
- @retval (UINTN)(-1) An error ocurred.
-**/
-UINTN
-EFIAPI
-ShellStrToUintn(
- IN CONST CHAR16 *String
- )
-{
- UINT64 RetVal;
- BOOLEAN Hex;
-
- Hex = FALSE;
-
- if (!InternalShellIsHexOrDecimalNumber(String, Hex, TRUE, FALSE)) {
- Hex = TRUE;
- }
-
- if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, Hex, TRUE))) {
- return ((UINTN)RetVal);
- }
- return ((UINTN)(-1));
-}
-
-/**
- Safely append with automatic string resizing given length of Destination and
- desired length of copy from Source.
-
- append the first D characters of Source to the end of Destination, where D is
- the lesser of Count and the StrLen() of Source. If appending those D characters
- will fit within Destination (whose Size is given as CurrentSize) and
- still leave room for a NULL terminator, then those characters are appended,
- starting at the original terminating NULL of Destination, and a new terminating
- NULL is appended.
-
- If appending D characters onto Destination will result in a overflow of the size
- given in CurrentSize the string will be grown such that the copy can be performed
- and CurrentSize will be updated to the new size.
-
- If Source is NULL, there is nothing to append, just return the current buffer in
- Destination.
-
- if Destination is NULL, then ASSERT()
- if Destination's current length (including NULL terminator) is already more then
- CurrentSize, then ASSERT()
-
- @param[in, out] Destination The String to append onto
- @param[in, out] CurrentSize on call the number of bytes in Destination. On
- return possibly the new size (still in bytes). if NULL
- then allocate whatever is needed.
- @param[in] Source The String to append from
- @param[in] Count Maximum number of characters to append. if 0 then
- all are appended.
-
- @return Destination return the resultant string.
-**/
-CHAR16*
-EFIAPI
-StrnCatGrow (
- IN OUT CHAR16 **Destination,
- IN OUT UINTN *CurrentSize,
- IN CONST CHAR16 *Source,
- IN UINTN Count
- )
-{
- UINTN DestinationStartSize;
- UINTN NewSize;
-
- //
- // ASSERTs
- //
- ASSERT(Destination != NULL);
-
- //
- // If there's nothing to do then just return Destination
- //
- if (Source == NULL) {
- return (*Destination);
- }
-
- //
- // allow for un-initialized pointers, based on size being 0
- //
- if (CurrentSize != NULL && *CurrentSize == 0) {
- *Destination = NULL;
- }
-
- //
- // allow for NULL pointers address as Destination
- //
- if (*Destination != NULL) {
- ASSERT(CurrentSize != 0);
- DestinationStartSize = StrSize(*Destination);
- ASSERT(DestinationStartSize <= *CurrentSize);
- } else {
- DestinationStartSize = 0;
-// ASSERT(*CurrentSize == 0);
- }
-
- //
- // Append all of Source?
- //
- if (Count == 0) {
- Count = StrLen(Source);
- }
-
- //
- // Test and grow if required
- //
- if (CurrentSize != NULL) {
- NewSize = *CurrentSize;
- if (NewSize < DestinationStartSize + (Count * sizeof(CHAR16))) {
- while (NewSize < (DestinationStartSize + (Count*sizeof(CHAR16)))) {
- NewSize += 2 * Count * sizeof(CHAR16);
- }
- *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);
- *CurrentSize = NewSize;
- }
- } else {
- NewSize = (Count+1)*sizeof(CHAR16);
- *Destination = AllocateZeroPool(NewSize);
- }
-
- //
- // Now use standard StrnCat on a big enough buffer
- //
- if (*Destination == NULL) {
- return (NULL);
- }
-
- StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);
- return *Destination;
-}
-
-/**
- Prompt the user and return the resultant answer to the requestor.
-
- This function will display the requested question on the shell prompt and then
- wait for an apropriate answer to be input from the console.
-
- if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue
- or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.
-
- if the SHELL_PROMPT_REQUEST_TYPE is ShellPromptResponseTypeFreeform then *Response is of type
- CHAR16*.
-
- In either case *Response must be callee freed if Response was not NULL;
-
- @param Type What type of question is asked. This is used to filter the input
- to prevent invalid answers to question.
- @param Prompt Pointer to string prompt to use to request input.
- @param Response Pointer to Response which will be populated upon return.
-
- @retval EFI_SUCCESS The operation was sucessful.
- @retval EFI_UNSUPPORTED The operation is not supported as requested.
- @retval EFI_INVALID_PARAMETER A parameter was invalid.
- @return other The operation failed.
-**/
-EFI_STATUS
-EFIAPI
-ShellPromptForResponse (
- IN SHELL_PROMPT_REQUEST_TYPE Type,
- IN CHAR16 *Prompt OPTIONAL,
- IN OUT VOID **Response OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- UINTN EventIndex;
- SHELL_PROMPT_RESPONSE *Resp;
- UINTN Size;
- CHAR16 *Buffer;
-
- Status = EFI_UNSUPPORTED;
- Resp = NULL;
- Buffer = NULL;
- Size = 0;
- if (Type != ShellPromptResponseTypeFreeform) {
- Resp = (SHELL_PROMPT_RESPONSE*)AllocateZeroPool(sizeof(SHELL_PROMPT_RESPONSE));
- if (Resp == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- }
-
- switch(Type) {
- case ShellPromptResponseTypeQuitContinue:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- //
- // wait for valid response
- //
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- if (Key.UnicodeChar == L'Q' || Key.UnicodeChar ==L'q') {
- *Resp = ShellPromptResponseQuit;
- } else {
- *Resp = ShellPromptResponseContinue;
- }
- break;
- case ShellPromptResponseTypeYesNoCancel:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- //
- // wait for valid response
- //
- *Resp = ShellPromptResponseMax;
- while (*Resp == ShellPromptResponseMax) {
- if (ShellGetExecutionBreakFlag()) {
- Status = EFI_ABORTED;
- break;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- switch (Key.UnicodeChar) {
- case L'Y':
- case L'y':
- *Resp = ShellPromptResponseYes;
- break;
- case L'N':
- case L'n':
- *Resp = ShellPromptResponseNo;
- break;
- case L'C':
- case L'c':
- *Resp = ShellPromptResponseCancel;
- break;
- }
- }
- break; case ShellPromptResponseTypeYesNoAllCancel:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- //
- // wait for valid response
- //
- *Resp = ShellPromptResponseMax;
- while (*Resp == ShellPromptResponseMax) {
- if (ShellGetExecutionBreakFlag()) {
- Status = EFI_ABORTED;
- break;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- switch (Key.UnicodeChar) {
- case L'Y':
- case L'y':
- *Resp = ShellPromptResponseYes;
- break;
- case L'N':
- case L'n':
- *Resp = ShellPromptResponseNo;
- break;
- case L'A':
- case L'a':
- *Resp = ShellPromptResponseAll;
- break;
- case L'C':
- case L'c':
- *Resp = ShellPromptResponseCancel;
- break;
- }
- }
- break;
- case ShellPromptResponseTypeEnterContinue:
- case ShellPromptResponseTypeAnyKeyContinue:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- //
- // wait for valid response
- //
- *Resp = ShellPromptResponseMax;
- while (*Resp == ShellPromptResponseMax) {
- if (ShellGetExecutionBreakFlag()) {
- Status = EFI_ABORTED;
- break;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- if (Type == ShellPromptResponseTypeEnterContinue) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- *Resp = ShellPromptResponseContinue;
- break;
- }
- }
- if (Type == ShellPromptResponseTypeAnyKeyContinue) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- ASSERT_EFI_ERROR(Status);
- *Resp = ShellPromptResponseContinue;
- break;
- }
- }
- break;
- case ShellPromptResponseTypeYesNo:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- //
- // wait for valid response
- //
- *Resp = ShellPromptResponseMax;
- while (*Resp == ShellPromptResponseMax) {
- if (ShellGetExecutionBreakFlag()) {
- Status = EFI_ABORTED;
- break;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- switch (Key.UnicodeChar) {
- case L'Y':
- case L'y':
- *Resp = ShellPromptResponseYes;
- break;
- case L'N':
- case L'n':
- *Resp = ShellPromptResponseNo;
- break;
- }
- }
- break;
- case ShellPromptResponseTypeFreeform:
- if (Prompt != NULL) {
- ShellPrintEx(-1, -1, L"%s", Prompt);
- }
- while(1) {
- if (ShellGetExecutionBreakFlag()) {
- Status = EFI_ABORTED;
- break;
- }
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (EFI_ERROR(Status)) {
- break;
- }
- ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- break;
- }
- ASSERT((Buffer == NULL && Size == 0) || (Buffer != NULL));
- StrnCatGrow(&Buffer, &Size, &Key.UnicodeChar, 1);
- }
- break;
- //
- // This is the location to add new prompt types.
- // If your new type loops remember to add ExecutionBreak support.
- //
- default:
- ASSERT(FALSE);
- }
-
- if (Response != NULL) {
- if (Resp != NULL) {
- *Response = Resp;
- } else if (Buffer != NULL) {
- *Response = Buffer;
- }
- } else {
- if (Resp != NULL) {
- FreePool(Resp);
- }
- if (Buffer != NULL) {
- FreePool(Buffer);
- }
- }
-
- ShellPrintEx(-1, -1, L"\r\n");
- return (Status);
-}
-
-/**
- Prompt the user and return the resultant answer to the requestor.
-
- This function is the same as ShellPromptForResponse, except that the prompt is
- automatically pulled from HII.
-
- @param Type What type of question is asked. This is used to filter the input
- to prevent invalid answers to question.
- @param[in] HiiFormatStringId The format string Id for getting from Hii.
- @param[in] HiiFormatHandle The format string Handle for getting from Hii.
- @param Response Pointer to Response which will be populated upon return.
-
- @retval EFI_SUCCESS the operation was sucessful.
- @return other the operation failed.
-
- @sa ShellPromptForResponse
-**/
-EFI_STATUS
-EFIAPI
-ShellPromptForResponseHii (
- IN SHELL_PROMPT_REQUEST_TYPE Type,
- IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
- IN OUT VOID **Response
- )
-{
- CHAR16 *Prompt;
- EFI_STATUS Status;
-
- Prompt = HiiGetString(HiiFormatHandle, HiiFormatStringId, NULL);
- Status = ShellPromptForResponse(Type, Prompt, Response);
- FreePool(Prompt);
- return (Status);
-}
-
-/**
- Function to determin if an entire string is a valid number.
-
- If Hex it must be preceeded with a 0x or has ForceHex, set TRUE.
-
- @param[in] String The string to evaluate.
- @param[in] ForceHex TRUE - always assume hex.
- @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
- @param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
-
- @retval TRUE It is all numeric (dec/hex) characters.
- @retval FALSE There is a non-numeric character.
-**/
-BOOLEAN
-EFIAPI
-InternalShellIsHexOrDecimalNumber (
- IN CONST CHAR16 *String,
- IN CONST BOOLEAN ForceHex,
- IN CONST BOOLEAN StopAtSpace,
- IN CONST BOOLEAN TimeNumbers
- )
-{
- BOOLEAN Hex;
-
- //
- // chop off a single negative sign
- //
- if (String != NULL && *String == L'-') {
- String++;
- }
-
- if (String == NULL) {
- return (FALSE);
- }
-
- //
- // chop leading zeroes
- //
- while(String != NULL && *String == L'0'){
- String++;
- }
- //
- // allow '0x' or '0X', but not 'x' or 'X'
- //
- if (String != NULL && (*String == L'x' || *String == L'X')) {
- if (*(String-1) != L'0') {
- //
- // we got an x without a preceeding 0
- //
- return (FALSE);
- }
- String++;
- Hex = TRUE;
- } else if (ForceHex) {
- Hex = TRUE;
- } else {
- Hex = FALSE;
- }
-
- //
- // loop through the remaining characters and use the lib function
- //
- for ( ; String != NULL && *String != CHAR_NULL && !(StopAtSpace && *String == L' ') ; String++){
- if (TimeNumbers && (String[0] == L':')) {
- continue;
- }
- if (Hex) {
- if (!ShellIsHexaDecimalDigitCharacter(*String)) {
- return (FALSE);
- }
- } else {
- if (!ShellIsDecimalDigitCharacter(*String)) {
- return (FALSE);
- }
- }
- }
-
- return (TRUE);
-}
-
-/**
- Function to determine if a given filename exists.
-
- @param[in] Name Path to test.
-
- @retval EFI_SUCCESS The Path represents a file.
- @retval EFI_NOT_FOUND The Path does not represent a file.
- @retval other The path failed to open.
-**/
-EFI_STATUS
-EFIAPI
-ShellFileExists(
- IN CONST CHAR16 *Name
- )
-{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *List;
-
- ASSERT(Name != NULL);
-
- List = NULL;
- Status = ShellOpenFileMetaArg((CHAR16*)Name, EFI_FILE_MODE_READ, &List);
- if (EFI_ERROR(Status)) {
- return (Status);
- }
-
- ShellCloseFileMetaArg(&List);
-
- return (EFI_SUCCESS);
-}
-
-/**
- Convert a Unicode character to upper case only if
- it maps to a valid small-case ASCII character.
-
- This internal function only deal with Unicode character
- which maps to a valid small-case ASCII character, i.e.
- L'a' to L'z'. For other Unicode character, the input character
- is returned directly.
-
- @param Char The character to convert.
-
- @retval LowerCharacter If the Char is with range L'a' to L'z'.
- @retval Unchanged Otherwise.
-
-**/
-CHAR16
-EFIAPI
-InternalShellCharToUpper (
- IN CHAR16 Char
- )
-{
- if (Char >= L'a' && Char <= L'z') {
- return (CHAR16) (Char - (L'a' - L'A'));
- }
-
- return Char;
-}
-
-/**
- Convert a Unicode character to numerical value.
-
- This internal function only deal with Unicode character
- which maps to a valid hexadecimal ASII character, i.e.
- L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
- Unicode character, the value returned does not make sense.
-
- @param Char The character to convert.
-
- @return The numerical value converted.
-
-**/
-UINTN
-EFIAPI
-InternalShellHexCharToUintn (
- IN CHAR16 Char
- )
-{
- if (ShellIsDecimalDigitCharacter (Char)) {
- return Char - L'0';
- }
-
- return (UINTN) (10 + InternalShellCharToUpper (Char) - L'A');
-}
-
-/**
- Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
-
- This function returns a value of type UINT64 by interpreting the contents
- of the Unicode string specified by String as a hexadecimal number.
- The format of the input Unicode string String is:
-
- [spaces][zeros][x][hexadecimal digits].
-
- The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
- The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
- If "x" appears in the input string, it must be prefixed with at least one 0.
- The function will ignore the pad space, which includes spaces or tab characters,
- before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
- [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
- first valid hexadecimal digit. Then, the function stops at the first character that is
- a not a valid hexadecimal character or NULL, whichever one comes first.
-
- If String has only pad spaces, then zero is returned.
- If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
- then zero is returned.
-
- @param[in] String A pointer to a Null-terminated Unicode string.
- @param[out] Value Upon a successful return the value of the conversion.
- @param[in] StopAtSpace FALSE to skip spaces.
-
- @retval EFI_SUCCESS The conversion was successful.
- @retval EFI_INVALID_PARAMETER A parameter was NULL or invalid.
- @retval EFI_DEVICE_ERROR An overflow occured.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellStrHexToUint64 (
- IN CONST CHAR16 *String,
- OUT UINT64 *Value,
- IN CONST BOOLEAN StopAtSpace
- )
-{
- UINT64 Result;
-
- if (String == NULL || StrSize(String) == 0 || Value == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // Ignore the pad spaces (space or tab)
- //
- while ((*String == L' ') || (*String == L'\t')) {
- String++;
- }
-
- //
- // Ignore leading Zeros after the spaces
- //
- while (*String == L'0') {
- String++;
- }
-
- if (InternalShellCharToUpper (*String) == L'X') {
- if (*(String - 1) != L'0') {
- return 0;
- }
- //
- // Skip the 'X'
- //
- String++;
- }
-
- Result = 0;
-
- //
- // there is a space where there should't be
- //
- if (*String == L' ') {
- return (EFI_INVALID_PARAMETER);
- }
-
- while (ShellIsHexaDecimalDigitCharacter (*String)) {
- //
- // If the Hex Number represented by String overflows according
- // to the range defined by UINT64, then return EFI_DEVICE_ERROR.
- //
- if (!(Result <= (RShiftU64((((UINT64) ~0) - InternalShellHexCharToUintn (*String)), 4)))) {
-// if (!(Result <= ((((UINT64) ~0) - InternalShellHexCharToUintn (*String)) >> 4))) {
- return (EFI_DEVICE_ERROR);
- }
-
- Result = (LShiftU64(Result, 4));
- Result += InternalShellHexCharToUintn (*String);
- String++;
-
- //
- // stop at spaces if requested
- //
- if (StopAtSpace && *String == L' ') {
- break;
- }
- }
-
- *Value = Result;
- return (EFI_SUCCESS);
-}
-
-/**
- Convert a Null-terminated Unicode decimal string to a value of
- type UINT64.
-
- This function returns a value of type UINT64 by interpreting the contents
- of the Unicode string specified by String as a decimal number. The format
- of the input Unicode string String is:
-
- [spaces] [decimal digits].
-
- The valid decimal digit character is in the range [0-9]. The
- function will ignore the pad space, which includes spaces or
- tab characters, before [decimal digits]. The running zero in the
- beginning of [decimal digits] will be ignored. Then, the function
- stops at the first character that is a not a valid decimal character
- or a Null-terminator, whichever one comes first.
-
- If String has only pad spaces, then 0 is returned.
- If String has no pad spaces or valid decimal digits,
- then 0 is returned.
-
- @param[in] String A pointer to a Null-terminated Unicode string.
- @param[out] Value Upon a successful return the value of the conversion.
- @param[in] StopAtSpace FALSE to skip spaces.
-
- @retval EFI_SUCCESS The conversion was successful.
- @retval EFI_INVALID_PARAMETER A parameter was NULL or invalid.
- @retval EFI_DEVICE_ERROR An overflow occured.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellStrDecimalToUint64 (
- IN CONST CHAR16 *String,
- OUT UINT64 *Value,
- IN CONST BOOLEAN StopAtSpace
- )
-{
- UINT64 Result;
-
- if (String == NULL || StrSize (String) == 0 || Value == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // Ignore the pad spaces (space or tab)
- //
- while ((*String == L' ') || (*String == L'\t')) {
- String++;
- }
-
- //
- // Ignore leading Zeros after the spaces
- //
- while (*String == L'0') {
- String++;
- }
-
- Result = 0;
-
- //
- // Stop upon space if requested
- // (if the whole value was 0)
- //
- if (StopAtSpace && *String == L' ') {
- *Value = Result;
- return (EFI_SUCCESS);
- }
-
- while (ShellIsDecimalDigitCharacter (*String)) {
- //
- // If the number represented by String overflows according
- // to the range defined by UINT64, then return EFI_DEVICE_ERROR.
- //
-
- if (!(Result <= (DivU64x32((((UINT64) ~0) - (*String - L'0')),10)))) {
- return (EFI_DEVICE_ERROR);
- }
-
- Result = MultU64x32(Result, 10) + (*String - L'0');
- String++;
-
- //
- // Stop at spaces if requested
- //
- if (StopAtSpace && *String == L' ') {
- break;
- }
- }
-
- *Value = Result;
-
- return (EFI_SUCCESS);
-}
-
-/**
- Function to verify and convert a string to its numerical value.
-
- If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.
-
- @param[in] String The string to evaluate.
- @param[out] Value Upon a successful return the value of the conversion.
- @param[in] ForceHex TRUE - always assume hex.
- @param[in] StopAtSpace FALSE to skip spaces.
-
- @retval EFI_SUCCESS The conversion was successful.
- @retval EFI_INVALID_PARAMETER String contained an invalid character.
- @retval EFI_NOT_FOUND String was a number, but Value was NULL.
-**/
-EFI_STATUS
-EFIAPI
-ShellConvertStringToUint64(
- IN CONST CHAR16 *String,
- OUT UINT64 *Value,
- IN CONST BOOLEAN ForceHex,
- IN CONST BOOLEAN StopAtSpace
- )
-{
- UINT64 RetVal;
- CONST CHAR16 *Walker;
- EFI_STATUS Status;
- BOOLEAN Hex;
-
- Hex = ForceHex;
-
- if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {
- if (!Hex) {
- Hex = TRUE;
- if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {
- return (EFI_INVALID_PARAMETER);
- }
- } else {
- return (EFI_INVALID_PARAMETER);
- }
- }
-
- //
- // Chop off leading spaces
- //
- for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker++);
-
- //
- // make sure we have something left that is numeric.
- //
- if (Walker == NULL || *Walker == CHAR_NULL || !InternalShellIsHexOrDecimalNumber(Walker, Hex, StopAtSpace, FALSE)) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // do the conversion.
- //
- if (Hex || StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){
- Status = InternalShellStrHexToUint64(Walker, &RetVal, StopAtSpace);
- } else {
- Status = InternalShellStrDecimalToUint64(Walker, &RetVal, StopAtSpace);
- }
-
- if (Value == NULL && !EFI_ERROR(Status)) {
- return (EFI_NOT_FOUND);
- }
-
- if (Value != NULL) {
- *Value = RetVal;
- }
-
- return (Status);
-}
-
-/**
- Function to determin if an entire string is a valid number.
-
- If Hex it must be preceeded with a 0x or has ForceHex, set TRUE.
-
- @param[in] String The string to evaluate.
- @param[in] ForceHex TRUE - always assume hex.
- @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
-
- @retval TRUE It is all numeric (dec/hex) characters.
- @retval FALSE There is a non-numeric character.
-**/
-BOOLEAN
-EFIAPI
-ShellIsHexOrDecimalNumber (
- IN CONST CHAR16 *String,
- IN CONST BOOLEAN ForceHex,
- IN CONST BOOLEAN StopAtSpace
- )
-{
- if (ShellConvertStringToUint64(String, NULL, ForceHex, StopAtSpace) == EFI_NOT_FOUND) {
- return (TRUE);
- }
- return (FALSE);
-}
-
-/**
- Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned
- buffer. The returned buffer must be callee freed.
-
- If the position upon start is 0, then the Ascii Boolean will be set. This should be
- maintained and not changed for all operations with the same file.
-
- @param[in] Handle SHELL_FILE_HANDLE to read from.
- @param[in, out] Ascii Boolean value for indicating whether the file is
- Ascii (TRUE) or UCS2 (FALSE).
-
- @return The line of text from the file.
- @retval NULL There was not enough memory available.
-
- @sa ShellFileHandleReadLine
-**/
-CHAR16*
-EFIAPI
-ShellFileHandleReturnLine(
- IN SHELL_FILE_HANDLE Handle,
- IN OUT BOOLEAN *Ascii
- )
-{
- CHAR16 *RetVal;
- UINTN Size;
- EFI_STATUS Status;
-
- Size = 0;
- RetVal = NULL;
-
- Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- RetVal = AllocateZeroPool(Size);
- if (RetVal == NULL) {
- return (NULL);
- }
- Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
-
- }
- if (EFI_ERROR(Status) && (RetVal != NULL)) {
- FreePool(RetVal);
- RetVal = NULL;
- }
- return (RetVal);
-}
-
-/**
- Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.
-
- If the position upon start is 0, then the Ascii Boolean will be set. This should be
- maintained and not changed for all operations with the same file.
-
- @param[in] Handle SHELL_FILE_HANDLE to read from.
- @param[in, out] Buffer The pointer to buffer to read into.
- @param[in, out] Size The pointer to number of bytes in Buffer.
- @param[in] Truncate If the buffer is large enough, this has no effect.
- If the buffer is is too small and Truncate is TRUE,
- the line will be truncated.
- If the buffer is is too small and Truncate is FALSE,
- then no read will occur.
-
- @param[in, out] Ascii Boolean value for indicating whether the file is
- Ascii (TRUE) or UCS2 (FALSE).
-
- @retval EFI_SUCCESS The operation was successful. The line is stored in
- Buffer.
- @retval EFI_INVALID_PARAMETER Handle was NULL.
- @retval EFI_INVALID_PARAMETER Size was NULL.
- @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.
- Size was updated to the minimum space required.
-**/
-EFI_STATUS
-EFIAPI
-ShellFileHandleReadLine(
- IN SHELL_FILE_HANDLE Handle,
- IN OUT CHAR16 *Buffer,
- IN OUT UINTN *Size,
- IN BOOLEAN Truncate,
- IN OUT BOOLEAN *Ascii
- )
-{
- EFI_STATUS Status;
- CHAR16 CharBuffer;
- UINTN CharSize;
- UINTN CountSoFar;
- UINT64 OriginalFilePosition;
-
-
- if (Handle == NULL
- ||Size == NULL
- ){
- return (EFI_INVALID_PARAMETER);
- }
- if (Buffer == NULL) {
- ASSERT(*Size == 0);
- } else {
- *Buffer = CHAR_NULL;
- }
- gEfiShellProtocol->GetFilePosition(Handle, &OriginalFilePosition);
- if (OriginalFilePosition == 0) {
- CharSize = sizeof(CHAR16);
- Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);
- ASSERT_EFI_ERROR(Status);
- if (CharBuffer == gUnicodeFileTag) {
- *Ascii = FALSE;
- } else {
- *Ascii = TRUE;
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- }
- }
-
- for (CountSoFar = 0;;CountSoFar++){
- CharBuffer = 0;
- if (*Ascii) {
- CharSize = sizeof(CHAR8);
- } else {
- CharSize = sizeof(CHAR16);
- }
- Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);
- if ( EFI_ERROR(Status)
- || CharSize == 0
- || (CharBuffer == L'\n' && !(*Ascii))
- || (CharBuffer == '\n' && *Ascii)
- ){
- break;
- }
- //
- // if we have space save it...
- //
- if ((CountSoFar+1)*sizeof(CHAR16) < *Size){
- ASSERT(Buffer != NULL);
- ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
- ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
- }
- }
-
- //
- // if we ran out of space tell when...
- //
- if ((CountSoFar+1)*sizeof(CHAR16) > *Size){
- *Size = (CountSoFar+1)*sizeof(CHAR16);
- if (!Truncate) {
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- } else {
- DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));
- }
- return (EFI_BUFFER_TOO_SMALL);
- }
- while(Buffer[StrLen(Buffer)-1] == L'\r') {
- Buffer[StrLen(Buffer)-1] = CHAR_NULL;
- }
-
- return (Status);
-}
-
-/**
- Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.
-
- @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.
- @param[in] SectionToGetHelpOn Pointer to the section specifier(s).
- @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints
- the help content only.
- @retval EFI_DEVICE_ERROR The help data format was incorrect.
- @retval EFI_NOT_FOUND The help data could not be found.
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ShellPrintHelp (
- IN CONST CHAR16 *CommandToGetHelpOn,
- IN CONST CHAR16 *SectionToGetHelpOn,
- IN BOOLEAN PrintCommandText
- )
-{
- EFI_STATUS Status;
- CHAR16 *OutText;
-
- OutText = NULL;
-
- //
- // Get the string to print based
- //
- Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, SectionToGetHelpOn, &OutText);
-
- //
- // make sure we got a valid string
- //
- if (EFI_ERROR(Status)){
- return Status;
- }
- if (OutText == NULL || StrLen(OutText) == 0) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Chop off trailing stuff we dont need
- //
- while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
- OutText[StrLen(OutText)-1] = CHAR_NULL;
- }
-
- //
- // Print this out to the console
- //
- if (PrintCommandText) {
- ShellPrintEx(-1, -1, L"%H%-14s%N- %s\r\n", CommandToGetHelpOn, OutText);
- } else {
- ShellPrintEx(-1, -1, L"%N%s\r\n", OutText);
- }
-
- SHELL_FREE_NON_NULL(OutText);
-
- return EFI_SUCCESS;
-}
-
-/**
- Function to delete a file by name
-
- @param[in] FileName Pointer to file name to delete.
-
- @retval EFI_SUCCESS the file was deleted sucessfully
- @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not
- deleted
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_NOT_FOUND The specified file could not be found on the
- device or the file system could not be found
- on the device.
- @retval EFI_NO_MEDIA The device has no medium.
- @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
- medium is no longer supported.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
- @retval EFI_WRITE_PROTECTED The file or medium is write protected.
- @retval EFI_ACCESS_DENIED The file was opened read only.
- @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
- file.
- @retval other The file failed to open
-**/
-EFI_STATUS
-EFIAPI
-ShellDeleteFileByName(
- IN CONST CHAR16 *FileName
- )
-{
- EFI_STATUS Status;
- SHELL_FILE_HANDLE FileHandle;
-
- Status = ShellFileExists(FileName);
-
- if (Status == EFI_SUCCESS){
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0x0);
- if (Status == EFI_SUCCESS){
- Status = ShellDeleteFile(&FileHandle);
- }
- }
-
- return(Status);
-
-}
-
-/**
- Cleans off all the quotes in the string.
-
- @param[in] OriginalString pointer to the string to be cleaned.
- @param[out] CleanString The new string with all quotes removed.
- Memory allocated in the function and free
- by caller.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellStripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
- )
-{
- CHAR16 *Walker;
-
- if (OriginalString == NULL || CleanString == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);
- if (*CleanString == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
- if (*Walker == L'\"') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
- }
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.h b/ShellPkg/Library/UefiShellLib/UefiShellLib.h
deleted file mode 100644
index 3596f7b011..0000000000
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/** @file
- Provides interface to shell functionality for shell commands and applications.
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_LIB_INTERNAL_H_
-#define _UEFI_SHELL_LIB_INTERNAL_H_
-
-#include <Uefi.h>
-
-#include <Guid/FileInfo.h>
-
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/EfiShellInterface.h>
-#include <Protocol/EfiShellEnvironment2.h>
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiLib.h>
-#include <Library/HiiLib.h>
-#include <Library/ShellLib.h>
-
-typedef struct {
- EFI_SHELL_GET_FILE_INFO GetFileInfo;
- EFI_SHELL_SET_FILE_INFO SetFileInfo;
- EFI_SHELL_READ_FILE ReadFile;
- EFI_SHELL_WRITE_FILE WriteFile;
- EFI_SHELL_CLOSE_FILE CloseFile;
- EFI_SHELL_DELETE_FILE DeleteFile;
- EFI_SHELL_GET_FILE_POSITION GetFilePosition;
- EFI_SHELL_SET_FILE_POSITION SetFilePosition;
- EFI_SHELL_FLUSH_FILE FlushFile;
- EFI_SHELL_GET_FILE_SIZE GetFileSize;
-} FILE_HANDLE_FUNCTION_MAP;
-
-/**
- Function to determin if an entire string is a valid number.
-
- If Hex it must be preceeded with a 0x or has ForceHex, set TRUE.
-
- @param[in] String The string to evaluate.
- @param[in] ForceHex TRUE - always assume hex.
- @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
- @param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
-
- @retval TRUE It is all numeric (dec/hex) characters.
- @retval FALSE There is a non-numeric character.
-**/
-BOOLEAN
-EFIAPI
-InternalShellIsHexOrDecimalNumber (
- IN CONST CHAR16 *String,
- IN CONST BOOLEAN ForceHex,
- IN CONST BOOLEAN StopAtSpace,
- IN CONST BOOLEAN TimeNumbers
- );
-
-/**
- Cleans off all the quotes in the string.
-
- @param[in] OriginalString pointer to the string to be cleaned.
- @param[out] CleanString The new string with all quotes removed.
- Memory allocated in the function and free
- by caller.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-InternalShellStripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
- );
-
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf
deleted file mode 100644
index 6ed76cc2bc..0000000000
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file
-# Provides interface to shell functionality for shell commands and applications.
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellLib
- FILE_GUID = 449D0F00-2148-4a43-9836-F10B3980ECF5
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ShellLib|UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER DXE_DRIVER
- CONSTRUCTOR = ShellLibConstructor
- DESTRUCTOR = ShellLibDestructor
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- UefiShellLib.c
- UefiShellLib.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ShellPkg/ShellPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- MemoryAllocationLib
- DevicePathLib
- BaseLib
- BaseMemoryLib
- DebugLib
- FileHandleLib
- PrintLib
- UefiLib
- HiiLib
- SortLib
-
-[Protocols]
- gEfiSimpleFileSystemProtocolGuid ## CONSUMES
-
- # shell 2.0
- gEfiShellProtocolGuid ## SOMETIMES_CONSUMES
- gEfiShellParametersProtocolGuid ## SOMETIMES_CONSUMES
-
- # 'old' shell
- gEfiShellEnvironment2Guid ## SOMETIMES_CONSUMES
- gEfiShellInterfaceGuid ## SOMETIMES_CONSUMES
-
-[Guids]
- gEfiFileInfoGuid ## CONSUMES ## GUID
- gEfiShellEnvironment2ExtGuid ## CONSUMES ## GUID
-
-[Pcd.common]
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize ## CONSUMES
- gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize ## CONSUMES
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
deleted file mode 100644
index e16d46a8ec..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-/** @file
- The implementation for Shell command ifconfig based on IP4Config2 protocol.
-
- (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-
- 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 "UefiShellNetwork1CommandsLib.h"
-
-typedef enum {
- IfConfigOpList = 1,
- IfConfigOpSet = 2,
- IfConfigOpClear = 3
-} IFCONFIG_OPCODE;
-
-typedef enum {
- VarCheckReserved = -1,
- VarCheckOk = 0,
- VarCheckDuplicate,
- VarCheckConflict,
- VarCheckUnknown,
- VarCheckLackValue,
- VarCheckOutOfMem
-} VAR_CHECK_CODE;
-
-typedef enum {
- FlagTypeSingle = 0,
- FlagTypeNeedVar,
- FlagTypeNeedSet,
- FlagTypeSkipUnknown
-} VAR_CHECK_FLAG_TYPE;
-
-#define MACADDRMAXSIZE 32
-
-typedef struct _IFCONFIG_INTERFACE_CB {
- EFI_HANDLE NicHandle;
- LIST_ENTRY Link;
- EFI_IP4_CONFIG2_PROTOCOL *IfCfg;
- EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
- EFI_IP4_CONFIG2_POLICY Policy;
- UINT32 DnsCnt;
- EFI_IPv4_ADDRESS DnsAddr[1];
-} IFCONFIG_INTERFACE_CB;
-
-typedef struct _ARG_LIST ARG_LIST;
-
-struct _ARG_LIST {
- ARG_LIST *Next;
- CHAR16 *Arg;
-};
-
-typedef struct _IFCONFIG4_PRIVATE_DATA {
- LIST_ENTRY IfList;
-
- UINT32 OpCode;
- CHAR16 *IfName;
- ARG_LIST *VarArg;
-} IFCONFIG_PRIVATE_DATA;
-
-typedef struct _VAR_CHECK_ITEM{
- CHAR16 *FlagStr;
- UINT32 FlagID;
- UINT32 ConflictMask;
- VAR_CHECK_FLAG_TYPE FlagType;
-} VAR_CHECK_ITEM;
-
-SHELL_PARAM_ITEM mIfConfigCheckList[] = {
- {
- L"-b",
- TypeFlag
- },
- {
- L"-l",
- TypeValue
- },
- {
- L"-r",
- TypeValue
- },
- {
- L"-c",
- TypeValue
- },
- {
- L"-s",
- TypeMaxValue
- },
- {
- NULL,
- TypeMax
- },
-};
-
-VAR_CHECK_ITEM mSetCheckList[] = {
- {
- L"static",
- 0x00000001,
- 0x00000001,
- FlagTypeSingle
- },
- {
- L"dhcp",
- 0x00000002,
- 0x00000001,
- FlagTypeSingle
- },
- {
- L"dns",
- 0x00000008,
- 0x00000004,
- FlagTypeSingle
- },
- {
- NULL,
- 0x0,
- 0x0,
- FlagTypeSkipUnknown
- },
-};
-
-STATIC CONST CHAR16 PermanentString[10] = L"PERMANENT";
-
-/**
- Split a string with specified separator and save the substring to a list.
-
- @param[in] String The pointer of the input string.
- @param[in] Separator The specified separator.
-
- @return The pointer of headnode of ARG_LIST.
-
-**/
-ARG_LIST *
-SplitStrToList (
- IN CONST CHAR16 *String,
- IN CHAR16 Separator
- )
-{
- CHAR16 *Str;
- CHAR16 *ArgStr;
- ARG_LIST *ArgList;
- ARG_LIST *ArgNode;
-
- if (*String == L'\0') {
- return NULL;
- }
-
- //
- // Copy the CONST string to a local copy.
- //
- Str = AllocateCopyPool (StrSize (String), String);
- ASSERT (Str != NULL);
- ArgStr = Str;
-
- //
- // init a node for the list head.
- //
- ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
- ASSERT (ArgNode != NULL);
- ArgList = ArgNode;
-
- //
- // Split the local copy and save in the list node.
- //
- while (*Str != L'\0') {
- if (*Str == Separator) {
- *Str = L'\0';
- ArgNode->Arg = ArgStr;
- ArgStr = Str + 1;
- ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
- ASSERT (ArgNode->Next != NULL);
- ArgNode = ArgNode->Next;
- }
-
- Str++;
- }
-
- ArgNode->Arg = ArgStr;
- ArgNode->Next = NULL;
-
- return ArgList;
-}
-
-/**
- Check the correctness of input Args with '-s' option.
-
- @param[in] CheckList The pointer of VAR_CHECK_ITEM array.
- @param[in] Name The pointer of input arg.
- @param[in] Init The switch to execute the check.
-
- @return VarCheckOk Valid parameter or Initialize check successfully.
- @return VarCheckDuplicate Duplicated parameter happened.
- @return VarCheckConflict Conflicted parameter happened
- @return VarCheckUnknown Unknown parameter.
-
-**/
-VAR_CHECK_CODE
-IfConfigRetriveCheckListByName(
- IN VAR_CHECK_ITEM *CheckList,
- IN CHAR16 *Name,
- IN BOOLEAN Init
-)
-{
- STATIC UINT32 CheckDuplicate;
- STATIC UINT32 CheckConflict;
- VAR_CHECK_CODE RtCode;
- UINT32 Index;
- VAR_CHECK_ITEM Arg;
-
- if (Init) {
- CheckDuplicate = 0;
- CheckConflict = 0;
- return VarCheckOk;
- }
-
- RtCode = VarCheckOk;
- Index = 0;
- Arg = CheckList[Index];
-
- //
- // Check the Duplicated/Conflicted/Unknown input Args.
- //
- while (Arg.FlagStr != NULL) {
- if (StrCmp (Arg.FlagStr, Name) == 0) {
-
- if (CheckDuplicate & Arg.FlagID) {
- RtCode = VarCheckDuplicate;
- break;
- }
-
- if (CheckConflict & Arg.ConflictMask) {
- RtCode = VarCheckConflict;
- break;
- }
-
- CheckDuplicate |= Arg.FlagID;
- CheckConflict |= Arg.ConflictMask;
- break;
- }
-
- Arg = CheckList[++Index];
- }
-
- if (Arg.FlagStr == NULL) {
- RtCode = VarCheckUnknown;
- }
-
- return RtCode;
-}
-
-/**
- The notify function of create event when performing a manual config.
-
- @param[in] Event The event this notify function registered to.
- @param[in] Context Pointer to the context data registered to the event.
-
-**/
-VOID
-EFIAPI
-IfConfigManualAddressNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- *((BOOLEAN *) Context) = TRUE;
-}
-
-
-/**
- Create an IP child, use it to start the auto configuration, then destroy it.
-
- @param[in] Controller The controller which has the service installed.
- @param[in] Image The image handle used to open service.
-
- @retval EFI_SUCCESS The configuration is done.
-**/
-EFI_STATUS
-EFIAPI
-IfConfigStartIp4(
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Image
- )
-{
- EFI_IP4_PROTOCOL *Ip4;
- EFI_HANDLE Ip4Handle;
- EFI_IP4_CONFIG_DATA Ip4ConfigData;
- EFI_STATUS Status;
-
- //
- // Get the Ip4ServiceBinding Protocol
- //
- Ip4Handle = NULL;
- Ip4 = NULL;
-
- Status = NetLibCreateServiceChild (
- Controller,
- Image,
- &gEfiIp4ServiceBindingProtocolGuid,
- &Ip4Handle
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->OpenProtocol (
- Ip4Handle,
- &gEfiIp4ProtocolGuid,
- (VOID **) &Ip4,
- Controller,
- Image,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- Ip4ConfigData.DefaultProtocol = EFI_IP_PROTO_ICMP;
- Ip4ConfigData.AcceptAnyProtocol = FALSE;
- Ip4ConfigData.AcceptIcmpErrors = FALSE;
- Ip4ConfigData.AcceptBroadcast = FALSE;
- Ip4ConfigData.AcceptPromiscuous = FALSE;
- Ip4ConfigData.UseDefaultAddress = TRUE;
- ZeroMem (&Ip4ConfigData.StationAddress, sizeof (EFI_IPv4_ADDRESS));
- ZeroMem (&Ip4ConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
- Ip4ConfigData.TypeOfService = 0;
- Ip4ConfigData.TimeToLive = 1;
- Ip4ConfigData.DoNotFragment = FALSE;
- Ip4ConfigData.RawData = FALSE;
- Ip4ConfigData.ReceiveTimeout = 0;
- Ip4ConfigData.TransmitTimeout = 0;
-
- Ip4->Configure (Ip4, &Ip4ConfigData);
-
-ON_EXIT:
- NetLibDestroyServiceChild (
- Controller,
- Image,
- &gEfiIp4ServiceBindingProtocolGuid,
- Ip4Handle
- );
-
- return Status;
-}
-
-
-/**
- Print MAC address.
-
- @param[in] Node The pointer of MAC address buffer.
- @param[in] Size The size of MAC address buffer.
-
-**/
-VOID
-IfConfigPrintMacAddr (
- IN UINT8 *Node,
- IN UINT32 Size
- )
-{
- UINTN Index;
-
- ASSERT (Size <= MACADDRMAXSIZE);
-
- for (Index = 0; Index < Size; Index++) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MAC_ADDR_BODY), gShellNetwork1HiiHandle, Node[Index]);
- if (Index + 1 < Size) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_COLON), gShellNetwork1HiiHandle);
- }
- }
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_NEWLINE), gShellNetwork1HiiHandle);
-}
-
-
-/**
- The get current status of all handles.
-
- @param[in] IfName The pointer of IfName(interface name).
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The get status processed successfully.
- @retval others The get status process failed.
-
-**/
-EFI_STATUS
-IfConfigGetInterfaceInfo (
- IN CHAR16 *IfName,
- IN LIST_ENTRY *IfList
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- UINTN HandleNum;
- EFI_HANDLE *HandleBuffer;
- EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
- EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
- IFCONFIG_INTERFACE_CB *IfCb;
- UINTN DataSize;
-
- HandleBuffer = NULL;
- HandleNum = 0;
-
- IfInfo = NULL;
- IfCb = NULL;
-
- //
- // Locate all the handles with ip4 service binding protocol.
- //
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiIp4ServiceBindingProtocolGuid,
- NULL,
- &HandleNum,
- &HandleBuffer
- );
- if (EFI_ERROR (Status) || (HandleNum == 0)) {
- return EFI_ABORTED;
- }
-
- //
- // Enumerate all handles that installed with ip4 service binding protocol.
- //
- for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
- IfCb = NULL;
- IfInfo = NULL;
- DataSize = 0;
-
- //
- // Ip4config protocol and ip4 service binding protocol are installed
- // on the same handle.
- //
- ASSERT (HandleBuffer != NULL);
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- &gEfiIp4Config2ProtocolGuid,
- (VOID **) &Ip4Cfg2
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- //
- // Get the interface information size.
- //
- Status = Ip4Cfg2->GetData (
- Ip4Cfg2,
- Ip4Config2DataTypeInterfaceInfo,
- &DataSize,
- NULL
- );
-
- if (Status != EFI_BUFFER_TOO_SMALL) {
- goto ON_ERROR;
- }
-
- IfInfo = AllocateZeroPool (DataSize);
-
- if (IfInfo == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
-
- //
- // Get the interface info.
- //
- Status = Ip4Cfg2->GetData (
- Ip4Cfg2,
- Ip4Config2DataTypeInterfaceInfo,
- &DataSize,
- IfInfo
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- //
- // Check the interface name if required.
- //
- if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) != 0)) {
- FreePool (IfInfo);
- continue;
- }
-
- DataSize = 0;
-
- //
- // Get the size of dns server list.
- //
- Status = Ip4Cfg2->GetData (
- Ip4Cfg2,
- Ip4Config2DataTypeDnsServer,
- &DataSize,
- NULL
- );
-
- if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) {
- goto ON_ERROR;
- }
-
- IfCb = AllocateZeroPool (sizeof (IFCONFIG_INTERFACE_CB) + DataSize);
-
- if (IfCb == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
-
- IfCb->NicHandle = HandleBuffer[HandleIndex];
- IfCb->IfInfo = IfInfo;
- IfCb->IfCfg = Ip4Cfg2;
- IfCb->DnsCnt = (UINT32) (DataSize / sizeof (EFI_IPv4_ADDRESS));
-
- //
- // Get the dns server list if has.
- //
- if (DataSize > 0) {
- Status = Ip4Cfg2->GetData (
- Ip4Cfg2,
- Ip4Config2DataTypeDnsServer,
- &DataSize,
- IfCb->DnsAddr
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
- }
-
- //
- // Get the config policy.
- //
- DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
- Status = Ip4Cfg2->GetData (
- Ip4Cfg2,
- Ip4Config2DataTypePolicy,
- &DataSize,
- &IfCb->Policy
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- InsertTailList (IfList, &IfCb->Link);
-
- if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) == 0)) {
- //
- // Only need the appointed interface, keep the allocated buffer.
- //
- IfCb = NULL;
- IfInfo = NULL;
- break;
- }
- }
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- return EFI_SUCCESS;
-
-ON_ERROR:
-
- if (IfInfo != NULL) {
- FreePool (IfInfo);
- }
-
- if (IfCb != NULL) {
- FreePool (IfCb);
- }
-
- return Status;
-}
-
-/**
- The list process of the ifconfig command.
-
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The ifconfig command list processed successfully.
- @retval others The ifconfig command list process failed.
-
-**/
-EFI_STATUS
-IfConfigShowInterfaceInfo (
- IN LIST_ENTRY *IfList
- )
-{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IFCONFIG_INTERFACE_CB *IfCb;
- BOOLEAN MediaPresent;
- EFI_IPv4_ADDRESS Gateway;
- UINT32 Index;
-
- MediaPresent = TRUE;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
- }
-
- //
- // Go through the interface list.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, Next, IfList) {
- IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_BREAK), gShellNetwork1HiiHandle);
-
- //
- // Print interface name.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), gShellNetwork1HiiHandle, IfCb->IfInfo->Name);
-
- //
- // Get Media State.
- //
- NetLibDetectMedia (IfCb->NicHandle, &MediaPresent);
- if (!MediaPresent) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media disconnected");
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
- }
-
- //
- // Print interface config policy.
- //
- if (IfCb->Policy == Ip4Config2PolicyDhcp) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_POLICY_DHCP), gShellNetwork1HiiHandle);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_POLICY_MAN), gShellNetwork1HiiHandle);
- }
-
- //
- // Print mac address of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MAC_ADDR_HEAD), gShellNetwork1HiiHandle);
-
- IfConfigPrintMacAddr (
- IfCb->IfInfo->HwAddress.Addr,
- IfCb->IfInfo->HwAddressSize
- );
-
- //
- // Print IPv4 address list of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IP_ADDR_HEAD), gShellNetwork1HiiHandle);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_INFO_IP_ADDR_BODY),
- gShellNetwork1HiiHandle,
- (UINTN)IfCb->IfInfo->StationAddress.Addr[0],
- (UINTN)IfCb->IfInfo->StationAddress.Addr[1],
- (UINTN)IfCb->IfInfo->StationAddress.Addr[2],
- (UINTN)IfCb->IfInfo->StationAddress.Addr[3]
- );
-
- //
- // Print subnet mask list of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_SUBNET_MASK_HEAD), gShellNetwork1HiiHandle);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_INFO_IP_ADDR_BODY),
- gShellNetwork1HiiHandle,
- (UINTN)IfCb->IfInfo->SubnetMask.Addr[0],
- (UINTN)IfCb->IfInfo->SubnetMask.Addr[1],
- (UINTN)IfCb->IfInfo->SubnetMask.Addr[2],
- (UINTN)IfCb->IfInfo->SubnetMask.Addr[3]
- );
-
- //
- // Print default gateway of the interface.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_GATEWAY_HEAD), gShellNetwork1HiiHandle);
-
- ZeroMem (&Gateway, sizeof (EFI_IPv4_ADDRESS));
-
- for (Index = 0; Index < IfCb->IfInfo->RouteTableSize; Index++) {
- if ((CompareMem (&IfCb->IfInfo->RouteTable[Index].SubnetAddress, &mZeroIp4Addr, sizeof (EFI_IPv4_ADDRESS)) == 0) &&
- (CompareMem (&IfCb->IfInfo->RouteTable[Index].SubnetMask , &mZeroIp4Addr, sizeof (EFI_IPv4_ADDRESS)) == 0) ){
- CopyMem (&Gateway, &IfCb->IfInfo->RouteTable[Index].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
- }
- }
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_INFO_IP_ADDR_BODY),
- gShellNetwork1HiiHandle,
- (UINTN)Gateway.Addr[0],
- (UINTN)Gateway.Addr[1],
- (UINTN)Gateway.Addr[2],
- (UINTN)Gateway.Addr[3]
- );
-
- //
- // Print route table entry.
- //
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_ROUTES_SIZE), gShellNetwork1HiiHandle, IfCb->IfInfo->RouteTableSize);
-
- for (Index = 0; Index < IfCb->IfInfo->RouteTableSize; Index++) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_ROUTES_ENTRY_INDEX), gShellNetwork1HiiHandle, Index);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_SHOW_IP_ADDR),
- gShellNetwork1HiiHandle,
- L"Subnet ",
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetAddress.Addr[0],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetAddress.Addr[1],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetAddress.Addr[2],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetAddress.Addr[3]
- );
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_SHOW_IP_ADDR),
- gShellNetwork1HiiHandle,
- L"Netmask",
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetMask.Addr[0],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetMask.Addr[1],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetMask.Addr[2],
- (UINTN)IfCb->IfInfo->RouteTable[Index].SubnetMask.Addr[3]
- );
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_SHOW_IP_ADDR),
- gShellNetwork1HiiHandle,
- L"Gateway",
- (UINTN)IfCb->IfInfo->RouteTable[Index].GatewayAddress.Addr[0],
- (UINTN)IfCb->IfInfo->RouteTable[Index].GatewayAddress.Addr[1],
- (UINTN)IfCb->IfInfo->RouteTable[Index].GatewayAddress.Addr[2],
- (UINTN)IfCb->IfInfo->RouteTable[Index].GatewayAddress.Addr[3]
- );
- }
-
- //
- // Print dns server addresses list of the interface if has.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_DNS_ADDR_HEAD), gShellNetwork1HiiHandle);
-
- for (Index = 0; Index < IfCb->DnsCnt; Index++) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_IFCONFIG_INFO_DNS_ADDR_BODY),
- gShellNetwork1HiiHandle,
- (UINTN) IfCb->DnsAddr[Index].Addr[0],
- (UINTN) IfCb->DnsAddr[Index].Addr[1],
- (UINTN) IfCb->DnsAddr[Index].Addr[2],
- (UINTN) IfCb->DnsAddr[Index].Addr[3]
- );
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_NEWLINE), gShellNetwork1HiiHandle);
- }
- }
-
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_BREAK), gShellNetwork1HiiHandle);
-
- return EFI_SUCCESS;
-}
-
-/**
- The clean process of the ifconfig command to clear interface info.
-
- @param[in] IfList The pointer of IfList(interface list).
-
- @retval EFI_SUCCESS The ifconfig command clean processed successfully.
- @retval others The ifconfig command clean process failed.
-
-**/
-EFI_STATUS
-IfConfigClearInterfaceInfo (
- IN LIST_ENTRY *IfList
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IFCONFIG_INTERFACE_CB *IfCb;
- EFI_IP4_CONFIG2_POLICY Policy;
-
- Policy = Ip4Config2PolicyDhcp;
- Status = EFI_SUCCESS;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
- }
-
- //
- // Go through the interface list.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, Next, IfList) {
- IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
-
- if (EFI_ERROR (Status)) {
- break;
- }
- }
-
- return Status;
-}
-
-/**
- The set process of the ifconfig command.
-
- @param[in] IfList The pointer of IfList(interface list).
- @param[in] VarArg The pointer of ARG_LIST(Args with "-s" option).
-
- @retval EFI_SUCCESS The ifconfig command set processed successfully.
- @retval others The ifconfig command set process failed.
-
-**/
-EFI_STATUS
-IfConfigSetInterfaceInfo (
- IN LIST_ENTRY *IfList,
- IN ARG_LIST *VarArg
- )
-{
-
- EFI_STATUS Status;
- IFCONFIG_INTERFACE_CB *IfCb;
- VAR_CHECK_CODE CheckCode;
- EFI_EVENT TimeOutEvt;
- EFI_EVENT MappedEvt;
- BOOLEAN IsAddressOk;
-
- EFI_IP4_CONFIG2_POLICY Policy;
- EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress;
- UINTN DataSize;
- EFI_IPv4_ADDRESS Gateway;
- EFI_IPv4_ADDRESS *Dns;
- ARG_LIST *Tmp;
- UINTN Index;
-
- CONST CHAR16* TempString;
-
- Dns = NULL;
-
- if (IsListEmpty (IfList)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Make sure to set only one interface each time.
- //
- IfCb = NET_LIST_USER_STRUCT (IfList->ForwardLink, IFCONFIG_INTERFACE_CB, Link);
- Status = EFI_SUCCESS;
-
- //
- // Initialize check list mechanism.
- //
- CheckCode = IfConfigRetriveCheckListByName(
- NULL,
- NULL,
- TRUE
- );
-
- //
- // Create events & timers for asynchronous settings.
- //
- Status = gBS->CreateEvent (
- EVT_TIMER,
- TPL_CALLBACK,
- NULL,
- NULL,
- &TimeOutEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- IfConfigManualAddressNotify,
- &IsAddressOk,
- &MappedEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- //
- // Parse the setting variables.
- //
- while (VarArg != NULL) {
- //
- // Check invalid parameters (duplication & unknown & conflict).
- //
- CheckCode = IfConfigRetriveCheckListByName(
- mSetCheckList,
- VarArg->Arg,
- FALSE
- );
-
- if (VarCheckOk != CheckCode) {
- switch (CheckCode) {
- case VarCheckDuplicate:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_DUPLICATE_COMMAND), gShellNetwork1HiiHandle, VarArg->Arg);
- break;
-
- case VarCheckConflict:
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_CONFLICT_COMMAND), gShellNetwork1HiiHandle, VarArg->Arg);
- break;
-
- case VarCheckUnknown:
- //
- // To handle unsupported option.
- //
- TempString = PermanentString;
- if (StringNoCaseCompare(&VarArg->Arg, &TempString) == 0) {
- ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_UNSUPPORTED_OPTION), gShellNetwork1HiiHandle, PermanentString);
- goto ON_EXIT;
- }
-
- //
- // To handle unknown option.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_UNKNOWN_COMMAND), gShellNetwork1HiiHandle, VarArg->Arg);
- break;
-
- default:
- break;
- }
-
- VarArg = VarArg->Next;
- continue;
- }
-
- //
- // Process valid variables.
- //
- if (StrCmp(VarArg->Arg, L"dhcp") == 0) {
- if (IfCb->Policy == Ip4Config2PolicyDhcp) {
- Status = IfConfigStartIp4 (IfCb->NicHandle, gImageHandle);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- } else {
- //
- // Set dhcp config policy
- //
- Policy = Ip4Config2PolicyDhcp;
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- }
-
- VarArg= VarArg->Next;
-
- } else if (StrCmp (VarArg->Arg, L"static") == 0) {
- //
- // Set manual config policy.
- //
- Policy = Ip4Config2PolicyStatic;
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- VarArg= VarArg->Next;
-
- ZeroMem (&ManualAddress, sizeof (ManualAddress));
-
- //
- // Get manual IP address.
- //
- Status = NetLibStrToIp4 (VarArg->Arg, &ManualAddress.Address);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- //
- // Get subnetmask.
- //
- VarArg = VarArg->Next;
- Status = NetLibStrToIp4 (VarArg->Arg, &ManualAddress.SubnetMask);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- //
- // Get gateway.
- //
- VarArg = VarArg->Next;
- Status = NetLibStrToIp4 (VarArg->Arg, &Gateway);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
-
- IsAddressOk = FALSE;
-
- Status = IfCb->IfCfg->RegisterDataNotify (
- IfCb->IfCfg,
- Ip4Config2DataTypeManualAddress,
- MappedEvt
- );
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- DataSize = sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS);
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypeManualAddress,
- DataSize,
- &ManualAddress
- );
-
- if (Status == EFI_NOT_READY) {
- gBS->SetTimer (TimeOutEvt, TimerRelative, 50000000);
-
- while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
- if (IsAddressOk) {
- Status = EFI_SUCCESS;
- break;
- }
- }
- }
-
- IfCb->IfCfg->UnregisterDataNotify (
- IfCb->IfCfg,
- Ip4Config2DataTypeManualAddress,
- MappedEvt
- );
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_SET_ADDR_FAILED), gShellNetwork1HiiHandle, Status);
- goto ON_EXIT;
- }
-
- //
- // Set gateway.
- //
- DataSize = sizeof (EFI_IPv4_ADDRESS);
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypeGateway,
- DataSize,
- &Gateway
- );
- VarArg = VarArg->Next;
-
- } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
- //
- // Get DNS addresses.
- //
- VarArg = VarArg->Next;
- Tmp = VarArg;
- Index = 0;
- while (Tmp != NULL) {
- Index ++;
- Tmp = Tmp->Next;
- }
-
- Dns = AllocatePool (Index * sizeof (EFI_IPv4_ADDRESS));
- ASSERT(Dns != NULL);
- Tmp = VarArg;
- Index = 0;
- while (Tmp != NULL) {
- Status = NetLibStrToIp4 (Tmp->Arg, Dns + Index);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- Index ++;
- Tmp = Tmp->Next;
- }
-
- VarArg = Tmp;
-
- //
- // Set DNS addresses.
- //
- DataSize = Index * sizeof (EFI_IPv4_ADDRESS);
-
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypeDnsServer,
- DataSize,
- Dns
- );
- }
- }
-
-ON_EXIT:
- if (Dns != NULL) {
- FreePool (Dns);
- }
-
- return Status;
-
-}
-
-/**
- The ifconfig command main process.
-
- @param[in] Private The pointer of IFCONFIG_PRIVATE_DATA.
-
- @retval EFI_SUCCESS ifconfig command processed successfully.
- @retval others The ifconfig command process failed.
-
-**/
-EFI_STATUS
-IfConfig (
- IN IFCONFIG_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
-
- //
- // Get configure information of all interfaces.
- //
- Status = IfConfigGetInterfaceInfo (
- Private->IfName,
- &Private->IfList
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_EXIT;
- }
-
- switch (Private->OpCode) {
- case IfConfigOpList:
- Status = IfConfigShowInterfaceInfo (&Private->IfList);
- break;
-
- case IfConfigOpClear:
- Status = IfConfigClearInterfaceInfo (&Private->IfList);
- break;
-
- case IfConfigOpSet:
- Status = IfConfigSetInterfaceInfo (&Private->IfList, Private->VarArg);
- break;
-
- default:
- Status = EFI_ABORTED;
- }
-
-ON_EXIT:
-
- return Status;
-}
-
-/**
- The ifconfig command cleanup process, free the allocated memory.
-
- @param[in] Private The pointer of IFCONFIG_PRIVATE_DATA.
-
-**/
-VOID
-IfConfigCleanup (
- IN IFCONFIG_PRIVATE_DATA *Private
- )
-{
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- IFCONFIG_INTERFACE_CB *IfCb;
- ARG_LIST *ArgNode;
- ARG_LIST *ArgHead;
-
- ASSERT (Private != NULL);
-
- //
- // Clean the list which save the set config Args.
- //
- if (Private->VarArg != NULL) {
- ArgHead = Private->VarArg;
-
- while (ArgHead->Next != NULL) {
- ArgNode = ArgHead->Next;
- FreePool (ArgHead);
- ArgHead = ArgNode;
- }
-
- FreePool (ArgHead);
- }
-
- if (Private->IfName != NULL) {
- FreePool (Private->IfName);
- }
-
- //
- // Clean the IFCONFIG_INTERFACE_CB list.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->IfList) {
- IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
-
- RemoveEntryList (&IfCb->Link);
-
- if (IfCb->IfInfo != NULL) {
-
- FreePool (IfCb->IfInfo);
- }
-
- FreePool (IfCb);
- }
-
- FreePool (Private);
-}
-
-/**
- Function for 'ifconfig' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-
- @retval EFI_SUCCESS ifconfig command processed successfully.
- @retval others The ifconfig command process failed.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunIfconfig (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- IFCONFIG_PRIVATE_DATA *Private;
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *ValueStr;
- ARG_LIST *ArgList;
- CHAR16 *ProblemParam;
- CHAR16 *Str;
-
- Private = NULL;
-
- Status = ShellCommandLineParseEx (mIfConfigCheckList, &ParamPackage, &ProblemParam, TRUE, FALSE);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ifconfig", ProblemParam);
- goto ON_EXIT;
- }
-
- //
- // To handle unsupported option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-c")) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_UNSUPPORTED_OPTION), gShellNetwork1HiiHandle,L"-c");
- goto ON_EXIT;
- }
-
- //
- // To handle no option.
- //
- if (!ShellCommandLineGetFlag (ParamPackage, L"-r") && !ShellCommandLineGetFlag (ParamPackage, L"-s") &&
- !ShellCommandLineGetFlag (ParamPackage, L"-l")) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_OPTION), gShellNetwork1HiiHandle);
- goto ON_EXIT;
- }
-
- //
- // To handle conflict options.
- //
- if (((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-s"))) ||
- ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-l"))) ||
- ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && (ShellCommandLineGetFlag (ParamPackage, L"-l")))) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellNetwork1HiiHandle, L"ifconfig");
- goto ON_EXIT;
- }
-
- Status = EFI_INVALID_PARAMETER;
-
- Private = AllocateZeroPool (sizeof (IFCONFIG_PRIVATE_DATA));
-
- if (Private == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_EXIT;
- }
-
- InitializeListHead (&Private->IfList);
-
- //
- // To get interface name for the list option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-l")) {
- Private->OpCode = IfConfigOpList;
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");
- if (ValueStr != NULL) {
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);
- ASSERT (Str != NULL);
- Private->IfName = Str;
- }
- }
-
- //
- // To get interface name for the clear option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-r")) {
- Private->OpCode = IfConfigOpClear;
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r");
- if (ValueStr != NULL) {
- Str = AllocateCopyPool (StrSize (ValueStr), ValueStr);
- ASSERT (Str != NULL);
- Private->IfName = Str;
- }
- }
-
- //
- // To get interface name and corresponding Args for the set option.
- //
- if (ShellCommandLineGetFlag (ParamPackage, L"-s")) {
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s");
- if (ValueStr == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_INTERFACE), gShellNetwork1HiiHandle);
- goto ON_EXIT;
- }
-
- //
- // To split the configuration into multi-section.
- //
- ArgList = SplitStrToList (ValueStr, L' ');
- ASSERT (ArgList != NULL);
-
- Private->OpCode = IfConfigOpSet;
- Private->IfName = ArgList->Arg;
-
- Private->VarArg = ArgList->Next;
-
- if (Private->IfName == NULL || Private->VarArg == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_COMMAND), gShellNetwork1HiiHandle);
- goto ON_EXIT;
- }
- }
-
- //
- // Main process of ifconfig.
- //
- Status = IfConfig (Private);
-
-ON_EXIT:
-
- ShellCommandLineFreeVarList (ParamPackage);
-
- if (Private != NULL) {
- IfConfigCleanup (Private);
- }
-
- return Status;
-}
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
deleted file mode 100644
index dbee764b64..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ /dev/null
@@ -1,1579 +0,0 @@
-/** @file
- The implementation for Ping shell command.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
-
- 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 "UefiShellNetwork1CommandsLib.h"
-
-#define PING_IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS)))
-
-UINT64 mCurrentTick = 0;
-
-//
-// Function templates to match the IPv4 and IPv6 commands that we use.
-//
-typedef
-EFI_STATUS
-(EFIAPI *PING_IPX_POLL)(
- IN VOID *This
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *PING_IPX_TRANSMIT)(
- IN VOID *This,
- IN VOID *Token
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *PING_IPX_RECEIVE)(
- IN VOID *This,
- IN VOID *Token
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *PING_IPX_CANCEL)(
- IN VOID *This,
- IN VOID *Token OPTIONAL
- );
-
-///
-/// A set of pointers to either IPv6 or IPv4 functions.
-/// Unknown which one to the ping command.
-///
-typedef struct {
- PING_IPX_TRANSMIT Transmit;
- PING_IPX_RECEIVE Receive;
- PING_IPX_CANCEL Cancel;
- PING_IPX_POLL Poll;
-}PING_IPX_PROTOCOL;
-
-
-typedef union {
- VOID *RxData;
- VOID *TxData;
-} PING_PACKET;
-
-//
-// PING_IPX_COMPLETION_TOKEN
-// structures are used for both transmit and receive operations.
-// This version is IP-unaware.
-//
-typedef struct {
- EFI_EVENT Event;
- EFI_STATUS Status;
- PING_PACKET Packet;
-} PING_IPX_COMPLETION_TOKEN;
-
-#pragma pack(1)
-typedef struct _ICMPX_ECHO_REQUEST_REPLY {
- UINT8 Type;
- UINT8 Code;
- UINT16 Checksum;
- UINT16 Identifier;
- UINT16 SequenceNum;
- UINT64 TimeStamp;
- UINT8 Data[1];
-} ICMPX_ECHO_REQUEST_REPLY;
-#pragma pack()
-
-typedef struct _PING_ICMP_TX_INFO {
- LIST_ENTRY Link;
- UINT16 SequenceNum;
- UINT64 TimeStamp;
- PING_IPX_COMPLETION_TOKEN *Token;
-} PING_ICMPX_TX_INFO;
-
-#define DEFAULT_TIMEOUT 5000
-#define MAX_SEND_NUMBER 10000
-#define MAX_BUFFER_SIZE 32768
-#define DEFAULT_TIMER_PERIOD 358049
-#define ONE_SECOND 10000000
-#define PING_IP_CHOICE_IP4 1
-#define PING_IP_CHOICE_IP6 2
-#define DEFAULT_SEND_COUNT 10
-#define DEFAULT_BUFFER_SIZE 16
-#define ICMP_V4_ECHO_REQUEST 0x8
-#define ICMP_V4_ECHO_REPLY 0x0
-
-#define PING_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'i', 'n', 'g')
-typedef struct _PING_PRIVATE_DATA {
- UINT32 Signature;
- EFI_HANDLE NicHandle;
- EFI_HANDLE IpChildHandle;
- EFI_EVENT Timer;
-
- EFI_STATUS Status;
- LIST_ENTRY TxList;
- UINT16 RxCount;
- UINT16 TxCount;
- UINT64 RttSum;
- UINT64 RttMin;
- UINT64 RttMax;
- UINT32 SequenceNum;
-
- UINT32 SendNum;
- UINT32 BufferSize;
- UINT32 IpChoice;
-
- PING_IPX_PROTOCOL ProtocolPointers;
- VOID *IpProtocol;
- UINT8 SrcAddress[MAX(sizeof(EFI_IPv6_ADDRESS) , sizeof(EFI_IPv4_ADDRESS) )];
- UINT8 DstAddress[MAX(sizeof(EFI_IPv6_ADDRESS) , sizeof(EFI_IPv4_ADDRESS) )];
- PING_IPX_COMPLETION_TOKEN RxToken;
-} PING_PRIVATE_DATA;
-
-/**
- Calculate the internet checksum (see RFC 1071).
-
- @param[in] Packet Buffer which contains the data to be checksummed.
- @param[in] Length Length to be checksummed.
-
- @retval Checksum Returns the 16 bit ones complement of
- ones complement sum of 16 bit words
-**/
-UINT16
-EFIAPI
-NetChecksum (
- IN UINT8 *Buffer,
- IN UINT32 Length
- )
-{
- UINT32 Sum;
- UINT8 Odd;
- UINT16 *Packet;
-
- Packet = (UINT16 *) Buffer;
-
- Sum = 0;
- Odd = (UINT8) (Length & 1);
- Length >>= 1;
- while ((Length--) != 0) {
- Sum += *Packet++;
- }
-
- if (Odd != 0) {
- Sum += *(UINT8 *) Packet;
- }
-
- Sum = (Sum & 0xffff) + (Sum >> 16);
-
- //
- // in case above carried
- //
- Sum += Sum >> 16;
-
- return (UINT16) Sum;
-}
-
-/**
- Reads and returns the current value of register.
- In IA64, the register is the Interval Timer Vector (ITV).
- In X86(IA32/X64), the register is the Time Stamp Counter (TSC)
-
- @return The current value of the register.
-
-**/
-
-STATIC CONST SHELL_PARAM_ITEM PingParamList[] = {
- {
- L"-l",
- TypeValue
- },
- {
- L"-n",
- TypeValue
- },
- {
- L"-_s",
- TypeValue
- },
- {
- L"-_ip6",
- TypeFlag
- },
- {
- NULL,
- TypeMax
- },
-};
-
-//
-// Global Variables in Ping command.
-//
-STATIC CONST CHAR16 *mDstString;
-STATIC CONST CHAR16 *mSrcString;
-STATIC UINT64 mFrequency = 0;
-EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;
-
-/**
- Read the current time.
-
- @retval the current tick value.
-**/
-UINT64
-EFIAPI
-ReadTime (
- VOID
- )
-{
- UINT64 TimerPeriod;
- EFI_STATUS Status;
-
- ASSERT (gCpu != NULL);
-
- Status = gCpu->GetTimerValue (gCpu, 0, &mCurrentTick, &TimerPeriod);
- if (EFI_ERROR (Status)) {
- //
- // The WinntGetTimerValue will return EFI_UNSUPPORTED. Set the
- // TimerPeriod by ourselves.
- //
- mCurrentTick += 1000000;
- }
-
- return mCurrentTick;
-}
-
-
-/**
- Get and calculate the frequency in ticks/ms.
- The result is saved in the global variable mFrequency
-
- @retval EFI_SUCCESS Calculated the frequency successfully.
- @retval Others Failed to calculate the frequency.
-
-**/
-EFI_STATUS
-EFIAPI
-GetFrequency (
- VOID
- )
-{
- EFI_STATUS Status;
- UINT64 CurrentTick;
- UINT64 TimerPeriod;
-
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &gCpu);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gCpu->GetTimerValue (gCpu, 0, &CurrentTick, &TimerPeriod);
-
- if (EFI_ERROR (Status)) {
- TimerPeriod = DEFAULT_TIMER_PERIOD;
- }
-
- //
- // The timer period is in femtosecond (1 femtosecond is 1e-15 second).
- // So 1e+12 is divided by timer period to produce the freq in ticks/ms.
- //
- mFrequency = DivU64x64Remainder (1000000000000ULL, TimerPeriod, NULL);
-
- return EFI_SUCCESS;
-}
-
-/**
- Calculate a duration in ms.
-
- @param[in] Begin The start point of time.
- @param[in] End The end point of time.
-
- @return The duration in ms.
- @retval 0 The parameters were not valid.
-**/
-UINT64
-EFIAPI
-CalculateTick (
- IN UINT64 Begin,
- IN UINT64 End
- )
-{
- if (End <= Begin) {
- return (0);
- }
- return DivU64x64Remainder (End - Begin, mFrequency, NULL);
-}
-
-/**
- Destroy PING_ICMPX_TX_INFO, and recollect the memory.
-
- @param[in] TxInfo The pointer to PING_ICMPX_TX_INFO.
- @param[in] IpChoice Whether the token is IPv4 or IPv6
-**/
-VOID
-EFIAPI
-PingDestroyTxInfo (
- IN PING_ICMPX_TX_INFO *TxInfo,
- IN UINT32 IpChoice
- )
-{
- EFI_IP6_TRANSMIT_DATA *Ip6TxData;
- EFI_IP4_TRANSMIT_DATA *Ip4TxData;
- EFI_IP6_FRAGMENT_DATA *FragData;
- UINTN Index;
-
- if (TxInfo == NULL) {
- return;
- }
-
- if (TxInfo->Token != NULL) {
-
- if (TxInfo->Token->Event != NULL) {
- gBS->CloseEvent (TxInfo->Token->Event);
- }
-
- if (TxInfo->Token->Packet.TxData != NULL) {
- if (IpChoice == PING_IP_CHOICE_IP6) {
- Ip6TxData = TxInfo->Token->Packet.TxData;
-
- if (Ip6TxData->OverrideData != NULL) {
- FreePool (Ip6TxData->OverrideData);
- }
-
- if (Ip6TxData->ExtHdrs != NULL) {
- FreePool (Ip6TxData->ExtHdrs);
- }
-
- for (Index = 0; Index < Ip6TxData->FragmentCount; Index++) {
- FragData = Ip6TxData->FragmentTable[Index].FragmentBuffer;
- if (FragData != NULL) {
- FreePool (FragData);
- }
- }
- } else {
- Ip4TxData = TxInfo->Token->Packet.TxData;
-
- if (Ip4TxData->OverrideData != NULL) {
- FreePool (Ip4TxData->OverrideData);
- }
-
- for (Index = 0; Index < Ip4TxData->FragmentCount; Index++) {
- FragData = Ip4TxData->FragmentTable[Index].FragmentBuffer;
- if (FragData != NULL) {
- FreePool (FragData);
- }
- }
- }
- }
-
- FreePool (TxInfo->Token);
- }
-
- FreePool (TxInfo);
-}
-
-/**
- Match the request, and reply with SequenceNum/TimeStamp.
-
- @param[in] Private The pointer to PING_PRIVATE_DATA.
- @param[in] Packet The pointer to ICMPX_ECHO_REQUEST_REPLY.
-
- @retval EFI_SUCCESS The match is successful.
- @retval EFI_NOT_FOUND The reply can't be matched with any request.
-
-**/
-EFI_STATUS
-EFIAPI
-Ping6MatchEchoReply (
- IN PING_PRIVATE_DATA *Private,
- IN ICMPX_ECHO_REQUEST_REPLY *Packet
- )
-{
- PING_ICMPX_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
-
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING_ICMPX_TX_INFO, Link);
-
- if ((TxInfo->SequenceNum == Packet->SequenceNum) && (TxInfo->TimeStamp == Packet->TimeStamp)) {
- Private->RxCount++;
- RemoveEntryList (&TxInfo->Link);
- PingDestroyTxInfo (TxInfo, Private->IpChoice);
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- The original intention is to send a request.
- Currently, the application retransmits an icmp6 echo request packet
- per second in sendnumber times that is specified by the user.
- Because nothing can be done here, all things move to the timer rountine.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to Context.
-
-**/
-VOID
-EFIAPI
-Ping6OnEchoRequestSent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-}
-
-/**
- receive reply, match and print reply infomation.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to context.
-
-**/
-VOID
-EFIAPI
-Ping6OnEchoReplyReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- PING_PRIVATE_DATA *Private;
- ICMPX_ECHO_REQUEST_REPLY *Reply;
- UINT32 PayLoad;
- UINT64 Rtt;
- CHAR8 Near;
-
- Private = (PING_PRIVATE_DATA *) Context;
-
- if (Private == NULL || Private->Status == EFI_ABORTED || Private->Signature != PING_PRIVATE_DATA_SIGNATURE) {
- return;
- }
-
- if (Private->RxToken.Packet.RxData == NULL) {
- return;
- }
-
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- Reply = ((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->FragmentTable[0].FragmentBuffer;
- PayLoad = ((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->DataLength;
- if (((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->Header->NextHeader != IP6_ICMP) {
- goto ON_EXIT;
- }
- if (!IP6_IS_MULTICAST ((EFI_IPv6_ADDRESS*)&Private->DstAddress) &&
- !EFI_IP6_EQUAL (&((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->Header->SourceAddress, (EFI_IPv6_ADDRESS*)&Private->DstAddress)) {
- goto ON_EXIT;
- }
-
- if ((Reply->Type != ICMP_V6_ECHO_REPLY) || (Reply->Code != 0)) {
- goto ON_EXIT;
- }
- } else {
- Reply = ((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->FragmentTable[0].FragmentBuffer;
- PayLoad = ((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->DataLength;
- if (!IP4_IS_MULTICAST (EFI_IP4(*(EFI_IPv4_ADDRESS*)Private->DstAddress)) &&
- !EFI_IP4_EQUAL (&((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->Header->SourceAddress, (EFI_IPv4_ADDRESS*)&Private->DstAddress)) {
- goto ON_EXIT;
- }
-
- if ((Reply->Type != ICMP_V4_ECHO_REPLY) || (Reply->Code != 0)) {
- goto ON_EXIT;
- }
- }
-
-
- if (PayLoad != Private->BufferSize) {
- goto ON_EXIT;
- }
- //
- // Check whether the reply matches the sent request before.
- //
- Status = Ping6MatchEchoReply (Private, Reply);
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- //
- // Display statistics on this icmp6 echo reply packet.
- //
- Rtt = CalculateTick (Reply->TimeStamp, ReadTime ());
- if (Rtt != 0) {
- Near = (CHAR8) '=';
- } else {
- Near = (CHAR8) '<';
- }
-
- Private->RttSum += Rtt;
- Private->RttMin = Private->RttMin > Rtt ? Rtt : Private->RttMin;
- Private->RttMax = Private->RttMax < Rtt ? Rtt : Private->RttMax;
-
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING_REPLY_INFO),
- gShellNetwork1HiiHandle,
- PayLoad,
- mDstString,
- Reply->SequenceNum,
- Private->IpChoice == PING_IP_CHOICE_IP6?((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->Header->HopLimit:0,
- Near,
- Rtt
- );
-
-ON_EXIT:
-
- if (Private->RxCount < Private->SendNum) {
- //
- // Continue to receive icmp echo reply packets.
- //
- Private->RxToken.Status = EFI_ABORTED;
-
- Status = Private->ProtocolPointers.Receive (Private->IpProtocol, &Private->RxToken);
-
- if (EFI_ERROR (Status)) {
- Private->Status = EFI_ABORTED;
- }
- } else {
- //
- // All reply have already been received from the dest host.
- //
- Private->Status = EFI_SUCCESS;
- }
- //
- // Singal to recycle the each rxdata here, not at the end of process.
- //
- gBS->SignalEvent (Private->IpChoice == PING_IP_CHOICE_IP6?((EFI_IP6_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal:((EFI_IP4_RECEIVE_DATA*)Private->RxToken.Packet.RxData)->RecycleSignal);
-}
-
-/**
- Create a PING_IPX_COMPLETION_TOKEN.
-
- @param[in] Private The pointer of PING_PRIVATE_DATA.
- @param[in] TimeStamp The TimeStamp of request.
- @param[in] SequenceNum The SequenceNum of request.
-
- @return The pointer of PING_IPX_COMPLETION_TOKEN.
-
-**/
-PING_IPX_COMPLETION_TOKEN *
-EFIAPI
-PingGenerateToken (
- IN PING_PRIVATE_DATA *Private,
- IN UINT64 TimeStamp,
- IN UINT16 SequenceNum
- )
-{
- EFI_STATUS Status;
- PING_IPX_COMPLETION_TOKEN *Token;
- VOID *TxData;
- ICMPX_ECHO_REQUEST_REPLY *Request;
- UINT16 HeadSum;
- UINT16 TempChecksum;
-
- Request = AllocateZeroPool (Private->BufferSize);
- if (Request == NULL) {
- return NULL;
- }
- TxData = AllocateZeroPool (Private->IpChoice==PING_IP_CHOICE_IP6?sizeof (EFI_IP6_TRANSMIT_DATA):sizeof (EFI_IP4_TRANSMIT_DATA));
- if (TxData == NULL) {
- FreePool (Request);
- return NULL;
- }
- Token = AllocateZeroPool (sizeof (PING_IPX_COMPLETION_TOKEN));
- if (Token == NULL) {
- FreePool (Request);
- FreePool (TxData);
- return NULL;
- }
-
- //
- // Assembly echo request packet.
- //
- Request->Type = (UINT8)(Private->IpChoice==PING_IP_CHOICE_IP6?ICMP_V6_ECHO_REQUEST:ICMP_V4_ECHO_REQUEST);
- Request->Code = 0;
- Request->SequenceNum = SequenceNum;
- Request->Identifier = 0;
- Request->Checksum = 0;
-
- //
- // Assembly token for transmit.
- //
- if (Private->IpChoice==PING_IP_CHOICE_IP6) {
- Request->TimeStamp = TimeStamp;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->ExtHdrsLength = 0;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->ExtHdrs = NULL;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->OverrideData = 0;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->DataLength = Private->BufferSize;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->FragmentCount = 1;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->FragmentTable[0].FragmentBuffer = (VOID *) Request;
- ((EFI_IP6_TRANSMIT_DATA*)TxData)->FragmentTable[0].FragmentLength = Private->BufferSize;
- } else {
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->OptionsLength = 0;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->OptionsBuffer = NULL;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->OverrideData = 0;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->TotalDataLength = Private->BufferSize;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->FragmentCount = 1;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->FragmentTable[0].FragmentBuffer = (VOID *) Request;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->FragmentTable[0].FragmentLength = Private->BufferSize;
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->DestinationAddress.Addr[0] = Private->DstAddress[0];
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->DestinationAddress.Addr[1] = Private->DstAddress[1];
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->DestinationAddress.Addr[2] = Private->DstAddress[2];
- ((EFI_IP4_TRANSMIT_DATA*)TxData)->DestinationAddress.Addr[3] = Private->DstAddress[3];
-
- HeadSum = NetChecksum ((UINT8 *) Request, Private->BufferSize);
- Request->TimeStamp = TimeStamp;
- TempChecksum = NetChecksum ((UINT8 *) &Request->TimeStamp, sizeof (UINT64));
- Request->Checksum = (UINT16)(~NetAddChecksum (HeadSum, TempChecksum));
- }
-
-
- Token->Status = EFI_ABORTED;
- Token->Packet.TxData = TxData;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnEchoRequestSent,
- Private,
- &Token->Event
- );
-
- if (EFI_ERROR (Status)) {
- FreePool (Request);
- FreePool (TxData);
- FreePool (Token);
- return NULL;
- }
-
- return Token;
-}
-
-/**
- Transmit the PING_IPX_COMPLETION_TOKEN.
-
- @param[in] Private The pointer of PING_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Transmitted successfully.
- @retval EFI_OUT_OF_RESOURCES No memory is available on the platform.
- @retval others Transmitted unsuccessfully.
-
-**/
-EFI_STATUS
-EFIAPI
-PingSendEchoRequest (
- IN PING_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- PING_ICMPX_TX_INFO *TxInfo;
-
- TxInfo = AllocateZeroPool (sizeof (PING_ICMPX_TX_INFO));
-
- if (TxInfo == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- TxInfo->TimeStamp = ReadTime ();
- TxInfo->SequenceNum = (UINT16) (Private->TxCount + 1);
- TxInfo->Token = PingGenerateToken (
- Private,
- TxInfo->TimeStamp,
- TxInfo->SequenceNum
- );
-
- if (TxInfo->Token == NULL) {
- PingDestroyTxInfo (TxInfo, Private->IpChoice);
- return EFI_OUT_OF_RESOURCES;
- }
-
- ASSERT(Private->ProtocolPointers.Transmit != NULL);
- Status = Private->ProtocolPointers.Transmit (Private->IpProtocol, TxInfo->Token);
-
- if (EFI_ERROR (Status)) {
- PingDestroyTxInfo (TxInfo, Private->IpChoice);
- return Status;
- }
-
- InsertTailList (&Private->TxList, &TxInfo->Link);
- Private->TxCount++;
-
- return EFI_SUCCESS;
-}
-
-/**
- Place a completion token into the receive packet queue to receive the echo reply.
-
- @param[in] Private The pointer of PING_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Put the token into the receive packet queue successfully.
- @retval others Put the token into the receive packet queue unsuccessfully.
-
-**/
-EFI_STATUS
-EFIAPI
-Ping6ReceiveEchoReply (
- IN PING_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
-
- ZeroMem (&Private->RxToken, sizeof (PING_IPX_COMPLETION_TOKEN));
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnEchoReplyReceived,
- Private,
- &Private->RxToken.Event
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Private->RxToken.Status = EFI_NOT_READY;
-
- return (Private->ProtocolPointers.Receive (Private->IpProtocol, &Private->RxToken));
-}
-
-/**
- Remove the timeout request from the list.
-
- @param[in] Event A EFI_EVENT type event.
- @param[in] Context The pointer to Context.
-
-**/
-VOID
-EFIAPI
-Ping6OnTimerRoutine (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- PING_PRIVATE_DATA *Private;
- PING_ICMPX_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- UINT64 Time;
-
- Private = (PING_PRIVATE_DATA *) Context;
- if (Private->Signature != PING_PRIVATE_DATA_SIGNATURE) {
- Private->Status = EFI_NOT_FOUND;
- return;
- }
-
- //
- // Retransmit icmp6 echo request packets per second in sendnumber times.
- //
- if (Private->TxCount < Private->SendNum) {
-
- Status = PingSendEchoRequest (Private);
- if (Private->TxCount != 0){
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_SEND_REQUEST), gShellNetwork1HiiHandle, Private->TxCount + 1);
- }
- }
- }
- //
- // Check whether any icmp6 echo request in the list timeout.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING_ICMPX_TX_INFO, Link);
- Time = CalculateTick (TxInfo->TimeStamp, ReadTime ());
-
- //
- // Remove the timeout echo request from txlist.
- //
- if (Time > DEFAULT_TIMEOUT) {
-
- if (EFI_ERROR (TxInfo->Token->Status)) {
- Private->ProtocolPointers.Cancel (Private->IpProtocol, TxInfo->Token);
- }
- //
- // Remove the timeout icmp6 echo request from list.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_TIMEOUT), gShellNetwork1HiiHandle, TxInfo->SequenceNum);
-
- RemoveEntryList (&TxInfo->Link);
- PingDestroyTxInfo (TxInfo, Private->IpChoice);
-
- if (IsListEmpty (&Private->TxList) && (Private->TxCount == Private->SendNum)) {
- //
- // All the left icmp6 echo request in the list timeout.
- //
- Private->Status = EFI_TIMEOUT;
- }
- }
- }
-}
-
-/**
- Determine if a IP4 address is Link Local.
-
- 169.254.1.0 through 169.254.254.255 is link local.
-
- @param[in] Address The address to test.
-
- @retval TRUE It is.
- @retval FALSE It is not.
-**/
-BOOLEAN
-EFIAPI
-PingNetIp4IsLinkLocalAddr (
- IN CONST EFI_IPv4_ADDRESS *Address
- )
-{
- return ((BOOLEAN)(Address->Addr[0] == 169 && Address->Addr[1] == 254 && Address->Addr[2] >= 1 && Address->Addr[2] <= 254));
-}
-
-/**
- Determine if a IP4 address is unspecified.
-
- @param[in] Address The address to test.
-
- @retval TRUE It is.
- @retval FALSE It is not.
-**/
-BOOLEAN
-EFIAPI
-PingNetIp4IsUnspecifiedAddr (
- IN CONST EFI_IPv4_ADDRESS *Address
- )
-{
- return ((BOOLEAN)((ReadUnaligned32 ((UINT32*)&Address->Addr[0])) == 0x00000000));
-}
-
-/**
- Create a valid IP instance.
-
- @param[in] Private The pointer of PING_PRIVATE_DATA.
-
- @retval EFI_SUCCESS Create a valid IPx instance successfully.
- @retval EFI_ABORTED Locate handle with ipx service binding protocol unsuccessfully.
- @retval EFI_INVALID_PARAMETER The source address is unspecified when the destination address is a link-local address.
- @retval EFI_OUT_OF_RESOURCES No memory is available on the platform.
- @retval EFI_NOT_FOUND The source address is not found.
-**/
-EFI_STATUS
-EFIAPI
-PingCreateIpInstance (
- IN PING_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- UINTN HandleIndex;
- UINTN HandleNum;
- EFI_HANDLE *HandleBuffer;
- EFI_SERVICE_BINDING_PROTOCOL *EfiSb;
- VOID *IpXCfg;
- EFI_IP6_CONFIG_DATA Ip6Config;
- EFI_IP4_CONFIG_DATA Ip4Config;
- VOID *IpXInterfaceInfo;
- UINTN IfInfoSize;
- EFI_IPv6_ADDRESS *Addr;
- UINTN AddrIndex;
-
- HandleBuffer = NULL;
- EfiSb = NULL;
- IpXInterfaceInfo = NULL;
- IfInfoSize = 0;
-
- //
- // Locate all the handles with ip6 service binding protocol.
- //
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- Private->IpChoice == PING_IP_CHOICE_IP6?&gEfiIp6ServiceBindingProtocolGuid:&gEfiIp4ServiceBindingProtocolGuid,
- NULL,
- &HandleNum,
- &HandleBuffer
- );
- if (EFI_ERROR (Status) || (HandleNum == 0) || (HandleBuffer == NULL)) {
- return EFI_ABORTED;
- }
- //
- // Source address is required when pinging a link-local address on multi-
- // interfaces host.
- //
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- if (NetIp6IsLinkLocalAddr ((EFI_IPv6_ADDRESS*)&Private->DstAddress) &&
- NetIp6IsUnspecifiedAddr ((EFI_IPv6_ADDRESS*)&Private->SrcAddress) &&
- (HandleNum > 1)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", mSrcString);
- Status = EFI_INVALID_PARAMETER;
- goto ON_ERROR;
- }
- } else {
- ASSERT(Private->IpChoice == PING_IP_CHOICE_IP4);
- if (PingNetIp4IsLinkLocalAddr ((EFI_IPv4_ADDRESS*)&Private->DstAddress) &&
- PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private->SrcAddress) &&
- (HandleNum > 1)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", mSrcString);
- Status = EFI_INVALID_PARAMETER;
- goto ON_ERROR;
- }
- }
- //
- // For each ip6 protocol, check interface addresses list.
- //
- for (HandleIndex = 0; HandleIndex < HandleNum; HandleIndex++) {
-
- EfiSb = NULL;
- IpXInterfaceInfo = NULL;
- IfInfoSize = 0;
-
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- Private->IpChoice == PING_IP_CHOICE_IP6?&gEfiIp6ServiceBindingProtocolGuid:&gEfiIp4ServiceBindingProtocolGuid,
- (VOID **) &EfiSb
- );
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
- if (Private->IpChoice == PING_IP_CHOICE_IP6?NetIp6IsUnspecifiedAddr ((EFI_IPv6_ADDRESS*)&Private->SrcAddress):PingNetIp4IsUnspecifiedAddr ((EFI_IPv4_ADDRESS*)&Private->SrcAddress)) {
- //
- // No need to match interface address.
- //
- break;
- } else {
- //
- // Ip6config protocol and ip6 service binding protocol are installed
- // on the same handle.
- //
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- Private->IpChoice == PING_IP_CHOICE_IP6?&gEfiIp6ConfigProtocolGuid:&gEfiIp4Config2ProtocolGuid,
- (VOID **) &IpXCfg
- );
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
- //
- // Get the interface information size.
- //
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- Status = ((EFI_IP6_CONFIG_PROTOCOL*)IpXCfg)->GetData (
- IpXCfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &IfInfoSize,
- NULL
- );
- } else {
- Status = ((EFI_IP4_CONFIG2_PROTOCOL*)IpXCfg)->GetData (
- IpXCfg,
- Ip4Config2DataTypeInterfaceInfo,
- &IfInfoSize,
- NULL
- );
- }
-
- //
- // Skip the ones not in current use.
- //
- if (Status == EFI_NOT_STARTED) {
- continue;
- }
-
- if (Status != EFI_BUFFER_TOO_SMALL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_GETDATA), gShellNetwork1HiiHandle, Status);
- goto ON_ERROR;
- }
-
- IpXInterfaceInfo = AllocateZeroPool (IfInfoSize);
-
- if (IpXInterfaceInfo == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_ERROR;
- }
- //
- // Get the interface info.
- //
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- Status = ((EFI_IP6_CONFIG_PROTOCOL*)IpXCfg)->GetData (
- IpXCfg,
- Ip6ConfigDataTypeInterfaceInfo,
- &IfInfoSize,
- IpXInterfaceInfo
- );
- } else {
- Status = ((EFI_IP4_CONFIG2_PROTOCOL*)IpXCfg)->GetData (
- IpXCfg,
- Ip4Config2DataTypeInterfaceInfo,
- &IfInfoSize,
- IpXInterfaceInfo
- );
- }
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_GETDATA), gShellNetwork1HiiHandle, Status);
- goto ON_ERROR;
- }
- //
- // Check whether the source address is one of the interface addresses.
- //
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- for (AddrIndex = 0; AddrIndex < ((EFI_IP6_CONFIG_INTERFACE_INFO*)IpXInterfaceInfo)->AddressInfoCount; AddrIndex++) {
-
- Addr = &(((EFI_IP6_CONFIG_INTERFACE_INFO*)IpXInterfaceInfo)->AddressInfo[AddrIndex].Address);
- if (EFI_IP6_EQUAL (&Private->SrcAddress, Addr)) {
- //
- // Match a certain interface address.
- //
- break;
- }
- }
-
- if (AddrIndex < ((EFI_IP6_CONFIG_INTERFACE_INFO*)IpXInterfaceInfo)->AddressInfoCount) {
- //
- // Found a nic handle with right interface address.
- //
- break;
- }
- } else {
- //
- // IP4 address check
- //
- if (EFI_IP4_EQUAL (&Private->SrcAddress, &((EFI_IP4_CONFIG2_INTERFACE_INFO*)IpXInterfaceInfo)->StationAddress)) {
- //
- // Match a certain interface address.
- //
- break;
- }
- }
- }
-
- FreePool (IpXInterfaceInfo);
- IpXInterfaceInfo = NULL;
- }
- //
- // No exact interface address matched.
- //
-
- if (HandleIndex == HandleNum) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_CONFIGD_NIC_NF), gShellNetwork1HiiHandle, L"ping");
- Status = EFI_NOT_FOUND;
- goto ON_ERROR;
- }
-
- Private->NicHandle = HandleBuffer[HandleIndex];
-
- ASSERT (EfiSb != NULL);
- Status = EfiSb->CreateChild (EfiSb, &Private->IpChildHandle);
-
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
- if (Private->IpChoice == PING_IP_CHOICE_IP6) {
- Status = gBS->OpenProtocol (
- Private->IpChildHandle,
- &gEfiIp6ProtocolGuid,
- &Private->IpProtocol,
- gImageHandle,
- Private->IpChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
-
- ZeroMem (&Ip6Config, sizeof (EFI_IP6_CONFIG_DATA));
-
- //
- // Configure the ip6 instance for icmp6 packet exchange.
- //
- Ip6Config.DefaultProtocol = 58;
- Ip6Config.AcceptAnyProtocol = FALSE;
- Ip6Config.AcceptIcmpErrors = TRUE;
- Ip6Config.AcceptPromiscuous = FALSE;
- Ip6Config.TrafficClass = 0;
- Ip6Config.HopLimit = 128;
- Ip6Config.FlowLabel = 0;
- Ip6Config.ReceiveTimeout = 0;
- Ip6Config.TransmitTimeout = 0;
-
- IP6_COPY_ADDRESS (&Ip6Config.StationAddress, &Private->SrcAddress);
- IP6_COPY_ADDRESS (&Ip6Config.DestinationAddress, &Private->DstAddress);
-
- Status = ((EFI_IP6_PROTOCOL*)(Private->IpProtocol))->Configure (Private->IpProtocol, &Ip6Config);
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_CONFIG), gShellNetwork1HiiHandle, Status);
- goto ON_ERROR;
- }
-
- Private->ProtocolPointers.Transmit = (PING_IPX_TRANSMIT )((EFI_IP6_PROTOCOL*)Private->IpProtocol)->Transmit;
- Private->ProtocolPointers.Receive = (PING_IPX_RECEIVE )((EFI_IP6_PROTOCOL*)Private->IpProtocol)->Receive;
- Private->ProtocolPointers.Cancel = (PING_IPX_CANCEL )((EFI_IP6_PROTOCOL*)Private->IpProtocol)->Cancel;
- Private->ProtocolPointers.Poll = (PING_IPX_POLL )((EFI_IP6_PROTOCOL*)Private->IpProtocol)->Poll;
- } else {
- Status = gBS->OpenProtocol (
- Private->IpChildHandle,
- &gEfiIp4ProtocolGuid,
- &Private->IpProtocol,
- gImageHandle,
- Private->IpChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- goto ON_ERROR;
- }
-
-
- ZeroMem (&Ip4Config, sizeof (EFI_IP4_CONFIG_DATA));
-
- //
- // Configure the ip4 instance for icmp4 packet exchange.
- //
- Ip4Config.DefaultProtocol = 1;
- Ip4Config.AcceptAnyProtocol = FALSE;
- Ip4Config.AcceptBroadcast = FALSE;
- Ip4Config.AcceptIcmpErrors = TRUE;
- Ip4Config.AcceptPromiscuous = FALSE;
- Ip4Config.DoNotFragment = FALSE;
- Ip4Config.RawData = FALSE;
- Ip4Config.ReceiveTimeout = 0;
- Ip4Config.TransmitTimeout = 0;
- Ip4Config.UseDefaultAddress = TRUE;
- Ip4Config.TimeToLive = 128;
- Ip4Config.TypeOfService = 0;
-
- Status = ((EFI_IP4_PROTOCOL*)(Private->IpProtocol))->Configure (Private->IpProtocol, &Ip4Config);
-
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_CONFIG), gShellNetwork1HiiHandle, Status);
- goto ON_ERROR;
- }
-
- Private->ProtocolPointers.Transmit = (PING_IPX_TRANSMIT )((EFI_IP4_PROTOCOL*)Private->IpProtocol)->Transmit;
- Private->ProtocolPointers.Receive = (PING_IPX_RECEIVE )((EFI_IP4_PROTOCOL*)Private->IpProtocol)->Receive;
- Private->ProtocolPointers.Cancel = (PING_IPX_CANCEL )((EFI_IP4_PROTOCOL*)Private->IpProtocol)->Cancel;
- Private->ProtocolPointers.Poll = (PING_IPX_POLL )((EFI_IP4_PROTOCOL*)Private->IpProtocol)->Poll;
- }
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- return EFI_SUCCESS;
-
-ON_ERROR:
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- if (IpXInterfaceInfo != NULL) {
- FreePool (IpXInterfaceInfo);
- }
-
- if ((EfiSb != NULL) && (Private->IpChildHandle != NULL)) {
- EfiSb->DestroyChild (EfiSb, Private->IpChildHandle);
- }
-
- return Status;
-}
-
-/**
- Destroy the IP instance.
-
- @param[in] Private The pointer of PING_PRIVATE_DATA.
-
-**/
-VOID
-EFIAPI
-Ping6DestroyIp6Instance (
- IN PING_PRIVATE_DATA *Private
- )
-{
- EFI_STATUS Status;
- EFI_SERVICE_BINDING_PROTOCOL *IpSb;
-
- gBS->CloseProtocol (
- Private->IpChildHandle,
- Private->IpChoice == PING_IP_CHOICE_IP6?&gEfiIp6ProtocolGuid:&gEfiIp4ProtocolGuid,
- gImageHandle,
- Private->IpChildHandle
- );
-
- Status = gBS->HandleProtocol (
- Private->NicHandle,
- Private->IpChoice == PING_IP_CHOICE_IP6?&gEfiIp6ServiceBindingProtocolGuid:&gEfiIp4ServiceBindingProtocolGuid,
- (VOID **) &IpSb
- );
-
- if (!EFI_ERROR(Status)) {
- IpSb->DestroyChild (IpSb, Private->IpChildHandle);
- }
-}
-
-/**
- The Ping Process.
-
- @param[in] SendNumber The send request count.
- @param[in] BufferSize The send buffer size.
- @param[in] SrcAddress The source address.
- @param[in] DstAddress The destination address.
- @param[in] IpChoice The choice between IPv4 and IPv6.
-
- @retval SHELL_SUCCESS The ping processed successfullly.
- @retval others The ping processed unsuccessfully.
-**/
-SHELL_STATUS
-EFIAPI
-ShellPing (
- IN UINT32 SendNumber,
- IN UINT32 BufferSize,
- IN EFI_IPv6_ADDRESS *SrcAddress,
- IN EFI_IPv6_ADDRESS *DstAddress,
- IN UINT32 IpChoice
- )
-{
- EFI_STATUS Status;
- PING_PRIVATE_DATA *Private;
- PING_ICMPX_TX_INFO *TxInfo;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
- Private = AllocateZeroPool (sizeof (PING_PRIVATE_DATA));
-
- if (Private == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
-
- Private->IpChoice = IpChoice;
- Private->Signature = PING_PRIVATE_DATA_SIGNATURE;
- Private->SendNum = SendNumber;
- Private->BufferSize = BufferSize;
- Private->RttMin = ~((UINT64 )(0x0));
- Private->Status = EFI_NOT_READY;
-
- CopyMem(&Private->SrcAddress, SrcAddress, sizeof(Private->SrcAddress));
- CopyMem(&Private->DstAddress, DstAddress, sizeof(Private->DstAddress));
-
- InitializeListHead (&Private->TxList);
-
- //
- // Open and configure a ip instance for us.
- //
- Status = PingCreateIpInstance (Private);
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_ACCESS_DENIED;
- goto ON_EXIT;
- }
- //
- // Print the command line itself.
- //
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_START), gShellNetwork1HiiHandle, mDstString, Private->BufferSize);
- //
- // Create a ipv6 token to receive the first icmp6 echo reply packet.
- //
- Status = Ping6ReceiveEchoReply (Private);
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_ACCESS_DENIED;
- goto ON_EXIT;
- }
- //
- // Create and start timer to send icmp6 echo request packet per second.
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- Ping6OnTimerRoutine,
- Private,
- &Private->Timer
- );
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_ACCESS_DENIED;
- goto ON_EXIT;
- }
- //
- // Create a ipv6 token to send the first icmp6 echo request packet.
- //
- Status = PingSendEchoRequest (Private);
- //
- // EFI_NOT_READY for IPsec is enable and IKE is not established.
- //
- if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
- ShellStatus = SHELL_ACCESS_DENIED;
- if(Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_NOSOURCE_INDO), gShellNetwork1HiiHandle, mDstString);
- } else if (Status == RETURN_NO_MAPPING) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_NOROUTE_FOUND), gShellNetwork1HiiHandle, mDstString, mSrcString);
- } else {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING_NETWORK_ERROR), gShellNetwork1HiiHandle, L"ping", Status);
- }
-
- goto ON_EXIT;
- }
-
- Status = gBS->SetTimer (
- Private->Timer,
- TimerPeriodic,
- ONE_SECOND
- );
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_ACCESS_DENIED;
- goto ON_EXIT;
- }
- //
- // Control the ping6 process by two factors:
- // 1. Hot key
- // 2. Private->Status
- // 2.1. success means all icmp6 echo request packets get reply packets.
- // 2.2. timeout means the last icmp6 echo reply request timeout to get reply.
- // 2.3. noready means ping6 process is on-the-go.
- //
- while (Private->Status == EFI_NOT_READY) {
- Status = Private->ProtocolPointers.Poll (Private->IpProtocol);
- if (ShellGetExecutionBreakFlag()) {
- Private->Status = EFI_ABORTED;
- goto ON_STAT;
- }
- }
-
-ON_STAT:
- //
- // Display the statistics in all.
- //
- gBS->SetTimer (Private->Timer, TimerCancel, 0);
-
- if (Private->TxCount != 0) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING_STAT),
- gShellNetwork1HiiHandle,
- Private->TxCount,
- Private->RxCount,
- (100 * (Private->TxCount - Private->RxCount)) / Private->TxCount,
- Private->RttSum
- );
- }
-
- if (Private->RxCount != 0) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_PING_RTT),
- gShellNetwork1HiiHandle,
- Private->RttMin,
- Private->RttMax,
- DivU64x64Remainder (Private->RttSum, Private->RxCount, NULL)
- );
- }
-
-ON_EXIT:
-
- if (Private != NULL) {
-
- NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->TxList) {
- TxInfo = BASE_CR (Entry, PING_ICMPX_TX_INFO, Link);
-
- if (Private->IpProtocol != NULL && Private->ProtocolPointers.Cancel != NULL) {
- Status = Private->ProtocolPointers.Cancel (Private->IpProtocol, TxInfo->Token);
- }
-
- RemoveEntryList (&TxInfo->Link);
- PingDestroyTxInfo (TxInfo, Private->IpChoice);
- }
-
- if (Private->Timer != NULL) {
- gBS->CloseEvent (Private->Timer);
- }
-
- if (Private->IpProtocol != NULL && Private->ProtocolPointers.Cancel != NULL) {
- Status = Private->ProtocolPointers.Cancel (Private->IpProtocol, &Private->RxToken);
- }
-
- if (Private->RxToken.Event != NULL) {
- gBS->CloseEvent (Private->RxToken.Event);
- }
-
- if (Private->IpChildHandle != NULL) {
- Ping6DestroyIp6Instance (Private);
- }
-
- FreePool (Private);
- }
-
- return ShellStatus;
-}
-
-/**
- Function for 'ping' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-
- @retval SHELL_SUCCESS The ping processed successfullly.
- @retval others The ping processed unsuccessfully.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPing (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- EFI_IPv6_ADDRESS DstAddress;
- EFI_IPv6_ADDRESS SrcAddress;
- UINT64 BufferSize;
- UINTN SendNumber;
- LIST_ENTRY *ParamPackage;
- CONST CHAR16 *ValueStr;
- UINTN NonOptionCount;
- UINT32 IpChoice;
- CHAR16 *ProblemParam;
-
- //
- // we use IPv6 buffers to hold items...
- // make sure this is enough space!
- //
- ASSERT(sizeof(EFI_IPv4_ADDRESS ) <= sizeof(EFI_IPv6_ADDRESS ));
- ASSERT(sizeof(EFI_IP4_COMPLETION_TOKEN) <= sizeof(EFI_IP6_COMPLETION_TOKEN ));
-
- IpChoice = PING_IP_CHOICE_IP4;
-
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
- Status = ShellCommandLineParseEx (PingParamList, &ParamPackage, &ProblemParam, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
-
- if (ShellCommandLineGetFlag (ParamPackage, L"-_ip6")) {
- IpChoice = PING_IP_CHOICE_IP6;
- }
-
- //
- // Parse the paramter of count number.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-n");
- if (ValueStr != NULL) {
- SendNumber = ShellStrToUintn (ValueStr);
-
- //
- // ShellStrToUintn will return 0 when input is 0 or an invalid input string.
- //
- if ((SendNumber == 0) || (SendNumber > MAX_SEND_NUMBER)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", ValueStr);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- } else {
- SendNumber = DEFAULT_SEND_COUNT;
- }
- //
- // Parse the paramter of buffer size.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");
- if (ValueStr != NULL) {
- BufferSize = ShellStrToUintn (ValueStr);
-
- //
- // ShellStrToUintn will return 0 when input is 0 or an invalid input string.
- //
- if ((BufferSize < 16) || (BufferSize > MAX_BUFFER_SIZE)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", ValueStr);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- } else {
- BufferSize = DEFAULT_BUFFER_SIZE;
- }
-
- ZeroMem (&SrcAddress, sizeof (EFI_IPv6_ADDRESS));
- ZeroMem (&DstAddress, sizeof (EFI_IPv6_ADDRESS));
-
- //
- // Parse the paramter of source ip address.
- //
- ValueStr = ShellCommandLineGetValue (ParamPackage, L"-_s");
- if (ValueStr != NULL) {
- mSrcString = ValueStr;
- if (IpChoice == PING_IP_CHOICE_IP6) {
- Status = NetLibStrToIp6 (ValueStr, &SrcAddress);
- } else {
- Status = NetLibStrToIp4 (ValueStr, (EFI_IPv4_ADDRESS*)&SrcAddress);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", ValueStr);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
- //
- // Parse the paramter of destination ip address.
- //
- NonOptionCount = ShellCommandLineGetCount(ParamPackage);
- if (NonOptionCount < 2) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellNetwork1HiiHandle, L"ping");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- if (NonOptionCount > 2) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellNetwork1HiiHandle, L"ping");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- ValueStr = ShellCommandLineGetRawValue (ParamPackage, 1);
- if (ValueStr != NULL) {
- mDstString = ValueStr;
- if (IpChoice == PING_IP_CHOICE_IP6) {
- Status = NetLibStrToIp6 (ValueStr, &DstAddress);
- } else {
- Status = NetLibStrToIp4 (ValueStr, (EFI_IPv4_ADDRESS*)&DstAddress);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellNetwork1HiiHandle, L"ping", ValueStr);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto ON_EXIT;
- }
- }
- //
- // Get frequency to calculate the time from ticks.
- //
- Status = GetFrequency ();
-
- if (EFI_ERROR(Status)) {
- goto ON_EXIT;
- }
- //
- // Enter into ping process.
- //
- ShellStatus = ShellPing (
- (UINT32)SendNumber,
- (UINT32)BufferSize,
- &SrcAddress,
- &DstAddress,
- IpChoice
- );
-
-ON_EXIT:
- ShellCommandLineFreeVarList (ParamPackage);
- return ShellStatus;
-}
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c
deleted file mode 100644
index 49849a6191..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file
- Main file for NULL named library for network1 shell command functions.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>
- 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 "UefiShellNetwork1CommandsLib.h"
-
-CONST CHAR16 gShellNetwork1FileName[] = L"ShellCommands";
-EFI_HANDLE gShellNetwork1HiiHandle = NULL;
-
-/**
- return the file name of the help text file if not using HII.
-
- @return The string pointer to the file name.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameNetwork1 (
- VOID
- )
-{
- return (gShellNetwork1FileName);
-}
-
-/**
- Constructor for the Shell Network1 Commands library.
-
- Install the handlers for Network1 UEFI Shell 2.0 profile commands.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-
- @retval EFI_SUCCESS The shell command handlers were installed sucessfully.
- @retval EFI_UNSUPPORTED The shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellNetwork1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- gShellNetwork1HiiHandle = NULL;
-
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT3) == 0) {
- return (EFI_SUCCESS);
- }
-
- gShellNetwork1HiiHandle = HiiAddPackages (&gShellNetwork1HiiGuid, gImageHandle, UefiShellNetwork1CommandsLibStrings, NULL);
- if (gShellNetwork1HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
- //
- // install our shell command handlers
- //
- ShellCommandRegisterCommandName(L"ping", ShellCommandRunPing , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_PING));
- ShellCommandRegisterCommandName(L"ifconfig",ShellCommandRunIfconfig , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_IFCONFIG));
-
- return (EFI_SUCCESS);
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellNetwork1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellNetwork1HiiHandle != NULL) {
- HiiRemovePackages(gShellNetwork1HiiHandle);
- }
- return (EFI_SUCCESS);
-}
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.h b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.h
deleted file mode 100644
index 98b40df825..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
- header file for NULL named library for network1 shell command functions.
-
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_NETWORK1_COMMANDS_LIB_H_
-#define _UEFI_SHELL_NETWORK1_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/Cpu.h>
-#include <Protocol/ServiceBinding.h>
-#include <Protocol/Ip6.h>
-#include <Protocol/Ip6Config.h>
-#include <Protocol/Ip4.h>
-#include <Protocol/Ip4Config2.h>
-#include <Protocol/Arp.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/NetLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PrintLib.h>
-
-extern EFI_HANDLE gShellNetwork1HiiHandle;
-
-/**
- Function for 'ping' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunPing (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'ifconfig' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunIfconfig (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
deleted file mode 100644
index 92d47d114f..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file
-# Provides shell network1 functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellNetwork1CommandsLib
- FILE_GUID = 9A929F7E-3861-45ce-87AB-7371219AE255
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellNetwork1CommandsLibConstructor
- DESTRUCTOR = ShellNetwork1CommandsLibDestructor
-
-[Sources.common]
- UefiShellNetwork1CommandsLib.uni
- UefiShellNetwork1CommandsLib.c
- UefiShellNetwork1CommandsLib.h
- Ping.c
- Ifconfig.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- PcdLib
- HiiLib
- FileHandleLib
- NetLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
-[Protocols]
- gEfiCpuArchProtocolGuid ## CONSUMES
- gEfiIp6ProtocolGuid ## SOMETIMES_CONSUMES
- gEfiIp6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
- gEfiIp6ConfigProtocolGuid ## SOMETIMES_CONSUMES
-
- gEfiIp4ProtocolGuid ## SOMETIMES_CONSUMES
- gEfiIp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
- gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES
-
-[Guids]
- gShellNetwork1HiiGuid ## SOMETIMES_CONSUMES ## HII \ No newline at end of file
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
deleted file mode 100644
index 4325959182..0000000000
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ /dev/null
Binary files differ
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
deleted file mode 100644
index 2dc9287020..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ /dev/null
@@ -1,1002 +0,0 @@
-/** @file
- The implementation for the 'tftp' Shell command.
-
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
- Copyright (c) 2015, Intel Corporation. All rights reserved. <BR>
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
-
- 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 "UefiShellTftpCommandLib.h"
-
-#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
-
-/*
- Constant strings and definitions related to the message indicating the amount of
- progress in the dowloading of a TFTP file.
-*/
-
-// Frame for the progression slider
-STATIC CONST CHAR16 mTftpProgressFrame[] = L"[ ]";
-
-// Number of steps in the progression slider
-#define TFTP_PROGRESS_SLIDER_STEPS ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) - 3)
-
-// Size in number of characters plus one (final zero) of the message to
-// indicate the progress of a TFTP download. The format is "[(progress slider:
-// 40 characters)] (nb of KBytes downloaded so far: 7 characters) Kb". There
-// are thus the number of characters in mTftpProgressFrame[] plus 11 characters
-// (2 // spaces, "Kb" and seven characters for the number of KBytes).
-#define TFTP_PROGRESS_MESSAGE_SIZE ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) + 12)
-
-// String to delete the TFTP progress message to be able to update it :
-// (TFTP_PROGRESS_MESSAGE_SIZE-1) '\b'
-STATIC CONST CHAR16 mTftpProgressDelete[] = L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
-
-/**
- Check and convert the UINT16 option values of the 'tftp' command
-
- @param[in] ValueStr Value as an Unicode encoded string
- @param[out] Value UINT16 value
-
- @return TRUE The value was returned.
- @return FALSE A parsing error occured.
-**/
-STATIC
-BOOLEAN
-StringToUint16 (
- IN CONST CHAR16 *ValueStr,
- OUT UINT16 *Value
- );
-
-/**
- Get the name of the NIC.
-
- @param[in] ControllerHandle The network physical device handle.
- @param[in] NicNumber The network physical device number.
- @param[out] NicName Address where to store the NIC name.
- The memory area has to be at least
- IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
- double byte wide.
-
- @return EFI_SUCCESS The name of the NIC was returned.
- @return Others The creation of the child for the Managed
- Network Service failed or the opening of
- the Managed Network Protocol failed or
- the operational parameters for the
- Managed Network Protocol could not be
- read.
-**/
-STATIC
-EFI_STATUS
-GetNicName (
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NicNumber,
- OUT CHAR16 *NicName
- );
-
-/**
- Create a child for the service identified by its service binding protocol GUID
- and get from the child the interface of the protocol identified by its GUID.
-
- @param[in] ControllerHandle Controller handle.
- @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
- service to be created.
- @param[in] ProtocolGuid GUID of the protocol to be open.
- @param[out] ChildHandle Address where the handler of the
- created child is returned. NULL is
- returned in case of error.
- @param[out] Interface Address where a pointer to the
- protocol interface is returned in
- case of success.
-
- @return EFI_SUCCESS The child was created and the protocol opened.
- @return Others Either the creation of the child or the opening
- of the protocol failed.
-**/
-STATIC
-EFI_STATUS
-CreateServiceChildAndOpenProtocol (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_GUID *ServiceBindingProtocolGuid,
- IN EFI_GUID *ProtocolGuid,
- OUT EFI_HANDLE *ChildHandle,
- OUT VOID **Interface
- );
-
-/**
- Close the protocol identified by its GUID on the child handle of the service
- identified by its service binding protocol GUID, then destroy the child
- handle.
-
- @param[in] ControllerHandle Controller handle.
- @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
- service to be destroyed.
- @param[in] ProtocolGuid GUID of the protocol to be closed.
- @param[in] ChildHandle Handle of the child to be destroyed.
-
-**/
-STATIC
-VOID
-CloseProtocolAndDestroyServiceChild (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_GUID *ServiceBindingProtocolGuid,
- IN EFI_GUID *ProtocolGuid,
- IN EFI_HANDLE ChildHandle
- );
-
-/**
- Worker function that gets the size in numbers of bytes of a file from a TFTP
- server before to download the file.
-
- @param[in] Mtftp4 MTFTP4 protocol interface
- @param[in] FilePath Path of the file, ASCII encoded
- @param[out] FileSize Address where to store the file size in number of
- bytes.
-
- @retval EFI_SUCCESS The size of the file was returned.
- @retval EFI_UNSUPPORTED The server does not support the "tsize" option.
- @retval Others Error when retrieving the information from the server
- (see EFI_MTFTP4_PROTOCOL.GetInfo() status codes)
- or error when parsing the response of the server.
-**/
-STATIC
-EFI_STATUS
-GetFileSize (
- IN EFI_MTFTP4_PROTOCOL *Mtftp4,
- IN CONST CHAR8 *FilePath,
- OUT UINTN *FileSize
- );
-
-/**
- Worker function that download the data of a file from a TFTP server given
- the path of the file and its size.
-
- @param[in] Mtftp4 MTFTP4 protocol interface
- @param[in] FilePath Path of the file, Unicode encoded
- @param[in] AsciiFilePath Path of the file, ASCII encoded
- @param[in] FileSize Size of the file in number of bytes
- @param[out] Data Address where to store the address of the buffer
- where the data of the file were downloaded in
- case of success.
-
- @retval EFI_SUCCESS The file was downloaded.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval Others The downloading of the file from the server failed
- (see EFI_MTFTP4_PROTOCOL.ReadFile() status codes).
-
-**/
-STATIC
-EFI_STATUS
-DownloadFile (
- IN EFI_MTFTP4_PROTOCOL *Mtftp4,
- IN CONST CHAR16 *FilePath,
- IN CONST CHAR8 *AsciiFilePath,
- IN UINTN FileSize,
- OUT VOID **Data
- );
-
-/**
- Update the progress of a file download
- This procedure is called each time a new TFTP packet is received.
-
- @param[in] This MTFTP4 protocol interface
- @param[in] Token Parameters for the download of the file
- @param[in] PacketLen Length of the packet
- @param[in] Packet Address of the packet
-
- @retval EFI_SUCCESS All packets are accepted.
-
-**/
-STATIC
-EFI_STATUS
-CheckPacket (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP4_PACKET *Packet
- );
-
-EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData = {
- TRUE, // Use default setting
- { { 0, 0, 0, 0 } }, // StationIp - Not relevant as UseDefaultSetting=TRUE
- { { 0, 0, 0, 0 } }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
- 0, // LocalPort - Automatically assigned port number.
- { { 0, 0, 0, 0 } }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
- { { 0, 0, 0, 0 } }, // ServerIp - Not known yet
- 69, // InitialServerPort - Standard TFTP server port
- 6, // TryCount - Max number of retransmissions.
- 4 // TimeoutValue - Retransmission timeout in seconds.
-};
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeValue},
- {L"-l", TypeValue},
- {L"-r", TypeValue},
- {L"-c", TypeValue},
- {L"-t", TypeValue},
- {NULL , TypeMax}
- };
-
-/**
- Function for 'tftp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-
- @return SHELL_SUCCESS The 'tftp' command completed successfully.
- @return SHELL_ABORTED The Shell Library initialization failed.
- @return SHELL_INVALID_PARAMETER At least one of the command's arguments is
- not valid.
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
- @return SHELL_NOT_FOUND Network Interface Card not found or server
- error or file error.
-
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTftp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- LIST_ENTRY *CheckPackage;
- CHAR16 *ProblemParam;
- UINTN ParamCount;
- CONST CHAR16 *UserNicName;
- BOOLEAN NicFound;
- CONST CHAR16 *ValueStr;
- CONST CHAR16 *RemoteFilePath;
- CHAR8 *AsciiRemoteFilePath;
- CONST CHAR16 *Walker;
- CONST CHAR16 *LocalFilePath;
- EFI_MTFTP4_CONFIG_DATA Mtftp4ConfigData;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN NicNumber;
- CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];
- EFI_HANDLE ControllerHandle;
- EFI_HANDLE Mtftp4ChildHandle;
- EFI_MTFTP4_PROTOCOL *Mtftp4;
- UINTN FileSize;
- VOID *Data;
- SHELL_FILE_HANDLE FileHandle;
-
- ShellStatus = SHELL_INVALID_PARAMETER;
- ProblemParam = NULL;
- NicFound = FALSE;
- AsciiRemoteFilePath = NULL;
- Handles = NULL;
- FileSize = 0;
-
- //
- // Initialize the Shell library (we must be in non-auto-init...)
- //
- Status = ShellInitialize ();
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return SHELL_ABORTED;
- }
-
- //
- // Parse the command line.
- //
- Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
- if (EFI_ERROR (Status)) {
- if ((Status == EFI_VOLUME_CORRUPTED) &&
- (ProblemParam != NULL) ) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellTftpHiiHandle,
- L"tftp", ProblemParam
- );
- FreePool (ProblemParam);
- } else {
- ASSERT (FALSE);
- }
- goto Error;
- }
-
- //
- // Check the number of parameters
- //
- ParamCount = ShellCommandLineGetCount (CheckPackage);
- if (ParamCount > 4) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
- gShellTftpHiiHandle, L"tftp"
- );
- goto Error;
- }
- if (ParamCount < 3) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
- gShellTftpHiiHandle, L"tftp"
- );
- goto Error;
- }
-
- Mtftp4ConfigData = DefaultMtftp4ConfigData;
-
- //
- // Check the host IPv4 address
- //
- ValueStr = ShellCommandLineGetRawValue (CheckPackage, 1);
- Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
- );
- goto Error;
- }
-
- RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);
- AsciiRemoteFilePath = AllocatePool (
- (StrLen (RemoteFilePath) + 1) * sizeof (CHAR8)
- );
- if (AsciiRemoteFilePath == NULL) {
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- goto Error;
- }
- UnicodeStrToAsciiStr (RemoteFilePath, AsciiRemoteFilePath);
-
- if (ParamCount == 4) {
- LocalFilePath = ShellCommandLineGetRawValue (CheckPackage, 3);
- } else {
- Walker = RemoteFilePath + StrLen (RemoteFilePath);
- while ((--Walker) >= RemoteFilePath) {
- if ((*Walker == L'\\') ||
- (*Walker == L'/' ) ) {
- break;
- }
- }
- LocalFilePath = Walker + 1;
- }
-
- //
- // Get the name of the Network Interface Card to be used if any.
- //
- UserNicName = ShellCommandLineGetValue (CheckPackage, L"-i");
-
- ValueStr = ShellCommandLineGetValue (CheckPackage, L"-l");
- if (ValueStr != NULL) {
- if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.LocalPort)) {
- goto Error;
- }
- }
-
- ValueStr = ShellCommandLineGetValue (CheckPackage, L"-r");
- if (ValueStr != NULL) {
- if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.InitialServerPort)) {
- goto Error;
- }
- }
-
- ValueStr = ShellCommandLineGetValue (CheckPackage, L"-c");
- if (ValueStr != NULL) {
- if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TryCount)) {
- goto Error;
- }
- }
-
- ValueStr = ShellCommandLineGetValue (CheckPackage, L"-t");
- if (ValueStr != NULL) {
- if (!StringToUint16 (ValueStr, &Mtftp4ConfigData.TimeoutValue)) {
- goto Error;
- }
- if (Mtftp4ConfigData.TimeoutValue == 0) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
- );
- goto Error;
- }
- }
-
- //
- // Locate all MTFTP4 Service Binding protocols
- //
- ShellStatus = SHELL_NOT_FOUND;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiManagedNetworkServiceBindingProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
- if (EFI_ERROR (Status) || (HandleCount == 0)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
- gShellTftpHiiHandle
- );
- goto Error;
- }
-
- for (NicNumber = 0;
- (NicNumber < HandleCount) && (ShellStatus != SHELL_SUCCESS);
- NicNumber++) {
- ControllerHandle = Handles[NicNumber];
- Data = NULL;
-
- Status = GetNicName (ControllerHandle, NicNumber, NicName);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
- gShellTftpHiiHandle, NicNumber, Status
- );
- continue;
- }
-
- if (UserNicName != NULL) {
- if (StrCmp (NicName, UserNicName) != 0) {
- continue;
- }
- NicFound = TRUE;
- }
-
- Status = CreateServiceChildAndOpenProtocol (
- ControllerHandle,
- &gEfiMtftp4ServiceBindingProtocolGuid,
- &gEfiMtftp4ProtocolGuid,
- &Mtftp4ChildHandle,
- (VOID**)&Mtftp4
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
- gShellTftpHiiHandle, NicName, Status
- );
- continue;
- }
-
- Status = Mtftp4->Configure (Mtftp4, &Mtftp4ConfigData);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
- gShellTftpHiiHandle, NicName, Status
- );
- goto NextHandle;
- }
-
- Status = GetFileSize (Mtftp4, AsciiRemoteFilePath, &FileSize);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
- gShellTftpHiiHandle, RemoteFilePath, NicName, Status
- );
- goto NextHandle;
- }
-
- Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, &Data);
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
- gShellTftpHiiHandle, RemoteFilePath, NicName, Status
- );
- goto NextHandle;
- }
-
- if (!EFI_ERROR (ShellFileExists (LocalFilePath))) {
- ShellDeleteFileByName (LocalFilePath);
- }
-
- Status = ShellOpenFileByName (
- LocalFilePath,
- &FileHandle,
- EFI_FILE_MODE_CREATE |
- EFI_FILE_MODE_WRITE |
- EFI_FILE_MODE_READ,
- 0
- );
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
- gShellTftpHiiHandle, L"tftp", LocalFilePath
- );
- goto NextHandle;
- }
-
- Status = ShellWriteFile (FileHandle, &FileSize, Data);
- if (!EFI_ERROR (Status)) {
- ShellStatus = SHELL_SUCCESS;
- } else {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE),
- gShellTftpHiiHandle, LocalFilePath, Status
- );
- }
- ShellCloseFile (&FileHandle);
-
- NextHandle:
-
- if (Data != NULL) {
- gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES (FileSize));
- }
-
- CloseProtocolAndDestroyServiceChild (
- ControllerHandle,
- &gEfiMtftp4ServiceBindingProtocolGuid,
- &gEfiMtftp4ProtocolGuid,
- Mtftp4ChildHandle
- );
- }
-
- if ((UserNicName != NULL) && (!NicFound)) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
- gShellTftpHiiHandle, UserNicName
- );
- }
-
- Error:
-
- ShellCommandLineFreeVarList (CheckPackage);
- if (AsciiRemoteFilePath != NULL) {
- FreePool (AsciiRemoteFilePath);
- }
- if (Handles != NULL) {
- FreePool (Handles);
- }
-
- return ShellStatus;
-}
-
-/**
- Check and convert the UINT16 option values of the 'tftp' command
-
- @param[in] ValueStr Value as an Unicode encoded string
- @param[out] Value UINT16 value
-
- @return TRUE The value was returned.
- @return FALSE A parsing error occured.
-**/
-STATIC
-BOOLEAN
-StringToUint16 (
- IN CONST CHAR16 *ValueStr,
- OUT UINT16 *Value
- )
-{
- UINTN Val;
-
- Val = ShellStrToUintn (ValueStr);
- if (Val > MAX_UINT16) {
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
- );
- return FALSE;
- }
-
- *Value = (UINT16)Val;
- return TRUE;
-}
-
-/**
- Get the name of the NIC.
-
- @param[in] ControllerHandle The network physical device handle.
- @param[in] NicNumber The network physical device number.
- @param[out] NicName Address where to store the NIC name.
- The memory area has to be at least
- IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH
- double byte wide.
-
- @return EFI_SUCCESS The name of the NIC was returned.
- @return Others The creation of the child for the Managed
- Network Service failed or the opening of
- the Managed Network Protocol failed or
- the operational parameters for the
- Managed Network Protocol could not be
- read.
-**/
-STATIC
-EFI_STATUS
-GetNicName (
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NicNumber,
- OUT CHAR16 *NicName
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE MnpHandle;
- EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
- EFI_SIMPLE_NETWORK_MODE SnpMode;
-
- Status = CreateServiceChildAndOpenProtocol (
- ControllerHandle,
- &gEfiManagedNetworkServiceBindingProtocolGuid,
- &gEfiManagedNetworkProtocolGuid,
- &MnpHandle,
- (VOID**)&Mnp
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- Status = Mnp->GetModeData (Mnp, NULL, &SnpMode);
- if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
- goto Error;
- }
-
- UnicodeSPrint (
- NicName,
- IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,
- SnpMode.IfType == NET_IFTYPE_ETHERNET ?
- L"eth%d" :
- L"unk%d" ,
- NicNumber
- );
-
- Status = EFI_SUCCESS;
-
-Error:
-
- if (MnpHandle != NULL) {
- CloseProtocolAndDestroyServiceChild (
- ControllerHandle,
- &gEfiManagedNetworkServiceBindingProtocolGuid,
- &gEfiManagedNetworkProtocolGuid,
- MnpHandle
- );
- }
-
- return Status;
-}
-
-/**
- Create a child for the service identified by its service binding protocol GUID
- and get from the child the interface of the protocol identified by its GUID.
-
- @param[in] ControllerHandle Controller handle.
- @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
- service to be created.
- @param[in] ProtocolGuid GUID of the protocol to be open.
- @param[out] ChildHandle Address where the handler of the
- created child is returned. NULL is
- returned in case of error.
- @param[out] Interface Address where a pointer to the
- protocol interface is returned in
- case of success.
-
- @return EFI_SUCCESS The child was created and the protocol opened.
- @return Others Either the creation of the child or the opening
- of the protocol failed.
-**/
-STATIC
-EFI_STATUS
-CreateServiceChildAndOpenProtocol (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_GUID *ServiceBindingProtocolGuid,
- IN EFI_GUID *ProtocolGuid,
- OUT EFI_HANDLE *ChildHandle,
- OUT VOID **Interface
- )
-{
- EFI_STATUS Status;
-
- *ChildHandle = NULL;
- Status = NetLibCreateServiceChild (
- ControllerHandle,
- gImageHandle,
- ServiceBindingProtocolGuid,
- ChildHandle
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- *ChildHandle,
- ProtocolGuid,
- Interface,
- gImageHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- NetLibDestroyServiceChild (
- ControllerHandle,
- gImageHandle,
- ServiceBindingProtocolGuid,
- *ChildHandle
- );
- *ChildHandle = NULL;
- }
- }
-
- return Status;
-}
-
-/**
- Close the protocol identified by its GUID on the child handle of the service
- identified by its service binding protocol GUID, then destroy the child
- handle.
-
- @param[in] ControllerHandle Controller handle.
- @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
- service to be destroyed.
- @param[in] ProtocolGuid GUID of the protocol to be closed.
- @param[in] ChildHandle Handle of the child to be destroyed.
-
-**/
-STATIC
-VOID
-CloseProtocolAndDestroyServiceChild (
- IN EFI_HANDLE ControllerHandle,
- IN EFI_GUID *ServiceBindingProtocolGuid,
- IN EFI_GUID *ProtocolGuid,
- IN EFI_HANDLE ChildHandle
- )
-{
- gBS->CloseProtocol (
- ChildHandle,
- ProtocolGuid,
- gImageHandle,
- ControllerHandle
- );
-
- NetLibDestroyServiceChild (
- ControllerHandle,
- gImageHandle,
- ServiceBindingProtocolGuid,
- ChildHandle
- );
-}
-
-/**
- Worker function that gets the size in numbers of bytes of a file from a TFTP
- server before to download the file.
-
- @param[in] Mtftp4 MTFTP4 protocol interface
- @param[in] FilePath Path of the file, ASCII encoded
- @param[out] FileSize Address where to store the file size in number of
- bytes.
-
- @retval EFI_SUCCESS The size of the file was returned.
- @retval EFI_UNSUPPORTED The server does not support the "tsize" option.
- @retval Others Error when retrieving the information from the server
- (see EFI_MTFTP4_PROTOCOL.GetInfo() status codes)
- or error when parsing the response of the server.
-**/
-STATIC
-EFI_STATUS
-GetFileSize (
- IN EFI_MTFTP4_PROTOCOL *Mtftp4,
- IN CONST CHAR8 *FilePath,
- OUT UINTN *FileSize
- )
-{
- EFI_STATUS Status;
- EFI_MTFTP4_OPTION ReqOpt[1];
- EFI_MTFTP4_PACKET *Packet;
- UINT32 PktLen;
- EFI_MTFTP4_OPTION *TableOfOptions;
- EFI_MTFTP4_OPTION *Option;
- UINT32 OptCnt;
- UINT8 OptBuf[128];
-
- ReqOpt[0].OptionStr = (UINT8*)"tsize";
- OptBuf[0] = '0';
- OptBuf[1] = 0;
- ReqOpt[0].ValueStr = OptBuf;
-
- Status = Mtftp4->GetInfo (
- Mtftp4,
- NULL,
- (UINT8*)FilePath,
- NULL,
- 1,
- ReqOpt,
- &PktLen,
- &Packet
- );
-
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- Status = Mtftp4->ParseOptions (
- Mtftp4,
- PktLen,
- Packet,
- (UINT32 *) &OptCnt,
- &TableOfOptions
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- Option = TableOfOptions;
- while (OptCnt != 0) {
- if (AsciiStrnCmp ((CHAR8 *)Option->OptionStr, "tsize", 5) == 0) {
- *FileSize = AsciiStrDecimalToUintn ((CHAR8 *)Option->ValueStr);
- break;
- }
- OptCnt--;
- Option++;
- }
- FreePool (TableOfOptions);
-
- if (OptCnt == 0) {
- Status = EFI_UNSUPPORTED;
- }
-
-Error :
-
- return Status;
-}
-
-/**
- Worker function that download the data of a file from a TFTP server given
- the path of the file and its size.
-
- @param[in] Mtftp4 MTFTP4 protocol interface
- @param[in] FilePath Path of the file, Unicode encoded
- @param[in] AsciiFilePath Path of the file, ASCII encoded
- @param[in] FileSize Size of the file in number of bytes
- @param[out] Data Address where to store the address of the buffer
- where the data of the file were downloaded in
- case of success.
-
- @retval EFI_SUCCESS The file was downloaded.
- @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
- @retval Others The downloading of the file from the server failed
- (see EFI_MTFTP4_PROTOCOL.ReadFile() status codes).
-
-**/
-STATIC
-EFI_STATUS
-DownloadFile (
- IN EFI_MTFTP4_PROTOCOL *Mtftp4,
- IN CONST CHAR16 *FilePath,
- IN CONST CHAR8 *AsciiFilePath,
- IN UINTN FileSize,
- OUT VOID **Data
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PagesAddress;
- VOID *Buffer;
- DOWNLOAD_CONTEXT *TftpContext;
- EFI_MTFTP4_TOKEN Mtftp4Token;
-
- // Downloaded file can be large. BS.AllocatePages() is more faster
- // than AllocatePool() and avoid fragmentation.
- // The downloaded file could be an EFI application. Marking the
- // allocated page as EfiBootServicesCode would allow to execute a
- // potential downloaded EFI application.
- Status = gBS->AllocatePages (
- AllocateAnyPages,
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES (FileSize),
- &PagesAddress
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Buffer = (VOID*)(UINTN)PagesAddress;
- TftpContext = AllocatePool (sizeof (DOWNLOAD_CONTEXT));
- if (TftpContext == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
- TftpContext->FileSize = FileSize;
- TftpContext->DownloadedNbOfBytes = 0;
- TftpContext->LastReportedNbOfBytes = 0;
-
- ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));
- Mtftp4Token.Filename = (UINT8*)AsciiFilePath;
- Mtftp4Token.BufferSize = FileSize;
- Mtftp4Token.Buffer = Buffer;
- Mtftp4Token.CheckPacket = CheckPacket;
- Mtftp4Token.Context = (VOID*)TftpContext;
-
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
- gShellTftpHiiHandle, FilePath
- );
-
- Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
- ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
- gShellTftpHiiHandle
- );
-
-Error :
-
- if (TftpContext == NULL) {
- FreePool (TftpContext);
- }
-
- if (EFI_ERROR (Status)) {
- gBS->FreePages (PagesAddress, EFI_SIZE_TO_PAGES (FileSize));
- return Status;
- }
-
- *Data = Buffer;
-
- return EFI_SUCCESS;
-}
-
-/**
- Update the progress of a file download
- This procedure is called each time a new TFTP packet is received.
-
- @param[in] This MTFTP4 protocol interface
- @param[in] Token Parameters for the download of the file
- @param[in] PacketLen Length of the packet
- @param[in] Packet Address of the packet
-
- @retval EFI_SUCCESS All packets are accepted.
-
-**/
-STATIC
-EFI_STATUS
-CheckPacket (
- IN EFI_MTFTP4_PROTOCOL *This,
- IN EFI_MTFTP4_TOKEN *Token,
- IN UINT16 PacketLen,
- IN EFI_MTFTP4_PACKET *Packet
- )
-{
- DOWNLOAD_CONTEXT *Context;
- CHAR16 Progress[TFTP_PROGRESS_MESSAGE_SIZE];
- UINTN NbOfKb;
- UINTN Index;
- UINTN LastStep;
- UINTN Step;
-
- if ((NTOHS (Packet->OpCode)) != EFI_MTFTP4_OPCODE_DATA) {
- return EFI_SUCCESS;
- }
-
- Context = (DOWNLOAD_CONTEXT*)Token->Context;
- if (Context->DownloadedNbOfBytes == 0) {
- ShellPrintEx (-1, -1, L"%s 0 Kb", mTftpProgressFrame);
- }
-
- //
- // The data in the packet are prepended with two UINT16 :
- // . OpCode = EFI_MTFTP4_OPCODE_DATA
- // . Block = the number of this block of data
- //
- Context->DownloadedNbOfBytes += PacketLen - sizeof (Packet->OpCode)
- - sizeof (Packet->Data.Block);
- NbOfKb = Context->DownloadedNbOfBytes / 1024;
-
- Progress[0] = L'\0';
- LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
- Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;
-
- if (Step <= LastStep) {
- return EFI_SUCCESS;
- }
-
- ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);
-
- StrCpy (Progress, mTftpProgressFrame);
- for (Index = 1; Index < Step; Index++) {
- Progress[Index] = L'=';
- }
- Progress[Step] = L'>';
-
- UnicodeSPrint (
- Progress + (sizeof (mTftpProgressFrame) / sizeof (CHAR16)) - 1,
- sizeof (Progress) - sizeof (mTftpProgressFrame),
- L" %7d Kb",
- NbOfKb
- );
- Context->LastReportedNbOfBytes = Context->DownloadedNbOfBytes;
-
- ShellPrintEx (-1, -1, L"%s", Progress);
-
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c
deleted file mode 100644
index 22c81b8d2a..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file
- Main file for NULL named library for 'tftp' Shell command functions.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-
- 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 "UefiShellTftpCommandLib.h"
-
-CONST CHAR16 gShellTftpFileName[] = L"ShellCommand";
-EFI_HANDLE gShellTftpHiiHandle = NULL;
-
-/**
- Return the file name of the help text file if not using HII.
-
- @return The string pointer to the file name.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameTftp (
- VOID
- )
-{
- return gShellTftpFileName;
-}
-
-/**
- Constructor for the Shell Tftp Command library.
-
- Install the handlers for Tftp UEFI Shell command.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-
- @retval EFI_SUCCESS The Shell command handlers were installed sucessfully.
- @retval EFI_UNSUPPORTED The Shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellTftpCommandLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- gShellTftpHiiHandle = NULL;
-
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8 (PcdShellProfileMask) & BIT3) == 0) {
- return EFI_SUCCESS;
- }
-
- gShellTftpHiiHandle = HiiAddPackages (
- &gShellTftpHiiGuid, gImageHandle,
- UefiShellTftpCommandLibStrings, NULL
- );
- if (gShellTftpHiiHandle == NULL) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Install our Shell command handler
- //
- ShellCommandRegisterCommandName (
- L"tftp", ShellCommandRunTftp, ShellCommandGetManFileNameTftp, 0,
- L"tftp", TRUE , gShellTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellTftpCommandLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellTftpHiiHandle != NULL) {
- HiiRemovePackages (gShellTftpHiiHandle);
- }
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h
deleted file mode 100644
index bef1e1d9f7..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file
- header file for NULL named library for 'tftp' Shell command functions.
-
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-
- 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.
-
-**/
-
-#ifndef _UEFI_SHELL_TFTP_COMMAND_LIB_H_
-#define _UEFI_SHELL_TFTP_COMMAND_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <Protocol/ServiceBinding.h>
-#include <Protocol/Mtftp4.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/NetLib.h>
-#include <Library/PrintLib.h>
-
-extern EFI_HANDLE gShellTftpHiiHandle;
-
-typedef struct {
- UINTN FileSize;
- UINTN DownloadedNbOfBytes;
- UINTN LastReportedNbOfBytes;
-} DOWNLOAD_CONTEXT;
-
-/**
- Function for 'tftp' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunTftp (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif /* _UEFI_SHELL_TFTP_COMMAND_LIB_H_ */
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf
deleted file mode 100644
index 96db258920..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf
+++ /dev/null
@@ -1,61 +0,0 @@
-## @file
-# Provides Shell 'tftp' command functions
-#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
-# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellTftpCommandLib
- FILE_GUID = D2B61A25-9835-4E5D-906A-15615E1FF668
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellTftpCommandLibConstructor
- DESTRUCTOR = ShellTftpCommandLibDestructor
-
-[Sources.common]
- UefiShellTftpCommandLib.uni
- UefiShellTftpCommandLib.c
- UefiShellTftpCommandLib.h
- Tftp.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- PcdLib
- HiiLib
- FileHandleLib
- NetLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
-[Protocols]
- gEfiManagedNetworkServiceBindingProtocolGuid ## CONSUMES
- gEfiMtftp4ServiceBindingProtocolGuid ## CONSUMES
-
-[Guids]
- gShellTftpHiiGuid ## CONSUMES ## HII
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
deleted file mode 100644
index 43b8cc5e7c..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
+++ /dev/null
Binary files differ