blob: 7db25990c589f3d98554d9aee47cf7b5c3c486fd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/lib/putuser.S
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
11 *
12 * These functions have a non-standard call interface to make
13 * them more efficient, especially as they return an error
14 * value in addition to the "real" return value.
15 *
16 * __put_user_X
17 *
18 * Inputs: r0 contains the address
19 * r2, r3 contains the value
20 * Outputs: r0 is the error code
21 * lr corrupted
22 *
Russell King4baa9922008-08-02 10:55:55 +010023 * No other registers must be altered. (see <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 * for specific ASM register usage).
25 *
26 * Note that ADDR_LIMIT is either 0 or 0xc0000000
27 * Note also that it is intended that __put_user_bad is not global.
28 */
Catalin Marinas93ed3972008-08-28 11:22:32 +010029#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/errno.h>
Catalin Marinas247055a2010-09-13 16:03:21 +010031#include <asm/domain.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Catalin Marinas93ed3972008-08-28 11:22:32 +010033ENTRY(__put_user_1)
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100341: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 mov r0, #0
36 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010037ENDPROC(__put_user_1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Catalin Marinas93ed3972008-08-28 11:22:32 +010039ENTRY(__put_user_2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 mov ip, r2, lsr #8
Catalin Marinas8b592782009-07-24 12:32:57 +010041#ifdef CONFIG_THUMB2_KERNEL
42#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100432: TUSER(strb) r2, [r0]
443: TUSER(strb) ip, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010045#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100462: TUSER(strb) ip, [r0]
473: TUSER(strb) r2, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010048#endif
49#else /* !CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100512: TUSER(strb) r2, [r0], #1
523: TUSER(strb) ip, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100542: TUSER(strb) ip, [r0], #1
553: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#endif
Catalin Marinas8b592782009-07-24 12:32:57 +010057#endif /* CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 mov r0, #0
59 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010060ENDPROC(__put_user_2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Catalin Marinas93ed3972008-08-28 11:22:32 +010062ENTRY(__put_user_4)
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100634: TUSER(str) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 mov r0, #0
65 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010066ENDPROC(__put_user_4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Catalin Marinas93ed3972008-08-28 11:22:32 +010068ENTRY(__put_user_8)
Catalin Marinas8b592782009-07-24 12:32:57 +010069#ifdef CONFIG_THUMB2_KERNEL
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100705: TUSER(str) r2, [r0]
716: TUSER(str) r3, [r0, #4]
Catalin Marinas8b592782009-07-24 12:32:57 +010072#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100735: TUSER(str) r2, [r0], #4
746: TUSER(str) r3, [r0]
Catalin Marinas8b592782009-07-24 12:32:57 +010075#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 mov r0, #0
77 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010078ENDPROC(__put_user_8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80__put_user_bad:
81 mov r0, #-EFAULT
82 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010083ENDPROC(__put_user_bad)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Russell King42604152010-04-19 10:15:03 +010085.pushsection __ex_table, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 .long 1b, __put_user_bad
87 .long 2b, __put_user_bad
88 .long 3b, __put_user_bad
89 .long 4b, __put_user_bad
90 .long 5b, __put_user_bad
91 .long 6b, __put_user_bad
Russell King42604152010-04-19 10:15:03 +010092.popsection