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
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Protected memory access. Used for everything that might take revenge
10 * by sending a DBE error like accessing possibly non-existant memory or
13 #ifndef _ASM_PACCESS_H
14 #define _ASM_PACCESS_H
16 #include <linux/config.h>
17 #include <linux/errno.h>
20 #define __PA_ADDR ".word"
23 #define __PA_ADDR ".dword"
26 extern asmlinkage void handle_ibe(void);
27 extern asmlinkage void handle_dbe(void);
29 #define put_dbe(x,ptr) __put_dbe((x),(ptr),sizeof(*(ptr)))
30 #define get_dbe(x,ptr) __get_dbe((x),(ptr),sizeof(*(ptr)))
32 struct __large_pstruct { unsigned long buf[100]; };
33 #define __mp(x) (*(struct __large_pstruct *)(x))
35 #define __get_dbe(x,ptr,size) \
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)); \
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; \
50 x = (__typeof__(*(ptr))) __gu_val; \
54 #define __get_dbe_asm(insn) \
56 __asm__ __volatile__( \
57 "1:\t" insn "\t%1,%2\n\t" \
60 ".section\t.fixup,\"ax\"\n" \
65 ".section\t__dbe_table,\"a\"\n\t" \
66 __PA_ADDR "\t1b, 3b\n\t" \
68 :"=r" (__gu_err), "=r" (__gu_val) \
69 :"o" (__mp(__gu_addr)), "i" (-EFAULT)); \
72 extern void __get_dbe_unknown(void);
74 #define __put_dbe(x,ptr,size) \
77 __typeof__(*(ptr)) __pu_val; \
80 __pu_addr = (long) (ptr); \
81 __asm__("":"=r" (__pu_err)); \
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; \
92 #define __put_dbe_asm(insn) \
94 __asm__ __volatile__( \
95 "1:\t" insn "\t%1,%2\n\t" \
98 ".section\t.fixup,\"ax\"\n" \
102 ".section\t__dbe_table,\"a\"\n\t" \
103 __PA_ADDR "\t1b, 3b\n\t" \
106 : "r" (__pu_val), "o" (__mp(__pu_addr)), "i" (-EFAULT)); \
109 extern void __put_dbe_unknown(void);
111 extern unsigned long search_dbe_table(unsigned long addr);
113 #endif /* _ASM_PACCESS_H */