SmmCpuService.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /** @file
  2. SMM CPU Service protocol definition.
  3. Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _SMM_CPU_SERVICE_PROTOCOL_H_
  7. #define _SMM_CPU_SERVICE_PROTOCOL_H_
  8. //
  9. // Share some definitions with MP Services and CPU Arch Protocol
  10. //
  11. #include <Protocol/MpService.h>
  12. #include <Protocol/Cpu.h>
  13. #define EFI_SMM_CPU_SERVICE_PROTOCOL_GUID \
  14. { \
  15. 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 } \
  16. }
  17. typedef struct _EFI_SMM_CPU_SERVICE_PROTOCOL EFI_SMM_CPU_SERVICE_PROTOCOL;
  18. //
  19. // Protocol functions
  20. //
  21. /**
  22. Gets processor information on the requested processor at the
  23. instant this call is made. This service may only be called from the BSP.
  24. @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL
  25. instance.
  26. @param[in] ProcessorNumber The handle number of processor.
  27. @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
  28. the requested processor is deposited.
  29. @retval EFI_SUCCESS Processor information was returned.
  30. @retval EFI_DEVICE_ERROR The calling processor is an AP.
  31. @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
  32. @retval EFI_NOT_FOUND The processor with the handle specified by
  33. ProcessorNumber does not exist in the platform.
  34. **/
  35. typedef
  36. EFI_STATUS
  37. (EFIAPI *EFI_SMM_GET_PROCESSOR_INFO)(
  38. IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  39. IN UINTN ProcessorNumber,
  40. OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
  41. );
  42. /**
  43. This service switches the requested AP to be the BSP from that point onward.
  44. This service changes the BSP for all purposes. This call can only be performed
  45. by the current BSP.
  46. This service switches the requested AP to be the BSP from that point onward.
  47. This service changes the BSP for all purposes. The new BSP can take over the
  48. execution of the old BSP and continue seamlessly from where the old one left
  49. off.
  50. If the BSP cannot be switched prior to the return from this service, then
  51. EFI_UNSUPPORTED must be returned.
  52. @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
  53. @param[in] ProcessorNumber The handle number of AP that is to become the new
  54. BSP. The range is from 0 to the total number of
  55. logical processors minus 1.
  56. @retval EFI_SUCCESS BSP successfully switched.
  57. @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
  58. this service returning.
  59. @retval EFI_UNSUPPORTED Switching the BSP is not supported.
  60. @retval EFI_SUCCESS The calling processor is an AP.
  61. @retval EFI_NOT_FOUND The processor with the handle specified by
  62. ProcessorNumber does not exist.
  63. @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
  64. a disabled AP.
  65. @retval EFI_NOT_READY The specified AP is busy.
  66. **/
  67. typedef
  68. EFI_STATUS
  69. (EFIAPI *EFI_SMM_SWITCH_BSP)(
  70. IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  71. IN UINTN ProcessorNumber
  72. );
  73. /**
  74. Notify that a new processor has been added to the system.
  75. The SMM CPU driver should add the processor to the SMM CPU list.
  76. If the processor is disabled it won't participate any SMI handler during subsequent SMIs.
  77. @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
  78. @param ProcessorId The hardware ID of the processor.
  79. @param ProcessorNumber The handle number of processor.
  80. @param ProcessorResource A pointer to EFI_SMM_PROCESSOR_RESOURCE which holds the assigned resources.
  81. @retval EFI_SUCCESS The function completed successfully.
  82. @retval EFI_ALREADY_STARTED Processor already present.
  83. @retval EFI_NOT_READY Space for a new handle could not be allocated.
  84. **/
  85. typedef
  86. EFI_STATUS
  87. (EFIAPI *EFI_SMM_ADD_PROCESSOR)(
  88. IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  89. IN UINT64 ProcessorId,
  90. OUT UINTN *ProcessorNumber
  91. );
  92. /**
  93. Notify that a processor is hot-removed.
  94. Remove a processor from the CPU list of the SMM CPU driver. After this API is called, the removed processor
  95. must not respond to SMIs in the coherence domain.
  96. @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
  97. @param ProcessorId The hardware ID of the processor.
  98. @retval EFI_SUCCESS The function completed successfully.
  99. @retval EFI_NOT_FOUND Processor with the hardware ID specified by ProcessorId does not exist.
  100. @retval EFI_NOT_READY Specified AP is busy.
  101. **/
  102. typedef
  103. EFI_STATUS
  104. (EFIAPI *EFI_SMM_REMOVE_PROCESSOR)(
  105. IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  106. IN UINTN ProcessorNumber
  107. );
  108. /**
  109. This return the handle number for the calling processor. This service may be
  110. called from the BSP and APs.
  111. This service returns the processor handle number for the calling processor.
  112. The returned value is in the range from 0 to the total number of logical
  113. processors minus 1. This service may be called from the BSP and APs.
  114. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
  115. is returned. Otherwise, the current processors handle number is returned in
  116. ProcessorNumber, and EFI_SUCCESS is returned.
  117. @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance.
  118. @param[in] ProcessorNumber The handle number of AP that is to become the new
  119. BSP. The range is from 0 to the total number of
  120. logical processors minus 1.
  121. @retval EFI_SUCCESS The current processor handle number was returned
  122. in ProcessorNumber.
  123. @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
  124. **/
  125. typedef
  126. EFI_STATUS
  127. (EFIAPI *EFI_SMM_WHOAMI)(
  128. IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  129. OUT UINTN *ProcessorNumber
  130. );
  131. /**
  132. Register exception handler.
  133. @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance.
  134. @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and
  135. the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL
  136. of the UEFI 2.0 specification.
  137. @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER
  138. that is called when a processor interrupt occurs.
  139. If this parameter is NULL, then the handler will be uninstalled.
  140. @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
  141. @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed.
  142. @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed.
  143. @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
  144. **/
  145. typedef
  146. EFI_STATUS
  147. (EFIAPI *EFI_SMM_REGISTER_EXCEPTION_HANDLER)(
  148. IN EFI_SMM_CPU_SERVICE_PROTOCOL *This,
  149. IN EFI_EXCEPTION_TYPE ExceptionType,
  150. IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
  151. );
  152. //
  153. // This protocol provides CPU services from SMM.
  154. //
  155. struct _EFI_SMM_CPU_SERVICE_PROTOCOL {
  156. EFI_SMM_GET_PROCESSOR_INFO GetProcessorInfo;
  157. EFI_SMM_SWITCH_BSP SwitchBsp;
  158. EFI_SMM_ADD_PROCESSOR AddProcessor;
  159. EFI_SMM_REMOVE_PROCESSOR RemoveProcessor;
  160. EFI_SMM_WHOAMI WhoAmI;
  161. EFI_SMM_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler;
  162. };
  163. extern EFI_GUID gEfiSmmCpuServiceProtocolGuid;
  164. #endif