]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Application / SmiHandlerProfileInfo / SmiHandlerProfileInfo.c
index 84a1c8ee53b680c1ddc7b05ac6f75fb2feb6e102..0f7163160b4e9076d7fd0a64fb11a6c22d5ac2fe 100644 (file)
@@ -2,13 +2,7 @@
   Shell application to dump SMI handler profile information.\r
 \r
 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -22,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PrintLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/DevicePathLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/DxeServicesLib.h>\r
 #include <Protocol/SmmCommunication.h>\r
 #include <Guid/PiSmmCommunicationRegionTable.h>\r
@@ -266,8 +259,8 @@ GetDriverNameString (
   //\r
   // Method 1: Get the name string from image PDB\r
   //\r
-  if (ImageStruct->Header.Length > sizeof (SMM_CORE_IMAGE_DATABASE_STRUCTURE)) {\r
-    GetShortPdbFileName ((CHAR8 *) (ImageStruct + 1), mNameString);\r
+  if (ImageStruct->PdbStringOffset != 0) {\r
+    GetShortPdbFileName ((CHAR8 *) ((UINTN) ImageStruct + ImageStruct->PdbStringOffset), mNameString);\r
     return mNameString;\r
   }\r
 \r
@@ -348,15 +341,17 @@ DumpSmmLoadedImage(
     if (ImageStruct->Header.Signature == SMM_CORE_IMAGE_DATABASE_SIGNATURE) {\r
       NameString = GetDriverNameString (ImageStruct);\r
       Print(L"  <Image Name=\"%a\"", NameString);\r
-      Print(L" Base=\"0x%x\" Size=\"0x%x\"", ImageStruct->ImageBase, ImageStruct->ImageSize);\r
+      Print(L" Base=\"0x%lx\" Size=\"0x%lx\"", ImageStruct->ImageBase, ImageStruct->ImageSize);\r
       if (ImageStruct->EntryPoint != 0) {\r
-        Print(L" EntryPoint=\"0x%x\"", ImageStruct->EntryPoint);\r
+        Print(L" EntryPoint=\"0x%lx\"", ImageStruct->EntryPoint);\r
       }\r
       Print(L" FvFile=\"%g\"", &ImageStruct->FileGuid);\r
       Print(L" RefId=\"0x%x\"", ImageStruct->ImageRef);\r
       Print(L">\n");\r
-      PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset);\r
-      Print(L"    <Pdb>%a</Pdb>\n", PdbString);\r
+      if (ImageStruct->PdbStringOffset != 0) {\r
+        PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset);\r
+        Print(L"    <Pdb>%a</Pdb>\n", PdbString);\r
+      }\r
       Print(L"  </Image>\n");\r
     }\r
 \r
@@ -535,8 +530,10 @@ DumpSmiChildContext (
   IN UINTN      ContextSize\r
   )\r
 {\r
+  CHAR16        *Str;\r
+\r
   if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) {\r
-    Print(L" SwSmi=\"0x%x\"", ((EFI_SMM_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue);\r
+    Print(L" SwSmi=\"0x%lx\"", ((SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue);\r
   } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) {\r
     Print(L" SxType=\"%a\"", SxTypeToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Type));\r
     Print(L" SxPhase=\"%a\"", SxPhaseToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Phase));\r
@@ -555,7 +552,11 @@ DumpSmiChildContext (
     Print(L" IoTrapType=\"%a\"", IoTrapTypeToString(((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Type));\r
   } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) {\r
     Print(L" UsbType=\"0x%x\"", UsbTypeToString(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context)->Type));\r
-    Print(L" UsbDevicePath=\"%s\"", ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, TRUE));\r
+    Str = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, TRUE);\r
+    Print(L" UsbDevicePath=\"%s\"", Str);\r
+    if (Str != NULL) {\r
+      FreePool (Str);\r
+    }\r
   } else {\r
     Print(L" Context=\"");\r
     InternalDumpData (Context, ContextSize);\r
@@ -601,14 +602,14 @@ DumpSmiHandler(
           Print(L"      <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset);\r
         }\r
         Print(L"      </Module>\n");\r
-        Print(L"      <Handler Address=\"0x%x\">\n", SmiHandlerStruct->Handler);\r
+        Print(L"      <Handler Address=\"0x%lx\">\n", SmiHandlerStruct->Handler);\r
         if (ImageStruct != NULL) {\r
-          Print(L"         <RVA>0x%x</RVA>\n", SmiHandlerStruct->Handler - ImageStruct->ImageBase);\r
+          Print(L"         <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->Handler - ImageStruct->ImageBase));\r
         }\r
         Print(L"      </Handler>\n", SmiHandlerStruct->Handler);\r
-        Print(L"      <Caller Address=\"0x%x\">\n", SmiHandlerStruct->CallerAddr);\r
+        Print(L"      <Caller Address=\"0x%lx\">\n", SmiHandlerStruct->CallerAddr);\r
         if (ImageStruct != NULL) {\r
-          Print(L"         <RVA>0x%x</RVA>\n", SmiHandlerStruct->CallerAddr - ImageStruct->ImageBase);\r
+          Print(L"         <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->CallerAddr - ImageStruct->ImageBase));\r
         }\r
         Print(L"      </Caller>\n", SmiHandlerStruct->Handler);\r
         SmiHandlerStruct = (VOID *)((UINTN)SmiHandlerStruct + SmiHandlerStruct->Length);\r