/*1* linux/arch/unicore32/mm/proc-macros.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* We need constants.h for:12* VMA_VM_MM13* VMA_VM_FLAGS14* VM_EXEC15*/16#include <generated/asm-offsets.h>17#include <asm/thread_info.h>18#include <asm/memory.h>1920/*21* the cache line sizes of the I and D cache are the same22*/23#define CACHE_LINESIZE 322425/*26* This is the maximum size of an area which will be invalidated27* using the single invalidate entry instructions. Anything larger28* than this, and we go for the whole cache.29*30* This value should be chosen such that we choose the cheapest31* alternative.32*/33#ifdef CONFIG_CPU_UCV234#define MAX_AREA_SIZE 0x800 /* 64 cache line */35#endif3637/*38* vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)39*/40.macro vma_vm_mm, rd, rn41ldw \rd, [\rn+], #VMA_VM_MM42.endm4344/*45* vma_vm_flags - get vma->vm_flags46*/47.macro vma_vm_flags, rd, rn48ldw \rd, [\rn+], #VMA_VM_FLAGS49.endm5051.macro tsk_mm, rd, rn52ldw \rd, [\rn+], #TI_TASK53ldw \rd, [\rd+], #TSK_ACTIVE_MM54.endm5556/*57* act_mm - get current->active_mm58*/59.macro act_mm, rd60andn \rd, sp, #812861andn \rd, \rd, #6362ldw \rd, [\rd+], #TI_TASK63ldw \rd, [\rd+], #TSK_ACTIVE_MM64.endm6566/*67* mmid - get context id from mm pointer (mm->context.id)68*/69.macro mmid, rd, rn70ldw \rd, [\rn+], #MM_CONTEXT_ID71.endm7273/*74* mask_asid - mask the ASID from the context ID75*/76.macro asid, rd, rn77and \rd, \rn, #25578.endm7980.macro crval, clear, mmuset, ucset81.word \clear82.word \mmuset83.endm8485#ifndef CONFIG_CPU_DCACHE_LINE_DISABLE86/*87* va2pa va, pa, tbl, msk, off, err88* This macro is used to translate virtual address to its physical address.89*90* va: virtual address91* pa: physical address, result is stored in this register92* tbl, msk, off: temp registers, will be destroyed93* err: jump to error label if the physical address not exist94* NOTE: all regs must be different95*/96.macro va2pa, va, pa, tbl, msk, off, err=990f97movc \pa, p0.c2, #098mov \off, \va >> #22 @ off <- index of 1st page table99adr \tbl, 910f @ tbl <- table of 1st page table100900: @ ---- handle 1, 2 page table101add \pa, \pa, #PAGE_OFFSET @ pa <- virt addr of page table102ldw \pa, [\pa+], \off << #2 @ pa <- the content of pt103cand.a \pa, #4 @ test exist bit104beq \err @ if not exist105and \off, \pa, #3 @ off <- the last 2 bits106add \tbl, \tbl, \off << #3 @ cmove table pointer107ldw \msk, [\tbl+], #0 @ get the mask108ldw pc, [\tbl+], #4109930: @ ---- handle 2nd page table110and \pa, \pa, \msk @ pa <- phys addr of 2nd pt111mov \off, \va << #10112cntlo \tbl, \msk @ use tbl as temp reg113mov \off, \off >> \tbl114mov \off, \off >> #2 @ off <- index of 2nd pt115adr \tbl, 920f @ tbl <- table of 2nd pt116b 900b117910: @ 1st level page table118.word 0xfffff000, 930b @ second level page table119.word 0xfffffc00, 930b @ second level large page table120.word 0x00000000, \err @ invalid121.word 0xffc00000, 980f @ super page122123920: @ 2nd level page table124.word 0xfffff000, 980f @ page125.word 0xffffc000, 980f @ middle page126.word 0xffff0000, 980f @ large page127.word 0x00000000, \err @ invalid128980:129andn \tbl, \va, \msk130and \pa, \pa, \msk131or \pa, \pa, \tbl132990:133.endm134#endif135136.macro dcacheline_flush, addr, t1, t2137mov \t1, \addr << #20138ldw \t2, =_stext @ _stext must ALIGN(4096)139add \t2, \t2, \t1 >> #20140ldw \t1, [\t2+], #0x0000141ldw \t1, [\t2+], #0x1000142ldw \t1, [\t2+], #0x2000143ldw \t1, [\t2+], #0x3000144.endm145146147