OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-mips/] [paccess.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
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/errno.h>
17
 
18
#define put_dbe(x,ptr) __put_dbe((x),(ptr),sizeof(*(ptr)))
19
#define get_dbe(x,ptr) __get_dbe((x),(ptr),sizeof(*(ptr)))
20
 
21
struct __large_pstruct { unsigned long buf[100]; };
22
#define __mp(x) (*(struct __large_pstruct *)(x))
23
 
24
#define __get_dbe(x,ptr,size) ({ \
25
int __gu_err; \
26
__typeof(*(ptr)) __gu_val; \
27
unsigned long __gu_addr; \
28
__asm__("":"=r" (__gu_val)); \
29
__gu_addr = (unsigned long) (ptr); \
30
__asm__("":"=r" (__gu_err)); \
31
switch (size) { \
32
case 1: __get_dbe_asm("lb"); break; \
33
case 2: __get_dbe_asm("lh"); break; \
34
case 4: __get_dbe_asm("lw"); break; \
35
case 8:  __get_dbe_asm("ld"); break; \
36
default: __get_dbe_unknown(); break; \
37
} x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
38
 
39
#define __get_dbe_asm(insn) \
40
({ \
41
__asm__ __volatile__( \
42
        ".set\tpush\n\t" \
43
        ".set\tnoreorder\n\t" \
44
        insn "\t%1,%2\n\t" \
45
        "1:\tmove\t%0,$0\n" \
46
        ".set\tpop\n\t" \
47
        "2:\n\t" \
48
        ".section\t.fixup,\"ax\"\n" \
49
        "3:\tli\t%0,%3\n\t" \
50
        "move\t%1,$0\n\t" \
51
        "j\t2b\n\t" \
52
        ".previous\n\t" \
53
        ".section\t__dbe_table,\"a\"\n\t" \
54
        ".word\t1b-4,3b\n\t" \
55
        ".previous" \
56
        :"=r" (__gu_err), "=r" (__gu_val) \
57
        :"o" (__mp(__gu_addr)), "i" (-EFAULT)); })
58
 
59
extern void __get_dbe_unknown(void);
60
 
61
#define __put_dbe(x,ptr,size) ({ \
62
int __pu_err; \
63
__typeof__(*(ptr)) __pu_val; \
64
unsigned long __pu_addr; \
65
__pu_val = (x); \
66
__pu_addr = (unsigned long) (ptr); \
67
__asm__("":"=r" (__pu_err)); \
68
switch (size) { \
69
case 1: __put_dbe_asm("sb"); break; \
70
case 2: __put_dbe_asm("sh"); break; \
71
case 4: __put_dbe_asm("sw"); break; \
72
case 8: __put_dbe_asm("sd"); break; \
73
default: __put_dbe_unknown(); break; \
74
} __pu_err; })
75
 
76
#define __put_dbe_asm(insn) \
77
({ \
78
__asm__ __volatile__( \
79
        ".set\tpush\n\t" \
80
        ".set\tnoreorder\n\t" \
81
        insn "\t%1,%2\n\t" \
82
        "1:\tmove\t%0,$0\n" \
83
        ".set\tpop\n\t" \
84
        "2:\n\t" \
85
        ".section\t.fixup,\"ax\"\n" \
86
        "3:\tli\t%0,%3\n\t" \
87
        "j\t2b\n\t" \
88
        ".previous\n\t" \
89
        ".section\t__dbe_table,\"a\"\n\t" \
90
        ".word\t1b-4,3b\n\t" \
91
        ".previous" \
92
        :"=r" (__pu_err) \
93
        :"r" (__pu_val), "o" (__mp(__pu_addr)), "i" (-EFAULT)); })
94
 
95
extern void __put_dbe_unknown(void);
96
 
97
#endif /* _ASM_PACCESS_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.