PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/edk2/Clover/UefiCpuPkg/Include/Library/LocalApicLib.h

https://gitlab.com/envieidoc/Clover
C Header | 372 lines | 140 code | 29 blank | 203 comment | 0 complexity | 55e39aa92b3c3a231b4112e4aed1d0c8 MD5 | raw file
  1. /** @file
  2. Public include file for Local APIC library.
  3. Local APIC library assumes local APIC is enabled. It does not
  4. handles cases where local APIC is disabled.
  5. Copyright (c) 2010 - 2011, 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. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  12. **/
  13. #ifndef __LOCAL_APIC_LIB_H__
  14. #define __LOCAL_APIC_LIB_H__
  15. #define LOCAL_APIC_MODE_XAPIC 0x1 ///< xAPIC mode.
  16. #define LOCAL_APIC_MODE_X2APIC 0x2 ///< x2APIC mode.
  17. /**
  18. Get the current local APIC mode.
  19. If local APIC is disabled, then ASSERT.
  20. @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC.
  21. @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC.
  22. **/
  23. UINTN
  24. EFIAPI
  25. GetApicMode (
  26. VOID
  27. );
  28. /**
  29. Set the current local APIC mode.
  30. If the specified local APIC mode is not valid, then ASSERT.
  31. If the specified local APIC mode can't be set as current, then ASSERT.
  32. @param ApicMode APIC mode to be set.
  33. **/
  34. VOID
  35. EFIAPI
  36. SetApicMode (
  37. IN UINTN ApicMode
  38. );
  39. /**
  40. Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset.
  41. In xAPIC mode, the initial local APIC ID is 8-bit, and may be different from current APIC ID.
  42. In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case,
  43. the 32-bit local APIC ID is returned as initial APIC ID.
  44. @return 32-bit initial local APIC ID of the executing processor.
  45. **/
  46. UINT32
  47. EFIAPI
  48. GetInitialApicId (
  49. VOID
  50. );
  51. /**
  52. Get the local APIC ID of the executing processor.
  53. @return 32-bit local APIC ID of the executing processor.
  54. **/
  55. UINT32
  56. EFIAPI
  57. GetApicId (
  58. VOID
  59. );
  60. /**
  61. Get the value of the local APIC version register.
  62. @return the value of the local APIC version register.
  63. **/
  64. UINT32
  65. EFIAPI
  66. GetApicVersion (
  67. VOID
  68. );
  69. /**
  70. Send a Fixed IPI to a specified target processor.
  71. This function returns after the IPI has been accepted by the target processor.
  72. @param ApicId The local APIC ID of the target processor.
  73. @param Vector The vector number of the interrupt being sent.
  74. **/
  75. VOID
  76. EFIAPI
  77. SendFixedIpi (
  78. IN UINT32 ApicId,
  79. IN UINT8 Vector
  80. );
  81. /**
  82. Send a Fixed IPI to all processors excluding self.
  83. This function returns after the IPI has been accepted by the target processors.
  84. @param Vector The vector number of the interrupt being sent.
  85. **/
  86. VOID
  87. EFIAPI
  88. SendFixedIpiAllExcludingSelf (
  89. IN UINT8 Vector
  90. );
  91. /**
  92. Send a SMI IPI to a specified target processor.
  93. This function returns after the IPI has been accepted by the target processor.
  94. @param ApicId Specify the local APIC ID of the target processor.
  95. **/
  96. VOID
  97. EFIAPI
  98. SendSmiIpi (
  99. IN UINT32 ApicId
  100. );
  101. /**
  102. Send a SMI IPI to all processors excluding self.
  103. This function returns after the IPI has been accepted by the target processors.
  104. **/
  105. VOID
  106. EFIAPI
  107. SendSmiIpiAllExcludingSelf (
  108. VOID
  109. );
  110. /**
  111. Send an INIT IPI to a specified target processor.
  112. This function returns after the IPI has been accepted by the target processor.
  113. @param ApicId Specify the local APIC ID of the target processor.
  114. **/
  115. VOID
  116. EFIAPI
  117. SendInitIpi (
  118. IN UINT32 ApicId
  119. );
  120. /**
  121. Send an INIT IPI to all processors excluding self.
  122. This function returns after the IPI has been accepted by the target processors.
  123. **/
  124. VOID
  125. EFIAPI
  126. SendInitIpiAllExcludingSelf (
  127. VOID
  128. );
  129. /**
  130. Send an INIT-Start-up-Start-up IPI sequence to a specified target processor.
  131. This function returns after the IPI has been accepted by the target processor.
  132. if StartupRoutine >= 1M, then ASSERT.
  133. if StartupRoutine is not multiple of 4K, then ASSERT.
  134. @param ApicId Specify the local APIC ID of the target processor.
  135. @param StartupRoutine Points to a start-up routine which is below 1M physical
  136. address and 4K aligned.
  137. **/
  138. VOID
  139. EFIAPI
  140. SendInitSipiSipi (
  141. IN UINT32 ApicId,
  142. IN UINT32 StartupRoutine
  143. );
  144. /**
  145. Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self.
  146. This function returns after the IPI has been accepted by the target processors.
  147. if StartupRoutine >= 1M, then ASSERT.
  148. if StartupRoutine is not multiple of 4K, then ASSERT.
  149. @param StartupRoutine Points to a start-up routine which is below 1M physical
  150. address and 4K aligned.
  151. **/
  152. VOID
  153. EFIAPI
  154. SendInitSipiSipiAllExcludingSelf (
  155. IN UINT32 StartupRoutine
  156. );
  157. /**
  158. Programming Virtual Wire Mode.
  159. This function programs the local APIC for virtual wire mode following
  160. the example described in chapter A.3 of the MP 1.4 spec.
  161. IOxAPIC is not involved in this type of virtual wire mode.
  162. **/
  163. VOID
  164. EFIAPI
  165. ProgramVirtualWireMode (
  166. VOID
  167. );
  168. /**
  169. Disable LINT0 & LINT1 interrupts.
  170. This function sets the mask flag in the LVT LINT0 & LINT1 registers.
  171. **/
  172. VOID
  173. EFIAPI
  174. DisableLvtInterrupts (
  175. VOID
  176. );
  177. /**
  178. Read the initial count value from the init-count register.
  179. @return The initial count value read from the init-count register.
  180. **/
  181. UINT32
  182. EFIAPI
  183. GetApicTimerInitCount (
  184. VOID
  185. );
  186. /**
  187. Read the current count value from the current-count register.
  188. @return The current count value read from the current-count register.
  189. **/
  190. UINT32
  191. EFIAPI
  192. GetApicTimerCurrentCount (
  193. VOID
  194. );
  195. /**
  196. Initialize the local APIC timer.
  197. The local APIC timer is initialized and enabled.
  198. @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128.
  199. If it is 0, then use the current divide value in the DCR.
  200. @param InitCount The initial count value.
  201. @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot.
  202. @param Vector The timer interrupt vector number.
  203. **/
  204. VOID
  205. EFIAPI
  206. InitializeApicTimer (
  207. IN UINTN DivideValue,
  208. IN UINT32 InitCount,
  209. IN BOOLEAN PeriodicMode,
  210. IN UINT8 Vector
  211. );
  212. /**
  213. Get the state of the local APIC timer.
  214. @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128.
  215. @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot.
  216. @param Vector Return the timer interrupt vector number.
  217. **/
  218. VOID
  219. EFIAPI
  220. GetApicTimerState (
  221. OUT UINTN *DivideValue OPTIONAL,
  222. OUT BOOLEAN *PeriodicMode OPTIONAL,
  223. OUT UINT8 *Vector OPTIONAL
  224. );
  225. /**
  226. Enable the local APIC timer interrupt.
  227. **/
  228. VOID
  229. EFIAPI
  230. EnableApicTimerInterrupt (
  231. VOID
  232. );
  233. /**
  234. Disable the local APIC timer interrupt.
  235. **/
  236. VOID
  237. EFIAPI
  238. DisableApicTimerInterrupt (
  239. VOID
  240. );
  241. /**
  242. Get the local APIC timer interrupt state.
  243. @retval TRUE The local APIC timer interrupt is enabled.
  244. @retval FALSE The local APIC timer interrupt is disabled.
  245. **/
  246. BOOLEAN
  247. EFIAPI
  248. GetApicTimerInterruptState (
  249. VOID
  250. );
  251. /**
  252. Send EOI to the local APIC.
  253. **/
  254. VOID
  255. EFIAPI
  256. SendApicEoi (
  257. VOID
  258. );
  259. /**
  260. Get the 32-bit address that a device should use to send a Message Signaled
  261. Interrupt (MSI) to the Local APIC of the currently executing processor.
  262. @return 32-bit address used to send an MSI to the Local APIC.
  263. **/
  264. UINT32
  265. EFIAPI
  266. GetApicMsiAddress (
  267. VOID
  268. );
  269. /**
  270. Get the 64-bit data value that a device should use to send a Message Signaled
  271. Interrupt (MSI) to the Local APIC of the currently executing processor.
  272. If Vector is not in range 0x10..0xFE, then ASSERT().
  273. If DeliveryMode is not supported, then ASSERT().
  274. @param Vector The 8-bit interrupt vector associated with the MSI.
  275. Must be in the range 0x10..0xFE
  276. @param DeliveryMode A 3-bit value that specifies how the recept of the MSI
  277. is handled. The only supported values are:
  278. 0: LOCAL_APIC_DELIVERY_MODE_FIXED
  279. 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY
  280. 2: LOCAL_APIC_DELIVERY_MODE_SMI
  281. 4: LOCAL_APIC_DELIVERY_MODE_NMI
  282. 5: LOCAL_APIC_DELIVERY_MODE_INIT
  283. 7: LOCAL_APIC_DELIVERY_MODE_EXTINT
  284. @param LevelTriggered TRUE specifies a level triggered interrupt.
  285. FALSE specifies an edge triggered interrupt.
  286. @param AssertionLevel Ignored if LevelTriggered is FALSE.
  287. TRUE specifies a level triggered interrupt that active
  288. when the interrupt line is asserted.
  289. FALSE specifies a level triggered interrupt that active
  290. when the interrupt line is deasserted.
  291. @return 64-bit data value used to send an MSI to the Local APIC.
  292. **/
  293. UINT64
  294. EFIAPI
  295. GetApicMsiValue (
  296. IN UINT8 Vector,
  297. IN UINTN DeliveryMode,
  298. IN BOOLEAN LevelTriggered,
  299. IN BOOLEAN AssertionLevel
  300. );
  301. #endif