]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.c
44edff869eaeb9ad253d4f35c41ac824ffdaef3f
[mirror_edk2.git] / ArmPkg / Library / ArmLib / ArmV7 / ArmV7Lib.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
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 #include <Uefi.h>
16 #include <Chipset/ArmV7.h>
17 #include <Library/ArmLib.h>
18 #include <Library/BaseLib.h>
19 #include <Library/IoLib.h>
20 #include "ArmV7Lib.h"
21 #include "ArmLibPrivate.h"
22
23 UINTN
24 EFIAPI
25 ArmDataCacheLineLength (
26 VOID
27 )
28 {
29 UINT32 CCSIDR = ReadCCSIDR (0) & 7;
30
31 // * 4 converts to bytes
32 return (1 << (CCSIDR + 2)) * 4;
33 }
34
35 UINTN
36 EFIAPI
37 ArmInstructionCacheLineLength (
38 VOID
39 )
40 {
41 UINT32 CCSIDR = ReadCCSIDR (1) & 7;
42
43 // * 4 converts to bytes
44 return (1 << (CCSIDR + 2)) * 4;
45
46 // return 64;
47 }
48
49
50 VOID
51 ArmV7DataCacheOperation (
52 IN ARM_V7_CACHE_OPERATION DataCacheOperation
53 )
54 {
55 UINTN SavedInterruptState;
56
57 SavedInterruptState = ArmGetInterruptState ();
58 ArmDisableInterrupts ();
59
60 ArmV7AllDataCachesOperation (DataCacheOperation);
61
62 ArmDrainWriteBuffer ();
63
64 if (SavedInterruptState) {
65 ArmEnableInterrupts ();
66 }
67 }
68
69 VOID
70 EFIAPI
71 ArmInvalidateDataCache (
72 VOID
73 )
74 {
75 ArmDrainWriteBuffer ();
76 ArmV7DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
77 }
78
79 VOID
80 EFIAPI
81 ArmCleanInvalidateDataCache (
82 VOID
83 )
84 {
85 ArmDrainWriteBuffer ();
86 ArmV7DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
87 }
88
89 VOID
90 EFIAPI
91 ArmCleanDataCache (
92 VOID
93 )
94 {
95 ArmDrainWriteBuffer ();
96 ArmV7DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
97 }