]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
Use mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE) to get...
[mirror_edk2.git] / MdeModulePkg / Library / PiDxeS3BootScriptLib / BootScriptExecute.c
index 5a935492715a8806e668b26de007656fb478e307..538cd1435c427f283625c5f2853da533a10d5119 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 - 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
@@ -415,7 +415,7 @@ ScriptIoWrite (
         IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
         break;       \r
       case S3BootScriptWidthFillUint8:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
         IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
         break;\r
       case S3BootScriptWidthUint16:\r
@@ -427,7 +427,7 @@ ScriptIoWrite (
         IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
         break;      \r
       case S3BootScriptWidthFillUint16:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
         IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
         break;\r
       case S3BootScriptWidthUint32:\r
@@ -439,7 +439,7 @@ ScriptIoWrite (
         IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
         break;\r
       case S3BootScriptWidthFillUint32:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));\r
         IoWrite32 ((UINTN) Address, *OriginalIn.Uint32);\r
         break;\r
       case S3BootScriptWidthUint64:\r
@@ -447,11 +447,11 @@ ScriptIoWrite (
         IoWrite64 ((UINTN) Address, *In.Uint64);\r
         break;      \r
       case S3BootScriptWidthFifoUint64:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));\r
         IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
         break;      \r
       case S3BootScriptWidthFillUint64:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
         IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
         break;\r
       default:\r
@@ -621,7 +621,7 @@ ScriptMemoryWrite (
         MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
         break;      \r
       case S3BootScriptWidthFillUint8:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
         MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
         break;\r
       case S3BootScriptWidthUint16:\r
@@ -633,7 +633,7 @@ ScriptMemoryWrite (
         MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
         break;      \r
       case S3BootScriptWidthFillUint16:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
         MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
         break;\r
       case S3BootScriptWidthUint32:\r
@@ -645,7 +645,7 @@ ScriptMemoryWrite (
         MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
         break;      \r
       case S3BootScriptWidthFillUint32:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));\r
         MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);\r
         break;\r
       case S3BootScriptWidthUint64:\r
@@ -657,7 +657,7 @@ ScriptMemoryWrite (
         MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
         break;      \r
       case S3BootScriptWidthFillUint64:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
         MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
         break;\r
       default:\r
@@ -1199,9 +1199,46 @@ 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
+/**\r
+  Execute the boot script to interpret the Label information. \r
+\r
+  @param Script       The pointer of node in boot script table \r
\r
+**/\r
+VOID\r
+BootScriptExecuteLabel (\r
+  IN UINT8       *Script\r
+  )\r
+\r
+{\r
+  UINT32                        Index;\r
+  EFI_BOOT_SCRIPT_INFORMATION   Information;\r
+\r
+  CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(Information));\r
+\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN)Information.Information));\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
+  }\r
+  DEBUG ((EFI_D_INFO, "\n"));\r
 }\r
+\r
 /**\r
   calculate the mask value for 'and' and 'or' operation\r
   @param ScriptHeader   The pointer of header of node in boot script table \r
@@ -1680,6 +1717,7 @@ S3BootScriptExecute (
 \r
     case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:\r
       DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));\r
       return EFI_SUCCESS;\r
 \r
     case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r
@@ -1732,6 +1770,7 @@ S3BootScriptExecute (
       // For label\r
       //\r
       DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));\r
+      BootScriptExecuteLabel (Script);\r
       break;\r
     default:\r
       DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));\r