1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 #include <generated/asm-offsets.h>
  15 #include <asm/thread_info.h>
  16 #include <asm/memory.h>
  17 
  18 
  19 
  20 
  21 #define CACHE_LINESIZE  32
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 
  31 #ifdef CONFIG_CPU_UCV2
  32 #define MAX_AREA_SIZE   0x800           
  33 #endif
  34 
  35 
  36 
  37 
  38         .macro  vma_vm_mm, rd, rn
  39         ldw     \rd, [\rn+], #VMA_VM_MM
  40         .endm
  41 
  42 
  43 
  44 
  45         .macro  vma_vm_flags, rd, rn
  46         ldw     \rd, [\rn+], #VMA_VM_FLAGS
  47         .endm
  48 
  49         .macro  tsk_mm, rd, rn
  50         ldw     \rd, [\rn+], #TI_TASK
  51         ldw     \rd, [\rd+], #TSK_ACTIVE_MM
  52         .endm
  53 
  54 
  55 
  56 
  57         .macro  act_mm, rd
  58         andn    \rd, sp, #8128
  59         andn    \rd, \rd, #63
  60         ldw     \rd, [\rd+], #TI_TASK
  61         ldw     \rd, [\rd+], #TSK_ACTIVE_MM
  62         .endm
  63 
  64 
  65 
  66 
  67         .macro  mmid, rd, rn
  68         ldw     \rd, [\rn+], #MM_CONTEXT_ID
  69         .endm
  70 
  71 
  72 
  73 
  74         .macro  asid, rd, rn
  75         and     \rd, \rn, #255
  76         .endm
  77 
  78         .macro  crval, clear, mmuset, ucset
  79         .word   \clear
  80         .word   \mmuset
  81         .endm
  82 
  83 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
  84 
  85 
  86 
  87 
  88 
  89 
  90 
  91 
  92 
  93 
  94         .macro  va2pa, va, pa, tbl, msk, off, err=990f
  95         movc    \pa, p0.c2, #0
  96         mov     \off, \va >> #22                @ off <- index of 1st page table
  97         adr     \tbl, 910f                      @ tbl <- table of 1st page table
  98 900:                                            @ ---- handle 1, 2 page table
  99         add     \pa, \pa, #PAGE_OFFSET          @ pa <- virt addr of page table
 100         ldw     \pa, [\pa+], \off << #2         @ pa <- the content of pt
 101         cand.a  \pa, #4                         @ test exist bit
 102         beq     \err                            @ if not exist
 103         and     \off, \pa, #3                   @ off <- the last 2 bits
 104         add     \tbl, \tbl, \off << #3          @ cmove table pointer
 105         ldw     \msk, [\tbl+], #0               @ get the mask
 106         ldw     pc, [\tbl+], #4
 107 930:                                            @ ---- handle 2nd page table
 108         and     \pa, \pa, \msk                  @ pa <- phys addr of 2nd pt
 109         mov     \off, \va << #10
 110         cntlo   \tbl, \msk                      @ use tbl as temp reg
 111         mov     \off, \off >> \tbl
 112         mov     \off, \off >> #2                @ off <- index of 2nd pt
 113         adr     \tbl, 920f                      @ tbl <- table of 2nd pt
 114         b       900b
 115 910:                                            @ 1st level page table
 116         .word   0xfffff000, 930b                @ second level page table
 117         .word   0xfffffc00, 930b                @ second level large page table
 118         .word   0x00000000, \err                @ invalid
 119         .word   0xffc00000, 980f                @ super page
 120 
 121 920:                                            @ 2nd level page table
 122         .word   0xfffff000, 980f                @ page
 123         .word   0xffffc000, 980f                @ middle page
 124         .word   0xffff0000, 980f                @ large page
 125         .word   0x00000000, \err                @ invalid
 126 980:
 127         andn    \tbl, \va, \msk
 128         and     \pa, \pa, \msk
 129         or      \pa, \pa, \tbl
 130 990:
 131         .endm
 132 #endif
 133 
 134         .macro dcacheline_flush, addr, t1, t2
 135         mov     \t1, \addr << #20
 136         ldw     \t2, =_stext                    @ _stext must ALIGN(4096)
 137         add     \t2, \t2, \t1 >> #20
 138         ldw     \t1, [\t2+], #0x0000
 139         ldw     \t1, [\t2+], #0x1000
 140         ldw     \t1, [\t2+], #0x2000
 141         ldw     \t1, [\t2+], #0x3000
 142         .endm