--- /dev/null
+/** @file\r
+SMM CPU Service protocol definition.\r
+\r
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_CPU_SERVICE_PROTOCOL_H_\r
+#define _SMM_CPU_SERVICE_PROTOCOL_H_\r
+\r
+//\r
+// Share some definitions with MP Services and CPU Arch Protocol\r
+//\r
+#include <Protocol/MpService.h>\r
+#include <Protocol/Cpu.h>\r
+\r
+#define EFI_SMM_CPU_SERVICE_PROTOCOL_GUID \\r
+ { \\r
+ 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 } \\r
+ }\r
+\r
+typedef struct _EFI_SMM_CPU_SERVICE_PROTOCOL EFI_SMM_CPU_SERVICE_PROTOCOL;\r
+\r
+//\r
+// Protocol functions\r
+//\r
+\r
+/**\r
+ Gets processor information on the requested processor at the\r
+ instant this call is made. This service may only be called from the BSP.\r
+\r
+ @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL\r
+ instance.\r
+ @param[in] ProcessorNumber The handle number of processor.\r
+ @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
+ the requested processor is deposited.\r
+\r
+ @retval EFI_SUCCESS Processor information was returned.\r
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
+ @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r
+ @retval EFI_NOT_FOUND The processor with the handle specified by\r
+ ProcessorNumber does not exist in the platform.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_SMM_GET_PROCESSOR_INFO) (\r
+ IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ IN UINTN ProcessorNumber,\r
+ OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r
+ );\r
+\r
+/**\r
+ This service switches the requested AP to be the BSP from that point onward.\r
+ This service changes the BSP for all purposes. This call can only be performed\r
+ by the current BSP.\r
+\r
+ This service switches the requested AP to be the BSP from that point onward.\r
+ This service changes the BSP for all purposes. The new BSP can take over the\r
+ execution of the old BSP and continue seamlessly from where the old one left\r
+ off.\r
+\r
+ If the BSP cannot be switched prior to the return from this service, then\r
+ EFI_UNSUPPORTED must be returned.\r
+\r
+ @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.\r
+ @param[in] ProcessorNumber The handle number of AP that is to become the new\r
+ BSP. The range is from 0 to the total number of\r
+ logical processors minus 1.\r
+\r
+ @retval EFI_SUCCESS BSP successfully switched.\r
+ @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r
+ this service returning.\r
+ @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r
+ @retval EFI_SUCCESS The calling processor is an AP.\r
+ @retval EFI_NOT_FOUND The processor with the handle specified by\r
+ ProcessorNumber does not exist.\r
+ @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r
+ a disabled AP.\r
+ @retval EFI_NOT_READY The specified AP is busy.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_SMM_SWITCH_BSP) (\r
+ IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ IN UINTN ProcessorNumber\r
+ );\r
+\r
+/**\r
+ Notify that a new processor has been added to the system.\r
+\r
+ The SMM CPU driver should add the processor to the SMM CPU list.\r
+\r
+ If the processor is disabled it won't participate any SMI handler during subsequent SMIs.\r
+\r
+ @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.\r
+ @param ProcessorId The hardware ID of the processor.\r
+ @param ProcessorNumber The handle number of processor.\r
+ @param ProcessorResource A pointer to EFI_SMM_PROCESSOR_RESOURCE which holds the assigned resources.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ALREADY_STARTED Processor already present.\r
+ @retval EFI_NOT_READY Space for a new handle could not be allocated.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_ADD_PROCESSOR) (\r
+ IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ IN UINT64 ProcessorId,\r
+ OUT UINTN *ProcessorNumber\r
+ );\r
+\r
+/**\r
+ Notify that a processor is hot-removed.\r
+\r
+ Remove a processor from the CPU list of the SMM CPU driver. After this API is called, the removed processor\r
+ must not respond to SMIs in the coherence domain.\r
+\r
+ @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.\r
+ @param ProcessorId The hardware ID of the processor.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_NOT_FOUND Processor with the hardware ID specified by ProcessorId does not exist.\r
+ @retval EFI_NOT_READY Specified AP is busy.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_REMOVE_PROCESSOR) (\r
+ IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ IN UINTN ProcessorNumber\r
+ );\r
+\r
+/**\r
+ This return the handle number for the calling processor. This service may be\r
+ called from the BSP and APs.\r
+\r
+ This service returns the processor handle number for the calling processor.\r
+ The returned value is in the range from 0 to the total number of logical\r
+ processors minus 1. This service may be called from the BSP and APs.\r
+ If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
+ is returned. Otherwise, the current processors handle number is returned in\r
+ ProcessorNumber, and EFI_SUCCESS is returned.\r
+\r
+ @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.\r
+ @param[in] ProcessorNumber The handle number of AP that is to become the new\r
+ BSP. The range is from 0 to the total number of\r
+ logical processors minus 1.\r
+\r
+ @retval EFI_SUCCESS The current processor handle number was returned\r
+ in ProcessorNumber.\r
+ @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_SMM_WHOAMI) (\r
+ IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ OUT UINTN *ProcessorNumber\r
+ );\r
+\r
+/**\r
+ Register exception handler.\r
+\r
+ @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance.\r
+ @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and\r
+ the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL\r
+ of the UEFI 2.0 specification.\r
+ @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER\r
+ that is called when a processor interrupt occurs.\r
+ If this parameter is NULL, then the handler will be uninstalled.\r
+\r
+ @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r
+ @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed.\r
+ @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed.\r
+ @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_REGISTER_EXCEPTION_HANDLER) (\r
+ IN EFI_SMM_CPU_SERVICE_PROTOCOL *This,\r
+ IN EFI_EXCEPTION_TYPE ExceptionType,\r
+ IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
+ );\r
+\r
+//\r
+// This protocol provides CPU services from SMM.\r
+//\r
+struct _EFI_SMM_CPU_SERVICE_PROTOCOL {\r
+ EFI_SMM_GET_PROCESSOR_INFO GetProcessorInfo;\r
+ EFI_SMM_SWITCH_BSP SwitchBsp;\r
+ EFI_SMM_ADD_PROCESSOR AddProcessor;\r
+ EFI_SMM_REMOVE_PROCESSOR RemoveProcessor;\r
+ EFI_SMM_WHOAMI WhoAmI;\r
+ EFI_SMM_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler;\r
+};\r
+\r
+extern EFI_GUID gEfiSmmCpuServiceProtocolGuid;\r
+\r
+#endif\r