X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FLibrary%2FArmCacheMaintenanceLib%2FArmCacheMaintenanceLib.c;h=bad5d244cbbadc8a96938f48c048dcb13143e26e;hp=f4c12e71731748032b835f819a9baabc12407c33;hb=HEAD;hpb=01674afdad3460f1c1f5f7a941c4c5895c8c3f86 diff --git a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c index f4c12e7173..bad5d244cb 100644 --- a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c +++ b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c @@ -1,47 +1,41 @@ /** @file Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2014, ARM Limited. All rights reserved. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php + Copyright (c) 2011 - 2021, ARM Limited. All rights reserved. - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include #include +#include #include +STATIC VOID CacheRangeOperation ( IN VOID *Start, IN UINTN Length, - IN CACHE_OPERATION CacheOperation, - IN LINE_OPERATION LineOperation + IN LINE_OPERATION LineOperation, + IN UINTN LineLength ) { - UINTN ArmCacheLineLength = ArmDataCacheLineLength(); - UINTN ArmCacheLineAlignmentMask = ArmCacheLineLength - 1; - UINTN ArmCacheOperationThreshold = PcdGet32(PcdArmCacheOperationThreshold); - - if ((CacheOperation != NULL) && (Length >= ArmCacheOperationThreshold)) { - ArmDrainWriteBuffer (); - CacheOperation (); - } else { - // Align address (rounding down) - UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask); - UINTN EndAddress = (UINTN)Start + Length; - - // Perform the line operation on an address in each cache line - while (AlignedAddress < EndAddress) { - LineOperation(AlignedAddress); - AlignedAddress += ArmCacheLineLength; - } + UINTN ArmCacheLineAlignmentMask; + // Align address (rounding down) + UINTN AlignedAddress; + UINTN EndAddress; + + ArmCacheLineAlignmentMask = LineLength - 1; + AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask); + EndAddress = (UINTN)Start + Length; + + // Perform the line operation on an address in each cache line + while (AlignedAddress < EndAddress) { + LineOperation (AlignedAddress); + AlignedAddress += LineLength; } + + ArmDataSynchronizationBarrier (); } VOID @@ -50,8 +44,7 @@ InvalidateInstructionCache ( VOID ) { - ArmCleanDataCache(); - ArmInvalidateInstructionCache(); + ASSERT (FALSE); } VOID @@ -60,18 +53,31 @@ InvalidateDataCache ( VOID ) { - ArmInvalidateDataCache(); + ASSERT (FALSE); } VOID * EFIAPI InvalidateInstructionCacheRange ( - IN VOID *Address, - IN UINTN Length + IN VOID *Address, + IN UINTN Length ) { - CacheRangeOperation (Address, Length, ArmCleanDataCacheToPoU, ArmCleanDataCacheEntryByMVA); - ArmInvalidateInstructionCache (); + CacheRangeOperation ( + Address, + Length, + ArmCleanDataCacheEntryToPoUByMVA, + ArmDataCacheLineLength () + ); + CacheRangeOperation ( + Address, + Length, + ArmInvalidateInstructionCacheEntryToPoUByMVA, + ArmInstructionCacheLineLength () + ); + + ArmInstructionSynchronizationBarrier (); + return Address; } @@ -81,17 +87,22 @@ WriteBackInvalidateDataCache ( VOID ) { - ArmCleanInvalidateDataCache(); + ASSERT (FALSE); } VOID * EFIAPI WriteBackInvalidateDataCacheRange ( - IN VOID *Address, - IN UINTN Length + IN VOID *Address, + IN UINTN Length ) { - CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCache, ArmCleanInvalidateDataCacheEntryByMVA); + CacheRangeOperation ( + Address, + Length, + ArmCleanInvalidateDataCacheEntryByMVA, + ArmDataCacheLineLength () + ); return Address; } @@ -101,27 +112,37 @@ WriteBackDataCache ( VOID ) { - ArmCleanDataCache(); + ASSERT (FALSE); } VOID * EFIAPI WriteBackDataCacheRange ( - IN VOID *Address, - IN UINTN Length + IN VOID *Address, + IN UINTN Length ) { - CacheRangeOperation(Address, Length, ArmCleanDataCache, ArmCleanDataCacheEntryByMVA); + CacheRangeOperation ( + Address, + Length, + ArmCleanDataCacheEntryByMVA, + ArmDataCacheLineLength () + ); return Address; } VOID * EFIAPI InvalidateDataCacheRange ( - IN VOID *Address, - IN UINTN Length + IN VOID *Address, + IN UINTN Length ) { - CacheRangeOperation(Address, Length, NULL, ArmInvalidateDataCacheEntryByMVA); + CacheRangeOperation ( + Address, + Length, + ArmInvalidateDataCacheEntryByMVA, + ArmDataCacheLineLength () + ); return Address; }