1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/lib/copy_from_user.S
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
16 * size_t raw_copy_from_user(void *to, const void *from, size_t n)
20 * copy a block to kernel memory from user memory
26 * n = number of bytes to copy
30 * Number of bytes NOT copied.
33 .macro ldr1w ptr reg abort
34 ldrusr \reg, \ptr, 4, abort=\abort
37 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
38 100: ldm.w (\reg1, \reg2, \reg3, \reg4), [\ptr]+
39 .pushsection __ex_table, "a"
45 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
46 100: ldm.w (\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8), [\ptr]+
47 .pushsection __ex_table, "a"
53 .macro ldr1b ptr reg cond=al abort
54 ldrusr \reg, \ptr, 1, \cond, abort=\abort
57 .macro str1w ptr reg abort
58 stw.w \reg, [\ptr]+, #4
61 .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
62 stm.w (\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8), [\ptr]+
65 .macro str1b ptr reg cond=al abort
70 201: stb.w \reg, [\ptr]+, #1
76 stm.w (r0, r2, r3), [sp-]
87 ENTRY(raw_copy_from_user)
89 #include "copy_template.S"
91 ENDPROC(raw_copy_from_user)
93 .pushsection .fixup,"ax"
96 ldm.w (r1, r2, r3), [sp]+