]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
ArmPkg/ArmLib: remove CCSIDR based cache info routines
[mirror_edk2.git] / ArmPkg / Library / ArmLib / AArch64 / AArch64Lib.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include <Uefi.h>
17 #include <Chipset/AArch64.h>
18 #include <Library/ArmLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/IoLib.h>
21 #include "AArch64Lib.h"
22 #include "ArmLibPrivate.h"
23
24 UINTN
25 EFIAPI
26 ArmDataCacheLineLength (
27 VOID
28 )
29 {
30 UINT32 CCSIDR = ReadCCSIDR (0) & 7;
31
32 // * 4 converts to bytes
33 return (1 << (CCSIDR + 2)) * 4;
34 }
35
36 UINTN
37 EFIAPI
38 ArmInstructionCacheLineLength (
39 VOID
40 )
41 {
42 UINT32 CCSIDR = ReadCCSIDR (1) & 7;
43
44 // * 4 converts to bytes
45 return (1 << (CCSIDR + 2)) * 4;
46 }
47
48
49 VOID
50 AArch64DataCacheOperation (
51 IN AARCH64_CACHE_OPERATION DataCacheOperation
52 )
53 {
54 UINTN SavedInterruptState;
55
56 SavedInterruptState = ArmGetInterruptState ();
57 ArmDisableInterrupts();
58
59 AArch64AllDataCachesOperation (DataCacheOperation);
60
61 ArmDrainWriteBuffer ();
62
63 if (SavedInterruptState) {
64 ArmEnableInterrupts ();
65 }
66 }
67
68 VOID
69 EFIAPI
70 ArmInvalidateDataCache (
71 VOID
72 )
73 {
74 ArmDrainWriteBuffer ();
75 AArch64DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
76 }
77
78 VOID
79 EFIAPI
80 ArmCleanInvalidateDataCache (
81 VOID
82 )
83 {
84 ArmDrainWriteBuffer ();
85 AArch64DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
86 }
87
88 VOID
89 EFIAPI
90 ArmCleanDataCache (
91 VOID
92 )
93 {
94 ArmDrainWriteBuffer ();
95 AArch64DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
96 }