]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Dispatcher.c
Add Perf log for SMM driver Load and Start Image.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Dispatcher.c
index 53eedbbf61055ffad18e58f1a45629cc803e89ac..5edf184b927d7d6b8c343aec23fa7ac3ab5a47d0 100644 (file)
@@ -27,7 +27,7 @@
 \r
   Depex - Dependency Expresion.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -320,6 +320,12 @@ SmmLoadImage (
   EFI_DEVICE_PATH_PROTOCOL       *HandleFilePath;\r
   EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;\r
   PE_COFF_LOADER_IMAGE_CONTEXT   ImageContext;\r
+  UINT64                         Tick;\r
+\r
+  Tick = 0;\r
+  PERF_CODE (\r
+    Tick = GetPerformanceCounter ();\r
+  );\r
    \r
   Buffer               = NULL;\r
   Size                 = 0;\r
@@ -406,7 +412,7 @@ SmmLoadImage (
   \r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     return Status;\r
   }\r
@@ -423,7 +429,7 @@ SmmLoadImage (
   Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     return Status;\r
   }\r
@@ -448,7 +454,7 @@ SmmLoadImage (
        //\r
        // allocate the memory to load the SMM driver\r
        //\r
-       PageCount = (UINTN)EFI_SIZE_TO_PAGES(ImageContext.ImageSize + ImageContext.SectionAlignment);\r
+       PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);\r
        DstBuffer = (UINTN)(-1);\r
      \r
        Status = SmmAllocatePages (\r
@@ -459,14 +465,14 @@ SmmLoadImage (
                    );\r
        if (EFI_ERROR (Status)) {\r
          if (Buffer != NULL) {\r
-           Status = gBS->FreePool (Buffer);\r
+           gBS->FreePool (Buffer);\r
          } \r
          return Status;\r
        }     \r
       ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)DstBuffer;\r
     }\r
   } else {\r
-     PageCount = (UINTN)EFI_SIZE_TO_PAGES(ImageContext.ImageSize + ImageContext.SectionAlignment);\r
+     PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);\r
      DstBuffer = (UINTN)(-1);\r
      \r
      Status = SmmAllocatePages (\r
@@ -477,7 +483,7 @@ SmmLoadImage (
                   );\r
      if (EFI_ERROR (Status)) {\r
        if (Buffer != NULL) {\r
-         Status = gBS->FreePool (Buffer);\r
+         gBS->FreePool (Buffer);\r
        }\r
        return Status;\r
      }\r
@@ -496,7 +502,7 @@ SmmLoadImage (
   Status = PeCoffLoaderLoadImage (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     SmmFreePages (DstBuffer, PageCount);\r
     return Status;\r
@@ -508,7 +514,7 @@ SmmLoadImage (
   Status = PeCoffLoaderRelocateImage (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     SmmFreePages (DstBuffer, PageCount);\r
     return Status;\r
@@ -532,7 +538,7 @@ SmmLoadImage (
   Status = gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&DriverEntry->LoadedImage);\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     SmmFreePages (DstBuffer, PageCount);\r
     return Status;\r
@@ -553,7 +559,7 @@ SmmLoadImage (
   Status = gBS->AllocatePool (EfiBootServicesData, GetDevicePathSize (FilePath), (VOID **)&DriverEntry->LoadedImage->FilePath);\r
   if (EFI_ERROR (Status)) {\r
     if (Buffer != NULL) {\r
-      Status = gBS->FreePool (Buffer);\r
+      gBS->FreePool (Buffer);\r
     }\r
     SmmFreePages (DstBuffer, PageCount);\r
     return Status;\r
@@ -575,6 +581,9 @@ SmmLoadImage (
                   NULL\r
                   );\r
 \r
+  PERF_START (DriverEntry->ImageHandle, "LoadImage:", NULL, Tick);\r
+  PERF_END (DriverEntry->ImageHandle, "LoadImage:", NULL, 0);\r
+\r
   //\r
   // Print the load address and the PDB file name if it is available\r
   //\r
@@ -836,7 +845,9 @@ SmmDispatcher (
       //\r
       // For each SMM driver, pass NULL as ImageHandle\r
       //\r
+      PERF_START (DriverEntry->ImageHandle, "StartImage:", NULL, 0);\r
       Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, gST);\r
+      PERF_END (DriverEntry->ImageHandle, "StartImage:", NULL, 0);\r
       if (EFI_ERROR(Status)){\r
         SmmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);\r
       }\r