1/* 2 * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2022-11-22 13 * Description: cache相关处理。 14 */ 15 16 .section .os.init.text, "ax" 17 18 .global OsCacheConfigInit 19 .global OsCacheFlushDcache 20 .global OsCacheInvIcache 21 22 .type OsCacheConfigInit, "function" 23 .type OsCacheFlushDcache, "function" 24 .type OsCacheInvIcache, "function" 25 26.macro GetCacheLineSize size, tmp 27 mrs \tmp, ctr_el0 28 lsr \tmp, \tmp, #16 29 and \tmp, \tmp, #0xf 30 mov \size, #4 31 lsl \size, \size, \tmp 32.endm 33 34OsCacheConfigInit: 35 mov w0, #0 36 ret 37 38/* 39 * 描述:按地址范围进行DCache写回 40 * 备注:当前仅用于动态加载模块 41 */ 42OsCacheFlushDcache: 43 GetCacheLineSize x2, x3 44 sub x3, x2, #1 45 add x1, x0, x1 46 bic x0, x0, x3 471: dc cvac, x0 /* Data Cache Clean by address to Point of Coherency */ 48 add x0, x0, x2 49 cmp x0, x1 50 b.lo 1b 51 dsb sy 52 ret 53 54/* 55 * 描述:按地址范围进行ICache无效 56 * 备注:当前仅用于动态加载模块 57 */ 58OsCacheInvIcache: 59 GetCacheLineSize x2, x3 60 sub x3, x2, #1 61 add x1, x0, x1 62 bic x0, x0, x3 631: ic ivau, x0 /* I cache Invalidate by address to Point of Unification */ 64 add x0, x0, x2 65 cmp x0, x1 66 b.lo 1b 67 dsb sy 68 isb sy 69 ret 70 71 .text 72