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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [include/] [asm-alpha/] [segment.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#ifndef _ASM_SEGMENT_H
2
#define _ASM_SEGMENT_H
3
 
4
#include <linux/string.h>
5
 
6
/*
7
 * This is a gcc optimization barrier, which essentially
8
 * inserts a sequence point in the gcc RTL tree that gcc
9
 * can't move code around. This is needed when we enter
10
 * or exit a critical region (in this case around user-level
11
 * accesses that may sleep, and we can't let gcc optimize
12
 * global state around them).
13
 */
14
#define __gcc_barrier() __asm__ __volatile__("": : :"memory")
15
 
16
/*
17
 * Uh, these should become the main single-value transfer routines..
18
 * They automatically use the right size if we just have the right
19
 * pointer type..
20
 */
21
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
22
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
23
 
24
/*
25
 * This is a silly but good way to make sure that
26
 * the __put_user function is indeed always optimized,
27
 * and that we use the correct sizes..
28
 */
29
extern int bad_user_access_length(void);
30
 
31
/* I should make this use unaligned transfers etc.. */
32
static inline void __put_user(unsigned long x, void * y, int size)
33
{
34
        __gcc_barrier();
35
        switch (size) {
36
                case 1:
37
                        *(char *) y = x;
38
                        break;
39
                case 2:
40
                        *(short *) y = x;
41
                        break;
42
                case 4:
43
                        *(int *) y = x;
44
                        break;
45
                case 8:
46
                        *(long *) y = x;
47
                        break;
48
                default:
49
                        bad_user_access_length();
50
        }
51
        __gcc_barrier();
52
}
53
 
54
/* I should make this use unaligned transfers etc.. */
55
static inline unsigned long __get_user(const void * y, int size)
56
{
57
        unsigned long result;
58
 
59
        __gcc_barrier();
60
        switch (size) {
61
                case 1:
62
                        result = *(unsigned char *) y;
63
                        break;
64
                case 2:
65
                        result = *(unsigned short *) y;
66
                        break;
67
                case 4:
68
                        result = *(unsigned int *) y;
69
                        break;
70
                case 8:
71
                        result = *(unsigned long *) y;
72
                        break;
73
                default:
74
                        result = bad_user_access_length();
75
        }
76
        __gcc_barrier();
77
        return result;
78
}
79
 
80
#define get_fs_byte(addr) get_user((unsigned char *)(addr))
81
#define get_fs_word(addr) get_user((unsigned short *)(addr))
82
#define get_fs_long(addr) get_user((unsigned int *)(addr))
83
#define get_fs_quad(addr) get_user((unsigned long *)(addr))
84
 
85
#define put_fs_byte(x,addr) put_user((x),(char *)(addr))
86
#define put_fs_word(x,addr) put_user((x),(short *)(addr))
87
#define put_fs_long(x,addr) put_user((x),(int *)(addr))
88
#define put_fs_quad(x,addr) put_user((x),(long *)(addr))
89
 
90
static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
91
{
92
        __gcc_barrier();
93
        memcpy(to, from, n);
94
        __gcc_barrier();
95
}
96
 
97
static inline void memcpy_tofs(void * to, const void * from, unsigned long n)
98
{
99
        __gcc_barrier();
100
        memcpy(to, from, n);
101
        __gcc_barrier();
102
}
103
 
104
/*
105
 * The fs value determines whether argument validity checking should be
106
 * performed or not.  If get_fs() == USER_DS, checking is performed, with
107
 * get_fs() == KERNEL_DS, checking is bypassed.
108
 *
109
 * For historical reasons, these macros are grossly misnamed.
110
 */
111
 
112
#define KERNEL_DS       0
113
#define USER_DS         1
114
 
115
#define get_fs()  (current->tss.flags & 0x1)
116
#define set_fs(x) (current->tss.flags = (current->tss.flags & ~0x1) | ((x) & 0x1))
117
 
118
static inline unsigned long get_ds(void)
119
{
120
        return 0;
121
}
122
 
123
#endif /* _ASM_SEGMENT_H */

powered by: WebSVN 2.1.0

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