2 Internal header file for CPU Cache info Library.
4 Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _INTERNAL_CPU_CACHE_INFO_LIB_H_
10 #define _INTERNAL_CPU_CACHE_INFO_LIB_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>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/MemoryAllocationLib.h>
20 #include <Library/CpuCacheInfoLib.h>
24 // Package ID, the information comes from
25 // EFI_CPU_PHYSICAL_LOCATION.Package
29 // APIC ID, the information comes from
30 // EFI_PROCESSOR_INFORMATION.ProcessorId
34 // Core type of logical processor.
35 // Value = CPUID.1Ah:EAX[31:24]
38 } CPUID_PROCESSOR_INFO
;
42 // Level of the cache.
43 // Value = CPUID.04h:EAX[07:05]
48 // Value = CPUID.04h:EAX[04:00]
52 // Ways of associativity.
53 // Value = CPUID.04h:EBX[31:22]
55 UINT16 CacheWays
: 10;
57 // Fully associative cache.
58 // Value = CPUID.04h:EAX[09]
60 UINT16 FullyAssociativeCache
: 1;
62 // Direct mapped cache.
63 // Value = CPUID.04h:EDX[02]
65 UINT16 DirectMappedCache
: 1;
69 // Value = CPUID.04h:EAX[25:14]
71 UINT16 CacheShareBits
;
73 // Size of single cache.
74 // Value = (CPUID.04h:EBX[31:22] + 1) * (CPUID.04h:EBX[21:12] + 1) *
75 // (CPUID.04h:EBX[11:00] + 1) * (CPUID.04h:ECX[31:00] + 1)
81 EDKII_PEI_MP_SERVICES2_PPI
*Ppi
;
82 EFI_MP_SERVICES_PROTOCOL
*Protocol
;
86 MP_SERVICES MpServices
;
87 CPUID_PROCESSOR_INFO
*ProcessorInfo
;
88 CPUID_CACHE_DATA
*CacheData
;
89 } COLLECT_CPUID_CACHE_DATA_CONTEXT
;
93 Defines the maximum count of Deterministic Cache Parameters Leaf of all APs and BSP.
94 To save boot time, skip starting up all APs to calculate each AP's count of Deterministic
95 Cache Parameters Leaf, so use a definition instead.
96 Anyway, definition value will be checked in CpuCacheInfoCollectCoreAndCacheData function.
98 #define MAX_NUM_OF_CACHE_PARAMS_LEAF 6
101 Defines the maximum count of packages.
103 #define MAX_NUM_OF_PACKAGE 100
106 Get EDKII_PEI_MP_SERVICES2_PPI or EFI_MP_SERVICES_PROTOCOL pointer.
108 @param[out] MpServices A pointer to the buffer where EDKII_PEI_MP_SERVICES2_PPI or
109 EFI_MP_SERVICES_PROTOCOL is stored
111 @retval EFI_SUCCESS EDKII_PEI_MP_SERVICES2_PPI or EFI_MP_SERVICES_PROTOCOL interface is returned
112 @retval EFI_NOT_FOUND EDKII_PEI_MP_SERVICES2_PPI or EFI_MP_SERVICES_PROTOCOL interface is not found
115 CpuCacheInfoGetMpServices (
116 OUT MP_SERVICES
*MpServices
120 Activate all of the logical processors.
122 @param[in] MpServices MP_SERVICES structure.
123 @param[in] Procedure A pointer to the function to be run on enabled logical processors.
124 @param[in] ProcedureArgument The parameter passed into Procedure for all enabled logical processors.
127 CpuCacheInfoStartupAllCPUs (
128 IN MP_SERVICES MpServices
,
129 IN EFI_AP_PROCEDURE Procedure
,
130 IN VOID
*ProcedureArgument
134 Get detailed information of the requested logical processor.
136 @param[in] MpServices MP_SERVICES structure.
137 @param[in] ProcessorNum The requested logical processor number.
138 @param[out] ProcessorInfo A pointer to the buffer where the processor information is stored
141 CpuCacheInfoGetProcessorInfo (
142 IN MP_SERVICES MpServices
,
143 IN UINTN ProcessorNum
,
144 OUT EFI_PROCESSOR_INFORMATION
*ProcessorInfo
148 Get the logical processor number.
150 @param[in] MpServices MP_SERVICES structure.
152 @retval Return the logical processor number.
156 IN MP_SERVICES MpServices
160 Get the total number of logical processors in the platform.
162 @param[in] MpServices MP_SERVICES structure.
164 @retval Return the total number of logical processors.
167 CpuCacheInfoGetNumberOfProcessors (
168 IN MP_SERVICES MpServices