TianoCore EDK2 master
Loading...
Searching...
No Matches
SecGetPerformance.c
Go to the documentation of this file.
1
9#include <PiPei.h>
10
11#include <Ppi/SecPerformance.h>
13
15#include <Library/TimerLib.h>
16#include <Library/DebugLib.h>
17
35EFIAPI
37 IN CONST EFI_PEI_SERVICES **PeiServices,
39 OUT FIRMWARE_SEC_PERFORMANCE *Performance
40 )
41{
42 UINT32 Size;
43 UINT32 Count;
44 UINT32 TopOfTemporaryRam;
45 UINT64 Ticker;
46 VOID *TopOfTemporaryRamPpi;
47 EFI_STATUS Status;
48
49 DEBUG ((DEBUG_INFO, "SecGetPerformance\n"));
50
51 Status = (*PeiServices)->LocatePpi (
52 PeiServices,
53 &gTopOfTemporaryRamPpiGuid,
54 0,
55 NULL,
56 (VOID **)&TopOfTemporaryRamPpi
57 );
58 if (EFI_ERROR (Status)) {
59 return EFI_NOT_FOUND;
60 }
61
62 //
63 // |--------------| <- TopOfTemporaryRam
64 // |Number of BSPs|
65 // |--------------|
66 // | BIST |
67 // |--------------|
68 // | .... |
69 // |--------------|
70 // | TSC[63:32] |
71 // |--------------|
72 // | TSC[31:00] |
73 // |--------------|
74 //
75 TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
76 TopOfTemporaryRam -= sizeof (UINT32) * 2;
77 Count = *(UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof (UINT32));
78 Size = Count * sizeof (UINT64);
79
80 Ticker = *(UINT64 *)(UINTN)(TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2);
81 Performance->ResetEnd = GetTimeInNanoSecond (Ticker);
82
83 return EFI_SUCCESS;
84}
UINT64 UINTN
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
#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 EFIAPI SecGetPerformance(IN CONST EFI_PEI_SERVICES **PeiServices, IN PEI_SEC_PERFORMANCE_PPI *This, OUT FIRMWARE_SEC_PERFORMANCE *Performance)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112