summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c
blob: 8000e647a9791f3edf4630840819ca0c7ee672d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/** @file
  Performance Library used in SMM phase.

  This library instance provides infrastructure for SMM drivers to log performance
  data. It consumes SMM PerformanceEx or Performance Protocol published by SmmCorePerformanceLib
  to log performance data. If both SMM PerformanceEx and Performance Protocol are not available, it does not log any
  performance information.

  Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>
  Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <PiMm.h>
#include <Protocol/SmmExitBootServices.h>
#include "SmmPerformanceLibInternal.h"

/**
  The constructor function initializes the Performance Measurement Enable flag.

  @param[in]  ImageHandle   The firmware allocated handle for the EFI image.
  @param[in]  SystemTable   A pointer to the EFI System Table.

  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.

**/
EFI_STATUS
EFIAPI
SmmPerformanceLibConstructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return RegisterExitBootServicesCallback (&gEdkiiSmmExitBootServicesProtocolGuid);
}

/**
  The destructor function frees resources allocated by constructor.

  @param[in]  ImageHandle   The firmware allocated handle for the EFI image.
  @param[in]  SystemTable   A pointer to the EFI System Table.

  @retval EFI_SUCCESS   The destructor always returns EFI_SUCCESS.

**/
EFI_STATUS
EFIAPI
SmmPerformanceLibDestructor (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return UnregisterExitBootServicesCallback (&gEdkiiSmmExitBootServicesProtocolGuid);
}