Report the setting variable failure to platform through the status code when core...
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 25 Mar 2014 03:54:34 +0000 (03:54 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Mar 2014 03:54:34 +0000 (03:54 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Elvin Li <elvin.li@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15386 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

index a270908..5110948 100644 (file)
@@ -1422,11 +1422,13 @@ TerminalUpdateConsoleDevVariable (
   )\r
 {\r
   EFI_STATUS                Status;\r
+  UINTN                     NameSize;\r
   UINTN                     VariableSize;\r
   UINT8                     TerminalType;\r
   EFI_DEVICE_PATH_PROTOCOL  *Variable;\r
   EFI_DEVICE_PATH_PROTOCOL  *NewVariable;\r
   EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EDKII_SET_VARIABLE_STATUS *SetVariableStatus;\r
 \r
   //\r
   // Get global variable and its size according to the name given.\r
@@ -1462,6 +1464,33 @@ TerminalUpdateConsoleDevVariable (
                   VariableSize,\r
                   Variable\r
                   );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    NameSize = StrSize (VariableName);\r
+    SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + VariableSize);\r
+    if (SetVariableStatus != NULL) {\r
+      CopyGuid (&SetVariableStatus->Guid, &gEfiGlobalVariableGuid);\r
+      SetVariableStatus->NameSize   = NameSize;\r
+      SetVariableStatus->DataSize   = VariableSize;\r
+      SetVariableStatus->SetStatus  = Status;\r
+      SetVariableStatus->Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;\r
+      CopyMem (SetVariableStatus + 1,                          VariableName, NameSize);\r
+      CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Variable,     VariableSize);\r
+\r
+      REPORT_STATUS_CODE_EX (\r
+        EFI_ERROR_CODE,\r
+        PcdGet32 (PcdErrorCodeSetVariable),\r
+        0,\r
+        NULL,\r
+        &gEdkiiStatusCodeDataTypeVariableGuid,\r
+        SetVariableStatus,\r
+        sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + VariableSize\r
+        );\r
+\r
+      FreePool (SetVariableStatus);\r
+    }\r
+  }\r
+\r
   FreePool (Variable);\r
 \r
   return ;\r
@@ -1569,6 +1598,10 @@ TerminalRemoveConsoleDevVariable (
                     VariableSize,\r
                     NewVariable\r
                     );\r
+    //\r
+    // Shrinking variable with existing variable driver implementation shouldn't fail.\r
+    //\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   if (NewVariable != NULL) {\r
index 0f285eb..d393acb 100644 (file)
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/PcAnsi.h>\r
+#include <Guid/StatusCodeDataTypeVariable.h>\r
 \r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/SerialIo.h>\r
index d4bd55b..6611751 100644 (file)
@@ -4,7 +4,7 @@
 #\r
 #  This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).\r
 #\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2014, 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
@@ -65,6 +65,7 @@
   gEfiVT100Guid                                 ## SOMETIMES_CONSUMES ## GUID\r
   gEfiVT100PlusGuid                             ## SOMETIMES_CONSUMES ## GUID\r
   gEfiPcAnsiGuid                                ## SOMETIMES_CONSUMES ## GUID\r
+  gEdkiiStatusCodeDataTypeVariableGuid          ## SOMETIMES_CONSUMES ## GUID\r
 \r
 [Protocols]\r
   gEfiSerialIoProtocolGuid                      ## TO_START\r
@@ -75,6 +76,7 @@
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable\r
 \r
 # [Event]\r
 #   ##\r