/*1* linux/arch/unicore32/mm/cache-ucv2.S2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*11* This is the "shell" of the UniCore-v2 processor support.12*/13#include <linux/linkage.h>14#include <linux/init.h>15#include <asm/assembler.h>16#include <asm/page.h>1718#include "proc-macros.S"1920/*21* __cpuc_flush_icache_all()22* __cpuc_flush_kern_all()23* __cpuc_flush_user_all()24*25* Flush the entire cache.26*/27ENTRY(__cpuc_flush_icache_all)28/*FALLTHROUGH*/29ENTRY(__cpuc_flush_kern_all)30/*FALLTHROUGH*/31ENTRY(__cpuc_flush_user_all)32mov r0, #033movc p0.c5, r0, #14 @ Dcache flush all34nop83536mov r0, #037movc p0.c5, r0, #20 @ Icache invalidate all38nop83940mov pc, lr4142/*43* __cpuc_flush_user_range(start, end, flags)44*45* Flush a range of TLB entries in the specified address space.46*47* - start - start address (may not be aligned)48* - end - end address (exclusive, may not be aligned)49* - flags - vm_area_struct flags describing address space50*/51ENTRY(__cpuc_flush_user_range)52cxor.a r2, #053beq __cpuc_dma_flush_range5455#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE56andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check57sub r1, r1, r058csub.a r1, #MAX_AREA_SIZE59bsg 2f6061andn r1, r1, #CACHE_LINESIZE - 162add r1, r1, #CACHE_LINESIZE6364101: dcacheline_flush r0, r11, r126566add r0, r0, #CACHE_LINESIZE67sub.a r1, r1, #CACHE_LINESIZE68bns 101b69b 3f70#endif712: mov ip, #072movc p0.c5, ip, #14 @ Dcache flush all73nop874753: mov ip, #076movc p0.c5, ip, #20 @ Icache invalidate all77nop87879mov pc, lr8081/*82* __cpuc_coherent_kern_range(start,end)83* __cpuc_coherent_user_range(start,end)84*85* Ensure that the I and D caches are coherent within specified86* region. This is typically used when code has been written to87* a memory region, and will be executed.88*89* - start - virtual start address of region90* - end - virtual end address of region91*/92ENTRY(__cpuc_coherent_kern_range)93/* FALLTHROUGH */94ENTRY(__cpuc_coherent_user_range)95#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE96andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check97sub r1, r1, r098csub.a r1, #MAX_AREA_SIZE99bsg 2f100101andn r1, r1, #CACHE_LINESIZE - 1102add r1, r1, #CACHE_LINESIZE103104@ r0 va2pa r10105mov r9, #PAGE_SZ106sub r9, r9, #1 @ PAGE_MASK107101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA108b 103f109102: cand.a r0, r9110beq 101b111112103: movc p0.c5, r10, #11 @ Dcache clean line of R10113nop8114115add r0, r0, #CACHE_LINESIZE116add r10, r10, #CACHE_LINESIZE117sub.a r1, r1, #CACHE_LINESIZE118bns 102b119b 3f120#endif1212: mov ip, #0122movc p0.c5, ip, #10 @ Dcache clean all123nop81241253: mov ip, #0126movc p0.c5, ip, #20 @ Icache invalidate all127nop8128129mov pc, lr130131/*132* __cpuc_flush_kern_dcache_area(void *addr, size_t size)133*134* - addr - kernel address135* - size - region size136*/137ENTRY(__cpuc_flush_kern_dcache_area)138mov ip, #0139movc p0.c5, ip, #14 @ Dcache flush all140nop8141mov pc, lr142143/*144* __cpuc_dma_clean_range(start,end)145* - start - virtual start address of region146* - end - virtual end address of region147*/148ENTRY(__cpuc_dma_clean_range)149#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE150andn r0, r0, #CACHE_LINESIZE - 1151sub r1, r1, r0152andn r1, r1, #CACHE_LINESIZE - 1153add r1, r1, #CACHE_LINESIZE154155csub.a r1, #MAX_AREA_SIZE156bsg 2f157158@ r0 va2pa r10159mov r9, #PAGE_SZ160sub r9, r9, #1 @ PAGE_MASK161101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA162b 1f163102: cand.a r0, r9164beq 101b1651661: movc p0.c5, r10, #11 @ Dcache clean line of R10167nop8168add r0, r0, #CACHE_LINESIZE169add r10, r10, #CACHE_LINESIZE170sub.a r1, r1, #CACHE_LINESIZE171bns 102b172mov pc, lr173#endif1742: mov ip, #0175movc p0.c5, ip, #10 @ Dcache clean all176nop8177178mov pc, lr179180/*181* __cpuc_dma_inv_range(start,end)182* __cpuc_dma_flush_range(start,end)183* - start - virtual start address of region184* - end - virtual end address of region185*/186__cpuc_dma_inv_range:187/* FALLTHROUGH */188ENTRY(__cpuc_dma_flush_range)189#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE190andn r0, r0, #CACHE_LINESIZE - 1191sub r1, r1, r0192andn r1, r1, #CACHE_LINESIZE - 1193add r1, r1, #CACHE_LINESIZE194195csub.a r1, #MAX_AREA_SIZE196bsg 2f197198@ r0 va2pa r10199101: dcacheline_flush r0, r11, r12200201add r0, r0, #CACHE_LINESIZE202sub.a r1, r1, #CACHE_LINESIZE203bns 101b204mov pc, lr205#endif2062: mov ip, #0207movc p0.c5, ip, #14 @ Dcache flush all208nop8209210mov pc, lr211212213214