Revision: 15386
          http://sourceforge.net/p/edk2/code/15386
Author:   niruiyu
Date:     2014-03-25 03:54:34 +0000 (Tue, 25 Mar 2014)
Log Message:
-----------
Report the setting variable failure to platform through the status code when 
core cannot handle the error.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Reviewed-by: Elvin Li <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
    trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
    trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

Modified: trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c    
2014-03-25 02:38:54 UTC (rev 15385)
+++ trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c    
2014-03-25 03:54:34 UTC (rev 15386)
@@ -1422,11 +1422,13 @@
   )
 {
   EFI_STATUS                Status;
+  UINTN                     NameSize;
   UINTN                     VariableSize;
   UINT8                     TerminalType;
   EFI_DEVICE_PATH_PROTOCOL  *Variable;
   EFI_DEVICE_PATH_PROTOCOL  *NewVariable;
   EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;
+  EDKII_SET_VARIABLE_STATUS *SetVariableStatus;
 
   //
   // Get global variable and its size according to the name given.
@@ -1462,6 +1464,33 @@
                   VariableSize,
                   Variable
                   );
+
+  if (EFI_ERROR (Status)) {
+    NameSize = StrSize (VariableName);
+    SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + 
NameSize + VariableSize);
+    if (SetVariableStatus != NULL) {
+      CopyGuid (&SetVariableStatus->Guid, &gEfiGlobalVariableGuid);
+      SetVariableStatus->NameSize   = NameSize;
+      SetVariableStatus->DataSize   = VariableSize;
+      SetVariableStatus->SetStatus  = Status;
+      SetVariableStatus->Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | 
EFI_VARIABLE_RUNTIME_ACCESS;
+      CopyMem (SetVariableStatus + 1,                          VariableName, 
NameSize);
+      CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Variable,     
VariableSize);
+
+      REPORT_STATUS_CODE_EX (
+        EFI_ERROR_CODE,
+        PcdGet32 (PcdErrorCodeSetVariable),
+        0,
+        NULL,
+        &gEdkiiStatusCodeDataTypeVariableGuid,
+        SetVariableStatus,
+        sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + VariableSize
+        );
+
+      FreePool (SetVariableStatus);
+    }
+  }
+
   FreePool (Variable);
 
   return ;
@@ -1569,6 +1598,10 @@
                     VariableSize,
                     NewVariable
                     );
+    //
+    // Shrinking variable with existing variable driver implementation 
shouldn't fail.
+    //
+    ASSERT_EFI_ERROR (Status);
   }
 
   if (NewVariable != NULL) {

Modified: trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h    
2014-03-25 02:38:54 UTC (rev 15385)
+++ trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h    
2014-03-25 03:54:34 UTC (rev 15386)
@@ -20,6 +20,7 @@
 
 #include <Guid/GlobalVariable.h>
 #include <Guid/PcAnsi.h>
+#include <Guid/StatusCodeDataTypeVariable.h>
 
 #include <Protocol/SimpleTextOut.h>
 #include <Protocol/SerialIo.h>

Modified: trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf       
2014-03-25 02:38:54 UTC (rev 15385)
+++ trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf       
2014-03-25 03:54:34 UTC (rev 15386)
@@ -4,7 +4,7 @@
 #
 #  This driver installs Simple Text In/Out protocol for terminal devices 
(serial devices or hotplug devices).
 #
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
 #  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
@@ -65,6 +65,7 @@
   gEfiVT100Guid                                 ## SOMETIMES_CONSUMES ## GUID
   gEfiVT100PlusGuid                             ## SOMETIMES_CONSUMES ## GUID
   gEfiPcAnsiGuid                                ## SOMETIMES_CONSUMES ## GUID
+  gEdkiiStatusCodeDataTypeVariableGuid          ## SOMETIMES_CONSUMES ## GUID
 
 [Protocols]
   gEfiSerialIoProtocolGuid                      ## TO_START
@@ -75,6 +76,7 @@
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType
+  gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable
 
 # [Event]
 #   ##

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to