Revision: 13979
          http://edk2.svn.sourceforge.net/edk2/?rev=13979&view=rev
Author:   lzeng14
Date:     2012-11-29 05:41:51 +0000 (Thu, 29 Nov 2012)
Log Message:
-----------
Fix the issue that S3BootScriptLabel() does not work to insert label when the 
specified position is not at the end of table.

Signed-off-by: Star Zeng <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
    
trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
    trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
    trunk/edk2/MdePkg/Include/Library/S3BootScriptLib.h

Modified: 
trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
===================================================================
--- trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c    
2012-11-29 02:12:32 UTC (rev 13978)
+++ trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c    
2012-11-29 05:41:51 UTC (rev 13979)
@@ -1201,14 +1201,16 @@
 {
   UINT32                        Index;
   EFI_BOOT_SCRIPT_INFORMATION   Information;
+  UINT8                         *InformationData;
 
-  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));
+  CopyMem ((VOID*)&Information, (VOID*)Script, 
sizeof(EFI_BOOT_SCRIPT_INFORMATION));
 
-  DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", 
(UINTN)Information.Information));
+  InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) 
InformationData));
 
   DEBUG ((EFI_D_INFO, "BootScriptInformation: "));
   for (Index = 0; Index < Information.InformationLength; Index++) {
-    DEBUG ((EFI_D_INFO, "%02x ", *(UINT8 *)(UINTN)(Information.Information + 
Index)));
+    DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));
   }
   DEBUG ((EFI_D_INFO, "\n"));
 }
@@ -1227,14 +1229,16 @@
 {
   UINT32                        Index;
   EFI_BOOT_SCRIPT_INFORMATION   Information;
+  UINT8                         *InformationData;
 
-  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));
+  CopyMem ((VOID*)&Information, (VOID*)Script, 
sizeof(EFI_BOOT_SCRIPT_INFORMATION));
 
-  DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", 
(UINTN)Information.Information));
+  InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) 
InformationData));
 
   DEBUG ((EFI_D_INFO, "BootScriptLabel: "));
   for (Index = 0; Index < Information.InformationLength; Index++) {
-    DEBUG ((EFI_D_INFO, "%02x ", *(UINT8 *)(UINTN)(Information.Information + 
Index)));
+    DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));
   }
   DEBUG ((EFI_D_INFO, "\n"));
 }

Modified: 
trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
===================================================================
--- 
trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h 
    2012-11-29 02:12:32 UTC (rev 13978)
+++ 
trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h 
    2012-11-29 05:41:51 UTC (rev 13979)
@@ -2,7 +2,7 @@
   This file declares the internal Framework Boot Script format used by
   the PI implementation of Script Saver and Executor.
 
-  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -144,8 +144,8 @@
 typedef struct {
   UINT16  OpCode;
   UINT8   Length;
-  UINT32                InformationLength;  
-  EFI_PHYSICAL_ADDRESS  Information;
+  UINT32  InformationLength;
+// UINT8   InformationData[InformationLength];
 } EFI_BOOT_SCRIPT_INFORMATION;
 
 typedef struct {

Modified: trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
===================================================================
--- trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       
2012-11-29 02:12:32 UTC (rev 13978)
+++ trunk/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       
2012-11-29 05:41:51 UTC (rev 13979)
@@ -54,10 +54,6 @@
   0x1810ab4a, 0x2314, 0x4df6, { 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91 }
 };
 
