CpuDxe.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /** @file
  2. RISC-V CPU DXE module header file.
  3. Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef CPU_DXE_H_
  7. #define CPU_DXE_H_
  8. #include <PiDxe.h>
  9. #include <Protocol/Cpu.h>
  10. #include <Protocol/RiscVBootProtocol.h>
  11. #include <Library/BaseRiscVSbiLib.h>
  12. #include <Library/BaseLib.h>
  13. #include <Library/CpuExceptionHandlerLib.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/UefiBootServicesTableLib.h>
  16. #include <Library/UefiDriverEntryPoint.h>
  17. /**
  18. Flush CPU data cache. If the instruction cache is fully coherent
  19. with all DMA operations then function can just return EFI_SUCCESS.
  20. @param This Protocol instance structure
  21. @param Start Physical address to start flushing from.
  22. @param Length Number of bytes to flush. Round up to chipset
  23. granularity.
  24. @param FlushType Specifies the type of flush operation to perform.
  25. @retval EFI_SUCCESS If cache was flushed
  26. @retval EFI_UNSUPPORTED If flush type is not supported.
  27. @retval EFI_DEVICE_ERROR If requested range could not be flushed.
  28. **/
  29. EFI_STATUS
  30. EFIAPI
  31. CpuFlushCpuDataCache (
  32. IN EFI_CPU_ARCH_PROTOCOL *This,
  33. IN EFI_PHYSICAL_ADDRESS Start,
  34. IN UINT64 Length,
  35. IN EFI_CPU_FLUSH_TYPE FlushType
  36. );
  37. /**
  38. Enables CPU interrupts.
  39. @param This Protocol instance structure
  40. @retval EFI_SUCCESS If interrupts were enabled in the CPU
  41. @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU.
  42. **/
  43. EFI_STATUS
  44. EFIAPI
  45. CpuEnableInterrupt (
  46. IN EFI_CPU_ARCH_PROTOCOL *This
  47. );
  48. /**
  49. Disables CPU interrupts.
  50. @param This Protocol instance structure
  51. @retval EFI_SUCCESS If interrupts were disabled in the CPU.
  52. @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. CpuDisableInterrupt (
  57. IN EFI_CPU_ARCH_PROTOCOL *This
  58. );
  59. /**
  60. Return the state of interrupts.
  61. @param This Protocol instance structure
  62. @param State Pointer to the CPU's current interrupt state
  63. @retval EFI_SUCCESS If interrupts were disabled in the CPU.
  64. @retval EFI_INVALID_PARAMETER State is NULL.
  65. **/
  66. EFI_STATUS
  67. EFIAPI
  68. CpuGetInterruptState (
  69. IN EFI_CPU_ARCH_PROTOCOL *This,
  70. OUT BOOLEAN *State
  71. );
  72. /**
  73. Generates an INIT to the CPU.
  74. @param This Protocol instance structure
  75. @param InitType Type of CPU INIT to perform
  76. @retval EFI_SUCCESS If CPU INIT occurred. This value should never be
  77. seen.
  78. @retval EFI_DEVICE_ERROR If CPU INIT failed.
  79. @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported.
  80. **/
  81. EFI_STATUS
  82. EFIAPI
  83. CpuInit (
  84. IN EFI_CPU_ARCH_PROTOCOL *This,
  85. IN EFI_CPU_INIT_TYPE InitType
  86. );
  87. /**
  88. Registers a function to be called from the CPU interrupt handler.
  89. @param This Protocol instance structure
  90. @param InterruptType Defines which interrupt to hook. IA-32
  91. valid range is 0x00 through 0xFF
  92. @param InterruptHandler A pointer to a function of type
  93. EFI_CPU_INTERRUPT_HANDLER that is called
  94. when a processor interrupt occurs. A null
  95. pointer is an error condition.
  96. @retval EFI_SUCCESS If handler installed or uninstalled.
  97. @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler
  98. for InterruptType was previously installed.
  99. @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for
  100. InterruptType was not previously installed.
  101. @retval EFI_UNSUPPORTED The interrupt specified by InterruptType
  102. is not supported.
  103. **/
  104. EFI_STATUS
  105. EFIAPI
  106. CpuRegisterInterruptHandler (
  107. IN EFI_CPU_ARCH_PROTOCOL *This,
  108. IN EFI_EXCEPTION_TYPE InterruptType,
  109. IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
  110. );
  111. /**
  112. Returns a timer value from one of the CPU's internal timers. There is no
  113. inherent time interval between ticks but is a function of the CPU frequency.
  114. @param This - Protocol instance structure.
  115. @param TimerIndex - Specifies which CPU timer is requested.
  116. @param TimerValue - Pointer to the returned timer value.
  117. @param TimerPeriod - A pointer to the amount of time that passes
  118. in femtoseconds (10-15) for each increment
  119. of TimerValue. If TimerValue does not
  120. increment at a predictable rate, then 0 is
  121. returned. The amount of time that has
  122. passed between two calls to GetTimerValue()
  123. can be calculated with the formula
  124. (TimerValue2 - TimerValue1) * TimerPeriod.
  125. This parameter is optional and may be NULL.
  126. @retval EFI_SUCCESS - If the CPU timer count was returned.
  127. @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers.
  128. @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer.
  129. @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.
  130. **/
  131. EFI_STATUS
  132. EFIAPI
  133. CpuGetTimerValue (
  134. IN EFI_CPU_ARCH_PROTOCOL *This,
  135. IN UINT32 TimerIndex,
  136. OUT UINT64 *TimerValue,
  137. OUT UINT64 *TimerPeriod OPTIONAL
  138. );
  139. /**
  140. Set memory cacheability attributes for given range of memeory.
  141. @param This Protocol instance structure
  142. @param BaseAddress Specifies the start address of the
  143. memory range
  144. @param Length Specifies the length of the memory range
  145. @param Attributes The memory cacheability for the memory range
  146. @retval EFI_SUCCESS If the cacheability of that memory range is
  147. set successfully
  148. @retval EFI_UNSUPPORTED If the desired operation cannot be done
  149. @retval EFI_INVALID_PARAMETER The input parameter is not correct,
  150. such as Length = 0
  151. **/
  152. EFI_STATUS
  153. EFIAPI
  154. CpuSetMemoryAttributes (
  155. IN EFI_CPU_ARCH_PROTOCOL *This,
  156. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  157. IN UINT64 Length,
  158. IN UINT64 Attributes
  159. );
  160. #endif