2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
15 #include <linux/linkage.h>
16 #include <asm/errno.h>
17 #include <asm/cache.h>
18 #include <arch/chip.h>
20 /* Access user memory, but use MMU to avoid propagating kernel exceptions. */
23 * clear_user_asm takes the user target address in r0 and the
24 * number of bytes to zero in r1.
25 * It returns the number of uncopiable bytes (hopefully zero) in r0.
26 * Note that we don't use a separate .fixup section here since we fall
27 * through into the "fixup" code as the last straight-line bundle anyway.
29 STD_ENTRY(clear_user_asm)
30 { bz r1, 2f; or r2, r0, r1 }
32 bzt r2, .Lclear_aligned_user_asm
33 1: { sb r0, zero; addi r0, r0, 1; addi r1, r1, -1 }
35 2: { move r0, r1; jrp lr }
36 .pushsection __ex_table,"a"
41 .Lclear_aligned_user_asm:
42 1: { sw r0, zero; addi r0, r0, 4; addi r1, r1, -4 }
44 2: { move r0, r1; jrp lr }
45 STD_ENDPROC(clear_user_asm)
46 .pushsection __ex_table,"a"
52 * flush_user_asm takes the user target address in r0 and the
53 * number of bytes to flush in r1.
54 * It returns the number of unflushable bytes (hopefully zero) in r0.
56 STD_ENTRY(flush_user_asm)
58 { movei r2, L2_CACHE_BYTES; add r1, r0, r1 }
59 { sub r2, zero, r2; addi r1, r1, L2_CACHE_BYTES-1 }
60 { and r0, r0, r2; and r1, r1, r2 }
62 1: { flush r0; addi r1, r1, -CHIP_FLUSH_STRIDE() }
63 { addi r0, r0, CHIP_FLUSH_STRIDE(); bnzt r1, 1b }
64 2: { move r0, r1; jrp lr }
65 STD_ENDPROC(flush_user_asm)
66 .pushsection __ex_table,"a"
72 * finv_user_asm takes the user target address in r0 and the
73 * number of bytes to flush-invalidate in r1.
74 * It returns the number of not finv'able bytes (hopefully zero) in r0.
76 STD_ENTRY(finv_user_asm)
78 { movei r2, L2_CACHE_BYTES; add r1, r0, r1 }
79 { sub r2, zero, r2; addi r1, r1, L2_CACHE_BYTES-1 }
80 { and r0, r0, r2; and r1, r1, r2 }
82 1: { finv r0; addi r1, r1, -CHIP_FINV_STRIDE() }
83 { addi r0, r0, CHIP_FINV_STRIDE(); bnzt r1, 1b }
84 2: { move r0, r1; jrp lr }
85 STD_ENDPROC(finv_user_asm)
86 .pushsection __ex_table,"a"