]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that S3BootScriptLabel() does not work to insert label when the specifi...
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 29 Nov 2012 05:41:51 +0000 (05:41 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 29 Nov 2012 05:41:51 +0000 (05:41 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13979 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
MdePkg/Include/Library/S3BootScriptLib.h

index 538cd1435c427f283625c5f2853da533a10d5119..01ca7df7cecbe58b326eb819191770706759fde0 100644 (file)
@@ -1201,14 +1201,16 @@ BootScriptExecuteInformation (
 {\r
   UINT32                        Index;\r
   EFI_BOOT_SCRIPT_INFORMATION   Information;\r
+  UINT8                         *InformationData;\r
 \r
-  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
+  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN)Information.Information));\r
+  InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptInformation: "));\r
   for (Index = 0; Index < Information.InformationLength; Index++) {\r
-    DEBUG ((EFI_D_INFO, "%02x ", *(UINT8 *)(UINTN)(Information.Information + Index)));\r
+    DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));\r
   }\r
   DEBUG ((EFI_D_INFO, "\n"));\r
 }\r
@@ -1227,14 +1229,16 @@ BootScriptExecuteLabel (
 {\r
   UINT32                        Index;\r
   EFI_BOOT_SCRIPT_INFORMATION   Information;\r
+  UINT8                         *InformationData;\r
 \r
-  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
+  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN)Information.Information));\r
+  InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptLabel: "));\r
   for (Index = 0; Index < Information.InformationLength; Index++) {\r
-    DEBUG ((EFI_D_INFO, "%02x ", *(UINT8 *)(UINTN)(Information.Information + Index)));\r
+    DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));\r
   }\r
   DEBUG ((EFI_D_INFO, "\n"));\r
 }\r
index 6edb11adf30a09a54d25cb18fb2b22e3c9ef7af0..dce2a1ca77ea767fddb70e3c25b38a7c0aaed506 100644 (file)
@@ -2,7 +2,7 @@
   This file declares the internal Framework Boot Script format used by\r
   the PI implementation of Script Saver and Executor.\r
 \r
