2 * linux/arch/arm26/lib/uaccess-kernel.S
4 * Copyright (C) 1998 Russell King
6 * Note! Some code fragments found in here have a special calling
7 * convention - they are not APCS compliant!
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
18 //FIXME - surely this can be done in C not asm, removing the problem of keeping C and asm in sync? (this is a struct uaccess_t)
22 .word uaccess_kernel_put_byte
23 .word uaccess_kernel_get_byte
24 .word uaccess_kernel_put_half
25 .word uaccess_kernel_get_half
26 .word uaccess_kernel_put_word
27 .word uaccess_kernel_get_word
28 .word uaccess_kernel_put_dword
29 .word uaccess_kernel_copy
30 .word uaccess_kernel_copy
31 .word uaccess_kernel_clear
32 .word uaccess_kernel_strncpy
33 .word uaccess_kernel_strnlen
35 @ In : r0 = x, r1 = addr, r2 = error
37 uaccess_kernel_put_byte:
42 @ In : r0 = x, r1 = addr, r2 = error
44 uaccess_kernel_put_half:
51 @ In : r0 = x, r1 = addr, r2 = error
53 uaccess_kernel_put_word:
58 @ In : r0 = x, r1 = addr, r2 = error
60 uaccess_kernel_put_dword:
66 @ In : r0 = addr, r1 = error
67 @ Out: r0 = x, r1 = error
68 uaccess_kernel_get_byte:
73 @ In : r0 = addr, r1 = error
74 @ Out: r0 = x, r1 = error
75 uaccess_kernel_get_half:
82 @ In : r0 = addr, r1 = error
83 @ Out: r0 = x, r1 = error
84 uaccess_kernel_get_word:
90 /* Prototype: int uaccess_kernel_copy(void *to, const char *from, size_t n)
91 * Purpose : copy a block to kernel memory from kernel memory
92 * Params : to - kernel memory
93 * : from - kernel memory
94 * : n - number of bytes to copy
95 * Returns : Number of bytes NOT copied.
103 /* Prototype: int uaccess_kernel_clear(void *addr, size_t sz)
104 * Purpose : clear some kernel memory
105 * Params : addr - kernel memory address to clear
106 * : sz - number of bytes to clear
107 * Returns : number of bytes NOT cleared
109 uaccess_kernel_clear:
121 sub r1, r1, ip @ 7 6 5 4 3 2 1
122 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
127 2: adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
129 tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
132 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
137 /* Prototype: size_t uaccess_kernel_strncpy(char *dst, char *src, size_t len)
138 * Purpose : copy a string from kernel memory to kernel memory
139 * Params : dst - kernel memory destination
140 * : src - kernel memory source
141 * : len - maximum length of string
142 * Returns : number of characters copied
144 uaccess_kernel_strncpy:
156 /* Prototype: int uaccess_kernel_strlen(char *str, long n)
157 * Purpose : get length of a string in kernel memory
158 * Params : str - address of string in kernel memory
159 * Returns : length of string *including terminator*,
160 * or zero on exception, or n + 1 if too long
162 uaccess_kernel_strnlen: