Subrata Banik | 20fe24b | 2021-12-09 02:46:38 +0530 | [diff] [blame] | 1 | /** @file |
| 2 | Common definitions in the Platform Initialization Specification version 1.5 |
| 3 | VOLUME 4 Management Mode Core Interface version. |
| 4 | |
| 5 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> |
| 6 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 7 | |
| 8 | **/ |
| 9 | |
| 10 | #ifndef _PI_MMCIS_H_ |
| 11 | #define _PI_MMCIS_H_ |
| 12 | |
| 13 | #include <Pi/PiMultiPhase.h> |
| 14 | #include <Protocol/MmCpuIo.h> |
| 15 | |
| 16 | typedef struct _EFI_MM_SYSTEM_TABLE EFI_MM_SYSTEM_TABLE; |
| 17 | |
| 18 | /// |
| 19 | /// The Management Mode System Table (MMST) signature |
| 20 | /// |
| 21 | #define MM_MMST_SIGNATURE SIGNATURE_32 ('S', 'M', 'S', 'T') |
| 22 | /// |
| 23 | /// The Management Mode System Table (MMST) revision is 1.6 |
| 24 | /// |
| 25 | #define MM_SPECIFICATION_MAJOR_REVISION 1 |
| 26 | #define MM_SPECIFICATION_MINOR_REVISION 60 |
| 27 | #define EFI_MM_SYSTEM_TABLE_REVISION ((MM_SPECIFICATION_MAJOR_REVISION<<16) | (MM_SPECIFICATION_MINOR_REVISION)) |
| 28 | |
| 29 | /** |
| 30 | Adds, updates, or removes a configuration table entry from the Management Mode System Table. |
| 31 | |
| 32 | The MmInstallConfigurationTable() function is used to maintain the list |
| 33 | of configuration tables that are stored in the Management Mode System |
| 34 | Table. The list is stored as an array of (GUID, Pointer) pairs. The list |
| 35 | must be allocated from pool memory with PoolType set to EfiRuntimeServicesData. |
| 36 | |
| 37 | @param[in] SystemTable A pointer to the MM System Table (MMST). |
| 38 | @param[in] Guid A pointer to the GUID for the entry to add, update, or remove. |
| 39 | @param[in] Table A pointer to the buffer of the table to add. |
| 40 | @param[in] TableSize The size of the table to install. |
| 41 | |
| 42 | @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed. |
| 43 | @retval EFI_INVALID_PARAMETER Guid is not valid. |
| 44 | @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry. |
| 45 | @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation. |
| 46 | **/ |
| 47 | typedef |
| 48 | EFI_STATUS |
| 49 | (EFIAPI *EFI_MM_INSTALL_CONFIGURATION_TABLE)( |
| 50 | IN CONST EFI_MM_SYSTEM_TABLE *SystemTable, |
| 51 | IN CONST EFI_GUID *Guid, |
| 52 | IN VOID *Table, |
| 53 | IN UINTN TableSize |
| 54 | ); |
| 55 | |
| 56 | /** |
| 57 | This service lets the caller to get one distinct application processor (AP) to execute |
| 58 | a caller-provided code stream while in MM. |
| 59 | |
| 60 | @param[in] Procedure A pointer to the code stream to be run on the designated |
| 61 | AP of the system. |
| 62 | @param[in] CpuNumber The zero-based index of the processor number of the AP |
| 63 | on which the code stream is supposed to run. |
| 64 | @param[in,out] ProcArguments Allows the caller to pass a list of parameters to the code |
| 65 | that is run by the AP. |
| 66 | |
| 67 | @retval EFI_SUCCESS The call was successful and the return parameters are valid. |
| 68 | @retval EFI_INVALID_PARAMETER The input arguments are out of range. |
| 69 | @retval EFI_INVALID_PARAMETER The CPU requested is not available on this SMI invocation. |
| 70 | @retval EFI_INVALID_PARAMETER The CPU cannot support an additional service invocation. |
| 71 | **/ |
| 72 | typedef |
| 73 | EFI_STATUS |
| 74 | (EFIAPI *EFI_MM_STARTUP_THIS_AP)( |
| 75 | IN EFI_AP_PROCEDURE Procedure, |
| 76 | IN UINTN CpuNumber, |
| 77 | IN OUT VOID *ProcArguments OPTIONAL |
| 78 | ); |
| 79 | |
| 80 | /** |
| 81 | Function prototype for protocol install notification. |
| 82 | |
| 83 | @param[in] Protocol Points to the protocol's unique identifier. |
| 84 | @param[in] Interface Points to the interface instance. |
| 85 | @param[in] Handle The handle on which the interface was installed. |
| 86 | |
| 87 | @return Status Code |
| 88 | **/ |
| 89 | typedef |
| 90 | EFI_STATUS |
| 91 | (EFIAPI *EFI_MM_NOTIFY_FN)( |
| 92 | IN CONST EFI_GUID *Protocol, |
| 93 | IN VOID *Interface, |
| 94 | IN EFI_HANDLE Handle |
| 95 | ); |
| 96 | |
| 97 | /** |
| 98 | Register a callback function be called when a particular protocol interface is installed. |
| 99 | |
| 100 | The MmRegisterProtocolNotify() function creates a registration Function that is to be |
| 101 | called whenever a protocol interface is installed for Protocol by |
| 102 | MmInstallProtocolInterface(). |
| 103 | If Function == NULL and Registration is an existing registration, then the callback is unhooked. |
| 104 | |
| 105 | @param[in] Protocol The unique ID of the protocol for which the event is to be registered. |
| 106 | @param[in] Function Points to the notification function. |
| 107 | @param[out] Registration A pointer to a memory location to receive the registration value. |
| 108 | |
| 109 | @retval EFI_SUCCESS Successfully returned the registration record |
| 110 | that has been added or unhooked. |
| 111 | @retval EFI_INVALID_PARAMETER Protocol is NULL or Registration is NULL. |
| 112 | @retval EFI_OUT_OF_RESOURCES Not enough memory resource to finish the request. |
| 113 | @retval EFI_NOT_FOUND If the registration is not found when Function == NULL. |
| 114 | **/ |
| 115 | typedef |
| 116 | EFI_STATUS |
| 117 | (EFIAPI *EFI_MM_REGISTER_PROTOCOL_NOTIFY)( |
| 118 | IN CONST EFI_GUID *Protocol, |
| 119 | IN EFI_MM_NOTIFY_FN Function, |
| 120 | OUT VOID **Registration |
| 121 | ); |
| 122 | |
| 123 | /** |
| 124 | Manage MMI of a particular type. |
| 125 | |
| 126 | @param[in] HandlerType Points to the handler type or NULL for root MMI handlers. |
| 127 | @param[in] Context Points to an optional context buffer. |
| 128 | @param[in,out] CommBuffer Points to the optional communication buffer. |
| 129 | @param[in,out] CommBufferSize Points to the size of the optional communication buffer. |
| 130 | |
| 131 | @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was processed successfully but not quiesced. |
| 132 | @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced. |
| 133 | @retval EFI_NOT_FOUND Interrupt source was not handled or quiesced. |
| 134 | @retval EFI_SUCCESS Interrupt source was handled and quiesced. |
| 135 | **/ |
| 136 | typedef |
| 137 | EFI_STATUS |
| 138 | (EFIAPI *EFI_MM_INTERRUPT_MANAGE)( |
| 139 | IN CONST EFI_GUID *HandlerType, |
| 140 | IN CONST VOID *Context OPTIONAL, |
| 141 | IN OUT VOID *CommBuffer OPTIONAL, |
| 142 | IN OUT UINTN *CommBufferSize OPTIONAL |
| 143 | ); |
| 144 | |
| 145 | /** |
| 146 | Main entry point for an MM handler dispatch or communicate-based callback. |
| 147 | |
| 148 | @param[in] DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister(). |
| 149 | @param[in] Context Points to an optional handler context which was specified when the |
| 150 | handler was registered. |
| 151 | @param[in,out] CommBuffer A pointer to a collection of data in memory that will |
| 152 | be conveyed from a non-MM environment into an MM environment. |
| 153 | @param[in,out] CommBufferSize The size of the CommBuffer. |
| 154 | |
| 155 | @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers |
| 156 | should still be called. |
| 157 | @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should |
| 158 | still be called. |
| 159 | @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still |
| 160 | be called. |
| 161 | @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced. |
| 162 | **/ |
| 163 | typedef |
| 164 | EFI_STATUS |
| 165 | (EFIAPI *EFI_MM_HANDLER_ENTRY_POINT)( |
| 166 | IN EFI_HANDLE DispatchHandle, |
| 167 | IN CONST VOID *Context OPTIONAL, |
| 168 | IN OUT VOID *CommBuffer OPTIONAL, |
| 169 | IN OUT UINTN *CommBufferSize OPTIONAL |
| 170 | ); |
| 171 | |
| 172 | /** |
| 173 | Registers a handler to execute within MM. |
| 174 | |
| 175 | @param[in] Handler Handler service function pointer. |
| 176 | @param[in] HandlerType Points to the handler type or NULL for root MMI handlers. |
| 177 | @param[out] DispatchHandle On return, contains a unique handle which can be used to later |
| 178 | unregister the handler function. |
| 179 | |
| 180 | @retval EFI_SUCCESS MMI handler added successfully. |
| 181 | @retval EFI_INVALID_PARAMETER Handler is NULL or DispatchHandle is NULL. |
| 182 | **/ |
| 183 | typedef |
| 184 | EFI_STATUS |
| 185 | (EFIAPI *EFI_MM_INTERRUPT_REGISTER)( |
| 186 | IN EFI_MM_HANDLER_ENTRY_POINT Handler, |
| 187 | IN CONST EFI_GUID *HandlerType OPTIONAL, |
| 188 | OUT EFI_HANDLE *DispatchHandle |
| 189 | ); |
| 190 | |
| 191 | /** |
| 192 | Unregister a handler in MM. |
| 193 | |
| 194 | @param[in] DispatchHandle The handle that was specified when the handler was registered. |
| 195 | |
| 196 | @retval EFI_SUCCESS Handler function was successfully unregistered. |
| 197 | @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle. |
| 198 | **/ |
| 199 | typedef |
| 200 | EFI_STATUS |
| 201 | (EFIAPI *EFI_MM_INTERRUPT_UNREGISTER)( |
| 202 | IN EFI_HANDLE DispatchHandle |
| 203 | ); |
| 204 | |
| 205 | /// |
| 206 | /// Processor information and functionality needed by MM Foundation. |
| 207 | /// |
| 208 | typedef struct _EFI_MM_ENTRY_CONTEXT { |
| 209 | EFI_MM_STARTUP_THIS_AP MmStartupThisAp; |
| 210 | /// |
| 211 | /// A number between zero and the NumberOfCpus field. This field designates which |
| 212 | /// processor is executing the MM Foundation. |
| 213 | /// |
| 214 | UINTN CurrentlyExecutingCpu; |
| 215 | /// |
| 216 | /// The number of possible processors in the platform. This is a 1 based |
| 217 | /// counter. This does not indicate the number of processors that entered MM. |
| 218 | /// |
| 219 | UINTN NumberOfCpus; |
| 220 | /// |
| 221 | /// Points to an array, where each element describes the number of bytes in the |
| 222 | /// corresponding save state specified by CpuSaveState. There are always |
| 223 | /// NumberOfCpus entries in the array. |
| 224 | /// |
| 225 | UINTN *CpuSaveStateSize; |
| 226 | /// |
| 227 | /// Points to an array, where each element is a pointer to a CPU save state. The |
| 228 | /// corresponding element in CpuSaveStateSize specifies the number of bytes in the |
| 229 | /// save state area. There are always NumberOfCpus entries in the array. |
| 230 | /// |
| 231 | VOID **CpuSaveState; |
| 232 | } EFI_MM_ENTRY_CONTEXT; |
| 233 | |
| 234 | /** |
| 235 | This function is the main entry point to the MM Foundation. |
| 236 | |
| 237 | @param[in] MmEntryContext Processor information and functionality needed by MM Foundation. |
| 238 | **/ |
| 239 | typedef |
| 240 | VOID |
| 241 | (EFIAPI *EFI_MM_ENTRY_POINT)( |
| 242 | IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext |
| 243 | ); |
| 244 | |
| 245 | /// |
| 246 | /// Management Mode System Table (MMST) |
| 247 | /// |
| 248 | /// The Management Mode System Table (MMST) is a table that contains a collection of common |
| 249 | /// services for managing MMRAM allocation and providing basic I/O services. These services are |
| 250 | /// intended for both preboot and runtime usage. |
| 251 | /// |
| 252 | struct _EFI_MM_SYSTEM_TABLE { |
| 253 | /// |
| 254 | /// The table header for the SMST. |
| 255 | /// |
| 256 | EFI_TABLE_HEADER Hdr; |
| 257 | /// |
| 258 | /// A pointer to a NULL-terminated Unicode string containing the vendor name. |
| 259 | /// It is permissible for this pointer to be NULL. |
| 260 | /// |
| 261 | CHAR16 *MmFirmwareVendor; |
| 262 | /// |
| 263 | /// The particular revision of the firmware. |
| 264 | /// |
| 265 | UINT32 MmFirmwareRevision; |
| 266 | |
| 267 | EFI_MM_INSTALL_CONFIGURATION_TABLE MmInstallConfigurationTable; |
| 268 | |
| 269 | /// |
| 270 | /// I/O Service |
| 271 | /// |
| 272 | EFI_MM_CPU_IO_PROTOCOL MmIo; |
| 273 | |
| 274 | /// |
| 275 | /// Runtime memory services |
| 276 | /// |
| 277 | EFI_ALLOCATE_POOL MmAllocatePool; |
| 278 | EFI_FREE_POOL MmFreePool; |
| 279 | EFI_ALLOCATE_PAGES MmAllocatePages; |
| 280 | EFI_FREE_PAGES MmFreePages; |
| 281 | |
| 282 | /// |
| 283 | /// MP service |
| 284 | /// |
| 285 | EFI_MM_STARTUP_THIS_AP MmStartupThisAp; |
| 286 | |
| 287 | /// |
| 288 | /// CPU information records |
| 289 | /// |
| 290 | |
| 291 | /// |
| 292 | /// A number between zero and and the NumberOfCpus field. This field designates |
| 293 | /// which processor is executing the MM infrastructure. |
| 294 | /// |
| 295 | UINTN CurrentlyExecutingCpu; |
| 296 | /// |
| 297 | /// The number of possible processors in the platform. This is a 1 based counter. |
| 298 | /// |
| 299 | UINTN NumberOfCpus; |
| 300 | /// |
| 301 | /// Points to an array, where each element describes the number of bytes in the |
| 302 | /// corresponding save state specified by CpuSaveState. There are always |
| 303 | /// NumberOfCpus entries in the array. |
| 304 | /// |
| 305 | UINTN *CpuSaveStateSize; |
| 306 | /// |
| 307 | /// Points to an array, where each element is a pointer to a CPU save state. The |
| 308 | /// corresponding element in CpuSaveStateSize specifies the number of bytes in the |
| 309 | /// save state area. There are always NumberOfCpus entries in the array. |
| 310 | /// |
| 311 | VOID **CpuSaveState; |
| 312 | |
| 313 | /// |
| 314 | /// Extensibility table |
| 315 | /// |
| 316 | |
| 317 | /// |
| 318 | /// The number of UEFI Configuration Tables in the buffer MmConfigurationTable. |
| 319 | /// |
| 320 | UINTN NumberOfTableEntries; |
| 321 | /// |
| 322 | /// A pointer to the UEFI Configuration Tables. The number of entries in the table is |
| 323 | /// NumberOfTableEntries. |
| 324 | /// |
| 325 | EFI_CONFIGURATION_TABLE *MmConfigurationTable; |
| 326 | |
| 327 | /// |
| 328 | /// Protocol services |
| 329 | /// |
| 330 | EFI_INSTALL_PROTOCOL_INTERFACE MmInstallProtocolInterface; |
| 331 | EFI_UNINSTALL_PROTOCOL_INTERFACE MmUninstallProtocolInterface; |
| 332 | EFI_HANDLE_PROTOCOL MmHandleProtocol; |
| 333 | EFI_MM_REGISTER_PROTOCOL_NOTIFY MmRegisterProtocolNotify; |
| 334 | EFI_LOCATE_HANDLE MmLocateHandle; |
| 335 | EFI_LOCATE_PROTOCOL MmLocateProtocol; |
| 336 | |
| 337 | /// |
| 338 | /// MMI Management functions |
| 339 | /// |
| 340 | EFI_MM_INTERRUPT_MANAGE MmiManage; |
| 341 | EFI_MM_INTERRUPT_REGISTER MmiHandlerRegister; |
| 342 | EFI_MM_INTERRUPT_UNREGISTER MmiHandlerUnRegister; |
| 343 | }; |
| 344 | |
| 345 | #endif |