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