-EFI_GUID                         mBootScriptInformationGuid = {
-  0x2c680508, 0x2b87, 0x46ab, { 0xb9, 0x8a, 0x49, 0xfc, 0x23, 0xf9, 0xf5, 0x95 
}
-};
-
 /**
   This is an internal function to add a terminate node the entry, recalculate 
the table 
   length and fill into the table. 
@@ -104,113 +100,6 @@
 }  
 
 /**
-  This function return the total size of INFORMATION OPCODE in boot script 
table.
-
-  @return InformationBufferSize The total size of INFORMATION OPCODE in boot 
script table.
-**/
-UINTN
-GetBootScriptInformationBufferSize (
-  VOID
-  )
-{
-  UINT8                          *S3TableBase;
-  UINT8                          *Script;
-  UINTN                          TableLength;
-  EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;
-  EFI_BOOT_SCRIPT_TABLE_HEADER   TableHeader;
-  EFI_BOOT_SCRIPT_INFORMATION    Information;
-  UINTN                          InformationBufferSize;
-
-  InformationBufferSize = 0;
-
-  S3TableBase   = mS3BootScriptTablePtr->TableBase;
-  Script        = S3TableBase;
-  CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
-  TableLength   = TableHeader.TableLength;
-
-  //
-  // Go through the ScriptTable
-  //
-  while ((UINTN) Script < (UINTN) (S3TableBase + TableLength)) {
-    CopyMem ((VOID*)&ScriptHeader, Script, 
sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
-    switch (ScriptHeader.OpCode) {
-    case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
-      CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));
-      InformationBufferSize += Information.InformationLength;
-      break;
-    default:
-      break;
-    }
-    Script  = Script + ScriptHeader.Length;
-  }
-
-  return InformationBufferSize;
-}
-
-/**
-  This function fix INFORMATION OPCODE in boot script table.
-  Originally, the Information buffer is pointer to EfiRuntimeServicesCode,
-  EfiRuntimeServicesData, or EfiACPIMemoryNVS. They are seperated.
-  Now, in order to save it to LockBox, we allocate a big EfiACPIMemoryNVS,
-  and fix the pointer for INFORMATION opcode InformationBuffer.
-
-  @param InformationBuffer     The address of new Information buffer.
-  @param InformationBufferSize The size of new Information buffer.
-**/
-VOID
-FixBootScriptInformation (
-  IN VOID  *InformationBuffer,
-  IN UINTN InformationBufferSize
-  )
-{
-  UINT8                          *S3TableBase;
-  UINT8                          *Script;
-  UINTN                          TableLength;
-  EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;
-  EFI_BOOT_SCRIPT_TABLE_HEADER   TableHeader;
-  EFI_BOOT_SCRIPT_INFORMATION    Information;
-  UINTN                          FixedInformationBufferSize;
-
-  FixedInformationBufferSize = 0;
-
-  S3TableBase   = mS3BootScriptTablePtr->TableBase;
-  Script        = S3TableBase;
-  CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
-  TableLength   = TableHeader.TableLength;
-
-  //
-  // Go through the ScriptTable
-  //
-  while ((UINTN) Script < (UINTN) (S3TableBase + TableLength)) {
-    CopyMem ((VOID*)&ScriptHeader, Script, 
sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
-    switch (ScriptHeader.OpCode) {
-    case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
-      CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));
-
-      CopyMem (
-        (VOID *)((UINTN)InformationBuffer + FixedInformationBufferSize),
-        (VOID *)(UINTN)Information.Information,
-        Information.InformationLength
-        );
-      gBS->FreePool ((VOID *)(UINTN)Information.Information);
-      Information.Information = 
(EFI_PHYSICAL_ADDRESS)((UINTN)InformationBuffer + FixedInformationBufferSize);
-
-      CopyMem ((VOID*)Script, (VOID*)&Information, sizeof(Information));
-
-      FixedInformationBufferSize += Information.InformationLength;
-      break;
-    default:
-      break;
-    }
-    Script  = Script + ScriptHeader.Length;
-  }
-
-  ASSERT (FixedInformationBufferSize == InformationBufferSize);
-
-  return ;
-}
-
-/**
   This function save boot script data to LockBox.
   1. BootSriptPrivate data, BootScript data - Image and DispatchContext are 
handled by platform.
   2. BootScriptExecutor, BootScriptExecutor context
@@ -223,45 +112,8 @@
   )
 {
   EFI_STATUS            Status;
-  EFI_PHYSICAL_ADDRESS  InformationBuffer;
-  UINTN                 InformationBufferSize;
 
   //
-  // We need save BootScriptInformation to LockBox, because it is in
-  // EfiRuntimeServicesCode, EfiRuntimeServicesData, or EfiACPIMemoryNVS.
-  // 
-  //
-  InformationBufferSize = GetBootScriptInformationBufferSize ();
-  if (InformationBufferSize != 0) {
-    InformationBuffer = 0xFFFFFFFF;
-    Status = gBS->AllocatePages (
-                    AllocateMaxAddress,
-                    EfiACPIMemoryNVS,
-                    EFI_SIZE_TO_PAGES(InformationBufferSize),
-                    &InformationBuffer
-                    );
-    ASSERT_EFI_ERROR (Status);
-
-    //
-    // Fix BootScript information pointer
-    //
-    FixBootScriptInformation ((VOID *)(UINTN)InformationBuffer, 
InformationBufferSize);
-
-    //
-    // Save BootScript information to lockbox
-    //
-    Status = SaveLockBox (
-               &mBootScriptInformationGuid,
-               (VOID *)(UINTN)InformationBuffer,
-               InformationBufferSize
-               );
-    ASSERT_EFI_ERROR (Status);
-
-    Status = SetLockBoxAttributes (&mBootScriptInformationGuid, 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
-    ASSERT_EFI_ERROR (Status);
-  }
-
-  //
   // mS3BootScriptTablePtr->TableLength does not include 
EFI_BOOT_SCRIPT_TERMINATE, because we need add entry at runtime.
   // Save all info here, just in case that no one will add boot script entry 
in SMM.
   //
@@ -1371,7 +1223,6 @@
   @param InformationLength   Length of the data in bytes
   @param Information       Information to be logged in the boot scrpit
  
-  @retval RETURN_UNSUPPORTED       If  entering runtime, this method will not 
support.
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do 
operation.
   @retval RETURN_SUCCESS           Opcode is added.
 
@@ -1383,30 +1234,12 @@
   IN  VOID                                 *Information
   )
 {
-  RETURN_STATUS         Status;
   UINT8                 Length;
   UINT8                 *Script;
-  VOID                  *Buffer;
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;
 
-  if (mS3BootScriptTablePtr->AtRuntime) {
-    return RETURN_UNSUPPORTED;
-  }
-  Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION));
-  
-  //
-  // Use BootServicesData to hold the data, just in case caller free it.
-  // It will be copied into ACPINvs later.
-  //
-  Status = gBS->AllocatePool (
-                  EfiBootServicesData,
-                  InformationLength,
-                  &Buffer
-                  );
-  if (EFI_ERROR (Status)) {
-    return RETURN_OUT_OF_RESOURCES;
-  }
-  
+  Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
+
   Script = S3BootScriptGetEntryAddAddress (Length);
   if (Script == NULL) {
     return RETURN_OUT_OF_RESOURCES;
@@ -1420,10 +1253,11 @@
 
   ScriptInformation.InformationLength = InformationLength;  
 
-  CopyMem ((VOID *)(UINTN)Buffer, Information,(UINTN) InformationLength);  
-  ScriptInformation.Information = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;
-  
-  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof 
(EFI_BOOT_SCRIPT_INFORMATION));  
+  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof 
(EFI_BOOT_SCRIPT_INFORMATION));
+  CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) 
Information, (UINTN) InformationLength);
+
+  SyncBootScript ();
+
   return RETURN_SUCCESS;
 
 }
@@ -1840,7 +1674,6 @@
 {
   UINT8                 Length;
   UINT8                 *Script;
-  VOID                  *Buffer;
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;
  
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
@@ -1849,7 +1682,6 @@
   if (Script == NULL) {
     return RETURN_OUT_OF_RESOURCES;
   }
-  Buffer =  Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
   //
   // Build script data
   //
@@ -1859,11 +1691,9 @@
 
   ScriptInformation.InformationLength = InformationLength;  
 
-  AsciiStrnCpy (Buffer, Information,(UINTN) InformationLength);  
-  ScriptInformation.Information = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;
-  
-  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof 
(EFI_BOOT_SCRIPT_INFORMATION));  
-  
+  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof 
(EFI_BOOT_SCRIPT_INFORMATION));
+  CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) 
Information, (UINTN) InformationLength);
+
   return S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);
 
 }

Modified: trunk/edk2/MdePkg/Include/Library/S3BootScriptLib.h
===================================================================
--- trunk/edk2/MdePkg/Include/Library/S3BootScriptLib.h 2012-11-29 02:12:32 UTC 
(rev 13978)
+++ trunk/edk2/MdePkg/Include/Library/S3BootScriptLib.h 2012-11-29 05:41:51 UTC 
(rev 13979)
@@ -5,7 +5,7 @@
   be provided in the Framework version library instance, which means some of 
these 
   APIs cannot be used if the underlying firmware is Framework and not PI.
 
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -348,7 +348,6 @@
   @param[in] InformationLength   Length of the data in bytes
   @param[in] Information        Information to be logged in the boot scrpit
  
-  @retval RETURN_UNSUPPORTED        In runtime, this method is not supported.
   @retval RETURN_OUT_OF_RESOURCES   Not enough memory for the table to perform 
                                     the operation.
   @retval RETURN_SUCCESS            The opcode was added.
@@ -461,7 +460,6 @@
   @param[in] String   The Null-terminated ASCII string to store into the S3 
boot 
                       script table.
 
-  @retval RETURN_UNSUPPORTED        In runtime, this method is not supported.
   @retval RETURN_OUT_OF_RESOURCES   Not enough memory for the table to perform 
                                     the operation.
   @retval RETURN_SUCCESS            The opcode was added.

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


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to