--- /dev/null
+/** @file\r
+ EFI MM MP Protocol is defined in the PI 1.5 specification.\r
+\r
+ The MM MP protocol provides a set of functions to allow execution of procedures on processors that\r
+ have entered MM. This protocol has the following properties:\r
+ 1. The caller can only invoke execution of a procedure on a processor, other than the caller, that\r
+ has also entered MM.\r
+ 2. It is possible to invoke a procedure on multiple processors. Supports blocking and non-blocking\r
+ modes of operation.\r
+\r
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef _MM_MP_H_\r
+#define _MM_MP_H_\r
+\r
+#include <Pi/PiMmCis.h>\r
+\r
+#define EFI_MM_MP_PROTOCOL_GUID \\r
+ { \\r
+ 0x5d5450d7, 0x990c, 0x4180, {0xa8, 0x3, 0x8e, 0x63, 0xf0, 0x60, 0x83, 0x7 } \\r
+ }\r
+\r
+//\r
+// Revision definition.\r
+//\r
+#define EFI_MM_MP_PROTOCOL_REVISION 0x00\r
+\r
+//\r
+// Attribute flags\r
+//\r
+#define EFI_MM_MP_TIMEOUT_SUPPORTED 0x01\r
+\r
+//\r
+// Completion token\r
+//\r
+typedef VOID* MM_COMPLETION;\r
+\r
+typedef struct {\r
+ MM_COMPLETION Completion;\r
+ EFI_STATUS Status;\r
+} MM_DISPATCH_COMPLETION_TOKEN;\r
+\r
+typedef struct _EFI_MM_MP_PROTOCOL EFI_MM_MP_PROTOCOL;\r
+\r
+/**\r
+ Service to retrieves the number of logical processor in the platform.\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[out] NumberOfProcessors Pointer to the total number of logical processors in the system,\r
+ including the BSP and all APs.\r
+\r
+ @retval EFI_SUCCESS The number of processors was retrieved successfully\r
+ @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MM_GET_NUMBER_OF_PROCESSORS) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ OUT UINTN *NumberOfProcessors\r
+);\r
+\r
+\r
+/**\r
+ This service allows the caller to invoke a procedure one of the application processors (AP). This\r
+ function uses an optional token parameter to support blocking and non-blocking modes. If the token\r
+ is passed into the call, the function will operate in a non-blocking fashion and the caller can\r
+ check for completion with CheckOnProcedure or WaitForProcedure.\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[in] Procedure A pointer to the procedure to be run on the designated target\r
+ AP of the system. Type EFI_AP_PROCEDURE2 is defined below in\r
+ related definitions.\r
+ @param[in] CpuNumber The zero-based index of the processor number of the target\r
+ AP, on which the code stream is supposed to run. If the number\r
+ points to the calling processor then it will not run the\r
+ supplied code.\r
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for this AP to\r
+ finish execution of Procedure, either for blocking or\r
+ non-blocking mode. Zero means infinity. If the timeout\r
+ expires before this AP returns from Procedure, then Procedure\r
+ on the AP is terminated. If the timeout expires in blocking\r
+ mode, the call returns EFI_TIMEOUT. If the timeout expires\r
+ in non-blocking mode, the timeout determined can be through\r
+ CheckOnProcedure or WaitForProcedure.\r
+ Note that timeout support is optional. Whether an\r
+ implementation supports this feature, can be determined via\r
+ the Attributes data member.\r
+ @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code\r
+ that is run by the AP. It is an optional common mailbox\r
+ between APs and the caller to share information.\r
+ @param[in,out] Token This is parameter is broken into two components:\r
+ 1.Token->Completion is an optional parameter that allows the\r
+ caller to execute the procedure in a blocking or non-blocking\r
+ fashion. If it is NULL the call is blocking, and the call will\r
+ not return until the AP has completed the procedure. If the\r
+ token is not NULL, the call will return immediately. The caller\r
+ can check whether the procedure has completed with\r
+ CheckOnProcedure or WaitForProcedure.\r
+ 2.Token->Status The implementation updates the address pointed\r
+ at by this variable with the status code returned by Procedure\r
+ when it completes execution on the target AP, or with EFI_TIMEOUT\r
+ if the Procedure fails to complete within the optional timeout.\r
+ The implementation will update this variable with EFI_NOT_READY\r
+ prior to starting Procedure on the target AP.\r
+ @param[in,out] CPUStatus This optional pointer may be used to get the status code returned\r
+ by Procedure when it completes execution on the target AP, or with\r
+ EFI_TIMEOUT if the Procedure fails to complete within the optional\r
+ timeout. The implementation will update this variable with\r
+ EFI_NOT_READY prior to starting Procedure on the target AP.\r
+\r
+ @retval EFI_SUCCESS In the blocking case, this indicates that Procedure has completed\r
+ execution on the target AP.\r
+ In the non-blocking case this indicates that the procedure has\r
+ been successfully scheduled for execution on the target AP.\r
+ @retval EFI_INVALID_PARAMETER The input arguments are out of range. Either the target AP is the\r
+ caller of the function, or the Procedure or Token is NULL\r
+ @retval EFI_NOT_READY If the target AP is busy executing another procedure\r
+ @retval EFI_ALREADY_STARTED Token is already in use for another procedure\r
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before the specified AP\r
+ has finished\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MM_DISPATCH_PROCEDURE) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ IN EFI_AP_PROCEDURE2 Procedure,\r
+ IN UINTN CpuNumber,\r
+ IN UINTN TimeoutInMicroseconds,\r
+ IN OUT VOID *ProcedureArguments OPTIONAL,\r
+ IN OUT MM_COMPLETION *Token,\r
+ IN OUT EFI_STATUS *CPUStatus\r
+);\r
+\r
+/**\r
+ This service allows the caller to invoke a procedure on all running application processors (AP)\r
+ except the caller. This function uses an optional token parameter to support blocking and\r
+ nonblocking modes. If the token is passed into the call, the function will operate in a non-blocking\r
+ fashion and the caller can check for completion with CheckOnProcedure or WaitForProcedure.\r
+\r
+ It is not necessary for the implementation to run the procedure on every processor on the platform.\r
+ Processors that are powered down in such a way that they cannot respond to interrupts, may be\r
+ excluded from the broadcast.\r
+\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[in] Procedure A pointer to the code stream to be run on the APs that have\r
+ entered MM. Type EFI_AP_PROCEDURE is defined below in related\r
+ definitions.\r
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for the APs to finish\r
+ execution of Procedure, either for blocking or non-blocking mode.\r
+ Zero means infinity. If the timeout expires before all APs return\r
+ from Procedure, then Procedure on the failed APs is terminated. If\r
+ the timeout expires in blocking mode, the call returns EFI_TIMEOUT.\r
+ If the timeout expires in non-blocking mode, the timeout determined\r
+ can be through CheckOnProcedure or WaitForProcedure.\r
+ Note that timeout support is optional. Whether an implementation\r
+ supports this feature can be determined via the Attributes data\r
+ member.\r
+ @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code\r
+ that is run by the AP. It is an optional common mailbox\r
+ between APs and the caller to share information.\r
+ @param[in,out] Token This is parameter is broken into two components:\r
+ 1.Token->Completion is an optional parameter that allows the\r
+ caller to execute the procedure in a blocking or non-blocking\r
+ fashion. If it is NULL the call is blocking, and the call will\r
+ not return until the AP has completed the procedure. If the\r
+ token is not NULL, the call will return immediately. The caller\r
+ can check whether the procedure has completed with\r
+ CheckOnProcedure or WaitForProcedure.\r
+ 2.Token->Status The implementation updates the address pointed\r
+ at by this variable with the status code returned by Procedure\r
+ when it completes execution on the target AP, or with EFI_TIMEOUT\r
+ if the Procedure fails to complete within the optional timeout.\r
+ The implementation will update this variable with EFI_NOT_READY\r
+ prior to starting Procedure on the target AP\r
+ @param[in,out] CPUStatus This optional pointer may be used to get the individual status\r
+ returned by every AP that participated in the broadcast. This\r
+ parameter if used provides the base address of an array to hold\r
+ the EFI_STATUS value of each AP in the system. The size of the\r
+ array can be ascertained by the GetNumberOfProcessors function.\r
+ As mentioned above, the broadcast may not include every processor\r
+ in the system. Some implementations may exclude processors that\r
+ have been powered down in such a way that they are not responsive\r
+ to interrupts. Additionally the broadcast excludes the processor\r
+ which is making the BroadcastProcedure call. For every excluded\r
+ processor, the array entry must contain a value of EFI_NOT_STARTED\r
+\r
+ @retval EFI_SUCCESS In the blocking case, this indicates that Procedure has completed\r
+ execution on the APs. In the non-blocking case this indicates that\r
+ the procedure has been successfully scheduled for execution on the\r
+ APs.\r
+ @retval EFI_INVALID_PARAMETER Procedure or Token is NULL.\r
+ @retval EFI_NOT_READY If a target AP is busy executing another procedure.\r
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all enabled APs have\r
+ finished.\r
+ @retval EFI_ALREADY_STARTED Before the AP procedure associated with the Token is finished, the\r
+ same Token cannot be used to dispatch or broadcast another procedure.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MM_BROADCAST_PROCEDURE) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ IN EFI_AP_PROCEDURE2 Procedure,\r
+ IN UINTN TimeoutInMicroseconds,\r
+ IN OUT VOID *ProcedureArguments OPTIONAL,\r
+ IN OUT MM_COMPLETION *Token,\r
+ IN OUT EFI_STATUS *CPUStatus\r
+);\r
+\r
+\r
+/**\r
+ This service allows the caller to set a startup procedure that will be executed when an AP powers\r
+ up from a state where core configuration and context is lost. The procedure is execution has the\r
+ following properties:\r
+ 1. The procedure executes before the processor is handed over to the operating system.\r
+ 2. All processors execute the same startup procedure.\r
+ 3. The procedure may run in parallel with other procedures invoked through the functions in this\r
+ protocol, or with processors that are executing an MM handler or running in the operating system.\r
+\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[in] Procedure A pointer to the code stream to be run on the designated target AP\r
+ of the system. Type EFI_AP_PROCEDURE is defined below in Volume 2\r
+ with the related definitions of\r
+ EFI_MP_SERVICES_PROTOCOL.StartupAllAPs.\r
+ If caller may pass a value of NULL to deregister any existing\r
+ startup procedure.\r
+ @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code that is\r
+ run by the AP. It is an optional common mailbox between APs and\r
+ the caller to share information\r
+\r
+ @retval EFI_SUCCESS The Procedure has been set successfully.\r
+ @retval EFI_INVALID_PARAMETER The Procedure is NULL.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MM_SET_STARTUP_PROCEDURE) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ IN EFI_AP_PROCEDURE Procedure,\r
+ IN OUT VOID *ProcedureArguments OPTIONAL\r
+);\r
+\r
+/**\r
+ When non-blocking execution of a procedure on an AP is invoked with DispatchProcedure,\r
+ via the use of a token, this function can be used to check for completion of the procedure on the AP.\r
+ The function takes the token that was passed into the DispatchProcedure call. If the procedure\r
+ is complete, and therefore it is now possible to run another procedure on the same AP, this function\r
+ returns EFI_SUCESS. In this case the status returned by the procedure that executed on the AP is\r
+ returned in the token's Status field. If the procedure has not yet completed, then this function\r
+ returns EFI_NOT_READY.\r
+\r
+ When a non-blocking execution of a procedure is invoked with BroadcastProcedure, via the\r
+ use of a token, this function can be used to check for completion of the procedure on all the\r
+ broadcast APs. The function takes the token that was passed into the BroadcastProcedure\r
+ call. If the procedure is complete on all broadcast APs this function returns EFI_SUCESS. In this\r
+ case the Status field in the token passed into the function reflects the overall result of the\r
+ invocation, which may be EFI_SUCCESS, if all executions succeeded, or the first observed failure.\r
+ If the procedure has not yet completed on the broadcast APs, the function returns\r
+ EFI_NOT_READY.\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[in] Token This parameter describes the token that was passed into\r
+ DispatchProcedure or BroadcastProcedure.\r
+\r
+ @retval EFI_SUCCESS Procedure has completed.\r
+ @retval EFI_NOT_READY The Procedure has not completed.\r
+ @retval EFI_INVALID_PARAMETER Token or Token->Completion is NULL\r
+ @retval EFI_NOT_FOUND Token is not currently in use for a non-blocking call\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CHECK_FOR_PROCEDURE) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ IN MM_COMPLETION Token\r
+);\r
+\r
+/**\r
+ When a non-blocking execution of a procedure on an AP is invoked via DispatchProcedure,\r
+ this function will block the caller until the remote procedure has completed on the designated AP.\r
+ The non-blocking procedure invocation is identified by the Token parameter, which must match the\r
+ token that used when DispatchProcedure was called. Upon completion the status returned by\r
+ the procedure that executed on the AP is used to update the token's Status field.\r
+\r
+ When a non-blocking execution of a procedure on an AP is invoked via BroadcastProcedure\r
+ this function will block the caller until the remote procedure has completed on all of the APs that\r
+ entered MM. The non-blocking procedure invocation is identified by the Token parameter, which\r
+ must match the token that used when BroadcastProcedure was called. Upon completion the\r
+ overall status returned by the procedures that executed on the broadcast AP is used to update the\r
+ token's Status field. The overall status may be EFI_SUCCESS, if all executions succeeded, or the\r
+ first observed failure.\r
+\r
+\r
+ @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
+ @param[in] Token This parameter describes the token that was passed into\r
+ DispatchProcedure or BroadcastProcedure.\r
+\r
+ @retval EFI_SUCCESS Procedure has completed.\r
+ @retval EFI_INVALID_PARAMETER Token or Token->Completion is NULL\r
+ @retval EFI_NOT_FOUND Token is not currently in use for a non-blocking call\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_WAIT_FOR_PROCEDURE) (\r
+ IN CONST EFI_MM_MP_PROTOCOL *This,\r
+ IN MM_COMPLETION Token\r
+);\r
+\r
+\r
+\r
+///\r
+/// The MM MP protocol provides a set of functions to allow execution of procedures on processors that\r
+/// have entered MM.\r
+///\r
+struct _EFI_MM_MP_PROTOCOL {\r
+ UINT32 Revision;\r
+ UINT32 Attributes;\r
+ EFI_MM_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;\r
+ EFI_MM_DISPATCH_PROCEDURE DispatchProcedure;\r
+ EFI_MM_BROADCAST_PROCEDURE BroadcastProcedure;\r
+ EFI_MM_SET_STARTUP_PROCEDURE SetStartupProcedure;\r
+ EFI_CHECK_FOR_PROCEDURE CheckForProcedure;\r
+ EFI_WAIT_FOR_PROCEDURE WaitForProcedure;\r
+};\r
+\r
+extern EFI_GUID gEfiMmMpProtocolGuid;\r
+\r
+#endif\r