PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
\r
- EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf\r
-\r
# These libraries are used by the dynamic EFI Shell commands\r
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
[PcdsFixedAtBuild.common]\r
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"Beagle Board"\r
\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"BeagleEdk2"\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000\r
+++ /dev/null
-/** @file\r
- %CommandName% for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name: CmdTemplate.c\r
-\r
- Search/Replace %CommandName% with the name of your new command\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-/**\r
- Fill Me In\r
-\r
- Argv[0] - "%CommandName%"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-Ebl%CommandName%Cmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmd%CommandName%Template[] =\r
-{\r
- {\r
- "%CommandName%",\r
- " [show args] ; explain args and command",\r
- NULL,\r
- Ebl%CommandName%Cmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this file\r
-**/\r
-VOID\r
-EblInitialize%CommandName%Cmd (\r
- VOID\r
- )\r
-{\r
- EblAddCommands (mCmd%CommandName%Template, sizeof (mCmd%CommandName%Template)/sizeof (EBL_COMMAND_TABLE));\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Basic commands and command processing infrastructure for EBL\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-#include <Protocol/DiskIo.h>\r
-#include <Protocol/BlockIo.h>\r
-\r
-UINTN mCmdTableMaxIndex = EBL_MAX_COMMAND_COUNT;\r
-UINTN mCmdTableNextFreeIndex = 0;\r
-EBL_COMMAND_TABLE *mCmdTable[EBL_MAX_COMMAND_COUNT];\r
-\r
-/**\r
- Converts a lowercase Ascii character to upper one\r
-\r
- If Chr is lowercase Ascii character, then converts it to upper one.\r
-\r
- If Value >= 0xA0, then ASSERT().\r
- If (Value & 0x0F) >= 0x0A, then ASSERT().\r
-\r
- @param chr one Ascii character\r
-\r
- @return The uppercase value of Ascii character\r
-\r
-**/\r
-STATIC\r
-CHAR8\r
-AsciiToUpper (\r
- IN CHAR8 Chr\r
- )\r
-{\r
- return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);\r
-}\r
-\r
-\r
-/**\r
- Case insensitive comparison of two Null-terminated Unicode strings with maximum\r
- lengths, and returns the difference between the first mismatched Unicode\r
- characters.\r
- This function compares the Null-terminated Unicode string FirstString to the\r
- Null-terminated Unicode string SecondString. At most, Length Unicode\r
- characters will be compared. If Length is 0, then 0 is returned. If\r
- FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
- value returned is the first mismatched Unicode character in SecondString\r
- subtracted from the first mismatched Unicode character in FirstString.\r
-\r
- @param FirstString Pointer to a Null-terminated ASCII string.\r
- @param SecondString Pointer to a Null-terminated ASCII string.\r
- @param Length Max length to compare.\r
-\r
- @retval 0 FirstString is identical to SecondString using case insensitive\r
- comparisons.\r
- @retval !=0 FirstString is not identical to SecondString using case\r
- insensitive comparisons.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-AsciiStrniCmp (\r
- IN CONST CHAR8 *FirstString,\r
- IN CONST CHAR8 *SecondString,\r
- IN UINTN Length\r
- )\r
-{\r
- if (Length == 0) {\r
- return 0;\r
- }\r
-\r
- while ((AsciiToUpper (*FirstString) != '\0') &&\r
- (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString)) &&\r
- (Length > 1)) {\r
- FirstString++;\r
- SecondString++;\r
- Length--;\r
- }\r
-\r
- return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);\r
-}\r
-\r
-\r
-\r
-/**\r
- Add a command to the mCmdTable. If there is no free space in the command\r
- table ASSERT. The mCmdTable is maintained in alphabetical order and the\r
- new entry is inserted into its sorted position.\r
-\r
- @param Entry Command Entry to add to the CmdTable\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EblAddCommand (\r
- IN const EBL_COMMAND_TABLE *Entry\r
- )\r
-{\r
- UINTN Count;\r
-\r
- if (mCmdTableNextFreeIndex == EBL_MAX_COMMAND_COUNT) {\r
- //\r
- // Ran out of space to store commands. Increase EBL_MAX_COMMAND_COUNT\r
- //\r
- ASSERT (FALSE);\r
- return;\r
- }\r
-\r
- //\r
- // Add command and Insertion sort array in the process\r
- //\r
- mCmdTable[mCmdTableNextFreeIndex] = (EBL_COMMAND_TABLE *)Entry;\r
- if (mCmdTableNextFreeIndex != 0) {\r
- for (Count = mCmdTableNextFreeIndex; Count > 0; Count--) {\r
- if (AsciiStriCmp (mCmdTable[Count - 1]->Name, Entry->Name) <= 0) {\r
- break;\r
- }\r
-\r
- mCmdTable[Count] = mCmdTable[Count - 1];\r
- }\r
- mCmdTable[Count] = (EBL_COMMAND_TABLE *)Entry;\r
- }\r
-\r
- mCmdTableNextFreeIndex++;\r
-}\r
-\r
-\r
-/**\r
- Add an set of commands to the command table. Most commonly used on static\r
- array of commands.\r
-\r
- @param EntryArray Pointer to array of command entries\r
- @param ArrayCount Number of command entries to add\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EblAddCommands (\r
- IN const EBL_COMMAND_TABLE *EntryArray,\r
- IN UINTN ArrayCount\r
- )\r
-{\r
- UINTN Index;\r
-\r
- for (Index = 0; Index < ArrayCount; Index++) {\r
- EblAddCommand (&EntryArray[Index]);\r
- }\r
-}\r
-\r
-\r
-EBL_ADD_COMMAND_PROTOCOL gEblAddCommand = {\r
- EblAddCommand,\r
- EblAddCommands,\r
- EblGetCharKey,\r
- EblAnyKeyToContinueQtoQuit\r
-};\r
-\r
-\r
-\r
-/**\r
- Return the best matching command for the passed in command name. The match\r
- does not have to be exact, it just needs to be unique. This enables commands\r
- to be shortened to the smallest set of starting characters that is unique.\r
-\r
- @param CommandName Name of command to search for\r
-\r
- @return NULL CommandName did not match or was not unique\r
- Other Pointer to EBL_COMMAND_TABLE entry for CommandName\r
-\r
-**/\r
-EBL_COMMAND_TABLE *\r
-EblGetCommand (\r
- IN CHAR8 *CommandName\r
- )\r
-{\r
- UINTN Index;\r
- UINTN BestMatchCount;\r
- UINTN Length;\r
- EBL_COMMAND_TABLE *Match;\r
- CHAR8 *Str;\r
-\r
- Length = AsciiStrLen (CommandName);\r
- Str = AsciiStrStr (CommandName, ".");\r
- if (Str != NULL) {\r
- // If the command includes a trailing . command extension skip it for the match.\r
- // Example: hexdump.4\r
- Length = (UINTN)(Str - CommandName);\r
- }\r
-\r
- for (Index = 0, BestMatchCount = 0, Match = NULL; Index < mCmdTableNextFreeIndex; Index++) {\r
- if (AsciiStriCmp (mCmdTable[Index]->Name, CommandName) == 0) {\r
- // match a command exactly\r
- return mCmdTable[Index];\r
- }\r
-\r
- if (AsciiStrniCmp (CommandName, mCmdTable[Index]->Name, Length) == 0) {\r
- // partial match, so keep looking to make sure there is only one partial match\r
- BestMatchCount++;\r
- Match = mCmdTable[Index];\r
- }\r
- }\r
-\r
- if (BestMatchCount == 1) {\r
- return Match;\r
- }\r
-\r
- //\r
- // We had no matches or too many matches\r
- //\r
- return NULL;\r
-}\r
-\r
-\r
-UINTN\r
-CountNewLines (\r
- IN CHAR8 *Str\r
- )\r
-{\r
- UINTN Count;\r
-\r
- if (Str == NULL) {\r
- return 0;\r
- }\r
-\r
- for (Count = 0; *Str != '\0'; Str++) {\r
- if (Str[Count] == '\n') {\r
- Count++;\r
- }\r
- }\r
-\r
- return Count;\r
-}\r
-\r
-\r
-/**\r
- List out help information on all the commands or print extended information\r
- about a specific passed in command.\r
-\r
- Argv[0] - "help"\r
- Argv[1] - Command to display help about\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblHelpCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Index;\r
- CHAR8 *Ptr;\r
- UINTN CurrentRow = 0;\r
-\r
- if (Argc == 1) {\r
- // Print all the commands\r
- AsciiPrint ("Embedded Boot Loader (EBL) commands (help command for more info):\n");\r
- CurrentRow++;\r
- for (Index = 0; Index < mCmdTableNextFreeIndex; Index++) {\r
- EblSetTextColor (EFI_YELLOW);\r
- AsciiPrint (" %a", mCmdTable[Index]->Name);\r
- EblSetTextColor (0);\r
- AsciiPrint ("%a\n", mCmdTable[Index]->HelpSummary);\r
- // Handle multi line help summaries\r
- CurrentRow += CountNewLines (mCmdTable[Index]->HelpSummary);\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
- }\r
- } else if (Argv[1] != NULL) {\r
- // Print specific help\r
- for (Index = 0, CurrentRow = 0; Index < mCmdTableNextFreeIndex; Index++) {\r
- if (AsciiStriCmp (Argv[1], mCmdTable[Index]->Name) == 0) {\r
- Ptr = (mCmdTable[Index]->Help == NULL) ? mCmdTable[Index]->HelpSummary : mCmdTable[Index]->Help;\r
- AsciiPrint ("%a%a\n", Argv[1], Ptr);\r
- // Handle multi line help summaries\r
- CurrentRow += CountNewLines (Ptr);\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Exit the EBL. If the command processor sees EFI_ABORTED return status it will\r
- exit the EBL.\r
-\r
- Argv[0] - "exit"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_ABORTED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblExitCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN MemoryMapSize;\r
- EFI_MEMORY_DESCRIPTOR *MemoryMap;\r
- UINTN MapKey;\r
- UINTN DescriptorSize;\r
- UINT32 DescriptorVersion;\r
- UINTN Pages;\r
-\r
- if (Argc > 1) {\r
- if (AsciiStriCmp (Argv[1], "efi") != 0) {\r
- return EFI_ABORTED;\r
- }\r
- } else if (Argc == 1) {\r
- return EFI_ABORTED;\r
- }\r
-\r
- MemoryMap = NULL;\r
- MemoryMapSize = 0;\r
- do {\r
- Status = gBS->GetMemoryMap (\r
- &MemoryMapSize,\r
- MemoryMap,\r
- &MapKey,\r
- &DescriptorSize,\r
- &DescriptorVersion\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
-\r
- Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;\r
- MemoryMap = AllocatePages (Pages);\r
-\r
- //\r
- // Get System MemoryMap\r
- //\r
- Status = gBS->GetMemoryMap (\r
- &MemoryMapSize,\r
- MemoryMap,\r
- &MapKey,\r
- &DescriptorSize,\r
- &DescriptorVersion\r
- );\r
- // Don't do anything between the GetMemoryMap() and ExitBootServices()\r
- if (!EFI_ERROR (Status)) {\r
- Status = gBS->ExitBootServices (gImageHandle, MapKey);\r
- if (EFI_ERROR (Status)) {\r
- FreePages (MemoryMap, Pages);\r
- MemoryMap = NULL;\r
- MemoryMapSize = 0;\r
- }\r
- }\r
- }\r
- } while (EFI_ERROR (Status));\r
-\r
- //\r
- // At this point it is very dangerous to do things EFI as most of EFI is now gone.\r
- // This command is useful if you are working with a debugger as it will shutdown\r
- // DMA and other things that could break a soft resets.\r
- //\r
- CpuDeadLoop ();\r
-\r
- // Should never get here, but makes the compiler happy\r
- return EFI_ABORTED;\r
-}\r
-\r
-\r
-/**\r
- Update the screen by decrementing the timeout value.\r
- This AsciiPrint has to match the AsciiPrint in\r
- EblPauseCmd.\r
-\r
- @param ElaspedTime Current timeout value remaining\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EblPauseCallback (\r
- IN UINTN ElapsedTime\r
- )\r
-{\r
- AsciiPrint ("\b\b\b\b\b\b\b\b\b\b\b\b \b\b%3d seconds", ElapsedTime);\r
-}\r
-\r
-/**\r
- Pause until a key is pressed and abort the remaining commands on the command\r
- line. If no key is pressed continue processing the command line. This command\r
- allows the user to stop an operation from happening and return control to the\r
- command prompt.\r
-\r
- Argv[0] - "pause"\r
- Argv[1] - timeout value is decimal seconds\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS Timeout expired with no input\r
- @return EFI_TIMEOUT Stop processing other commands on the same command line\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblPauseCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Delay;\r
- EFI_INPUT_KEY Key;\r
-\r
- Delay = (Argc == 1)? 10 : AsciiStrDecimalToUintn (Argv[1]);\r
-\r
- AsciiPrint ("Hit any key to break. You have %3d seconds", Delay);\r
- Status = EblGetCharKey (&Key, Delay, EblPauseCallback);\r
- AsciiPrint ("\n");\r
-\r
- // If we timeout then the pause succeeded thus return success\r
- // If we get a key return timeout to stop other command on this cmd line\r
- return (Status == EFI_SUCCESS) ? EFI_TIMEOUT : EFI_SUCCESS;;\r
-}\r
-\r
-\r
-/**\r
- On a debug build issue a software breakpoint to enter the debugger\r
-\r
- Argv[0] - "break"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblBreakPointCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- CpuBreakpoint ();\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Reset the system. If no Argument do a Cold reset. If argument use that reset type\r
- (W)arm = Warm Reset\r
- (S)hutdown = Shutdown Reset\r
-\r
- Argv[0] - "reset"\r
- Argv[1] - warm or shutdown reset type\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblResetCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_RESET_TYPE ResetType;\r
-\r
- ResetType = EfiResetCold;\r
- if (Argc > 1) {\r
- switch (*Argv[1]) {\r
- case 'W':\r
- case 'w':\r
- ResetType = EfiResetWarm;\r
- break;\r
- case 'S':\r
- case 's':\r
- ResetType = EfiResetShutdown;\r
- }\r
- }\r
-\r
- gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Toggle page break global. This turns on and off prompting to Quit or hit any\r
- key to continue when a command is about to scroll the screen with its output\r
-\r
- Argv[0] - "page"\r
- Argv[1] - on or off\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblPageCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- if (Argc <= 1) {\r
- // toggle setting\r
- gPageBreak = (gPageBreak) ? FALSE : TRUE;\r
- } else {\r
- // use argv to set the value\r
- if ((Argv[1][0] == 'o') || (Argv[1][0] == 'O')) {\r
- if ((Argv[1][1] == 'n') || (Argv[1][1] == 'N')) {\r
- gPageBreak = TRUE;\r
- } else if ((Argv[1][1] == 'f') || (Argv[1][1] == 'F')) {\r
- gPageBreak = FALSE;\r
- } else {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- }\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblSleepCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Delay;\r
-\r
- Delay = (Argc == 1)? 10 : AsciiStrDecimalToUintn (Argv[1]);\r
-\r
- gBS->Stall (Delay * 1000000);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-CHAR8\r
-ConvertToTextLine (\r
- IN CHAR8 Character\r
- )\r
-{\r
- if (Character < ' ' || Character > '~') {\r
- return '.';\r
- } else {\r
- return Character;\r
- }\r
-}\r
-\r
-UINTN\r
-GetBytes (\r
- IN UINT8 *Address,\r
- IN UINTN Bytes\r
- )\r
-{\r
- UINTN Result = 0;\r
-\r
- if (Bytes >= 1) {\r
- Result = *Address++;\r
- }\r
- if (Bytes >= 2) {\r
- Result = (Result << 8) + *Address++;\r
- }\r
- if (Bytes >= 3) {\r
- Result = (Result << 8) + *Address++;\r
- }\r
- return Result;\r
-}\r
-\r
-CHAR8 mBlanks[] = " ";\r
-\r
-EFI_STATUS\r
-OutputData (\r
- IN UINT8 *Address,\r
- IN UINTN Length,\r
- IN UINTN Width,\r
- IN UINTN Offset\r
- )\r
-{\r
- UINT8 *EndAddress;\r
- UINTN Line;\r
- CHAR8 TextLine[0x11];\r
- UINTN CurrentRow = 0;\r
- UINTN Bytes;\r
- UINTN Spaces = 0;\r
- CHAR8 Blanks[80];\r
-\r
- AsciiStrCpyS (Blanks, sizeof Blanks, mBlanks);\r
- for (EndAddress = Address + Length; Address < EndAddress; Offset += Line) {\r
- AsciiPrint ("%08x: ", Offset);\r
- for (Line = 0; (Line < 0x10) && (Address < EndAddress);) {\r
- Bytes = EndAddress - Address;\r
-\r
- switch (Width) {\r
- case 4:\r
- if (Bytes >= 4) {\r
- AsciiPrint ("%08x ", *((UINT32 *)Address));\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- } else {\r
- AsciiPrint ("%08x ", GetBytes(Address, Bytes));\r
- Address += Bytes;\r
- Line += Bytes;\r
- }\r
- break;\r
-\r
- case 2:\r
- if (Bytes >= 2) {\r
- AsciiPrint ("%04x ", *((UINT16 *)Address));\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- } else {\r
- AsciiPrint ("%04x ", GetBytes(Address, Bytes));\r
- Address += Bytes;\r
- Line += Bytes;\r
- }\r
- break;\r
-\r
- case 1:\r
- AsciiPrint ("%02x ", *((UINT8 *)Address));\r
- TextLine[Line++] = ConvertToTextLine(*Address++);\r
- break;\r
-\r
- default:\r
- AsciiPrint ("Width must be 1, 2, or 4!\n");\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- }\r
-\r
- // Pad spaces\r
- if (Line < 0x10) {\r
- switch (Width) {\r
- case 4:\r
- Spaces = 9 * ((0x10 - Line)/4);\r
- break;\r
- case 2:\r
- Spaces = 5 * ((0x10 - Line)/2);\r
- break;\r
- case 1:\r
- Spaces = 3 * (0x10 - Line);\r
- break;\r
- }\r
-\r
- Blanks[Spaces] = '\0';\r
-\r
- AsciiPrint(Blanks);\r
-\r
- Blanks[Spaces] = ' ';\r
- }\r
-\r
- TextLine[Line] = 0;\r
- AsciiPrint ("|%a|\n", TextLine);\r
-\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- return EFI_END_OF_FILE;\r
- }\r
- }\r
-\r
- if (Length % Width != 0) {\r
- AsciiPrint ("%08x\n", Offset);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- See if command contains .# where # is a number. Return # as the Width\r
- or 1 as the default Width for commands.\r
-\r
- Example hexdump.4 returns a width of 4.\r
-\r
- @param Argv Argv[0] is the command name\r
-\r
- @return Width of command\r
-\r
-**/\r
-UINTN\r
-WidthFromCommandName (\r
- IN CHAR8 *Argv,\r
- IN UINTN Default\r
- )\r
-{\r
- CHAR8 *Str;\r
- UINTN Width;\r
-\r
- //Hexdump.2 HexDump.4 mean use a different width\r
- Str = AsciiStrStr (Argv, ".");\r
- if (Str != NULL) {\r
- Width = AsciiStrDecimalToUintn (Str + 1);\r
- if (Width == 0) {\r
- Width = Default;\r
- }\r
- } else {\r
- // Default answer\r
- return Default;\r
- }\r
-\r
- return Width;\r
-}\r
-\r
-#define HEXDUMP_CHUNK 1024\r
-\r
-/**\r
- Toggle page break global. This turns on and off prompting to Quit or hit any\r
- key to continue when a command is about to scroll the screen with its output\r
-\r
- Argv[0] - "hexdump"[.#] # is optional 1,2, or 4 for width\r
- Argv[1] - Device or File to dump.\r
- Argv[2] - Optional offset to start dumping\r
- Argv[3] - Optional number of bytes to dump\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblHexdumpCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_OPEN_FILE *File;\r
- VOID *Location;\r
- UINTN Size;\r
- UINTN Width;\r
- UINTN Offset = 0;\r
- EFI_STATUS Status;\r
- UINTN Chunk = HEXDUMP_CHUNK;\r
-\r
- if ((Argc < 2) || (Argc > 4)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Width = WidthFromCommandName (Argv[0], 1);\r
- if ((Width != 1) && (Width != 2) && (Width != 4)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Location = AllocatePool (Chunk);\r
- Size = (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : EfiTell (File, NULL);\r
-\r
- Offset = 0;\r
- if (Argc > 2) {\r
- Offset = AsciiStrHexToUintn (Argv[2]);\r
- if (Offset > 0) {\r
- // Make sure size includes the part of the file we have skipped\r
- Size += Offset;\r
- }\r
- }\r
-\r
- Status = EfiSeek (File, Offset, EfiSeekStart);\r
- if (EFI_ERROR (Status)) {\r
- goto Exit;\r
- }\r
-\r
- for (; Offset + HEXDUMP_CHUNK <= Size; Offset += Chunk) {\r
- Chunk = HEXDUMP_CHUNK;\r
- Status = EfiRead (File, Location, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint ("Error reading file content\n");\r
- goto Exit;\r
- }\r
-\r
- Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset);\r
- if (EFI_ERROR(Status)) {\r
- if (Status == EFI_END_OF_FILE) {\r
- Status = EFI_SUCCESS;\r
- }\r
- goto Exit;\r
- }\r
- }\r
-\r
- // Any left over?\r
- if (Offset < Size) {\r
- Chunk = Size - Offset;\r
- Status = EfiRead (File, Location, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint ("Error reading file content\n");\r
- goto Exit;\r
- }\r
-\r
- Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset);\r
- if (EFI_ERROR(Status)) {\r
- if (Status == EFI_END_OF_FILE) {\r
- Status = EFI_SUCCESS;\r
- }\r
- goto Exit;\r
- }\r
- }\r
-\r
-Exit:\r
- EfiClose (File);\r
-\r
- FreePool (Location);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdTemplate[] =\r
-{\r
- {\r
- "reset",\r
- " [type]; Reset system. type = [warm] [shutdown] default is cold reset",\r
- NULL,\r
- EblResetCmd\r
- },\r
- {\r
- "exit",\r
- "; Exit EBL",\r
- NULL,\r
- EblExitCmd\r
- },\r
- {\r
- "help",\r
- " [cmd]; Help on cmd or a list of all commands if cmd is ommited",\r
- NULL,\r
- EblHelpCmd\r
- },\r
- {\r
- "break",\r
- "; Generate debugging breakpoint",\r
- NULL,\r
- EblBreakPointCmd\r
- },\r
- {\r
- "page",\r
- " [on|off]]; toggle promting on command output larger than screen",\r
- NULL,\r
- EblPageCmd\r
- },\r
- {\r
- "pause",\r
- " [sec]; Pause for sec[10] seconds. ",\r
- NULL,\r
- EblPauseCmd\r
- },\r
- {\r
- "sleep",\r
- " [sec]; Sleep for sec[10] seconds. ",\r
- NULL,\r
- EblSleepCmd\r
- },\r
- {\r
- "hexdump",\r
- "[.{1|2|4}] filename [Offset] [Size]; dump a file as hex .width",\r
- NULL,\r
- EblHexdumpCmd\r
- }\r
-};\r
-\r
-\r
-EFI_HANDLE gExternalCmdHandle = NULL;\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializeCmdTable (\r
- VOID\r
- )\r
-{\r
-\r
- EblAddCommands (mCmdTemplate, sizeof (mCmdTemplate)/sizeof (EBL_COMMAND_TABLE));\r
-\r
- gBS->InstallProtocolInterface (\r
- &gExternalCmdHandle,\r
- &gEfiEblAddCommandProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &gEblAddCommand\r
- );\r
-\r
-}\r
-\r
-\r
-VOID\r
-EblShutdownExternalCmdTable (\r
- VOID\r
- )\r
-{\r
- gBS->UninstallProtocolInterface (gExternalCmdHandle, &gEfiEblAddCommandProtocolGuid, &gEblAddCommand);\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- Dir for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name: CmdTemplate.c\r
-\r
- Search/Replace Dir with the name of your new command\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gFvFileType[] = {\r
- "All",\r
- "Bin",\r
- "section",\r
- "SEC",\r
- "PeiCore",\r
- "DxeCore",\r
- "PEIM",\r
- "Driver",\r
- "Combo",\r
- "App",\r
- "NULL",\r
- "FV"\r
-};\r
-\r
-\r
-/**\r
- Perform a dir on a device. The device must support Simple File System Protocol\r
- or the FV protocol.\r
-\r
- Argv[0] - "dir"\r
- Argv[1] - Device Name:path. Path is optional\r
- Argv[2] - Optional filename to match on. A leading * means match substring\r
- Argv[3] - Optional FV file type\r
-\r
- dir fs1:\efi ; perform a dir on fs1: device in the efi directory\r
- dir fs1:\efi *.efi; perform a dir on fs1: device in the efi directory but\r
- only print out files that contain the string *.efi\r
- dir fv1:\ ; perform a dir on fv1: device in the efi directory\r
- NOTE: fv devices do not contain subdirs\r
- dir fv1:\ * PEIM ; will match all files of type PEIM\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblDirCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- EFI_FILE_INFO *DirInfo;\r
- UINTN ReadSize;\r
- UINTN CurrentRow;\r
- CHAR16 *MatchSubString;\r
- EFI_STATUS GetNextFileStatus;\r
- UINTN Key;\r
- EFI_FV_FILETYPE SearchType;\r
- EFI_FV_FILETYPE Type;\r
- EFI_FV_FILE_ATTRIBUTES Attributes;\r
- UINTN Size;\r
- EFI_GUID NameGuid;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
- UINT32 AuthenticationStatus;\r
- VOID *Section;\r
- UINTN SectionSize;\r
- EFI_FV_FILETYPE Index;\r
- UINTN Length;\r
- UINTN BestMatchCount;\r
- CHAR16 UnicodeFileName[MAX_CMD_LINE];\r
- CHAR8 *Path;\r
- CHAR8 *TypeStr;\r
- UINTN TotalSize;\r
-\r
-\r
- if (Argc <= 1) {\r
- Path = EfiGetCwd ();\r
- if (Path == NULL) {\r
- return EFI_SUCCESS;\r
- }\r
- } else {\r
- Path = Argv[1];\r
- }\r
-\r
- File = EfiOpen (Path, EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- if (File->Type == EfiOpenFirmwareVolume) {\r
- // FV Dir\r
-\r
- SearchType = EFI_FV_FILETYPE_ALL;\r
- UnicodeFileName[0] = '\0';\r
- MatchSubString = &UnicodeFileName[0];\r
- if (Argc > 2) {\r
- AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName,\r
- ARRAY_SIZE (UnicodeFileName));\r
- if (UnicodeFileName[0] == '*') {\r
- // Handle *Name substring matching\r
- MatchSubString = &UnicodeFileName[1];\r
- }\r
-\r
- // Handle file type matchs\r
- if (Argc > 3) {\r
- // match a specific file type, always last argument\r
- Length = AsciiStrLen (Argv[3]);\r
- for (Index = 1, BestMatchCount = 0; Index < sizeof (gFvFileType)/sizeof (CHAR8 *); Index++) {\r
- if (AsciiStriCmp (gFvFileType[Index], Argv[3]) == 0) {\r
- // exact match\r
- SearchType = Index;\r
- break;\r
- }\r
-\r
- if (AsciiStrniCmp (Argv[3], gFvFileType[Index], Length) == 0) {\r
- // partial match, so keep looking to make sure there is only one partial match\r
- BestMatchCount++;\r
- SearchType = Index;\r
- }\r
- }\r
-\r
- if (BestMatchCount > 1) {\r
- SearchType = EFI_FV_FILETYPE_ALL;\r
- }\r
- }\r
- }\r
-\r
- TotalSize = 0;\r
- Fv = File->Fv;\r
- Key = 0;\r
- CurrentRow = 0;\r
- do {\r
- Type = SearchType;\r
- GetNextFileStatus = Fv->GetNextFile (\r
- Fv,\r
- &Key,\r
- &Type,\r
- &NameGuid,\r
- &Attributes,\r
- &Size\r
- );\r
- if (!EFI_ERROR (GetNextFileStatus)) {\r
- TotalSize += Size;\r
- // Calculate size of entire file\r
- Section = NULL;\r
- Size = 0;\r
- Status = Fv->ReadFile (\r
- Fv,\r
- &NameGuid,\r
- Section,\r
- &Size,\r
- &Type,\r
- &Attributes,\r
- &AuthenticationStatus\r
- );\r
- if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {\r
- // EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid\r
- Size = 0;\r
- }\r
-\r
- TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN";\r
-\r
- // read the UI seciton to do a name match.\r
- Section = NULL;\r
- Status = Fv->ReadSection (\r
- Fv,\r
- &NameGuid,\r
- EFI_SECTION_USER_INTERFACE,\r
- 0,\r
- &Section,\r
- &SectionSize,\r
- &AuthenticationStatus\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- if (StrStr (Section, MatchSubString) != NULL) {\r
- AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
- }\r
- FreePool (Section);\r
- } else {\r
- if (*MatchSubString == '\0') {\r
- AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- } while (!EFI_ERROR (GetNextFileStatus));\r
-\r
- if (SearchType == EFI_FV_FILETYPE_ALL) {\r
- AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize);\r
- }\r
-\r
-\r
- } else if ((File->Type == EfiOpenFileSystem) || (File->Type == EfiOpenBlockIo)) {\r
- // Simple File System DIR\r
-\r
- if (File->FsFileInfo == NULL) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- if (!(File->FsFileInfo->Attribute & EFI_FILE_DIRECTORY)) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- // Handle *Name substring matching\r
- MatchSubString = NULL;\r
- UnicodeFileName[0] = '\0';\r
- if (Argc > 2) {\r
- AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName, MAX_CMD_LINE);\r
- if (UnicodeFileName[0] == '*') {\r
- MatchSubString = &UnicodeFileName[1];\r
- }\r
- }\r
-\r
- File->FsFileHandle->SetPosition (File->FsFileHandle, 0);\r
- for (CurrentRow = 0;;) {\r
- // First read gets the size\r
- DirInfo = NULL;\r
- ReadSize = 0;\r
- Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- // Allocate the buffer for the real read\r
- DirInfo = AllocatePool (ReadSize);\r
- if (DirInfo == NULL) {\r
- goto Done;\r
- }\r
-\r
- // Read the data\r
- Status = File->FsFileHandle->Read (File->FsFileHandle, &ReadSize, DirInfo);\r
- if ((EFI_ERROR (Status)) || (ReadSize == 0)) {\r
- break;\r
- }\r
- } else {\r
- break;\r
- }\r
-\r
- if (MatchSubString != NULL) {\r
- if (StrStr (&DirInfo->FileName[0], MatchSubString) == NULL) {\r
- // does not match *name argument, so skip\r
- continue;\r
- }\r
- } else if (UnicodeFileName[0] != '\0') {\r
- // is not an exact match for name argument, so skip\r
- if (StrCmp (&DirInfo->FileName[0], UnicodeFileName) != 0) {\r
- continue;\r
- }\r
- }\r
-\r
- if (DirInfo->Attribute & EFI_FILE_DIRECTORY) {\r
- AsciiPrint (" <DIR> %s\n", &DirInfo->FileName[0]);\r
- } else {\r
- AsciiPrint ("%,14ld %s\n", DirInfo->FileSize, &DirInfo->FileName[0]);\r
- }\r
-\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
-\r
- FreePool (DirInfo);\r
- }\r
-\r
-Done:\r
- if (DirInfo != NULL) {\r
- FreePool (DirInfo);\r
- }\r
- }\r
-\r
- EfiClose (File);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Change the Current Working Directory\r
-\r
- Argv[0] - "cd"\r
- Argv[1] - Device Name:path. Path is optional\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblCdCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- if (Argc <= 1) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- return EfiSetCwd (Argv[1]);\r
-}\r
-\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDirTemplate[] =\r
-{\r
- {\r
- "dir",\r
- " dirdev [*match]; directory listing of dirdev. opt match a substring",\r
- NULL,\r
- EblDirCmd\r
- },\r
- {\r
- "cd",\r
- " device - set the current working directory",\r
- NULL,\r
- EblCdCmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializeDirCmd (\r
- VOID\r
- )\r
-{\r
- if (FeaturePcdGet (PcdEmbeddedDirCmd)) {\r
- EblAddCommands (mCmdDirTemplate, sizeof (mCmdDirTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Include file for basic command line parser for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EBL_H__\r
-#define __EBL_H__\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/LoadFile.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/PxeBaseCode.h>\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/EblAddCommand.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/DxeServices.h>\r
-#include <Guid/MemoryTypeInformation.h>\r
-#include <Guid/MemoryAllocationHob.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EfiFileLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/EblCmdLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/EblNetworkLib.h>\r
-#include <Library/TimerLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-//\r
-// Prompt for the command line\r
-//\r
-#define CMD_SEPARATOR ';'\r
-#define EBL_MAX_COMMAND_COUNT 0x100\r
-#define MAX_CMD_HISTORY 16\r
-#define MAX_CMD_LINE 256\r
-#define MAX_ARGS 32\r
-\r
-#define EBL_CR 0x0a\r
-#define EBL_LF 0x0d\r
-\r
-#define EFI_SET_TIMER_TO_SECOND 10000000\r
-\r
-\r
-\r
-EBL_COMMAND_TABLE *\r
-EblGetCommand (\r
- IN CHAR8 *CommandName\r
- );\r
-\r
-\r
-EFI_STATUS\r
-EblPathToDevice (\r
- IN CHAR8 *Path,\r
- OUT EFI_HANDLE *DeviceHandle,\r
- OUT EFI_DEVICE_PATH_PROTOCOL **PathDevicePath,\r
- OUT VOID **Buffer,\r
- OUT UINTN *BufferSize\r
- );\r
-\r
-BOOLEAN\r
-EFIAPI\r
-EblAnyKeyToContinueQtoQuit (\r
- IN UINTN *CurrentRow,\r
- IN BOOLEAN PrefixNewline\r
- );\r
-\r
-VOID\r
-EblUpdateDeviceLists (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeCmdTable (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblShutdownExternalCmdTable (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblSetTextColor (\r
- UINTN Attribute\r
- );\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCharKey (\r
- IN OUT EFI_INPUT_KEY *Key,\r
- IN UINTN TimoutInSec,\r
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r
- );\r
-\r
-// BugBug: Move me to a library\r
-INTN\r
-EFIAPI\r
-AsciiStrniCmp (\r
- IN CONST CHAR8 *FirstString,\r
- IN CONST CHAR8 *SecondString,\r
- IN UINTN Length\r
- );\r
-\r
-\r
-VOID\r
-EblInitializeDeviceCmd (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializemdHwDebugCmds (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeDirCmd (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeHobCmd (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializemdHwIoDebugCmds (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeScriptCmd (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeNetworkCmd (\r
- VOID\r
- );\r
-\r
-VOID\r
-EblInitializeVariableCmds (\r
- VOID\r
- );\r
-\r
-CHAR8 *\r
-ParseArguments (\r
- IN CHAR8 *CmdLine,\r
- OUT UINTN *Argc,\r
- OUT CHAR8 **Argv\r
- );\r
-\r
-EFI_STATUS\r
-ProcessCmdLine (\r
- IN CHAR8 *CmdLine,\r
- IN UINTN MaxCmdLineSize\r
- );\r
-\r
-EFI_STATUS\r
-OutputData (\r
- IN UINT8 *Address,\r
- IN UINTN Length,\r
- IN UINTN Width,\r
- IN UINTN Offset\r
- );\r
-\r
-UINTN\r
-WidthFromCommandName (\r
- IN CHAR8 *Argv,\r
- IN UINTN Default\r
- );\r
-\r
-\r
-extern UINTN gScreenColumns;\r
-extern UINTN gScreenRows;\r
-extern BOOLEAN gPageBreak;\r
-extern CHAR8 *gMemMapType[];\r
-\r
-#endif\r
-\r
+++ /dev/null
-#/** @file\r
-# EBL Applicaiton\r
-#\r
-# This is a shell application that will display Hello World.\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = Ebl\r
- FILE_GUID = 3CEF354A-3B7A-4519-AD70-72A134698311\r
- MODULE_TYPE = UEFI_APPLICATION\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = EdkBootLoaderEntry\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-[Sources.common]\r
- Main.c\r
- Command.c\r
- EfiDevice.c\r
- HwDebug.c\r
- HwIoDebug.c\r
- Dir.c\r
- Hob.c\r
- Script.c\r
- Ebl.h\r
- Network.c\r
- Variable.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- IntelFrameworkPkg/IntelFrameworkPkg.dec\r
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
- DebugLib\r
- UefiLib\r
- UefiApplicationEntryPoint\r
- UefiBootServicesTableLib\r
- UefiRuntimeServicesTableLib\r
- BaseMemoryLib\r
- MemoryAllocationLib\r
- DevicePathLib\r
- IoLib\r
- PrintLib\r
- PcdLib\r
- EfiFileLib\r
- HobLib\r
- BaseLib\r
- EblCmdLib\r
- EblNetworkLib\r
-\r
-[LibraryClasses.ARM]\r
- SemihostLib\r
-\r
-[Protocols.common]\r
- gEfiFirmwareVolume2ProtocolGuid\r
- gEfiFirmwareVolumeBlockProtocolGuid\r
- gEfiBlockIoProtocolGuid\r
- gEfiSimpleFileSystemProtocolGuid\r
- gEfiLoadFileProtocolGuid\r
- gEfiLoadedImageProtocolGuid\r
- gEfiPxeBaseCodeProtocolGuid\r
- gEfiEblAddCommandProtocolGuid\r
- gEfiDiskIoProtocolGuid\r
- gEfiPciIoProtocolGuid\r
- gEfiSimpleNetworkProtocolGuid\r
-\r
-[Guids.common]\r
- gEfiDxeServicesTableGuid\r
- gEfiFileInfoGuid\r
- gEfiHobMemoryAllocModuleGuid\r
- gEfiMemoryTypeInformationGuid\r
-\r
-[FeaturePcd.common]\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDirCmd\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHobCmd\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedHwDebugCmd\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable\r
-\r
-[FixedPcd.common]\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedShellCharacterEcho\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt\r
-\r
+++ /dev/null
-/** @file\r
- EBL commands for EFI and PI Devices\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-EFI_DXE_SERVICES *gDS = NULL;\r
-\r
-\r
-/**\r
- Print information about the File System device.\r
-\r
- @param File Open File for the device\r
-\r
-**/\r
-VOID\r
-EblPrintFsInfo (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- CHAR16 *Str;\r
-\r
- if (File == NULL) {\r
- return;\r
- }\r
-\r
- AsciiPrint (" %a: ", File->DeviceName);\r
- if (File->FsInfo != NULL) {\r
- for (Str = File->FsInfo->VolumeLabel; *Str != '\0'; Str++) {\r
- if (*Str == ' ') {\r
- // UI makes you enter _ for space, so make the printout match that\r
- *Str = '_';\r
- }\r
- AsciiPrint ("%c", *Str);\r
- }\r
- AsciiPrint (":");\r
- if (File->FsInfo->ReadOnly) {\r
- AsciiPrint ("ReadOnly");\r
- }\r
- }\r
-\r
- AsciiPrint ("\n");\r
- EfiClose (File);\r
-}\r
-\r
-\r
-/**\r
- Print information about the FV devices.\r
-\r
- @param File Open File for the device\r
-\r
-**/\r
-VOID\r
-EblPrintFvbInfo (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- if (File == NULL) {\r
- return;\r
- }\r
-\r
- AsciiPrint (" %a: 0x%08lx - 0x%08lx : 0x%08x\n", File->DeviceName, File->FvStart, File->FvStart + File->FvSize - 1, File->FvSize);\r
- EfiClose (File);\r
-}\r
-\r
-\r
-/**\r
- Print information about the Blk IO devices.\r
- If the device supports PXE dump out extra information\r
-\r
- @param File Open File for the device\r
-\r
-**/\r
-VOID\r
-EblPrintBlkIoInfo (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- UINT64 DeviceSize;\r
- UINTN Index;\r
- UINTN Max;\r
- EFI_OPEN_FILE *FsFile;\r
-\r
- if (File == NULL) {\r
- return;\r
- }\r
-\r
- AsciiPrint (" %a: ", File->DeviceName);\r
-\r
- // print out name of file system, if any, on this block device\r
- Max = EfiGetDeviceCounts (EfiOpenFileSystem);\r
- if (Max != 0) {\r
- for (Index = 0; Index < Max; Index++) {\r
- FsFile = EfiDeviceOpenByType (EfiOpenFileSystem, Index);\r
- if (FsFile != NULL) {\r
- if (FsFile->EfiHandle == File->EfiHandle) {\r
- AsciiPrint ("fs%d: ", Index);\r
- EfiClose (FsFile);\r
- break;\r
- }\r
- EfiClose (FsFile);\r
- }\r
- }\r
- }\r
-\r
- // Print out useful Block IO media properties\r
- if (File->FsBlockIoMedia->RemovableMedia) {\r
- AsciiPrint ("Removable ");\r
- }\r
- if (!File->FsBlockIoMedia->MediaPresent) {\r
- AsciiPrint ("No Media\n");\r
- } else {\r
- if (File->FsBlockIoMedia->LogicalPartition) {\r
- AsciiPrint ("Partition ");\r
- }\r
- DeviceSize = MultU64x32 (File->FsBlockIoMedia->LastBlock + 1, File->FsBlockIoMedia->BlockSize);\r
- AsciiPrint ("Size = 0x%lX\n", DeviceSize);\r
- }\r
- EfiClose (File);\r
-}\r
-\r
- /**\r
- Print information about the Load File devices.\r
- If the device supports PXE dump out extra information\r
-\r
- @param File Open File for the device\r
-\r
-**/\r
-VOID\r
-EblPrintLoadFileInfo (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
- MAC_ADDR_DEVICE_PATH *MacAddr;\r
- UINTN HwAddressSize;\r
- UINTN Index;\r
-\r
- if (File == NULL) {\r
- return;\r
- }\r
-\r
- AsciiPrint (" %a: %a ", File->DeviceName, EblLoadFileBootTypeString (File->EfiHandle));\r
-\r
- if (File->DevicePath != NULL) {\r
- // Try to print out the MAC address\r
- for (DevicePathNode = File->DevicePath;\r
- !IsDevicePathEnd (DevicePathNode);\r
- DevicePathNode = NextDevicePathNode (DevicePathNode)) {\r
-\r
- if ((DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePathNode) == MSG_MAC_ADDR_DP)) {\r
- MacAddr = (MAC_ADDR_DEVICE_PATH *)DevicePathNode;\r
-\r
- HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
- if (MacAddr->IfType == 0x01 || MacAddr->IfType == 0x00) {\r
- HwAddressSize = 6;\r
- }\r
-\r
- AsciiPrint ("MAC ");\r
- for (Index = 0; Index < HwAddressSize; Index++) {\r
- AsciiPrint ("%02x", MacAddr->MacAddress.Addr[Index] & 0xff);\r
- }\r
- }\r
- }\r
- }\r
-\r
- AsciiPrint ("\n");\r
- EfiClose (File);\r
- return;\r
-}\r
-\r
-\r
-\r
-/**\r
- Dump information about devices in the system.\r
-\r
- fv: PI Firmware Volume\r
- fs: EFI Simple File System\r
- blk: EFI Block IO\r
- LoadFile: EFI Load File Protocol (commonly PXE network boot)\r
-\r
- Argv[0] - "device"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblDeviceCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Index;\r
- UINTN CurrentRow;\r
- UINTN Max;\r
-\r
- CurrentRow = 0;\r
-\r
- // Need to call here to make sure Device Counts are valid\r
- EblUpdateDeviceLists ();\r
-\r
- // Now we can print out the info...\r
- Max = EfiGetDeviceCounts (EfiOpenFirmwareVolume);\r
- if (Max != 0) {\r
- AsciiPrint ("Firmware Volume Devices:\n");\r
- for (Index = 0; Index < Max; Index++) {\r
- EblPrintFvbInfo (EfiDeviceOpenByType (EfiOpenFirmwareVolume, Index));\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- Max = EfiGetDeviceCounts (EfiOpenFileSystem);\r
- if (Max != 0) {\r
- AsciiPrint ("File System Devices:\n");\r
- for (Index = 0; Index < Max; Index++) {\r
- EblPrintFsInfo (EfiDeviceOpenByType (EfiOpenFileSystem, Index));\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- Max = EfiGetDeviceCounts (EfiOpenBlockIo);\r
- if (Max != 0) {\r
- AsciiPrint ("Block IO Devices:\n");\r
- for (Index = 0; Index < Max; Index++) {\r
- EblPrintBlkIoInfo (EfiDeviceOpenByType (EfiOpenBlockIo, Index));\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- Max = EfiGetDeviceCounts (EfiOpenLoadFile);\r
- if (Max != 0) {\r
- AsciiPrint ("LoadFile Devices: (usually network)\n");\r
- for (Index = 0; Index < Max; Index++) {\r
- EblPrintLoadFileInfo (EfiDeviceOpenByType (EfiOpenLoadFile, Index));\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Start an EFI image (PE32+ with EFI defined entry point).\r
-\r
- Argv[0] - "start"\r
- Argv[1] - device name and path\r
- Argv[2] - "" string to pass into image being started\r
-\r
- start fs1:\Temp\Fv.Fv "arg to pass" ; load an FV from the disk and pass the\r
- ; ascii string arg to pass to the image\r
- start fv0:\FV ; load an FV from an FV (not common)\r
- start LoadFile0: ; load an FV via a PXE boot\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblStartCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_HANDLE ImageHandle;\r
- UINTN ExitDataSize;\r
- CHAR16 *ExitData;\r
- VOID *Buffer;\r
- UINTN BufferSize;\r
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
-\r
- ImageHandle = NULL;\r
-\r
- if (Argc < 2) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- DevicePath = File->DevicePath;\r
- if (DevicePath != NULL) {\r
- // check for device path form: blk, fv, fs, and loadfile\r
- Status = gBS->LoadImage (FALSE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);\r
- } else {\r
- // Check for buffer form: A0x12345678:0x1234 syntax.\r
- // Means load using buffer starting at 0x12345678 of size 0x1234.\r
-\r
- Status = EfiReadAllocatePool (File, &Buffer, &BufferSize);\r
- if (EFI_ERROR (Status)) {\r
- EfiClose (File);\r
- return Status;\r
- }\r
- Status = gBS->LoadImage (FALSE, gImageHandle, DevicePath, Buffer, BufferSize, &ImageHandle);\r
-\r
- FreePool (Buffer);\r
- }\r
-\r
- EfiClose (File);\r
-\r
- if (!EFI_ERROR (Status)) {\r
- if (Argc >= 3) {\r
- // Argv[2] is a "" string that we pass directly to the EFI application without the ""\r
- // We don't pass Argv[0] to the EFI Application (it's name) just the args\r
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- ImageInfo->LoadOptionsSize = (UINT32)AsciiStrSize (Argv[2]);\r
- ImageInfo->LoadOptions = AllocatePool (ImageInfo->LoadOptionsSize);\r
- AsciiStrCpyS (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, Argv[2]);\r
- }\r
-\r
- // Transfer control to the EFI image we loaded with LoadImage()\r
- Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Load a Firmware Volume (FV) into memory from a device. This causes drivers in\r
- the FV to be dispatched if the dependencies of the drivers are met.\r
-\r
- Argv[0] - "loadfv"\r
- Argv[1] - device name and path\r
-\r
- loadfv fs1:\Temp\Fv.Fv ; load an FV from the disk\r
- loadfv fv0:\FV ; load an FV from an FV (not common)\r
- loadfv LoadFile0: ; load an FV via a PXE boot\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblLoadFvCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- VOID *FvStart;\r
- UINTN FvSize;\r
- EFI_HANDLE FvHandle;\r
-\r
-\r
- if (Argc < 2) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (File->Type == EfiOpenMemoryBuffer) {\r
- // If it is a address just use it.\r
- Status = gDS->ProcessFirmwareVolume (File->Buffer, File->Size, &FvHandle);\r
- } else {\r
- // If it is a file read it into memory and use it\r
- Status = EfiReadAllocatePool (File, &FvStart, &FvSize);\r
- EfiClose (File);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = gDS->ProcessFirmwareVolume (FvStart, FvSize, &FvHandle);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (FvStart);\r
- }\r
- }\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Perform an EFI connect to connect devices that follow the EFI driver model.\r
- If it is a PI system also call the dispatcher in case a new FV was made\r
- available by one of the connect EFI drivers (this is not a common case).\r
-\r
- Argv[0] - "connect"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblConnectCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuffer;\r
- UINTN Index;\r
- BOOLEAN Dispatch;\r
- EFI_OPEN_FILE *File;\r
-\r
-\r
- if (Argc > 1) {\r
- if ((*Argv[1] == 'd') || (*Argv[1] == 'D')) {\r
- Status = gBS->LocateHandleBuffer (\r
- AllHandles,\r
- NULL,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
- }\r
-\r
- //\r
- // Given we disconnect our console we should go and do a connect now\r
- //\r
- } else {\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File != NULL) {\r
- AsciiPrint ("Connecting %a\n", Argv[1]);\r
- gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE);\r
- EfiClose (File);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- }\r
-\r
- Dispatch = FALSE;\r
- do {\r
- Status = gBS->LocateHandleBuffer (\r
- AllHandles,\r
- NULL,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
- }\r
-\r
- FreePool (HandleBuffer);\r
-\r
- //\r
- // Check to see if it's possible to dispatch an more DXE drivers.\r
- // The BdsLibConnectAllEfi () may have made new DXE drivers show up.\r
- // If anything is Dispatched Status == EFI_SUCCESS and we will try\r
- // the connect again.\r
- //\r
- if (gDS == NULL) {\r
- Status = EFI_NOT_FOUND;\r
- } else {\r
- Status = gDS->Dispatch ();\r
- if (!EFI_ERROR (Status)) {\r
- Dispatch = TRUE;\r
- }\r
- }\r
-\r
- } while (!EFI_ERROR (Status));\r
-\r
- if (Dispatch) {\r
- AsciiPrint ("Connected and dispatched\n");\r
- } else {\r
- AsciiPrint ("Connect\n");\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-CHAR8 *gMemMapType[] = {\r
- "reserved ",\r
- "LoaderCode",\r
- "LoaderData",\r
- "BS_code ",\r
- "BS_data ",\r
- "RT_code ",\r
- "RT_data ",\r
- "available ",\r
- "Unusable ",\r
- "ACPI_recl ",\r
- "ACPI_NVS ",\r
- "MemMapIO ",\r
- "MemPortIO ",\r
- "PAL_code "\r
-};\r
-\r
-\r
-/**\r
- Dump out the EFI memory map\r
-\r
- Argv[0] - "memmap"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblMemMapCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_MEMORY_DESCRIPTOR *MemMap;\r
- EFI_MEMORY_DESCRIPTOR *OrigMemMap;\r
- UINTN MemMapSize;\r
- UINTN MapKey;\r
- UINTN DescriptorSize;\r
- UINT32 DescriptorVersion;\r
- UINT64 PageCount[EfiMaxMemoryType];\r
- UINTN Index;\r
- UINT64 EntrySize;\r
- UINTN CurrentRow;\r
- UINT64 TotalMemory;\r
-\r
- ZeroMem (PageCount, sizeof (PageCount));\r
-\r
- AsciiPrint ("EFI Memory Map\n");\r
-\r
- // First call is to figure out how big the buffer needs to be\r
- MemMapSize = 0;\r
- MemMap = NULL;\r
- Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- // In case the AllocatPool changes the memory map we added in some extra descriptors\r
- MemMapSize += (DescriptorSize * 0x100);\r
- OrigMemMap = MemMap = AllocatePool (MemMapSize);\r
- if (OrigMemMap != NULL) {\r
- // 2nd time we get the data\r
- Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
- if (!EFI_ERROR (Status)) {\r
- for (Index = 0, CurrentRow = 0; Index < MemMapSize/DescriptorSize; Index++) {\r
- EntrySize = LShiftU64 (MemMap->NumberOfPages, 12);\r
- AsciiPrint ("\n%a %016lx - %016lx: # %08lx %016lx", gMemMapType[MemMap->Type % EfiMaxMemoryType], MemMap->PhysicalStart, MemMap->PhysicalStart + EntrySize -1, MemMap->NumberOfPages, MemMap->Attribute);\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, TRUE)) {\r
- break;\r
- }\r
-\r
- PageCount[MemMap->Type % EfiMaxMemoryType] += MemMap->NumberOfPages;\r
- MemMap = NEXT_MEMORY_DESCRIPTOR (MemMap, DescriptorSize);\r
- }\r
- }\r
-\r
- for (Index = 0, TotalMemory = 0; Index < EfiMaxMemoryType; Index++) {\r
- if (PageCount[Index] != 0) {\r
- AsciiPrint ("\n %a %,7ld Pages (%,14ld)", gMemMapType[Index], PageCount[Index], LShiftU64 (PageCount[Index], 12));\r
- if (Index == EfiLoaderCode ||\r
- Index == EfiLoaderData ||\r
- Index == EfiBootServicesCode ||\r
- Index == EfiBootServicesData ||\r
- Index == EfiRuntimeServicesCode ||\r
- Index == EfiRuntimeServicesData ||\r
- Index == EfiConventionalMemory ||\r
- Index == EfiACPIReclaimMemory ||\r
- Index == EfiACPIMemoryNVS ||\r
- Index == EfiPalCode\r
- ) {\r
- // Count total memory\r
- TotalMemory += PageCount[Index];\r
- }\r
- }\r
- }\r
-\r
- AsciiPrint ("\nTotal Memory: %,ld MB (%,ld bytes)\n", RShiftU64 (TotalMemory, 8), LShiftU64 (TotalMemory, 12));\r
-\r
- FreePool (OrigMemMap);\r
-\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
- Load a file into memory and optionally jump to it. A load address can be\r
- specified or automatically allocated. A quoted command line can optionally\r
- be passed into the image.\r
-\r
- Argv[0] - "go"\r
- Argv[1] - Device Name:path for the file to load\r
- Argv[2] - Address to load to or '*' if the load address will be allocated\r
- Argv[3] - Optional Entry point to the image. Image will be called if present\r
- Argv[4] - "" string that will be passed as Argc & Argv to EntryPoint. Needs\r
- to include the command name\r
-\r
- go fv1:\EblCmdX 0x10000 0x10010 "EblCmdX Arg2 Arg3 Arg4"; - load EblCmdX\r
- from FV1 to location 0x10000 and call the entry point at 0x10010 passing\r
- in "EblCmdX Arg2 Arg3 Arg4" as the arguments.\r
-\r
- go fv0:\EblCmdX * 0x10 "EblCmdX Arg2 Arg3 Arg4"; - load EblCmdX from FS0\r
- to location allocated by this command and call the entry point at offset 0x10\r
- passing in "EblCmdX Arg2 Arg3 Arg4" as the arguments.\r
-\r
- go fv1:\EblCmdX 0x10000; Load EblCmdX to address 0x10000 and return\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblGoCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- VOID *Address;\r
- UINTN Size;\r
- EBL_COMMMAND EntryPoint;\r
- UINTN EntryPointArgc;\r
- CHAR8 *EntryPointArgv[MAX_ARGS];\r
-\r
-\r
- if (Argc <= 2) {\r
- // device name and laod address are required\r
- return EFI_SUCCESS;\r
- }\r
-\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- AsciiPrint (" %a is not a valid path\n", Argv[1]);\r
- return EFI_SUCCESS;\r
- }\r
-\r
- EntryPoint = (EBL_COMMMAND)((Argc > 3) ? (UINTN)AsciiStrHexToUintn (Argv[3]) : (UINTN)NULL);\r
- if (Argv[2][0] == '*') {\r
- // * Means allocate the buffer\r
- Status = EfiReadAllocatePool (File, &Address, &Size);\r
-\r
- // EntryPoint is relative to the start of the image\r
- EntryPoint = (EBL_COMMMAND)((UINTN)EntryPoint + (UINTN)Address);\r
-\r
- } else {\r
- Address = (VOID *)AsciiStrHexToUintn (Argv[2]);\r
- Size = File->Size;\r
-\r
- // File->Size for LoadFile is lazy so we need to use the tell to figure it out\r
- EfiTell (File, NULL);\r
- Status = EfiRead (File, Address, &Size);\r
- }\r
-\r
- if (!EFI_ERROR (Status)) {\r
- AsciiPrint ("Loaded %,d bytes to 0x%08x\n", Size, Address);\r
-\r
- if (Argc > 3) {\r
- if (Argc > 4) {\r
- ParseArguments (Argv[4], &EntryPointArgc, EntryPointArgv);\r
- } else {\r
- EntryPointArgc = 1;\r
- EntryPointArgv[0] = File->FileName;\r
- }\r
-\r
- Status = EntryPoint (EntryPointArgc, EntryPointArgv);\r
- }\r
- }\r
-\r
- EfiClose (File);\r
- return Status;\r
-}\r
-\r
-#define FILE_COPY_CHUNK 0x20000\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblFileCopyCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_OPEN_FILE *Source = NULL;\r
- EFI_OPEN_FILE *Destination = NULL;\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- VOID *Buffer = NULL;\r
- UINTN Size;\r
- UINTN Offset;\r
- UINTN Chunk = FILE_COPY_CHUNK;\r
- UINTN FileNameLen, DestFileNameLen;\r
- CHAR8* DestFileName;\r
- CHAR8* SrcFileName;\r
- CHAR8* SrcPtr;\r
-\r
- if (Argc < 3) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- DestFileName = Argv[2];\r
- FileNameLen = AsciiStrLen (DestFileName);\r
-\r
- // Check if the destination file name looks like a directory\r
- if ((DestFileName[FileNameLen-1] == '\\') || (DestFileName[FileNameLen-1] == ':')) {\r
- // Set the pointer after the source drive (eg: after fs1:)\r
- SrcPtr = AsciiStrStr (Argv[1], ":");\r
- if (SrcPtr == NULL) {\r
- SrcPtr = Argv[1];\r
- } else {\r
- SrcPtr++;\r
- if (*SrcPtr == '\\') {\r
- SrcPtr++;\r
- }\r
- }\r
-\r
- if (*SrcPtr == '\0') {\r
- AsciiPrint("Source file incorrect.\n");\r
- }\r
-\r
- // Skip the Source Directories\r
- while (1) {\r
- SrcFileName = SrcPtr;\r
- SrcPtr = AsciiStrStr (SrcPtr,"\\");\r
- if (SrcPtr != NULL) {\r
- SrcPtr++;\r
- } else {\r
- break;\r
- }\r
- }\r
-\r
- if (*SrcFileName == '\0') {\r
- AsciiPrint("Source file incorrect (Error 2).\n");\r
- }\r
-\r
- // Construct the destination filepath\r
- DestFileNameLen = FileNameLen + AsciiStrLen (SrcFileName) + 1;\r
- DestFileName = (CHAR8*)AllocatePool (DestFileNameLen);\r
- AsciiStrCpyS (DestFileName, DestFileNameLen, Argv[2]);\r
- AsciiStrCatS (DestFileName, DestFileNameLen, SrcFileName);\r
- }\r
-\r
- Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (Source == NULL) {\r
- AsciiPrint("Source file open error.\n");\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Destination = EfiOpen(DestFileName, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);\r
- if (Destination == NULL) {\r
- AsciiPrint("Destination file open error.\n");\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Buffer = AllocatePool(FILE_COPY_CHUNK);\r
- if (Buffer == NULL) {\r
- goto Exit;\r
- }\r
-\r
- Size = EfiTell(Source, NULL);\r
-\r
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size; Offset += Chunk) {\r
- Chunk = FILE_COPY_CHUNK;\r
-\r
- Status = EfiRead(Source, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Read file error %r\n", Status);\r
- goto Exit;\r
- }\r
-\r
- Status = EfiWrite(Destination, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Write file error %r\n", Status);\r
- goto Exit;\r
- }\r
- }\r
-\r
- // Any left over?\r
- if (Offset < Size) {\r
- Chunk = Size - Offset;\r
-\r
- Status = EfiRead(Source, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Read file error %r\n", Status);\r
- goto Exit;\r
- }\r
-\r
- Status = EfiWrite(Destination, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Write file error %r\n", Status);\r
- goto Exit;\r
- }\r
- }\r
-\r
-\r
-Exit:\r
- if (Source != NULL) {\r
- Status = EfiClose(Source);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Source close error %r\n", Status);\r
- }\r
- }\r
- if (Destination != NULL) {\r
- Status = EfiClose(Destination);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Destination close error %r\n", Status);\r
- }\r
-\r
- // Case when we have concated the filename to the destination directory\r
- if (DestFileName != Argv[2]) {\r
- FreePool (DestFileName);\r
- }\r
- }\r
-\r
- if (Buffer != NULL) {\r
- FreePool(Buffer);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblFileDiffCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_OPEN_FILE *File1 = NULL;\r
- EFI_OPEN_FILE *File2 = NULL;\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- VOID *Buffer1 = NULL;\r
- VOID *Buffer2 = NULL;\r
- UINTN Size1;\r
- UINTN Size2;\r
- UINTN Offset;\r
- UINTN Chunk = FILE_COPY_CHUNK;\r
-\r
- if (Argc != 3) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- File1 = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File1 == NULL) {\r
- AsciiPrint("File 1 open error.\n");\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- File2 = EfiOpen(Argv[2], EFI_FILE_MODE_READ, 0);\r
- if (File2 == NULL) {\r
- AsciiPrint("File 2 open error.\n");\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Size1 = EfiTell(File1, NULL);\r
- Size2 = EfiTell(File2, NULL);\r
-\r
- if (Size1 != Size2) {\r
- AsciiPrint("Files differ.\n");\r
- goto Exit;\r
- }\r
-\r
- Buffer1 = AllocatePool(FILE_COPY_CHUNK);\r
- if (Buffer1 == NULL) {\r
- goto Exit;\r
- }\r
-\r
- Buffer2 = AllocatePool(FILE_COPY_CHUNK);\r
- if (Buffer2 == NULL) {\r
- goto Exit;\r
- }\r
-\r
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size1; Offset += Chunk) {\r
- Chunk = FILE_COPY_CHUNK;\r
-\r
- Status = EfiRead(File1, Buffer1, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 1 read error\n");\r
- goto Exit;\r
- }\r
-\r
- Status = EfiRead(File2, Buffer2, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 2 read error\n");\r
- goto Exit;\r
- }\r
-\r
- if (CompareMem(Buffer1, Buffer2, Chunk) != 0) {\r
- AsciiPrint("Files differ.\n");\r
- goto Exit;\r
- };\r
- }\r
-\r
- // Any left over?\r
- if (Offset < Size1) {\r
- Chunk = Size1 - Offset;\r
-\r
- Status = EfiRead(File1, Buffer1, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 1 read error\n");\r
- goto Exit;\r
- }\r
-\r
- Status = EfiRead(File2, Buffer2, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 2 read error\n");\r
- goto Exit;\r
- }\r
- }\r
-\r
- if (CompareMem(Buffer1, Buffer2, Chunk) != 0) {\r
- AsciiPrint("Files differ.\n");\r
- } else {\r
- AsciiPrint("Files are identical.\n");\r
- }\r
-\r
-Exit:\r
- if (File1 != NULL) {\r
- Status = EfiClose(File1);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 1 close error %r\n", Status);\r
- }\r
- }\r
-\r
- if (File2 != NULL) {\r
- Status = EfiClose(File2);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("File 2 close error %r\n", Status);\r
- }\r
- }\r
-\r
- if (Buffer1 != NULL) {\r
- FreePool(Buffer1);\r
- }\r
-\r
- if (Buffer2 != NULL) {\r
- FreePool(Buffer2);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDeviceTemplate[] =\r
-{\r
- {\r
- "connect",\r
- "[d]; Connect all EFI devices. d means disconnect",\r
- NULL,\r
- EblConnectCmd\r
- },\r
- {\r
- "device",\r
- "; Show information about boot devices",\r
- NULL,\r
- EblDeviceCmd\r
- },\r
- {\r
- "go",\r
- " dev:path loadaddress entrypoint args; load to given address and jump in",\r
- NULL,\r
- EblGoCmd\r
- },\r
- {\r
- "loadfv",\r
- " devname; Load PI FV from device",\r
- NULL,\r
- EblLoadFvCmd\r
- },\r
- {\r
- "start",\r
- " path; EFI Boot Device:filepath. fs1:\\EFI\\BOOT.EFI",\r
- NULL,\r
- EblStartCmd\r
- },\r
- {\r
- "memmap",\r
- "; dump EFI memory map",\r
- NULL,\r
- EblMemMapCmd\r
- },\r
- {\r
- "cp",\r
- " file1 file2; copy file only.",\r
- NULL,\r
- EblFileCopyCmd\r
- },\r
- {\r
- "diff",\r
- " file1 file2; compare files",\r
- NULL,\r
- EblFileDiffCmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-\r
-VOID\r
-EblInitializeDeviceCmd (\r
- VOID\r
- )\r
-{\r
- EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
- EblAddCommands (mCmdDeviceTemplate, sizeof (mCmdDeviceTemplate)/sizeof (EBL_COMMAND_TABLE));\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Hob command for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name: Hob.c\r
-\r
- Search/Replace Dir with the name of your new command\r
-\r
- Boot Mode:\r
- ==========\r
- BOOT_WITH_FULL_CONFIGURATION 0x00\r
- BOOT_WITH_MINIMAL_CONFIGURATION 0x01\r
- BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02\r
- BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03\r
- BOOT_WITH_DEFAULT_SETTINGS 0x04\r
- BOOT_ON_S4_RESUME 0x05\r
- BOOT_ON_S5_RESUME 0x06\r
- BOOT_ON_S2_RESUME 0x10\r
- BOOT_ON_S3_RESUME 0x11\r
- BOOT_ON_FLASH_UPDATE 0x12\r
- BOOT_IN_RECOVERY_MODE 0x20\r
- BOOT_IN_RECOVERY_MODE_MASK 0x40\r
- BOOT_SPECIAL_MASK 0x80\r
-\r
- Mem Alloc HOB Type:\r
- ===================\r
- typedef enum {\r
- EfiReservedMemoryType = 0x00\r
- EfiLoaderCode = 0x01\r
- EfiLoaderData = 0x02\r
- EfiBootServicesCode = 0x03\r
- EfiBootServicesData = 0x04\r
- EfiRuntimeServicesCode = 0x05\r
- EfiRuntimeServicesData = 0x06\r
- EfiConventionalMemory = 0x07\r
- EfiUnusableMemory = 0x08\r
- EfiACPIReclaimMemory = 0x09\r
- EfiACPIMemoryNVS = 0x0a\r
- EfiMemoryMappedIO = 0x0b\r
- EfiMemoryMappedIOPortSpace = 0x0c\r
- EfiPalCode = 0x0d\r
- EfiMaxMemoryType = 0x0e\r
- } EFI_MEMORY_TYPE;\r
-\r
- Resource Hob Tye:\r
- =================\r
- EFI_RESOURCE_SYSTEM_MEMORY 0\r
- EFI_RESOURCE_MEMORY_MAPPED_IO 1\r
- EFI_RESOURCE_IO 2\r
- EFI_RESOURCE_FIRMWARE_DEVICE 3\r
- EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4\r
- EFI_RESOURCE_MEMORY_RESERVED 5\r
- EFI_RESOURCE_IO_RESERVED 6\r
- EFI_RESOURCE_MAX_MEMORY_TYPE 7\r
-\r
- Resource Hob Attribute (last thing printed):\r
- ============================================\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002\r
- EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004\r
- EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008\r
- EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010\r
- EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020\r
- EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040\r
- EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100\r
- EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000\r
- EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000\r
- EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000\r
- EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-// BugBug: Autogen does not allow this to be included currently\r
-//#include <EdkModulePkg/Include/EdkDxe.h>\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED char *mHobResourceType[] = {\r
- "Memory ",\r
- "MMIO ",\r
- "IO ",\r
- "Firmware ",\r
- "MMIO Port ",\r
- "Reserved ",\r
- "IO Reserved",\r
- "Illegal "\r
-};\r
-\r
-\r
-/**\r
- Dump out the HOBs in the system. HOBs are defined in the PI specification\r
- and they are used to hand off information from PEI to DXE.\r
-\r
- Argv[0] - "hob"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblHobCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN CurrentRow;\r
- EFI_PEI_HOB_POINTERS Hob;\r
- EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation;\r
- UINTN Index;\r
-\r
- CurrentRow = 0;\r
- for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
- if (Hob.Header->HobType == EFI_HOB_TYPE_HANDOFF) {\r
- AsciiPrint ("PHIT HOB Ver %x Boot Mode %02x Top %lx Bottom %lx\n",\r
- Hob.HandoffInformationTable->Version,\r
- Hob.HandoffInformationTable->BootMode,\r
- Hob.HandoffInformationTable->EfiMemoryTop,\r
- Hob.HandoffInformationTable->EfiMemoryBottom\r
- );\r
-\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- AsciiPrint (" Free Top %lx Free Bottom %lx End Of HOB %lx\n",\r
- Hob.HandoffInformationTable->EfiFreeMemoryTop,\r
- Hob.HandoffInformationTable->EfiFreeMemoryBottom,\r
- Hob.HandoffInformationTable->EfiEndOfHobList\r
- );\r
-\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
- // mod(%) on array index is just to prevent buffer overrun\r
- AsciiPrint ("Mem Alloc HOB %a %g %08lx:%lx\n",\r
- (Hob.MemoryAllocation->AllocDescriptor.MemoryType < EfiMaxMemoryType) ? gMemMapType[Hob.MemoryAllocation->AllocDescriptor.MemoryType] : "ILLEGAL TYPE",\r
- &Hob.MemoryAllocation->AllocDescriptor.Name,\r
- Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress,\r
- Hob.MemoryAllocation->AllocDescriptor.MemoryLength\r
- );\r
- if (CompareGuid (&gEfiHobMemoryAllocModuleGuid, &Hob.MemoryAllocation->AllocDescriptor.Name)) {\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- return EFI_SUCCESS;\r
- }\r
- AsciiPrint (" Module Name %g EntryPoint %lx\n", &Hob.MemoryAllocationModule->ModuleName, Hob.MemoryAllocationModule->EntryPoint);\r
- }\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r
- AsciiPrint ("Resource HOB %a %g %08lx:%lx\n Attributes: %08x\n",\r
- (Hob.ResourceDescriptor->ResourceType < EFI_RESOURCE_MAX_MEMORY_TYPE) ? mHobResourceType[Hob.ResourceDescriptor->ResourceType] : mHobResourceType[EFI_RESOURCE_MAX_MEMORY_TYPE],\r
- &Hob.ResourceDescriptor->Owner,\r
- Hob.ResourceDescriptor->PhysicalStart,\r
- Hob.ResourceDescriptor->ResourceLength,\r
- Hob.ResourceDescriptor->ResourceAttribute\r
- );\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- return EFI_SUCCESS;\r
- }\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {\r
- AsciiPrint ("GUID HOB %g\n", &Hob.Guid->Name);\r
- if (CompareGuid (&gEfiMemoryTypeInformationGuid, &Hob.Guid->Name)) {\r
- EfiMemoryTypeInformation = GET_GUID_HOB_DATA (Hob.Guid);\r
- for (Index = 0; Index < (GET_GUID_HOB_DATA_SIZE (Hob.Guid)/sizeof (EFI_MEMORY_TYPE_INFORMATION)); Index++, EfiMemoryTypeInformation++) {\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- return EFI_SUCCESS;\r
- }\r
- AsciiPrint (" %a 0x%08x\n",\r
- (EfiMemoryTypeInformation->Type < EfiMaxMemoryType) ? gMemMapType[EfiMemoryTypeInformation->Type] : "END ",\r
- EfiMemoryTypeInformation->NumberOfPages\r
- );\r
- }\r
- }\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_FV) {\r
- AsciiPrint ("FV HOB %08lx:%08lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->Length);\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_CPU) {\r
- AsciiPrint ("CPU HOB: Mem %x IO %x\n", Hob.Cpu->SizeOfMemorySpace, Hob.Cpu->SizeOfIoSpace);\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_POOL) {\r
- AsciiPrint ("Mem Pool HOB:\n");\r
-/* Not in PI\r
- } else if (Hob.Header->HobType == EFI_HOB_TYPE_CV) {\r
- AsciiPrint ("CV HOB: %08lx:%08lx\n", Hob.CapsuleVolume->BaseAddress, Hob.CapsuleVolume->Length);\r
- */\r
- }\r
-\r
- if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {\r
- break;\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHobTemplate[] =\r
-{\r
- {\r
- "hob",\r
- "; dump HOBs",\r
- NULL,\r
- EblHobCmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializeHobCmd (\r
- VOID\r
- )\r
-{\r
- if (FeaturePcdGet (PcdEmbeddedHobCmd)) {\r
- EblAddCommands (mCmdHobTemplate, sizeof (mCmdHobTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Basic command line parser for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name: HwDebug.c\r
-\r
- Commands useful for debugging hardware.\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-/**\r
- Dump memory\r
-\r
- Argv[0] - "md"[.#] # is optional width 1, 2, 4, or 8. Default 1\r
- Argv[1] - Hex Address to dump\r
- Argv[2] - Number of hex bytes to dump (0x20 is default)\r
-\r
- md.4 0x123445678 50 ; Dump 0x50 4 byte quantities starting at 0x123445678\r
- md 0x123445678 40 ; Dump 0x40 1 byte quantities starting at 0x123445678\r
- md 0x123445678 ; Dump 0x20 1 byte quantities starting at 0x123445678\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblMdCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- STATIC UINT8 *Address = NULL;\r
- STATIC UINTN Length = 0x20;\r
- STATIC UINTN Width;\r
-\r
- Width = WidthFromCommandName (Argv[0], 1);\r
-\r
- switch (Argc) {\r
- case 3:\r
- Length = AsciiStrHexToUintn(Argv[2]);\r
- case 2:\r
- Address = (UINT8 *)AsciiStrHexToUintn (Argv[1]);\r
- default:\r
- break;\r
- }\r
-\r
- OutputData (Address, Length, Width, (UINTN)Address);\r
-\r
- Address += Length;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Fill Memory with data\r
-\r
- Argv[0] - "mfill"[.#] # is optional width 1, 2, 4, or 8. Default 4\r
- Argv[1] - Hex Address to fill\r
- Argv[2] - Data to write (0x00 is default)\r
- Argv[3] - Number of units to dump.\r
-\r
- mf.1 0x123445678 aa 100 ; Start at 0x123445678 and write aa (1 byte) to the next 100 bytes\r
- mf.4 0x123445678 aa 100 ; Start at 0x123445678 and write aa (4 byte) to the next 400 bytes\r
- mf 0x123445678 aa ; Start at 0x123445678 and write aa (4 byte) to the next 1 byte\r
- mf 0x123445678 ; Start at 0x123445678 and write 00 (4 byte) to the next 1 byte\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblMfillCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Address;\r
- UINTN EndAddress;\r
- UINT32 Data;\r
- UINTN Length;\r
- UINTN Width;\r
-\r
- if (Argc < 2) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Width = WidthFromCommandName (Argv[0], 4);\r
-\r
- Address = AsciiStrHexToUintn (Argv[1]);\r
- Data = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 0;\r
- Length = (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : 1;\r
-\r
- for (EndAddress = Address + (Length * Width); Address < EndAddress; Address += Width) {\r
- if (Width == 4) {\r
- MmioWrite32 (Address, Data);\r
- } else if (Width == 2) {\r
- MmioWrite16 (Address, (UINT16)Data);\r
- } else {\r
- MmioWrite8 (Address, (UINT8)Data);\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-//\r
-// Strings for PCI Class code [2]\r
-//\r
-CHAR8 *gPciDevClass[] = {\r
- "Old Device ",\r
- "Mass storage ",\r
- "Network ",\r
- "Display ",\r
- "Multimedia ",\r
- "Memory controller ",\r
- "Bridge device ",\r
- "simple communications ",\r
- "base system peripherals",\r
- "Input devices ",\r
- "Docking stations ",\r
- "Processors ",\r
- "serial bus ",\r
-};\r
-\r
-\r
-CHAR8 *gPciSerialClassCodes[] = {\r
- "Mass storage ",\r
- "Firewire ",\r
- "ACCESS bus ",\r
- "SSA ",\r
- "USB "\r
-};\r
-\r
-\r
-/**\r
- PCI Dump\r
-\r
- Argv[0] - "pci"\r
- Argv[1] - bus\r
- Argv[2] - dev\r
- Argv[3] - func\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblPciCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PCI_IO_PROTOCOL *Pci;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuffer;\r
- UINTN Seg;\r
- UINTN Bus;\r
- UINTN Dev;\r
- UINTN Func;\r
- UINTN BusArg;\r
- UINTN DevArg;\r
- UINTN FuncArg;\r
- UINTN Index;\r
- UINTN Count;\r
- PCI_TYPE_GENERIC PciHeader;\r
- PCI_TYPE_GENERIC *Header;\r
- PCI_BRIDGE_CONTROL_REGISTER *Bridge;\r
- PCI_DEVICE_HEADER_TYPE_REGION *Device;\r
- PCI_DEVICE_INDEPENDENT_REGION *Hdr;\r
- CHAR8 *Str;\r
- UINTN ThisBus;\r
-\r
-\r
- BusArg = (Argc > 1) ? AsciiStrDecimalToUintn (Argv[1]) : 0;\r
- DevArg = (Argc > 2) ? AsciiStrDecimalToUintn (Argv[2]) : 0;\r
- FuncArg = (Argc > 3) ? AsciiStrDecimalToUintn (Argv[3]) : 0;\r
-\r
- Header = &PciHeader;\r
-\r
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, NULL, &HandleCount, &HandleBuffer);\r
- if (EFI_ERROR (Status)) {\r
- AsciiPrint ("No PCI devices found in the system\n");\r
- return EFI_SUCCESS;\r
- }\r
-\r
- if (Argc == 1) {\r
- // Dump all PCI devices\r
- AsciiPrint ("BusDevFun VendorId DeviceId Device Class Sub-Class\n");\r
- AsciiPrint ("_____________________________________________________________");\r
- for (ThisBus = 0; ThisBus <= PCI_MAX_BUS; ThisBus++) {\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&Pci);\r
- if (!EFI_ERROR (Status)) {\r
- Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func);\r
- if (ThisBus != Bus) {\r
- continue;\r
- }\r
- AsciiPrint ("\n%03d.%02d.%02d", Bus, Dev, Func);\r
- Status = Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (PciHeader)/sizeof (UINT32), &PciHeader);\r
- if (!EFI_ERROR (Status)) {\r
- Hdr = &PciHeader.Bridge.Hdr;\r
-\r
- if (Hdr->ClassCode[2] < sizeof (gPciDevClass)/sizeof (VOID *)) {\r
- Str = gPciDevClass[Hdr->ClassCode[2]];\r
- if (Hdr->ClassCode[2] == PCI_CLASS_SERIAL) {\r
- if (Hdr->ClassCode[1] < sizeof (gPciSerialClassCodes)/sizeof (VOID *)) {\r
- // print out Firewire or USB inplace of Serial Bus controllers\r
- Str = gPciSerialClassCodes[Hdr->ClassCode[1]];\r
- }\r
- }\r
- } else {\r
- Str = "Unknown device ";\r
- }\r
- AsciiPrint (" 0x%04x 0x%04x %a 0x%02x", Hdr->VendorId, Hdr->DeviceId, Str, Hdr->ClassCode[1]);\r
- }\r
- if (Seg != 0) {\r
- // Only print Segment if it is non zero. If you only have one PCI segment it is\r
- // redundent to print it out\r
- AsciiPrint (" Seg:%d", Seg);\r
- }\r
- }\r
- }\r
- }\r
- AsciiPrint ("\n");\r
- } else {\r
- // Dump specific PCI device\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&Pci);\r
- if (!EFI_ERROR (Status)) {\r
- Pci->GetLocation (Pci, &Seg, &Bus, &Dev, &Func);\r
- if ((Bus == BusArg) && (Dev == DevArg) && (Func == FuncArg)) {\r
- // Only print Segment if it is non zero. If you only have one PCI segment it is\r
- // redundant to print it out\r
- if (Seg != 0) {\r
- AsciiPrint ("Seg:%d ", Seg);\r
- }\r
- AsciiPrint ("Bus:%d Dev:%d Func:%d ", Bus, Dev, Func);\r
-\r
- Status = Pci->Pci.Read (Pci, EfiPciIoWidthUint32, 0, sizeof (PciHeader)/sizeof (UINT32), Header);\r
- if (!EFI_ERROR (Status)) {\r
- Hdr = &PciHeader.Bridge.Hdr;\r
- if (IS_PCI_BRIDGE (&PciHeader.Bridge)) {\r
- Bridge = &PciHeader.Bridge.Bridge;\r
- AsciiPrint (\r
- "PCI Bridge. Bus Primary %d Secondary %d Subordinate %d\n",\r
- Bridge->PrimaryBus, Bridge->SecondaryBus, Bridge->SubordinateBus\r
- );\r
- AsciiPrint (" Bar 0: 0x%08x Bar 1: 0x%08x\n", Bridge->Bar[0], Bridge->Bar[1]);\r
- } else {\r
- Device = &PciHeader.Device.Device;\r
- AsciiPrint (\r
- "VendorId: 0x%04x DeviceId: 0x%04x SubSusVendorId: 0x%04x SubSysDeviceId: 0x%04x\n",\r
- Hdr->VendorId, Hdr->DeviceId, Device->SubsystemVendorID, Device->SubsystemID\r
- );\r
- AsciiPrint (" Class Code: 0x%02x 0x%02x 0x%02x\n", Hdr->ClassCode[2], Hdr->ClassCode[1], Hdr->ClassCode[0]);\r
- for (Count = 0; Count < 6; Count++) {\r
- AsciiPrint (" Bar %d: 0x%08x\n", Count, Device->Bar[Count]);\r
- }\r
- }\r
- }\r
-\r
- AsciiPrint ("\n");\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
- FreePool (HandleBuffer);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdPciDebugTemplate[] = {\r
- {\r
- "pci",\r
- " [bus] [dev] [func]; Dump PCI",\r
- NULL,\r
- EblPciCmd\r
- }\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwDebugTemplate[] =\r
-{\r
- {\r
- "md",\r
- "[.{1|2|4}] [Addr] [Len] [1|2|4]; Memory Dump from Addr Len bytes",\r
- NULL,\r
- EblMdCmd\r
- },\r
- {\r
- "mfill",\r
- "[.{1|2|4}] Addr Len [data]; Memory Fill Addr Len*(1|2|4) bytes of data(0)",\r
- NULL,\r
- EblMfillCmd\r
- },\r
-};\r
-\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializemdHwDebugCmds (\r
- VOID\r
- )\r
-{\r
- if (FeaturePcdGet (PcdEmbeddedHwDebugCmd)) {\r
- EblAddCommands (mCmdHwDebugTemplate, sizeof (mCmdHwDebugTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
- if (FeaturePcdGet (PcdEmbeddedPciDebugCmd)) {\r
- EblAddCommands (mCmdPciDebugTemplate, sizeof (mCmdPciDebugTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Hardware IO based debug commands\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Commands useful for debugging hardware. IO commands separated out as not all\r
- processor architectures support the IO command.\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-\r
-/**\r
- Read from IO space\r
-\r
- Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1\r
- Argv[1] - Hex IO address\r
-\r
- ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8\r
- ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblIoReadCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Width;\r
- UINTN Port;\r
- UINTN Data;\r
-\r
- if (Argc < 2) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Port = AsciiStrHexToUintn (Argv[1]);\r
- Width = WidthFromCommandName (Argv[0], 1);\r
-\r
- if (Width == 1) {\r
- Data = IoRead8 (Port);\r
- } else if (Width == 2) {\r
- Data = IoRead16 (Port);\r
- } else if (Width == 4) {\r
- Data = IoRead32 (Port);\r
- } else {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- AsciiPrint ("0x%04x = 0x%x", Port, Data);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Write to IO space\r
-\r
- Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1\r
- Argv[1] - Hex IO address\r
- Argv[2] - Hex data to write\r
-\r
- iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8\r
- iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblIoWriteCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Width;\r
- UINTN Port;\r
- UINTN Data;\r
-\r
- if (Argc < 3) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Port = AsciiStrHexToUintn (Argv[1]);\r
- Data = AsciiStrHexToUintn (Argv[2]);\r
- Width = WidthFromCommandName (Argv[0], 1);\r
-\r
- if (Width == 1) {\r
- IoWrite8 (Port, (UINT8)Data);\r
- } else if (Width == 2) {\r
- IoWrite16 (Port, (UINT16)Data);\r
- } else if (Width == 4) {\r
- IoWrite32 (Port, (UINT32)Data);\r
- } else {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate[] =\r
-{\r
- {\r
- "ioread",\r
- "[.{1|2|4}] Port ; IO read of width byte(s) from Port",\r
- NULL,\r
- EblIoReadCmd\r
- },\r
- {\r
- "iowrite",\r
- "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",\r
- NULL,\r
- EblIoWriteCmd\r
- }\r
-};\r
-\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializemdHwIoDebugCmds (\r
- VOID\r
- )\r
-{\r
- if (FeaturePcdGet (PcdEmbeddedIoEnable)) {\r
- EblAddCommands (mCmdHwIoDebugTemplate, sizeof (mCmdHwIoDebugTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Basic command line parser for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-// Globals for command history processing\r
-INTN mCmdHistoryEnd = -1;\r
-INTN mCmdHistoryStart = -1;\r
-INTN mCmdHistoryCurrent = -1;\r
-CHAR8 mCmdHistory[MAX_CMD_HISTORY][MAX_CMD_LINE];\r
-CHAR8 *mCmdBlank = "";\r
-\r
-// Globals to remember current screen geometry\r
-UINTN gScreenColumns;\r
-UINTN gScreenRows;\r
-\r
-// Global to turn on/off breaking commands with prompts before they scroll the screen\r
-BOOLEAN gPageBreak = TRUE;\r
-\r
-VOID\r
-RingBufferIncrement (\r
- IN INTN *Value\r
- )\r
-{\r
- *Value = *Value + 1;\r
-\r
- if (*Value >= MAX_CMD_HISTORY) {\r
- *Value = 0;\r
- }\r
-}\r
-\r
-VOID\r
-RingBufferDecrement (\r
- IN INTN *Value\r
- )\r
-{\r
- *Value = *Value - 1;\r
-\r
- if (*Value < 0) {\r
- *Value = MAX_CMD_HISTORY - 1;\r
- }\r
-}\r
-\r
-/**\r
- Save this command in the circular history buffer. Older commands are\r
- overwritten with newer commands.\r
-\r
- @param Cmd Command line to archive the history of.\r
-\r
- @return None\r
-\r
-**/\r
-VOID\r
-SetCmdHistory (\r
- IN CHAR8 *Cmd\r
- )\r
-{\r
- // Don't bother adding empty commands to the list\r
- if (AsciiStrLen(Cmd) != 0) {\r
-\r
- // First entry\r
- if (mCmdHistoryStart == -1) {\r
- mCmdHistoryStart = 0;\r
- mCmdHistoryEnd = 0;\r
- } else {\r
- // Record the new command at the next index\r
- RingBufferIncrement(&mCmdHistoryStart);\r
-\r
- // If the next index runs into the end index, shuffle end back by one\r
- if (mCmdHistoryStart == mCmdHistoryEnd) {\r
- RingBufferIncrement(&mCmdHistoryEnd);\r
- }\r
- }\r
-\r
- // Copy the new command line into the ring buffer\r
- AsciiStrnCpyS (&mCmdHistory[mCmdHistoryStart][0], MAX_CMD_LINE, Cmd, MAX_CMD_LINE);\r
- }\r
-\r
- // Reset the command history for the next up arrow press\r
- mCmdHistoryCurrent = mCmdHistoryStart;\r
-}\r
-\r
-\r
-/**\r
- Retreave data from the Command History buffer. Direction maps into up arrow\r
- an down arrow on the command line\r
-\r
- @param Direction Command forward or back\r
-\r
- @return The Command history based on the Direction\r
-\r
-**/\r
-CHAR8 *\r
-GetCmdHistory (\r
- IN UINT16 Direction\r
- )\r
-{\r
- CHAR8 *HistoricalCommand = NULL;\r
-\r
- // No history yet?\r
- if (mCmdHistoryCurrent == -1) {\r
- HistoricalCommand = mCmdBlank;\r
- goto Exit;\r
- }\r
-\r
- if (Direction == SCAN_UP) {\r
- HistoricalCommand = &mCmdHistory[mCmdHistoryCurrent][0];\r
-\r
- // if we just echoed the last command, hang out there, don't wrap around\r
- if (mCmdHistoryCurrent == mCmdHistoryEnd) {\r
- goto Exit;\r
- }\r
-\r
- // otherwise, back up by one\r
- RingBufferDecrement(&mCmdHistoryCurrent);\r
-\r
- } else if (Direction == SCAN_DOWN) {\r
-\r
- // if we last echoed the start command, put a blank prompt out\r
- if (mCmdHistoryCurrent == mCmdHistoryStart) {\r
- HistoricalCommand = mCmdBlank;\r
- goto Exit;\r
- }\r
-\r
- // otherwise increment the current pointer and return that command\r
- RingBufferIncrement(&mCmdHistoryCurrent);\r
- RingBufferIncrement(&mCmdHistoryCurrent);\r
-\r
- HistoricalCommand = &mCmdHistory[mCmdHistoryCurrent][0];\r
- RingBufferDecrement(&mCmdHistoryCurrent);\r
- }\r
-\r
-Exit:\r
- return HistoricalCommand;\r
-}\r
-\r
-\r
-/**\r
- Parse the CmdLine and break it up into Argc (arg count) and Argv (array of\r
- pointers to each argument). The Cmd buffer is altered and separators are\r
- converted to string terminators. This allows Argv to point into CmdLine.\r
- A CmdLine can support multiple commands. The next command in the command line\r
- is returned if it exists.\r
-\r
- @param CmdLine String to parse for a set of commands\r
- @param Argc Returns the number of arguments in the CmdLine current command\r
- @param Argv Argc pointers to each string in CmdLine\r
-\r
- @return Next Command in the command line or NULL if non exists\r
-**/\r
-CHAR8 *\r
-ParseArguments (\r
- IN CHAR8 *CmdLine,\r
- OUT UINTN *Argc,\r
- OUT CHAR8 **Argv\r
- )\r
-{\r
- UINTN Arg;\r
- CHAR8 *Char;\r
- BOOLEAN LookingForArg;\r
- BOOLEAN InQuote;\r
-\r
- *Argc = 0;\r
- if (AsciiStrLen (CmdLine) == 0) {\r
- return NULL;\r
- }\r
-\r
- // Walk a single command line. A CMD_SEPARATOR allows multiple commands on a single line\r
- InQuote = FALSE;\r
- LookingForArg = TRUE;\r
- for (Char = CmdLine, Arg = 0; *Char != '\0'; Char++) {\r
- if (!InQuote && *Char == CMD_SEPARATOR) {\r
- break;\r
- }\r
-\r
- // Perform any text conversion here\r
- if (*Char == '\t') {\r
- // TAB to space\r
- *Char = ' ';\r
- }\r
-\r
- if (LookingForArg) {\r
- // Look for the beginning of an Argv[] entry\r
- if (*Char == '"') {\r
- Argv[Arg++] = ++Char;\r
- LookingForArg = FALSE;\r
- InQuote = TRUE;\r
- } else if (*Char != ' ') {\r
- Argv[Arg++] = Char;\r
- LookingForArg = FALSE;\r
- }\r
- } else {\r
- // Looking for the terminator of an Argv[] entry\r
- if (!InQuote && (*Char == ' ')) {\r
- *Char = '\0';\r
- LookingForArg = TRUE;\r
- } else if (!InQuote && (*Char == '"') && (*(Char-1) != '\\')) {\r
- InQuote = TRUE;\r
- } else if (InQuote && (*Char == '"') && (*(Char-1) != '\\')) {\r
- *Char = '\0';\r
- InQuote = FALSE;\r
- }\r
- }\r
- }\r
-\r
- *Argc = Arg;\r
-\r
- if (*Char == CMD_SEPARATOR) {\r
- // Replace the command delimiter with null and return pointer to next command line\r
- *Char = '\0';\r
- return ++Char;\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-\r
-/**\r
- Return a keypress or optionally timeout if a timeout value was passed in.\r
- An optional callback function is called every second when waiting for a\r
- timeout.\r
-\r
- @param Key EFI Key information returned\r
- @param TimeoutInSec Number of seconds to wait to timeout\r
- @param CallBack Callback called every second during the timeout wait\r
-\r
- @return EFI_SUCCESS Key was returned\r
- @return EFI_TIMEOUT If the TimoutInSec expired\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCharKey (\r
- IN OUT EFI_INPUT_KEY *Key,\r
- IN UINTN TimeoutInSec,\r
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN WaitCount;\r
- UINTN WaitIndex;\r
- EFI_EVENT WaitList[2];\r
-\r
- WaitCount = 1;\r
- WaitList[0] = gST->ConIn->WaitForKey;\r
- if (TimeoutInSec != 0) {\r
- // Create a time event for 1 sec duration if we have a timeout\r
- gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &WaitList[1]);\r
- gBS->SetTimer (WaitList[1], TimerPeriodic, EFI_SET_TIMER_TO_SECOND);\r
- WaitCount++;\r
- }\r
-\r
- for (;;) {\r
- Status = gBS->WaitForEvent (WaitCount, WaitList, &WaitIndex);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- switch (WaitIndex) {\r
- case 0:\r
- // Key event signaled\r
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, Key);\r
- if (!EFI_ERROR (Status)) {\r
- if (WaitCount == 2) {\r
- gBS->CloseEvent (WaitList[1]);\r
- }\r
- return EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case 1:\r
- // Periodic 1 sec timer signaled\r
- TimeoutInSec--;\r
- if (CallBack != NULL) {\r
- // Call the users callback function if registered\r
- CallBack (TimeoutInSec);\r
- }\r
- if (TimeoutInSec == 0) {\r
- gBS->CloseEvent (WaitList[1]);\r
- return EFI_TIMEOUT;\r
- }\r
- break;\r
- default:\r
- ASSERT (FALSE);\r
- }\r
- }\r
-}\r
-\r
-\r
-/**\r
- This routine is used prevent command output data from scrolling off the end\r
- of the screen. The global gPageBreak is used to turn on or off this feature.\r
- If the CurrentRow is near the end of the screen pause and print out a prompt\r
- If the use hits Q to quit return TRUE else for any other key return FALSE.\r
- PrefixNewline is used to figure out if a newline is needed before the prompt\r
- string. This depends on the last print done before calling this function.\r
- CurrentRow is updated by one on a call or set back to zero if a prompt is\r
- needed.\r
-\r
- @param CurrentRow Used to figure out if its the end of the page and updated\r
- @param PrefixNewline Did previous print issue a newline\r
-\r
- @return TRUE if Q was hit to quit, FALSE in all other cases.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-EblAnyKeyToContinueQtoQuit (\r
- IN UINTN *CurrentRow,\r
- IN BOOLEAN PrefixNewline\r
- )\r
-{\r
- EFI_INPUT_KEY InputKey;\r
-\r
- if (!gPageBreak) {\r
- // global disable for this feature\r
- return FALSE;\r
- }\r
-\r
- if (*CurrentRow >= (gScreenRows - 2)) {\r
- if (PrefixNewline) {\r
- AsciiPrint ("\n");\r
- }\r
- AsciiPrint ("Any key to continue (Q to quit): ");\r
- EblGetCharKey (&InputKey, 0, NULL);\r
- AsciiPrint ("\n");\r
-\r
- // Time to promt to stop the screen. We have to leave space for the prompt string\r
- *CurrentRow = 0;\r
- if (InputKey.UnicodeChar == 'Q' || InputKey.UnicodeChar == 'q') {\r
- return TRUE;\r
- }\r
- } else {\r
- *CurrentRow += 1;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
- Set the text color of the EFI Console. If a zero is passed in reset to\r
- default text/background color.\r
-\r
- @param Attribute For text and background color\r
-\r
-**/\r
-VOID\r
-EblSetTextColor (\r
- UINTN Attribute\r
- )\r
-{\r
- if (Attribute == 0) {\r
- // Set the text color back to default\r
- Attribute = (UINTN)PcdGet32 (PcdEmbeddedDefaultTextColor);\r
- }\r
-\r
- gST->ConOut->SetAttribute (gST->ConOut, Attribute);\r
-}\r
-\r
-\r
-/**\r
- Collect the keyboard input for a cmd line. Carriage Return, New Line, or ESC\r
- terminates the command line. You can edit the command line via left arrow,\r
- delete and backspace and they all back up and erase the command line.\r
- No edit of command line is possible without deletion at this time!\r
- The up arrow and down arrow fill Cmd with information from the history\r
- buffer.\r
-\r
- @param Cmd Command line to return\r
- @param CmdMaxSize Maximum size of Cmd\r
-\r
- @return The Status of EblGetCharKey()\r
-\r
-**/\r
-EFI_STATUS\r
-GetCmd (\r
- IN OUT CHAR8 *Cmd,\r
- IN UINTN CmdMaxSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- UINTN Index2;\r
- CHAR8 Char;\r
- CHAR8 *History;\r
- EFI_INPUT_KEY Key;\r
-\r
- for (Index = 0; Index < CmdMaxSize - 1;) {\r
- Status = EblGetCharKey (&Key, 0, NULL);\r
- if (EFI_ERROR (Status)) {\r
- Cmd[Index] = '\0';\r
- AsciiPrint ("\n");\r
- return Status;\r
- }\r
-\r
- Char = (CHAR8)Key.UnicodeChar;\r
- if ((Char == '\n') || (Char == '\r') || (Char == 0x7f)) {\r
- Cmd[Index] = '\0';\r
- if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {\r
- AsciiPrint ("\n\r");\r
- }\r
- return EFI_SUCCESS;\r
- } else if ((Char == '\b') || (Key.ScanCode == SCAN_LEFT) || (Key.ScanCode == SCAN_DELETE)){\r
- if (Index != 0) {\r
- Index--;\r
- //\r
- // Update the display\r
- //\r
- AsciiPrint ("\b \b");\r
- }\r
- } else if ((Key.ScanCode == SCAN_UP) || Key.ScanCode == SCAN_DOWN) {\r
- History = GetCmdHistory (Key.ScanCode);\r
- //\r
- // Clear display line\r
- //\r
- for (Index2 = 0; Index2 < Index; Index2++) {\r
- AsciiPrint ("\b \b");\r
- }\r
- AsciiPrint (History);\r
- Index = AsciiStrLen (History);\r
- AsciiStrnCpyS (Cmd, CmdMaxSize, History, CmdMaxSize);\r
- } else {\r
- Cmd[Index++] = Char;\r
- if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {\r
- AsciiPrint ("%c", Char);\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Print the boot up banner for the EBL.\r
-**/\r
-VOID\r
-EblPrintStartupBanner (\r
- VOID\r
- )\r
-{\r
- AsciiPrint ("Embedded Boot Loader (");\r
- EblSetTextColor (EFI_YELLOW);\r
- AsciiPrint ("EBL");\r
- EblSetTextColor (0);\r
- AsciiPrint (") prototype. Built at %a on %a\n",__TIME__, __DATE__);\r
- AsciiPrint ("THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN 'AS IS' BASIS,\nWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n");\r
- AsciiPrint ("Please send feedback to edk2-devel@lists.sourceforge.net\n");\r
-}\r
-\r
-\r
-/**\r
- Send null requests to all removable media block IO devices so the a media add/remove/change\r
- can be detected in real before we execute a command.\r
-\r
- This is mainly due to the fact that the FAT driver does not do this today so you can get stale\r
- dir commands after an SD Card has been removed.\r
-**/\r
-VOID\r
-EblProbeRemovableMedia (\r
- VOID\r
- )\r
-{\r
- UINTN Index;\r
- UINTN Max;\r
- EFI_OPEN_FILE *File;\r
-\r
- //\r
- // Probe for media insertion/removal in removable media devices\r
- //\r
- Max = EfiGetDeviceCounts (EfiOpenBlockIo);\r
- if (Max != 0) {\r
- for (Index = 0; Index < Max; Index++) {\r
- File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);\r
- if (File != NULL) {\r
- if (File->FsBlockIoMedia->RemovableMedia) {\r
- // Probe to see if media is present (or not) or media changed\r
- // this causes the ReinstallProtocolInterface() to fire in the\r
- // block io driver to update the system about media change events\r
- File->FsBlockIo->ReadBlocks (File->FsBlockIo, File->FsBlockIo->Media->MediaId, (EFI_LBA)0, 0, NULL);\r
- }\r
- EfiClose (File);\r
- }\r
- }\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
- Print the prompt for the EBL.\r
-**/\r
-VOID\r
-EblPrompt (\r
- VOID\r
- )\r
-{\r
- EblSetTextColor (EFI_YELLOW);\r
- AsciiPrint ("%a %a",(CHAR8 *)PcdGetPtr (PcdEmbeddedPrompt), EfiGetCwd ());\r
- EblSetTextColor (0);\r
- AsciiPrint ("%a", ">");\r
-}\r
-\r
-\r
-\r
-/**\r
- Parse a command line and execute the commands. The ; separator allows\r
- multiple commands for each command line. Stop processing if one of the\r
- commands returns an error.\r
-\r
- @param CmdLine Command Line to process.\r
- @param MaxCmdLineSize MaxSize of the Command line\r
-\r
- @return EFI status of the Command\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessCmdLine (\r
- IN CHAR8 *CmdLine,\r
- IN UINTN MaxCmdLineSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EBL_COMMAND_TABLE *Cmd;\r
- CHAR8 *Ptr;\r
- UINTN Argc;\r
- CHAR8 *Argv[MAX_ARGS];\r
-\r
- // Parse the command line. The loop processes commands separated by ;\r
- for (Ptr = CmdLine, Status = EFI_SUCCESS; Ptr != NULL;) {\r
- Ptr = ParseArguments (Ptr, &Argc, Argv);\r
- if (Argc != 0) {\r
- Cmd = EblGetCommand (Argv[0]);\r
- if (Cmd != NULL) {\r
- // Execute the Command!\r
- Status = Cmd->Command (Argc, Argv);\r
- if (Status == EFI_ABORTED) {\r
- // exit command so lets exit\r
- break;\r
- } else if (Status == EFI_TIMEOUT) {\r
- // pause command got input so don't process any more cmd on this cmd line\r
- break;\r
- } else if (EFI_ERROR (Status)) {\r
- AsciiPrint ("%a returned %r error\n", Cmd->Name, Status);\r
- // if any command fails stop processing CmdLine\r
- break;\r
- }\r
- } else {\r
- AsciiPrint ("The command '%a' is not supported.\n", Argv[0]);\r
- }\r
- }\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
- Embedded Boot Loader (EBL) - A simple EFI command line application for embedded\r
- devices. PcdEmbeddedAutomaticBootCommand is a complied in command line that\r
- gets executed automatically. The ; separator allows multiple commands\r
- for each command line.\r
-\r
- @param ImageHandle EFI ImageHandle for this application.\r
- @param SystemTable EFI system table\r
-\r
- @return EFI status of the application\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EdkBootLoaderEntry (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- CHAR8 CmdLine[MAX_CMD_LINE];\r
- CHAR16 *CommandLineVariable = NULL;\r
- CHAR16 *CommandLineVariableName = L"default-cmdline";\r
- UINTN CommandLineVariableSize = 0;\r
- EFI_GUID VendorGuid;\r
-\r
- // Initialize tables of commands\r
- EblInitializeCmdTable ();\r
- EblInitializeDeviceCmd ();\r
- EblInitializemdHwDebugCmds ();\r
- EblInitializemdHwIoDebugCmds ();\r
- EblInitializeDirCmd ();\r
- EblInitializeHobCmd ();\r
- EblInitializeScriptCmd ();\r
- EblInitializeExternalCmd ();\r
- EblInitializeNetworkCmd();\r
- EblInitializeVariableCmds ();\r
-\r
- if (gST->ConOut == NULL) {\r
- DEBUG((EFI_D_ERROR,"Error: No Console Output\n"));\r
- return EFI_NOT_READY;\r
- }\r
-\r
- // Disable the 5 minute EFI watchdog time so we don't get automatically reset\r
- gBS->SetWatchdogTimer (0, 0, 0, NULL);\r
-\r
- if (FeaturePcdGet (PcdEmbeddedMacBoot)) {\r
- // A MAC will boot in graphics mode, so turn it back to text here\r
- // This protocol was removed from edk2. It is only an edk thing. We need to make our own copy.\r
- // DisableQuietBoot ();\r
-\r
- // Enable the biggest output screen size possible\r
- gST->ConOut->SetMode (gST->ConOut, (UINTN)gST->ConOut->Mode->MaxMode - 1);\r
-\r
- }\r
-\r
- // Save current screen mode\r
- gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &gScreenColumns, &gScreenRows);\r
-\r
- EblPrintStartupBanner ();\r
-\r
- // Parse command line and handle commands separated by ;\r
- // The loop prints the prompt gets user input and saves history\r
-\r
- // Look for a variable with a default command line, otherwise use the Pcd\r
- ZeroMem(&VendorGuid, sizeof(EFI_GUID));\r
-\r
- Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- CommandLineVariable = AllocatePool(CommandLineVariableSize);\r
-\r
- Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);\r
- if (!EFI_ERROR(Status)) {\r
- UnicodeStrToAsciiStrS (CommandLineVariable, CmdLine, MAX_CMD_LINE);\r
- }\r
-\r
- FreePool(CommandLineVariable);\r
- }\r
-\r
- if (EFI_ERROR(Status)) {\r
- AsciiStrCpyS (CmdLine, MAX_CMD_LINE, (CHAR8 *)PcdGetPtr (PcdEmbeddedAutomaticBootCommand));\r
- }\r
-\r
- for (;;) {\r
- Status = ProcessCmdLine (CmdLine, MAX_CMD_LINE);\r
- if (Status == EFI_ABORTED) {\r
- // if a command returns EFI_ABORTED then exit the EBL\r
- EblShutdownExternalCmdTable ();\r
- return EFI_SUCCESS;\r
- }\r
-\r
- // get the command line from the user\r
- EblPrompt ();\r
- GetCmd (CmdLine, MAX_CMD_LINE);\r
- SetCmdHistory (CmdLine);\r
-\r
- if (FeaturePcdGet (PcdEmbeddedProbeRemovable)) {\r
- // Probe removable media devices to see if media has been inserted or removed.\r
- EblProbeRemovableMedia ();\r
- }\r
- }\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- EBL commands for Network Devices\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-EFI_STATUS\r
-ParseIp (\r
- IN CHAR8 *String,\r
- OUT EFI_IP_ADDRESS *Address\r
- )\r
-{\r
- Address->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (String);\r
- String = AsciiStrStr(String, ".") + 1;\r
- Address->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (String);\r
- String = AsciiStrStr(String, ".") + 1;\r
- Address->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (String);\r
- String = AsciiStrStr(String, ".") + 1;\r
- Address->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (String);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblIpCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status = EFI_INVALID_PARAMETER;\r
- EFI_MAC_ADDRESS Mac;\r
- EFI_IP_ADDRESS Ip;\r
-\r
- if (Argc == 1) {\r
- // Get current IP/MAC\r
-\r
- // Get current MAC address\r
- Status = EblGetCurrentMacAddress (&Mac);\r
- if (EFI_ERROR (Status)) {\r
- goto Exit;\r
- }\r
-\r
- 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]);\r
-\r
- // Get current IP address\r
- Status = EblGetCurrentIpAddress (&Ip);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("IP Address is not configured.\n");\r
- Status = EFI_SUCCESS;\r
- goto Exit;\r
- }\r
-\r
- AsciiPrint("IP Address: %d.%d.%d.%d\n", Ip.v4.Addr[0], Ip.v4.Addr[1],Ip.v4.Addr[2], Ip.v4.Addr[3]);\r
-\r
- } else if ((Argv[1][0] == 'r') && (Argc == 2)) {\r
- // Get new address via dhcp\r
- Status = EblPerformDHCP (TRUE);\r
- } else if ((Argv[1][0] == 's') && (Argc == 3)) {\r
- // Set static IP\r
- Status = ParseIp (Argv[2], &Ip);\r
- if (EFI_ERROR (Status)) {\r
- goto Exit;\r
- }\r
-\r
- Status = EblSetStationIp (&Ip, NULL);\r
- }\r
-\r
-Exit:\r
- return Status;\r
-}\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdNetworkTemplate[] =\r
-{\r
- {\r
- "ip",\r
- " ; print current ip address\n\r [r]; request DHCP address\n\r [s] ipaddr; set static IP address",\r
- NULL,\r
- EblIpCmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializeNetworkCmd (\r
- VOID\r
- )\r
-{\r
- EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- Script command allows the execution of commands from a text file\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name: EfiDevice.c\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-\r
-/**\r
- Execute the passed in file like a series of commands. The ; can be used on\r
- a single line to indicate multiple commands per line. The Ascii text file\r
- can contain any number of lines. The following line termination forms are\r
- supported:\r
- LF : Unix, Mac OS X*, BeOS\r
- CR+LF: MS-DOS*, Microsoft Windows*\r
- CR : Commodore, Apple II, and really Mac OS\r
- LF+CR: for simplicity and completeness\r
-\r
- Argv[0] - "script"\r
- Argv[1] - Device Name:path for the file to load\r
-\r
- script fv1:\script.txt\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblScriptCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- VOID *Address;\r
- UINTN Size;\r
- CHAR8 *Ptr;\r
- CHAR8 *ScanPtr;\r
- UINTN CmdLineSize;\r
-\r
-\r
-\r
- if (Argc < 2) {\r
- // file name required\r
- return EFI_SUCCESS;\r
- }\r
-\r
- File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- AsciiPrint (" %a is not a valid path\n", Argv[1]);\r
- return EFI_SUCCESS;\r
- }\r
-\r
- Status = EfiReadAllocatePool (File, &Address, &Size);\r
- if (!EFI_ERROR (Status)) {\r
- // Loop through each line in the text file\r
- for (Ptr = (CHAR8 *)Address; (Ptr < (((CHAR8 *)Address) + Size)) && !EFI_ERROR (Status); Ptr += CmdLineSize) {\r
- for (CmdLineSize = 0, ScanPtr = Ptr; ; CmdLineSize++, ScanPtr++) {\r
- // look for the end of the line\r
- if ((*ScanPtr == EBL_CR) || (*ScanPtr == EBL_LF)) {\r
- // convert to NULL as this is what input routine would do\r
- *ScanPtr = 0;\r
- if ((*(ScanPtr + 1) == EBL_CR) || (*(ScanPtr + 1) == EBL_LF)) {\r
- // if its a set get the 2nd EOL char\r
- CmdLineSize++;\r
- *(ScanPtr + 1) = 0;\r
- }\r
- CmdLineSize++;\r
- break;\r
- }\r
-\r
- }\r
-\r
- Status = ProcessCmdLine (Ptr, CmdLineSize);\r
- }\r
-\r
- FreePool (Address);\r
- }\r
-\r
- EfiClose (File);\r
- return Status;\r
-}\r
-\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mScriptTemplate[] = {\r
- {\r
- "script",\r
- " device:path; load an ascii file and execute it like commands",\r
- NULL,\r
- EblScriptCmd\r
- }\r
-};\r
-\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-\r
-VOID\r
-EblInitializeScriptCmd (\r
- VOID\r
- )\r
-{\r
- if (FeaturePcdGet (PcdEmbeddedScriptCmd)) {\r
- EblAddCommands (mScriptTemplate, sizeof (mScriptTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- }\r
-}\r
-\r
+++ /dev/null
-/** @file\r
-*\r
-* Copyright (c) 2011, ARM Limited. All rights reserved.\r
-* (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-*\r
-* This program and the accompanying materials\r
-* are licensed and made available under the terms and conditions of the BSD License\r
-* which accompanies this distribution. The full text of the license may be found at\r
-* http://opensource.org/licenses/bsd-license.php\r
-*\r
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-*\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-#include <Guid/GlobalVariable.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status = EFI_INVALID_PARAMETER;\r
- UINTN Size;\r
- VOID* Value;\r
- CHAR8* AsciiVariableName = NULL;\r
- CHAR16* VariableName;\r
- UINTN VariableNameLen;\r
- UINT32 Index;\r
-\r
- if (Argc == 1) {\r
- AsciiPrint("Variable name is missing.\n");\r
- return Status;\r
- }\r
-\r
- for (Index = 1; Index < Argc; Index++) {\r
- if (Argv[Index][0] == '-') {\r
- AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);\r
- } else {\r
- AsciiVariableName = Argv[Index];\r
- }\r
- }\r
-\r
- if (AsciiVariableName == NULL) {\r
- AsciiPrint("Variable name is missing.\n");\r
- return Status;\r
- } else {\r
- VariableNameLen = AsciiStrLen (AsciiVariableName) + 1;\r
- VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));\r
- AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLen);\r
- }\r
-\r
- // Try to get the variable size.\r
- Value = NULL;\r
- Size = 0;\r
- Status = gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);\r
- if (Status == EFI_NOT_FOUND) {\r
- AsciiPrint("Variable name '%s' not found.\n",VariableName);\r
- } else if (Status == EFI_BUFFER_TOO_SMALL) {\r
- // Get the environment variable value\r
- Value = AllocatePool (Size);\r
- if (Value == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- Status = gRT->GetVariable ((CHAR16 *)VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);\r
- if (EFI_ERROR (Status)) {\r
- AsciiPrint("Error: '%r'\n",Status);\r
- } else {\r
- AsciiPrint("%a=%a\n",AsciiVariableName,Value);\r
- }\r
- FreePool(Value);\r
- } else {\r
- AsciiPrint("Error: '%r'\n",Status);\r
- }\r
-\r
- FreePool(VariableName);\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblSetCmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- EFI_STATUS Status = EFI_INVALID_PARAMETER;\r
- CHAR8* AsciiVariableSetting = NULL;\r
- CHAR8* AsciiVariableName;\r
- CHAR8* AsciiValue;\r
- UINT32 AsciiValueLength;\r
- CHAR16* VariableName;\r
- UINTN VariableNameLen;\r
- UINT32 Index;\r
- UINT32 EscapedQuotes = 0;\r
- BOOLEAN Volatile = FALSE;\r
-\r
- if (Argc == 1) {\r
- AsciiPrint("Variable name is missing.\n");\r
- return Status;\r
- }\r
-\r
- for (Index = 1; Index < Argc; Index++) {\r
- if (AsciiStrCmp(Argv[Index],"-v") == 0) {\r
- Volatile = 0;\r
- } else if (Argv[Index][0] == '-') {\r
- AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);\r
- } else {\r
- AsciiVariableSetting = Argv[Index];\r
- }\r
- }\r
-\r
- if (AsciiVariableSetting == NULL) {\r
- AsciiPrint("Variable name is missing.\n");\r
- return Status;\r
- }\r
-\r
- // Check if it is a valid variable setting\r
- AsciiValue = AsciiStrStr (AsciiVariableSetting,"=");\r
- if (AsciiValue == NULL) {\r
- //\r
- // There is no value. It means this variable will be deleted\r
- //\r
-\r
- // Convert VariableName into Unicode\r
- VariableNameLen = AsciiStrLen (AsciiVariableSetting) + 1;\r
- VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));\r
- AsciiStrToUnicodeStrS (AsciiVariableSetting, VariableName, VariableNameLen);\r
-\r
- Status = gRT->SetVariable (\r
- VariableName,\r
- &gEfiGlobalVariableGuid,\r
- ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- 0,\r
- NULL\r
- );\r
- if (!EFI_ERROR(Status)) {\r
- AsciiPrint("Variable '%s' deleted\n",VariableName);\r
- } else {\r
- AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n");\r
- }\r
- return Status;\r
- }\r
-\r
- AsciiValue[0] = '\0';\r
- AsciiVariableName = AsciiVariableSetting;\r
- AsciiValue++;\r
-\r
- // Clean AsciiValue from quote\r
- if (AsciiValue[0] == '"') {\r
- AsciiValue++;\r
- }\r
- AsciiValueLength = AsciiStrLen (AsciiValue);\r
- if ((AsciiValue[AsciiValueLength-2] != '\\') && (AsciiValue[AsciiValueLength-1] == '"')) {\r
- AsciiValue[AsciiValueLength-1] = '\0';\r
- }\r
-\r
- // Clean AsciiValue from escaped quotes\r
- for (Index = 0; Index < AsciiValueLength; Index++) {\r
- if ((Index > 0) && (AsciiValue[Index-1] == '\\') && (AsciiValue[Index] == '"')) {\r
- EscapedQuotes++;\r
- }\r
- AsciiValue[Index-EscapedQuotes] = AsciiValue[Index];\r
- }\r
- // Fill the end of the value with '\0'\r
- for (Index = 0; Index < EscapedQuotes; Index++) {\r
- AsciiValue[AsciiValueLength-1-Index] = '\0';\r
- }\r
-\r
- // Convert VariableName into Unicode\r
- VariableNameLen = AsciiStrLen (AsciiVariableName) + 1;\r
- VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));\r
- AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLen);\r
-\r
- Status = gRT->SetVariable (\r
- VariableName,\r
- &gEfiGlobalVariableGuid,\r
- ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- AsciiStrLen (AsciiValue)+1,\r
- AsciiValue\r
- );\r
- if (!EFI_ERROR(Status)) {\r
- AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdVariableTemplate[] =\r
-{\r
- {\r
- "get",\r
- " ; get UEFI variable\n\r [v]; verbose",\r
- NULL,\r
- EblGetCmd\r
- },\r
- {\r
- "set",\r
- " ; set UEFI variable\n\r [v]; create volatile variable",\r
- NULL,\r
- EblSetCmd\r
- }\r
-};\r
-\r
-/**\r
- Initialize the commands in this in this file\r
-**/\r
-VOID\r
-EblInitializeVariableCmds (\r
- VOID\r
- )\r
-{\r
- EblAddCommands (mCmdVariableTemplate, sizeof (mCmdVariableTemplate)/sizeof (EBL_COMMAND_TABLE));\r
-}\r
+++ /dev/null
-/** @file\r
- Glue code that contains the EFI entry point and converts it to an EBL\r
- ASCII Argc, Argv sytle entry point\r
-\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-#define CMD_SEPARATOR ';'\r
-#define MAX_ARGS 32\r
-\r
-EFI_STATUS\r
-EblMain (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- );\r
-\r
-\r
-///\r
-/// EdkExternCmdEntry() & ParseArguments() convert the standard EFI entry point\r
-/// into Argc, Argv form that calls EblMain().\r
-///\r
-\r
-\r
-/**\r
- Parse the CmdLine and break it up into Argc (arg count) and Argv (array of\r
- pointers to each argument). The Cmd buffer is altered and separators are\r
- converted to string terminators. This allows Argv to point into CmdLine.\r
- A CmdLine can support multiple commands. The next command in the command line\r
- is returned if it exists.\r
-\r
- @param CmdLine String to parse for a set of commands\r
- @param CmdLineSize Size of CmdLine in bytes\r
- @param Argc Returns the number of arguments in the CmdLine current command\r
- @param Argv Argc pointers to each string in CmdLine\r
-\r
- @return Next Command in the command line or NULL if non exists\r
-**/\r
-VOID\r
-ParseArguments (\r
- IN CHAR8 *CmdLine,\r
- IN UINTN CmdLineSize,\r
- OUT UINTN *Argc,\r
- OUT CHAR8 **Argv\r
- )\r
-{\r
- UINTN Arg;\r
- CHAR8 *Char;\r
- BOOLEAN LookingForArg;\r
- BOOLEAN InQuote;\r
- UINTN Index;\r
-\r
- *Argc = 0;\r
- if ((CmdLineSize == 0) || (AsciiStrLen (CmdLine) == 0)) {\r
- // basic error checking failed on the arguments\r
- return;\r
- }\r
-\r
- // Walk a single command line. A CMD_SEPARATOR allows multiple commands on a single line\r
- InQuote = FALSE;\r
- LookingForArg = TRUE;\r
- for (Char = CmdLine, Arg = 0, Index = 0; *Char != '\0' && *Char != CMD_SEPARATOR; Char++, Index++) {\r
- // Perform any text conversion here\r
- if (*Char == '\t') {\r
- // TAB to space\r
- *Char = ' ';\r
- }\r
-\r
- if (LookingForArg) {\r
- // Look for the beginning of an Argv[] entry\r
- if (*Char == '"') {\r
- Argv[Arg++] = ++Char;\r
- LookingForArg = FALSE;\r
- InQuote = TRUE;\r
- } else if (*Char != ' ') {\r
- Argv[Arg++] = Char;\r
- LookingForArg = FALSE;\r
- }\r
- } else {\r
- // Looking for the terminator of an Argv[] entry\r
- if ((InQuote && (*Char == '"')) || (!InQuote && (*Char == ' '))) {\r
- *Char = '\0';\r
- LookingForArg = TRUE;\r
- }\r
- }\r
-\r
- if ((Arg >= MAX_ARGS) || (Index > CmdLineSize)) {\r
- // Error check buffer and exit since it does not look valid\r
- break;\r
- }\r
- }\r
-\r
- *Argc = Arg;\r
-\r
- if (*Char == CMD_SEPARATOR) {\r
- // Replace the command delimiter with null\r
- *Char = '\0';\r
- }\r
-\r
- return;\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
- Embedded Boot Loader (EBL) - A simple EFI command line application for embedded\r
- devices. PcdEmbeddedAutomaticBootCommand is a complied in command line that\r
- gets executed automatically. The ; separator allows multiple commands\r
- for each command line.\r
-\r
- @param ImageHandle EFI ImageHandle for this application.\r
- @param SystemTable EFI system table\r
-\r
- @return EFI status of the application\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EdkExternCmdEntry (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
- UINTN Argc;\r
- CHAR8 *Argv[MAX_ARGS];\r
-\r
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);\r
- if (EFI_ERROR (Status)) {\r
- Argc = 0;\r
- } else {\r
- // Looks like valid commands were passed in.\r
- ParseArguments (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, &Argc, Argv);\r
- }\r
-\r
- return EblMain (Argc, Argv);\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- Example of an external EBL command. It's loaded via EBL start command.\r
- Argc and Argv are passed in via "" of the EBL command line.\r
-\r
- Start fs0:\EdkExternCmd.efi "Argv[0] Argv[1] 2"\r
-\r
- will launch this command with\r
- Argv[0] = "Argv[0]"\r
- Argv[1] = "Argv[2]"\r
- Argv[2] = "3"\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "Ebl.h"\r
-\r
-/**\r
- Entry point with Argc, Argv. Put your code here.\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EblMain (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- UINTN Index;\r
-\r
- AsciiPrint ("Hello World\n");\r
- for (Index = 0; Index < Argc; Index++) {\r
- AsciiPrint ("Argv[%d] = %a\n", Index, Argv[Index]);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
Include # Root include for the package\r
\r
[LibraryClasses.common]\r
- EfiFileLib|Include/Library/EfiFileLib.h\r
PrePiLib|Include/Library/PrePiLib.h\r
RealTimeClockLib|Include/Library/RealTimeClockLib.h\r
EfiResetSystemLib|Include/Library/EfiResetSystemLib.h\r
- EblCmdLib|Include/Library/EblCmdLib.h\r
- EblAddExternalCommandLib|Include/Library/EblAddExternalCommandLib.h\r
- EblNetworkLib|Include/Library/EblNetworkLib.h\r
GdbSerialLib|Include/Library/GdbSerialLib.h\r
DebugAgentTimerLib|Include/Library/DebugAgentTimerLib.h\r
NorFlashInfoLib|Include/Library/NorFlashInfoLib.h\r
gHardwareInterruptProtocolGuid = { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }\r
gHardwareInterrupt2ProtocolGuid = { 0x32898322, 0x2da1, 0x474a, { 0xba, 0xaa, 0xf3, 0xf7, 0xcf, 0x56, 0x94, 0x70 } }\r
gEfiDebugSupportPeriodicCallbackProtocolGuid = { 0x9546e07c, 0x2cbb, 0x4c88, { 0x98, 0x6c, 0xcd, 0x34, 0x10, 0x86, 0xf0, 0x44 } }\r
- gEfiEblAddCommandProtocolGuid = { 0xaeda2428, 0x9a22, 0x4637, { 0x9b, 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8, 0x29 } }\r
gEmbeddedDeviceGuid = { 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0xe9, 0xb, 0x71, 0x8f, 0x27, 0xde } }\r
gEmbeddedExternalDeviceProtocolGuid = { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}\r
gEmbeddedGpioProtocolGuid = { 0x17a0a3d7, 0xc0a5, 0x4635, { 0xbb, 0xd5, 0x07, 0x21, 0x87, 0xdf, 0xe2, 0xee }}\r
gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|L""|VOID*|0x00000007\r
gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07|UINT32|0x00000008\r
gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000|UINT32|0x00000009\r
- gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"Ebl"|VOID*|0x00000034\r
\r
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x0000000b\r
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|131072|UINT32|0x0000000c\r
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
- EfiFileLib|EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf\r
\r
ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
\r
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
\r
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
- EblCmdLib|EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf\r
-\r
- EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf\r
\r
AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf\r
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf\r
#\r
################################################################################\r
[Components.common]\r
- EmbeddedPkg/Library/EblAddExternalCommandLib/EblAddExternalCommandLib.inf\r
- EmbeddedPkg/Library/EblCmdLibNull/EblCmdLibNull.inf\r
- EmbeddedPkg/Library/EfiFileLib/EfiFileLib.inf\r
EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.inf\r
EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.inf\r
EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf\r
EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf\r
EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf\r
\r
- EmbeddedPkg/Ebl/Ebl.inf\r
-#### EmbeddedPkg/EblExternCmd/EblExternCmd.inf\r
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf\r
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf\r
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf\r
EmbeddedPkg/Library/AcpiLib/AcpiLib.inf\r
EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf\r
EmbeddedPkg/Library/DxeHobPeCoffLib/DxeHobPeCoffLib.inf\r
- EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf\r
EmbeddedPkg/Library/FdtLib/FdtLib.inf\r
EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf\r
EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf\r
+++ /dev/null
-# This is Ebl FDF file\r
-#\r
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-################################################################################\r
-#\r
-# FV Section\r
-#\r
-# [FV] section is used to define what components or modules are placed within a flash\r
-# device file. This section also defines order the components and modules are positioned\r
-# within the image. The [FV] section consists of define statements, set statements and\r
-# module statements.\r
-#\r
-################################################################################\r
-[FV.FvLoad]\r
-FvAlignment = 16 #FV alignment and FV attributes setting.\r
-ERASE_POLARITY = 1\r
-MEMORY_MAPPED = TRUE\r
-STICKY_WRITE = TRUE\r
-LOCK_CAP = TRUE\r
-LOCK_STATUS = TRUE\r
-WRITE_DISABLED_CAP = TRUE\r
-WRITE_ENABLED_CAP = TRUE\r
-WRITE_STATUS = TRUE\r
-WRITE_LOCK_CAP = TRUE\r
-WRITE_LOCK_STATUS = TRUE\r
-READ_DISABLED_CAP = TRUE\r
-READ_ENABLED_CAP = TRUE\r
-READ_STATUS = TRUE\r
-READ_LOCK_CAP = TRUE\r
-READ_LOCK_STATUS = TRUE\r
-\r
-################################################################################\r
-#\r
-# The INF statements point to module INF files, which will be placed into this FV image.\r
-# Parsing tools will scan the INF file to determine the type of component or module.\r
-# The component or module type is used to reference the standard rules\r
-# defined elsewhere in the FDF file.\r
-#\r
-# The format for INF statements is:\r
-# INF $(PathAndInfFileName)\r
-#\r
-################################################################################\r
-INF EmbeddedPkg/Ebl/Ebl.inf\r
-\r
-################################################################################\r
-#\r
-# Rules are use with the [FV] section's module INF type to define\r
-# how an FFS file is created for a given INF file. The following Rule are the default\r
-# rules for the different module type. User can add the customized rules to define the\r
-# content of the FFS file.\r
-#\r
-################################################################################\r
-\r
-\r
-############################################################################\r
-# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section #\r
-############################################################################\r
-#\r
-#[Rule.Common.DXE_DRIVER]\r
-# FILE DRIVER = $(NAMED_GUID) {\r
-# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-# COMPRESS PI_STD {\r
-# GUIDED {\r
-# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-# UI STRING="$(MODULE_NAME)" Optional\r
-# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-# }\r
-# }\r
-# }\r
-#\r
-############################################################################\r
-\r
-[Rule.Common.SEC]\r
- FILE SEC = $(NAMED_GUID) {\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- }\r
-\r
-[Rule.Common.PEI_CORE]\r
- FILE PEI_CORE = $(NAMED_GUID) {\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING ="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.PEIM]\r
- FILE PEIM = $(NAMED_GUID) {\r
- PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.PEIM.TIANOCOMPRESSED]\r
- FILE PEIM = $(NAMED_GUID) DEBUG_MYTOOLS_IA32 {\r
- PEI_DEPEX PEI_DEPEX Optional $(MODULE_NAME).depex\r
- GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE {\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
- }\r
-\r
-[Rule.Common.DXE_CORE]\r
- FILE DXE_CORE = $(NAMED_GUID) {\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.UEFI_DRIVER]\r
- FILE DRIVER = $(NAMED_GUID) {\r
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.DXE_DRIVER]\r
- FILE DRIVER = $(NAMED_GUID) {\r
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.DXE_RUNTIME_DRIVER]\r
- FILE DRIVER = $(NAMED_GUID) {\r
- DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
-\r
-[Rule.Common.UEFI_APPLICATION]\r
- FILE APPLICATION = $(NAMED_GUID) {\r
- PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
- UI STRING="$(MODULE_NAME)" Optional\r
- }\r
+++ /dev/null
-/** @file\r
- Include file for basic command line parser for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EBL_ADD_EXTERNAL_COMMAND_LIB_H__\r
-#define __EBL_ADD_EXTERNAL_COMMAND_LIB_H__\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/EblAddCommand.h>\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblAddExternalCommands (\r
- IN const EBL_COMMAND_TABLE *EntryArray,\r
- IN UINTN ArrayCount\r
- );\r
-\r
-/**\r
-\r
- Return a keypress or optionally timeout if a timeout value was passed in.\r
-\r
- An optional callback function is called every second when waiting for a\r
-\r
- timeout.\r
-\r
-\r
-\r
- @param Key EFI Key information returned\r
-\r
- @param TimeoutInSec Number of seconds to wait to timeout\r
-\r
- @param CallBack Callback called every second during the timeout wait\r
-\r
-\r
-\r
- @return EFI_SUCCESS Key was returned\r
-\r
- @return EFI_TIMEOUT If the TimoutInSec expired\r
-\r
-\r
-\r
-**/\r
-\r
-EFI_STATUS\r
-\r
-EFIAPI\r
-\r
-EblGetCharKey (\r
-\r
- IN OUT EFI_INPUT_KEY *Key,\r
-\r
- IN UINTN TimeoutInSec,\r
-\r
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r
-\r
- );\r
-\r
-\r
-\r
-\r
-\r
-/**\r
-\r
- This routine is used prevent command output data from scrolling off the end\r
-\r
- of the screen. The global gPageBreak is used to turn on or off this feature.\r
-\r
- If the CurrentRow is near the end of the screen pause and print out a prompt\r
-\r
- If the use hits Q to quit return TRUE else for any other key return FALSE.\r
-\r
- PrefixNewline is used to figure out if a newline is needed before the prompt\r
-\r
- string. This depends on the last print done before calling this function.\r
-\r
- CurrentRow is updated by one on a call or set back to zero if a prompt is\r
-\r
- needed.\r
-\r
-\r
-\r
- @param CurrentRow Used to figure out if its the end of the page and updated\r
-\r
- @param PrefixNewline Did previous print issue a newline\r
-\r
-\r
-\r
- @return TRUE if Q was hit to quit, FALSE in all other cases.\r
-\r
-\r
-\r
-**/\r
-\r
-BOOLEAN\r
-\r
-EFIAPI\r
-\r
-EblAnyKeyToContinueQtoQuit (\r
-\r
- IN UINTN *CurrentRow,\r
-\r
- IN BOOLEAN PrefixNewline\r
-\r
- );\r
-\r
-\r
-\r
-#endif\r
-\r
+++ /dev/null
-/** @file\r
- Include file for basic command line parser for EBL (Embedded Boot Loader)\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EBL_LIB_H__\r
-#define __EBL_LIB_H__\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/EblAddCommand.h>\r
-\r
-\r
-VOID\r
-EFIAPI\r
-EblAddCommand (\r
- IN const EBL_COMMAND_TABLE *Entry\r
- );\r
-\r
-VOID\r
-EFIAPI\r
-EblAddCommands (\r
- IN const EBL_COMMAND_TABLE *EntryArray,\r
- IN UINTN ArrayCount\r
- );\r
-\r
-\r
-//\r
-// LIbrary constructor called directly from Ebl Code.\r
-// This module calls EblAddCommand () or EblAddCommands () to register new commands\r
-//\r
-VOID\r
-EblInitializeExternalCmd (\r
- VOID\r
- );\r
-\r
-\r
-\r
-#endif\r
-\r
+++ /dev/null
-/** @file\r
- Abstractions for Ebl network accesses.\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EBL_NETWORK_LIB_H__\r
-#define __EBL_NETWORK_LIB_H__\r
-\r
-#include <Protocol/PxeBaseCode.h>\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCurrentIpAddress (\r
- IN OUT EFI_IP_ADDRESS *Ip\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCurrentMacAddress (\r
- IN OUT EFI_MAC_ADDRESS *Mac\r
- );\r
-\r
-CHAR8 *\r
-EFIAPI\r
-EblLoadFileBootTypeString (\r
- IN EFI_HANDLE Handle\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblPerformDHCP (\r
- IN BOOLEAN SortOffers\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblSetStationIp (\r
- IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL\r
- IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblMtftp (\r
- IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,\r
- IN OUT VOID *BufferPtr OPTIONAL,\r
- IN BOOLEAN Overwrite,\r
- IN OUT UINT64 *BufferSize,\r
- IN UINTN *BlockSize OPTIONAL,\r
- IN EFI_IP_ADDRESS *ServerIp,\r
- IN UINT8 *Filename OPTIONAL,\r
- IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,\r
- IN BOOLEAN DontUseBuffer\r
- );\r
-\r
-#endif\r
-\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#ifndef __EBL_ADD_COMMAND_H__\r
-#define __EBL_ADD_COMMAND_H__\r
-\r
-\r
-\r
-//\r
-// Protocol GUID\r
-//\r
-// AEDA2428-9A22-4637-9B21-545E28FBB829\r
-\r
-#define EBL_ADD_COMMAND_PROTOCOL_GUID \\r
- { 0xaeda2428, 0x9a22, 0x4637, { 0x9b, 0x21, 0x54, 0x5e, 0x28, 0xfb, 0xb8, 0x29 } }\r
-\r
-\r
-typedef struct _EBL_ADD_COMMAND_PROTOCOL EBL_ADD_COMMAND_PROTOCOL;\r
-\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EBL_COMMMAND) (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- );\r
-\r
-typedef struct {\r
- CHAR8 *Name;\r
- CHAR8 *HelpSummary;\r
- CHAR8 *Help;\r
- EBL_COMMMAND Command;\r
-} EBL_COMMAND_TABLE;\r
-\r
-\r
-/**\r
- Add a single command table entry.\r
-\r
- @param EntryArray Pointer EBL_COMMAND_TABLE of the command that is being added\r
-\r
-**/\r
-typedef\r
-VOID\r
-(EFIAPI *EBL_ADD_COMMAND) (\r
- IN const EBL_COMMAND_TABLE *Entry\r
- );\r
-\r
-\r
-/**\r
- Add a multiple command table entry.\r
-\r
- @param EntryArray Pointer EBL_COMMAND_TABLE of the commands that are being added\r
-\r
- @param ArrayCount Number of commands in the EntryArray.\r
-\r
-**/\r
-typedef\r
-VOID\r
-(EFIAPI *EBL_ADD_COMMANDS) (\r
- IN const EBL_COMMAND_TABLE *EntryArray,\r
- IN UINTN ArrayCount\r
- );\r
-\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EBL_GET_CHAR_CALL_BACK) (\r
- IN UINTN ElapsedTime\r
- );\r
-\r
-/**\r
- Return a keypress or optionally timeout if a timeout value was passed in.\r
- An optional callback function is called every second when waiting for a\r
- timeout.\r
-\r
- @param Key EFI Key information returned\r
- @param TimeoutInSec Number of seconds to wait to timeout\r
- @param CallBack Callback called every second during the timeout wait\r
-\r
- @return EFI_SUCCESS Key was returned\r
- @return EFI_TIMEOUT If the TimoutInSec expired\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EBL_GET_CHAR_KEY) (\r
- IN OUT EFI_INPUT_KEY *Key,\r
- IN UINTN TimeoutInSec,\r
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r
- );\r
-\r
-\r
-/**\r
- This routine is used prevent command output data from scrolling off the end\r
- of the screen. The global gPageBreak is used to turn on or off this feature.\r
- If the CurrentRow is near the end of the screen pause and print out a prompt\r
- If the use hits Q to quit return TRUE else for any other key return FALSE.\r
- PrefixNewline is used to figure out if a newline is needed before the prompt\r
- string. This depends on the last print done before calling this function.\r
- CurrentRow is updated by one on a call or set back to zero if a prompt is\r
- needed.\r
-\r
- @param CurrentRow Used to figure out if its the end of the page and updated\r
- @param PrefixNewline Did previous print issue a newline\r
-\r
- @return TRUE if Q was hit to quit, FALSE in all other cases.\r
-\r
-**/\r
-typedef\r
-BOOLEAN\r
-(EFIAPI *EBL_ANY_KEY_CONTINUE_Q_QUIT) (\r
- IN UINTN *CurrentRow,\r
- IN BOOLEAN PrefixNewline\r
- );\r
-\r
-\r
-\r
-struct _EBL_ADD_COMMAND_PROTOCOL {\r
- EBL_ADD_COMMAND AddCommand;\r
- EBL_ADD_COMMANDS AddCommands;\r
-\r
- // Commands to reuse EBL infrastructure\r
- EBL_GET_CHAR_KEY EblGetCharKey;\r
- EBL_ANY_KEY_CONTINUE_Q_QUIT EblAnyKeyToContinueQtoQuit;\r
-};\r
-\r
-extern EFI_GUID gEfiEblAddCommandProtocolGuid;\r
-\r
-#endif\r
-\r
-\r
+++ /dev/null
-/** @file\r
- Add external EblCmd Lib\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/EblAddExternalCommandLib.h>\r
-#include <Protocol/EblAddCommand.h>\r
-\r
-STATIC BOOLEAN gInstalledCommand = FALSE;\r
-STATIC EFI_EVENT mEblCommandRegistration = NULL;\r
-\r
-STATIC const EBL_COMMAND_TABLE *mAddExternalCmdLibTemplate = NULL;\r
-STATIC UINTN mAddExternalCmdLibTemplateSize = 0;\r
-EBL_ADD_COMMAND_PROTOCOL *gEblExternalCommand = NULL;\r
-\r
-\r
-/**\r
- Return a keypress or optionally timeout if a timeout value was passed in.\r
- An optional callback function is called every second when waiting for a\r
- timeout.\r
-\r
- @param Key EFI Key information returned\r
- @param TimeoutInSec Number of seconds to wait to timeout\r
- @param CallBack Callback called every second during the timeout wait\r
-\r
- @return EFI_SUCCESS Key was returned\r
- @return EFI_TIMEOUT If the TimoutInSec expired\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCharKey (\r
- IN OUT EFI_INPUT_KEY *Key,\r
- IN UINTN TimeoutInSec,\r
- IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r
- )\r
-{\r
- if (gEblExternalCommand != NULL) {\r
- return gEblExternalCommand->EblGetCharKey (Key, TimeoutInSec, CallBack);\r
- }\r
- return EFI_TIMEOUT;\r
-}\r
-\r
-\r
-/**\r
- This routine is used prevent command output data from scrolling off the end\r
- of the screen. The global gPageBreak is used to turn on or off this feature.\r
- If the CurrentRow is near the end of the screen pause and print out a prompt\r
- If the use hits Q to quit return TRUE else for any other key return FALSE.\r
- PrefixNewline is used to figure out if a newline is needed before the prompt\r
- string. This depends on the last print done before calling this function.\r
- CurrentRow is updated by one on a call or set back to zero if a prompt is\r
- needed.\r
-\r
- @param CurrentRow Used to figure out if its the end of the page and updated\r
- @param PrefixNewline Did previous print issue a newline\r
-\r
- @return TRUE if Q was hit to quit, FALSE in all other cases.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-EblAnyKeyToContinueQtoQuit (\r
- IN UINTN *CurrentRow,\r
- IN BOOLEAN PrefixNewline\r
- )\r
-{\r
- if (gEblExternalCommand != NULL) {\r
- return gEblExternalCommand->EblAnyKeyToContinueQtoQuit (CurrentRow, PrefixNewline);\r
- }\r
- return FALSE;\r
-}\r
-\r
-\r
-\r
-/**\r
- Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r
- reinstalled.\r
-\r
- @param Event The Event that is being processed\r
- @param Context Event Context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EblAddCommandNotificationEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if (!gInstalledCommand) {\r
- Status = gBS->LocateProtocol (&gEfiEblAddCommandProtocolGuid, NULL, (VOID **)&gEblExternalCommand);\r
- if (!EFI_ERROR (Status)) {\r
- gEblExternalCommand->AddCommands (mAddExternalCmdLibTemplate, mAddExternalCmdLibTemplateSize);\r
- gInstalledCommand = TRUE;\r
- }\r
- }\r
-}\r
-\r
-\r
-\r
-/**\r
- The user Entry Point for the driver. The user code starts with this function\r
- as the real entry point for the image goes into a library that calls this\r
- function.\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
- @param[in] SystemTable A pointer to the EFI System Table.\r
-\r
- @retval EFI_SUCCESS The entry point is executed successfully.\r
- @retval other Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EblAddExternalCommands (\r
- IN const EBL_COMMAND_TABLE *EntryArray,\r
- IN UINTN ArrayCount\r
- )\r
-{\r
- if (mAddExternalCmdLibTemplate != NULL) {\r
- return EFI_ALREADY_STARTED;\r
- }\r
-\r
- mAddExternalCmdLibTemplate = EntryArray;\r
- mAddExternalCmdLibTemplateSize = ArrayCount;\r
-\r
- EfiCreateProtocolNotifyEvent (\r
- &gEfiEblAddCommandProtocolGuid,\r
- TPL_CALLBACK,\r
- EblAddCommandNotificationEvent,\r
- NULL,\r
- &mEblCommandRegistration\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
+++ /dev/null
-#/** @file\r
-# Component description file for the entry point to a EFIDXE Drivers\r
-#\r
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification\r
-# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = EblAddExternalCommandLib\r
- FILE_GUID = 9195D970-C6F7-484E-8013-5B03C89C3B81\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = EblAddExternalCommandLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- EblAddExternalCommandLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiBootServicesTableLib\r
- UefiLib\r
- EblAddExternalCommandLib\r
-\r
-[Protocols]\r
- gEfiEblAddCommandProtocolGuid\r
-\r
-[Guids]\r
+++ /dev/null
-/** @file\r
- Null EblCmdLib\r
-\r
- Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Library/EblCmdLib.h>\r
-\r
-\r
-VOID\r
-EblInitializeExternalCmd (\r
- VOID\r
- )\r
-{\r
- return;\r
-}\r
+++ /dev/null
-#/** @file\r
-# Component description file for the entry point to a EFIDXE Drivers\r
-#\r
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification\r
-# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = EblCmdLibNull\r
- FILE_GUID = 3513C4E2-06D6-4921-9C2B-E938777BA79E\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = EfiCmdLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- EblCmdLibNull.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
-\r
-[Protocols]\r
-\r
-[Guids]\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/PxeBaseCode.h>\r
-\r
-\r
-BOOLEAN gUseIpv6 = FALSE;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCurrentIpAddress (\r
- IN OUT EFI_IP_ADDRESS *Ip\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PXE_BASE_CODE_PROTOCOL *Pxe;\r
-\r
- Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->Start (Pxe, gUseIpv6);\r
- if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {\r
- return Status;\r
- }\r
-\r
- CopyMem (Ip, &Pxe->Mode->StationIp, sizeof (EFI_IP_ADDRESS));\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblGetCurrentMacAddress (\r
- IN OUT EFI_MAC_ADDRESS *Mac\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNet;\r
-\r
- Status = gBS->LocateProtocol (&gEfiSimpleNetworkProtocolGuid, NULL, (VOID **)&SimpleNet);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- CopyMem (Mac, SimpleNet->Mode->CurrentAddress.Addr, sizeof (EFI_MAC_ADDRESS));\r
- return Status;\r
-}\r
-\r
-\r
-CHAR8 *\r
-EFIAPI\r
-EblLoadFileBootTypeString (\r
- IN EFI_HANDLE Handle\r
- )\r
-{\r
- EFI_STATUS Status;\r
- VOID *NullPtr;\r
-\r
- Status = gBS->HandleProtocol (Handle, &gEfiPxeBaseCodeProtocolGuid, &NullPtr);\r
- if (!EFI_ERROR (Status)) {\r
- return "EFI PXE Network Boot";\r
- }\r
-\r
- return "";\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblPerformDHCP (\r
- IN BOOLEAN SortOffers\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PXE_BASE_CODE_PROTOCOL *Pxe;\r
-\r
- Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->Start (Pxe, gUseIpv6);\r
- if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->Dhcp(Pxe, TRUE);\r
- return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblSetStationIp (\r
- IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL\r
- IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PXE_BASE_CODE_PROTOCOL *Pxe;\r
-\r
- Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->Start (Pxe, gUseIpv6);\r
- if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->SetStationIp (Pxe, NewStationIp, NewSubnetMask);\r
- return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EblMtftp (\r
- IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,\r
- IN OUT VOID *BufferPtr OPTIONAL,\r
- IN BOOLEAN Overwrite,\r
- IN OUT UINT64 *BufferSize,\r
- IN UINTN *BlockSize OPTIONAL,\r
- IN EFI_IP_ADDRESS *ServerIp,\r
- IN UINT8 *Filename OPTIONAL,\r
- IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,\r
- IN BOOLEAN DontUseBuffer\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PXE_BASE_CODE_PROTOCOL *Pxe;\r
-\r
- Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- Status = Pxe->Mtftp (\r
- Pxe,\r
- Operation,\r
- BufferPtr,\r
- Overwrite,\r
- BufferSize,\r
- BlockSize,\r
- ServerIp,\r
- Filename,\r
- Info,\r
- DontUseBuffer\r
- );\r
- return Status;\r
-}\r
-\r
+++ /dev/null
-#/** @file\r
-#\r
-# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = EblNetworkLib\r
- FILE_GUID = D885869A-7869-47DB-9429-DE03C318BCFD\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = EblNetworkLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-[sources.common]\r
- EblNetworkLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[Protocols]\r
- gEfiSimpleNetworkProtocolGuid\r
- gEfiPxeBaseCodeProtocolGuid\r
-\r
-[Depex]\r
- TRUE\r
+++ /dev/null
-/** @file\r
-File IO routines inspired by Streams with an EFI flavor\r
-\r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Basic support for opening files on different device types. The device string\r
-is in the form of DevType:Path. Current DevType is required as there is no\r
-current mounted device concept of current working directory concept implement\r
-by this library.\r
-\r
-Device names are case insensitive and only check the leading characters for\r
-unique matches. Thus the following are all the same:\r
-LoadFile0:\r
-l0:\r
-L0:\r
-Lo0:\r
-\r
-Supported Device Names:\r
-A0x1234:0x12 - A memory buffer starting at address 0x1234 for 0x12 bytes\r
-l1: - EFI LoadFile device one.\r
-B0: - EFI BlockIo zero.\r
-fs3: - EFI Simple File System device 3\r
-Fv2: - EFI Firmware VOlume device 2\r
-10.0.1.102: - TFTP service IP followed by the file name\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/DiskIo.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/LoadFile.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/ZeroGuid.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EfiFileLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/EblNetworkLib.h>\r
-\r
-\r
-CHAR8 *gCwd = NULL;\r
-\r
-#define EFI_OPEN_FILE_GUARD_HEADER 0x4B4D4641\r
-#define EFI_OPEN_FILE_GUARD_FOOTER 0x444D5A56\r
-\r
-// Need to defend against this overflowing\r
-#define MAX_CMD_LINE 0x200\r
-\r
-typedef struct {\r
- UINT32 Header;\r
- EFI_OPEN_FILE File;\r
- UINT32 Footer;\r
-} EFI_OPEN_FILE_GUARD;\r
-\r
-\r
-// globals to store current open device info\r
-EFI_HANDLE *mBlkIo = NULL;\r
-UINTN mBlkIoCount = 0;\r
-\r
-EFI_HANDLE *mFs = NULL;\r
-UINTN mFsCount = 0;\r
-// mFsInfo[] array entries must match mFs[] handles\r
-EFI_FILE_SYSTEM_INFO **mFsInfo = NULL;\r
-\r
-EFI_HANDLE *mFv = NULL;\r
-UINTN mFvCount = 0;\r
-EFI_HANDLE *mLoadFile = NULL;\r
-UINTN mLoadFileCount = 0;\r
-\r
-\r
-\r
-/**\r
-Internal worker function to validate a File handle.\r
-\r
-@param File Open File Handle\r
-\r
-@return TRUE File is valid\r
-@return FALSE File is not valid\r
-\r
-\r
-**/\r
-BOOLEAN\r
-FileHandleValid (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- EFI_OPEN_FILE_GUARD *GuardFile;\r
-\r
- // Look right before and after file structure for the correct signatures\r
- GuardFile = BASE_CR (File, EFI_OPEN_FILE_GUARD, File);\r
- if ((GuardFile->Header != EFI_OPEN_FILE_GUARD_HEADER) ||\r
- (GuardFile->Footer != EFI_OPEN_FILE_GUARD_FOOTER) ) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-/**\r
-Internal worker function. If Buffer is not NULL free it.\r
-\r
-@param Buffer Buffer to FreePool()\r
-\r
-**/\r
-VOID\r
-EblFreePool (\r
- IN VOID *Buffer\r
- )\r
-{\r
- if (Buffer != NULL) {\r
- FreePool (Buffer);\r
- }\r
-}\r
-\r
-/**\r
-Update Device List Global Variables\r
-\r
-**/\r
-VOID\r
-EblUpdateDeviceLists (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;\r
- EFI_FILE_HANDLE Root;\r
- UINTN Index;\r
-\r
- if (mBlkIo != NULL) {\r
- FreePool (mBlkIo);\r
- }\r
- gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);\r
-\r
-\r
-\r
- if (mFv != NULL) {\r
- FreePool (mFv);\r
- }\r
- gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &mFvCount, &mFv);\r
-\r
- if (mLoadFile != NULL) {\r
- FreePool (mLoadFile);\r
- }\r
- gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &mLoadFileCount, &mLoadFile);\r
-\r
- if (mFs != NULL) {\r
- FreePool (mFs);\r
- }\r
-\r
- if (&mFsInfo[0] != NULL) {\r
- // Need to Free the mFsInfo prior to recalculating mFsCount so don't move this code\r
- for (Index = 0; Index < mFsCount; Index++) {\r
- if (mFsInfo[Index] != NULL) {\r
- FreePool (mFsInfo[Index]);\r
- }\r
- }\r
- FreePool (mFsInfo);\r
- }\r
-\r
- gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &mFsCount, &mFs);\r
-\r
-\r
- mFsInfo = AllocateZeroPool (mFsCount * sizeof (EFI_FILE_SYSTEM_INFO *));\r
- if (mFsInfo == NULL) {\r
- // If we can't do this then we can't support file system entries\r
- mFsCount = 0;\r
- } else {\r
- // Loop through all the file system structures and cache the file system info data\r
- for (Index =0; Index < mFsCount; Index++) {\r
- Status = gBS->HandleProtocol (mFs[Index], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);\r
- if (!EFI_ERROR (Status)) {\r
- Status = Fs->OpenVolume (Fs, &Root);\r
- if (!EFI_ERROR (Status)) {\r
- // Get information about the volume\r
- Size = 0;\r
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, mFsInfo[Index]);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- mFsInfo[Index] = AllocatePool (Size);\r
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, mFsInfo[Index]);\r
- }\r
-\r
- Root->Close (Root);\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-\r
-/**\r
-PathName is in the form <device name>:<path> for example fs1:\ or ROOT:\.\r
-Return TRUE if the <devce name> prefix of PathName matches a file system\r
-Volume Name. MatchIndex is the array index in mFsInfo[] of the match,\r
-and it can be used with mFs[] to find the handle that needs to be opened\r
-\r
-@param PathName PathName to check\r
-@param FileStart Index of the first character of the <path>\r
-@param MatchIndex Index in mFsInfo[] that matches\r
-\r
-@return TRUE PathName matches a Volume Label and MatchIndex is valid\r
-@return FALSE PathName does not match a Volume Label MatchIndex undefined\r
-\r
-**/\r
-BOOLEAN\r
-EblMatchVolumeName (\r
- IN CHAR8 *PathName,\r
- IN UINTN FileStart,\r
- OUT UINTN *MatchIndex\r
- )\r
-{\r
- UINTN Index;\r
- UINTN Compare;\r
- UINTN VolStrLen;\r
- BOOLEAN Match;\r
-\r
- for (Index =0; Index < mFsCount; Index++) {\r
- if (mFsInfo[Index] == NULL) {\r
- // FsInfo is not valid so skip it\r
- continue;\r
- }\r
- VolStrLen = StrLen (mFsInfo[Index]->VolumeLabel);\r
- for (Compare = 0, Match = TRUE; Compare < (FileStart - 1); Compare++) {\r
- if (Compare > VolStrLen) {\r
- Match = FALSE;\r
- break;\r
- }\r
- if (PathName[Compare] != (CHAR8)mFsInfo[Index]->VolumeLabel[Compare]) {\r
- // If the VolumeLabel has a space allow a _ to match with it in addition to ' '\r
- if (!((PathName[Compare] == '_') && (mFsInfo[Index]->VolumeLabel[Compare] == L' '))) {\r
- Match = FALSE;\r
- break;\r
- }\r
- }\r
- }\r
- if (Match) {\r
- *MatchIndex = Index;\r
- return TRUE;\r
- }\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
-Return the number of devices of the current type active in the system\r
-\r
-@param Type Device type to check\r
-\r
-@return 0 Invalid type\r
-\r
-**/\r
-UINTN\r
-EfiGetDeviceCounts (\r
- IN EFI_OPEN_FILE_TYPE DeviceType\r
- )\r
-{\r
- switch (DeviceType) {\r
- case EfiOpenLoadFile:\r
- return mLoadFileCount;\r
- case EfiOpenFirmwareVolume:\r
- return mFvCount;\r
- case EfiOpenFileSystem:\r
- return mFsCount;\r
- case EfiOpenBlockIo:\r
- return mBlkIoCount;\r
- default:\r
- return 0;\r
- }\r
-}\r
-\r
-EFI_STATUS\r
-ConvertIpStringToEfiIp (\r
- IN CHAR8 *PathName,\r
- OUT EFI_IP_ADDRESS *ServerIp\r
- )\r
-{\r
- CHAR8 *Str;\r
-\r
- Str = PathName;\r
- ServerIp->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (Str);\r
-\r
- Str = AsciiStrStr (Str, ".");\r
- if (Str == NULL) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- ServerIp->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (++Str);\r
-\r
- Str = AsciiStrStr (Str, ".");\r
- if (Str == NULL) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- ServerIp->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (++Str);\r
-\r
- Str = AsciiStrStr (Str, ".");\r
- if (Str == NULL) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- ServerIp->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (++Str);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-Internal work function to extract a device number from a string skipping\r
-text. Easy way to extract numbers from strings like blk7:.\r
-\r
-@param Str String to extract device number form\r
-\r
-@return -1 Device string is not valid\r
-@return Device #\r
-\r
-**/\r
-UINTN\r
-EblConvertDevStringToNumber (\r
- IN CHAR8 *Str\r
- )\r
-{\r
- UINTN Max;\r
- UINTN Index;\r
-\r
-\r
- // Find the first digit\r
- Max = AsciiStrLen (Str);\r
- for (Index = 0; !((*Str >= '0') && (*Str <= '9')) && (Index < Max); Index++) {\r
- Str++;\r
- }\r
- if (Index == Max) {\r
- return (UINTN)-1;\r
- }\r
-\r
- return AsciiStrDecimalToUintn (Str);\r
-}\r
-\r
-\r
-/**\r
-Internal work function to fill in EFI_OPEN_FILE information for the Fs and BlkIo\r
-\r
-@param File Open file handle\r
-@param FileName Name of file after device stripped off\r
-\r
-\r
-**/\r
-EFI_STATUS\r
-EblFileDevicePath (\r
- IN OUT EFI_OPEN_FILE *File,\r
- IN CHAR8 *FileName,\r
- IN CONST UINT64 OpenMode\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- FILEPATH_DEVICE_PATH *FilePath;\r
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;\r
- CHAR16 UnicodeFileName[MAX_PATHNAME];\r
- EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;\r
- EFI_FILE_HANDLE Root;\r
-\r
-\r
- if ( *FileName != 0 ) {\r
- AsciiStrToUnicodeStrS (FileName, UnicodeFileName,\r
- ARRAY_SIZE (UnicodeFileName));\r
- } else {\r
- AsciiStrToUnicodeStrS ("\\", UnicodeFileName, ARRAY_SIZE (UnicodeFileName));\r
- }\r
-\r
- Size = StrSize (UnicodeFileName);\r
- FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
- if (FileDevicePath != NULL) {\r
- FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
- FilePath->Header.Type = MEDIA_DEVICE_PATH;\r
- FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
- CopyMem (&FilePath->PathName, UnicodeFileName, Size);\r
- SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
- SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));\r
-\r
- if (File->EfiHandle != NULL) {\r
- File->DevicePath = DevicePathFromHandle (File->EfiHandle);\r
- }\r
-\r
- File->DevicePath = AppendDevicePath (File->DevicePath, FileDevicePath);\r
- FreePool (FileDevicePath);\r
- }\r
-\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);\r
- if (!EFI_ERROR (Status)) {\r
- File->FsBlockIoMedia = BlkIo->Media;\r
- File->FsBlockIo = BlkIo;\r
-\r
- // If we are not opening the device this will get over written with file info\r
- File->MaxPosition = MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);\r
- }\r
-\r
- if (File->Type == EfiOpenFileSystem) {\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);\r
- if (!EFI_ERROR (Status)) {\r
- Status = Fs->OpenVolume (Fs, &Root);\r
- if (!EFI_ERROR (Status)) {\r
- // Get information about the volume\r
- Size = 0;\r
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- File->FsInfo = AllocatePool (Size);\r
- Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);\r
- }\r
-\r
- // Get information about the file\r
- Status = Root->Open (Root, &File->FsFileHandle, UnicodeFileName, OpenMode, 0);\r
- if (!EFI_ERROR (Status)) {\r
- Size = 0;\r
- Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, NULL);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- File->FsFileInfo = AllocatePool (Size);\r
- Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, File->FsFileInfo);\r
- if (!EFI_ERROR (Status)) {\r
- File->Size = (UINTN)File->FsFileInfo->FileSize;\r
- File->MaxPosition = (UINT64)File->Size;\r
- }\r
- }\r
- }\r
-\r
- Root->Close (Root);\r
- }\r
- }\r
- } else if (File->Type == EfiOpenBlockIo) {\r
- File->Size = (UINTN)File->MaxPosition;\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-#define ToUpper(a) ((((a) >= 'a') && ((a) <= 'z')) ? ((a) - 'a' + 'A') : (a))\r
-\r
-EFI_STATUS\r
-CompareGuidToString (\r
- IN EFI_GUID *Guid,\r
- IN CHAR8 *String\r
- )\r
-{\r
- CHAR8 AsciiGuid[64];\r
- CHAR8 *StringPtr;\r
- CHAR8 *GuidPtr;\r
-\r
- AsciiSPrint (AsciiGuid, sizeof(AsciiGuid), "%g", Guid);\r
-\r
- StringPtr = String;\r
- GuidPtr = AsciiGuid;\r
-\r
- while ((*StringPtr != '\0') && (*GuidPtr != '\0')) {\r
- // Skip dashes\r
- if (*StringPtr == '-') {\r
- StringPtr++;\r
- continue;\r
- }\r
-\r
- if (*GuidPtr == '-') {\r
- GuidPtr++;\r
- continue;\r
- }\r
-\r
- if (ToUpper(*StringPtr) != ToUpper(*GuidPtr)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- StringPtr++;\r
- GuidPtr++;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-Internal work function to fill in EFI_OPEN_FILE information for the FV\r
-\r
-@param File Open file handle\r
-@param FileName Name of file after device stripped off\r
-\r
-\r
-**/\r
-EFI_STATUS\r
-EblFvFileDevicePath (\r
- IN OUT EFI_OPEN_FILE *File,\r
- IN CHAR8 *FileName,\r
- IN CONST UINT64 OpenMode\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_STATUS GetNextFileStatus;\r
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH DevicePathNode;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- UINTN Key;\r
- UINT32 AuthenticationStatus;\r
- CHAR8 AsciiSection[MAX_PATHNAME];\r
- VOID *Section;\r
- UINTN SectionSize;\r
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
- EFI_LBA Lba;\r
- UINTN BlockSize;\r
- UINTN NumberOfBlocks;\r
- EFI_FIRMWARE_VOLUME_HEADER *FvHeader = NULL;\r
- UINTN Index;\r
-\r
-\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&File->Fv);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- // Get FVB Info about the handle\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);\r
- if (!EFI_ERROR (Status)) {\r
- Status = Fvb->GetPhysicalAddress (Fvb, &File->FvStart);\r
- if (!EFI_ERROR (Status)) {\r
- FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)File->FvStart;\r
- File->FvHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_HEADER);\r
- for (Index = 0; FvHeader->BlockMap[Index].Length !=0; Index++) {\r
- File->FvHeaderSize += sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
- }\r
-\r
- for (Lba = 0, File->FvSize = 0, NumberOfBlocks = 0; ; File->FvSize += (BlockSize * NumberOfBlocks), Lba += NumberOfBlocks) {\r
- Status = Fvb->GetBlockSize (Fvb, Lba, &BlockSize, &NumberOfBlocks);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
-\r
- DevicePath = DevicePathFromHandle (File->EfiHandle);\r
-\r
- if (*FileName == '\0') {\r
- File->DevicePath = DuplicateDevicePath (DevicePath);\r
- File->Size = File->FvSize;\r
- File->MaxPosition = File->Size;\r
- } else {\r
- Key = 0;\r
- do {\r
- File->FvType = EFI_FV_FILETYPE_ALL;\r
- GetNextFileStatus = File->Fv->GetNextFile (\r
- File->Fv,\r
- &Key,\r
- &File->FvType,\r
- &File->FvNameGuid,\r
- &File->FvAttributes,\r
- &File->Size\r
- );\r
- if (!EFI_ERROR (GetNextFileStatus)) {\r
- // Compare GUID first\r
- Status = CompareGuidToString (&File->FvNameGuid, FileName);\r
- if (!EFI_ERROR(Status)) {\r
- break;\r
- }\r
-\r
- Section = NULL;\r
- Status = File->Fv->ReadSection (\r
- File->Fv,\r
- &File->FvNameGuid,\r
- EFI_SECTION_USER_INTERFACE,\r
- 0,\r
- &Section,\r
- &SectionSize,\r
- &AuthenticationStatus\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- UnicodeStrToAsciiStrS (Section, AsciiSection, MAX_PATHNAME);\r
- if (AsciiStriCmp (FileName, AsciiSection) == 0) {\r
- FreePool (Section);\r
- break;\r
- }\r
- FreePool (Section);\r
- }\r
- }\r
- } while (!EFI_ERROR (GetNextFileStatus));\r
-\r
- if (EFI_ERROR (GetNextFileStatus)) {\r
- return GetNextFileStatus;\r
- }\r
-\r
- if (OpenMode != EFI_SECTION_ALL) {\r
- // Calculate the size of the section we are targeting\r
- Section = NULL;\r
- File->Size = 0;\r
- Status = File->Fv->ReadSection (\r
- File->Fv,\r
- &File->FvNameGuid,\r
- (EFI_SECTION_TYPE)OpenMode,\r
- 0,\r
- &Section,\r
- &File->Size,\r
- &AuthenticationStatus\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- }\r
-\r
- File->MaxPosition = File->Size;\r
- EfiInitializeFwVolDevicepathNode (&DevicePathNode, &File->FvNameGuid);\r
- File->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&DevicePathNode);\r
- }\r
-\r
-\r
- // FVB not required if FV was soft loaded...\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
-Open a device named by PathName. The PathName includes a device name and\r
-path separated by a :. See file header for more details on the PathName\r
-syntax. There is no checking to prevent a file from being opened more than\r
-one type.\r
-\r
-SectionType is only used to open an FV. Each file in an FV contains multiple\r
-sections and only the SectionType section is opened.\r
-\r
-For any file that is opened with EfiOpen() must be closed with EfiClose().\r
-\r
-@param PathName Path to parse to open\r
-@param OpenMode Same as EFI_FILE.Open()\r
-@param SectionType Section in FV to open.\r
-\r
-@return NULL Open failed\r
-@return Valid EFI_OPEN_FILE handle\r
-\r
-**/\r
-EFI_OPEN_FILE *\r
-EfiOpen (\r
- IN CHAR8 *PathName,\r
- IN CONST UINT64 OpenMode,\r
- IN CONST EFI_SECTION_TYPE SectionType\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_OPEN_FILE *File;\r
- EFI_OPEN_FILE FileData;\r
- UINTN StrLen;\r
- UINTN FileStart;\r
- UINTN DevNumber = 0;\r
- EFI_OPEN_FILE_GUARD *GuardFile;\r
- BOOLEAN VolumeNameMatch;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- UINTN Size;\r
- EFI_IP_ADDRESS Ip;\r
- CHAR8 *CwdPlusPathName;\r
- UINTN Index;\r
- EFI_SECTION_TYPE ModifiedSectionType;\r
- UINTN AsciiLength;\r
-\r
- EblUpdateDeviceLists ();\r
-\r
- File = &FileData;\r
- ZeroMem (File, sizeof (EFI_OPEN_FILE));\r
-\r
- StrLen = AsciiStrSize (PathName);\r
- if (StrLen <= 1) {\r
- // Smallest valid path is 1 char and a null\r
- return NULL;\r
- }\r
-\r
- for (FileStart = 0; FileStart < StrLen; FileStart++) {\r
- if (PathName[FileStart] == ':') {\r
- FileStart++;\r
- break;\r
- }\r
- }\r
-\r
- //\r
- // Matching volume name has precedence over handle based names\r
- //\r
- VolumeNameMatch = EblMatchVolumeName (PathName, FileStart, &DevNumber);\r
- if (!VolumeNameMatch) {\r
- if (FileStart == StrLen) {\r
- // No Volume name or device name, so try Current Working Directory\r
- if (gCwd == NULL) {\r
- // No CWD\r
- return NULL;\r
- }\r
-\r
- // We could add a current working directory concept\r
- AsciiLength = AsciiStrSize (gCwd) + AsciiStrSize (PathName);\r
- CwdPlusPathName = AllocatePool (AsciiLength);\r
- if (CwdPlusPathName == NULL) {\r
- return NULL;\r
- }\r
-\r
- if ((PathName[0] == '/') || (PathName[0] == '\\')) {\r
- // PathName starts in / so this means we go to the root of the device in the CWD.\r
- CwdPlusPathName[0] = '\0';\r
- for (FileStart = 0; gCwd[FileStart] != '\0'; FileStart++) {\r
- CwdPlusPathName[FileStart] = gCwd[FileStart];\r
- if (gCwd[FileStart] == ':') {\r
- FileStart++;\r
- CwdPlusPathName[FileStart] = '\0';\r
- break;\r
- }\r
- }\r
- } else {\r
- AsciiStrCpyS (CwdPlusPathName, AsciiLength, gCwd);\r
- StrLen = AsciiStrLen (gCwd);\r
- if ((*PathName != '/') && (*PathName != '\\') && (gCwd[StrLen-1] != '/') && (gCwd[StrLen-1] != '\\')) {\r
- AsciiStrCatS (CwdPlusPathName, AsciiLength, "\\");\r
- }\r
- }\r
-\r
- AsciiStrCatS (CwdPlusPathName, AsciiLength, PathName);\r
- if (AsciiStrStr (CwdPlusPathName, ":") == NULL) {\r
- // Extra error check to make sure we don't recurse and blow stack\r
- return NULL;\r
- }\r
-\r
- File = EfiOpen (CwdPlusPathName, OpenMode, SectionType);\r
- FreePool (CwdPlusPathName);\r
- return File;\r
- }\r
-\r
- DevNumber = EblConvertDevStringToNumber ((CHAR8 *)PathName);\r
- }\r
-\r
- File->DeviceName = AllocatePool (StrLen);\r
- AsciiStrCpyS (File->DeviceName, StrLen, PathName);\r
- File->DeviceName[FileStart - 1] = '\0';\r
- File->FileName = &File->DeviceName[FileStart];\r
- if (File->FileName[0] == '\0') {\r
- // if it is just a file name use / as root\r
- File->FileName = "\\";\r
- }\r
-\r
- //\r
- // Use best match algorithm on the dev names so we only need to look at the\r
- // first few charters to match the full device name. Short name forms are\r
- // legal from the caller.\r
- //\r
- Status = EFI_SUCCESS;\r
- if (*PathName == 'f' || *PathName == 'F' || VolumeNameMatch) {\r
- if (PathName[1] == 's' || PathName[1] == 'S' || VolumeNameMatch) {\r
- if (DevNumber >= mFsCount) {\r
- goto ErrorExit;\r
- }\r
- File->Type = EfiOpenFileSystem;\r
- File->EfiHandle = mFs[DevNumber];\r
- Status = EblFileDevicePath (File, &PathName[FileStart], OpenMode);\r
-\r
- } else if (PathName[1] == 'v' || PathName[1] == 'V') {\r
- if (DevNumber >= mFvCount) {\r
- goto ErrorExit;\r
- }\r
- File->Type = EfiOpenFirmwareVolume;\r
- File->EfiHandle = mFv[DevNumber];\r
-\r
- if ((PathName[FileStart] == '/') || (PathName[FileStart] == '\\')) {\r
- // Skip leading / as its not really needed for the FV since no directories are supported\r
- FileStart++;\r
- }\r
-\r
- // Check for 2nd :\r
- ModifiedSectionType = SectionType;\r
- for (Index = FileStart; PathName[Index] != '\0'; Index++) {\r
- if (PathName[Index] == ':') {\r
- // Support fv0:\DxeCore:0x10\r
- // This means open the PE32 Section of the file\r
- ModifiedSectionType = (EFI_SECTION_TYPE)AsciiStrHexToUintn (&PathName[Index + 1]);\r
- PathName[Index] = '\0';\r
- }\r
- }\r
- File->FvSectionType = ModifiedSectionType;\r
- Status = EblFvFileDevicePath (File, &PathName[FileStart], ModifiedSectionType);\r
- }\r
- } else if ((*PathName == 'A') || (*PathName == 'a')) {\r
- // Handle a:0x10000000:0x1234 address form a:ADDRESS:SIZE\r
- File->Type = EfiOpenMemoryBuffer;\r
- // 1st colon is at PathName[FileStart - 1]\r
- File->Buffer = (VOID *)AsciiStrHexToUintn (&PathName[FileStart]);\r
-\r
- // Find 2nd colon\r
- while ((PathName[FileStart] != ':') && (PathName[FileStart] != '\0')) {\r
- FileStart++;\r
- }\r
-\r
- // If we ran out of string, there's no extra data\r
- if (PathName[FileStart] == '\0') {\r
- File->Size = 0;\r
- } else {\r
- File->Size = AsciiStrHexToUintn (&PathName[FileStart + 1]);\r
- }\r
-\r
- // if there's no number after the second colon, default\r
- // the end of memory\r
- if (File->Size == 0) {\r
- File->Size = (UINTN)(0 - (UINTN)File->Buffer);\r
- }\r
-\r
- File->MaxPosition = File->Size;\r
- File->BaseOffset = (UINTN)File->Buffer;\r
-\r
- } else if (*PathName== 'l' || *PathName == 'L') {\r
- if (DevNumber >= mLoadFileCount) {\r
- goto ErrorExit;\r
- }\r
- File->Type = EfiOpenLoadFile;\r
- File->EfiHandle = mLoadFile[DevNumber];\r
-\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiLoadFileProtocolGuid, (VOID **)&File->LoadFile);\r
- if (EFI_ERROR (Status)) {\r
- goto ErrorExit;\r
- }\r
-\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);\r
- if (EFI_ERROR (Status)) {\r
- goto ErrorExit;\r
- }\r
- File->DevicePath = DuplicateDevicePath (DevicePath);\r
-\r
- } else if (*PathName == 'b' || *PathName == 'B') {\r
- // Handle b#:0x10000000:0x1234 address form b#:ADDRESS:SIZE\r
- if (DevNumber >= mBlkIoCount) {\r
- goto ErrorExit;\r
- }\r
- File->Type = EfiOpenBlockIo;\r
- File->EfiHandle = mBlkIo[DevNumber];\r
- EblFileDevicePath (File, "", OpenMode);\r
-\r
- // 1st colon is at PathName[FileStart - 1]\r
- File->DiskOffset = AsciiStrHexToUintn (&PathName[FileStart]);\r
-\r
- // Find 2nd colon\r
- while ((PathName[FileStart] != ':') && (PathName[FileStart] != '\0')) {\r
- FileStart++;\r
- }\r
-\r
- // If we ran out of string, there's no extra data\r
- if (PathName[FileStart] == '\0') {\r
- Size = 0;\r
- } else {\r
- Size = AsciiStrHexToUintn (&PathName[FileStart + 1]);\r
- }\r
-\r
- // if a zero size is passed in (or the size is left out entirely),\r
- // go to the end of the device.\r
- if (Size == 0) {\r
- File->Size = File->Size - File->DiskOffset;\r
- } else {\r
- File->Size = Size;\r
- }\r
-\r
- File->MaxPosition = File->Size;\r
- File->BaseOffset = File->DiskOffset;\r
- } else if ((*PathName) >= '0' && (*PathName <= '9')) {\r
-\r
- // Get current IP address\r
- Status = EblGetCurrentIpAddress (&Ip);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Device IP Address is not configured.\n");\r
- goto ErrorExit;\r
- }\r
-\r
-\r
- // Parse X.X.X.X:Filename, only support IPv4 TFTP for now...\r
- File->Type = EfiOpenTftp;\r
- File->IsDirty = FALSE;\r
- File->IsBufferValid = FALSE;\r
-\r
- Status = ConvertIpStringToEfiIp (PathName, &File->ServerIp);\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- goto ErrorExit;\r
- }\r
-\r
- GuardFile = (EFI_OPEN_FILE_GUARD *)AllocateZeroPool (sizeof (EFI_OPEN_FILE_GUARD));\r
- if (GuardFile == NULL) {\r
- goto ErrorExit;\r
- }\r
-\r
- GuardFile->Header = EFI_OPEN_FILE_GUARD_HEADER;\r
- CopyMem (&(GuardFile->File), &FileData, sizeof (EFI_OPEN_FILE));\r
- GuardFile->Footer = EFI_OPEN_FILE_GUARD_FOOTER;\r
-\r
- return &(GuardFile->File);\r
-\r
-ErrorExit:\r
- FreePool (File->DeviceName);\r
- return NULL;\r
-}\r
-\r
-#define FILE_COPY_CHUNK 0x01000000\r
-\r
-EFI_STATUS\r
-EfiCopyFile (\r
- IN CHAR8 *DestinationFile,\r
- IN CHAR8 *SourceFile\r
- )\r
-{\r
- EFI_OPEN_FILE *Source = NULL;\r
- EFI_OPEN_FILE *Destination = NULL;\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- VOID *Buffer = NULL;\r
- UINTN Size;\r
- UINTN Offset;\r
- UINTN Chunk = FILE_COPY_CHUNK;\r
-\r
- Source = EfiOpen (SourceFile, EFI_FILE_MODE_READ, 0);\r
- if (Source == NULL) {\r
- AsciiPrint("Source file open error.\n");\r
- Status = EFI_NOT_FOUND;\r
- goto Exit;\r
- }\r
-\r
- Destination = EfiOpen (DestinationFile, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);\r
- if (Destination == NULL) {\r
- AsciiPrint("Destination file open error.\n");\r
- Status = EFI_NOT_FOUND;\r
- goto Exit;\r
- }\r
-\r
- Buffer = AllocatePool(FILE_COPY_CHUNK);\r
- if (Buffer == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Exit;\r
- }\r
-\r
- Size = EfiTell(Source, NULL);\r
-\r
- for (Offset = 0; Offset + FILE_COPY_CHUNK <= Size; Offset += Chunk) {\r
- Chunk = FILE_COPY_CHUNK;\r
-\r
- Status = EfiRead(Source, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Read file error %r\n", Status);\r
- goto Exit;\r
- }\r
-\r
- Status = EfiWrite(Destination, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Write file error %r\n", Status);\r
- goto Exit;\r
- }\r
- }\r
-\r
- // Any left over?\r
- if (Offset < Size) {\r
- Chunk = Size - Offset;\r
-\r
- Status = EfiRead(Source, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Read file error\n");\r
- goto Exit;\r
- }\r
-\r
- Status = EfiWrite(Destination, Buffer, &Chunk);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Write file error\n");\r
- goto Exit;\r
- }\r
- }\r
-\r
-Exit:\r
- if (Source != NULL) {\r
- Status = EfiClose(Source);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Source close error");\r
- }\r
- }\r
-\r
- if (Destination != NULL) {\r
- Status = EfiClose(Destination);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("Destination close error");\r
- }\r
- }\r
-\r
- if (Buffer != NULL) {\r
- FreePool(Buffer);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
-Use DeviceType and Index to form a valid PathName and try and open it.\r
-\r
-@param DeviceType Device type to open\r
-@param Index Device Index to use. Zero relative.\r
-\r
-@return NULL Open failed\r
-@return Valid EFI_OPEN_FILE handle\r
-\r
-**/\r
-EFI_OPEN_FILE *\r
-EfiDeviceOpenByType (\r
- IN EFI_OPEN_FILE_TYPE DeviceType,\r
- IN UINTN Index\r
- )\r
-{\r
- CHAR8 *DevStr;\r
- CHAR8 Path[MAX_CMD_LINE];\r
-\r
- switch (DeviceType) {\r
- case EfiOpenLoadFile:\r
- DevStr = "loadfile%d:";\r
- break;\r
- case EfiOpenFirmwareVolume:\r
- DevStr = "fv%d:";\r
- break;\r
- case EfiOpenFileSystem:\r
- DevStr = "fs%d:";\r
- break;\r
- case EfiOpenBlockIo:\r
- DevStr = "blk%d:";\r
- break;\r
- case EfiOpenMemoryBuffer:\r
- DevStr = "a%d:";\r
- break;\r
- default:\r
- return NULL;\r
- }\r
-\r
- AsciiSPrint (Path, MAX_PATHNAME, DevStr, Index);\r
-\r
- return EfiOpen (Path, EFI_FILE_MODE_READ, 0);\r
-}\r
-\r
-\r
-/**\r
-Close a file handle opened by EfiOpen() and free all resources allocated by\r
-EfiOpen().\r
-\r
-@param Stream Open File Handle\r
-\r
-@return EFI_INVALID_PARAMETER Stream is not an Open File\r
-@return EFI_SUCCESS Steam closed\r
-\r
-**/\r
-EFI_STATUS\r
-EfiClose (\r
- IN EFI_OPEN_FILE *File\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT64 TftpBufferSize;\r
-\r
- if (!FileHandleValid (File)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //Write the buffer contents to TFTP file.\r
- if ((File->Type == EfiOpenTftp) && (File->IsDirty)) {\r
-\r
- TftpBufferSize = File->Size;\r
- Status = EblMtftp (\r
- EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,\r
- File->Buffer,\r
- TRUE,\r
- &TftpBufferSize,\r
- NULL,\r
- &File->ServerIp,\r
- (UINT8 *)File->FileName,\r
- NULL,\r
- FALSE\r
- );\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_WRITE_FILE: %r\n", Status);\r
- return Status;\r
- }\r
- }\r
-\r
- if ((File->Type == EfiOpenLoadFile) ||\r
- ((File->Type == EfiOpenTftp) && (File->IsBufferValid == TRUE)) ||\r
- ((File->Type == EfiOpenFirmwareVolume) && (File->IsBufferValid == TRUE))) {\r
- EblFreePool(File->Buffer);\r
- }\r
-\r
- EblFreePool (File->DevicePath);\r
- EblFreePool (File->DeviceName);\r
- EblFreePool (File->FsFileInfo);\r
- EblFreePool (File->FsInfo);\r
-\r
- if (File->FsFileHandle != NULL) {\r
- File->FsFileHandle->Close (File->FsFileHandle);\r
- }\r
-\r
- // Need to free File and it's Guard structures\r
- EblFreePool (BASE_CR (File, EFI_OPEN_FILE_GUARD, File));\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-Return the size of the file represented by Stream. Also return the current\r
-Seek position. Opening a file will enable a valid file size to be returned.\r
-LoadFile is an exception as a load file size is set to zero.\r
-\r
-@param Stream Open File Handle\r
-\r
-@return 0 Stream is not an Open File or a valid LoadFile handle\r
-\r
-**/\r
-UINTN\r
-EfiTell (\r
- IN EFI_OPEN_FILE *File,\r
- OUT EFI_LBA *CurrentPosition OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT64 BufferSize = 0;\r
-\r
- if (!FileHandleValid (File)) {\r
- return 0;\r
- }\r
-\r
- if (CurrentPosition != NULL) {\r
- *CurrentPosition = File->CurrentPosition;\r
- }\r
-\r
- if (File->Type == EfiOpenLoadFile) {\r
- // Figure out the File->Size\r
- File->Buffer = NULL;\r
- File->Size = 0;\r
- Status = File->LoadFile->LoadFile (File->LoadFile, File->DevicePath, FALSE, &File->Size, File->Buffer);\r
- if (Status != EFI_BUFFER_TOO_SMALL) {\r
- return 0;\r
- }\r
-\r
- File->MaxPosition = (UINT64)File->Size;\r
- } else if (File->Type == EfiOpenTftp) {\r
-\r
- Status = EblMtftp (\r
- EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,\r
- NULL,\r
- FALSE,\r
- &BufferSize,\r
- NULL,\r
- &File->ServerIp,\r
- (UINT8 *)File->FileName,\r
- NULL,\r
- TRUE\r
- );\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_GET_FILE_SIZE: %r\n", Status);\r
- return 0;\r
- }\r
-\r
- File->Size = (UINTN)BufferSize;\r
- File->MaxPosition = File->Size;\r
- }\r
-\r
- return File->Size;\r
-}\r
-\r
-\r
-/**\r
-Seek to the Offset location in the file. LoadFile and FV device types do\r
-not support EfiSeek(). It is not possible to grow the file size using\r
-EfiSeek().\r
-\r
-SeekType defines how use Offset to calculate the new file position:\r
-EfiSeekStart : Position = Offset\r
-EfiSeekCurrent: Position is Offset bytes from the current position\r
-EfiSeekEnd : Only supported if Offset is zero to seek to end of file.\r
-\r
-@param Stream Open File Handle\r
-@param Offset Offset to seek too.\r
-@param SeekType Type of seek to perform\r
-\r
-\r
-@return EFI_INVALID_PARAMETER Stream is not an Open File\r
-@return EFI_UNSUPPORTED LoadFile and FV do not support Seek\r
-@return EFI_NOT_FOUND Seek past the end of the file.\r
-@return EFI_SUCCESS Steam closed\r
-\r
-**/\r
-EFI_STATUS\r
-EfiSeek (\r
- IN EFI_OPEN_FILE *File,\r
- IN EFI_LBA Offset,\r
- IN EFI_SEEK_TYPE SeekType\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT64 CurrentPosition;\r
-\r
- if (!FileHandleValid (File)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (File->Type == EfiOpenLoadFile) {\r
- // LoadFile does not support Seek\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- CurrentPosition = File->CurrentPosition;\r
- switch (SeekType) {\r
- case EfiSeekStart:\r
- if (Offset > File->MaxPosition) {\r
- return EFI_NOT_FOUND;\r
- }\r
- CurrentPosition = Offset;\r
- break;\r
-\r
- case EfiSeekCurrent:\r
- if ((File->CurrentPosition + Offset) > File->MaxPosition) {\r
- return EFI_NOT_FOUND;\r
- }\r
- CurrentPosition += Offset;\r
- break;\r
-\r
- case EfiSeekEnd:\r
- if (Offset != 0) {\r
- // We don't support growing file size via seeking past end of file\r
- return EFI_UNSUPPORTED;\r
- }\r
- CurrentPosition = File->MaxPosition;\r
- break;\r
-\r
- default:\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Status = EFI_SUCCESS;\r
- if (File->FsFileHandle != NULL) {\r
- Status = File->FsFileHandle->SetPosition (File->FsFileHandle, CurrentPosition);\r
- }\r
-\r
- if (!EFI_ERROR (Status)) {\r
- File->CurrentPosition = CurrentPosition;\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-EFI_STATUS\r
-CacheTftpFile (\r
- IN OUT EFI_OPEN_FILE *File\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT64 TftpBufferSize;\r
-\r
- if (File->IsBufferValid) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- // Make sure the file size is set.\r
- EfiTell (File, NULL);\r
-\r
- //Allocate a buffer to hold the whole file.\r
- File->Buffer = AllocatePool(File->Size);\r
- if (File->Buffer == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- TftpBufferSize = File->Size;\r
-\r
- Status = EblMtftp (\r
- EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r
- File->Buffer,\r
- FALSE,\r
- &TftpBufferSize,\r
- NULL,\r
- &File->ServerIp,\r
- (UINT8 *)File->FileName,\r
- NULL,\r
- FALSE);\r
- if (EFI_ERROR(Status)) {\r
- AsciiPrint("TFTP error during APPLE_NSP_TFTP_READ_FILE: %r\n", Status);\r
- FreePool(File->Buffer);\r
- return Status;\r
- }\r
-\r
- // Set the buffer valid flag.\r
- File->IsBufferValid = TRUE;\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
-Read BufferSize bytes from the current location in the file. For load file,\r
-FV, and TFTP case you must read the entire file.\r
-\r
-@param Stream Open File Handle\r
-@param Buffer Caller allocated buffer.\r
-@param BufferSize Size of buffer in bytes.\r
-\r
-\r
-@return EFI_SUCCESS Stream is not an Open File\r
-@return EFI_END_OF_FILE Tried to read past the end of the file\r
-@return EFI_INVALID_PARAMETER Stream is not an open file handle\r
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read\r
-@return "other" Error returned from device read\r
-\r
-**/\r
-EFI_STATUS\r
-EfiRead (\r
- IN EFI_OPEN_FILE *File,\r
- OUT VOID *Buffer,\r
- OUT UINTN *BufferSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT32 AuthenticationStatus;\r
- EFI_DISK_IO_PROTOCOL *DiskIo;\r
-\r
- if (!FileHandleValid (File)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- // Don't read past the end of the file.\r
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {\r
- return EFI_END_OF_FILE;\r
- }\r
-\r
- switch (File->Type) {\r
- case EfiOpenLoadFile:\r
- // Figure out the File->Size\r
- EfiTell (File, NULL);\r
-\r
- Status = File->LoadFile->LoadFile (File->LoadFile, File->DevicePath, FALSE, BufferSize, Buffer);\r
- break;\r
-\r
- case EfiOpenFirmwareVolume:\r
- if (CompareGuid (&File->FvNameGuid, &gZeroGuid)) {\r
- // This is the entire FV device, so treat like a memory buffer\r
- CopyMem (Buffer, (VOID *)(UINTN)(File->FvStart + File->CurrentPosition), *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
- Status = EFI_SUCCESS;\r
- } else {\r
- if (File->Buffer == NULL) {\r
- if (File->FvSectionType == EFI_SECTION_ALL) {\r
- Status = File->Fv->ReadFile (\r
- File->Fv,\r
- &File->FvNameGuid,\r
- (VOID **)&File->Buffer,\r
- &File->Size,\r
- &File->FvType,\r
- &File->FvAttributes,\r
- &AuthenticationStatus\r
- );\r
- } else {\r
- Status = File->Fv->ReadSection (\r
- File->Fv,\r
- &File->FvNameGuid,\r
- File->FvSectionType,\r
- 0,\r
- (VOID **)&File->Buffer,\r
- &File->Size,\r
- &AuthenticationStatus\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- File->IsBufferValid = TRUE;\r
- }\r
- // Operate on the cached buffer so Seek will work\r
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
- Status = EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case EfiOpenMemoryBuffer:\r
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
- Status = EFI_SUCCESS;\r
- break;\r
-\r
- case EfiOpenFileSystem:\r
- Status = File->FsFileHandle->Read (File->FsFileHandle, BufferSize, Buffer);\r
- File->CurrentPosition += *BufferSize;\r
- break;\r
-\r
- case EfiOpenBlockIo:\r
- Status = gBS->HandleProtocol(File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);\r
- if (!EFI_ERROR(Status)) {\r
- Status = DiskIo->ReadDisk(DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);\r
- }\r
- File->CurrentPosition += *BufferSize;\r
- break;\r
-\r
- case EfiOpenTftp:\r
- // Cache the file if it hasn't been cached yet.\r
- if (File->IsBufferValid == FALSE) {\r
- Status = CacheTftpFile (File);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- }\r
-\r
- // Copy out the requested data\r
- CopyMem (Buffer, File->Buffer + File->CurrentPosition, *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
-\r
- Status = EFI_SUCCESS;\r
- break;\r
-\r
- default:\r
- return EFI_INVALID_PARAMETER;\r
- };\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
-Read the entire file into a buffer. This routine allocates the buffer and\r
-returns it to the user full of the read data.\r
-\r
-This is very useful for load file where it's hard to know how big the buffer\r
-must be.\r
-\r
-@param Stream Open File Handle\r
-@param Buffer Pointer to buffer to return.\r
-@param BufferSize Pointer to Size of buffer return..\r
-\r
-\r
-@return EFI_SUCCESS Stream is not an Open File\r
-@return EFI_END_OF_FILE Tried to read past the end of the file\r
-@return EFI_INVALID_PARAMETER Stream is not an open file handle\r
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read\r
-@return "other" Error returned from device read\r
-\r
-**/\r
-EFI_STATUS\r
-EfiReadAllocatePool (\r
- IN EFI_OPEN_FILE *File,\r
- OUT VOID **Buffer,\r
- OUT UINTN *BufferSize\r
- )\r
-{\r
- if (!FileHandleValid (File)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- // Loadfile defers file size determination on Open so use tell to find it\r
- EfiTell (File, NULL);\r
-\r
- *BufferSize = File->Size;\r
- *Buffer = AllocatePool (*BufferSize);\r
- if (*Buffer == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- return EfiRead (File, *Buffer, BufferSize);\r
-}\r
-\r
-\r
-/**\r
-Write data back to the file. For TFTP case you must write the entire file.\r
-\r
-@param Stream Open File Handle\r
-@param Buffer Pointer to buffer to return.\r
-@param BufferSize Pointer to Size of buffer return..\r
-\r
-\r
-@return EFI_SUCCESS Stream is not an Open File\r
-@return EFI_END_OF_FILE Tried to read past the end of the file\r
-@return EFI_INVALID_PARAMETER Stream is not an open file handle\r
-@return EFI_BUFFER_TOO_SMALL Buffer is not big enough to do the read\r
-@return "other" Error returned from device write\r
-\r
-**/\r
-EFI_STATUS\r
-EfiWrite (\r
- IN EFI_OPEN_FILE *File,\r
- OUT VOID *Buffer,\r
- OUT UINTN *BufferSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_FV_WRITE_FILE_DATA FileData;\r
- EFI_DISK_IO_PROTOCOL *DiskIo;\r
-\r
- if (!FileHandleValid (File)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- switch (File->Type) {\r
- case EfiOpenMemoryBuffer:\r
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {\r
- return EFI_END_OF_FILE;\r
- }\r
-\r
- CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
- Status = EFI_SUCCESS;\r
-\r
- case EfiOpenLoadFile:\r
- // LoadFile device is read only be definition\r
- Status = EFI_UNSUPPORTED;\r
-\r
- case EfiOpenFirmwareVolume:\r
- if (File->FvSectionType != EFI_SECTION_ALL) {\r
- // Writes not support to a specific section. You have to update entire file\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- FileData.NameGuid = &(File->FvNameGuid);\r
- FileData.Type = File->FvType;\r
- FileData.FileAttributes = File->FvAttributes;\r
- FileData.Buffer = Buffer;\r
- FileData.BufferSize = (UINT32)*BufferSize;\r
- Status = File->Fv->WriteFile (File->Fv, 1, EFI_FV_UNRELIABLE_WRITE, &FileData);\r
- break;\r
-\r
- case EfiOpenFileSystem:\r
- Status = File->FsFileHandle->Write (File->FsFileHandle, BufferSize, Buffer);\r
- File->CurrentPosition += *BufferSize;\r
- break;\r
-\r
- case EfiOpenBlockIo:\r
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {\r
- return EFI_END_OF_FILE;\r
- }\r
-\r
- Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);\r
- if (!EFI_ERROR(Status)) {\r
- Status = DiskIo->WriteDisk (DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);\r
- }\r
- File->CurrentPosition += *BufferSize;\r
- break;\r
-\r
- case EfiOpenTftp:\r
- // Cache the file if it hasn't been cached yet.\r
- if (File->IsBufferValid == FALSE) {\r
- Status = CacheTftpFile(File);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
- }\r
-\r
- // Don't overwrite the buffer\r
- if ((File->CurrentPosition + *BufferSize) > File->MaxPosition) {\r
- UINT8 *TempBuffer;\r
-\r
- TempBuffer = File->Buffer;\r
-\r
- File->Buffer = AllocatePool ((UINTN)(File->CurrentPosition + *BufferSize));\r
- if (File->Buffer == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CopyMem (File->Buffer, TempBuffer, File->Size);\r
-\r
- FreePool (TempBuffer);\r
-\r
- File->Size = (UINTN)(File->CurrentPosition + *BufferSize);\r
- File->MaxPosition = (UINT64)File->Size;\r
- }\r
-\r
- // Copy in the requested data\r
- CopyMem (File->Buffer + File->CurrentPosition, Buffer, *BufferSize);\r
- File->CurrentPosition += *BufferSize;\r
-\r
- // Mark the file dirty\r
- File->IsDirty = TRUE;\r
-\r
- Status = EFI_SUCCESS;\r
- break;\r
-\r
- default:\r
- Status = EFI_INVALID_PARAMETER;\r
- };\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
-Given Cwd expand Path to remove .. and replace them with real\r
-directory names.\r
-\r
-@param Cwd Current Working Directory\r
-@param Path Path to expand\r
-\r
-@return NULL Cwd or Path are not valid\r
-@return 'other' Path with .. expanded\r
-\r
-**/\r
-CHAR8 *\r
-ExpandPath (\r
- IN CHAR8 *Cwd,\r
- IN CHAR8 *Path\r
- )\r
-{\r
- CHAR8 *NewPath;\r
- CHAR8 *Work, *Start, *End;\r
- UINTN StrLen, AllocLen;\r
- INTN i;\r
-\r
- if (Cwd == NULL || Path == NULL) {\r
- return NULL;\r
- }\r
-\r
- StrLen = AsciiStrSize (Cwd);\r
- if (StrLen <= 2) {\r
- // Smallest valid path is 1 char and a null\r
- return NULL;\r
- }\r
-\r
- StrLen = AsciiStrSize (Path);\r
- AllocLen = AsciiStrSize (Cwd) + StrLen + 1;\r
- NewPath = AllocatePool (AllocLen);\r
- if (NewPath == NULL) {\r
- return NULL;\r
- }\r
- AsciiStrCpyS (NewPath, AllocLen, Cwd);\r
-\r
- End = Path + StrLen;\r
- for (Start = Path ;;) {\r
- Work = AsciiStrStr (Start, "..") ;\r
- if (Work == NULL) {\r
- // Remaining part of Path contains no more ..\r
- break;\r
- }\r
-\r
- // append path prior to ..\r
- AsciiStrnCatS (NewPath, AllocLen, Start, Work - Start);\r
- StrLen = AsciiStrLen (NewPath);\r
- for (i = StrLen; i >= 0; i--) {\r
- if (NewPath[i] == ':') {\r
- // too many ..\r
- return NULL;\r
- }\r
- if (NewPath[i] == '/' || NewPath[i] == '\\') {\r
- if ((i > 0) && (NewPath[i-1] == ':')) {\r
- // leave the / before a :\r
- NewPath[i+1] = '\0';\r
- } else {\r
- // replace / will Null to remove trailing file/dir reference\r
- NewPath[i] = '\0';\r
- }\r
- break;\r
- }\r
- }\r
-\r
- Start = Work + 3;\r
- }\r
-\r
- // Handle the path that remains after the ..\r
- AsciiStrnCatS (NewPath, AllocLen, Start, End - Start);\r
-\r
- return NewPath;\r
-}\r
-\r
-\r
-/**\r
-Set the Current Working Directory (CWD). If a call is made to EfiOpen () and\r
-the path does not contain a device name, The CWD is prepended to the path.\r
-\r
-@param Cwd Current Working Directory to set\r
-\r
-\r
-@return EFI_SUCCESS CWD is set\r
-@return EFI_INVALID_PARAMETER Cwd is not a valid device:path\r
-\r
-**/\r
-EFI_STATUS\r
-EfiSetCwd (\r
- IN CHAR8 *Cwd\r
- )\r
-{\r
- EFI_OPEN_FILE *File;\r
- UINTN Len, AllocLen;\r
- CHAR8 *Path;\r
-\r
- if (Cwd == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (AsciiStrCmp (Cwd, ".") == 0) {\r
- // cd . is a no-op\r
- return EFI_SUCCESS;\r
- }\r
-\r
- Path = Cwd;\r
- if (AsciiStrStr (Cwd, "..") != NULL) {\r
- if (gCwd == NULL) {\r
- // no parent\r
- return EFI_SUCCESS;\r
- }\r
-\r
- Len = AsciiStrLen (gCwd);\r
- if ((gCwd[Len-2] == ':') && ((gCwd[Len-1] == '/') || (gCwd[Len-1] == '\\'))) {\r
- // parent is device so nothing to do\r
- return EFI_SUCCESS;\r
- }\r
-\r
- // Expand .. in Cwd, given we know current working directory\r
- Path = ExpandPath (gCwd, Cwd);\r
- if (Path == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
- }\r
-\r
- File = EfiOpen (Path, EFI_FILE_MODE_READ, 0);\r
- if (File == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (gCwd != NULL) {\r
- FreePool (gCwd);\r
- }\r
-\r
- // Use the info returned from EfiOpen as it can add in CWD if needed. So Cwd could be\r
- // relative to the current gCwd or not.\r
- AllocLen = AsciiStrSize (File->DeviceName) + AsciiStrSize (File->FileName) + 10;\r
- gCwd = AllocatePool (AllocLen);\r
- if (gCwd == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- AsciiStrCpyS (gCwd, AllocLen, File->DeviceName);\r
- if (File->FileName == NULL) {\r
- AsciiStrCatS (gCwd, AllocLen, ":\\");\r
- } else {\r
- AsciiStrCatS (gCwd, AllocLen, ":");\r
- AsciiStrCatS (gCwd, AllocLen, File->FileName);\r
- }\r
-\r
-\r
- EfiClose (File);\r
- if (Path != Cwd) {\r
- FreePool (Path);\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-Set the Current Working Directory (CWD). If a call is made to EfiOpen () and\r
-the path does not contain a device name, The CWD is prepended to the path.\r
-The CWD buffer is only valid until a new call is made to EfiSetCwd(). After\r
-a call to EfiSetCwd() it is not legal to use the pointer returned by\r
-this function.\r
-\r
-@param Cwd Current Working Directory\r
-\r
-\r
-@return "" No CWD set\r
-@return 'other' Returns buffer that contains CWD.\r
-\r
-**/\r
-CHAR8 *\r
-EfiGetCwd (\r
- VOID\r
- )\r
-{\r
- if (gCwd == NULL) {\r
- return "";\r
- }\r
- return gCwd;\r
-}\r
-\r
-\r
+++ /dev/null
-#/** @file\r
-# Component description file for the entry point to a EFIDXE Drivers\r
-#\r
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification\r
-# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = EfiFileLib\r
- FILE_GUID = d8c640db-73ba-48f5-a7ed-8e93c6012491\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = EfiFileLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- EfiFileLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- IntelFrameworkPkg/IntelFrameworkPkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- MemoryAllocationLib\r
- DevicePathLib\r
- PrintLib\r
- BaseMemoryLib\r
- UefiLib\r
- UefiBootServicesTableLib\r
- UefiRuntimeServicesTableLib\r
- DebugLib\r
- EblNetworkLib\r
-\r
-[Protocols]\r
- gEfiBlockIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
- gEfiDiskIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
- gEfiSimpleFileSystemProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
- gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
- gEfiLoadFileProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
- gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_CONSUMED\r
-\r
-[Guids]\r
- gEfiFileInfoGuid\r
- gEfiFileSystemInfoGuid\r
- gZeroGuid\r
+++ /dev/null
-/** @file\r
- Add custom commands for BeagleBoard development.\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Library/ArmLib.h>\r
-#include <Library/CacheMaintenanceLib.h>\r
-#include <Library/EblCmdLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/EfiFileLib.h>\r
-\r
-\r
-//PcdEmbeddedFdBaseAddress\r
-\r
-/**\r
- Fill Me In\r
-\r
- Argv[0] - "%CommandName%"\r
-\r
- @param Argc Number of command arguments in Argv\r
- @param Argv Array of strings that represent the parsed command line.\r
- Argv[0] is the command name\r
-\r
- @return EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EblEdk2Cmd (\r
- IN UINTN Argc,\r
- IN CHAR8 **Argv\r
- )\r
-{\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =\r
-{\r
- {\r
- "edk2",\r
- " filename ; Load FD into memory and boot from it",\r
- NULL,\r
- EblEdk2Cmd\r
- }\r
-};\r
-\r
-\r
-VOID\r
-EblInitializeExternalCmd (\r
- VOID\r
- )\r
-{\r
- EblAddCommands (mLibCmdTemplate, sizeof (mLibCmdTemplate)/sizeof (EBL_COMMAND_TABLE));\r
- return;\r
-}\r
+++ /dev/null
-#/** @file\r
-# Component description file for the entry point to a EFIDXE Drivers\r
-#\r
-# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification\r
-# Copyright (c) 2007 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = BeagleBoardEblCmdLib\r
- FILE_GUID = ea62bdc3-1063-425f-8851-98cb47f213a8\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = EblCmdLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- EblCmdLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
- ArmPkg/ArmPkg.dec\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- DebugLib\r
-\r
-[Protocols]\r
-\r
-[Guids]\r
-\r
-[Pcd]\r
\r
Omap35xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf\r
Omap35xxPkg/Library/DebugAgentTimerLib/DebugAgentTimerLib.inf\r
- Omap35xxPkg/Library/EblCmdLib/EblCmdLib.inf\r
Omap35xxPkg/Library/GdbSerialLib/GdbSerialLib.inf\r
Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.inf\r
Omap35xxPkg/Library/SerialPortLib/SerialPortLib.inf\r