1 /** @file 2 3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> 4 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 <Base.h> 17 18 #include <Library/ArmLib.h> 19 #include <Library/DebugLib.h> 20 #include <Library/PcdLib.h> 21 22 #include "ArmLibPrivate.h" 23 24 VOID 25 EFIAPI ArmSetAuxCrBit(IN UINT32 Bits)26ArmSetAuxCrBit ( 27 IN UINT32 Bits 28 ) 29 { 30 UINT32 val = ArmReadAuxCr(); 31 val |= Bits; 32 ArmWriteAuxCr(val); 33 } 34 35 VOID 36 EFIAPI ArmUnsetAuxCrBit(IN UINT32 Bits)37ArmUnsetAuxCrBit ( 38 IN UINT32 Bits 39 ) 40 { 41 UINT32 val = ArmReadAuxCr(); 42 val &= ~Bits; 43 ArmWriteAuxCr(val); 44 } 45 46 // 47 // Helper functions for accessing CPUACTLR 48 // 49 50 VOID 51 EFIAPI ArmSetCpuActlrBit(IN UINTN Bits)52ArmSetCpuActlrBit ( 53 IN UINTN Bits 54 ) 55 { 56 UINTN Value; 57 Value = ArmReadCpuActlr (); 58 Value |= Bits; 59 ArmWriteCpuActlr (Value); 60 } 61 62 VOID 63 EFIAPI ArmUnsetCpuActlrBit(IN UINTN Bits)64ArmUnsetCpuActlrBit ( 65 IN UINTN Bits 66 ) 67 { 68 UINTN Value; 69 Value = ArmReadCpuActlr (); 70 Value &= ~Bits; 71 ArmWriteCpuActlr (Value); 72 } 73 74 UINTN 75 EFIAPI ArmDataCacheLineLength(VOID)76ArmDataCacheLineLength ( 77 VOID 78 ) 79 { 80 return 4 << ((ArmCacheInfo () >> 16) & 0xf); // CTR_EL0.DminLine 81 } 82 83 UINTN 84 EFIAPI ArmInstructionCacheLineLength(VOID)85ArmInstructionCacheLineLength ( 86 VOID 87 ) 88 { 89 return 4 << (ArmCacheInfo () & 0xf); // CTR_EL0.IminLine 90 } 91 92 UINTN 93 EFIAPI ArmCacheWritebackGranule(VOID)94ArmCacheWritebackGranule ( 95 VOID 96 ) 97 { 98 UINTN CWG; 99 100 CWG = (ArmCacheInfo () >> 24) & 0xf; // CTR_EL0.CWG 101 102 if (CWG == 0) { 103 return SIZE_2KB; 104 } 105 106 return 4 << CWG; 107 } 108