-  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -144,8 +144,8 @@ typedef struct {
 typedef struct {\r
   UINT16  OpCode;\r
   UINT8   Length;\r
-  UINT32                InformationLength;  \r
-  EFI_PHYSICAL_ADDRESS  Information;\r
+  UINT32  InformationLength;\r
+// UINT8   InformationData[InformationLength];\r
 } EFI_BOOT_SCRIPT_INFORMATION;\r
 \r
 typedef struct {\r
index ee106552444e76c63ddce6c5e9f6c9b1c693e773..09dc2c4ec303397b1dd022b3a8bd9abaee291a8c 100644 (file)
@@ -54,10 +54,6 @@ EFI_GUID                         mBootScriptHeaderDataGuid = {
   0x1810ab4a, 0x2314, 0x4df6, { 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91 }\r
 };\r
 \r
-EFI_GUID                         mBootScriptInformationGuid = {\r
-  0x2c680508, 0x2b87, 0x46ab, { 0xb9, 0x8a, 0x49, 0xfc, 0x23, 0xf9, 0xf5, 0x95 }\r
-};\r
-\r
 /**\r
   This is an internal function to add a terminate node the entry, recalculate the table \r
   length and fill into the table. \r
@@ -103,113 +99,6 @@ S3BootScriptInternalCloseTable (
   //\r
 }  \r
 \r
-/**\r
-  This function return the total size of INFORMATION OPCODE in boot script table.\r
-\r
-  @return InformationBufferSize The total size of INFORMATION OPCODE in boot script table.\r
-**/\r
-UINTN\r
-GetBootScriptInformationBufferSize (\r
-  VOID\r
-  )\r
-{\r
-  UINT8                          *S3TableBase;\r
-  UINT8                          *Script;\r
-  UINTN                          TableLength;\r
-  EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;\r
-  EFI_BOOT_SCRIPT_TABLE_HEADER   TableHeader;\r
-  EFI_BOOT_SCRIPT_INFORMATION    Information;\r
-  UINTN                          InformationBufferSize;\r
-\r
-  InformationBufferSize = 0;\r
-\r
-  S3TableBase   = mS3BootScriptTablePtr->TableBase;\r
-  Script        = S3TableBase;\r
-  CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));\r
-  TableLength   = TableHeader.TableLength;\r
-\r
-  //\r
-  // Go through the ScriptTable\r
-  //\r
-  while ((UINTN) Script < (UINTN) (S3TableBase + TableLength)) {\r
-    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
-    switch (ScriptHeader.OpCode) {\r
-    case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r
-      CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
-      InformationBufferSize += Information.InformationLength;\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-    Script  = Script + ScriptHeader.Length;\r
-  }\r
-\r
-  return InformationBufferSize;\r
-}\r
-\r
-/**\r
-  This function fix INFORMATION OPCODE in boot script table.\r
-  Originally, the Information buffer is pointer to EfiRuntimeServicesCode,\r
-  EfiRuntimeServicesData, or EfiACPIMemoryNVS. They are seperated.\r
-  Now, in order to save it to LockBox, we allocate a big EfiACPIMemoryNVS,\r
-  and fix the pointer for INFORMATION opcode InformationBuffer.\r
-\r
-  @param InformationBuffer     The address of new Information buffer.\r
-  @param InformationBufferSize The size of new Information buffer.\r
-**/\r
-VOID\r
-FixBootScriptInformation (\r
-  IN VOID  *InformationBuffer,\r
-  IN UINTN InformationBufferSize\r
-  )\r
-{\r
-  UINT8                          *S3TableBase;\r
-  UINT8                          *Script;\r
-  UINTN                          TableLength;\r
-  EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;\r
-  EFI_BOOT_SCRIPT_TABLE_HEADER   TableHeader;\r
-  EFI_BOOT_SCRIPT_INFORMATION    Information;\r
-  UINTN                          FixedInformationBufferSize;\r
-\r
-  FixedInformationBufferSize = 0;\r
-\r
-  S3TableBase   = mS3BootScriptTablePtr->TableBase;\r
-  Script        = S3TableBase;\r
-  CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));\r
-  TableLength   = TableHeader.TableLength;\r
-\r
-  //\r
-  // Go through the ScriptTable\r
-  //\r
-  while ((UINTN) Script < (UINTN) (S3TableBase + TableLength)) {\r
-    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
-    switch (ScriptHeader.OpCode) {\r
-    case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r
-      CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
-\r
-      CopyMem (\r
-        (VOID *)((UINTN)InformationBuffer + FixedInformationBufferSize),\r
-        (VOID *)(UINTN)Information.Information,\r
-        Information.InformationLength\r
-        );\r
-      gBS->FreePool ((VOID *)(UINTN)Information.Information);\r
-      Information.Information = (EFI_PHYSICAL_ADDRESS)((UINTN)InformationBuffer + FixedInformationBufferSize);\r
-\r
-      CopyMem ((VOID*)Script, (VOID*)&Information, sizeof(Information));\r
-\r
-      FixedInformationBufferSize += Information.InformationLength;\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-    Script  = Script + ScriptHeader.Length;\r
-  }\r
-\r
-  ASSERT (FixedInformationBufferSize == InformationBufferSize);\r
-\r
-  return ;\r
-}\r
-\r
 /**\r
   This function save boot script data to LockBox.\r
   1. BootSriptPrivate data, BootScript data - Image and DispatchContext are handled by platform.\r
@@ -223,43 +112,6 @@ SaveBootScriptDataToLockBox (
   )\r
 {\r
   EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  InformationBuffer;\r
-  UINTN                 InformationBufferSize;\r
-\r
-  //\r
-  // We need save BootScriptInformation to LockBox, because it is in\r
-  // EfiRuntimeServicesCode, EfiRuntimeServicesData, or EfiACPIMemoryNVS.\r
-  // \r
-  //\r
-  InformationBufferSize = GetBootScriptInformationBufferSize ();\r
-  if (InformationBufferSize != 0) {\r
-    InformationBuffer = 0xFFFFFFFF;\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiACPIMemoryNVS,\r
-                    EFI_SIZE_TO_PAGES(InformationBufferSize),\r
-                    &InformationBuffer\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Fix BootScript information pointer\r
-    //\r
-    FixBootScriptInformation ((VOID *)(UINTN)InformationBuffer, InformationBufferSize);\r
-\r
-    //\r
-    // Save BootScript information to lockbox\r
-    //\r
-    Status = SaveLockBox (\r
-               &mBootScriptInformationGuid,\r
-               (VOID *)(UINTN)InformationBuffer,\r
-               InformationBufferSize\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    Status = SetLockBoxAttributes (&mBootScriptInformationGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
 \r
   //\r
   // mS3BootScriptTablePtr->TableLength does not include EFI_BOOT_SCRIPT_TERMINATE, because we need add entry at runtime.\r
@@ -1371,7 +1223,6 @@ S3BootScriptSaveMemPoll (
   @param InformationLength   Length of the data in bytes\r
   @param Information       Information to be logged in the boot scrpit\r
  \r
-  @retval RETURN_UNSUPPORTED       If  entering runtime, this method will not support.\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 \r
@@ -1383,30 +1234,12 @@ S3BootScriptSaveInformation (
   IN  VOID                                 *Information\r
   )\r
 {\r
-  RETURN_STATUS         Status;\r
   UINT8                 Length;\r
   UINT8                 *Script;\r
-  VOID                  *Buffer;\r
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;\r
 \r
-  if (mS3BootScriptTablePtr->AtRuntime) {\r
-    return RETURN_UNSUPPORTED;\r
-  }\r
-  Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
-  \r
-  //\r
-  // Use BootServicesData to hold the data, just in case caller free it.\r
-  // It will be copied into ACPINvs later.\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  InformationLength,\r
-                  &Buffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return RETURN_OUT_OF_RESOURCES;\r
-  }\r
-  \r
+  Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);\r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1420,10 +1253,11 @@ S3BootScriptSaveInformation (
 \r
   ScriptInformation.InformationLength = InformationLength;  \r
 \r
-  CopyMem ((VOID *)(UINTN)Buffer, Information,(UINTN) InformationLength);  \r
-  ScriptInformation.Information = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;\r
-  \r
-  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));  \r
+  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
+  CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);\r
+\r
+  SyncBootScript ();\r
+\r
   return RETURN_SUCCESS;\r
 \r
 }\r
@@ -1840,7 +1674,6 @@ S3BootScriptLabelInternal (
 {\r
   UINT8                 Length;\r
   UINT8                 *Script;\r
-  VOID                  *Buffer;\r
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;\r
  \r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);\r
@@ -1849,7 +1682,6 @@ S3BootScriptLabelInternal (
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
   }\r
-  Buffer =  Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);\r
   //\r
   // Build script data\r
   //\r
@@ -1859,11 +1691,9 @@ S3BootScriptLabelInternal (
 \r
   ScriptInformation.InformationLength = InformationLength;  \r
 \r
-  AsciiStrnCpy (Buffer, Information,(UINTN) InformationLength);  \r
-  ScriptInformation.Information = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;\r
-  \r
-  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));  \r
-  \r
+  CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
+  CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);\r
+\r
   return S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);\r
 \r
 }\r
index 2fabaa9f894c666791195722bd0f5fe99f37fafc..0776812e6a38143dd4fea2efb2ee12c0c6475e23 100644 (file)
@@ -5,7 +5,7 @@
   be provided in the Framework version library instance, which means some of these \r
   APIs cannot be used if the underlying firmware is Framework and not PI.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -348,7 +348,6 @@ S3BootScriptSaveMemPoll (
   @param[in] InformationLength   Length of the data in bytes\r
   @param[in] Information        Information to be logged in the boot scrpit\r
  \r
-  @retval RETURN_UNSUPPORTED        In runtime, this method is not supported.\r
   @retval RETURN_OUT_OF_RESOURCES   Not enough memory for the table to perform \r
                                     the operation.\r
   @retval RETURN_SUCCESS            The opcode was added.\r
@@ -461,7 +460,6 @@ S3BootScriptSavePci2Poll (
   @param[in] String   The Null-terminated ASCII string to store into the S3 boot \r
                       script table.\r
 \r
-  @retval RETURN_UNSUPPORTED        In runtime, this method is not supported.\r
   @retval RETURN_OUT_OF_RESOURCES   Not enough memory for the table to perform \r
                                     the operation.\r
   @retval RETURN_SUCCESS            The opcode was added.\r