]> git.proxmox.com Git - mirror_edk2.git/commitdiff
In BootScriptSaver, put INFORMATION_OPCODE message to LockBox.
authorjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Nov 2011 09:35:20 +0000 (09:35 +0000)
committerjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Nov 2011 09:35:20 +0000 (09:35 +0000)
In BootScriptExecutor, add code to display this INFORMATION_OPCODE message.

Signed-off-by: jyao1
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12735 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c

index 5a935492715a8806e668b26de007656fb478e307..766396d1d1521015d441a80a9d8ec194aa4a7535 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Interpret and execute the S3 data in S3 boot script. \r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2011, 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
@@ -1199,8 +1199,18 @@ BootScriptExecuteInformation (
   )\r
 \r
 {\r
-  UINT8 Index;\r
-  for (Index = 0; Index < 10; Index++);\r
+  UINT32                        Index;\r
+  EFI_BOOT_SCRIPT_INFORMATION   Information;\r
+\r
+  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
+\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN)Information.Information));\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
+  }\r
+  DEBUG ((EFI_D_INFO, "\n"));\r
 }\r
 /**\r
   calculate the mask value for 'and' and 'or' operation\r
index aa20d6d302f887b5f30d53707ac5ec88b96d1110..0ebfdbb1b67cd747da35be6189d094c7dbe44f77 100644 (file)
@@ -54,6 +54,10 @@ 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
@@ -99,6 +103,113 @@ 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
@@ -111,7 +222,45 @@ SaveBootScriptDataToLockBox (
   VOID\r
   )\r
 {\r
-  EFI_STATUS Status;\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
   // Save all info here, just in case that no one will add boot script entry in SMM.\r
@@ -1237,7 +1386,7 @@ S3BootScriptSaveInformation (
   RETURN_STATUS         Status;\r
   UINT8                 Length;\r
   UINT8                 *Script;\r
-  EFI_PHYSICAL_ADDRESS  Buffer;\r
+  VOID                  *Buffer;\r
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;\r
 \r
   if (mS3BootScriptTablePtr->AtRuntime) {\r
@@ -1245,11 +1394,13 @@ S3BootScriptSaveInformation (
   }\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
   \r
-  Buffer = 0xFFFFFFFF;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIMemoryNVS,\r
-                  EFI_SIZE_TO_PAGES(InformationLength),\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