1/* 2 * Copyright (c) 2014, Google Inc. All rights reserved 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24#include <asm.h> 25#include <arch/ops.h> 26#include <arch/defines.h> 27 28.text 29 30.macro cache_range_op, cache op 31 add x2, x0, x1 // calculate the end address 32 bic x3, x0, #(CACHE_LINE-1) // align the start with a cache line 33.Lcache_range_op_loop\@: 34 \cache \op, x3 35 add x3, x3, #CACHE_LINE 36 cmp x3, x2 37 blo .Lcache_range_op_loop\@ 38 dsb sy 39.endm 40 41 /* void arch_flush_cache_range(addr_t start, size_t len); */ 42FUNCTION(arch_clean_cache_range) 43 cache_range_op dc cvac // clean cache to PoC by MVA 44 ret 45 46 /* void arch_flush_invalidate_cache_range(addr_t start, size_t len); */ 47FUNCTION(arch_clean_invalidate_cache_range) 48 cache_range_op dc civac // clean & invalidate dcache to PoC by MVA 49 ret 50 51 /* void arch_invalidate_cache_range(addr_t start, size_t len); */ 52FUNCTION(arch_invalidate_cache_range) 53 cache_range_op dc ivac // invalidate dcache to PoC by MVA 54 ret 55 56 /* void arch_sync_cache_range(addr_t start, size_t len); */ 57FUNCTION(arch_sync_cache_range) 58 cache_range_op dc cvau // clean dcache to PoU by MVA 59 cache_range_op ic ivau // invalidate icache to PoU by MVA 60 ret 61