TianoCore EDK2 master
Loading...
Searching...
No Matches
InternalCpuCacheInfoLib.h
Go to the documentation of this file.
1
9#ifndef _INTERNAL_CPU_CACHE_INFO_LIB_H_
10#define _INTERNAL_CPU_CACHE_INFO_LIB_H_
11
12#include <PiPei.h>
13#include <Register/Cpuid.h>
14#include <Ppi/MpServices2.h>
15#include <Protocol/MpService.h>
16#include <Library/BaseLib.h>
17#include <Library/DebugLib.h>
21
22typedef union {
23 struct {
24 //
25 // Type of the cache that this package's this type of logical processor corresponds to.
26 // Value = CPUID.04h:EAX[04:00]
27 //
28 UINT32 CacheType : 5;
29 //
30 // Level of the cache that this package's this type of logical processor corresponds to.
31 // Value = CPUID.04h:EAX[07:05]
32 //
33 UINT32 CacheLevel : 3;
34 //
35 // Core type of logical processor.
36 // Value = CPUID.1Ah:EAX[31:24]
37 //
38 UINT32 CoreType : 8;
39 UINT32 Reserved : 16;
40 //
41 // Package number.
42 //
43 UINT32 Package;
44 } Bits;
45 UINT64 Uint64;
47
48typedef struct {
49 //
50 // Package ID, the information comes from
51 // EFI_CPU_PHYSICAL_LOCATION.Package
52 //
53 UINT32 Package;
54 //
55 // APIC ID, the information comes from
56 // EFI_PROCESSOR_INFORMATION.ProcessorId
57 //
58 UINT32 ApicId;
59 //
60 // Core type of logical processor.
61 // Value = CPUID.1Ah:EAX[31:24]
62 //
63 UINT8 CoreType;
65
66typedef struct {
67 //
68 // Level of the cache.
69 // Value = CPUID.04h:EAX[07:05]
70 //
71 UINT8 CacheLevel : 3;
72 //
73 // Type of the cache.
74 // Value = CPUID.04h:EAX[04:00]
75 //
76 UINT8 CacheType : 5;
77 //
78 // Ways of associativity.
79 // Value = CPUID.04h:EBX[31:22]
80 //
81 UINT16 CacheWays : 10;
82 //
83 // Fully associative cache.
84 // Value = CPUID.04h:EAX[09]
85 //
86 UINT16 FullyAssociativeCache : 1;
87 //
88 // Direct mapped cache.
89 // Value = CPUID.04h:EDX[02]
90 //
91 UINT16 DirectMappedCache : 1;
92 UINT16 Reserved : 4;
93 //
94 // Cache share bits.
95 // Value = CPUID.04h:EAX[25:14]
96 //
97 UINT16 CacheShareBits;
98 //
99 // Size of single cache.
100 // Value = (CPUID.04h:EBX[31:22] + 1) * (CPUID.04h:EBX[21:12] + 1) *
101 // (CPUID.04h:EBX[11:00] + 1) * (CPUID.04h:ECX[31:00] + 1)
102 //
103 UINT32 CacheSizeinKB;
105
106typedef union {
108 EFI_MP_SERVICES_PROTOCOL *Protocol;
110
111typedef struct {
112 MP_SERVICES MpServices;
113 CPUID_PROCESSOR_INFO *ProcessorInfo;
114 CPUID_CACHE_DATA *CacheData;
116
117/*
118 Defines the maximum count of Deterministic Cache Parameters Leaf of all APs and BSP.
119 To save boot time, skip starting up all APs to calculate each AP's count of Deterministic
120 Cache Parameters Leaf, so use a definition instead.
121 Anyway, definition value will be checked in CpuCacheInfoCollectCoreAndCacheData function.
122*/
123#define MAX_NUM_OF_CACHE_PARAMS_LEAF 6
124
125/*
126 Defines the maximum count of packages.
127*/
128#define MAX_NUM_OF_PACKAGE 100
129
141 OUT MP_SERVICES *MpServices
142 );
143
151VOID
153 IN MP_SERVICES MpServices,
154 IN EFI_AP_PROCEDURE Procedure,
155 IN VOID *ProcedureArgument
156 );
157
165VOID
167 IN MP_SERVICES MpServices,
168 IN UINTN ProcessorNum,
169 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfo
170 );
171
179UINT32
181 IN MP_SERVICES MpServices
182 );
183
191UINT32
193 IN MP_SERVICES MpServices
194 );
195
196#endif
UINT64 UINTN
UINT32 CpuCacheInfoWhoAmI(IN MP_SERVICES MpServices)
EFI_STATUS CpuCacheInfoGetMpServices(OUT MP_SERVICES *MpServices)
UINT32 CpuCacheInfoGetNumberOfProcessors(IN MP_SERVICES MpServices)
VOID CpuCacheInfoGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNum, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfo)
VOID CpuCacheInfoStartupAllCPUs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN VOID *ProcedureArgument)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29