summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellDebug1CommandsLib
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib')
-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
68 files changed, 0 insertions, 39267 deletions
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