]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Ebl/Variable.c
ArmPlatformPkg: Remove PcdStandalone from Sec module and Introduce ArmPlatformSecExtr...
[mirror_edk2.git] / EmbeddedPkg / Ebl / Variable.c
index 3fd688bee11943eff00bdb34e85d47368ddcb772..5c00122cdb16e6c5b1611eeea69073c1827bee46 100644 (file)
@@ -1,20 +1,20 @@
-/** @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.             
-*
-**/
+/** @file\r
+*\r
+*  Copyright (c) 2011, ARM Limited. All rights reserved.\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 <Guid/GlobalVariable.h>
+\r
+#include <Guid/GlobalVariable.h>\r
 \r
 EFI_STATUS\r
 EblGetCmd (\r
@@ -23,55 +23,55 @@ EblGetCmd (
   )\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 '%s' 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);
+  UINTN       Size;\r
+  VOID*       Value;\r
+  CHAR8*      AsciiVariableName = NULL;\r
+  CHAR16*     VariableName;\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
+    VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));\r
+    AsciiStrToUnicodeStr (AsciiVariableName,VariableName);\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
@@ -85,60 +85,60 @@ EblSetCmd (
   )\r
 {\r
   EFI_STATUS    Status = EFI_INVALID_PARAMETER;\r
-  CHAR8*        AsciiVariableSetting = NULL;
-  CHAR8*        AsciiVariableName;
-  CHAR8*        AsciiValue;
-  UINT32        AsciiValueLength;
-  CHAR16*       VariableName;
+  CHAR8*        AsciiVariableSetting = NULL;\r
+  CHAR8*        AsciiVariableName;\r
+  CHAR8*        AsciiValue;\r
+  UINT32        AsciiValueLength;\r
+  CHAR16*       VariableName;\r
   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
+  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) {
-    //
-    // There is no value. It means this variable will be deleted
-    //
-
-    // Convert VariableName into Unicode
-    VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16));
-    AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName);
-
-    Status = gRT->SetVariable (
-                          VariableName,
-                          &gEfiGlobalVariableGuid,
-                          ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |
-                          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-                          0,
-                          NULL
-                          );
-    if (!EFI_ERROR(Status)) {
-      AsciiPrint("Variable '%s' deleted\n",VariableName);
-    } else {
-      AsciiPrint("Variable setting is incorrect. It should be VariableName=Value\n");
-    }
-    return Status;
+  if (AsciiValue == NULL) {\r
+    //\r
+    // There is no value. It means this variable will be deleted\r
+    //\r
+\r
+    // Convert VariableName into Unicode\r
+    VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16));\r
+    AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName);\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
@@ -167,20 +167,20 @@ EblSetCmd (
   }\r
 \r
   // Convert VariableName into Unicode\r
-  VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
+  VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));\r
   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
+  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