TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmMemoryProfileLib.c
Go to the documentation of this file.
1
9#include <PiSmm.h>
10
13#include <Library/DebugLib.h>
14
15#include <Guid/MemoryProfile.h>
16
17EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
18EDKII_SMM_MEMORY_PROFILE_PROTOCOL *mLibSmmProfileProtocol;
19
28BOOLEAN
29EFIAPI
31 IN VOID *Buffer
32 );
33
44EFIAPI
46 IN EFI_HANDLE ImageHandle,
47 IN EFI_SYSTEM_TABLE *SystemTable
48 )
49{
50 EFI_STATUS Status;
51
52 //
53 // Locate Profile Protocol
54 //
55 Status = gBS->LocateProtocol (
56 &gEdkiiMemoryProfileGuid,
57 NULL,
58 (VOID **)&mLibProfileProtocol
59 );
60 if (EFI_ERROR (Status)) {
61 mLibProfileProtocol = NULL;
62 }
63
64 Status = gSmst->SmmLocateProtocol (
65 &gEdkiiSmmMemoryProfileGuid,
66 NULL,
67 (VOID **)&mLibSmmProfileProtocol
68 );
69 if (EFI_ERROR (Status)) {
70 mLibSmmProfileProtocol = NULL;
71 }
72
73 return EFI_SUCCESS;
74}
75
99EFIAPI
101 IN PHYSICAL_ADDRESS CallerAddress,
102 IN MEMORY_PROFILE_ACTION Action,
103 IN EFI_MEMORY_TYPE MemoryType,
104 IN VOID *Buffer,
105 IN UINTN Size,
106 IN CHAR8 *ActionString OPTIONAL
107 )
108{
109 if (BufferInSmram (Buffer)) {
110 if (mLibSmmProfileProtocol == NULL) {
111 return EFI_UNSUPPORTED;
112 }
113
114 return mLibSmmProfileProtocol->Record (
115 mLibSmmProfileProtocol,
116 CallerAddress,
117 Action,
118 MemoryType,
119 Buffer,
120 Size,
121 ActionString
122 );
123 } else {
124 if (mLibProfileProtocol == NULL) {
125 return EFI_UNSUPPORTED;
126 }
127
128 return mLibProfileProtocol->Record (
129 mLibProfileProtocol,
130 CallerAddress,
131 Action,
132 MemoryType,
133 Buffer,
134 Size,
135 ActionString
136 );
137 }
138}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
EFI_SMM_SYSTEM_TABLE2 * gSmst
BOOLEAN EFIAPI BufferInSmram(IN VOID *Buffer)
EFI_STATUS EFIAPI SmmMemoryProfileLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI MemoryProfileLibRecord(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN VOID *Buffer, IN UINTN Size, IN CHAR8 *ActionString OPTIONAL)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_MEMORY_TYPE