TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuDriver.h
1/*++ @file
2
3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4Portions copyright (c) 2011, Apple Inc. All rights reserved.
5
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
11#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
12
13#include <PiDxe.h>
15
16#include <Protocol/Cpu.h>
17#include <Protocol/Smbios.h>
18#include <Protocol/MpService.h>
19#include <Protocol/EmuThread.h>
20#include <Protocol/CpuIo2.h>
21
22#include <Guid/IdleLoopEvent.h>
23
24#include <Library/BaseLib.h>
25#include <Library/DebugLib.h>
30#include <Library/EmuThunkLib.h>
31#include <Library/UefiLib.h>
32#include <Library/PcdLib.h>
33
34//
35// Internal Data Structures
36//
37#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')
38
39typedef struct {
40 UINTN Signature;
41 EFI_HANDLE Handle;
42
45
46 //
47 // Local Data for CPU interface goes here
48 //
49 BOOLEAN InterruptState;
51
52#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
53 CR (a, \
54 CPU_ARCH_PROTOCOL_PRIVATE, \
55 Cpu, \
56 CPU_ARCH_PROT_PRIVATE_SIGNATURE \
57 )
58
59typedef enum {
60 CPU_STATE_IDLE,
61 CPU_STATE_BLOCKED,
62 CPU_STATE_READY,
63 CPU_STATE_BUSY,
64 CPU_STATE_FINISHED
65} PROCESSOR_STATE;
66
67//
68// Define Individual Processor Data block.
69//
70typedef struct {
72 EFI_AP_PROCEDURE Procedure;
73 VOID *Parameter;
74 VOID *StateLock;
75 VOID *ProcedureLock;
76 PROCESSOR_STATE State;
77 EFI_EVENT CheckThisAPEvent;
79
80//
81// Define MP data block which consumes individual processor block.
82//
83typedef struct {
84 UINTN NumberOfProcessors;
85 UINTN NumberOfEnabledProcessors;
86 EFI_EVENT CheckAllAPsEvent;
87 EFI_EVENT WaitEvent;
88 UINTN FinishCount;
89 UINTN StartCount;
90 EFI_AP_PROCEDURE Procedure;
91 VOID *ProcedureArgument;
92 BOOLEAN SingleThread;
93 UINTN StartedNumber;
94 PROCESSOR_DATA_BLOCK *ProcessorData;
95 UINTN Timeout;
96 UINTN *FailedList;
97 UINTN FailedListIndex;
98 BOOLEAN TimeoutActive;
100
102EFIAPI
106 IN UINT64 Address,
107 IN UINTN Count,
108 IN OUT VOID *Buffer
109 );
110
112EFIAPI
116 IN UINT64 Address,
117 IN UINTN Count,
118 IN OUT VOID *Buffer
119 );
120
122EFIAPI
126 IN UINT64 UserAddress,
127 IN UINTN Count,
128 IN OUT VOID *UserBuffer
129 );
130
132EFIAPI
136 IN UINT64 UserAddress,
137 IN UINTN Count,
138 IN OUT VOID *UserBuffer
139 );
140
142EFIAPI
143InitializeCpu (
144 IN EFI_HANDLE ImageHandle,
145 IN EFI_SYSTEM_TABLE *SystemTable
146 );
147
149EFIAPI
150EmuFlushCpuDataCache (
153 IN UINT64 Length,
154 IN EFI_CPU_FLUSH_TYPE FlushType
155 );
156
158EFIAPI
159EmuEnableInterrupt (
161 );
162
164EFIAPI
165EmuDisableInterrupt (
167 );
168
170EFIAPI
171EmuGetInterruptState (
173 OUT BOOLEAN *State
174 );
175
177EFIAPI
178EmuInit (
180 IN EFI_CPU_INIT_TYPE InitType
181 );
182
184EFIAPI
185EmuRegisterInterruptHandler (
187 IN EFI_EXCEPTION_TYPE InterruptType,
188 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
189 );
190
192EFIAPI
193EmuGetTimerValue (
195 IN UINT32 TimerIndex,
196 OUT UINT64 *TimerValue,
197 OUT UINT64 *TimerPeriod OPTIONAL
198 );
199
201EFIAPI
202EmuSetMemoryAttributes (
204 IN EFI_PHYSICAL_ADDRESS BaseAddress,
205 IN UINT64 Length,
206 IN UINT64 Attributes
207 );
208
210CpuMpServicesInit (
211 OUT UINTN *MaxCores
212 );
213
215EFIAPI
216CpuMpServicesWhoAmI (
218 OUT UINTN *ProcessorNumber
219 );
220
221extern EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate;
222
223#endif
UINT64 UINTN
STATIC EFI_STATUS EFIAPI CpuMemoryServiceRead(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer)
STATIC EFI_STATUS EFIAPI CpuIoServiceWrite(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
STATIC EFI_STATUS EFIAPI CpuMemoryServiceWrite(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer)
STATIC EFI_STATUS EFIAPI CpuIoServiceRead(IN EFI_CPU_IO2_PROTOCOL *This, IN EFI_CPU_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer)
EFI_CPU_FLUSH_TYPE
Definition: Cpu.h:24
EFI_CPU_INIT_TYPE
Definition: Cpu.h:34
VOID(EFIAPI * EFI_CPU_INTERRUPT_HANDLER)(IN CONST EFI_EXCEPTION_TYPE InterruptType, IN CONST EFI_SYSTEM_CONTEXT SystemContext)
Definition: Cpu.h:52
EFI_CPU_IO_PROTOCOL_WIDTH
Definition: CpuIo2.h:37
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
INTN EFI_EXCEPTION_TYPE
Definition: DebugSupport.h:35
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33