b53f455bfad295825266c444fa52682ef3254361
[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 VOID
24 ArmV7DataCacheOperation (
25 IN ARM_V7_CACHE_OPERATION DataCacheOperation
26 )
27 {
28 UINTN SavedInterruptState;
29
30 SavedInterruptState = ArmGetInterruptState ();
31 ArmDisableInterrupts ();
32
33 ArmV7AllDataCachesOperation (DataCacheOperation);
34
35 ArmDrainWriteBuffer ();
36
37 if (SavedInterruptState) {
38 ArmEnableInterrupts ();
39 }
40 }
41
42 VOID
43 EFIAPI
44 ArmInvalidateDataCache (
45 VOID
46 )
47 {
48 ArmDrainWriteBuffer ();
49 ArmV7DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
50 }
51
52 VOID
53 EFIAPI
54 ArmCleanInvalidateDataCache (
55 VOID
56 )
57 {
58 ArmDrainWriteBuffer ();
59 ArmV7DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
60 }
61
62 VOID
63 EFIAPI
64 ArmCleanDataCache (
65 VOID
66 )
67 {
68 ArmDrainWriteBuffer ();
69 ArmV7DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
70 }