]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorAArch64.c
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Universal / Smbios / ProcessorSubClassDxe / SmbiosProcessorAArch64.c
1 /** @file
2 Functions for AARCH64 processor information
3
4 Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Uefi.h>
11 #include <IndustryStandard/ArmCache.h>
12 #include <Library/ArmLib.h>
13
14 #include "SmbiosProcessor.h"
15
16 /** Gets the size of the specified cache.
17
18 @param CacheLevel The cache level (L1, L2 etc.).
19 @param DataCache Whether the cache is a dedicated data cache.
20 @param UnifiedCache Whether the cache is a unified cache.
21
22 @return The cache size.
23 **/
24 UINT64
25 SmbiosProcessorGetCacheSize (
26 IN UINT8 CacheLevel,
27 IN BOOLEAN DataCache,
28 IN BOOLEAN UnifiedCache
29 )
30 {
31 CCSIDR_DATA Ccsidr;
32 CSSELR_DATA Csselr;
33 BOOLEAN CcidxSupported;
34 UINT64 CacheSize;
35
36 Csselr.Data = 0;
37 Csselr.Bits.Level = CacheLevel - 1;
38 Csselr.Bits.InD = (!DataCache && !UnifiedCache);
39
40 Ccsidr.Data = ReadCCSIDR (Csselr.Data);
41
42 CcidxSupported = ArmHasCcidx ();
43
44 if (CcidxSupported) {
45 CacheSize = (1 << (Ccsidr.BitsCcidxAA64.LineSize + 4)) *
46 (Ccsidr.BitsCcidxAA64.Associativity + 1) *
47 (Ccsidr.BitsCcidxAA64.NumSets + 1);
48 } else {
49 CacheSize = (1 << (Ccsidr.BitsNonCcidx.LineSize + 4)) *
50 (Ccsidr.BitsNonCcidx.Associativity + 1) *
51 (Ccsidr.BitsNonCcidx.NumSets + 1);
52 }
53
54 return CacheSize;
55 }
56
57 /** Gets the associativity of the specified cache.
58
59 @param CacheLevel The cache level (L1, L2 etc.).
60 @param DataCache Whether the cache is a dedicated data cache.
61 @param UnifiedCache Whether the cache is a unified cache.
62
63 @return The cache associativity.
64 **/
65 UINT32
66 SmbiosProcessorGetCacheAssociativity (
67 IN UINT8 CacheLevel,
68 IN BOOLEAN DataCache,
69 IN BOOLEAN UnifiedCache
70 )
71 {
72 CCSIDR_DATA Ccsidr;
73 CSSELR_DATA Csselr;
74 BOOLEAN CcidxSupported;
75 UINT32 Associativity;
76
77 Csselr.Data = 0;
78 Csselr.Bits.Level = CacheLevel - 1;
79 Csselr.Bits.InD = (!DataCache && !UnifiedCache);
80
81 Ccsidr.Data = ReadCCSIDR (Csselr.Data);
82
83 CcidxSupported = ArmHasCcidx ();
84
85 if (CcidxSupported) {
86 Associativity = Ccsidr.BitsCcidxAA64.Associativity + 1;
87 } else {
88 Associativity = Ccsidr.BitsNonCcidx.Associativity + 1;
89 }
90
91 return Associativity;
92 }