diff options
author | Gleb O. Raiko <raiko@niisi.msk.ru> | 2000-04-07 12:55:57 +0000 |
---|---|---|
committer | Gleb O. Raiko <raiko@niisi.msk.ru> | 2000-04-07 12:55:57 +0000 |
commit | cdb6e8f01ce76e5128596c6d19804e3c402d35e1 (patch) | |
tree | 70af99983d916d2f7ed0129f4134b6154f0d3e29 /include | |
parent | fba859f9a0a26b3a0d4c116e161cb8698d666b07 (diff) |
Port paccess.h from mips64. mips32 paccess.h differs from the original one in
the following:
o works in case a constant address is passed to get_dbe/put_dbe
o uses faster binary search :-)
o the kernel are linked successfully even if get_dbe/put_dbe aren't
used
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-mips/paccess.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/include/asm-mips/paccess.h b/include/asm-mips/paccess.h new file mode 100644 index 000000000..264d8122c --- /dev/null +++ b/include/asm-mips/paccess.h @@ -0,0 +1,98 @@ +/* $Id: paccess.h,v 1.2 2000/01/21 22:34:07 ralf Exp $ + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 by Ralf Baechle + * Copyright (C) 1999, 2000 Silicon Graphics, Inc. + * + * Protected memory access. Used for everything that might take revenge + * by sending a DBE error like accessing possibly non-existant memory or + * devices. + */ +#ifndef _ASM_PACCESS_H +#define _ASM_PACCESS_H + +#include <linux/errno.h> + +#define put_dbe(x,ptr) __put_dbe((x),(ptr),sizeof(*(ptr))) +#define get_dbe(x,ptr) __get_dbe((x),(ptr),sizeof(*(ptr))) + +struct __large_pstruct { unsigned long buf[100]; }; +#define __mp(x) (*(struct __large_pstruct *)(x)) + +#define __get_dbe(x,ptr,size) ({ \ +int __gu_err; \ +__typeof(*(ptr)) __gu_val; \ +unsigned long __gu_addr; \ +__asm__("":"=r" (__gu_val)); \ +__gu_addr = (unsigned long) (ptr); \ +__asm__("":"=r" (__gu_err)); \ +switch (size) { \ +case 1: __get_dbe_asm("lb"); break; \ +case 2: __get_dbe_asm("lh"); break; \ +case 4: __get_dbe_asm("lw"); break; \ +case 8: __get_dbe_asm("ld"); break; \ +default: __get_dbe_unknown(); break; \ +} x = (__typeof__(*(ptr))) __gu_val; __gu_err; }) + +#define __get_dbe_asm(insn) \ +({ \ +__asm__ __volatile__( \ + ".set\tpush\n\t" \ + ".set\tnoreorder\n\t" \ + insn "\t%1,%2\n\t" \ + "1:\tmove\t%0,$0\n" \ + ".set\tpop\n\t" \ + "2:\n\t" \ + ".section\t.fixup,\"ax\"\n" \ + "3:\tli\t%0,%3\n\t" \ + "move\t%1,$0\n\t" \ + "j\t2b\n\t" \ + ".previous\n\t" \ + ".section\t__dbe_table,\"a\"\n\t" \ + ".word\t1b-4,3b\n\t" \ + ".previous" \ + :"=r" (__gu_err), "=r" (__gu_val) \ + :"o" (__mp(__gu_addr)), "i" (-EFAULT)); }) + +extern void __get_dbe_unknown(void); + +#define __put_dbe(x,ptr,size) ({ \ +int __pu_err; \ +__typeof__(*(ptr)) __pu_val; \ +unsigned long __pu_addr; \ +__pu_val = (x); \ +__pu_addr = (unsigned long) (ptr); \ +__asm__("":"=r" (__pu_err)); \ +switch (size) { \ +case 1: __put_dbe_asm("sb"); break; \ +case 2: __put_dbe_asm("sh"); break; \ +case 4: __put_dbe_asm("sw"); break; \ +case 8: __put_dbe_asm("sd"); break; \ +default: __put_dbe_unknown(); break; \ +} __pu_err; }) + +#define __put_dbe_asm(insn) \ +({ \ +__asm__ __volatile__( \ + ".set\tpush\n\t" \ + ".set\tnoreorder\n\t" \ + insn "\t%1,%2\n\t" \ + "1:\tmove\t%0,$0\n" \ + ".set\tpop\n\t" \ + "2:\n\t" \ + ".section\t.fixup,\"ax\"\n" \ + "3:\tli\t%0,%3\n\t" \ + "j\t2b\n\t" \ + ".previous\n\t" \ + ".section\t__dbe_table,\"a\"\n\t" \ + ".word\t1b-4,3b\n\t" \ + ".previous" \ + :"=r" (__pu_err) \ + :"r" (__pu_val), "o" (__mp(__pu_addr)), "i" (-EFAULT)); }) + +extern void __put_dbe_unknown(void); + +#endif /* _ASM_PACCESS_H */ |