TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiCpuExceptionHandlerUnitTest.c
Go to the documentation of this file.
1
13
20VOID *
22 VOID
23 )
24{
25 UINTN *NewIdtTable;
26 IA32_DESCRIPTOR *Idtr;
27
28 Idtr = AllocateZeroPool (sizeof (IA32_DESCRIPTOR));
29 ASSERT (Idtr != NULL);
30 NewIdtTable = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM + sizeof (UINTN));
31 ASSERT (NewIdtTable != NULL);
32 //
33 // Store original PeiServicePointer before new Idt table
34 //
35 *NewIdtTable = (UINTN)GetPeiServicesTablePointer ();
36 NewIdtTable = (UINTN *)((UINTN)NewIdtTable + sizeof (UINTN));
37
38 Idtr->Base = (UINTN)NewIdtTable;
39 Idtr->Limit = (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM - 1);
40
41 AsmWriteIdtr (Idtr);
42 return Idtr;
43}
44
59 IN MP_SERVICES MpServices,
60 OUT UINTN *NumberOfProcessors,
61 OUT UINTN *NumberOfEnabledProcessors
62 )
63{
64 return MpServices.Ppi->GetNumberOfProcessors (MpServices.Ppi, NumberOfProcessors, NumberOfEnabledProcessors);
65}
66
83 IN MP_SERVICES MpServices,
84 IN EFI_AP_PROCEDURE Procedure,
85 IN UINTN ProcessorNumber,
86 IN UINTN TimeoutInMicroSeconds,
87 IN VOID *ProcedureArgument
88 )
89{
90 return MpServices.Ppi->StartupThisAP (MpServices.Ppi, Procedure, ProcessorNumber, TimeoutInMicroSeconds, ProcedureArgument);
91}
92
111 IN MP_SERVICES MpServices,
112 IN EFI_AP_PROCEDURE Procedure,
113 IN BOOLEAN SingleThread,
114 IN UINTN TimeoutInMicroSeconds,
115 IN VOID *ProcedureArgument
116 )
117{
118 return MpServices.Ppi->StartupAllAPs (MpServices.Ppi, Procedure, SingleThread, TimeoutInMicroSeconds, ProcedureArgument);
119}
120
132 IN MP_SERVICES MpServices,
133 OUT UINTN *ProcessorNumber
134 )
135{
136 return MpServices.Ppi->WhoAmI (MpServices.Ppi, ProcessorNumber);
137}
138
149 OUT MP_SERVICES *MpServices
150 )
151{
152 return PeiServicesLocatePpi (&gEdkiiPeiMpServices2PpiGuid, 0, NULL, (VOID **)&MpServices->Ppi);
153}
154
165EFIAPI
167 IN EFI_PEI_FILE_HANDLE FileHandle,
168 IN CONST EFI_PEI_SERVICES **PeiServices
169 )
170{
171 EFI_STATUS Status;
172 UNIT_TEST_FRAMEWORK_HANDLE Framework;
173
174 Framework = NULL;
175
176 DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
177
178 //
179 // Start setting up the test framework for running the tests.
180 //
181 Status = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
182 if (EFI_ERROR (Status)) {
183 DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
184 goto EXIT;
185 }
186
187 Status = AddCommonTestCase (Framework);
188 if (EFI_ERROR (Status)) {
189 DEBUG ((DEBUG_ERROR, "Failed in AddCommonTestCase. Status = %r\n", Status));
190 goto EXIT;
191 }
192
193 //
194 // Execute the tests.
195 //
196 Status = RunAllTestSuites (Framework);
197
198EXIT:
199 if (Framework) {
200 FreeUnitTestFramework (Framework);
201 }
202
203 return Status;
204}
UINT64 UINTN
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
EFI_STATUS AddCommonTestCase(IN UNIT_TEST_FRAMEWORK_HANDLE Framework)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS MpServicesUnitTestWhoAmI(IN MP_SERVICES MpServices, OUT UINTN *ProcessorNumber)
EFI_STATUS MpServicesUnitTestStartupAllAPs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
EFI_STATUS GetMpServices(OUT MP_SERVICES *MpServices)
EFI_STATUS MpServicesUnitTestGetNumberOfProcessors(IN MP_SERVICES MpServices, OUT UINTN *NumberOfProcessors, OUT UINTN *NumberOfEnabledProcessors)
EFI_STATUS EFIAPI PeiEntryPoint(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
VOID * InitializeBspIdt(VOID)
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: RunTests.c:145
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: UnitTestLib.c:150
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
Definition: UnitTestLib.c:204
VOID EFIAPI AsmWriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)