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