AmpereCpuLib.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /** @file
  2. Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef AMPERE_CPU_LIB_H_
  6. #define AMPERE_CPU_LIB_H_
  7. #define SUBNUMA_MODE_MONOLITHIC 0
  8. #define SUBNUMA_MODE_HEMISPHERE 1
  9. #define SUBNUMA_MODE_QUADRANT 2
  10. #define MONOLITIC_NUM_OF_REGION 1
  11. #define HEMISPHERE_NUM_OF_REGION 2
  12. #define QUADRANT_NUM_OF_REGION 4
  13. #define SOCKET_ID(CpuId) ((CpuId) / (PLATFORM_CPU_MAX_CPM * PLATFORM_CPU_NUM_CORES_PER_CPM))
  14. #define CLUSTER_ID(CpuId) (((CpuId) / PLATFORM_CPU_NUM_CORES_PER_CPM) % PLATFORM_CPU_MAX_CPM)
  15. /**
  16. Get current CPU frequency.
  17. @param Socket Socket index.
  18. @return UINTN Current CPU frequency.
  19. **/
  20. UINTN
  21. EFIAPI
  22. CpuGetCurrentFreq (
  23. UINT8 Socket
  24. );
  25. /**
  26. Get maximum CPU frequency.
  27. @param Socket Socket index.
  28. @return UINTN Maximum CPU frequency.
  29. **/
  30. UINTN
  31. EFIAPI
  32. CpuGetMaxFreq (
  33. UINT8 Socket
  34. );
  35. /**
  36. Get CPU voltage.
  37. @param Socket Socket index.
  38. @return UINT8 CPU voltage.
  39. **/
  40. UINT8
  41. EFIAPI
  42. CpuGetVoltage (
  43. UINT8 Socket
  44. );
  45. /**
  46. Get CPU Core order number.
  47. @return UINT8 The order number.
  48. **/
  49. UINT32 *
  50. CpuGetCoreOrder (
  51. VOID
  52. );
  53. /**
  54. Get the SubNUMA mode.
  55. @return UINT8 The SubNUMA mode.
  56. **/
  57. UINT8
  58. EFIAPI
  59. CpuGetSubNumaMode (
  60. VOID
  61. );
  62. /**
  63. Get the number of SubNUMA region.
  64. @return UINT8 The number of SubNUMA region.
  65. **/
  66. UINT8
  67. EFIAPI
  68. CpuGetNumberOfSubNumaRegion (
  69. VOID
  70. );
  71. /**
  72. Get the SubNUMA node of a CPM.
  73. @param SocketId Socket index.
  74. @param Cpm CPM index.
  75. @return UINT8 The SubNUMA node of a CPM.
  76. **/
  77. UINT8
  78. EFIAPI
  79. CpuGetSubNumNode (
  80. UINT8 Socket,
  81. UINT16 Cpm
  82. );
  83. /**
  84. Get the number of supported socket.
  85. @return UINT8 Number of supported socket.
  86. **/
  87. UINT8
  88. EFIAPI
  89. GetNumberOfSupportedSockets (
  90. VOID
  91. );
  92. /**
  93. Get the number of active socket.
  94. @return UINT8 Number of active socket.
  95. **/
  96. UINT8
  97. EFIAPI
  98. GetNumberOfActiveSockets (
  99. VOID
  100. );
  101. /**
  102. Get the number of active CPM per socket.
  103. @param SocketId Socket index.
  104. @return UINT16 Number of CPM.
  105. **/
  106. UINT16
  107. EFIAPI
  108. GetNumberOfActiveCPMsPerSocket (
  109. UINT8 SocketId
  110. );
  111. /**
  112. Get the number of configured CPM per socket.
  113. @param SocketId Socket index.
  114. @return UINT16 Number of configured CPM.
  115. **/
  116. UINT16
  117. EFIAPI
  118. GetNumberOfConfiguredCPMs (
  119. UINT8 SocketId
  120. );
  121. /**
  122. Set the number of configured CPM per socket.
  123. @param SocketId Socket index.
  124. @param NumberOfCPMs Number of CPM to be configured.
  125. @return EFI_SUCCESS Operation succeeded.
  126. @return Others An error has occurred.
  127. **/
  128. EFI_STATUS
  129. EFIAPI
  130. SetNumberOfConfiguredCPMs (
  131. UINT8 SocketId,
  132. UINT16 NumberOfCPMs
  133. );
  134. /**
  135. Get the maximum number of core per socket. This number
  136. should be the same for all sockets.
  137. @return UINT16 Maximum number of core.
  138. **/
  139. UINT16
  140. EFIAPI
  141. GetMaximumNumberOfCores (
  142. VOID
  143. );
  144. /**
  145. Get the number of active cores of a sockets.
  146. @return UINT16 Number of active core.
  147. **/
  148. UINT16
  149. EFIAPI
  150. GetNumberOfActiveCoresPerSocket (
  151. UINT8 SocketId
  152. );
  153. /**
  154. Get the number of active cores of all socket.
  155. @return UINT16 Number of active core.
  156. **/
  157. UINT16
  158. EFIAPI
  159. GetNumberOfActiveCores (
  160. VOID
  161. );
  162. /**
  163. Check if the logical CPU is enabled or not.
  164. @param CpuId The logical Cpu ID. Started from 0.
  165. @return BOOLEAN TRUE if the Cpu enabled
  166. FALSE if the Cpu disabled.
  167. **/
  168. BOOLEAN
  169. EFIAPI
  170. IsCpuEnabled (
  171. UINT16 CpuId
  172. );
  173. /**
  174. Check if the slave socket is present
  175. @return BOOLEAN TRUE if the Slave Cpu is present
  176. FALSE if the Slave Cpu is not present
  177. **/
  178. BOOLEAN
  179. EFIAPI
  180. IsSlaveSocketAvailable (
  181. VOID
  182. );
  183. /**
  184. Check if the slave socket is active
  185. @return BOOLEAN TRUE if the Slave CPU Socket is active.
  186. FALSE if the Slave CPU Socket is not active.
  187. **/
  188. BOOLEAN
  189. EFIAPI
  190. IsSlaveSocketActive (
  191. VOID
  192. );
  193. /**
  194. Check if the CPU product ID is Ac01
  195. @return BOOLEAN TRUE if the Product ID is Ac01
  196. FALSE otherwise.
  197. **/
  198. BOOLEAN
  199. EFIAPI
  200. IsAc01Processor (
  201. VOID
  202. );
  203. #endif /* AMPERE_CPU_LIB_H_ */