1 | /** @file
|
---|
2 |
|
---|
3 | Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
---|
4 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
5 |
|
---|
6 | **/
|
---|
7 |
|
---|
8 | #ifndef MM_COMMUNICATION_DXE_H_
|
---|
9 | #define MM_COMMUNICATION_DXE_H_
|
---|
10 |
|
---|
11 | #include <PiDxe.h>
|
---|
12 |
|
---|
13 | #include <Library/BaseLib.h>
|
---|
14 | #include <Library/DebugLib.h>
|
---|
15 | #include <Library/HobLib.h>
|
---|
16 | #include <Library/PcdLib.h>
|
---|
17 | #include <Library/UefiLib.h>
|
---|
18 | #include <Library/UefiBootServicesTableLib.h>
|
---|
19 | #include <Library/BaseMemoryLib.h>
|
---|
20 | #include <Library/MemoryAllocationLib.h>
|
---|
21 | #include <Library/UefiRuntimeLib.h>
|
---|
22 | #include <Library/ReportStatusCodeLib.h>
|
---|
23 |
|
---|
24 | #include <Protocol/SmmControl2.h>
|
---|
25 | #include <Protocol/MmCommunication2.h>
|
---|
26 | #include <Protocol/MmCommunication.h>
|
---|
27 | #include <Protocol/DxeMmReadyToLock.h>
|
---|
28 | #include <Protocol/SmmAccess2.h>
|
---|
29 |
|
---|
30 | #include <Guid/MmCommBuffer.h>
|
---|
31 | #include <Guid/EventGroup.h>
|
---|
32 |
|
---|
33 | typedef enum {
|
---|
34 | EventNotify,
|
---|
35 | ProtocolNotify,
|
---|
36 | EndNotify,
|
---|
37 | } NOTIFICATION_TYPE;
|
---|
38 |
|
---|
39 | //
|
---|
40 | // Data structure used to declare a table of protocol notifications and event
|
---|
41 | // notifications required by the Standalone Mm environment
|
---|
42 | //
|
---|
43 | typedef struct {
|
---|
44 | NOTIFICATION_TYPE NotificationType;
|
---|
45 | BOOLEAN CloseOnLock;
|
---|
46 | EFI_GUID *Guid;
|
---|
47 | EFI_EVENT_NOTIFY NotifyFunction;
|
---|
48 | VOID *NotifyContext;
|
---|
49 | EFI_EVENT Event;
|
---|
50 | } MM_EVENT_NOTIFICATION;
|
---|
51 |
|
---|
52 | /**
|
---|
53 | Communicates with a registered handler.
|
---|
54 |
|
---|
55 | This function provides a service to send and receive messages from a registered UEFI service.
|
---|
56 |
|
---|
57 | @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance.
|
---|
58 | @param[in, out] CommBufferPhysical Physical address of the MM communication buffer.
|
---|
59 | @param[in, out] CommBufferVirtual Virtual address of the MM communication buffer.
|
---|
60 | @param[in, out] CommSize The size of the data buffer being passed in. On exit, the size of data
|
---|
61 | being returned. Zero if the handler does not wish to reply with any data.
|
---|
62 | This parameter is optional and may be NULL.
|
---|
63 |
|
---|
64 | @retval EFI_SUCCESS The message was successfully posted.
|
---|
65 | @retval EFI_INVALID_PARAMETER The CommBuffer was NULL.
|
---|
66 | @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.
|
---|
67 | If this error is returned, the MessageLength field
|
---|
68 | in the CommBuffer header or the integer pointed by
|
---|
69 | CommSize, are updated to reflect the maximum payload
|
---|
70 | size the implementation can accommodate.
|
---|
71 | @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter,
|
---|
72 | if not omitted, are in address range that cannot be
|
---|
73 | accessed by the MM environment.
|
---|
74 |
|
---|
75 | **/
|
---|
76 | EFI_STATUS
|
---|
77 | EFIAPI
|
---|
78 | MmCommunicate2 (
|
---|
79 | IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This,
|
---|
80 | IN OUT VOID *CommBufferPhysical,
|
---|
81 | IN OUT VOID *CommBufferVirtual,
|
---|
82 | IN OUT UINTN *CommSize OPTIONAL
|
---|
83 | );
|
---|
84 |
|
---|
85 | /**
|
---|
86 | Communicates with a registered handler.
|
---|
87 |
|
---|
88 | This function provides a service to send and receive messages from a registered UEFI service.
|
---|
89 |
|
---|
90 | @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instance.
|
---|
91 | @param[in, out] CommBufferPhysical Physical address of the MM communication buffer
|
---|
92 | @param[in, out] CommSize The size of the data buffer being passed in. On exit, the size of data
|
---|
93 | being returned. Zero if the handler does not wish to reply with any data.
|
---|
94 | This parameter is optional and may be NULL.
|
---|
95 |
|
---|
96 | @retval EFI_SUCCESS The message was successfully posted.
|
---|
97 | @retval EFI_INVALID_PARAMETER The CommBuffer was NULL.
|
---|
98 | @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implementation.
|
---|
99 | If this error is returned, the MessageLength field
|
---|
100 | in the CommBuffer header or the integer pointed by
|
---|
101 | CommSize, are updated to reflect the maximum payload
|
---|
102 | size the implementation can accommodate.
|
---|
103 | @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter,
|
---|
104 | if not omitted, are in address range that cannot be
|
---|
105 | accessed by the MM environment.
|
---|
106 |
|
---|
107 | **/
|
---|
108 | EFI_STATUS
|
---|
109 | EFIAPI
|
---|
110 | MmCommunicate (
|
---|
111 | IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This,
|
---|
112 | IN OUT VOID *CommBufferPhysical,
|
---|
113 | IN OUT UINTN *CommSize OPTIONAL
|
---|
114 | );
|
---|
115 |
|
---|
116 | /**
|
---|
117 | Event notification that is fired every time a DxeSmmReadyToLock protocol is added
|
---|
118 | or if gEfiEventReadyToBootGuid is signaled.
|
---|
119 |
|
---|
120 | @param Event The Event that is being processed, not used.
|
---|
121 | @param Context Event Context, not used.
|
---|
122 |
|
---|
123 | **/
|
---|
124 | VOID
|
---|
125 | EFIAPI
|
---|
126 | MmReadyToLockEventNotify (
|
---|
127 | IN EFI_EVENT Event,
|
---|
128 | IN VOID *Context
|
---|
129 | );
|
---|
130 |
|
---|
131 | /**
|
---|
132 | Event notification that is fired when GUIDed Event Group is signaled.
|
---|
133 |
|
---|
134 | @param Event The Event that is being processed, not used.
|
---|
135 | @param Context Event Context, not used.
|
---|
136 |
|
---|
137 | **/
|
---|
138 | VOID
|
---|
139 | EFIAPI
|
---|
140 | MmGuidedEventNotify (
|
---|
141 | IN EFI_EVENT Event,
|
---|
142 | IN VOID *Context
|
---|
143 | );
|
---|
144 |
|
---|
145 | /**
|
---|
146 | Event notification that is fired when EndOfDxe Event Group is signaled.
|
---|
147 |
|
---|
148 | @param Event The Event that is being processed, not used.
|
---|
149 | @param Context Event Context, not used.
|
---|
150 |
|
---|
151 | **/
|
---|
152 | VOID
|
---|
153 | EFIAPI
|
---|
154 | MmEndOfDxeEventNotify (
|
---|
155 | IN EFI_EVENT Event,
|
---|
156 | IN VOID *Context
|
---|
157 | );
|
---|
158 |
|
---|
159 | /**
|
---|
160 | Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
|
---|
161 |
|
---|
162 | This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
---|
163 | It convers pointer to new virtual address.
|
---|
164 |
|
---|
165 | @param[in] Event Event whose notification function is being invoked.
|
---|
166 | @param[in] Context Pointer to the notification function's context.
|
---|
167 |
|
---|
168 | **/
|
---|
169 | VOID
|
---|
170 | EFIAPI
|
---|
171 | MmVirtualAddressChangeEvent (
|
---|
172 | IN EFI_EVENT Event,
|
---|
173 | IN VOID *Context
|
---|
174 | );
|
---|
175 |
|
---|
176 | #endif
|
---|