aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/paccess.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-mips/paccess.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-mips/paccess.h')
-rw-r--r--include/asm-mips/paccess.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/include/asm-mips/paccess.h b/include/asm-mips/paccess.h
new file mode 100644
index 000000000000..36cec9e31696
--- /dev/null
+++ b/include/asm-mips/paccess.h
@@ -0,0 +1,113 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 *
9 * Protected memory access. Used for everything that might take revenge
10 * by sending a DBE error like accessing possibly non-existant memory or
11 * devices.
12 */
13#ifndef _ASM_PACCESS_H
14#define _ASM_PACCESS_H
15
16#include <linux/config.h>
17#include <linux/errno.h>
18
19#ifdef CONFIG_MIPS32
20#define __PA_ADDR ".word"
21#endif
22#ifdef CONFIG_MIPS64
23#define __PA_ADDR ".dword"
24#endif
25
26extern asmlinkage void handle_ibe(void);
27extern asmlinkage void handle_dbe(void);
28
29#define put_dbe(x,ptr) __put_dbe((x),(ptr),sizeof(*(ptr)))
30#define get_dbe(x,ptr) __get_dbe((x),(ptr),sizeof(*(ptr)))
31
32struct __large_pstruct { unsigned long buf[100]; };
33#define __mp(x) (*(struct __large_pstruct *)(x))
34
35#define __get_dbe(x,ptr,size) \
36({ \
37 long __gu_err; \
38 __typeof(*(ptr)) __gu_val; \
39 unsigned long __gu_addr; \
40 __asm__("":"=r" (__gu_val)); \
41 __gu_addr = (unsigned long) (ptr); \
42 __asm__("":"=r" (__gu_err)); \
43 switch (size) { \
44 case 1: __get_dbe_asm("lb"); break; \
45 case 2: __get_dbe_asm("lh"); break; \
46 case 4: __get_dbe_asm("lw"); break; \
47 case 8: __get_dbe_asm("ld"); break; \
48 default: __get_dbe_unknown(); break; \
49 } \
50 x = (__typeof__(*(ptr))) __gu_val; \
51 __gu_err; \
52})
53
54#define __get_dbe_asm(insn) \
55({ \
56 __asm__ __volatile__( \
57 "1:\t" insn "\t%1,%2\n\t" \
58 "move\t%0,$0\n" \
59 "2:\n\t" \
60 ".section\t.fixup,\"ax\"\n" \
61 "3:\tli\t%0,%3\n\t" \
62 "move\t%1,$0\n\t" \
63 "j\t2b\n\t" \
64 ".previous\n\t" \
65 ".section\t__dbe_table,\"a\"\n\t" \
66 __PA_ADDR "\t1b, 3b\n\t" \
67 ".previous" \
68 :"=r" (__gu_err), "=r" (__gu_val) \
69 :"o" (__mp(__gu_addr)), "i" (-EFAULT)); \
70})
71
72extern void __get_dbe_unknown(void);
73
74#define __put_dbe(x,ptr,size) \
75({ \
76 long __pu_err; \
77 __typeof__(*(ptr)) __pu_val; \
78 long __pu_addr; \
79 __pu_val = (x); \
80 __pu_addr = (long) (ptr); \
81 __asm__("":"=r" (__pu_err)); \
82 switch (size) { \
83 case 1: __put_dbe_asm("sb"); break; \
84 case 2: __put_dbe_asm("sh"); break; \
85 case 4: __put_dbe_asm("sw"); break; \
86 case 8: __put_dbe_asm("sd"); break; \
87 default: __put_dbe_unknown(); break; \
88 } \
89 __pu_err; \
90})
91
92#define __put_dbe_asm(insn) \
93({ \
94 __asm__ __volatile__( \
95 "1:\t" insn "\t%1,%2\n\t" \
96 "move\t%0,$0\n" \
97 "2:\n\t" \
98 ".section\t.fixup,\"ax\"\n" \
99 "3:\tli\t%0,%3\n\t" \
100 "j\t2b\n\t" \
101 ".previous\n\t" \
102 ".section\t__dbe_table,\"a\"\n\t" \
103 __PA_ADDR "\t1b, 3b\n\t" \
104 ".previous" \
105 : "=r" (__pu_err) \
106 : "r" (__pu_val), "o" (__mp(__pu_addr)), "i" (-EFAULT)); \
107})
108
109extern void __put_dbe_unknown(void);
110
111extern unsigned long search_dbe_table(unsigned long addr);
112
113#endif /* _ASM_PACCESS_H */