From nobody Sun May 19 21:29:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151076077504256.01436332698506; Wed, 15 Nov 2017 07:46:15 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E56BC20356865; Wed, 15 Nov 2017 07:42:03 -0800 (PST) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C491C2034EE1B for ; Wed, 15 Nov 2017 07:42:01 -0800 (PST) Received: by mail-wm0-x234.google.com with SMTP id v186so3851745wma.2 for ; Wed, 15 Nov 2017 07:46:10 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id x52sm25182630wrb.25.2017.11.15.07.46.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 07:46:04 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::234; helo=mail-wm0-x234.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=wyMWLCkW4TDjWe+0km61qf5CxRQjWIqhnaueAlcFXPE=; b=WtEPZ76e1EUE+O8qU6q4dhSR8/sWyWjdC8Guiol10+T0C5qpiLv2KwMmVOAlZyfz4s W4LGfLU7wbFfVfX5BrQjSo17MutIJbVvZAMUGhOg4sBukxLhwi3Cr8b2z6PxKyRunNzC 8qVdw5wWRieExHKUw+f3Fy5RHX30sUjIzXhyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wyMWLCkW4TDjWe+0km61qf5CxRQjWIqhnaueAlcFXPE=; b=nNUxk5dzu59l4t5Ptvi4T/HDmb3AEO86YiOZSRlcTp0X9v5NO1TijLzIHpFRtuWUWb AH0ablJ4e3zydHLs7l2NWcKDRTltGAcYlUkNmwFRnXJj6IyfsDO4/OWRnkU/27zWzTIz MZ26+uyuPkp3Eov1v7iDKaU2MJRFXZ08gkISDF/CTT5pIIYve+lPP523LAve7NWihvA9 afOq5nywWTOPW5+vhIMmZ0eJJIvae/MRW6Vw/uyRjwFry4MVcGdVqqxOEzZwzia3f25d BnWf7NFCPXW/P6+rBp93Ts9EwdwdTkuFo/EWBHxl0JvqLedGxeQwOkSHDjZsB9piU97j lysw== X-Gm-Message-State: AJaThX7geuGEVONlY8Lx8XNG9/e2/IhwY/2WfT9l0FbJ0dnVdcgzWAm2 gORAXZN4YPI+VOF929Xo62DyfWck0J4= X-Google-Smtp-Source: AGs4zMbHRRbYoUwIidUNfajFCXfbDQkz2A8G83+9b+HCsAEHf0fcm9eiNxUs7AskHd2B+gIQIItoZw== X-Received: by 10.28.126.14 with SMTP id z14mr7920383wmc.121.1510760765303; Wed, 15 Nov 2017 07:46:05 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 15 Nov 2017 15:45:53 +0000 Message-Id: <20171115154553.24275-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] EmbeddedPkg Omap35xxPkg: remove EBL and associated libraries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: afish@apple.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" EBL is a deprecated, small memory footprint alternative for the UEFI Shell that is no longer in use by any platforms in EDK2 or in edk2-platforms. To avoid confusion, let's remove it from the tree. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- BeagleBoardPkg/BeagleBoardPkg.dsc = | 3 - EmbeddedPkg/Ebl/CmdTemplate.c = | 65 - EmbeddedPkg/Ebl/Command.c = | 925 ---------- EmbeddedPkg/Ebl/Dir.c = | 357 ---- EmbeddedPkg/Ebl/Ebl.h = | 210 --- EmbeddedPkg/Ebl/Ebl.inf = | 111 -- EmbeddedPkg/Ebl/EfiDevice.c = | 1060 ------------ EmbeddedPkg/Ebl/Hob.c = | 234 --- EmbeddedPkg/Ebl/HwDebug.c = | 346 ---- EmbeddedPkg/Ebl/HwIoDebug.c = | 154 -- EmbeddedPkg/Ebl/Main.c = | 677 -------- EmbeddedPkg/Ebl/Network.c = | 106 -- EmbeddedPkg/Ebl/Script.c = | 128 -- EmbeddedPkg/Ebl/Variable.c = | 221 --- EmbeddedPkg/EblExternCmd/EntryPointGlue.c = | 154 -- EmbeddedPkg/EblExternCmd/Main.c = | 53 - EmbeddedPkg/EmbeddedPkg.dec = | 6 - EmbeddedPkg/EmbeddedPkg.dsc = | 10 - EmbeddedPkg/EmbeddedPkg.fdf = | 141 -- EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h = | 122 -- EmbeddedPkg/Include/Library/EblCmdLib.h = | 51 - EmbeddedPkg/Include/Library/EblNetworkLib.h = | 68 - EmbeddedPkg/Include/Protocol/EblAddCommand.h = | 142 -- EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.c = | 155 -- EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf = | 47 - EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c = | 28 - EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf = | 43 - EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c = | 173 -- EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf = | 34 - EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c = | 1784 -------------------- EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf = | 64 - Omap35xxPkg/Library/EblCmdLib/EblCmdLib.c = | 72 - Omap35xxPkg/Library/EblCmdLib/EblCmdLib.inf = | 48 - Omap35xxPkg/Omap35xxPkg.dsc = | 1 - 34 files changed, 7793 deletions(-) diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc b/BeagleBoardPkg/BeagleBoard= Pkg.dsc index 30f6fd02e82f..b342672c3877 100644 --- a/BeagleBoardPkg/BeagleBoardPkg.dsc +++ b/BeagleBoardPkg/BeagleBoardPkg.dsc @@ -60,8 +60,6 @@ [LibraryClasses.common] PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf =20 - EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf - # These libraries are used by the dynamic EFI Shell commands ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf @@ -265,7 +263,6 @@ [PcdsFeatureFlag.common] [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"Beagle Board" =20 - gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"BeagleEdk2" gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 diff --git a/EmbeddedPkg/Ebl/CmdTemplate.c b/EmbeddedPkg/Ebl/CmdTemplate.c deleted file mode 100644 index 2c291fcaea52..000000000000 --- a/EmbeddedPkg/Ebl/CmdTemplate.c +++ /dev/null @@ -1,65 +0,0 @@ -/** @file - %CommandName% for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Module Name: CmdTemplate.c - - Search/Replace %CommandName% with the name of your new command - -**/ - -#include "Ebl.h" - - -/** - Fill Me In - - Argv[0] - "%CommandName%" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -Ebl%CommandName%Cmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmd%CommandName%Tem= plate[] =3D -{ - { - "%CommandName%", - " [show args] ; explain args and command", - NULL, - Ebl%CommandName%Cmd - } -}; - - -/** - Initialize the commands in this file -**/ -VOID -EblInitialize%CommandName%Cmd ( - VOID - ) -{ - EblAddCommands (mCmd%CommandName%Template, sizeof (mCmd%CommandName%Temp= late)/sizeof (EBL_COMMAND_TABLE)); -} - diff --git a/EmbeddedPkg/Ebl/Command.c b/EmbeddedPkg/Ebl/Command.c deleted file mode 100644 index 4bc1f4df0ca0..000000000000 --- a/EmbeddedPkg/Ebl/Command.c +++ /dev/null @@ -1,925 +0,0 @@ -/** @file - Basic commands and command processing infrastructure for EBL - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include "Ebl.h" -#include -#include - -UINTN mCmdTableMaxIndex =3D EBL_MAX_COMMAND_COUNT; -UINTN mCmdTableNextFreeIndex =3D 0; -EBL_COMMAND_TABLE *mCmdTable[EBL_MAX_COMMAND_COUNT]; - -/** - Converts a lowercase Ascii character to upper one - - If Chr is lowercase Ascii character, then converts it to upper one. - - If Value >=3D 0xA0, then ASSERT(). - If (Value & 0x0F) >=3D 0x0A, then ASSERT(). - - @param chr one Ascii character - - @return The uppercase value of Ascii character - -**/ -STATIC -CHAR8 -AsciiToUpper ( - IN CHAR8 Chr - ) -{ - return (UINT8) ((Chr >=3D 'a' && Chr <=3D 'z') ? Chr - ('a' - 'A') : Chr= ); -} - - -/** - Case insensitive comparison of two Null-terminated Unicode strings with = maximum - lengths, and returns the difference between the first mismatched Unicode - characters. - This function compares the Null-terminated Unicode string FirstString to= the - Null-terminated Unicode string SecondString. At most, Length Unicode - characters will be compared. If Length is 0, then 0 is returned. If - FirstString is identical to SecondString, then 0 is returned. Otherwise,= the - value returned is the first mismatched Unicode character in SecondString - subtracted from the first mismatched Unicode character in FirstString. - - @param FirstString Pointer to a Null-terminated ASCII string. - @param SecondString Pointer to a Null-terminated ASCII string. - @param Length Max length to compare. - - @retval 0 FirstString is identical to SecondString using case insensit= ive - comparisons. - @retval !=3D0 FirstString is not identical to SecondString using case - insensitive comparisons. - -**/ -INTN -EFIAPI -AsciiStrniCmp ( - IN CONST CHAR8 *FirstString, - IN CONST CHAR8 *SecondString, - IN UINTN Length - ) -{ - if (Length =3D=3D 0) { - return 0; - } - - while ((AsciiToUpper (*FirstString) !=3D '\0') && - (AsciiToUpper (*FirstString) =3D=3D AsciiToUpper (*SecondString))= && - (Length > 1)) { - FirstString++; - SecondString++; - Length--; - } - - return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString); -} - - - -/** - Add a command to the mCmdTable. If there is no free space in the command - table ASSERT. The mCmdTable is maintained in alphabetical order and the - new entry is inserted into its sorted position. - - @param Entry Command Entry to add to the CmdTable - -**/ -VOID -EFIAPI -EblAddCommand ( - IN const EBL_COMMAND_TABLE *Entry - ) -{ - UINTN Count; - - if (mCmdTableNextFreeIndex =3D=3D EBL_MAX_COMMAND_COUNT) { - // - // Ran out of space to store commands. Increase EBL_MAX_COMMAND_COUNT - // - ASSERT (FALSE); - return; - } - - // - // Add command and Insertion sort array in the process - // - mCmdTable[mCmdTableNextFreeIndex] =3D (EBL_COMMAND_TABLE *)Entry; - if (mCmdTableNextFreeIndex !=3D 0) { - for (Count =3D mCmdTableNextFreeIndex; Count > 0; Count--) { - if (AsciiStriCmp (mCmdTable[Count - 1]->Name, Entry->Name) <=3D 0) { - break; - } - - mCmdTable[Count] =3D mCmdTable[Count - 1]; - } - mCmdTable[Count] =3D (EBL_COMMAND_TABLE *)Entry; - } - - mCmdTableNextFreeIndex++; -} - - -/** - Add an set of commands to the command table. Most commonly used on static - array of commands. - - @param EntryArray Pointer to array of command entries - @param ArrayCount Number of command entries to add - -**/ -VOID -EFIAPI -EblAddCommands ( - IN const EBL_COMMAND_TABLE *EntryArray, - IN UINTN ArrayCount - ) -{ - UINTN Index; - - for (Index =3D 0; Index < ArrayCount; Index++) { - EblAddCommand (&EntryArray[Index]); - } -} - - -EBL_ADD_COMMAND_PROTOCOL gEblAddCommand =3D { - EblAddCommand, - EblAddCommands, - EblGetCharKey, - EblAnyKeyToContinueQtoQuit -}; - - - -/** - Return the best matching command for the passed in command name. The mat= ch - does not have to be exact, it just needs to be unique. This enables comm= ands - to be shortened to the smallest set of starting characters that is uniqu= e. - - @param CommandName Name of command to search for - - @return NULL CommandName did not match or was not unique - Other Pointer to EBL_COMMAND_TABLE entry for CommandName - -**/ -EBL_COMMAND_TABLE * -EblGetCommand ( - IN CHAR8 *CommandName - ) -{ - UINTN Index; - UINTN BestMatchCount; - UINTN Length; - EBL_COMMAND_TABLE *Match; - CHAR8 *Str; - - Length =3D AsciiStrLen (CommandName); - Str =3D AsciiStrStr (CommandName, "."); - if (Str !=3D NULL) { - // If the command includes a trailing . command extension skip it for = the match. - // Example: hexdump.4 - Length =3D (UINTN)(Str - CommandName); - } - - for (Index =3D 0, BestMatchCount =3D 0, Match =3D NULL; Index < mCmdTabl= eNextFreeIndex; Index++) { - if (AsciiStriCmp (mCmdTable[Index]->Name, CommandName) =3D=3D 0) { - // match a command exactly - return mCmdTable[Index]; - } - - if (AsciiStrniCmp (CommandName, mCmdTable[Index]->Name, Length) =3D=3D= 0) { - // partial match, so keep looking to make sure there is only one par= tial match - BestMatchCount++; - Match =3D mCmdTable[Index]; - } - } - - if (BestMatchCount =3D=3D 1) { - return Match; - } - - // - // We had no matches or too many matches - // - return NULL; -} - - -UINTN -CountNewLines ( - IN CHAR8 *Str - ) -{ - UINTN Count; - - if (Str =3D=3D NULL) { - return 0; - } - - for (Count =3D 0; *Str !=3D '\0'; Str++) { - if (Str[Count] =3D=3D '\n') { - Count++; - } - } - - return Count; -} - - -/** - List out help information on all the commands or print extended informat= ion - about a specific passed in command. - - Argv[0] - "help" - Argv[1] - Command to display help about - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblHelpCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Index; - CHAR8 *Ptr; - UINTN CurrentRow =3D 0; - - if (Argc =3D=3D 1) { - // Print all the commands - AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for mor= e info):\n"); - CurrentRow++; - for (Index =3D 0; Index < mCmdTableNextFreeIndex; Index++) { - EblSetTextColor (EFI_YELLOW); - AsciiPrint (" %a", mCmdTable[Index]->Name); - EblSetTextColor (0); - AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary); - // Handle multi line help summaries - CurrentRow +=3D CountNewLines (mCmdTable[Index]->HelpSummary); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - } - } else if (Argv[1] !=3D NULL) { - // Print specific help - for (Index =3D 0, CurrentRow =3D 0; Index < mCmdTableNextFreeIndex; In= dex++) { - if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) =3D=3D 0) { - Ptr =3D (mCmdTable[Index]->Help =3D=3D NULL) ? mCmdTable[Index]->H= elpSummary : mCmdTable[Index]->Help; - AsciiPrint ("%a%a\n", Argv[1], Ptr); - // Handle multi line help summaries - CurrentRow +=3D CountNewLines (Ptr); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - } - } - } - - return EFI_SUCCESS; -} - - -/** - Exit the EBL. If the command processor sees EFI_ABORTED return status it= will - exit the EBL. - - Argv[0] - "exit" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_ABORTED - -**/ -EFI_STATUS -EFIAPI -EblExitCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - UINTN MemoryMapSize; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN MapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - UINTN Pages; - - if (Argc > 1) { - if (AsciiStriCmp (Argv[1], "efi") !=3D 0) { - return EFI_ABORTED; - } - } else if (Argc =3D=3D 1) { - return EFI_ABORTED; - } - - MemoryMap =3D NULL; - MemoryMapSize =3D 0; - do { - Status =3D gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - - Pages =3D EFI_SIZE_TO_PAGES (MemoryMapSize) + 1; - MemoryMap =3D AllocatePages (Pages); - - // - // Get System MemoryMap - // - Status =3D gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - // Don't do anything between the GetMemoryMap() and ExitBootServices= () - if (!EFI_ERROR (Status)) { - Status =3D gBS->ExitBootServices (gImageHandle, MapKey); - if (EFI_ERROR (Status)) { - FreePages (MemoryMap, Pages); - MemoryMap =3D NULL; - MemoryMapSize =3D 0; - } - } - } - } while (EFI_ERROR (Status)); - - // - // At this point it is very dangerous to do things EFI as most of EFI is= now gone. - // This command is useful if you are working with a debugger as it will = shutdown - // DMA and other things that could break a soft resets. - // - CpuDeadLoop (); - - // Should never get here, but makes the compiler happy - return EFI_ABORTED; -} - - -/** - Update the screen by decrementing the timeout value. - This AsciiPrint has to match the AsciiPrint in - EblPauseCmd. - - @param ElaspedTime Current timeout value remaining - -**/ -VOID -EFIAPI -EblPauseCallback ( - IN UINTN ElapsedTime - ) -{ - AsciiPrint ("\b\b\b\b\b\b\b\b\b\b\b\b \b\b%3d seconds", ElapsedTime); -} - -/** - Pause until a key is pressed and abort the remaining commands on the com= mand - line. If no key is pressed continue processing the command line. This co= mmand - allows the user to stop an operation from happening and return control t= o the - command prompt. - - Argv[0] - "pause" - Argv[1] - timeout value is decimal seconds - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS Timeout expired with no input - @return EFI_TIMEOUT Stop processing other commands on the same command = line - -**/ -EFI_STATUS -EFIAPI -EblPauseCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - UINTN Delay; - EFI_INPUT_KEY Key; - - Delay =3D (Argc =3D=3D 1)? 10 : AsciiStrDecimalToUintn (Argv[1]); - - AsciiPrint ("Hit any key to break. You have %3d seconds", Delay); - Status =3D EblGetCharKey (&Key, Delay, EblPauseCallback); - AsciiPrint ("\n"); - - // If we timeout then the pause succeeded thus return success - // If we get a key return timeout to stop other command on this cmd line - return (Status =3D=3D EFI_SUCCESS) ? EFI_TIMEOUT : EFI_SUCCESS;; -} - - -/** - On a debug build issue a software breakpoint to enter the debugger - - Argv[0] - "break" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblBreakPointCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - CpuBreakpoint (); - return EFI_SUCCESS; -} - - -/** - Reset the system. If no Argument do a Cold reset. If argument use that r= eset type - (W)arm =3D Warm Reset - (S)hutdown =3D Shutdown Reset - - Argv[0] - "reset" - Argv[1] - warm or shutdown reset type - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblResetCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_RESET_TYPE ResetType; - - ResetType =3D EfiResetCold; - if (Argc > 1) { - switch (*Argv[1]) { - case 'W': - case 'w': - ResetType =3D EfiResetWarm; - break; - case 'S': - case 's': - ResetType =3D EfiResetShutdown; - } - } - - gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL); - return EFI_SUCCESS; -} - - -/** - Toggle page break global. This turns on and off prompting to Quit or hit= any - key to continue when a command is about to scroll the screen with its ou= tput - - Argv[0] - "page" - Argv[1] - on or off - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblPageCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - if (Argc <=3D 1) { - // toggle setting - gPageBreak =3D (gPageBreak) ? FALSE : TRUE; - } else { - // use argv to set the value - if ((Argv[1][0] =3D=3D 'o') || (Argv[1][0] =3D=3D 'O')) { - if ((Argv[1][1] =3D=3D 'n') || (Argv[1][1] =3D=3D 'N')) { - gPageBreak =3D TRUE; - } else if ((Argv[1][1] =3D=3D 'f') || (Argv[1][1] =3D=3D 'F')) { - gPageBreak =3D FALSE; - } else { - return EFI_INVALID_PARAMETER; - } - } - } - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -EblSleepCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Delay; - - Delay =3D (Argc =3D=3D 1)? 10 : AsciiStrDecimalToUintn (Argv[1]); - - gBS->Stall (Delay * 1000000); - - return EFI_SUCCESS; -} - -CHAR8 -ConvertToTextLine ( - IN CHAR8 Character - ) -{ - if (Character < ' ' || Character > '~') { - return '.'; - } else { - return Character; - } -} - -UINTN -GetBytes ( - IN UINT8 *Address, - IN UINTN Bytes - ) -{ - UINTN Result =3D 0; - - if (Bytes >=3D 1) { - Result =3D *Address++; - } - if (Bytes >=3D 2) { - Result =3D (Result << 8) + *Address++; - } - if (Bytes >=3D 3) { - Result =3D (Result << 8) + *Address++; - } - return Result; -} - -CHAR8 mBlanks[] =3D " "; - -EFI_STATUS -OutputData ( - IN UINT8 *Address, - IN UINTN Length, - IN UINTN Width, - IN UINTN Offset - ) -{ - UINT8 *EndAddress; - UINTN Line; - CHAR8 TextLine[0x11]; - UINTN CurrentRow =3D 0; - UINTN Bytes; - UINTN Spaces =3D 0; - CHAR8 Blanks[80]; - - AsciiStrCpyS (Blanks, sizeof Blanks, mBlanks); - for (EndAddress =3D Address + Length; Address < EndAddress; Offset +=3D = Line) { - AsciiPrint ("%08x: ", Offset); - for (Line =3D 0; (Line < 0x10) && (Address < EndAddress);) { - Bytes =3D EndAddress - Address; - - switch (Width) { - case 4: - if (Bytes >=3D 4) { - AsciiPrint ("%08x ", *((UINT32 *)Address)); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - } else { - AsciiPrint ("%08x ", GetBytes(Address, Bytes)); - Address +=3D Bytes; - Line +=3D Bytes; - } - break; - - case 2: - if (Bytes >=3D 2) { - AsciiPrint ("%04x ", *((UINT16 *)Address)); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - } else { - AsciiPrint ("%04x ", GetBytes(Address, Bytes)); - Address +=3D Bytes; - Line +=3D Bytes; - } - break; - - case 1: - AsciiPrint ("%02x ", *((UINT8 *)Address)); - TextLine[Line++] =3D ConvertToTextLine(*Address++); - break; - - default: - AsciiPrint ("Width must be 1, 2, or 4!\n"); - return EFI_INVALID_PARAMETER; - } - } - - // Pad spaces - if (Line < 0x10) { - switch (Width) { - case 4: - Spaces =3D 9 * ((0x10 - Line)/4); - break; - case 2: - Spaces =3D 5 * ((0x10 - Line)/2); - break; - case 1: - Spaces =3D 3 * (0x10 - Line); - break; - } - - Blanks[Spaces] =3D '\0'; - - AsciiPrint(Blanks); - - Blanks[Spaces] =3D ' '; - } - - TextLine[Line] =3D 0; - AsciiPrint ("|%a|\n", TextLine); - - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - return EFI_END_OF_FILE; - } - } - - if (Length % Width !=3D 0) { - AsciiPrint ("%08x\n", Offset); - } - - return EFI_SUCCESS; -} - - -/** - See if command contains .# where # is a number. Return # as the Width - or 1 as the default Width for commands. - - Example hexdump.4 returns a width of 4. - - @param Argv Argv[0] is the command name - - @return Width of command - -**/ -UINTN -WidthFromCommandName ( - IN CHAR8 *Argv, - IN UINTN Default - ) -{ - CHAR8 *Str; - UINTN Width; - - //Hexdump.2 HexDump.4 mean use a different width - Str =3D AsciiStrStr (Argv, "."); - if (Str !=3D NULL) { - Width =3D AsciiStrDecimalToUintn (Str + 1); - if (Width =3D=3D 0) { - Width =3D Default; - } - } else { - // Default answer - return Default; - } - - return Width; -} - -#define HEXDUMP_CHUNK 1024 - -/** - Toggle page break global. This turns on and off prompting to Quit or hit= any - key to continue when a command is about to scroll the screen with its ou= tput - - Argv[0] - "hexdump"[.#] # is optional 1,2, or 4 for width - Argv[1] - Device or File to dump. - Argv[2] - Optional offset to start dumping - Argv[3] - Optional number of bytes to dump - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblHexdumpCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_OPEN_FILE *File; - VOID *Location; - UINTN Size; - UINTN Width; - UINTN Offset =3D 0; - EFI_STATUS Status; - UINTN Chunk =3D HEXDUMP_CHUNK; - - if ((Argc < 2) || (Argc > 4)) { - return EFI_INVALID_PARAMETER; - } - - Width =3D WidthFromCommandName (Argv[0], 1); - if ((Width !=3D 1) && (Width !=3D 2) && (Width !=3D 4)) { - return EFI_INVALID_PARAMETER; - } - - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - Location =3D AllocatePool (Chunk); - Size =3D (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : EfiTell (File, = NULL); - - Offset =3D 0; - if (Argc > 2) { - Offset =3D AsciiStrHexToUintn (Argv[2]); - if (Offset > 0) { - // Make sure size includes the part of the file we have skipped - Size +=3D Offset; - } - } - - Status =3D EfiSeek (File, Offset, EfiSeekStart); - if (EFI_ERROR (Status)) { - goto Exit; - } - - for (; Offset + HEXDUMP_CHUNK <=3D Size; Offset +=3D Chunk) { - Chunk =3D HEXDUMP_CHUNK; - Status =3D EfiRead (File, Location, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint ("Error reading file content\n"); - goto Exit; - } - - Status =3D OutputData (Location, Chunk, Width, File->BaseOffset + Offs= et); - if (EFI_ERROR(Status)) { - if (Status =3D=3D EFI_END_OF_FILE) { - Status =3D EFI_SUCCESS; - } - goto Exit; - } - } - - // Any left over? - if (Offset < Size) { - Chunk =3D Size - Offset; - Status =3D EfiRead (File, Location, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint ("Error reading file content\n"); - goto Exit; - } - - Status =3D OutputData (Location, Chunk, Width, File->BaseOffset + Offs= et); - if (EFI_ERROR(Status)) { - if (Status =3D=3D EFI_END_OF_FILE) { - Status =3D EFI_SUCCESS; - } - goto Exit; - } - } - -Exit: - EfiClose (File); - - FreePool (Location); - - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdTemplate[] =3D -{ - { - "reset", - " [type]; Reset system. type =3D [warm] [shutdown] default is cold res= et", - NULL, - EblResetCmd - }, - { - "exit", - "; Exit EBL", - NULL, - EblExitCmd - }, - { - "help", - " [cmd]; Help on cmd or a list of all commands if cmd is ommited", - NULL, - EblHelpCmd - }, - { - "break", - "; Generate debugging breakpoint", - NULL, - EblBreakPointCmd - }, - { - "page", - " [on|off]]; toggle promting on command output larger than screen", - NULL, - EblPageCmd - }, - { - "pause", - " [sec]; Pause for sec[10] seconds. ", - NULL, - EblPauseCmd - }, - { - "sleep", - " [sec]; Sleep for sec[10] seconds. ", - NULL, - EblSleepCmd - }, - { - "hexdump", - "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex .width", - NULL, - EblHexdumpCmd - } -}; - - -EFI_HANDLE gExternalCmdHandle =3D NULL; - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializeCmdTable ( - VOID - ) -{ - - EblAddCommands (mCmdTemplate, sizeof (mCmdTemplate)/sizeof (EBL_COMMAND_= TABLE)); - - gBS->InstallProtocolInterface ( - &gExternalCmdHandle, - &gEfiEblAddCommandProtocolGuid, - EFI_NATIVE_INTERFACE, - &gEblAddCommand - ); - -} - - -VOID -EblShutdownExternalCmdTable ( - VOID - ) -{ - gBS->UninstallProtocolInterface (gExternalCmdHandle, &gEfiEblAddCommandP= rotocolGuid, &gEblAddCommand); -} - - diff --git a/EmbeddedPkg/Ebl/Dir.c b/EmbeddedPkg/Ebl/Dir.c deleted file mode 100644 index a73c88d3aa2d..000000000000 --- a/EmbeddedPkg/Ebl/Dir.c +++ /dev/null @@ -1,357 +0,0 @@ -/** @file - Dir for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Module Name: CmdTemplate.c - - Search/Replace Dir with the name of your new command - -**/ - -#include "Ebl.h" - - -GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] =3D { - "All", - "Bin", - "section", - "SEC", - "PeiCore", - "DxeCore", - "PEIM", - "Driver", - "Combo", - "App", - "NULL", - "FV" -}; - - -/** - Perform a dir on a device. The device must support Simple File System Pr= otocol - or the FV protocol. - - Argv[0] - "dir" - Argv[1] - Device Name:path. Path is optional - Argv[2] - Optional filename to match on. A leading * means match substri= ng - Argv[3] - Optional FV file type - - dir fs1:\efi ; perform a dir on fs1: device in the efi directory - dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but - only print out files that contain the string *.efi - dir fv1:\ ; perform a dir on fv1: device in the efi directory - NOTE: fv devices do not contain subdirs - dir fv1:\ * PEIM ; will match all files of type PEIM - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblDirCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - EFI_FILE_INFO *DirInfo; - UINTN ReadSize; - UINTN CurrentRow; - CHAR16 *MatchSubString; - EFI_STATUS GetNextFileStatus; - UINTN Key; - EFI_FV_FILETYPE SearchType; - EFI_FV_FILETYPE Type; - EFI_FV_FILE_ATTRIBUTES Attributes; - UINTN Size; - EFI_GUID NameGuid; - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; - UINT32 AuthenticationStatus; - VOID *Section; - UINTN SectionSize; - EFI_FV_FILETYPE Index; - UINTN Length; - UINTN BestMatchCount; - CHAR16 UnicodeFileName[MAX_CMD_LINE]; - CHAR8 *Path; - CHAR8 *TypeStr; - UINTN TotalSize; - - - if (Argc <=3D 1) { - Path =3D EfiGetCwd (); - if (Path =3D=3D NULL) { - return EFI_SUCCESS; - } - } else { - Path =3D Argv[1]; - } - - File =3D EfiOpen (Path, EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - return EFI_SUCCESS; - } - - if (File->Type =3D=3D EfiOpenFirmwareVolume) { - // FV Dir - - SearchType =3D EFI_FV_FILETYPE_ALL; - UnicodeFileName[0] =3D '\0'; - MatchSubString =3D &UnicodeFileName[0]; - if (Argc > 2) { - AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName, - ARRAY_SIZE (UnicodeFileName)); - if (UnicodeFileName[0] =3D=3D '*') { - // Handle *Name substring matching - MatchSubString =3D &UnicodeFileName[1]; - } - - // Handle file type matchs - if (Argc > 3) { - // match a specific file type, always last argument - Length =3D AsciiStrLen (Argv[3]); - for (Index =3D 1, BestMatchCount =3D 0; Index < sizeof (gFvFileTyp= e)/sizeof (CHAR8 *); Index++) { - if (AsciiStriCmp (gFvFileType[Index], Argv[3]) =3D=3D 0) { - // exact match - SearchType =3D Index; - break; - } - - if (AsciiStrniCmp (Argv[3], gFvFileType[Index], Length) =3D=3D 0= ) { - // partial match, so keep looking to make sure there is only o= ne partial match - BestMatchCount++; - SearchType =3D Index; - } - } - - if (BestMatchCount > 1) { - SearchType =3D EFI_FV_FILETYPE_ALL; - } - } - } - - TotalSize =3D 0; - Fv =3D File->Fv; - Key =3D 0; - CurrentRow =3D 0; - do { - Type =3D SearchType; - GetNextFileStatus =3D Fv->GetNextFile ( - Fv, - &Key, - &Type, - &NameGuid, - &Attributes, - &Size - ); - if (!EFI_ERROR (GetNextFileStatus)) { - TotalSize +=3D Size; - // Calculate size of entire file - Section =3D NULL; - Size =3D 0; - Status =3D Fv->ReadFile ( - Fv, - &NameGuid, - Section, - &Size, - &Type, - &Attributes, - &AuthenticationStatus - ); - if (!((Status =3D=3D EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))= ) { - // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid - Size =3D 0; - } - - TypeStr =3D (Type <=3D EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gF= vFileType[Type] : "UNKNOWN"; - - // read the UI seciton to do a name match. - Section =3D NULL; - Status =3D Fv->ReadSection ( - Fv, - &NameGuid, - EFI_SECTION_USER_INTERFACE, - 0, - &Section, - &SectionSize, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - if (StrStr (Section, MatchSubString) !=3D NULL) { - AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Sect= ion); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - } - FreePool (Section); - } else { - if (*MatchSubString =3D=3D '\0') { - AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - } - } - } - } while (!EFI_ERROR (GetNextFileStatus)); - - if (SearchType =3D=3D EFI_FV_FILETYPE_ALL) { - AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File= ->FvSize - File->FvHeaderSize - TotalSize); - } - - - } else if ((File->Type =3D=3D EfiOpenFileSystem) || (File->Type =3D=3D E= fiOpenBlockIo)) { - // Simple File System DIR - - if (File->FsFileInfo =3D=3D NULL) { - return EFI_SUCCESS; - } - - if (!(File->FsFileInfo->Attribute & EFI_FILE_DIRECTORY)) { - return EFI_SUCCESS; - } - - // Handle *Name substring matching - MatchSubString =3D NULL; - UnicodeFileName[0] =3D '\0'; - if (Argc > 2) { - AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName, MAX_CMD_LINE); - if (UnicodeFileName[0] =3D=3D '*') { - MatchSubString =3D &UnicodeFileName[1]; - } - } - - File->FsFileHandle->SetPosition (File->FsFileHandle, 0); - for (CurrentRow =3D 0;;) { - // First read gets the size - DirInfo =3D NULL; - ReadSize =3D 0; - Status =3D File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, = DirInfo); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - // Allocate the buffer for the real read - DirInfo =3D AllocatePool (ReadSize); - if (DirInfo =3D=3D NULL) { - goto Done; - } - - // Read the data - Status =3D File->FsFileHandle->Read (File->FsFileHandle, &ReadSize= , DirInfo); - if ((EFI_ERROR (Status)) || (ReadSize =3D=3D 0)) { - break; - } - } else { - break; - } - - if (MatchSubString !=3D NULL) { - if (StrStr (&DirInfo->FileName[0], MatchSubString) =3D=3D NULL) { - // does not match *name argument, so skip - continue; - } - } else if (UnicodeFileName[0] !=3D '\0') { - // is not an exact match for name argument, so skip - if (StrCmp (&DirInfo->FileName[0], UnicodeFileName) !=3D 0) { - continue; - } - } - - if (DirInfo->Attribute & EFI_FILE_DIRECTORY) { - AsciiPrint (" %s\n", &DirInfo->FileName[0]); - } else { - AsciiPrint ("%,14ld %s\n", DirInfo->FileSize, &DirInfo->FileName[0= ]); - } - - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - - FreePool (DirInfo); - } - -Done: - if (DirInfo !=3D NULL) { - FreePool (DirInfo); - } - } - - EfiClose (File); - - return EFI_SUCCESS; -} - -/** - Change the Current Working Directory - - Argv[0] - "cd" - Argv[1] - Device Name:path. Path is optional - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblCdCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - if (Argc <=3D 1) { - return EFI_SUCCESS; - } - - return EfiSetCwd (Argv[1]); -} - - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] = =3D -{ - { - "dir", - " dirdev [*match]; directory listing of dirdev. opt match a substring", - NULL, - EblDirCmd - }, - { - "cd", - " device - set the current working directory", - NULL, - EblCdCmd - } -}; - - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializeDirCmd ( - VOID - ) -{ - if (FeaturePcdGet (PcdEmbeddedDirCmd)) { - EblAddCommands (mCmdDirTemplate, sizeof (mCmdDirTemplate)/sizeof (EBL_= COMMAND_TABLE)); - } -} - diff --git a/EmbeddedPkg/Ebl/Ebl.h b/EmbeddedPkg/Ebl/Ebl.h deleted file mode 100644 index e028735d6b8a..000000000000 --- a/EmbeddedPkg/Ebl/Ebl.h +++ /dev/null @@ -1,210 +0,0 @@ -/** @file - Include file for basic command line parser for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#ifndef __EBL_H__ -#define __EBL_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// -// Prompt for the command line -// -#define CMD_SEPARATOR ';' -#define EBL_MAX_COMMAND_COUNT 0x100 -#define MAX_CMD_HISTORY 16 -#define MAX_CMD_LINE 256 -#define MAX_ARGS 32 - -#define EBL_CR 0x0a -#define EBL_LF 0x0d - -#define EFI_SET_TIMER_TO_SECOND 10000000 - - - -EBL_COMMAND_TABLE * -EblGetCommand ( - IN CHAR8 *CommandName - ); - - -EFI_STATUS -EblPathToDevice ( - IN CHAR8 *Path, - OUT EFI_HANDLE *DeviceHandle, - OUT EFI_DEVICE_PATH_PROTOCOL **PathDevicePath, - OUT VOID **Buffer, - OUT UINTN *BufferSize - ); - -BOOLEAN -EFIAPI -EblAnyKeyToContinueQtoQuit ( - IN UINTN *CurrentRow, - IN BOOLEAN PrefixNewline - ); - -VOID -EblUpdateDeviceLists ( - VOID - ); - -VOID -EblInitializeCmdTable ( - VOID - ); - -VOID -EblShutdownExternalCmdTable ( - VOID - ); - -VOID -EblSetTextColor ( - UINTN Attribute - ); - - -EFI_STATUS -EFIAPI -EblGetCharKey ( - IN OUT EFI_INPUT_KEY *Key, - IN UINTN TimoutInSec, - IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL - ); - -// BugBug: Move me to a library -INTN -EFIAPI -AsciiStrniCmp ( - IN CONST CHAR8 *FirstString, - IN CONST CHAR8 *SecondString, - IN UINTN Length - ); - - -VOID -EblInitializeDeviceCmd ( - VOID - ); - -VOID -EblInitializemdHwDebugCmds ( - VOID - ); - -VOID -EblInitializeDirCmd ( - VOID - ); - -VOID -EblInitializeHobCmd ( - VOID - ); - -VOID -EblInitializemdHwIoDebugCmds ( - VOID - ); - -VOID -EblInitializeScriptCmd ( - VOID - ); - -VOID -EblInitializeNetworkCmd ( - VOID - ); - -VOID -EblInitializeVariableCmds ( - VOID - ); - -CHAR8 * -ParseArguments ( - IN CHAR8 *CmdLine, - OUT UINTN *Argc, - OUT CHAR8 **Argv - ); - -EFI_STATUS -ProcessCmdLine ( - IN CHAR8 *CmdLine, - IN UINTN MaxCmdLineSize - ); - -EFI_STATUS -OutputData ( - IN UINT8 *Address, - IN UINTN Length, - IN UINTN Width, - IN UINTN Offset - ); - -UINTN -WidthFromCommandName ( - IN CHAR8 *Argv, - IN UINTN Default - ); - - -extern UINTN gScreenColumns; -extern UINTN gScreenRows; -extern BOOLEAN gPageBreak; -extern CHAR8 *gMemMapType[]; - -#endif - diff --git a/EmbeddedPkg/Ebl/Ebl.inf b/EmbeddedPkg/Ebl/Ebl.inf deleted file mode 100644 index 91a82d9f8cf8..000000000000 --- a/EmbeddedPkg/Ebl/Ebl.inf +++ /dev/null @@ -1,111 +0,0 @@ -#/** @file -# EBL Applicaiton -# -# This is a shell application that will display Hello World. -# Copyright (c) 2007, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD License -# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. -# -# -#**/ - -##########################################################################= ###### -# -# Defines Section - statements that will be processed to create a Makefile. -# -##########################################################################= ###### -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D Ebl - FILE_GUID =3D 3CEF354A-3B7A-4519-AD70-72A134698311 - MODULE_TYPE =3D UEFI_APPLICATION - VERSION_STRING =3D 1.0 - ENTRY_POINT =3D EdkBootLoaderEntry - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# -[Sources.common] - Main.c - Command.c - EfiDevice.c - HwDebug.c - HwIoDebug.c - Dir.c - Hob.c - Script.c - Ebl.h - Network.c - Variable.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - -[LibraryClasses] - DebugLib - UefiLib - UefiApplicationEntryPoint - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - BaseMemoryLib - MemoryAllocationLib - DevicePathLib - IoLib - PrintLib - PcdLib - EfiFileLib - HobLib - BaseLib - EblCmdLib - EblNetworkLib - -[LibraryClasses.ARM] - SemihostLib - -[Protocols.common] - gEfiFirmwareVolume2ProtocolGuid - gEfiFirmwareVolumeBlockProtocolGuid - gEfiBlockIoProtocolGuid - gEfiSimpleFileSystemProtocolGuid - gEfiLoadFileProtocolGuid - gEfiLoadedImageProtocolGuid - gEfiPxeBaseCodeProtocolGuid - gEfiEblAddCommandProtocolGuid - gEfiDiskIoProtocolGuid - gEfiPciIoProtocolGuid - gEfiSimpleNetworkProtocolGuid - -[Guids.common] - gEfiDxeServicesTableGuid - gEfiFileInfoGuid - gEfiHobMemoryAllocModuleGuid - gEfiMemoryTypeInformationGuid - -[FeaturePcd.common] - gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot - gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd - gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd - gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd - gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable - gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd - gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd - gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable - -[FixedPcd.common] - gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand - gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor - gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize - gEmbeddedTokenSpaceGuid.PcdEmbeddedShellCharacterEcho - gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt - diff --git a/EmbeddedPkg/Ebl/EfiDevice.c b/EmbeddedPkg/Ebl/EfiDevice.c deleted file mode 100644 index f6969e7b2b05..000000000000 --- a/EmbeddedPkg/Ebl/EfiDevice.c +++ /dev/null @@ -1,1060 +0,0 @@ -/** @file - EBL commands for EFI and PI Devices - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include "Ebl.h" - - -EFI_DXE_SERVICES *gDS =3D NULL; - - -/** - Print information about the File System device. - - @param File Open File for the device - -**/ -VOID -EblPrintFsInfo ( - IN EFI_OPEN_FILE *File - ) -{ - CHAR16 *Str; - - if (File =3D=3D NULL) { - return; - } - - AsciiPrint (" %a: ", File->DeviceName); - if (File->FsInfo !=3D NULL) { - for (Str =3D File->FsInfo->VolumeLabel; *Str !=3D '\0'; Str++) { - if (*Str =3D=3D ' ') { - // UI makes you enter _ for space, so make the printout match that - *Str =3D '_'; - } - AsciiPrint ("%c", *Str); - } - AsciiPrint (":"); - if (File->FsInfo->ReadOnly) { - AsciiPrint ("ReadOnly"); - } - } - - AsciiPrint ("\n"); - EfiClose (File); -} - - -/** - Print information about the FV devices. - - @param File Open File for the device - -**/ -VOID -EblPrintFvbInfo ( - IN EFI_OPEN_FILE *File - ) -{ - if (File =3D=3D NULL) { - return; - } - - AsciiPrint (" %a: 0x%08lx - 0x%08lx : 0x%08x\n", File->DeviceName, File= ->FvStart, File->FvStart + File->FvSize - 1, File->FvSize); - EfiClose (File); -} - - -/** - Print information about the Blk IO devices. - If the device supports PXE dump out extra information - - @param File Open File for the device - -**/ -VOID -EblPrintBlkIoInfo ( - IN EFI_OPEN_FILE *File - ) -{ - UINT64 DeviceSize; - UINTN Index; - UINTN Max; - EFI_OPEN_FILE *FsFile; - - if (File =3D=3D NULL) { - return; - } - - AsciiPrint (" %a: ", File->DeviceName); - - // print out name of file system, if any, on this block device - Max =3D EfiGetDeviceCounts (EfiOpenFileSystem); - if (Max !=3D 0) { - for (Index =3D 0; Index < Max; Index++) { - FsFile =3D EfiDeviceOpenByType (EfiOpenFileSystem, Index); - if (FsFile !=3D NULL) { - if (FsFile->EfiHandle =3D=3D File->EfiHandle) { - AsciiPrint ("fs%d: ", Index); - EfiClose (FsFile); - break; - } - EfiClose (FsFile); - } - } - } - - // Print out useful Block IO media properties - if (File->FsBlockIoMedia->RemovableMedia) { - AsciiPrint ("Removable "); - } - if (!File->FsBlockIoMedia->MediaPresent) { - AsciiPrint ("No Media\n"); - } else { - if (File->FsBlockIoMedia->LogicalPartition) { - AsciiPrint ("Partition "); - } - DeviceSize =3D MultU64x32 (File->FsBlockIoMedia->LastBlock + 1, File->= FsBlockIoMedia->BlockSize); - AsciiPrint ("Size =3D 0x%lX\n", DeviceSize); - } - EfiClose (File); -} - - /** - Print information about the Load File devices. - If the device supports PXE dump out extra information - - @param File Open File for the device - -**/ -VOID -EblPrintLoadFileInfo ( - IN EFI_OPEN_FILE *File - ) -{ - EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; - MAC_ADDR_DEVICE_PATH *MacAddr; - UINTN HwAddressSize; - UINTN Index; - - if (File =3D=3D NULL) { - return; - } - - AsciiPrint (" %a: %a ", File->DeviceName, EblLoadFileBootTypeString (Fi= le->EfiHandle)); - - if (File->DevicePath !=3D NULL) { - // Try to print out the MAC address - for (DevicePathNode =3D File->DevicePath; - !IsDevicePathEnd (DevicePathNode); - DevicePathNode =3D NextDevicePathNode (DevicePathNode)) { - - if ((DevicePathType (DevicePathNode) =3D=3D MESSAGING_DEVICE_PATH) &= & (DevicePathSubType (DevicePathNode) =3D=3D MSG_MAC_ADDR_DP)) { - MacAddr =3D (MAC_ADDR_DEVICE_PATH *)DevicePathNode; - - HwAddressSize =3D sizeof (EFI_MAC_ADDRESS); - if (MacAddr->IfType =3D=3D 0x01 || MacAddr->IfType =3D=3D 0x00) { - HwAddressSize =3D 6; - } - - AsciiPrint ("MAC "); - for (Index =3D 0; Index < HwAddressSize; Index++) { - AsciiPrint ("%02x", MacAddr->MacAddress.Addr[Index] & 0xff); - } - } - } - } - - AsciiPrint ("\n"); - EfiClose (File); - return; -} - - - -/** - Dump information about devices in the system. - - fv: PI Firmware Volume - fs: EFI Simple File System - blk: EFI Block IO - LoadFile: EFI Load File Protocol (commonly PXE network boot) - - Argv[0] - "device" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblDeviceCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Index; - UINTN CurrentRow; - UINTN Max; - - CurrentRow =3D 0; - - // Need to call here to make sure Device Counts are valid - EblUpdateDeviceLists (); - - // Now we can print out the info... - Max =3D EfiGetDeviceCounts (EfiOpenFirmwareVolume); - if (Max !=3D 0) { - AsciiPrint ("Firmware Volume Devices:\n"); - for (Index =3D 0; Index < Max; Index++) { - EblPrintFvbInfo (EfiDeviceOpenByType (EfiOpenFirmwareVolume, Index)); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) { - break; - } - } - } - - Max =3D EfiGetDeviceCounts (EfiOpenFileSystem); - if (Max !=3D 0) { - AsciiPrint ("File System Devices:\n"); - for (Index =3D 0; Index < Max; Index++) { - EblPrintFsInfo (EfiDeviceOpenByType (EfiOpenFileSystem, Index)); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) { - break; - } - } - } - - Max =3D EfiGetDeviceCounts (EfiOpenBlockIo); - if (Max !=3D 0) { - AsciiPrint ("Block IO Devices:\n"); - for (Index =3D 0; Index < Max; Index++) { - EblPrintBlkIoInfo (EfiDeviceOpenByType (EfiOpenBlockIo, Index)); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) { - break; - } - } - } - - Max =3D EfiGetDeviceCounts (EfiOpenLoadFile); - if (Max !=3D 0) { - AsciiPrint ("LoadFile Devices: (usually network)\n"); - for (Index =3D 0; Index < Max; Index++) { - EblPrintLoadFileInfo (EfiDeviceOpenByType (EfiOpenLoadFile, Index)); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) { - break; - } - } - } - - return EFI_SUCCESS; -} - - -/** - Start an EFI image (PE32+ with EFI defined entry point). - - Argv[0] - "start" - Argv[1] - device name and path - Argv[2] - "" string to pass into image being started - - start fs1:\Temp\Fv.Fv "arg to pass" ; load an FV from the disk and pass = the - ; ascii string arg to pass to the im= age - start fv0:\FV ; load an FV from an FV (not common) - start LoadFile0: ; load an FV via a PXE boot - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblStartCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_HANDLE ImageHandle; - UINTN ExitDataSize; - CHAR16 *ExitData; - VOID *Buffer; - UINTN BufferSize; - EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; - - ImageHandle =3D NULL; - - if (Argc < 2) { - return EFI_INVALID_PARAMETER; - } - - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - DevicePath =3D File->DevicePath; - if (DevicePath !=3D NULL) { - // check for device path form: blk, fv, fs, and loadfile - Status =3D gBS->LoadImage (FALSE, gImageHandle, DevicePath, NULL, 0, &= ImageHandle); - } else { - // Check for buffer form: A0x12345678:0x1234 syntax. - // Means load using buffer starting at 0x12345678 of size 0x1234. - - Status =3D EfiReadAllocatePool (File, &Buffer, &BufferSize); - if (EFI_ERROR (Status)) { - EfiClose (File); - return Status; - } - Status =3D gBS->LoadImage (FALSE, gImageHandle, DevicePath, Buffer, Bu= fferSize, &ImageHandle); - - FreePool (Buffer); - } - - EfiClose (File); - - if (!EFI_ERROR (Status)) { - if (Argc >=3D 3) { - // Argv[2] is a "" string that we pass directly to the EFI applicati= on without the "" - // We don't pass Argv[0] to the EFI Application (it's name) just the= args - Status =3D gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtoco= lGuid, (VOID **)&ImageInfo); - ASSERT_EFI_ERROR (Status); - - ImageInfo->LoadOptionsSize =3D (UINT32)AsciiStrSize (Argv[2]); - ImageInfo->LoadOptions =3D AllocatePool (ImageInfo->LoadOptionsS= ize); - AsciiStrCpyS (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, Ar= gv[2]); - } - - // Transfer control to the EFI image we loaded with LoadImage() - Status =3D gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData); - } - - return Status; -} - - -/** - Load a Firmware Volume (FV) into memory from a device. This causes drive= rs in - the FV to be dispatched if the dependencies of the drivers are met. - - Argv[0] - "loadfv" - Argv[1] - device name and path - - loadfv fs1:\Temp\Fv.Fv ; load an FV from the disk - loadfv fv0:\FV ; load an FV from an FV (not common) - loadfv LoadFile0: ; load an FV via a PXE boot - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblLoadFvCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - VOID *FvStart; - UINTN FvSize; - EFI_HANDLE FvHandle; - - - if (Argc < 2) { - return EFI_INVALID_PARAMETER; - } - - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (File->Type =3D=3D EfiOpenMemoryBuffer) { - // If it is a address just use it. - Status =3D gDS->ProcessFirmwareVolume (File->Buffer, File->Size, &FvHa= ndle); - } else { - // If it is a file read it into memory and use it - Status =3D EfiReadAllocatePool (File, &FvStart, &FvSize); - EfiClose (File); - if (EFI_ERROR (Status)) { - return Status; - } - - Status =3D gDS->ProcessFirmwareVolume (FvStart, FvSize, &FvHandle); - if (EFI_ERROR (Status)) { - FreePool (FvStart); - } - } - return Status; -} - - -/** - Perform an EFI connect to connect devices that follow the EFI driver mod= el. - If it is a PI system also call the dispatcher in case a new FV was made - available by one of the connect EFI drivers (this is not a common case). - - Argv[0] - "connect" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblConnectCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Index; - BOOLEAN Dispatch; - EFI_OPEN_FILE *File; - - - if (Argc > 1) { - if ((*Argv[1] =3D=3D 'd') || (*Argv[1] =3D=3D 'D')) { - Status =3D gBS->LocateHandleBuffer ( - AllHandles, - NULL, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - for (Index =3D 0; Index < HandleCount; Index++) { - gBS->DisconnectController (HandleBuffer[Index], NULL, NULL); - } - - // - // Given we disconnect our console we should go and do a connect now - // - } else { - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File !=3D NULL) { - AsciiPrint ("Connecting %a\n", Argv[1]); - gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE); - EfiClose (File); - return EFI_SUCCESS; - } - } - } - - Dispatch =3D FALSE; - do { - Status =3D gBS->LocateHandleBuffer ( - AllHandles, - NULL, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - for (Index =3D 0; Index < HandleCount; Index++) { - gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE); - } - - FreePool (HandleBuffer); - - // - // Check to see if it's possible to dispatch an more DXE drivers. - // The BdsLibConnectAllEfi () may have made new DXE drivers show up. - // If anything is Dispatched Status =3D=3D EFI_SUCCESS and we will try - // the connect again. - // - if (gDS =3D=3D NULL) { - Status =3D EFI_NOT_FOUND; - } else { - Status =3D gDS->Dispatch (); - if (!EFI_ERROR (Status)) { - Dispatch =3D TRUE; - } - } - - } while (!EFI_ERROR (Status)); - - if (Dispatch) { - AsciiPrint ("Connected and dispatched\n"); - } else { - AsciiPrint ("Connect\n"); - } - - return EFI_SUCCESS; -} - - - -CHAR8 *gMemMapType[] =3D { - "reserved ", - "LoaderCode", - "LoaderData", - "BS_code ", - "BS_data ", - "RT_code ", - "RT_data ", - "available ", - "Unusable ", - "ACPI_recl ", - "ACPI_NVS ", - "MemMapIO ", - "MemPortIO ", - "PAL_code " -}; - - -/** - Dump out the EFI memory map - - Argv[0] - "memmap" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblMemMapCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_MEMORY_DESCRIPTOR *MemMap; - EFI_MEMORY_DESCRIPTOR *OrigMemMap; - UINTN MemMapSize; - UINTN MapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - UINT64 PageCount[EfiMaxMemoryType]; - UINTN Index; - UINT64 EntrySize; - UINTN CurrentRow; - UINT64 TotalMemory; - - ZeroMem (PageCount, sizeof (PageCount)); - - AsciiPrint ("EFI Memory Map\n"); - - // First call is to figure out how big the buffer needs to be - MemMapSize =3D 0; - MemMap =3D NULL; - Status =3D gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorS= ize, &DescriptorVersion); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - // In case the AllocatPool changes the memory map we added in some ext= ra descriptors - MemMapSize +=3D (DescriptorSize * 0x100); - OrigMemMap =3D MemMap =3D AllocatePool (MemMapSize); - if (OrigMemMap !=3D NULL) { - // 2nd time we get the data - Status =3D gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &Descrip= torSize, &DescriptorVersion); - if (!EFI_ERROR (Status)) { - for (Index =3D 0, CurrentRow =3D 0; Index < MemMapSize/DescriptorS= ize; Index++) { - EntrySize =3D LShiftU64 (MemMap->NumberOfPages, 12); - AsciiPrint ("\n%a %016lx - %016lx: # %08lx %016lx", gMemMapType[= MemMap->Type % EfiMaxMemoryType], MemMap->PhysicalStart, MemMap->PhysicalSt= art + EntrySize -1, MemMap->NumberOfPages, MemMap->Attribute); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) { - break; - } - - PageCount[MemMap->Type % EfiMaxMemoryType] +=3D MemMap->NumberOf= Pages; - MemMap =3D NEXT_MEMORY_DESCRIPTOR (MemMap, DescriptorSize); - } - } - - for (Index =3D 0, TotalMemory =3D 0; Index < EfiMaxMemoryType; Index= ++) { - if (PageCount[Index] !=3D 0) { - AsciiPrint ("\n %a %,7ld Pages (%,14ld)", gMemMapType[Index], P= ageCount[Index], LShiftU64 (PageCount[Index], 12)); - if (Index =3D=3D EfiLoaderCode || - Index =3D=3D EfiLoaderData || - Index =3D=3D EfiBootServicesCode || - Index =3D=3D EfiBootServicesData || - Index =3D=3D EfiRuntimeServicesCode || - Index =3D=3D EfiRuntimeServicesData || - Index =3D=3D EfiConventionalMemory || - Index =3D=3D EfiACPIReclaimMemory || - Index =3D=3D EfiACPIMemoryNVS || - Index =3D=3D EfiPalCode - ) { - // Count total memory - TotalMemory +=3D PageCount[Index]; - } - } - } - - AsciiPrint ("\nTotal Memory: %,ld MB (%,ld bytes)\n", RShiftU64 (Tot= alMemory, 8), LShiftU64 (TotalMemory, 12)); - - FreePool (OrigMemMap); - - } - } - - return EFI_SUCCESS; -} - - - - -/** - Load a file into memory and optionally jump to it. A load address can be - specified or automatically allocated. A quoted command line can optional= ly - be passed into the image. - - Argv[0] - "go" - Argv[1] - Device Name:path for the file to load - Argv[2] - Address to load to or '*' if the load address will be allocated - Argv[3] - Optional Entry point to the image. Image will be called if pre= sent - Argv[4] - "" string that will be passed as Argc & Argv to EntryPoint. Ne= eds - to include the command name - - go fv1:\EblCmdX 0x10000 0x10010 "EblCmdX Arg2 Arg3 Arg4"; - load EblCm= dX - from FV1 to location 0x10000 and call the entry point at 0x10010 passi= ng - in "EblCmdX Arg2 Arg3 Arg4" as the arguments. - - go fv0:\EblCmdX * 0x10 "EblCmdX Arg2 Arg3 Arg4"; - load EblCmdX from F= S0 - to location allocated by this command and call the entry point at offs= et 0x10 - passing in "EblCmdX Arg2 Arg3 Arg4" as the arguments. - - go fv1:\EblCmdX 0x10000; Load EblCmdX to address 0x10000 and return - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblGoCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - VOID *Address; - UINTN Size; - EBL_COMMMAND EntryPoint; - UINTN EntryPointArgc; - CHAR8 *EntryPointArgv[MAX_ARGS]; - - - if (Argc <=3D 2) { - // device name and laod address are required - return EFI_SUCCESS; - } - - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - AsciiPrint (" %a is not a valid path\n", Argv[1]); - return EFI_SUCCESS; - } - - EntryPoint =3D (EBL_COMMMAND)((Argc > 3) ? (UINTN)AsciiStrHexToUintn (A= rgv[3]) : (UINTN)NULL); - if (Argv[2][0] =3D=3D '*') { - // * Means allocate the buffer - Status =3D EfiReadAllocatePool (File, &Address, &Size); - - // EntryPoint is relative to the start of the image - EntryPoint =3D (EBL_COMMMAND)((UINTN)EntryPoint + (UINTN)Address); - - } else { - Address =3D (VOID *)AsciiStrHexToUintn (Argv[2]); - Size =3D File->Size; - - // File->Size for LoadFile is lazy so we need to use the tell to figur= e it out - EfiTell (File, NULL); - Status =3D EfiRead (File, Address, &Size); - } - - if (!EFI_ERROR (Status)) { - AsciiPrint ("Loaded %,d bytes to 0x%08x\n", Size, Address); - - if (Argc > 3) { - if (Argc > 4) { - ParseArguments (Argv[4], &EntryPointArgc, EntryPointArgv); - } else { - EntryPointArgc =3D 1; - EntryPointArgv[0] =3D File->FileName; - } - - Status =3D EntryPoint (EntryPointArgc, EntryPointArgv); - } - } - - EfiClose (File); - return Status; -} - -#define FILE_COPY_CHUNK 0x20000 - -EFI_STATUS -EFIAPI -EblFileCopyCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_OPEN_FILE *Source =3D NULL; - EFI_OPEN_FILE *Destination =3D NULL; - EFI_STATUS Status =3D EFI_SUCCESS; - VOID *Buffer =3D NULL; - UINTN Size; - UINTN Offset; - UINTN Chunk =3D FILE_COPY_CHUNK; - UINTN FileNameLen, DestFileNameLen; - CHAR8* DestFileName; - CHAR8* SrcFileName; - CHAR8* SrcPtr; - - if (Argc < 3) { - return EFI_INVALID_PARAMETER; - } - - DestFileName =3D Argv[2]; - FileNameLen =3D AsciiStrLen (DestFileName); - - // Check if the destination file name looks like a directory - if ((DestFileName[FileNameLen-1] =3D=3D '\\') || (DestFileName[FileNameL= en-1] =3D=3D ':')) { - // Set the pointer after the source drive (eg: after fs1:) - SrcPtr =3D AsciiStrStr (Argv[1], ":"); - if (SrcPtr =3D=3D NULL) { - SrcPtr =3D Argv[1]; - } else { - SrcPtr++; - if (*SrcPtr =3D=3D '\\') { - SrcPtr++; - } - } - - if (*SrcPtr =3D=3D '\0') { - AsciiPrint("Source file incorrect.\n"); - } - - // Skip the Source Directories - while (1) { - SrcFileName =3D SrcPtr; - SrcPtr =3D AsciiStrStr (SrcPtr,"\\"); - if (SrcPtr !=3D NULL) { - SrcPtr++; - } else { - break; - } - } - - if (*SrcFileName =3D=3D '\0') { - AsciiPrint("Source file incorrect (Error 2).\n"); - } - - // Construct the destination filepath - DestFileNameLen =3D FileNameLen + AsciiStrLen (SrcFileName) + 1; - DestFileName =3D (CHAR8*)AllocatePool (DestFileNameLen); - AsciiStrCpyS (DestFileName, DestFileNameLen, Argv[2]); - AsciiStrCatS (DestFileName, DestFileNameLen, SrcFileName); - } - - Source =3D EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0); - if (Source =3D=3D NULL) { - AsciiPrint("Source file open error.\n"); - return EFI_NOT_FOUND; - } - - Destination =3D EfiOpen(DestFileName, EFI_FILE_MODE_READ | EFI_FILE_MODE= _WRITE | EFI_FILE_MODE_CREATE, 0); - if (Destination =3D=3D NULL) { - AsciiPrint("Destination file open error.\n"); - return EFI_NOT_FOUND; - } - - Buffer =3D AllocatePool(FILE_COPY_CHUNK); - if (Buffer =3D=3D NULL) { - goto Exit; - } - - Size =3D EfiTell(Source, NULL); - - for (Offset =3D 0; Offset + FILE_COPY_CHUNK <=3D Size; Offset +=3D Chunk= ) { - Chunk =3D FILE_COPY_CHUNK; - - Status =3D EfiRead(Source, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Read file error %r\n", Status); - goto Exit; - } - - Status =3D EfiWrite(Destination, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Write file error %r\n", Status); - goto Exit; - } - } - - // Any left over? - if (Offset < Size) { - Chunk =3D Size - Offset; - - Status =3D EfiRead(Source, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Read file error %r\n", Status); - goto Exit; - } - - Status =3D EfiWrite(Destination, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Write file error %r\n", Status); - goto Exit; - } - } - - -Exit: - if (Source !=3D NULL) { - Status =3D EfiClose(Source); - if (EFI_ERROR(Status)) { - AsciiPrint("Source close error %r\n", Status); - } - } - if (Destination !=3D NULL) { - Status =3D EfiClose(Destination); - if (EFI_ERROR(Status)) { - AsciiPrint("Destination close error %r\n", Status); - } - - // Case when we have concated the filename to the destination directory - if (DestFileName !=3D Argv[2]) { - FreePool (DestFileName); - } - } - - if (Buffer !=3D NULL) { - FreePool(Buffer); - } - - return Status; -} - -EFI_STATUS -EFIAPI -EblFileDiffCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_OPEN_FILE *File1 =3D NULL; - EFI_OPEN_FILE *File2 =3D NULL; - EFI_STATUS Status =3D EFI_SUCCESS; - VOID *Buffer1 =3D NULL; - VOID *Buffer2 =3D NULL; - UINTN Size1; - UINTN Size2; - UINTN Offset; - UINTN Chunk =3D FILE_COPY_CHUNK; - - if (Argc !=3D 3) { - return EFI_INVALID_PARAMETER; - } - - File1 =3D EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0); - if (File1 =3D=3D NULL) { - AsciiPrint("File 1 open error.\n"); - return EFI_NOT_FOUND; - } - - File2 =3D EfiOpen(Argv[2], EFI_FILE_MODE_READ, 0); - if (File2 =3D=3D NULL) { - AsciiPrint("File 2 open error.\n"); - return EFI_NOT_FOUND; - } - - Size1 =3D EfiTell(File1, NULL); - Size2 =3D EfiTell(File2, NULL); - - if (Size1 !=3D Size2) { - AsciiPrint("Files differ.\n"); - goto Exit; - } - - Buffer1 =3D AllocatePool(FILE_COPY_CHUNK); - if (Buffer1 =3D=3D NULL) { - goto Exit; - } - - Buffer2 =3D AllocatePool(FILE_COPY_CHUNK); - if (Buffer2 =3D=3D NULL) { - goto Exit; - } - - for (Offset =3D 0; Offset + FILE_COPY_CHUNK <=3D Size1; Offset +=3D Chun= k) { - Chunk =3D FILE_COPY_CHUNK; - - Status =3D EfiRead(File1, Buffer1, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("File 1 read error\n"); - goto Exit; - } - - Status =3D EfiRead(File2, Buffer2, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("File 2 read error\n"); - goto Exit; - } - - if (CompareMem(Buffer1, Buffer2, Chunk) !=3D 0) { - AsciiPrint("Files differ.\n"); - goto Exit; - }; - } - - // Any left over? - if (Offset < Size1) { - Chunk =3D Size1 - Offset; - - Status =3D EfiRead(File1, Buffer1, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("File 1 read error\n"); - goto Exit; - } - - Status =3D EfiRead(File2, Buffer2, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("File 2 read error\n"); - goto Exit; - } - } - - if (CompareMem(Buffer1, Buffer2, Chunk) !=3D 0) { - AsciiPrint("Files differ.\n"); - } else { - AsciiPrint("Files are identical.\n"); - } - -Exit: - if (File1 !=3D NULL) { - Status =3D EfiClose(File1); - if (EFI_ERROR(Status)) { - AsciiPrint("File 1 close error %r\n", Status); - } - } - - if (File2 !=3D NULL) { - Status =3D EfiClose(File2); - if (EFI_ERROR(Status)) { - AsciiPrint("File 2 close error %r\n", Status); - } - } - - if (Buffer1 !=3D NULL) { - FreePool(Buffer1); - } - - if (Buffer2 !=3D NULL) { - FreePool(Buffer2); - } - - return Status; -} - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDeviceTemplate[]= =3D -{ - { - "connect", - "[d]; Connect all EFI devices. d means disconnect", - NULL, - EblConnectCmd - }, - { - "device", - "; Show information about boot devices", - NULL, - EblDeviceCmd - }, - { - "go", - " dev:path loadaddress entrypoint args; load to given address and jump= in", - NULL, - EblGoCmd - }, - { - "loadfv", - " devname; Load PI FV from device", - NULL, - EblLoadFvCmd - }, - { - "start", - " path; EFI Boot Device:filepath. fs1:\\EFI\\BOOT.EFI", - NULL, - EblStartCmd - }, - { - "memmap", - "; dump EFI memory map", - NULL, - EblMemMapCmd - }, - { - "cp", - " file1 file2; copy file only.", - NULL, - EblFileCopyCmd - }, - { - "diff", - " file1 file2; compare files", - NULL, - EblFileDiffCmd - } -}; - - -/** - Initialize the commands in this in this file -**/ - -VOID -EblInitializeDeviceCmd ( - VOID - ) -{ - EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gD= S); - EblAddCommands (mCmdDeviceTemplate, sizeof (mCmdDeviceTemplate)/sizeof (= EBL_COMMAND_TABLE)); -} - diff --git a/EmbeddedPkg/Ebl/Hob.c b/EmbeddedPkg/Ebl/Hob.c deleted file mode 100644 index edc0a744f47f..000000000000 --- a/EmbeddedPkg/Ebl/Hob.c +++ /dev/null @@ -1,234 +0,0 @@ -/** @file - Hob command for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Module Name: Hob.c - - Search/Replace Dir with the name of your new command - - Boot Mode: - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - BOOT_WITH_FULL_CONFIGURATION 0x00 - BOOT_WITH_MINIMAL_CONFIGURATION 0x01 - BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02 - BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03 - BOOT_WITH_DEFAULT_SETTINGS 0x04 - BOOT_ON_S4_RESUME 0x05 - BOOT_ON_S5_RESUME 0x06 - BOOT_ON_S2_RESUME 0x10 - BOOT_ON_S3_RESUME 0x11 - BOOT_ON_FLASH_UPDATE 0x12 - BOOT_IN_RECOVERY_MODE 0x20 - BOOT_IN_RECOVERY_MODE_MASK 0x40 - BOOT_SPECIAL_MASK 0x80 - - Mem Alloc HOB Type: - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - typedef enum { - EfiReservedMemoryType =3D 0x00 - EfiLoaderCode =3D 0x01 - EfiLoaderData =3D 0x02 - EfiBootServicesCode =3D 0x03 - EfiBootServicesData =3D 0x04 - EfiRuntimeServicesCode =3D 0x05 - EfiRuntimeServicesData =3D 0x06 - EfiConventionalMemory =3D 0x07 - EfiUnusableMemory =3D 0x08 - EfiACPIReclaimMemory =3D 0x09 - EfiACPIMemoryNVS =3D 0x0a - EfiMemoryMappedIO =3D 0x0b - EfiMemoryMappedIOPortSpace =3D 0x0c - EfiPalCode =3D 0x0d - EfiMaxMemoryType =3D 0x0e - } EFI_MEMORY_TYPE; - - Resource Hob Tye: - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - EFI_RESOURCE_SYSTEM_MEMORY 0 - EFI_RESOURCE_MEMORY_MAPPED_IO 1 - EFI_RESOURCE_IO 2 - EFI_RESOURCE_FIRMWARE_DEVICE 3 - EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4 - EFI_RESOURCE_MEMORY_RESERVED 5 - EFI_RESOURCE_IO_RESERVED 6 - EFI_RESOURCE_MAX_MEMORY_TYPE 7 - - Resource Hob Attribute (last thing printed): - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001 - EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002 - EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004 - EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008 - EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010 - EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020 - EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040 - EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080 - EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100 - EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200 - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400 - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800 - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000 - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000 - EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000 - EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000 - EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000 - EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000 - -**/ - -#include "Ebl.h" -// BugBug: Autogen does not allow this to be included currently -//#include - -GLOBAL_REMOVE_IF_UNREFERENCED char *mHobResourceType[] =3D { - "Memory ", - "MMIO ", - "IO ", - "Firmware ", - "MMIO Port ", - "Reserved ", - "IO Reserved", - "Illegal " -}; - - -/** - Dump out the HOBs in the system. HOBs are defined in the PI specification - and they are used to hand off information from PEI to DXE. - - Argv[0] - "hob" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblHobCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN CurrentRow; - EFI_PEI_HOB_POINTERS Hob; - EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation; - UINTN Index; - - CurrentRow =3D 0; - for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw =3D GET_N= EXT_HOB(Hob)) { - if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) { - AsciiPrint ("PHIT HOB Ver %x Boot Mode %02x Top %lx Bottom %lx\n", - Hob.HandoffInformationTable->Version, - Hob.HandoffInformationTable->BootMode, - Hob.HandoffInformationTable->EfiMemoryTop, - Hob.HandoffInformationTable->EfiMemoryBottom - ); - - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - return EFI_SUCCESS; - } - - AsciiPrint (" Free Top %lx Free Bottom %lx End Of HOB %lx\n", - Hob.HandoffInformationTable->EfiFreeMemoryTop, - Hob.HandoffInformationTable->EfiFreeMemoryBottom, - Hob.HandoffInformationTable->EfiEndOfHobList - ); - - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) { - // mod(%) on array index is just to prevent buffer overrun - AsciiPrint ("Mem Alloc HOB %a %g %08lx:%lx\n", - (Hob.MemoryAllocation->AllocDescriptor.MemoryType < EfiMaxMemoryTy= pe) ? gMemMapType[Hob.MemoryAllocation->AllocDescriptor.MemoryType] : "ILLE= GAL TYPE", - &Hob.MemoryAllocation->AllocDescriptor.Name, - Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress, - Hob.MemoryAllocation->AllocDescriptor.MemoryLength - ); - if (CompareGuid (&gEfiHobMemoryAllocModuleGuid, &Hob.MemoryAllocatio= n->AllocDescriptor.Name)) { - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - return EFI_SUCCESS; - } - AsciiPrint (" Module Name %g EntryPoint %lx\n", &Hob.MemoryAllo= cationModule->ModuleName, Hob.MemoryAllocationModule->EntryPoint); - } - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR= ) { - AsciiPrint ("Resource HOB %a %g %08lx:%lx\n Attributes: %08x\n", - (Hob.ResourceDescriptor->ResourceType < EFI_RESOURCE_MAX_MEMORY_TY= PE) ? mHobResourceType[Hob.ResourceDescriptor->ResourceType] : mHobResource= Type[EFI_RESOURCE_MAX_MEMORY_TYPE], - &Hob.ResourceDescriptor->Owner, - Hob.ResourceDescriptor->PhysicalStart, - Hob.ResourceDescriptor->ResourceLength, - Hob.ResourceDescriptor->ResourceAttribute - ); - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - return EFI_SUCCESS; - } - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_GUID_EXTENSION) { - AsciiPrint ("GUID HOB %g\n", &Hob.Guid->Name); - if (CompareGuid (&gEfiMemoryTypeInformationGuid, &Hob.Guid->Name)) { - EfiMemoryTypeInformation =3D GET_GUID_HOB_DATA (Hob.Guid); - for (Index =3D 0; Index < (GET_GUID_HOB_DATA_SIZE (Hob.Guid)/sizeo= f (EFI_MEMORY_TYPE_INFORMATION)); Index++, EfiMemoryTypeInformation++) { - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - return EFI_SUCCESS; - } - AsciiPrint (" %a 0x%08x\n", - (EfiMemoryTypeInformation->Type < EfiMaxMemoryType) ? gMemMapT= ype[EfiMemoryTypeInformation->Type] : "END ", - EfiMemoryTypeInformation->NumberOfPages - ); - } - } - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_FV) { - AsciiPrint ("FV HOB %08lx:%08lx\n", Hob.FirmwareVolume->BaseAddress,= Hob.FirmwareVolume->Length); - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_CPU) { - AsciiPrint ("CPU HOB: Mem %x IO %x\n", Hob.Cpu->SizeOfMemorySpace, H= ob.Cpu->SizeOfIoSpace); - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_POOL) { - AsciiPrint ("Mem Pool HOB:\n"); -/* Not in PI - } else if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_CV) { - AsciiPrint ("CV HOB: %08lx:%08lx\n", Hob.CapsuleVolume->BaseAddress,= Hob.CapsuleVolume->Length); - */ - } - - if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) { - break; - } - } - - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHobTemplate[] = =3D -{ - { - "hob", - "; dump HOBs", - NULL, - EblHobCmd - } -}; - - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializeHobCmd ( - VOID - ) -{ - if (FeaturePcdGet (PcdEmbeddedHobCmd)) { - EblAddCommands (mCmdHobTemplate, sizeof (mCmdHobTemplate)/sizeof (EBL_= COMMAND_TABLE)); - } -} - diff --git a/EmbeddedPkg/Ebl/HwDebug.c b/EmbeddedPkg/Ebl/HwDebug.c deleted file mode 100644 index a62ccdc9c521..000000000000 --- a/EmbeddedPkg/Ebl/HwDebug.c +++ /dev/null @@ -1,346 +0,0 @@ -/** @file - Basic command line parser for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Module Name: HwDebug.c - - Commands useful for debugging hardware. - -**/ - -#include "Ebl.h" - - -/** - Dump memory - - Argv[0] - "md"[.#] # is optional width 1, 2, 4, or 8. Default 1 - Argv[1] - Hex Address to dump - Argv[2] - Number of hex bytes to dump (0x20 is default) - - md.4 0x123445678 50 ; Dump 0x50 4 byte quantities starting at 0x123445678 - md 0x123445678 40 ; Dump 0x40 1 byte quantities starting at 0x123445678 - md 0x123445678 ; Dump 0x20 1 byte quantities starting at 0x123445678 - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblMdCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - STATIC UINT8 *Address =3D NULL; - STATIC UINTN Length =3D 0x20; - STATIC UINTN Width; - - Width =3D WidthFromCommandName (Argv[0], 1); - - switch (Argc) { - case 3: - Length =3D AsciiStrHexToUintn(Argv[2]); - case 2: - Address =3D (UINT8 *)AsciiStrHexToUintn (Argv[1]); - default: - break; - } - - OutputData (Address, Length, Width, (UINTN)Address); - - Address +=3D Length; - - return EFI_SUCCESS; -} - - -/** - Fill Memory with data - - Argv[0] - "mfill"[.#] # is optional width 1, 2, 4, or 8. Default 4 - Argv[1] - Hex Address to fill - Argv[2] - Data to write (0x00 is default) - Argv[3] - Number of units to dump. - - mf.1 0x123445678 aa 100 ; Start at 0x123445678 and write aa (1 byte) to = the next 100 bytes - mf.4 0x123445678 aa 100 ; Start at 0x123445678 and write aa (4 byte) to = the next 400 bytes - mf 0x123445678 aa ; Start at 0x123445678 and write aa (4 byte) to = the next 1 byte - mf 0x123445678 ; Start at 0x123445678 and write 00 (4 byte) to = the next 1 byte - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblMfillCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Address; - UINTN EndAddress; - UINT32 Data; - UINTN Length; - UINTN Width; - - if (Argc < 2) { - return EFI_INVALID_PARAMETER; - } - - Width =3D WidthFromCommandName (Argv[0], 4); - - Address =3D AsciiStrHexToUintn (Argv[1]); - Data =3D (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 0; - Length =3D (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : 1; - - for (EndAddress =3D Address + (Length * Width); Address < EndAddress; Ad= dress +=3D Width) { - if (Width =3D=3D 4) { - MmioWrite32 (Address, Data); - } else if (Width =3D=3D 2) { - MmioWrite16 (Address, (UINT16)Data); - } else { - MmioWrite8 (Address, (UINT8)Data); - } - } - - return EFI_SUCCESS; -} - - -// -// Strings for PCI Class code [2] -// -CHAR8 *gPciDevClass[] =3D { - "Old Device ", - "Mass storage ", - "Network ", - "Display ", - "Multimedia ", - "Memory controller ", - "Bridge device ", - "simple communications ", - "base system peripherals", - "Input devices ", - "Docking stations ", - "Processors ", - "serial bus ", -}; - - -CHAR8 *gPciSerialClassCodes[] =3D { - "Mass storage ", - "Firewire ", - "ACCESS bus ", - "SSA ", - "USB " -}; - - -/** - PCI Dump - - Argv[0] - "pci" - Argv[1] - bus - Argv[2] - dev - Argv[3] - func - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblPciCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *Pci; - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Seg; - UINTN Bus; - UINTN Dev; - UINTN Func; - UINTN BusArg; - UINTN DevArg; - UINTN FuncArg; - UINTN Index; - UINTN Count; - PCI_TYPE_GENERIC PciHeader; - PCI_TYPE_GENERIC *Header; - PCI_BRIDGE_CONTROL_REGISTER *Bridge; - PCI_DEVICE_HEADER_TYPE_REGION *Device; - PCI_DEVICE_INDEPENDENT_REGION *Hdr; - CHAR8 *Str; - UINTN ThisBus; - - - BusArg =3D (Argc > 1) ? AsciiStrDecimalToUintn (Argv[1]) : 0; - DevArg =3D (Argc > 2) ? AsciiStrDecimalToUintn (Argv[2]) : 0; - FuncArg =3D (Argc > 3) ? AsciiStrDecimalToUintn (Argv[3]) : 0; - - Header =3D &PciHeader; - - Status =3D gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, = NULL, &HandleCount, &HandleBuffer); - if (EFI_ERROR (Status)) { - AsciiPrint ("No PCI devices found in the system\n"); - return EFI_SUCCESS; - } - - if (Argc =3D=3D 1) { - // Dump all PCI devices - AsciiPrint ("BusDevFun VendorId DeviceId Device Class Sub-C= lass\n"); - AsciiPrint ("_________________________________________________________= ____"); - for (ThisBus =3D 0; ThisBus <=3D PCI_MAX_BUS; ThisBus++) { - for (Index =3D 0; Index < HandleCount; Index++) { - Status =3D gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoPro= tocolGuid, (VOID **)&Pci); - if (!EFI_ERROR (Status)) { - Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func); - if (ThisBus !=3D Bus) { - continue; - } - AsciiPrint ("\n%03d.%02d.%02d", Bus, Dev, Func); - Status =3D Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (P= ciHeader)/sizeof (UINT32), &PciHeader); - if (!EFI_ERROR (Status)) { - Hdr =3D &PciHeader.Bridge.Hdr; - - if (Hdr->ClassCode[2] < sizeof (gPciDevClass)/sizeof (VOID *))= { - Str =3D gPciDevClass[Hdr->ClassCode[2]]; - if (Hdr->ClassCode[2] =3D=3D PCI_CLASS_SERIAL) { - if (Hdr->ClassCode[1] < sizeof (gPciSerialClassCodes)/size= of (VOID *)) { - // print out Firewire or USB inplace of Serial Bus contr= ollers - Str =3D gPciSerialClassCodes[Hdr->ClassCode[1]]; - } - } - } else { - Str =3D "Unknown device "; - } - AsciiPrint (" 0x%04x 0x%04x %a 0x%02x", Hdr->VendorId, H= dr->DeviceId, Str, Hdr->ClassCode[1]); - } - if (Seg !=3D 0) { - // Only print Segment if it is non zero. If you only have one = PCI segment it is - // redundent to print it out - AsciiPrint (" Seg:%d", Seg); - } - } - } - } - AsciiPrint ("\n"); - } else { - // Dump specific PCI device - for (Index =3D 0; Index < HandleCount; Index++) { - Status =3D gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProto= colGuid, (VOID **)&Pci); - if (!EFI_ERROR (Status)) { - Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func); - if ((Bus =3D=3D BusArg) && (Dev =3D=3D DevArg) && (Func =3D=3D Fun= cArg)) { - // Only print Segment if it is non zero. If you only have one PC= I segment it is - // redundant to print it out - if (Seg !=3D 0) { - AsciiPrint ("Seg:%d ", Seg); - } - AsciiPrint ("Bus:%d Dev:%d Func:%d ", Bus, Dev, Func); - - Status =3D Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (P= ciHeader)/sizeof (UINT32), Header); - if (!EFI_ERROR (Status)) { - Hdr =3D &PciHeader.Bridge.Hdr; - if (IS_PCI_BRIDGE (&PciHeader.Bridge)) { - Bridge =3D &PciHeader.Bridge.Bridge; - AsciiPrint ( - "PCI Bridge. Bus Primary %d Secondary %d Subordinate %d\n", - Bridge->PrimaryBus, Bridge->SecondaryBus, Bridge->Subordin= ateBus - ); - AsciiPrint (" Bar 0: 0x%08x Bar 1: 0x%08x\n", Bridge->Bar[= 0], Bridge->Bar[1]); - } else { - Device =3D &PciHeader.Device.Device; - AsciiPrint ( - "VendorId: 0x%04x DeviceId: 0x%04x SubSusVendorId: 0x%04x = SubSysDeviceId: 0x%04x\n", - Hdr->VendorId, Hdr->DeviceId, Device->SubsystemVendorID, D= evice->SubsystemID - ); - AsciiPrint (" Class Code: 0x%02x 0x%02x 0x%02x\n", Hdr->Cla= ssCode[2], Hdr->ClassCode[1], Hdr->ClassCode[0]); - for (Count =3D 0; Count < 6; Count++) { - AsciiPrint (" Bar %d: 0x%08x\n", Count, Device->Bar[Count= ]); - } - } - } - - AsciiPrint ("\n"); - break; - } - } - } - } - - FreePool (HandleBuffer); - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdPciDebugTemplate= [] =3D { - { - "pci", - " [bus] [dev] [func]; Dump PCI", - NULL, - EblPciCmd - } -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwDebugTemplate[= ] =3D -{ - { - "md", - "[.{1|2|4}] [Addr] [Len] [1|2|4]; Memory Dump from Addr Len bytes", - NULL, - EblMdCmd - }, - { - "mfill", - "[.{1|2|4}] Addr Len [data]; Memory Fill Addr Len*(1|2|4) bytes of dat= a(0)", - NULL, - EblMfillCmd - }, -}; - - - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializemdHwDebugCmds ( - VOID - ) -{ - if (FeaturePcdGet (PcdEmbeddedHwDebugCmd)) { - EblAddCommands (mCmdHwDebugTemplate, sizeof (mCmdHwDebugTemplate)/size= of (EBL_COMMAND_TABLE)); - } - if (FeaturePcdGet (PcdEmbeddedPciDebugCmd)) { - EblAddCommands (mCmdPciDebugTemplate, sizeof (mCmdPciDebugTemplate)/si= zeof (EBL_COMMAND_TABLE)); - } -} - diff --git a/EmbeddedPkg/Ebl/HwIoDebug.c b/EmbeddedPkg/Ebl/HwIoDebug.c deleted file mode 100644 index 6c99e7af0e60..000000000000 --- a/EmbeddedPkg/Ebl/HwIoDebug.c +++ /dev/null @@ -1,154 +0,0 @@ -/** @file - Hardware IO based debug commands - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Commands useful for debugging hardware. IO commands separated out as not= all - processor architectures support the IO command. - -**/ - -#include "Ebl.h" - - - -/** - Read from IO space - - Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1 - Argv[1] - Hex IO address - - ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8 - ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8 - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblIoReadCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Width; - UINTN Port; - UINTN Data; - - if (Argc < 2) { - return EFI_INVALID_PARAMETER; - } - - Port =3D AsciiStrHexToUintn (Argv[1]); - Width =3D WidthFromCommandName (Argv[0], 1); - - if (Width =3D=3D 1) { - Data =3D IoRead8 (Port); - } else if (Width =3D=3D 2) { - Data =3D IoRead16 (Port); - } else if (Width =3D=3D 4) { - Data =3D IoRead32 (Port); - } else { - return EFI_INVALID_PARAMETER; - } - - AsciiPrint ("0x%04x =3D 0x%x", Port, Data); - - return EFI_SUCCESS; -} - - -/** - Write to IO space - - Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1 - Argv[1] - Hex IO address - Argv[2] - Hex data to write - - iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8 - iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8 - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblIoWriteCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Width; - UINTN Port; - UINTN Data; - - if (Argc < 3) { - return EFI_INVALID_PARAMETER; - } - - Port =3D AsciiStrHexToUintn (Argv[1]); - Data =3D AsciiStrHexToUintn (Argv[2]); - Width =3D WidthFromCommandName (Argv[0], 1); - - if (Width =3D=3D 1) { - IoWrite8 (Port, (UINT8)Data); - } else if (Width =3D=3D 2) { - IoWrite16 (Port, (UINT16)Data); - } else if (Width =3D=3D 4) { - IoWrite32 (Port, (UINT32)Data); - } else { - return EFI_INVALID_PARAMETER; - } - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwIoDebugTemplat= e[] =3D -{ - { - "ioread", - "[.{1|2|4}] Port ; IO read of width byte(s) from Port", - NULL, - EblIoReadCmd - }, - { - "iowrite", - "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port", - NULL, - EblIoWriteCmd - } -}; - - - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializemdHwIoDebugCmds ( - VOID - ) -{ - if (FeaturePcdGet (PcdEmbeddedIoEnable)) { - EblAddCommands (mCmdHwIoDebugTemplate, sizeof (mCmdHwIoDebugTemplate)/= sizeof (EBL_COMMAND_TABLE)); - } -} - diff --git a/EmbeddedPkg/Ebl/Main.c b/EmbeddedPkg/Ebl/Main.c deleted file mode 100644 index 62f559fccfe8..000000000000 --- a/EmbeddedPkg/Ebl/Main.c +++ /dev/null @@ -1,677 +0,0 @@ -/** @file - Basic command line parser for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - -**/ - -#include "Ebl.h" - -// Globals for command history processing -INTN mCmdHistoryEnd =3D -1; -INTN mCmdHistoryStart =3D -1; -INTN mCmdHistoryCurrent =3D -1; -CHAR8 mCmdHistory[MAX_CMD_HISTORY][MAX_CMD_LINE]; -CHAR8 *mCmdBlank =3D ""; - -// Globals to remember current screen geometry -UINTN gScreenColumns; -UINTN gScreenRows; - -// Global to turn on/off breaking commands with prompts before they scroll= the screen -BOOLEAN gPageBreak =3D TRUE; - -VOID -RingBufferIncrement ( - IN INTN *Value - ) -{ - *Value =3D *Value + 1; - - if (*Value >=3D MAX_CMD_HISTORY) { - *Value =3D 0; - } -} - -VOID -RingBufferDecrement ( - IN INTN *Value - ) -{ - *Value =3D *Value - 1; - - if (*Value < 0) { - *Value =3D MAX_CMD_HISTORY - 1; - } -} - -/** - Save this command in the circular history buffer. Older commands are - overwritten with newer commands. - - @param Cmd Command line to archive the history of. - - @return None - -**/ -VOID -SetCmdHistory ( - IN CHAR8 *Cmd - ) -{ - // Don't bother adding empty commands to the list - if (AsciiStrLen(Cmd) !=3D 0) { - - // First entry - if (mCmdHistoryStart =3D=3D -1) { - mCmdHistoryStart =3D 0; - mCmdHistoryEnd =3D 0; - } else { - // Record the new command at the next index - RingBufferIncrement(&mCmdHistoryStart); - - // If the next index runs into the end index, shuffle end back by one - if (mCmdHistoryStart =3D=3D mCmdHistoryEnd) { - RingBufferIncrement(&mCmdHistoryEnd); - } - } - - // Copy the new command line into the ring buffer - AsciiStrnCpyS (&mCmdHistory[mCmdHistoryStart][0], MAX_CMD_LINE, Cmd, M= AX_CMD_LINE); - } - - // Reset the command history for the next up arrow press - mCmdHistoryCurrent =3D mCmdHistoryStart; -} - - -/** - Retreave data from the Command History buffer. Direction maps into up ar= row - an down arrow on the command line - - @param Direction Command forward or back - - @return The Command history based on the Direction - -**/ -CHAR8 * -GetCmdHistory ( - IN UINT16 Direction - ) -{ - CHAR8 *HistoricalCommand =3D NULL; - - // No history yet? - if (mCmdHistoryCurrent =3D=3D -1) { - HistoricalCommand =3D mCmdBlank; - goto Exit; - } - - if (Direction =3D=3D SCAN_UP) { - HistoricalCommand =3D &mCmdHistory[mCmdHistoryCurrent][0]; - - // if we just echoed the last command, hang out there, don't wrap arou= nd - if (mCmdHistoryCurrent =3D=3D mCmdHistoryEnd) { - goto Exit; - } - - // otherwise, back up by one - RingBufferDecrement(&mCmdHistoryCurrent); - - } else if (Direction =3D=3D SCAN_DOWN) { - - // if we last echoed the start command, put a blank prompt out - if (mCmdHistoryCurrent =3D=3D mCmdHistoryStart) { - HistoricalCommand =3D mCmdBlank; - goto Exit; - } - - // otherwise increment the current pointer and return that command - RingBufferIncrement(&mCmdHistoryCurrent); - RingBufferIncrement(&mCmdHistoryCurrent); - - HistoricalCommand =3D &mCmdHistory[mCmdHistoryCurrent][0]; - RingBufferDecrement(&mCmdHistoryCurrent); - } - -Exit: - return HistoricalCommand; -} - - -/** - Parse the CmdLine and break it up into Argc (arg count) and Argv (array = of - pointers to each argument). The Cmd buffer is altered and separators are - converted to string terminators. This allows Argv to point into CmdLine. - A CmdLine can support multiple commands. The next command in the command= line - is returned if it exists. - - @param CmdLine String to parse for a set of commands - @param Argc Returns the number of arguments in the CmdLine current c= ommand - @param Argv Argc pointers to each string in CmdLine - - @return Next Command in the command line or NULL if non exists -**/ -CHAR8 * -ParseArguments ( - IN CHAR8 *CmdLine, - OUT UINTN *Argc, - OUT CHAR8 **Argv - ) -{ - UINTN Arg; - CHAR8 *Char; - BOOLEAN LookingForArg; - BOOLEAN InQuote; - - *Argc =3D 0; - if (AsciiStrLen (CmdLine) =3D=3D 0) { - return NULL; - } - - // Walk a single command line. A CMD_SEPARATOR allows multiple commands = on a single line - InQuote =3D FALSE; - LookingForArg =3D TRUE; - for (Char =3D CmdLine, Arg =3D 0; *Char !=3D '\0'; Char++) { - if (!InQuote && *Char =3D=3D CMD_SEPARATOR) { - break; - } - - // Perform any text conversion here - if (*Char =3D=3D '\t') { - // TAB to space - *Char =3D ' '; - } - - if (LookingForArg) { - // Look for the beginning of an Argv[] entry - if (*Char =3D=3D '"') { - Argv[Arg++] =3D ++Char; - LookingForArg =3D FALSE; - InQuote =3D TRUE; - } else if (*Char !=3D ' ') { - Argv[Arg++] =3D Char; - LookingForArg =3D FALSE; - } - } else { - // Looking for the terminator of an Argv[] entry - if (!InQuote && (*Char =3D=3D ' ')) { - *Char =3D '\0'; - LookingForArg =3D TRUE; - } else if (!InQuote && (*Char =3D=3D '"') && (*(Char-1) !=3D '\\')) { - InQuote =3D TRUE; - } else if (InQuote && (*Char =3D=3D '"') && (*(Char-1) !=3D '\\')) { - *Char =3D '\0'; - InQuote =3D FALSE; - } - } - } - - *Argc =3D Arg; - - if (*Char =3D=3D CMD_SEPARATOR) { - // Replace the command delimiter with null and return pointer to next = command line - *Char =3D '\0'; - return ++Char; - } - - return NULL; -} - - -/** - Return a keypress or optionally timeout if a timeout value was passed in. - An optional callback function is called every second when waiting for a - timeout. - - @param Key EFI Key information returned - @param TimeoutInSec Number of seconds to wait to timeout - @param CallBack Callback called every second during the timeout wa= it - - @return EFI_SUCCESS Key was returned - @return EFI_TIMEOUT If the TimoutInSec expired - -**/ -EFI_STATUS -EFIAPI -EblGetCharKey ( - IN OUT EFI_INPUT_KEY *Key, - IN UINTN TimeoutInSec, - IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL - ) -{ - EFI_STATUS Status; - UINTN WaitCount; - UINTN WaitIndex; - EFI_EVENT WaitList[2]; - - WaitCount =3D 1; - WaitList[0] =3D gST->ConIn->WaitForKey; - if (TimeoutInSec !=3D 0) { - // Create a time event for 1 sec duration if we have a timeout - gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &WaitList[1]); - gBS->SetTimer (WaitList[1], TimerPeriodic, EFI_SET_TIMER_TO_SECOND); - WaitCount++; - } - - for (;;) { - Status =3D gBS->WaitForEvent (WaitCount, WaitList, &WaitIndex); - ASSERT_EFI_ERROR (Status); - - switch (WaitIndex) { - case 0: - // Key event signaled - Status =3D gST->ConIn->ReadKeyStroke (gST->ConIn, Key); - if (!EFI_ERROR (Status)) { - if (WaitCount =3D=3D 2) { - gBS->CloseEvent (WaitList[1]); - } - return EFI_SUCCESS; - } - break; - - case 1: - // Periodic 1 sec timer signaled - TimeoutInSec--; - if (CallBack !=3D NULL) { - // Call the users callback function if registered - CallBack (TimeoutInSec); - } - if (TimeoutInSec =3D=3D 0) { - gBS->CloseEvent (WaitList[1]); - return EFI_TIMEOUT; - } - break; - default: - ASSERT (FALSE); - } - } -} - - -/** - This routine is used prevent command output data from scrolling off the = end - of the screen. The global gPageBreak is used to turn on or off this feat= ure. - If the CurrentRow is near the end of the screen pause and print out a pr= ompt - If the use hits Q to quit return TRUE else for any other key return FALS= E. - PrefixNewline is used to figure out if a newline is needed before the pr= ompt - string. This depends on the last print done before calling this function. - CurrentRow is updated by one on a call or set back to zero if a prompt is - needed. - - @param CurrentRow Used to figure out if its the end of the page and up= dated - @param PrefixNewline Did previous print issue a newline - - @return TRUE if Q was hit to quit, FALSE in all other cases. - -**/ -BOOLEAN -EFIAPI -EblAnyKeyToContinueQtoQuit ( - IN UINTN *CurrentRow, - IN BOOLEAN PrefixNewline - ) -{ - EFI_INPUT_KEY InputKey; - - if (!gPageBreak) { - // global disable for this feature - return FALSE; - } - - if (*CurrentRow >=3D (gScreenRows - 2)) { - if (PrefixNewline) { - AsciiPrint ("\n"); - } - AsciiPrint ("Any key to continue (Q to quit): "); - EblGetCharKey (&InputKey, 0, NULL); - AsciiPrint ("\n"); - - // Time to promt to stop the screen. We have to leave space for the pr= ompt string - *CurrentRow =3D 0; - if (InputKey.UnicodeChar =3D=3D 'Q' || InputKey.UnicodeChar =3D=3D 'q'= ) { - return TRUE; - } - } else { - *CurrentRow +=3D 1; - } - - return FALSE; -} - - -/** - Set the text color of the EFI Console. If a zero is passed in reset to - default text/background color. - - @param Attribute For text and background color - -**/ -VOID -EblSetTextColor ( - UINTN Attribute - ) -{ - if (Attribute =3D=3D 0) { - // Set the text color back to default - Attribute =3D (UINTN)PcdGet32 (PcdEmbeddedDefaultTextColor); - } - - gST->ConOut->SetAttribute (gST->ConOut, Attribute); -} - - -/** - Collect the keyboard input for a cmd line. Carriage Return, New Line, or= ESC - terminates the command line. You can edit the command line via left arro= w, - delete and backspace and they all back up and erase the command line. - No edit of command line is possible without deletion at this time! - The up arrow and down arrow fill Cmd with information from the history - buffer. - - @param Cmd Command line to return - @param CmdMaxSize Maximum size of Cmd - - @return The Status of EblGetCharKey() - -**/ -EFI_STATUS -GetCmd ( - IN OUT CHAR8 *Cmd, - IN UINTN CmdMaxSize - ) -{ - EFI_STATUS Status; - UINTN Index; - UINTN Index2; - CHAR8 Char; - CHAR8 *History; - EFI_INPUT_KEY Key; - - for (Index =3D 0; Index < CmdMaxSize - 1;) { - Status =3D EblGetCharKey (&Key, 0, NULL); - if (EFI_ERROR (Status)) { - Cmd[Index] =3D '\0'; - AsciiPrint ("\n"); - return Status; - } - - Char =3D (CHAR8)Key.UnicodeChar; - if ((Char =3D=3D '\n') || (Char =3D=3D '\r') || (Char =3D=3D 0x7f)) { - Cmd[Index] =3D '\0'; - if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) =3D=3D TRUE) { - AsciiPrint ("\n\r"); - } - return EFI_SUCCESS; - } else if ((Char =3D=3D '\b') || (Key.ScanCode =3D=3D SCAN_LEFT) || (K= ey.ScanCode =3D=3D SCAN_DELETE)){ - if (Index !=3D 0) { - Index--; - // - // Update the display - // - AsciiPrint ("\b \b"); - } - } else if ((Key.ScanCode =3D=3D SCAN_UP) || Key.ScanCode =3D=3D SCAN_D= OWN) { - History =3D GetCmdHistory (Key.ScanCode); - // - // Clear display line - // - for (Index2 =3D 0; Index2 < Index; Index2++) { - AsciiPrint ("\b \b"); - } - AsciiPrint (History); - Index =3D AsciiStrLen (History); - AsciiStrnCpyS (Cmd, CmdMaxSize, History, CmdMaxSize); - } else { - Cmd[Index++] =3D Char; - if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) =3D=3D TRUE) { - AsciiPrint ("%c", Char); - } - } - } - - return EFI_SUCCESS; -} - - -/** - Print the boot up banner for the EBL. -**/ -VOID -EblPrintStartupBanner ( - VOID - ) -{ - AsciiPrint ("Embedded Boot Loader ("); - EblSetTextColor (EFI_YELLOW); - AsciiPrint ("EBL"); - EblSetTextColor (0); - AsciiPrint (") prototype. Built at %a on %a\n",__TIME__, __DATE__); - AsciiPrint ("THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN 'AS = IS' BASIS,\nWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRE= SS OR IMPLIED.\n"); - AsciiPrint ("Please send feedback to edk2-devel@lists.sourceforge.net\n"= ); -} - - -/** - Send null requests to all removable media block IO devices so the a medi= a add/remove/change - can be detected in real before we execute a command. - - This is mainly due to the fact that the FAT driver does not do this toda= y so you can get stale - dir commands after an SD Card has been removed. -**/ -VOID -EblProbeRemovableMedia ( - VOID - ) -{ - UINTN Index; - UINTN Max; - EFI_OPEN_FILE *File; - - // - // Probe for media insertion/removal in removable media devices - // - Max =3D EfiGetDeviceCounts (EfiOpenBlockIo); - if (Max !=3D 0) { - for (Index =3D 0; Index < Max; Index++) { - File =3D EfiDeviceOpenByType (EfiOpenBlockIo, Index); - if (File !=3D NULL) { - if (File->FsBlockIoMedia->RemovableMedia) { - // Probe to see if media is present (or not) or media changed - // this causes the ReinstallProtocolInterface() to fire in the - // block io driver to update the system about media change even= ts - File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->M= edia->MediaId, (EFI_LBA)0, 0, NULL); - } - EfiClose (File); - } - } - } -} - - - - -/** - Print the prompt for the EBL. -**/ -VOID -EblPrompt ( - VOID - ) -{ - EblSetTextColor (EFI_YELLOW); - AsciiPrint ("%a %a",(CHAR8 *)PcdGetPtr (PcdEmbeddedPrompt), EfiGetCwd ()= ); - EblSetTextColor (0); - AsciiPrint ("%a", ">"); -} - - - -/** - Parse a command line and execute the commands. The ; separator allows - multiple commands for each command line. Stop processing if one of the - commands returns an error. - - @param CmdLine Command Line to process. - @param MaxCmdLineSize MaxSize of the Command line - - @return EFI status of the Command - -**/ -EFI_STATUS -ProcessCmdLine ( - IN CHAR8 *CmdLine, - IN UINTN MaxCmdLineSize - ) -{ - EFI_STATUS Status; - EBL_COMMAND_TABLE *Cmd; - CHAR8 *Ptr; - UINTN Argc; - CHAR8 *Argv[MAX_ARGS]; - - // Parse the command line. The loop processes commands separated by ; - for (Ptr =3D CmdLine, Status =3D EFI_SUCCESS; Ptr !=3D NULL;) { - Ptr =3D ParseArguments (Ptr, &Argc, Argv); - if (Argc !=3D 0) { - Cmd =3D EblGetCommand (Argv[0]); - if (Cmd !=3D NULL) { - // Execute the Command! - Status =3D Cmd->Command (Argc, Argv); - if (Status =3D=3D EFI_ABORTED) { - // exit command so lets exit - break; - } else if (Status =3D=3D EFI_TIMEOUT) { - // pause command got input so don't process any more cmd on this= cmd line - break; - } else if (EFI_ERROR (Status)) { - AsciiPrint ("%a returned %r error\n", Cmd->Name, Status); - // if any command fails stop processing CmdLine - break; - } - } else { - AsciiPrint ("The command '%a' is not supported.\n", Argv[0]); - } - } - } - - return Status; -} - - - -/** - Embedded Boot Loader (EBL) - A simple EFI command line application for e= mbedded - devices. PcdEmbeddedAutomaticBootCommand is a complied in command line t= hat - gets executed automatically. The ; separator allows multiple commands - for each command line. - - @param ImageHandle EFI ImageHandle for this application. - @param SystemTable EFI system table - - @return EFI status of the application - -**/ -EFI_STATUS -EFIAPI -EdkBootLoaderEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - CHAR8 CmdLine[MAX_CMD_LINE]; - CHAR16 *CommandLineVariable =3D NULL; - CHAR16 *CommandLineVariableName =3D L"default-cmdline"; - UINTN CommandLineVariableSize =3D 0; - EFI_GUID VendorGuid; - - // Initialize tables of commands - EblInitializeCmdTable (); - EblInitializeDeviceCmd (); - EblInitializemdHwDebugCmds (); - EblInitializemdHwIoDebugCmds (); - EblInitializeDirCmd (); - EblInitializeHobCmd (); - EblInitializeScriptCmd (); - EblInitializeExternalCmd (); - EblInitializeNetworkCmd(); - EblInitializeVariableCmds (); - - if (gST->ConOut =3D=3D NULL) { - DEBUG((EFI_D_ERROR,"Error: No Console Output\n")); - return EFI_NOT_READY; - } - - // Disable the 5 minute EFI watchdog time so we don't get automatically = reset - gBS->SetWatchdogTimer (0, 0, 0, NULL); - - if (FeaturePcdGet (PcdEmbeddedMacBoot)) { - // A MAC will boot in graphics mode, so turn it back to text here - // This protocol was removed from edk2. It is only an edk thing. We ne= ed to make our own copy. - // DisableQuietBoot (); - - // Enable the biggest output screen size possible - gST->ConOut->SetMode (gST->ConOut, (UINTN)gST->ConOut->Mode->MaxMode -= 1); - - } - - // Save current screen mode - gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &gScreenCo= lumns, &gScreenRows); - - EblPrintStartupBanner (); - - // Parse command line and handle commands separated by ; - // The loop prints the prompt gets user input and saves history - - // Look for a variable with a default command line, otherwise use the Pcd - ZeroMem(&VendorGuid, sizeof(EFI_GUID)); - - Status =3D gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, = &CommandLineVariableSize, CommandLineVariable); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - CommandLineVariable =3D AllocatePool(CommandLineVariableSize); - - Status =3D gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL= , &CommandLineVariableSize, CommandLineVariable); - if (!EFI_ERROR(Status)) { - UnicodeStrToAsciiStrS (CommandLineVariable, CmdLine, MAX_CMD_LINE); - } - - FreePool(CommandLineVariable); - } - - if (EFI_ERROR(Status)) { - AsciiStrCpyS (CmdLine, MAX_CMD_LINE, (CHAR8 *)PcdGetPtr (PcdEmbeddedAu= tomaticBootCommand)); - } - - for (;;) { - Status =3D ProcessCmdLine (CmdLine, MAX_CMD_LINE); - if (Status =3D=3D EFI_ABORTED) { - // if a command returns EFI_ABORTED then exit the EBL - EblShutdownExternalCmdTable (); - return EFI_SUCCESS; - } - - // get the command line from the user - EblPrompt (); - GetCmd (CmdLine, MAX_CMD_LINE); - SetCmdHistory (CmdLine); - - if (FeaturePcdGet (PcdEmbeddedProbeRemovable)) { - // Probe removable media devices to see if media has been inserted o= r removed. - EblProbeRemovableMedia (); - } - } -} - - diff --git a/EmbeddedPkg/Ebl/Network.c b/EmbeddedPkg/Ebl/Network.c deleted file mode 100644 index f2562e60b0db..000000000000 --- a/EmbeddedPkg/Ebl/Network.c +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - EBL commands for Network Devices - - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include "Ebl.h" - -EFI_STATUS -ParseIp ( - IN CHAR8 *String, - OUT EFI_IP_ADDRESS *Address - ) -{ - Address->v4.Addr[0] =3D (UINT8)AsciiStrDecimalToUintn (String); - String =3D AsciiStrStr(String, ".") + 1; - Address->v4.Addr[1] =3D (UINT8)AsciiStrDecimalToUintn (String); - String =3D AsciiStrStr(String, ".") + 1; - Address->v4.Addr[2] =3D (UINT8)AsciiStrDecimalToUintn (String); - String =3D AsciiStrStr(String, ".") + 1; - Address->v4.Addr[3] =3D (UINT8)AsciiStrDecimalToUintn (String); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -EblIpCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status =3D EFI_INVALID_PARAMETER; - EFI_MAC_ADDRESS Mac; - EFI_IP_ADDRESS Ip; - - if (Argc =3D=3D 1) { - // Get current IP/MAC - - // Get current MAC address - Status =3D EblGetCurrentMacAddress (&Mac); - if (EFI_ERROR (Status)) { - goto Exit; - } - - AsciiPrint ("MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n", Mac.Addr[= 0], Mac.Addr[1], Mac.Addr[2], Mac.Addr[3], Mac.Addr[4], Mac.Addr[5]); - - // Get current IP address - Status =3D EblGetCurrentIpAddress (&Ip); - if (EFI_ERROR(Status)) { - AsciiPrint("IP Address is not configured.\n"); - Status =3D EFI_SUCCESS; - goto Exit; - } - - AsciiPrint("IP Address: %d.%d.%d.%d\n", Ip.v4.Addr[0], Ip.v4.Addr[1]= ,Ip.v4.Addr[2], Ip.v4.Addr[3]); - - } else if ((Argv[1][0] =3D=3D 'r') && (Argc =3D=3D 2)) { - // Get new address via dhcp - Status =3D EblPerformDHCP (TRUE); - } else if ((Argv[1][0] =3D=3D 's') && (Argc =3D=3D 3)) { - // Set static IP - Status =3D ParseIp (Argv[2], &Ip); - if (EFI_ERROR (Status)) { - goto Exit; - } - - Status =3D EblSetStationIp (&Ip, NULL); - } - -Exit: - return Status; -} - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdNetworkTemplate[= ] =3D -{ - { - "ip", - " ; print current ip address\n\r [r]; request DHCP address\n\r [s]= ipaddr; set static IP address", - NULL, - EblIpCmd - } -}; - - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializeNetworkCmd ( - VOID - ) -{ - EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof= (EBL_COMMAND_TABLE)); -} - diff --git a/EmbeddedPkg/Ebl/Script.c b/EmbeddedPkg/Ebl/Script.c deleted file mode 100644 index 73360cb24840..000000000000 --- a/EmbeddedPkg/Ebl/Script.c +++ /dev/null @@ -1,128 +0,0 @@ -/** @file - Script command allows the execution of commands from a text file - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - Module Name: EfiDevice.c - -**/ - -#include "Ebl.h" - - -/** - Execute the passed in file like a series of commands. The ; can be used = on - a single line to indicate multiple commands per line. The Ascii text file - can contain any number of lines. The following line termination forms are - supported: - LF : Unix, Mac OS X*, BeOS - CR+LF: MS-DOS*, Microsoft Windows* - CR : Commodore, Apple II, and really Mac OS - LF+CR: for simplicity and completeness - - Argv[0] - "script" - Argv[1] - Device Name:path for the file to load - - script fv1:\script.txt - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -EblScriptCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - VOID *Address; - UINTN Size; - CHAR8 *Ptr; - CHAR8 *ScanPtr; - UINTN CmdLineSize; - - - - if (Argc < 2) { - // file name required - return EFI_SUCCESS; - } - - File =3D EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - AsciiPrint (" %a is not a valid path\n", Argv[1]); - return EFI_SUCCESS; - } - - Status =3D EfiReadAllocatePool (File, &Address, &Size); - if (!EFI_ERROR (Status)) { - // Loop through each line in the text file - for (Ptr =3D (CHAR8 *)Address; (Ptr < (((CHAR8 *)Address) + Size)) && = !EFI_ERROR (Status); Ptr +=3D CmdLineSize) { - for (CmdLineSize =3D 0, ScanPtr =3D Ptr; ; CmdLineSize++, ScanPtr++)= { - // look for the end of the line - if ((*ScanPtr =3D=3D EBL_CR) || (*ScanPtr =3D=3D EBL_LF)) { - // convert to NULL as this is what input routine would do - *ScanPtr =3D 0; - if ((*(ScanPtr + 1) =3D=3D EBL_CR) || (*(ScanPtr + 1) =3D=3D EBL= _LF)) { - // if its a set get the 2nd EOL char - CmdLineSize++; - *(ScanPtr + 1) =3D 0; - } - CmdLineSize++; - break; - } - - } - - Status =3D ProcessCmdLine (Ptr, CmdLineSize); - } - - FreePool (Address); - } - - EfiClose (File); - return Status; -} - - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mScriptTemplate[] = =3D { - { - "script", - " device:path; load an ascii file and execute it like commands", - NULL, - EblScriptCmd - } -}; - - -/** - Initialize the commands in this in this file -**/ - -VOID -EblInitializeScriptCmd ( - VOID - ) -{ - if (FeaturePcdGet (PcdEmbeddedScriptCmd)) { - EblAddCommands (mScriptTemplate, sizeof (mScriptTemplate)/sizeof (EBL_= COMMAND_TABLE)); - } -} - diff --git a/EmbeddedPkg/Ebl/Variable.c b/EmbeddedPkg/Ebl/Variable.c deleted file mode 100644 index 92464a6b7133..000000000000 --- a/EmbeddedPkg/Ebl/Variable.c +++ /dev/null @@ -1,221 +0,0 @@ -/** @file -* -* Copyright (c) 2011, ARM Limited. All rights reserved. -* (C) Copyright 2015 Hewlett Packard Enterprise Development LP
-* -* This program and the accompanying materials -* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. -* -**/ - -#include "Ebl.h" - -#include - -EFI_STATUS -EFIAPI -EblGetCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status =3D EFI_INVALID_PARAMETER; - UINTN Size; - VOID* Value; - CHAR8* AsciiVariableName =3D NULL; - CHAR16* VariableName; - UINTN VariableNameLen; - UINT32 Index; - - if (Argc =3D=3D 1) { - AsciiPrint("Variable name is missing.\n"); - return Status; - } - - for (Index =3D 1; Index < Argc; Index++) { - if (Argv[Index][0] =3D=3D '-') { - AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]); - } else { - AsciiVariableName =3D Argv[Index]; - } - } - - if (AsciiVariableName =3D=3D NULL) { - AsciiPrint("Variable name is missing.\n"); - return Status; - } else { - VariableNameLen =3D AsciiStrLen (AsciiVariableName) + 1; - VariableName =3D AllocatePool (VariableNameLen * sizeof (CHAR16)); - AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLe= n); - } - - // Try to get the variable size. - Value =3D NULL; - Size =3D 0; - Status =3D gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL= , &Size, Value); - if (Status =3D=3D EFI_NOT_FOUND) { - AsciiPrint("Variable name '%s' not found.\n",VariableName); - } else if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - // Get the environment variable value - Value =3D AllocatePool (Size); - if (Value =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status =3D gRT->GetVariable ((CHAR16 *)VariableName, &gEfiGlobalVariab= leGuid, NULL, &Size, Value); - if (EFI_ERROR (Status)) { - AsciiPrint("Error: '%r'\n",Status); - } else { - AsciiPrint("%a=3D%a\n",AsciiVariableName,Value); - } - FreePool(Value); - } else { - AsciiPrint("Error: '%r'\n",Status); - } - - FreePool(VariableName); - return Status; -} - -EFI_STATUS -EFIAPI -EblSetCmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - EFI_STATUS Status =3D EFI_INVALID_PARAMETER; - CHAR8* AsciiVariableSetting =3D NULL; - CHAR8* AsciiVariableName; - CHAR8* AsciiValue; - UINT32 AsciiValueLength; - CHAR16* VariableName; - UINTN VariableNameLen; - UINT32 Index; - UINT32 EscapedQuotes =3D 0; - BOOLEAN Volatile =3D FALSE; - - if (Argc =3D=3D 1) { - AsciiPrint("Variable name is missing.\n"); - return Status; - } - - for (Index =3D 1; Index < Argc; Index++) { - if (AsciiStrCmp(Argv[Index],"-v") =3D=3D 0) { - Volatile =3D 0; - } else if (Argv[Index][0] =3D=3D '-') { - AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]); - } else { - AsciiVariableSetting =3D Argv[Index]; - } - } - - if (AsciiVariableSetting =3D=3D NULL) { - AsciiPrint("Variable name is missing.\n"); - return Status; - } - - // Check if it is a valid variable setting - AsciiValue =3D AsciiStrStr (AsciiVariableSetting,"=3D"); - if (AsciiValue =3D=3D NULL) { - // - // There is no value. It means this variable will be deleted - // - - // Convert VariableName into Unicode - VariableNameLen =3D AsciiStrLen (AsciiVariableSetting) + 1; - VariableName =3D AllocatePool (VariableNameLen * sizeof (CHAR16)); - AsciiStrToUnicodeStrS (AsciiVariableSetting, VariableName, VariableNam= eLen); - - Status =3D gRT->SetVariable ( - VariableName, - &gEfiGlobalVariableGuid, - ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) | - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_R= UNTIME_ACCESS, - 0, - NULL - ); - if (!EFI_ERROR(Status)) { - AsciiPrint("Variable '%s' deleted\n",VariableName); - } else { - AsciiPrint("Variable setting is incorrect. It should be VariableName= =3DValue\n"); - } - return Status; - } - - AsciiValue[0] =3D '\0'; - AsciiVariableName =3D AsciiVariableSetting; - AsciiValue++; - - // Clean AsciiValue from quote - if (AsciiValue[0] =3D=3D '"') { - AsciiValue++; - } - AsciiValueLength =3D AsciiStrLen (AsciiValue); - if ((AsciiValue[AsciiValueLength-2] !=3D '\\') && (AsciiValue[AsciiValue= Length-1] =3D=3D '"')) { - AsciiValue[AsciiValueLength-1] =3D '\0'; - } - - // Clean AsciiValue from escaped quotes - for (Index =3D 0; Index < AsciiValueLength; Index++) { - if ((Index > 0) && (AsciiValue[Index-1] =3D=3D '\\') && (AsciiValue[In= dex] =3D=3D '"')) { - EscapedQuotes++; - } - AsciiValue[Index-EscapedQuotes] =3D AsciiValue[Index]; - } - // Fill the end of the value with '\0' - for (Index =3D 0; Index < EscapedQuotes; Index++) { - AsciiValue[AsciiValueLength-1-Index] =3D '\0'; - } - - // Convert VariableName into Unicode - VariableNameLen =3D AsciiStrLen (AsciiVariableName) + 1; - VariableName =3D AllocatePool (VariableNameLen * sizeof (CHAR16)); - AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLen); - - Status =3D gRT->SetVariable ( - VariableName, - &gEfiGlobalVariableGuid, - ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) | - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTI= ME_ACCESS, - AsciiStrLen (AsciiValue)+1, - AsciiValue - ); - if (!EFI_ERROR(Status)) { - AsciiPrint("'%a'=3D'%a'\n",AsciiVariableName,AsciiValue); - } - - return Status; -} - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdVariableTemplate= [] =3D -{ - { - "get", - " ; get UEFI variable\n\r [v]; verbose", - NULL, - EblGetCmd - }, - { - "set", - " ; set UEFI variable\n\r [v]; create volatile variable", - NULL, - EblSetCmd - } -}; - -/** - Initialize the commands in this in this file -**/ -VOID -EblInitializeVariableCmds ( - VOID - ) -{ - EblAddCommands (mCmdVariableTemplate, sizeof (mCmdVariableTemplate)/size= of (EBL_COMMAND_TABLE)); -} diff --git a/EmbeddedPkg/EblExternCmd/EntryPointGlue.c b/EmbeddedPkg/EblExt= ernCmd/EntryPointGlue.c deleted file mode 100644 index d0e549bdc189..000000000000 --- a/EmbeddedPkg/EblExternCmd/EntryPointGlue.c +++ /dev/null @@ -1,154 +0,0 @@ -/** @file - Glue code that contains the EFI entry point and converts it to an EBL - ASCII Argc, Argv sytle entry point - - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - -**/ - -#include "Ebl.h" - -#define CMD_SEPARATOR ';' -#define MAX_ARGS 32 - -EFI_STATUS -EblMain ( - IN UINTN Argc, - IN CHAR8 **Argv - ); - - -/// -/// EdkExternCmdEntry() & ParseArguments() convert the standard EFI entry = point -/// into Argc, Argv form that calls EblMain(). -/// - - -/** - Parse the CmdLine and break it up into Argc (arg count) and Argv (array = of - pointers to each argument). The Cmd buffer is altered and separators are - converted to string terminators. This allows Argv to point into CmdLine. - A CmdLine can support multiple commands. The next command in the command= line - is returned if it exists. - - @param CmdLine String to parse for a set of commands - @param CmdLineSize Size of CmdLine in bytes - @param Argc Returns the number of arguments in the CmdLine curre= nt command - @param Argv Argc pointers to each string in CmdLine - - @return Next Command in the command line or NULL if non exists -**/ -VOID -ParseArguments ( - IN CHAR8 *CmdLine, - IN UINTN CmdLineSize, - OUT UINTN *Argc, - OUT CHAR8 **Argv - ) -{ - UINTN Arg; - CHAR8 *Char; - BOOLEAN LookingForArg; - BOOLEAN InQuote; - UINTN Index; - - *Argc =3D 0; - if ((CmdLineSize =3D=3D 0) || (AsciiStrLen (CmdLine) =3D=3D 0)) { - // basic error checking failed on the arguments - return; - } - - // Walk a single command line. A CMD_SEPARATOR allows multiple commands = on a single line - InQuote =3D FALSE; - LookingForArg =3D TRUE; - for (Char =3D CmdLine, Arg =3D 0, Index =3D 0; *Char !=3D '\0' && *Char = !=3D CMD_SEPARATOR; Char++, Index++) { - // Perform any text conversion here - if (*Char =3D=3D '\t') { - // TAB to space - *Char =3D ' '; - } - - if (LookingForArg) { - // Look for the beginning of an Argv[] entry - if (*Char =3D=3D '"') { - Argv[Arg++] =3D ++Char; - LookingForArg =3D FALSE; - InQuote =3D TRUE; - } else if (*Char !=3D ' ') { - Argv[Arg++] =3D Char; - LookingForArg =3D FALSE; - } - } else { - // Looking for the terminator of an Argv[] entry - if ((InQuote && (*Char =3D=3D '"')) || (!InQuote && (*Char =3D=3D ' = '))) { - *Char =3D '\0'; - LookingForArg =3D TRUE; - } - } - - if ((Arg >=3D MAX_ARGS) || (Index > CmdLineSize)) { - // Error check buffer and exit since it does not look valid - break; - } - } - - *Argc =3D Arg; - - if (*Char =3D=3D CMD_SEPARATOR) { - // Replace the command delimiter with null - *Char =3D '\0'; - } - - return; -} - - - - -/** - Embedded Boot Loader (EBL) - A simple EFI command line application for e= mbedded - devices. PcdEmbeddedAutomaticBootCommand is a complied in command line t= hat - gets executed automatically. The ; separator allows multiple commands - for each command line. - - @param ImageHandle EFI ImageHandle for this application. - @param SystemTable EFI system table - - @return EFI status of the application - -**/ -EFI_STATUS -EFIAPI -EdkExternCmdEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; - UINTN Argc; - CHAR8 *Argv[MAX_ARGS]; - - Status =3D gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGui= d, (VOID **)&ImageInfo); - if (EFI_ERROR (Status)) { - Argc =3D 0; - } else { - // Looks like valid commands were passed in. - ParseArguments (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, &A= rgc, Argv); - } - - return EblMain (Argc, Argv); -} - - diff --git a/EmbeddedPkg/EblExternCmd/Main.c b/EmbeddedPkg/EblExternCmd/Mai= n.c deleted file mode 100644 index dbfe336899c7..000000000000 --- a/EmbeddedPkg/EblExternCmd/Main.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - Example of an external EBL command. It's loaded via EBL start command. - Argc and Argv are passed in via "" of the EBL command line. - - Start fs0:\EdkExternCmd.efi "Argv[0] Argv[1] 2" - - will launch this command with - Argv[0] =3D "Argv[0]" - Argv[1] =3D "Argv[2]" - Argv[2] =3D "3" - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - -**/ - -#include "Ebl.h" - -/** - Entry point with Argc, Argv. Put your code here. - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EblMain ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - UINTN Index; - - AsciiPrint ("Hello World\n"); - for (Index =3D 0; Index < Argc; Index++) { - AsciiPrint ("Argv[%d] =3D %a\n", Index, Argv[Index]); - } - - return EFI_SUCCESS; -} - diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index af9b221f4f07..adcf65be93b3 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -36,13 +36,9 @@ [Includes.common] Include # Root include for the package =20 [LibraryClasses.common] - EfiFileLib|Include/Library/EfiFileLib.h PrePiLib|Include/Library/PrePiLib.h RealTimeClockLib|Include/Library/RealTimeClockLib.h EfiResetSystemLib|Include/Library/EfiResetSystemLib.h - EblCmdLib|Include/Library/EblCmdLib.h - EblAddExternalCommandLib|Include/Library/EblAddExternalCommandLib.h - EblNetworkLib|Include/Library/EblNetworkLib.h GdbSerialLib|Include/Library/GdbSerialLib.h DebugAgentTimerLib|Include/Library/DebugAgentTimerLib.h NorFlashInfoLib|Include/Library/NorFlashInfoLib.h @@ -75,7 +71,6 @@ [Protocols.common] gHardwareInterruptProtocolGuid =3D { 0x2890B3EA, 0x053D, 0x1643, { 0xAD= , 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } } gHardwareInterrupt2ProtocolGuid =3D { 0x32898322, 0x2da1, 0x474a, { 0xba= , 0xaa, 0xf3, 0xf7, 0xcf, 0x56, 0x94, 0x70 } } gEfiDebugSupportPeriodicCallbackProtocolGuid =3D { 0x9546e07c, 0x2cbb, 0= x4c88, { 0x98, 0x6c, 0xcd, 0x34, 0x10, 0x86, 0xf0, 0x44 } } - gEfiEblAddCommandProtocolGuid =3D { 0xaeda2428, 0x9a22, 0x4637, { 0x9b= , 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8, 0x29 } } gEmbeddedDeviceGuid =3D { 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0x= e9, 0xb, 0x71, 0x8f, 0x27, 0xde } } gEmbeddedExternalDeviceProtocolGuid =3D { 0x735F8C64, 0xD696, 0x44D0, { = 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }} gEmbeddedGpioProtocolGuid =3D { 0x17a0a3d7, 0xc0a5, 0x4635, { = 0xbb, 0xd5, 0x07, 0x21, 0x87, 0xdf, 0xe2, 0xee }} @@ -115,7 +110,6 @@ [PcdsFixedAtBuild.common] gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|L""|VOID*|0x0000= 0007 gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07|UINT32|0x000000= 08 gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000|UINT32|0= x00000009 - gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"Ebl"|VOID*|0x00000034 =20 gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x0000000b gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|131072|UINT32|0x0000000c diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc index d7ee6a3018bf..8338715d6e46 100644 --- a/EmbeddedPkg/EmbeddedPkg.dsc +++ b/EmbeddedPkg/EmbeddedPkg.dsc @@ -59,7 +59,6 @@ [LibraryClasses.common] PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompres= sLib.inf - EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf =20 ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/= PeiDxeDebugLibReportStatusCode.inf =20 @@ -93,9 +92,6 @@ [LibraryClasses.common] UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA= pplicationEntryPoint.inf =20 PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - EblCmdLib|EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf - - EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf =20 AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf @@ -240,9 +236,6 @@ [BuildOptions] # ##########################################################################= ###### [Components.common] - EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf - EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf - EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSecti= onLib.inf @@ -254,8 +247,6 @@ [Components.common] EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoa= derLibDefault.inf =20 - EmbeddedPkg/Ebl/Ebl.inf -#### EmbeddedPkg/EblExternCmd/EblExternCmd.inf EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf @@ -274,7 +265,6 @@ [Components.common] EmbeddedPkg/Library/AcpiLib/AcpiLib.inf EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf - EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf EmbeddedPkg/Library/FdtLib/FdtLib.inf EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf diff --git a/EmbeddedPkg/EmbeddedPkg.fdf b/EmbeddedPkg/EmbeddedPkg.fdf deleted file mode 100644 index c84a5193efc4..000000000000 --- a/EmbeddedPkg/EmbeddedPkg.fdf +++ /dev/null @@ -1,141 +0,0 @@ -# This is Ebl FDF file -# -# Copyright (c) 2008, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the= BSD License -# which accompanies this distribution. The full text of the license may= be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. -# - -##########################################################################= ###### -# -# FV Section -# -# [FV] section is used to define what components or modules are placed wit= hin a flash -# device file. This section also defines order the components and modules= are positioned -# within the image. The [FV] section consists of define statements, set s= tatements and -# module statements. -# -##########################################################################= ###### -[FV.FvLoad] -FvAlignment =3D 16 #FV alignment and FV attributes setting. -ERASE_POLARITY =3D 1 -MEMORY_MAPPED =3D TRUE -STICKY_WRITE =3D TRUE -LOCK_CAP =3D TRUE -LOCK_STATUS =3D TRUE -WRITE_DISABLED_CAP =3D TRUE -WRITE_ENABLED_CAP =3D TRUE -WRITE_STATUS =3D TRUE -WRITE_LOCK_CAP =3D TRUE -WRITE_LOCK_STATUS =3D TRUE -READ_DISABLED_CAP =3D TRUE -READ_ENABLED_CAP =3D TRUE -READ_STATUS =3D TRUE -READ_LOCK_CAP =3D TRUE -READ_LOCK_STATUS =3D TRUE - -##########################################################################= ###### -# -# The INF statements point to module INF files, which will be placed into = this FV image. -# Parsing tools will scan the INF file to determine the type of component = or module. -# The component or module type is used to reference the standard rules -# defined elsewhere in the FDF file. -# -# The format for INF statements is: -# INF $(PathAndInfFileName) -# -##########################################################################= ###### -INF EmbeddedPkg/Ebl/Ebl.inf - -##########################################################################= ###### -# -# Rules are use with the [FV] section's module INF type to define -# how an FFS file is created for a given INF file. The following Rule are = the default -# rules for the different module type. User can add the customized rules t= o define the -# content of the FFS file. -# -##########################################################################= ###### - - -##########################################################################= ## -# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section = # -##########################################################################= ## -# -#[Rule.Common.DXE_DRIVER] -# FILE DRIVER =3D $(NAMED_GUID) { -# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_= NAME).depex -# COMPRESS PI_STD { -# GUIDED { -# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi -# UI STRING=3D"$(MODULE_NAME)" Optional -# VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_N= UMBER) -# } -# } -# } -# -##########################################################################= ## - -[Rule.Common.SEC] - FILE SEC =3D $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - } - -[Rule.Common.PEI_CORE] - FILE PEI_CORE =3D $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING =3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.PEIM] - FILE PEIM =3D $(NAMED_GUID) { - PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.PEIM.TIANOCOMPRESSED] - FILE PEIM =3D $(NAMED_GUID) DEBUG_MYTOOLS_IA32 { - PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex - GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED =3D TR= UE { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - } - -[Rule.Common.DXE_CORE] - FILE DXE_CORE =3D $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.UEFI_DRIVER] - FILE DRIVER =3D $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME= ).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.DXE_DRIVER] - FILE DRIVER =3D $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME= ).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.DXE_RUNTIME_DRIVER] - FILE DRIVER =3D $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME= ).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } - -[Rule.Common.UEFI_APPLICATION] - FILE APPLICATION =3D $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING=3D"$(MODULE_NAME)" Optional - } diff --git a/EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h b/Embed= dedPkg/Include/Library/EblAddExternalCommandLib.h deleted file mode 100644 index 65aeddddddad..000000000000 --- a/EmbeddedPkg/Include/Library/EblAddExternalCommandLib.h +++ /dev/null @@ -1,122 +0,0 @@ -/** @file - Include file for basic command line parser for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#ifndef __EBL_ADD_EXTERNAL_COMMAND_LIB_H__ -#define __EBL_ADD_EXTERNAL_COMMAND_LIB_H__ - -#include -#include - - -EFI_STATUS -EFIAPI -EblAddExternalCommands ( - IN const EBL_COMMAND_TABLE *EntryArray, - IN UINTN ArrayCount - ); - -/** - - Return a keypress or optionally timeout if a timeout value was passed in. - - An optional callback function is called every second when waiting for a - - timeout. - - - - @param Key EFI Key information returned - - @param TimeoutInSec Number of seconds to wait to timeout - - @param CallBack Callback called every second during the timeout wa= it - - - - @return EFI_SUCCESS Key was returned - - @return EFI_TIMEOUT If the TimoutInSec expired - - - -**/ - -EFI_STATUS - -EFIAPI - -EblGetCharKey ( - - IN OUT EFI_INPUT_KEY *Key, - - IN UINTN TimeoutInSec, - - IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL - - ); - - - - - -/** - - This routine is used prevent command output data from scrolling off the = end - - of the screen. The global gPageBreak is used to turn on or off this feat= ure. - - If the CurrentRow is near the end of the screen pause and print out a pr= ompt - - If the use hits Q to quit return TRUE else for any other key return FALS= E. - - PrefixNewline is used to figure out if a newline is needed before the pr= ompt - - string. This depends on the last print done before calling this function. - - CurrentRow is updated by one on a call or set back to zero if a prompt is - - needed. - - - - @param CurrentRow Used to figure out if its the end of the page and up= dated - - @param PrefixNewline Did previous print issue a newline - - - - @return TRUE if Q was hit to quit, FALSE in all other cases. - - - -**/ - -BOOLEAN - -EFIAPI - -EblAnyKeyToContinueQtoQuit ( - - IN UINTN *CurrentRow, - - IN BOOLEAN PrefixNewline - - ); - - - -#endif - diff --git a/EmbeddedPkg/Include/Library/EblCmdLib.h b/EmbeddedPkg/Include/= Library/EblCmdLib.h deleted file mode 100644 index 2a8a66c016c4..000000000000 --- a/EmbeddedPkg/Include/Library/EblCmdLib.h +++ /dev/null @@ -1,51 +0,0 @@ -/** @file - Include file for basic command line parser for EBL (Embedded Boot Loader) - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#ifndef __EBL_LIB_H__ -#define __EBL_LIB_H__ - -#include -#include - - -VOID -EFIAPI -EblAddCommand ( - IN const EBL_COMMAND_TABLE *Entry - ); - -VOID -EFIAPI -EblAddCommands ( - IN const EBL_COMMAND_TABLE *EntryArray, - IN UINTN ArrayCount - ); - - -// -// LIbrary constructor called directly from Ebl Code. -// This module calls EblAddCommand () or EblAddCommands () to register new= commands -// -VOID -EblInitializeExternalCmd ( - VOID - ); - - - -#endif - diff --git a/EmbeddedPkg/Include/Library/EblNetworkLib.h b/EmbeddedPkg/Incl= ude/Library/EblNetworkLib.h deleted file mode 100644 index 66dc6ac30502..000000000000 --- a/EmbeddedPkg/Include/Library/EblNetworkLib.h +++ /dev/null @@ -1,68 +0,0 @@ -/** @file - Abstractions for Ebl network accesses. - - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#ifndef __EBL_NETWORK_LIB_H__ -#define __EBL_NETWORK_LIB_H__ - -#include - - -EFI_STATUS -EFIAPI -EblGetCurrentIpAddress ( - IN OUT EFI_IP_ADDRESS *Ip - ); - -EFI_STATUS -EFIAPI -EblGetCurrentMacAddress ( - IN OUT EFI_MAC_ADDRESS *Mac - ); - -CHAR8 * -EFIAPI -EblLoadFileBootTypeString ( - IN EFI_HANDLE Handle - ); - -EFI_STATUS -EFIAPI -EblPerformDHCP ( - IN BOOLEAN SortOffers - ); - -EFI_STATUS -EFIAPI -EblSetStationIp ( - IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL - IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL - ); - -EFI_STATUS -EFIAPI -EblMtftp ( - IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, - IN OUT VOID *BufferPtr OPTIONAL, - IN BOOLEAN Overwrite, - IN OUT UINT64 *BufferSize, - IN UINTN *BlockSize OPTIONAL, - IN EFI_IP_ADDRESS *ServerIp, - IN UINT8 *Filename OPTIONAL, - IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL, - IN BOOLEAN DontUseBuffer - ); - -#endif - diff --git a/EmbeddedPkg/Include/Protocol/EblAddCommand.h b/EmbeddedPkg/Inc= lude/Protocol/EblAddCommand.h deleted file mode 100644 index 4a9f494c5d93..000000000000 --- a/EmbeddedPkg/Include/Protocol/EblAddCommand.h +++ /dev/null @@ -1,142 +0,0 @@ -/** @file - - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - - -#ifndef __EBL_ADD_COMMAND_H__ -#define __EBL_ADD_COMMAND_H__ - - - -// -// Protocol GUID -// -// AEDA2428-9A22-4637-9B21-545E28FBB829 - -#define EBL_ADD_COMMAND_PROTOCOL_GUID \ - { 0xaeda2428, 0x9a22, 0x4637, { 0x9b, 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8= , 0x29 } } - - -typedef struct _EBL_ADD_COMMAND_PROTOCOL EBL_ADD_COMMAND_PROTOCOL; - -typedef -EFI_STATUS -(EFIAPI *EBL_COMMMAND) ( - IN UINTN Argc, - IN CHAR8 **Argv - ); - -typedef struct { - CHAR8 *Name; - CHAR8 *HelpSummary; - CHAR8 *Help; - EBL_COMMMAND Command; -} EBL_COMMAND_TABLE; - - -/** - Add a single command table entry. - - @param EntryArray Pointer EBL_COMMAND_TABLE of the command that is b= eing added - -**/ -typedef -VOID -(EFIAPI *EBL_ADD_COMMAND) ( - IN const EBL_COMMAND_TABLE *Entry - ); - - -/** - Add a multiple command table entry. - - @param EntryArray Pointer EBL_COMMAND_TABLE of the commands that are= being added - - @param ArrayCount Number of commands in the EntryArray. - -**/ -typedef -VOID -(EFIAPI *EBL_ADD_COMMANDS) ( - IN const EBL_COMMAND_TABLE *EntryArray, - IN UINTN ArrayCount - ); - - -typedef -VOID -(EFIAPI *EBL_GET_CHAR_CALL_BACK) ( - IN UINTN ElapsedTime - ); - -/** - Return a keypress or optionally timeout if a timeout value was passed in. - An optional callback function is called every second when waiting for a - timeout. - - @param Key EFI Key information returned - @param TimeoutInSec Number of seconds to wait to timeout - @param CallBack Callback called every second during the timeout wa= it - - @return EFI_SUCCESS Key was returned - @return EFI_TIMEOUT If the TimoutInSec expired - -**/ -typedef -EFI_STATUS -(EFIAPI *EBL_GET_CHAR_KEY) ( - IN OUT EFI_INPUT_KEY *Key, - IN UINTN TimeoutInSec, - IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL - ); - - -/** - This routine is used prevent command output data from scrolling off the = end - of the screen. The global gPageBreak is used to turn on or off this feat= ure. - If the CurrentRow is near the end of the screen pause and print out a pr= ompt - If the use hits Q to quit return TRUE else for any other key return FALS= E. - PrefixNewline is used to figure out if a newline is needed before the pr= ompt - string. This depends on the last print done before calling this function. - CurrentRow is updated by one on a call or set back to zero if a prompt is - needed. - - @param CurrentRow Used to figure out if its the end of the page and up= dated - @param PrefixNewline Did previous print issue a newline - - @return TRUE if Q was hit to quit, FALSE in all other cases. - -**/ -typedef -BOOLEAN -(EFIAPI *EBL_ANY_KEY_CONTINUE_Q_QUIT) ( - IN UINTN *CurrentRow, - IN BOOLEAN PrefixNewline - ); - - - -struct _EBL_ADD_COMMAND_PROTOCOL { - EBL_ADD_COMMAND AddCommand; - EBL_ADD_COMMANDS AddCommands; - - // Commands to reuse EBL infrastructure - EBL_GET_CHAR_KEY EblGetCharKey; - EBL_ANY_KEY_CONTINUE_Q_QUIT EblAnyKeyToContinueQtoQuit; -}; - -extern EFI_GUID gEfiEblAddCommandProtocolGuid; - -#endif - - diff --git a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCom= mandLib.c b/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalComm= andLib.c deleted file mode 100644 index 3b9f1846d3cf..000000000000 --- a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib= .c +++ /dev/null @@ -1,155 +0,0 @@ -/** @file - Add external EblCmd Lib - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - -**/ - -#include -#include -#include -#include -#include - -STATIC BOOLEAN gInstalledCommand =3D FALSE; -STATIC EFI_EVENT mEblCommandRegistration =3D NULL; - -STATIC const EBL_COMMAND_TABLE *mAddExternalCmdLibTemplate =3D NULL; -STATIC UINTN mAddExternalCmdLibTemplateSize =3D 0; -EBL_ADD_COMMAND_PROTOCOL *gEblExternalCommand =3D NULL; - - -/** - Return a keypress or optionally timeout if a timeout value was passed in. - An optional callback function is called every second when waiting for a - timeout. - - @param Key EFI Key information returned - @param TimeoutInSec Number of seconds to wait to timeout - @param CallBack Callback called every second during the timeout wa= it - - @return EFI_SUCCESS Key was returned - @return EFI_TIMEOUT If the TimoutInSec expired - -**/ -EFI_STATUS -EFIAPI -EblGetCharKey ( - IN OUT EFI_INPUT_KEY *Key, - IN UINTN TimeoutInSec, - IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL - ) -{ - if (gEblExternalCommand !=3D NULL) { - return gEblExternalCommand->EblGetCharKey (Key, TimeoutInSec, CallBack= ); - } - return EFI_TIMEOUT; -} - - -/** - This routine is used prevent command output data from scrolling off the = end - of the screen. The global gPageBreak is used to turn on or off this feat= ure. - If the CurrentRow is near the end of the screen pause and print out a pr= ompt - If the use hits Q to quit return TRUE else for any other key return FALS= E. - PrefixNewline is used to figure out if a newline is needed before the pr= ompt - string. This depends on the last print done before calling this function. - CurrentRow is updated by one on a call or set back to zero if a prompt is - needed. - - @param CurrentRow Used to figure out if its the end of the page and up= dated - @param PrefixNewline Did previous print issue a newline - - @return TRUE if Q was hit to quit, FALSE in all other cases. - -**/ -BOOLEAN -EFIAPI -EblAnyKeyToContinueQtoQuit ( - IN UINTN *CurrentRow, - IN BOOLEAN PrefixNewline - ) -{ - if (gEblExternalCommand !=3D NULL) { - return gEblExternalCommand->EblAnyKeyToContinueQtoQuit (CurrentRow, Pr= efixNewline); - } - return FALSE; -} - - - -/** - Update mFvbEntry. Add new entry, or update existing entry if Fvb protoco= l is - reinstalled. - - @param Event The Event that is being processed - @param Context Event Context - -**/ -VOID -EFIAPI -EblAddCommandNotificationEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - if (!gInstalledCommand) { - Status =3D gBS->LocateProtocol (&gEfiEblAddCommandProtocolGuid, NULL, = (VOID **)&gEblExternalCommand); - if (!EFI_ERROR (Status)) { - gEblExternalCommand->AddCommands (mAddExternalCmdLibTemplate, mAddEx= ternalCmdLibTemplateSize); - gInstalledCommand =3D TRUE; - } - } -} - - - -/** - The user Entry Point for the driver. The user code starts with this func= tion - as the real entry point for the image goes into a library that calls this - function. - - @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry po= int. - -**/ -EFI_STATUS -EFIAPI -EblAddExternalCommands ( - IN const EBL_COMMAND_TABLE *EntryArray, - IN UINTN ArrayCount - ) -{ - if (mAddExternalCmdLibTemplate !=3D NULL) { - return EFI_ALREADY_STARTED; - } - - mAddExternalCmdLibTemplate =3D EntryArray; - mAddExternalCmdLibTemplateSize =3D ArrayCount; - - EfiCreateProtocolNotifyEvent ( - &gEfiEblAddCommandProtocolGuid, - TPL_CALLBACK, - EblAddCommandNotificationEvent, - NULL, - &mEblCommandRegistration - ); - - return EFI_SUCCESS; -} - diff --git a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCom= mandLib.inf b/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCo= mmandLib.inf deleted file mode 100644 index 335386a8c800..000000000000 --- a/EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib= .inf +++ /dev/null @@ -1,47 +0,0 @@ -#/** @file -# Component description file for the entry point to a EFIDXE Drivers -# -# Library to abstract Framework extensions that conflict with UEFI 2.0 Spe= cification -# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD License -# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. -# -# -#**/ - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D EblAddExternalCommandLib - FILE_GUID =3D 9195D970-C6F7-484E-8013-5B03C89C3B81 - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EblAddExternalCommandLib|DXE_DRIVER U= EFI_APPLICATION UEFI_DRIVER - - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# - -[Sources.common] - EblAddExternalCommandLib.c - -[Packages] - MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - UefiLib - EblAddExternalCommandLib - -[Protocols] - gEfiEblAddCommandProtocolGuid - -[Guids] diff --git a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c b/EmbeddedPk= g/Library/EblCmdLibNull/EblCmdLibNull.c deleted file mode 100644 index 6cde5f95ab88..000000000000 --- a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.c +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - Null EblCmdLib - - Copyright (c) 2007, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - - -**/ - -#include -#include - - -VOID -EblInitializeExternalCmd ( - VOID - ) -{ - return; -} diff --git a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf b/Embedded= Pkg/Library/EblCmdLibNull/EblCmdLibNull.inf deleted file mode 100644 index c7935ae37e3e..000000000000 --- a/EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf +++ /dev/null @@ -1,43 +0,0 @@ -#/** @file -# Component description file for the entry point to a EFIDXE Drivers -# -# Library to abstract Framework extensions that conflict with UEFI 2.0 Spe= cification -# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD License -# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. -# -# -#**/ - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D EblCmdLibNull - FILE_GUID =3D 3513C4E2-06D6-4921-9C2B-E938777BA79E - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EfiCmdLib|DXE_DRIVER UEFI_APPLICATION= UEFI_DRIVER - - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# - -[Sources.common] - EblCmdLibNull.c - -[Packages] - MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - -[LibraryClasses] - -[Protocols] - -[Guids] diff --git a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c b/EmbeddedPk= g/Library/EblNetworkLib/EblNetworkLib.c deleted file mode 100644 index 1c945cd33b5a..000000000000 --- a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c +++ /dev/null @@ -1,173 +0,0 @@ -/** @file - - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include -#include -#include -#include -#include - -#include -#include - - -BOOLEAN gUseIpv6 =3D FALSE; - -EFI_STATUS -EFIAPI -EblGetCurrentIpAddress ( - IN OUT EFI_IP_ADDRESS *Ip - ) -{ - EFI_STATUS Status; - EFI_PXE_BASE_CODE_PROTOCOL *Pxe; - - Status =3D gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOI= D **)&Pxe); - if (EFI_ERROR(Status)) { - return Status; - } - - Status =3D Pxe->Start (Pxe, gUseIpv6); - if (EFI_ERROR(Status) && (Status !=3D EFI_ALREADY_STARTED)) { - return Status; - } - - CopyMem (Ip, &Pxe->Mode->StationIp, sizeof (EFI_IP_ADDRESS)); - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -EblGetCurrentMacAddress ( - IN OUT EFI_MAC_ADDRESS *Mac - ) -{ - EFI_STATUS Status; - EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNet; - - Status =3D gBS->LocateProtocol (&gEfiSimpleNetworkProtocolGuid, NULL, (V= OID **)&SimpleNet); - if (EFI_ERROR(Status)) { - return Status; - } - - CopyMem (Mac, SimpleNet->Mode->CurrentAddress.Addr, sizeof (EFI_MAC_ADDR= ESS)); - return Status; -} - - -CHAR8 * -EFIAPI -EblLoadFileBootTypeString ( - IN EFI_HANDLE Handle - ) -{ - EFI_STATUS Status; - VOID *NullPtr; - - Status =3D gBS->HandleProtocol (Handle, &gEfiPxeBaseCodeProtocolGuid, &N= ullPtr); - if (!EFI_ERROR (Status)) { - return "EFI PXE Network Boot"; - } - - return ""; -} - -EFI_STATUS -EFIAPI -EblPerformDHCP ( - IN BOOLEAN SortOffers - ) -{ - EFI_STATUS Status; - EFI_PXE_BASE_CODE_PROTOCOL *Pxe; - - Status =3D gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOI= D **)&Pxe); - if (EFI_ERROR(Status)) { - return Status; - } - - Status =3D Pxe->Start (Pxe, gUseIpv6); - if (EFI_ERROR(Status) && (Status !=3D EFI_ALREADY_STARTED)) { - return Status; - } - - Status =3D Pxe->Dhcp(Pxe, TRUE); - return Status; -} - - -EFI_STATUS -EFIAPI -EblSetStationIp ( - IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL - IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL - ) -{ - EFI_STATUS Status; - EFI_PXE_BASE_CODE_PROTOCOL *Pxe; - - Status =3D gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOI= D **)&Pxe); - if (EFI_ERROR(Status)) { - return Status; - } - - Status =3D Pxe->Start (Pxe, gUseIpv6); - if (EFI_ERROR(Status) && (Status !=3D EFI_ALREADY_STARTED)) { - return Status; - } - - Status =3D Pxe->SetStationIp (Pxe, NewStationIp, NewSubnetMask); - return Status; -} - - -EFI_STATUS -EFIAPI -EblMtftp ( - IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, - IN OUT VOID *BufferPtr OPTIONAL, - IN BOOLEAN Overwrite, - IN OUT UINT64 *BufferSize, - IN UINTN *BlockSize OPTIONAL, - IN EFI_IP_ADDRESS *ServerIp, - IN UINT8 *Filename OPTIONAL, - IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL, - IN BOOLEAN DontUseBuffer - ) -{ - EFI_STATUS Status; - EFI_PXE_BASE_CODE_PROTOCOL *Pxe; - - Status =3D gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOI= D **)&Pxe); - if (EFI_ERROR(Status)) { - return Status; - } - - Status =3D Pxe->Mtftp ( - Pxe, - Operation, - BufferPtr, - Overwrite, - BufferSize, - BlockSize, - ServerIp, - Filename, - Info, - DontUseBuffer - ); - return Status; -} - diff --git a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf b/Embedded= Pkg/Library/EblNetworkLib/EblNetworkLib.inf deleted file mode 100644 index c9b2d31dc437..000000000000 --- a/EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf +++ /dev/null @@ -1,34 +0,0 @@ -#/** @file -# -# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. -# -#**/ - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D EblNetworkLib - FILE_GUID =3D D885869A-7869-47DB-9429-DE03C318BCFD - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EblNetworkLib|DXE_DRIVER DXE_RUNTIME_= DRIVER UEFI_APPLICATION UEFI_DRIVER - -[sources.common] - EblNetworkLib.c - -[Packages] - MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - -[Protocols] - gEfiSimpleNetworkProtocolGuid - gEfiPxeBaseCodeProtocolGuid - -[Depex] - TRUE diff --git a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c b/EmbeddedPkg/Libr= ary/EfiFileLib/EfiFileLib.c deleted file mode 100644 index 8c38d22f1eb1..000000000000 --- a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c +++ /dev/null @@ -1,1784 +0,0 @@ -/** @file -File IO routines inspired by Streams with an EFI flavor - -Copyright (c) 2007, Intel Corporation. All rights reserved.
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD = License -which accompanies this distribution. The full text of the license may be = found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. - -Basic support for opening files on different device types. The device stri= ng -is in the form of DevType:Path. Current DevType is required as there is no -current mounted device concept of current working directory concept implem= ent -by this library. - -Device names are case insensitive and only check the leading characters for -unique matches. Thus the following are all the same: -LoadFile0: -l0: -L0: -Lo0: - -Supported Device Names: -A0x1234:0x12 - A memory buffer starting at address 0x1234 for 0x12 bytes -l1: - EFI LoadFile device one. -B0: - EFI BlockIo zero. -fs3: - EFI Simple File System device 3 -Fv2: - EFI Firmware VOlume device 2 -10.0.1.102: - TFTP service IP followed by the file name -**/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -CHAR8 *gCwd =3D NULL; - -#define EFI_OPEN_FILE_GUARD_HEADER 0x4B4D4641 -#define EFI_OPEN_FILE_GUARD_FOOTER 0x444D5A56 - -// Need to defend against this overflowing -#define MAX_CMD_LINE 0x200 - -typedef struct { - UINT32 Header; - EFI_OPEN_FILE File; - UINT32 Footer; -} EFI_OPEN_FILE_GUARD; - - -// globals to store current open device info -EFI_HANDLE *mBlkIo =3D NULL; -UINTN mBlkIoCount =3D 0; - -EFI_HANDLE *mFs =3D NULL; -UINTN mFsCount =3D 0; -// mFsInfo[] array entries must match mFs[] handles -EFI_FILE_SYSTEM_INFO **mFsInfo =3D NULL; - -EFI_HANDLE *mFv =3D NULL; -UINTN mFvCount =3D 0; -EFI_HANDLE *mLoadFile =3D NULL; -UINTN mLoadFileCount =3D 0; - - - -/** -Internal worker function to validate a File handle. - -@param File Open File Handle - -@return TRUE File is valid -@return FALSE File is not valid - - -**/ -BOOLEAN -FileHandleValid ( - IN EFI_OPEN_FILE *File - ) -{ - EFI_OPEN_FILE_GUARD *GuardFile; - - // Look right before and after file structure for the correct signatures - GuardFile =3D BASE_CR (File, EFI_OPEN_FILE_GUARD, File); - if ((GuardFile->Header !=3D EFI_OPEN_FILE_GUARD_HEADER) || - (GuardFile->Footer !=3D EFI_OPEN_FILE_GUARD_FOOTER) ) { - return FALSE; - } - - return TRUE; -} - -/** -Internal worker function. If Buffer is not NULL free it. - -@param Buffer Buffer to FreePool() - -**/ -VOID -EblFreePool ( - IN VOID *Buffer - ) -{ - if (Buffer !=3D NULL) { - FreePool (Buffer); - } -} - -/** -Update Device List Global Variables - -**/ -VOID -EblUpdateDeviceLists ( - VOID - ) -{ - EFI_STATUS Status; - UINTN Size; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; - EFI_FILE_HANDLE Root; - UINTN Index; - - if (mBlkIo !=3D NULL) { - FreePool (mBlkIo); - } - gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mB= lkIoCount, &mBlkIo); - - - - if (mFv !=3D NULL) { - FreePool (mFv); - } - gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, N= ULL, &mFvCount, &mFv); - - if (mLoadFile !=3D NULL) { - FreePool (mLoadFile); - } - gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &m= LoadFileCount, &mLoadFile); - - if (mFs !=3D NULL) { - FreePool (mFs); - } - - if (&mFsInfo[0] !=3D NULL) { - // Need to Free the mFsInfo prior to recalculating mFsCount so don't m= ove this code - for (Index =3D 0; Index < mFsCount; Index++) { - if (mFsInfo[Index] !=3D NULL) { - FreePool (mFsInfo[Index]); - } - } - FreePool (mFsInfo); - } - - gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleFileSystemProtocolGuid, = NULL, &mFsCount, &mFs); - - - mFsInfo =3D AllocateZeroPool (mFsCount * sizeof (EFI_FILE_SYSTEM_INFO *)= ); - if (mFsInfo =3D=3D NULL) { - // If we can't do this then we can't support file system entries - mFsCount =3D 0; - } else { - // Loop through all the file system structures and cache the file syst= em info data - for (Index =3D0; Index < mFsCount; Index++) { - Status =3D gBS->HandleProtocol (mFs[Index], &gEfiSimpleFileSystemPro= tocolGuid, (VOID **)&Fs); - if (!EFI_ERROR (Status)) { - Status =3D Fs->OpenVolume (Fs, &Root); - if (!EFI_ERROR (Status)) { - // Get information about the volume - Size =3D 0; - Status =3D Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, = mFsInfo[Index]); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - mFsInfo[Index] =3D AllocatePool (Size); - Status =3D Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size= , mFsInfo[Index]); - } - - Root->Close (Root); - } - } - } - } -} - - -/** -PathName is in the form : for example fs1:\ or ROOT:\. -Return TRUE if the prefix of PathName matches a file system -Volume Name. MatchIndex is the array index in mFsInfo[] of the match, -and it can be used with mFs[] to find the handle that needs to be opened - -@param PathName PathName to check -@param FileStart Index of the first character of the -@param MatchIndex Index in mFsInfo[] that matches - -@return TRUE PathName matches a Volume Label and MatchIndex is valid -@return FALSE PathName does not match a Volume Label MatchIndex undefi= ned - -**/ -BOOLEAN -EblMatchVolumeName ( - IN CHAR8 *PathName, - IN UINTN FileStart, - OUT UINTN *MatchIndex - ) -{ - UINTN Index; - UINTN Compare; - UINTN VolStrLen; - BOOLEAN Match; - - for (Index =3D0; Index < mFsCount; Index++) { - if (mFsInfo[Index] =3D=3D NULL) { - // FsInfo is not valid so skip it - continue; - } - VolStrLen =3D StrLen (mFsInfo[Index]->VolumeLabel); - for (Compare =3D 0, Match =3D TRUE; Compare < (FileStart - 1); Compare= ++) { - if (Compare > VolStrLen) { - Match =3D FALSE; - break; - } - if (PathName[Compare] !=3D (CHAR8)mFsInfo[Index]->VolumeLabel[Compar= e]) { - // If the VolumeLabel has a space allow a _ to match with it in ad= dition to ' ' - if (!((PathName[Compare] =3D=3D '_') && (mFsInfo[Index]->VolumeLab= el[Compare] =3D=3D L' '))) { - Match =3D FALSE; - break; - } - } - } - if (Match) { - *MatchIndex =3D Index; - return TRUE; - } - } - - return FALSE; -} - - -/** -Return the number of devices of the current type active in the system - -@param Type Device type to check - -@return 0 Invalid type - -**/ -UINTN -EfiGetDeviceCounts ( - IN EFI_OPEN_FILE_TYPE DeviceType - ) -{ - switch (DeviceType) { - case EfiOpenLoadFile: - return mLoadFileCount; - case EfiOpenFirmwareVolume: - return mFvCount; - case EfiOpenFileSystem: - return mFsCount; - case EfiOpenBlockIo: - return mBlkIoCount; - default: - return 0; - } -} - -EFI_STATUS -ConvertIpStringToEfiIp ( - IN CHAR8 *PathName, - OUT EFI_IP_ADDRESS *ServerIp - ) -{ - CHAR8 *Str; - - Str =3D PathName; - ServerIp->v4.Addr[0] =3D (UINT8)AsciiStrDecimalToUintn (Str); - - Str =3D AsciiStrStr (Str, "."); - if (Str =3D=3D NULL) { - return EFI_DEVICE_ERROR; - } - - ServerIp->v4.Addr[1] =3D (UINT8)AsciiStrDecimalToUintn (++Str); - - Str =3D AsciiStrStr (Str, "."); - if (Str =3D=3D NULL) { - return EFI_DEVICE_ERROR; - } - - ServerIp->v4.Addr[2] =3D (UINT8)AsciiStrDecimalToUintn (++Str); - - Str =3D AsciiStrStr (Str, "."); - if (Str =3D=3D NULL) { - return EFI_DEVICE_ERROR; - } - - ServerIp->v4.Addr[3] =3D (UINT8)AsciiStrDecimalToUintn (++Str); - - return EFI_SUCCESS; -} - - -/** -Internal work function to extract a device number from a string skipping -text. Easy way to extract numbers from strings like blk7:. - -@param Str String to extract device number form - -@return -1 Device string is not valid -@return Device # - -**/ -UINTN -EblConvertDevStringToNumber ( - IN CHAR8 *Str - ) -{ - UINTN Max; - UINTN Index; - - - // Find the first digit - Max =3D AsciiStrLen (Str); - for (Index =3D 0; !((*Str >=3D '0') && (*Str <=3D '9')) && (Index < Max= ); Index++) { - Str++; - } - if (Index =3D=3D Max) { - return (UINTN)-1; - } - - return AsciiStrDecimalToUintn (Str); -} - - -/** -Internal work function to fill in EFI_OPEN_FILE information for the Fs and= BlkIo - -@param File Open file handle -@param FileName Name of file after device stripped off - - -**/ -EFI_STATUS -EblFileDevicePath ( - IN OUT EFI_OPEN_FILE *File, - IN CHAR8 *FileName, - IN CONST UINT64 OpenMode - ) -{ - EFI_STATUS Status; - UINTN Size; - FILEPATH_DEVICE_PATH *FilePath; - EFI_DEVICE_PATH_PROTOCOL *FileDevicePath; - CHAR16 UnicodeFileName[MAX_PATHNAME]; - EFI_BLOCK_IO_PROTOCOL *BlkIo; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; - EFI_FILE_HANDLE Root; - - - if ( *FileName !=3D 0 ) { - AsciiStrToUnicodeStrS (FileName, UnicodeFileName, - ARRAY_SIZE (UnicodeFileName)); - } else { - AsciiStrToUnicodeStrS ("\\", UnicodeFileName, ARRAY_SIZE (UnicodeFileN= ame)); - } - - Size =3D StrSize (UnicodeFileName); - FileDevicePath =3D AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + s= izeof (EFI_DEVICE_PATH_PROTOCOL)); - if (FileDevicePath !=3D NULL) { - FilePath =3D (FILEPATH_DEVICE_PATH *) FileDevicePath; - FilePath->Header.Type =3D MEDIA_DEVICE_PATH; - FilePath->Header.SubType =3D MEDIA_FILEPATH_DP; - CopyMem (&FilePath->PathName, UnicodeFileName, Size); - SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DE= VICE_PATH); - SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header)); - - if (File->EfiHandle !=3D NULL) { - File->DevicePath =3D DevicePathFromHandle (File->EfiHandle); - } - - File->DevicePath =3D AppendDevicePath (File->DevicePath, FileDevicePat= h); - FreePool (FileDevicePath); - } - - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGui= d, (VOID **)&BlkIo); - if (!EFI_ERROR (Status)) { - File->FsBlockIoMedia =3D BlkIo->Media; - File->FsBlockIo =3D BlkIo; - - // If we are not opening the device this will get over written with fi= le info - File->MaxPosition =3D MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->= Media->BlockSize); - } - - if (File->Type =3D=3D EfiOpenFileSystem) { - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiSimpleFileSystem= ProtocolGuid, (VOID **)&Fs); - if (!EFI_ERROR (Status)) { - Status =3D Fs->OpenVolume (Fs, &Root); - if (!EFI_ERROR (Status)) { - // Get information about the volume - Size =3D 0; - Status =3D Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, Fi= le->FsInfo); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - File->FsInfo =3D AllocatePool (Size); - Status =3D Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, = File->FsInfo); - } - - // Get information about the file - Status =3D Root->Open (Root, &File->FsFileHandle, UnicodeFileName,= OpenMode, 0); - if (!EFI_ERROR (Status)) { - Size =3D 0; - Status =3D File->FsFileHandle->GetInfo (File->FsFileHandle, &gEf= iFileInfoGuid, &Size, NULL); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - File->FsFileInfo =3D AllocatePool (Size); - Status =3D File->FsFileHandle->GetInfo (File->FsFileHandle, &g= EfiFileInfoGuid, &Size, File->FsFileInfo); - if (!EFI_ERROR (Status)) { - File->Size =3D (UINTN)File->FsFileInfo->FileSize; - File->MaxPosition =3D (UINT64)File->Size; - } - } - } - - Root->Close (Root); - } - } - } else if (File->Type =3D=3D EfiOpenBlockIo) { - File->Size =3D (UINTN)File->MaxPosition; - } - - return Status; -} - -#define ToUpper(a) ((((a) >=3D 'a') && ((a) <=3D 'z')) ? ((a) - 'a' + 'A'= ) : (a)) - -EFI_STATUS -CompareGuidToString ( - IN EFI_GUID *Guid, - IN CHAR8 *String - ) -{ - CHAR8 AsciiGuid[64]; - CHAR8 *StringPtr; - CHAR8 *GuidPtr; - - AsciiSPrint (AsciiGuid, sizeof(AsciiGuid), "%g", Guid); - - StringPtr =3D String; - GuidPtr =3D AsciiGuid; - - while ((*StringPtr !=3D '\0') && (*GuidPtr !=3D '\0')) { - // Skip dashes - if (*StringPtr =3D=3D '-') { - StringPtr++; - continue; - } - - if (*GuidPtr =3D=3D '-') { - GuidPtr++; - continue; - } - - if (ToUpper(*StringPtr) !=3D ToUpper(*GuidPtr)) { - return EFI_NOT_FOUND; - } - - StringPtr++; - GuidPtr++; - } - - return EFI_SUCCESS; -} - - -/** -Internal work function to fill in EFI_OPEN_FILE information for the FV - -@param File Open file handle -@param FileName Name of file after device stripped off - - -**/ -EFI_STATUS -EblFvFileDevicePath ( - IN OUT EFI_OPEN_FILE *File, - IN CHAR8 *FileName, - IN CONST UINT64 OpenMode - ) -{ - EFI_STATUS Status; - EFI_STATUS GetNextFileStatus; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH DevicePathNode; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN Key; - UINT32 AuthenticationStatus; - CHAR8 AsciiSection[MAX_PATHNAME]; - VOID *Section; - UINTN SectionSize; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; - EFI_LBA Lba; - UINTN BlockSize; - UINTN NumberOfBlocks; - EFI_FIRMWARE_VOLUME_HEADER *FvHeader =3D NULL; - UINTN Index; - - - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2Pro= tocolGuid, (VOID **)&File->Fv); - if (EFI_ERROR (Status)) { - return Status; - } - - // Get FVB Info about the handle - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolumeBloc= kProtocolGuid, (VOID **)&Fvb); - if (!EFI_ERROR (Status)) { - Status =3D Fvb->GetPhysicalAddress (Fvb, &File->FvStart); - if (!EFI_ERROR (Status)) { - FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)File->FvStart; - File->FvHeaderSize =3D sizeof (EFI_FIRMWARE_VOLUME_HEADER); - for (Index =3D 0; FvHeader->BlockMap[Index].Length !=3D0; Index++) { - File->FvHeaderSize +=3D sizeof (EFI_FV_BLOCK_MAP_ENTRY); - } - - for (Lba =3D 0, File->FvSize =3D 0, NumberOfBlocks =3D 0; ; File->Fv= Size +=3D (BlockSize * NumberOfBlocks), Lba +=3D NumberOfBlocks) { - Status =3D Fvb->GetBlockSize (Fvb, Lba, &BlockSize, &NumberOfBlock= s); - if (EFI_ERROR (Status)) { - break; - } - } - } - } - - - DevicePath =3D DevicePathFromHandle (File->EfiHandle); - - if (*FileName =3D=3D '\0') { - File->DevicePath =3D DuplicateDevicePath (DevicePath); - File->Size =3D File->FvSize; - File->MaxPosition =3D File->Size; - } else { - Key =3D 0; - do { - File->FvType =3D EFI_FV_FILETYPE_ALL; - GetNextFileStatus =3D File->Fv->GetNextFile ( - File->Fv, - &Key, - &File->FvType, - &File->FvNameGuid, - &File->FvAttributes, - &File->Size - ); - if (!EFI_ERROR (GetNextFileStatus)) { - // Compare GUID first - Status =3D CompareGuidToString (&File->FvNameGuid, FileName); - if (!EFI_ERROR(Status)) { - break; - } - - Section =3D NULL; - Status =3D File->Fv->ReadSection ( - File->Fv, - &File->FvNameGuid, - EFI_SECTION_USER_INTERFACE, - 0, - &Section, - &SectionSize, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - UnicodeStrToAsciiStrS (Section, AsciiSection, MAX_PATHNAME); - if (AsciiStriCmp (FileName, AsciiSection) =3D=3D 0) { - FreePool (Section); - break; - } - FreePool (Section); - } - } - } while (!EFI_ERROR (GetNextFileStatus)); - - if (EFI_ERROR (GetNextFileStatus)) { - return GetNextFileStatus; - } - - if (OpenMode !=3D EFI_SECTION_ALL) { - // Calculate the size of the section we are targeting - Section =3D NULL; - File->Size =3D 0; - Status =3D File->Fv->ReadSection ( - File->Fv, - &File->FvNameGuid, - (EFI_SECTION_TYPE)OpenMode, - 0, - &Section, - &File->Size, - &AuthenticationStatus - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - - File->MaxPosition =3D File->Size; - EfiInitializeFwVolDevicepathNode (&DevicePathNode, &File->FvNameGuid); - File->DevicePath =3D AppendDevicePathNode (DevicePath, (EFI_DEVICE_PAT= H_PROTOCOL *)&DevicePathNode); - } - - - // FVB not required if FV was soft loaded... - return EFI_SUCCESS; -} - - - - -/** -Open a device named by PathName. The PathName includes a device name and -path separated by a :. See file header for more details on the PathName -syntax. There is no checking to prevent a file from being opened more than -one type. - -SectionType is only used to open an FV. Each file in an FV contains multip= le -sections and only the SectionType section is opened. - -For any file that is opened with EfiOpen() must be closed with EfiClose(). - -@param PathName Path to parse to open -@param OpenMode Same as EFI_FILE.Open() -@param SectionType Section in FV to open. - -@return NULL Open failed -@return Valid EFI_OPEN_FILE handle - -**/ -EFI_OPEN_FILE * -EfiOpen ( - IN CHAR8 *PathName, - IN CONST UINT64 OpenMode, - IN CONST EFI_SECTION_TYPE SectionType - ) -{ - EFI_STATUS Status; - EFI_OPEN_FILE *File; - EFI_OPEN_FILE FileData; - UINTN StrLen; - UINTN FileStart; - UINTN DevNumber =3D 0; - EFI_OPEN_FILE_GUARD *GuardFile; - BOOLEAN VolumeNameMatch; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN Size; - EFI_IP_ADDRESS Ip; - CHAR8 *CwdPlusPathName; - UINTN Index; - EFI_SECTION_TYPE ModifiedSectionType; - UINTN AsciiLength; - - EblUpdateDeviceLists (); - - File =3D &FileData; - ZeroMem (File, sizeof (EFI_OPEN_FILE)); - - StrLen =3D AsciiStrSize (PathName); - if (StrLen <=3D 1) { - // Smallest valid path is 1 char and a null - return NULL; - } - - for (FileStart =3D 0; FileStart < StrLen; FileStart++) { - if (PathName[FileStart] =3D=3D ':') { - FileStart++; - break; - } - } - - // - // Matching volume name has precedence over handle based names - // - VolumeNameMatch =3D EblMatchVolumeName (PathName, FileStart, &DevNumber); - if (!VolumeNameMatch) { - if (FileStart =3D=3D StrLen) { - // No Volume name or device name, so try Current Working Directory - if (gCwd =3D=3D NULL) { - // No CWD - return NULL; - } - - // We could add a current working directory concept - AsciiLength =3D AsciiStrSize (gCwd) + AsciiStrSize (PathName); - CwdPlusPathName =3D AllocatePool (AsciiLength); - if (CwdPlusPathName =3D=3D NULL) { - return NULL; - } - - if ((PathName[0] =3D=3D '/') || (PathName[0] =3D=3D '\\')) { - // PathName starts in / so this means we go to the root of the dev= ice in the CWD. - CwdPlusPathName[0] =3D '\0'; - for (FileStart =3D 0; gCwd[FileStart] !=3D '\0'; FileStart++) { - CwdPlusPathName[FileStart] =3D gCwd[FileStart]; - if (gCwd[FileStart] =3D=3D ':') { - FileStart++; - CwdPlusPathName[FileStart] =3D '\0'; - break; - } - } - } else { - AsciiStrCpyS (CwdPlusPathName, AsciiLength, gCwd); - StrLen =3D AsciiStrLen (gCwd); - if ((*PathName !=3D '/') && (*PathName !=3D '\\') && (gCwd[StrLen-= 1] !=3D '/') && (gCwd[StrLen-1] !=3D '\\')) { - AsciiStrCatS (CwdPlusPathName, AsciiLength, "\\"); - } - } - - AsciiStrCatS (CwdPlusPathName, AsciiLength, PathName); - if (AsciiStrStr (CwdPlusPathName, ":") =3D=3D NULL) { - // Extra error check to make sure we don't recurse and blow stack - return NULL; - } - - File =3D EfiOpen (CwdPlusPathName, OpenMode, SectionType); - FreePool (CwdPlusPathName); - return File; - } - - DevNumber =3D EblConvertDevStringToNumber ((CHAR8 *)PathName); - } - - File->DeviceName =3D AllocatePool (StrLen); - AsciiStrCpyS (File->DeviceName, StrLen, PathName); - File->DeviceName[FileStart - 1] =3D '\0'; - File->FileName =3D &File->DeviceName[FileStart]; - if (File->FileName[0] =3D=3D '\0') { - // if it is just a file name use / as root - File->FileName =3D "\\"; - } - - // - // Use best match algorithm on the dev names so we only need to look at = the - // first few charters to match the full device name. Short name forms are - // legal from the caller. - // - Status =3D EFI_SUCCESS; - if (*PathName =3D=3D 'f' || *PathName =3D=3D 'F' || VolumeNameMatch) { - if (PathName[1] =3D=3D 's' || PathName[1] =3D=3D 'S' || VolumeNameMatc= h) { - if (DevNumber >=3D mFsCount) { - goto ErrorExit; - } - File->Type =3D EfiOpenFileSystem; - File->EfiHandle =3D mFs[DevNumber]; - Status =3D EblFileDevicePath (File, &PathName[FileStart], OpenMode); - - } else if (PathName[1] =3D=3D 'v' || PathName[1] =3D=3D 'V') { - if (DevNumber >=3D mFvCount) { - goto ErrorExit; - } - File->Type =3D EfiOpenFirmwareVolume; - File->EfiHandle =3D mFv[DevNumber]; - - if ((PathName[FileStart] =3D=3D '/') || (PathName[FileStart] =3D=3D = '\\')) { - // Skip leading / as its not really needed for the FV since no dir= ectories are supported - FileStart++; - } - - // Check for 2nd : - ModifiedSectionType =3D SectionType; - for (Index =3D FileStart; PathName[Index] !=3D '\0'; Index++) { - if (PathName[Index] =3D=3D ':') { - // Support fv0:\DxeCore:0x10 - // This means open the PE32 Section of the file - ModifiedSectionType =3D (EFI_SECTION_TYPE)AsciiStrHexToUintn (&P= athName[Index + 1]); - PathName[Index] =3D '\0'; - } - } - File->FvSectionType =3D ModifiedSectionType; - Status =3D EblFvFileDevicePath (File, &PathName[FileStart], Modified= SectionType); - } - } else if ((*PathName =3D=3D 'A') || (*PathName =3D=3D 'a')) { - // Handle a:0x10000000:0x1234 address form a:ADDRESS:SIZE - File->Type =3D EfiOpenMemoryBuffer; - // 1st colon is at PathName[FileStart - 1] - File->Buffer =3D (VOID *)AsciiStrHexToUintn (&PathName[FileStart]); - - // Find 2nd colon - while ((PathName[FileStart] !=3D ':') && (PathName[FileStart] !=3D '\0= ')) { - FileStart++; - } - - // If we ran out of string, there's no extra data - if (PathName[FileStart] =3D=3D '\0') { - File->Size =3D 0; - } else { - File->Size =3D AsciiStrHexToUintn (&PathName[FileStart + 1]); - } - - // if there's no number after the second colon, default - // the end of memory - if (File->Size =3D=3D 0) { - File->Size =3D (UINTN)(0 - (UINTN)File->Buffer); - } - - File->MaxPosition =3D File->Size; - File->BaseOffset =3D (UINTN)File->Buffer; - - } else if (*PathName=3D=3D 'l' || *PathName =3D=3D 'L') { - if (DevNumber >=3D mLoadFileCount) { - goto ErrorExit; - } - File->Type =3D EfiOpenLoadFile; - File->EfiHandle =3D mLoadFile[DevNumber]; - - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiLoadFileProtocol= Guid, (VOID **)&File->LoadFile); - if (EFI_ERROR (Status)) { - goto ErrorExit; - } - - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiDevicePathProtoc= olGuid, (VOID **)&DevicePath); - if (EFI_ERROR (Status)) { - goto ErrorExit; - } - File->DevicePath =3D DuplicateDevicePath (DevicePath); - - } else if (*PathName =3D=3D 'b' || *PathName =3D=3D 'B') { - // Handle b#:0x10000000:0x1234 address form b#:ADDRESS:SIZE - if (DevNumber >=3D mBlkIoCount) { - goto ErrorExit; - } - File->Type =3D EfiOpenBlockIo; - File->EfiHandle =3D mBlkIo[DevNumber]; - EblFileDevicePath (File, "", OpenMode); - - // 1st colon is at PathName[FileStart - 1] - File->DiskOffset =3D AsciiStrHexToUintn (&PathName[FileStart]); - - // Find 2nd colon - while ((PathName[FileStart] !=3D ':') && (PathName[FileStart] !=3D '\0= ')) { - FileStart++; - } - - // If we ran out of string, there's no extra data - if (PathName[FileStart] =3D=3D '\0') { - Size =3D 0; - } else { - Size =3D AsciiStrHexToUintn (&PathName[FileStart + 1]); - } - - // if a zero size is passed in (or the size is left out entirely), - // go to the end of the device. - if (Size =3D=3D 0) { - File->Size =3D File->Size - File->DiskOffset; - } else { - File->Size =3D Size; - } - - File->MaxPosition =3D File->Size; - File->BaseOffset =3D File->DiskOffset; - } else if ((*PathName) >=3D '0' && (*PathName <=3D '9')) { - - // Get current IP address - Status =3D EblGetCurrentIpAddress (&Ip); - if (EFI_ERROR(Status)) { - AsciiPrint("Device IP Address is not configured.\n"); - goto ErrorExit; - } - - - // Parse X.X.X.X:Filename, only support IPv4 TFTP for now... - File->Type =3D EfiOpenTftp; - File->IsDirty =3D FALSE; - File->IsBufferValid =3D FALSE; - - Status =3D ConvertIpStringToEfiIp (PathName, &File->ServerIp); - } - - if (EFI_ERROR (Status)) { - goto ErrorExit; - } - - GuardFile =3D (EFI_OPEN_FILE_GUARD *)AllocateZeroPool (sizeof (EFI_OPEN_= FILE_GUARD)); - if (GuardFile =3D=3D NULL) { - goto ErrorExit; - } - - GuardFile->Header =3D EFI_OPEN_FILE_GUARD_HEADER; - CopyMem (&(GuardFile->File), &FileData, sizeof (EFI_OPEN_FILE)); - GuardFile->Footer =3D EFI_OPEN_FILE_GUARD_FOOTER; - - return &(GuardFile->File); - -ErrorExit: - FreePool (File->DeviceName); - return NULL; -} - -#define FILE_COPY_CHUNK 0x01000000 - -EFI_STATUS -EfiCopyFile ( - IN CHAR8 *DestinationFile, - IN CHAR8 *SourceFile - ) -{ - EFI_OPEN_FILE *Source =3D NULL; - EFI_OPEN_FILE *Destination =3D NULL; - EFI_STATUS Status =3D EFI_SUCCESS; - VOID *Buffer =3D NULL; - UINTN Size; - UINTN Offset; - UINTN Chunk =3D FILE_COPY_CHUNK; - - Source =3D EfiOpen (SourceFile, EFI_FILE_MODE_READ, 0); - if (Source =3D=3D NULL) { - AsciiPrint("Source file open error.\n"); - Status =3D EFI_NOT_FOUND; - goto Exit; - } - - Destination =3D EfiOpen (DestinationFile, EFI_FILE_MODE_WRITE | EFI_FILE= _MODE_CREATE, 0); - if (Destination =3D=3D NULL) { - AsciiPrint("Destination file open error.\n"); - Status =3D EFI_NOT_FOUND; - goto Exit; - } - - Buffer =3D AllocatePool(FILE_COPY_CHUNK); - if (Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Exit; - } - - Size =3D EfiTell(Source, NULL); - - for (Offset =3D 0; Offset + FILE_COPY_CHUNK <=3D Size; Offset +=3D Chunk= ) { - Chunk =3D FILE_COPY_CHUNK; - - Status =3D EfiRead(Source, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Read file error %r\n", Status); - goto Exit; - } - - Status =3D EfiWrite(Destination, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Write file error %r\n", Status); - goto Exit; - } - } - - // Any left over? - if (Offset < Size) { - Chunk =3D Size - Offset; - - Status =3D EfiRead(Source, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Read file error\n"); - goto Exit; - } - - Status =3D EfiWrite(Destination, Buffer, &Chunk); - if (EFI_ERROR(Status)) { - AsciiPrint("Write file error\n"); - goto Exit; - } - } - -Exit: - if (Source !=3D NULL) { - Status =3D EfiClose(Source); - if (EFI_ERROR(Status)) { - AsciiPrint("Source close error"); - } - } - - if (Destination !=3D NULL) { - Status =3D EfiClose(Destination); - if (EFI_ERROR(Status)) { - AsciiPrint("Destination close error"); - } - } - - if (Buffer !=3D NULL) { - FreePool(Buffer); - } - - return Status; -} - -/** -Use DeviceType and Index to form a valid PathName and try and open it. - -@param DeviceType Device type to open -@param Index Device Index to use. Zero relative. - -@return NULL Open failed -@return Valid EFI_OPEN_FILE handle - -**/ -EFI_OPEN_FILE * -EfiDeviceOpenByType ( - IN EFI_OPEN_FILE_TYPE DeviceType, - IN UINTN Index - ) -{ - CHAR8 *DevStr; - CHAR8 Path[MAX_CMD_LINE]; - - switch (DeviceType) { - case EfiOpenLoadFile: - DevStr =3D "loadfile%d:"; - break; - case EfiOpenFirmwareVolume: - DevStr =3D "fv%d:"; - break; - case EfiOpenFileSystem: - DevStr =3D "fs%d:"; - break; - case EfiOpenBlockIo: - DevStr =3D "blk%d:"; - break; - case EfiOpenMemoryBuffer: - DevStr =3D "a%d:"; - break; - default: - return NULL; - } - - AsciiSPrint (Path, MAX_PATHNAME, DevStr, Index); - - return EfiOpen (Path, EFI_FILE_MODE_READ, 0); -} - - -/** -Close a file handle opened by EfiOpen() and free all resources allocated by -EfiOpen(). - -@param Stream Open File Handle - -@return EFI_INVALID_PARAMETER Stream is not an Open File -@return EFI_SUCCESS Steam closed - -**/ -EFI_STATUS -EfiClose ( - IN EFI_OPEN_FILE *File - ) -{ - EFI_STATUS Status; - UINT64 TftpBufferSize; - - if (!FileHandleValid (File)) { - return EFI_INVALID_PARAMETER; - } - - //Write the buffer contents to TFTP file. - if ((File->Type =3D=3D EfiOpenTftp) && (File->IsDirty)) { - - TftpBufferSize =3D File->Size; - Status =3D EblMtftp ( - EFI_PXE_BASE_CODE_TFTP_WRITE_FILE, - File->Buffer, - TRUE, - &TftpBufferSize, - NULL, - &File->ServerIp, - (UINT8 *)File->FileName, - NULL, - FALSE - ); - if (EFI_ERROR(Status)) { - AsciiPrint("TFTP error during APPLE_NSP_TFTP_WRITE_FILE: %r\n", Stat= us); - return Status; - } - } - - if ((File->Type =3D=3D EfiOpenLoadFile) || - ((File->Type =3D=3D EfiOpenTftp) && (File->IsBufferValid =3D=3D TRUE))= || - ((File->Type =3D=3D EfiOpenFirmwareVolume) && (File->IsBufferValid =3D= =3D TRUE))) { - EblFreePool(File->Buffer); - } - - EblFreePool (File->DevicePath); - EblFreePool (File->DeviceName); - EblFreePool (File->FsFileInfo); - EblFreePool (File->FsInfo); - - if (File->FsFileHandle !=3D NULL) { - File->FsFileHandle->Close (File->FsFileHandle); - } - - // Need to free File and it's Guard structures - EblFreePool (BASE_CR (File, EFI_OPEN_FILE_GUARD, File)); - return EFI_SUCCESS; -} - - -/** -Return the size of the file represented by Stream. Also return the current -Seek position. Opening a file will enable a valid file size to be returned. -LoadFile is an exception as a load file size is set to zero. - -@param Stream Open File Handle - -@return 0 Stream is not an Open File or a valid LoadFile handle - -**/ -UINTN -EfiTell ( - IN EFI_OPEN_FILE *File, - OUT EFI_LBA *CurrentPosition OPTIONAL - ) -{ - EFI_STATUS Status; - UINT64 BufferSize =3D 0; - - if (!FileHandleValid (File)) { - return 0; - } - - if (CurrentPosition !=3D NULL) { - *CurrentPosition =3D File->CurrentPosition; - } - - if (File->Type =3D=3D EfiOpenLoadFile) { - // Figure out the File->Size - File->Buffer =3D NULL; - File->Size =3D 0; - Status =3D File->LoadFile->LoadFile (File->LoadFile, File->DevicePath,= FALSE, &File->Size, File->Buffer); - if (Status !=3D EFI_BUFFER_TOO_SMALL) { - return 0; - } - - File->MaxPosition =3D (UINT64)File->Size; - } else if (File->Type =3D=3D EfiOpenTftp) { - - Status =3D EblMtftp ( - EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, - NULL, - FALSE, - &BufferSize, - NULL, - &File->ServerIp, - (UINT8 *)File->FileName, - NULL, - TRUE - ); - if (EFI_ERROR(Status)) { - AsciiPrint("TFTP error during APPLE_NSP_TFTP_GET_FILE_SIZE: %r\n", S= tatus); - return 0; - } - - File->Size =3D (UINTN)BufferSize; - File->MaxPosition =3D File->Size; - } - - return File->Size; -} - - -/** -Seek to the Offset location in the file. LoadFile and FV device types do -not support EfiSeek(). It is not possible to grow the file size using -EfiSeek(). - -SeekType defines how use Offset to calculate the new file position: -EfiSeekStart : Position =3D Offset -EfiSeekCurrent: Position is Offset bytes from the current position -EfiSeekEnd : Only supported if Offset is zero to seek to end of file. - -@param Stream Open File Handle -@param Offset Offset to seek too. -@param SeekType Type of seek to perform - - -@return EFI_INVALID_PARAMETER Stream is not an Open File -@return EFI_UNSUPPORTED LoadFile and FV do not support Seek -@return EFI_NOT_FOUND Seek past the end of the file. -@return EFI_SUCCESS Steam closed - -**/ -EFI_STATUS -EfiSeek ( - IN EFI_OPEN_FILE *File, - IN EFI_LBA Offset, - IN EFI_SEEK_TYPE SeekType - ) -{ - EFI_STATUS Status; - UINT64 CurrentPosition; - - if (!FileHandleValid (File)) { - return EFI_INVALID_PARAMETER; - } - - if (File->Type =3D=3D EfiOpenLoadFile) { - // LoadFile does not support Seek - return EFI_UNSUPPORTED; - } - - CurrentPosition =3D File->CurrentPosition; - switch (SeekType) { - case EfiSeekStart: - if (Offset > File->MaxPosition) { - return EFI_NOT_FOUND; - } - CurrentPosition =3D Offset; - break; - - case EfiSeekCurrent: - if ((File->CurrentPosition + Offset) > File->MaxPosition) { - return EFI_NOT_FOUND; - } - CurrentPosition +=3D Offset; - break; - - case EfiSeekEnd: - if (Offset !=3D 0) { - // We don't support growing file size via seeking past end of file - return EFI_UNSUPPORTED; - } - CurrentPosition =3D File->MaxPosition; - break; - - default: - return EFI_NOT_FOUND; - } - - Status =3D EFI_SUCCESS; - if (File->FsFileHandle !=3D NULL) { - Status =3D File->FsFileHandle->SetPosition (File->FsFileHandle, Curren= tPosition); - } - - if (!EFI_ERROR (Status)) { - File->CurrentPosition =3D CurrentPosition; - } - - return Status; -} - -EFI_STATUS -CacheTftpFile ( - IN OUT EFI_OPEN_FILE *File - ) -{ - EFI_STATUS Status; - UINT64 TftpBufferSize; - - if (File->IsBufferValid) { - return EFI_SUCCESS; - } - - // Make sure the file size is set. - EfiTell (File, NULL); - - //Allocate a buffer to hold the whole file. - File->Buffer =3D AllocatePool(File->Size); - if (File->Buffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - TftpBufferSize =3D File->Size; - - Status =3D EblMtftp ( - EFI_PXE_BASE_CODE_TFTP_READ_FILE, - File->Buffer, - FALSE, - &TftpBufferSize, - NULL, - &File->ServerIp, - (UINT8 *)File->FileName, - NULL, - FALSE); - if (EFI_ERROR(Status)) { - AsciiPrint("TFTP error during APPLE_NSP_TFTP_READ_FILE: %r\n", Status); - FreePool(File->Buffer); - return Status; - } - - // Set the buffer valid flag. - File->IsBufferValid =3D TRUE; - - return Status; -} - -/** -Read BufferSize bytes from the current location in the file. For load file, -FV, and TFTP case you must read the entire file. - -@param Stream Open File Handle -@param Buffer Caller allocated buffer. -@param BufferSize Size of buffer in bytes. - - -@return EFI_SUCCESS Stream is not an Open File -@return EFI_END_OF_FILE Tried to read past the end of the file -@return EFI_INVALID_PARAMETER Stream is not an open file handle -@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read -@return "other" Error returned from device read - -**/ -EFI_STATUS -EfiRead ( - IN EFI_OPEN_FILE *File, - OUT VOID *Buffer, - OUT UINTN *BufferSize - ) -{ - EFI_STATUS Status; - UINT32 AuthenticationStatus; - EFI_DISK_IO_PROTOCOL *DiskIo; - - if (!FileHandleValid (File)) { - return EFI_INVALID_PARAMETER; - } - - // Don't read past the end of the file. - if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) { - return EFI_END_OF_FILE; - } - - switch (File->Type) { - case EfiOpenLoadFile: - // Figure out the File->Size - EfiTell (File, NULL); - - Status =3D File->LoadFile->LoadFile (File->LoadFile, File->DevicePath,= FALSE, BufferSize, Buffer); - break; - - case EfiOpenFirmwareVolume: - if (CompareGuid (&File->FvNameGuid, &gZeroGuid)) { - // This is the entire FV device, so treat like a memory buffer - CopyMem (Buffer, (VOID *)(UINTN)(File->FvStart + File->CurrentPositi= on), *BufferSize); - File->CurrentPosition +=3D *BufferSize; - Status =3D EFI_SUCCESS; - } else { - if (File->Buffer =3D=3D NULL) { - if (File->FvSectionType =3D=3D EFI_SECTION_ALL) { - Status =3D File->Fv->ReadFile ( - File->Fv, - &File->FvNameGuid, - (VOID **)&File->Buffer, - &File->Size, - &File->FvType, - &File->FvAttributes, - &AuthenticationStatus - ); - } else { - Status =3D File->Fv->ReadSection ( - File->Fv, - &File->FvNameGuid, - File->FvSectionType, - 0, - (VOID **)&File->Buffer, - &File->Size, - &AuthenticationStatus - ); - } - if (EFI_ERROR (Status)) { - return Status; - } - File->IsBufferValid =3D TRUE; - } - // Operate on the cached buffer so Seek will work - CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize); - File->CurrentPosition +=3D *BufferSize; - Status =3D EFI_SUCCESS; - } - break; - - case EfiOpenMemoryBuffer: - CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize); - File->CurrentPosition +=3D *BufferSize; - Status =3D EFI_SUCCESS; - break; - - case EfiOpenFileSystem: - Status =3D File->FsFileHandle->Read (File->FsFileHandle, BufferSize, B= uffer); - File->CurrentPosition +=3D *BufferSize; - break; - - case EfiOpenBlockIo: - Status =3D gBS->HandleProtocol(File->EfiHandle, &gEfiDiskIoProtocolGui= d, (VOID **)&DiskIo); - if (!EFI_ERROR(Status)) { - Status =3D DiskIo->ReadDisk(DiskIo, File->FsBlockIoMedia->MediaId, F= ile->DiskOffset + File->CurrentPosition, *BufferSize, Buffer); - } - File->CurrentPosition +=3D *BufferSize; - break; - - case EfiOpenTftp: - // Cache the file if it hasn't been cached yet. - if (File->IsBufferValid =3D=3D FALSE) { - Status =3D CacheTftpFile (File); - if (EFI_ERROR (Status)) { - return Status; - } - } - - // Copy out the requested data - CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize); - File->CurrentPosition +=3D *BufferSize; - - Status =3D EFI_SUCCESS; - break; - - default: - return EFI_INVALID_PARAMETER; - }; - - return Status; -} - - -/** -Read the entire file into a buffer. This routine allocates the buffer and -returns it to the user full of the read data. - -This is very useful for load file where it's hard to know how big the buff= er -must be. - -@param Stream Open File Handle -@param Buffer Pointer to buffer to return. -@param BufferSize Pointer to Size of buffer return.. - - -@return EFI_SUCCESS Stream is not an Open File -@return EFI_END_OF_FILE Tried to read past the end of the file -@return EFI_INVALID_PARAMETER Stream is not an open file handle -@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read -@return "other" Error returned from device read - -**/ -EFI_STATUS -EfiReadAllocatePool ( - IN EFI_OPEN_FILE *File, - OUT VOID **Buffer, - OUT UINTN *BufferSize - ) -{ - if (!FileHandleValid (File)) { - return EFI_INVALID_PARAMETER; - } - - // Loadfile defers file size determination on Open so use tell to find it - EfiTell (File, NULL); - - *BufferSize =3D File->Size; - *Buffer =3D AllocatePool (*BufferSize); - if (*Buffer =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - return EfiRead (File, *Buffer, BufferSize); -} - - -/** -Write data back to the file. For TFTP case you must write the entire file. - -@param Stream Open File Handle -@param Buffer Pointer to buffer to return. -@param BufferSize Pointer to Size of buffer return.. - - -@return EFI_SUCCESS Stream is not an Open File -@return EFI_END_OF_FILE Tried to read past the end of the file -@return EFI_INVALID_PARAMETER Stream is not an open file handle -@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read -@return "other" Error returned from device write - -**/ -EFI_STATUS -EfiWrite ( - IN EFI_OPEN_FILE *File, - OUT VOID *Buffer, - OUT UINTN *BufferSize - ) -{ - EFI_STATUS Status; - EFI_FV_WRITE_FILE_DATA FileData; - EFI_DISK_IO_PROTOCOL *DiskIo; - - if (!FileHandleValid (File)) { - return EFI_INVALID_PARAMETER; - } - - switch (File->Type) { - case EfiOpenMemoryBuffer: - if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) { - return EFI_END_OF_FILE; - } - - CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize); - File->CurrentPosition +=3D *BufferSize; - Status =3D EFI_SUCCESS; - - case EfiOpenLoadFile: - // LoadFile device is read only be definition - Status =3D EFI_UNSUPPORTED; - - case EfiOpenFirmwareVolume: - if (File->FvSectionType !=3D EFI_SECTION_ALL) { - // Writes not support to a specific section. You have to update enti= re file - return EFI_UNSUPPORTED; - } - - FileData.NameGuid =3D &(File->FvNameGuid); - FileData.Type =3D File->FvType; - FileData.FileAttributes =3D File->FvAttributes; - FileData.Buffer =3D Buffer; - FileData.BufferSize =3D (UINT32)*BufferSize; - Status =3D File->Fv->WriteFile (File->Fv, 1, EFI_FV_UNRELIABLE_WRITE, = &FileData); - break; - - case EfiOpenFileSystem: - Status =3D File->FsFileHandle->Write (File->FsFileHandle, BufferSize, = Buffer); - File->CurrentPosition +=3D *BufferSize; - break; - - case EfiOpenBlockIo: - if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) { - return EFI_END_OF_FILE; - } - - Status =3D gBS->HandleProtocol (File->EfiHandle, &gEfiDiskIoProtocolGu= id, (VOID **)&DiskIo); - if (!EFI_ERROR(Status)) { - Status =3D DiskIo->WriteDisk (DiskIo, File->FsBlockIoMedia->MediaId,= File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer); - } - File->CurrentPosition +=3D *BufferSize; - break; - - case EfiOpenTftp: - // Cache the file if it hasn't been cached yet. - if (File->IsBufferValid =3D=3D FALSE) { - Status =3D CacheTftpFile(File); - if (EFI_ERROR(Status)) { - return Status; - } - } - - // Don't overwrite the buffer - if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) { - UINT8 *TempBuffer; - - TempBuffer =3D File->Buffer; - - File->Buffer =3D AllocatePool ((UINTN)(File->CurrentPosition + *Buff= erSize)); - if (File->Buffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - CopyMem (File->Buffer, TempBuffer, File->Size); - - FreePool (TempBuffer); - - File->Size =3D (UINTN)(File->CurrentPosition + *BufferSize); - File->MaxPosition =3D (UINT64)File->Size; - } - - // Copy in the requested data - CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize); - File->CurrentPosition +=3D *BufferSize; - - // Mark the file dirty - File->IsDirty =3D TRUE; - - Status =3D EFI_SUCCESS; - break; - - default: - Status =3D EFI_INVALID_PARAMETER; - }; - - return Status; -} - - -/** -Given Cwd expand Path to remove .. and replace them with real -directory names. - -@param Cwd Current Working Directory -@param Path Path to expand - -@return NULL Cwd or Path are not valid -@return 'other' Path with .. expanded - -**/ -CHAR8 * -ExpandPath ( - IN CHAR8 *Cwd, - IN CHAR8 *Path - ) -{ - CHAR8 *NewPath; - CHAR8 *Work, *Start, *End; - UINTN StrLen, AllocLen; - INTN i; - - if (Cwd =3D=3D NULL || Path =3D=3D NULL) { - return NULL; - } - - StrLen =3D AsciiStrSize (Cwd); - if (StrLen <=3D 2) { - // Smallest valid path is 1 char and a null - return NULL; - } - - StrLen =3D AsciiStrSize (Path); - AllocLen =3D AsciiStrSize (Cwd) + StrLen + 1; - NewPath =3D AllocatePool (AllocLen); - if (NewPath =3D=3D NULL) { - return NULL; - } - AsciiStrCpyS (NewPath, AllocLen, Cwd); - - End =3D Path + StrLen; - for (Start =3D Path ;;) { - Work =3D AsciiStrStr (Start, "..") ; - if (Work =3D=3D NULL) { - // Remaining part of Path contains no more .. - break; - } - - // append path prior to .. - AsciiStrnCatS (NewPath, AllocLen, Start, Work - Start); - StrLen =3D AsciiStrLen (NewPath); - for (i =3D StrLen; i >=3D 0; i--) { - if (NewPath[i] =3D=3D ':') { - // too many .. - return NULL; - } - if (NewPath[i] =3D=3D '/' || NewPath[i] =3D=3D '\\') { - if ((i > 0) && (NewPath[i-1] =3D=3D ':')) { - // leave the / before a : - NewPath[i+1] =3D '\0'; - } else { - // replace / will Null to remove trailing file/dir reference - NewPath[i] =3D '\0'; - } - break; - } - } - - Start =3D Work + 3; - } - - // Handle the path that remains after the .. - AsciiStrnCatS (NewPath, AllocLen, Start, End - Start); - - return NewPath; -} - - -/** -Set the Current Working Directory (CWD). If a call is made to EfiOpen () a= nd -the path does not contain a device name, The CWD is prepended to the path. - -@param Cwd Current Working Directory to set - - -@return EFI_SUCCESS CWD is set -@return EFI_INVALID_PARAMETER Cwd is not a valid device:path - -**/ -EFI_STATUS -EfiSetCwd ( - IN CHAR8 *Cwd - ) -{ - EFI_OPEN_FILE *File; - UINTN Len, AllocLen; - CHAR8 *Path; - - if (Cwd =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (AsciiStrCmp (Cwd, ".") =3D=3D 0) { - // cd . is a no-op - return EFI_SUCCESS; - } - - Path =3D Cwd; - if (AsciiStrStr (Cwd, "..") !=3D NULL) { - if (gCwd =3D=3D NULL) { - // no parent - return EFI_SUCCESS; - } - - Len =3D AsciiStrLen (gCwd); - if ((gCwd[Len-2] =3D=3D ':') && ((gCwd[Len-1] =3D=3D '/') || (gCwd[Len= -1] =3D=3D '\\'))) { - // parent is device so nothing to do - return EFI_SUCCESS; - } - - // Expand .. in Cwd, given we know current working directory - Path =3D ExpandPath (gCwd, Cwd); - if (Path =3D=3D NULL) { - return EFI_NOT_FOUND; - } - } - - File =3D EfiOpen (Path, EFI_FILE_MODE_READ, 0); - if (File =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (gCwd !=3D NULL) { - FreePool (gCwd); - } - - // Use the info returned from EfiOpen as it can add in CWD if needed. So= Cwd could be - // relative to the current gCwd or not. - AllocLen =3D AsciiStrSize (File->DeviceName) + AsciiStrSize (File->FileN= ame) + 10; - gCwd =3D AllocatePool (AllocLen); - if (gCwd =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - AsciiStrCpyS (gCwd, AllocLen, File->DeviceName); - if (File->FileName =3D=3D NULL) { - AsciiStrCatS (gCwd, AllocLen, ":\\"); - } else { - AsciiStrCatS (gCwd, AllocLen, ":"); - AsciiStrCatS (gCwd, AllocLen, File->FileName); - } - - - EfiClose (File); - if (Path !=3D Cwd) { - FreePool (Path); - } - return EFI_SUCCESS; -} - - -/** -Set the Current Working Directory (CWD). If a call is made to EfiOpen () a= nd -the path does not contain a device name, The CWD is prepended to the path. -The CWD buffer is only valid until a new call is made to EfiSetCwd(). After -a call to EfiSetCwd() it is not legal to use the pointer returned by -this function. - -@param Cwd Current Working Directory - - -@return "" No CWD set -@return 'other' Returns buffer that contains CWD. - -**/ -CHAR8 * -EfiGetCwd ( - VOID - ) -{ - if (gCwd =3D=3D NULL) { - return ""; - } - return gCwd; -} - - diff --git a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf b/EmbeddedPkg/Li= brary/EfiFileLib/EfiFileLib.inf deleted file mode 100644 index b8cb255268a5..000000000000 --- a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf +++ /dev/null @@ -1,64 +0,0 @@ -#/** @file -# Component description file for the entry point to a EFIDXE Drivers -# -# Library to abstract Framework extensions that conflict with UEFI 2.0 Spe= cification -# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD License -# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. -# -# -#**/ - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D EfiFileLib - FILE_GUID =3D d8c640db-73ba-48f5-a7ed-8e93c6012491 - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EfiFileLib|DXE_DRIVER UEFI_APPLICATIO= N UEFI_DRIVER - - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# - -[Sources.common] - EfiFileLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - EmbeddedPkg/EmbeddedPkg.dec - -[LibraryClasses] - BaseLib - MemoryAllocationLib - DevicePathLib - PrintLib - BaseMemoryLib - UefiLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - DebugLib - EblNetworkLib - -[Protocols] - gEfiBlockIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiDiskIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiSimpleFileSystemProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiLoadFileProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - -[Guids] - gEfiFileInfoGuid - gEfiFileSystemInfoGuid - gZeroGuid diff --git a/Omap35xxPkg/Library/EblCmdLib/EblCmdLib.c b/Omap35xxPkg/Librar= y/EblCmdLib/EblCmdLib.c deleted file mode 100644 index 47161755de84..000000000000 --- a/Omap35xxPkg/Library/EblCmdLib/EblCmdLib.c +++ /dev/null @@ -1,72 +0,0 @@ -/** @file - Add custom commands for BeagleBoard development. - - Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//PcdEmbeddedFdBaseAddress - -/** - Fill Me In - - Argv[0] - "%CommandName%" - - @param Argc Number of command arguments in Argv - @param Argv Array of strings that represent the parsed command line. - Argv[0] is the command name - - @return EFI_SUCCESS - -**/ -EFI_STATUS -EblEdk2Cmd ( - IN UINTN Argc, - IN CHAR8 **Argv - ) -{ - return EFI_SUCCESS; -} - - -GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] = =3D -{ - { - "edk2", - " filename ; Load FD into memory and boot from it", - NULL, - EblEdk2Cmd - } -}; - - -VOID -EblInitializeExternalCmd ( - VOID - ) -{ - EblAddCommands (mLibCmdTemplate, sizeof (mLibCmdTemplate)/sizeof (EBL_CO= MMAND_TABLE)); - return; -} diff --git a/Omap35xxPkg/Library/EblCmdLib/EblCmdLib.inf b/Omap35xxPkg/Libr= ary/EblCmdLib/EblCmdLib.inf deleted file mode 100644 index dd7a13cf6629..000000000000 --- a/Omap35xxPkg/Library/EblCmdLib/EblCmdLib.inf +++ /dev/null @@ -1,48 +0,0 @@ -#/** @file -# Component description file for the entry point to a EFIDXE Drivers -# -# Library to abstract Framework extensions that conflict with UEFI 2.0 Spe= cification -# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the B= SD License -# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. -# -# -#**/ - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D BeagleBoardEblCmdLib - FILE_GUID =3D ea62bdc3-1063-425f-8851-98cb47f213a8 - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D EblCmdLib|DXE_DRIVER UEFI_APPLICATION= UEFI_DRIVER - - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# - -[Sources.common] - EblCmdLib.c - -[Packages] - MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - ArmPkg/ArmPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - -[Protocols] - -[Guids] - -[Pcd] diff --git a/Omap35xxPkg/Omap35xxPkg.dsc b/Omap35xxPkg/Omap35xxPkg.dsc index c5d9746104e6..f150d544ab16 100644 --- a/Omap35xxPkg/Omap35xxPkg.dsc +++ b/Omap35xxPkg/Omap35xxPkg.dsc @@ -180,7 +180,6 @@ [Components.common] =20 Omap35xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf Omap35xxPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf - Omap35xxPkg/Library/EblCmdLib/EblCmdLib.inf Omap35xxPkg/Library/GdbSerialLib/GdbSerialLib.inf Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.inf Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel