]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix EBL GetCurrentIpAddress & GetCurrentMacAddress commands. Add variable services...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Feb 2011 05:37:22 +0000 (05:37 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Feb 2011 05:37:22 +0000 (05:37 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11290 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Ebl/Ebl.h
EmbeddedPkg/Ebl/Ebl.inf
EmbeddedPkg/Ebl/Main.c
EmbeddedPkg/Ebl/Variable.c [new file with mode: 0644]
EmbeddedPkg/EmbeddedPkg.dec
EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.c
EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S

index 04f75d0f76cb12ef2c80611635b2fd76116944a7..5c322e5e9735c85e6089047690e0d2c822bdd29e 100644 (file)
@@ -165,6 +165,11 @@ EblInitializeNetworkCmd (
   VOID
   );
 
+VOID
+EblInitializeVariableCmds (
+  VOID
+  );
+
 CHAR8 *
 ParseArguments (
   IN  CHAR8  *CmdLine,
index 44bab64b078fa14d0a10e394308f2256eeb6bc22..7c302337a523b8a0be64a1a9f9a27149cc2dc1b1 100644 (file)
@@ -43,6 +43,7 @@
   Script.c\r
   Ebl.h\r
   Network.c\r
+  Variable.c\r
   \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index 98097e4be1a726438a7d8b944784ef83809c1b38..8f6f4ea9e1579fbf06c10fe95471936738b14c46 100644 (file)
@@ -187,7 +187,7 @@ ParseArguments (
       break;\r
     }\r
 \r
-    // Perform any text coversion here\r
+    // Perform any text conversion here\r
     if (*Char == '\t') {\r
       // TAB to space\r
       *Char = ' ';\r
@@ -205,9 +205,14 @@ ParseArguments (
       } \r
     } else {\r
       // Looking for the terminator of an Argv[] entry\r
-      if ((InQuote && (*Char == '"')) || (!InQuote && (*Char == ' '))) {\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
@@ -597,6 +602,7 @@ EdkBootLoaderEntry (
   EblInitializeScriptCmd ();\r
   EblInitializeExternalCmd ();\r
   EblInitializeNetworkCmd();\r
+  EblInitializeVariableCmds ();\r
   \r
   // Disable the 5 minute EFI watchdog time so we don't get automatically reset\r
   gBS->SetWatchdogTimer (0, 0, 0, NULL);\r
diff --git a/EmbeddedPkg/Ebl/Variable.c b/EmbeddedPkg/Ebl/Variable.c
new file mode 100644 (file)
index 0000000..330a143
--- /dev/null
@@ -0,0 +1,192 @@
+/** @file
+*
+*  Copyright (c) 2011, ARM Limited. All rights reserved.
+*  
+*  This program and the accompanying materials                          
+*  are licensed and made available under the terms and conditions of the BSD License         
+*  which accompanies this distribution.  The full text of the license may be found at        
+*  http://opensource.org/licenses/bsd-license.php                                            
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+*
+**/
+\r
+#include "Ebl.h"\r
+
+#include <Guid/GlobalVariable.h>
+\r
+EFI_STATUS\r
+EblGetCmd (\r
+  IN UINTN  Argc,\r
+  IN CHAR8  **Argv\r
+  )\r
+{\r
+  EFI_STATUS        Status = EFI_INVALID_PARAMETER;\r
+  UINTN       Size;
+  VOID*       Value;
+  CHAR8*      AsciiVariableName = NULL;
+  CHAR16*     VariableName;
+  UINT32      Index;
+
+  if (Argc == 1) {
+    AsciiPrint("Variable name is missing.\n");
+    return Status;
+  }
+
+  for (Index = 1; Index < Argc; Index++) {
+    if (Argv[Index][0] == '-') {
+      AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);
+    } else {
+      AsciiVariableName = Argv[Index];
+    }
+  }
+
+  if (AsciiVariableName == NULL) {
+    AsciiPrint("Variable name is missing.\n");
+    return Status;
+  } else {
+    VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
+    AsciiStrToUnicodeStr (AsciiVariableName,VariableName);
+  }
+
+  // Try to get the variable size.
+  Value = NULL;
+  Size = 0;
+  Status = gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);
+  if (Status == EFI_NOT_FOUND) {
+    AsciiPrint("Variable name '%a' not found.\n",VariableName);
+  } else if (Status == EFI_BUFFER_TOO_SMALL) {
+    // Get the environment variable value
+    Value = AllocatePool (Size);
+    if (Value == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+
+    Status = gRT->GetVariable ((CHAR16 *)VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);
+    if (EFI_ERROR (Status)) {
+      AsciiPrint("Error: '%r'\n",Status);
+    } else {
+      AsciiPrint("%a=%a\n",AsciiVariableName,Value);
+    }
+    FreePool(Value);
+  } else {
+    AsciiPrint("Error: '%r'\n",Status);
+  }\r
+\r
+  FreePool(VariableName);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EblSetCmd (\r
+  IN UINTN  Argc,\r
+  IN CHAR8  **Argv\r
+  )\r
+{\r
+  EFI_STATUS    Status = EFI_INVALID_PARAMETER;\r
+  CHAR8*        AsciiVariableSetting = NULL;
+  CHAR8*        AsciiVariableName;
+  CHAR8*        AsciiValue;
+  UINT32        AsciiValueLength;
+  CHAR16*       VariableName;
+  UINT32        Index;\r
+  UINT32        EscapedQuotes = 0;\r
+  BOOLEAN       Volatile = FALSE;\r
+\r
+  if (Argc == 1) {
+    AsciiPrint("Variable name is missing.\n");
+    return Status;
+  }
+
+  for (Index = 1; Index < Argc; Index++) {
+    if (AsciiStrCmp(Argv[Index],"-v") == 0) {
+      Volatile = 0;
+    } else if (Argv[Index][0] == '-') {
+      AsciiPrint("Warning: '%a' not recognized.\n",Argv[Index]);
+    } else {
+      AsciiVariableSetting = Argv[Index];
+    }
+  }
+
+  if (AsciiVariableSetting == NULL) {
+    AsciiPrint("Variable name is missing.\n");
+    return Status;
+  }
+  
+  // Check if it is a valid variable setting
+  AsciiValue = AsciiStrStr (AsciiVariableSetting,"=");\r
+  if (AsciiValue == NULL) {
+    AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n");
+    return Status;
+  }\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
+  VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
+  AsciiStrToUnicodeStr (AsciiVariableName,VariableName);\r
+\r
+  Status = gRT->SetVariable (
+                      VariableName,
+                      &gEfiGlobalVariableGuid,
+                      ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |
+                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                      AsciiStrLen (AsciiValue)+1,
+                      AsciiValue
+                      );\r
+\r
+  AsciiPrint("'%a'='%a'\n",AsciiVariableName,AsciiValue);\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
index ca83ad93e423ac9e316896cab4d79dc85c111acb..714242fc6ee506847fac919346f0526be4ef5c9d 100644 (file)
   gEmbeddedTokenSpaceGuid.PcdEmbeddedIoEnable|FALSE|BOOLEAN|0x00000005\r
   gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE|BOOLEAN|0x00000006\r
   gEmbeddedTokenSpaceGuid.PcdEmbeddedPciDebugCmd|FALSE|BOOLEAN|0x00000041\r
-  gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable|TRUE|BOOLEAN|0x00000050\r
+  gEmbeddedTokenSpaceGuid.PcdEmbeddedProbeRemovable|TRUE|BOOLEAN|0x00000052\r
   \r
   gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x0000001b\r
   gEmbeddedTokenSpaceGuid.PcdCacheEnable|FALSE|BOOLEAN|0x00000042\r
-  gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x00000051\r
+  gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x00000053\r
 \r
 \r
 [PcdsFixedAtBuild.common]\r
@@ -94,6 +94,9 @@
   gEmbeddedTokenSpaceGuid.PcdFlashFvMainOffset|0x0|UINT32|0x00000044\r
   gEmbeddedTokenSpaceGuid.PcdFlashFvMainSize|0x0|UINT32|0x00000045\r
 \r
+  gEmbeddedTokenSpaceGuid.PcdFlashFvSecBase|0x0|UINT32|0x00000050\r
+  gEmbeddedTokenSpaceGuid.PcdFlashFvSecSize|0x0|UINT32|0x00000051\r
+\r
   \r
 # Used to help reduce fragmentation in the EFI memory map\r
 # EFI Pages (4K) are the units used\r
index c5fdb34ad1e94961c86bc4d668e71704d85f6a41..0edd5d018dff071ef923d109f33b1dba377b8075 100644 (file)
@@ -45,7 +45,7 @@ EblGetCurrentIpAddress (
 
   CopyMem (Ip, &Pxe->Mode->StationIp, sizeof (EFI_IP_ADDRESS));
 
-  return Status;
+  return EFI_SUCCESS;
 }
 
 
@@ -63,7 +63,7 @@ EblGetCurrentMacAddress (
     return Status;
   }
 
-  CopyMem (SimpleNet->Mode->CurrentAddress.Addr, Mac, sizeof (EFI_MAC_ADDRESS));
+  CopyMem (Mac, SimpleNet->Mode->CurrentAddress.Addr, sizeof (EFI_MAC_ADDRESS));
   return Status;
 }
 
index 2682581ea9d2777f9ceb8f2901d0f8e1e10c9f20..f8c4e296ca354fdcaa0e6481617c41803a3d80a6 100755 (executable)
@@ -50,16 +50,11 @@ This is the stack constructed by the exception handler (low address to high addr
  */
  
 
-.globl ASM_PFX(ExceptionHandlersStart)
-INTERWORK_FUNC(ExceptionHandlersStart)
-.globl ASM_PFX(ExceptionHandlersEnd)
-INTERWORK_FUNC(ExceptionHandlersEnd)
-.globl ASM_PFX(CommonExceptionEntry)
-INTERWORK_FUNC(CommonExceptionEntry)
-.globl ASM_PFX(AsmCommonExceptionEntry)
-INTERWORK_FUNC(AsmCommonExceptionEntry)
-.globl ASM_PFX(GdbExceptionHandler)
-INTERWORK_FUNC(GdbExceptionHandler)
+GCC_ASM_EXPORT(ExceptionHandlersStart)
+GCC_ASM_EXPORT(ExceptionHandlersEnd)
+GCC_ASM_EXPORT(CommonExceptionEntry)
+GCC_ASM_EXPORT(AsmCommonExceptionEntry)
+GCC_ASM_EXPORT(GdbExceptionHandler)
 
 .text
 .align 3