TianoCore EDK2 master
Loading...
Searching...
No Matches
SmbiosProcessorArm.c
Go to the documentation of this file.
1
10#include <Uefi.h>
12#include <Library/ArmLib.h>
13
14#include "SmbiosProcessor.h"
15
24UINT64
26 IN UINT8 CacheLevel,
27 IN BOOLEAN DataCache,
28 IN BOOLEAN UnifiedCache
29 )
30{
31 CCSIDR_DATA Ccsidr;
32 CCSIDR2_DATA Ccsidr2;
33 CSSELR_DATA Csselr;
34 BOOLEAN CcidxSupported;
35 UINT64 CacheSize;
36
37 // Read the CCSIDR register to get the cache architecture
38 Csselr.Data = 0;
39 Csselr.Bits.Level = CacheLevel - 1;
40 Csselr.Bits.InD = (!DataCache && !UnifiedCache);
41
42 Ccsidr.Data = ReadCCSIDR (Csselr.Data);
43
44 CcidxSupported = ArmHasCcidx ();
45
46 if (CcidxSupported) {
47 Ccsidr2.Data = ReadCCSIDR2 (Csselr.Data);
48 CacheSize = (1 << (Ccsidr.BitsCcidxAA32.LineSize + 4)) *
49 (Ccsidr.BitsCcidxAA32.Associativity + 1) *
50 (Ccsidr2.Bits.NumSets + 1);
51 } else {
52 CacheSize = (1 << (Ccsidr.BitsNonCcidx.LineSize + 4)) *
53 (Ccsidr.BitsNonCcidx.Associativity + 1) *
54 (Ccsidr.BitsNonCcidx.NumSets + 1);
55 }
56
57 return CacheSize;
58}
59
68UINT32
70 IN UINT8 CacheLevel,
71 IN BOOLEAN DataCache,
72 IN BOOLEAN UnifiedCache
73 )
74{
75 CCSIDR_DATA Ccsidr;
76 CSSELR_DATA Csselr;
77 BOOLEAN CcidxSupported;
78 UINT32 Associativity;
79
80 // Read the CCSIDR register to get the cache architecture
81 Csselr.Data = 0;
82 Csselr.Bits.Level = CacheLevel - 1;
83 Csselr.Bits.InD = (!DataCache && !UnifiedCache);
84
85 Ccsidr.Data = ReadCCSIDR (Csselr.Data);
86
87 CcidxSupported = ArmHasCcidx ();
88
89 if (CcidxSupported) {
90 Associativity = Ccsidr.BitsCcidxAA32.Associativity + 1;
91 } else {
92 Associativity = Ccsidr.BitsNonCcidx.Associativity + 1;
93 }
94
95 return Associativity;
96}
BOOLEAN EFIAPI ArmHasCcidx(VOID)
Definition: AArch64Lib.c:43
UINT32 ReadCCSIDR2(IN UINT32 CSSELR)
UINTN ReadCCSIDR(IN UINT32 CSSELR)
#define IN
Definition: Base.h:279
UINT64 SmbiosProcessorGetCacheSize(IN UINT8 CacheLevel, IN BOOLEAN DataCache, IN BOOLEAN UnifiedCache)
UINT32 SmbiosProcessorGetCacheAssociativity(IN UINT8 CacheLevel, IN BOOLEAN DataCache, IN BOOLEAN UnifiedCache)
Defines the structure of the AARCH32 CCSIDR2 register.
Definition: ArmCache.h:64
UINT32 Data
The entire 32-bit value.
Definition: ArmCache.h:69
struct CCSIDR2_DATA::@4 Bits
Bitfield definition of the register.
UINT32 NumSets
Number of sets in the cache - 1.
Definition: ArmCache.h:66
Defines the structure of the CCSIDR (Current Cache Size ID) register.
Definition: ArmCache.h:39
UINT64 Associativity
Associativity - 1.
Definition: ArmCache.h:42
struct CCSIDR_DATA::@1 BitsNonCcidx
Bitfield definition of the register when FEAT_CCIDX is not supported.
UINT64 Data
The entire 64-bit value.
Definition: ArmCache.h:60
UINT64 LineSize
Line size (Log2(Num bytes in cache) - 4)
Definition: ArmCache.h:41
UINT64 NumSets
Number of sets in the cache -1.
Definition: ArmCache.h:43
Defines the structure of the CSSELR (Cache Size Selection) register.
Definition: ArmCache.h:19
UINT32 Level
Cache level (zero based)
Definition: ArmCache.h:22
UINT32 Data
The entire 32-bit value.
Definition: ArmCache.h:26
UINT32 InD
Instruction not Data bit.
Definition: ArmCache.h:21
struct CSSELR_DATA::@0 Bits
Bitfield definition of the register.