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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-or32/] [segment.h] - Blame information for rev 1633

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

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _OR32_SEGMENT_H
2
#define _OR32_SEGMENT_H
3
 
4
/* define constants */
5
/* Address spaces (FC0-FC2) */
6
#define USER_DATA     (1)
7
#ifndef USER_DS
8
#define USER_DS       (USER_DATA)
9
#endif
10
#define USER_PROGRAM  (2)
11
#define SUPER_DATA    (5)
12
#ifndef KERNEL_DS
13
#define KERNEL_DS     (SUPER_DATA)
14
#endif
15
#define SUPER_PROGRAM (6)
16
#define CPU_SPACE     (7)
17
 
18
#ifndef __ASSEMBLY__
19
 
20
/*
21
 * Uh, these should become the main single-value transfer routines..
22
 * They automatically use the right size if we just have the right
23
 * pointer type..
24
 */
25
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
26
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
27
 
28
/*
29
 * This is a silly but good way to make sure that
30
 * the __put_user function is indeed always optimized,
31
 * and that we use the correct sizes..
32
 */
33
extern int bad_user_access_length(void);
34
 
35
#define __ptr(x) ((unsigned long *)(x))
36
 
37
static inline void __put_user(unsigned long x, void * y, int size)
38
{
39
        switch (size) {
40
                case 1:
41
                        *(char *) y = x;
42
                        break;
43
                case 2:
44
                        *(short *) y = x;
45
                        break;
46
                case 4:
47
                        *(int *) y = x;
48
                        break;
49
                case 8:
50
                        *(long *) y = x;
51
                        break;
52
                default:
53
                        bad_user_access_length();
54
        }
55
}
56
 
57
static inline unsigned long __get_user(const void * y, int size)
58
{
59
        switch (size) {
60
                case 1:
61
                        return *(unsigned char *) y;
62
                case 2:
63
                        return *(unsigned short *) y;
64
                case 4:
65
                        return *(unsigned int *) y;
66
                case 8:
67
                        return *(unsigned long *) y;
68
                default:
69
                        return bad_user_access_length();
70
        }
71
}
72
#undef __ptr
73
 
74
/*
75
 * These are deprecated..
76
 *
77
 * Use "put_user()" and "get_user()" with the proper pointer types instead.
78
 */
79
 
80
#define get_fs_byte(addr) __get_user((const unsigned char *)(addr),1)
81
#define get_fs_word(addr) __get_user((const unsigned short *)(addr),2)
82
#define get_fs_long(addr) __get_user((const unsigned int *)(addr),4)
83
 
84
#define put_fs_byte(x,addr) __put_user((x),(unsigned char *)(addr),1)
85
#define put_fs_word(x,addr) __put_user((x),(unsigned short *)(addr),2)
86
#define put_fs_long(x,addr) __put_user((x),(unsigned int *)(addr),4)
87
 
88
#ifdef WE_REALLY_WANT_TO_USE_A_BROKEN_INTERFACE
89
 
90
static inline unsigned char get_user_byte(const char * addr)
91
{
92
        return __get_user(addr,1);
93
}
94
 
95
static inline unsigned short get_user_word(const short *addr)
96
{
97
        return __get_user(addr,2);
98
}
99
 
100
static inline unsigned long get_user_long(const int *addr)
101
{
102
        return __get_user(addr,4);
103
}
104
 
105
static inline void put_user_byte(char val,char *addr)
106
{
107
        __put_user(val, addr, 1);
108
}
109
 
110
static inline void put_user_word(short val,short * addr)
111
{
112
        __put_user(val, addr, 2);
113
}
114
 
115
static inline void put_user_long(unsigned long val,int * addr)
116
{
117
        __put_user(val, addr, 4);
118
}
119
 
120
#endif
121
 
122
#define put_fs_quad(x,addr) put_user_quad((x),(long *)(addr))
123
 
124
#define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
125
 
126
#define memcpy_tofs(to, from, n) memcpy((to),(from),(n)) 
127
 
128
/*
129
 * Get/set the SFC/DFC registers for MOVES instructions
130
 */
131
 
132
static inline unsigned long get_fs(void)
133
{
134
        return USER_DS;
135
}
136
 
137
static inline unsigned long get_ds(void)
138
{
139
    /* return the supervisor data space code */
140
    return KERNEL_DS;
141
}
142
 
143
static inline void set_fs(unsigned long val)
144
{
145
}
146
 
147
#endif /* __ASSEMBLY__ */
148
 
149
#endif /* _OR32_SEGMENT_H */

powered by: WebSVN 2.1.0

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