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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-sparc/] [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
/* $Id: segment.h,v 1.1 2005-12-20 11:32:11 jcastillo Exp $ */
2
#ifndef _ASM_SEGMENT_H
3
#define _ASM_SEGMENT_H
4
 
5
#ifdef __KERNEL__
6
#include <asm/vac-ops.h>
7
#endif
8
 
9
#ifndef __ASSEMBLY__
10
 
11
/*
12
 * Uh, these should become the main single-value transfer routines..
13
 * They automatically use the right size if we just have the right
14
 * pointer type..
15
 */
16
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
17
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
18
 
19
/*
20
 * This is a silly but good way to make sure that
21
 * the __put_user function is indeed always optimized,
22
 * and that we use the correct sizes..
23
 */
24
extern int bad_user_access_length(void);
25
 
26
/* I should make this use unaligned transfers etc.. */
27
static inline void __put_user(unsigned long x, void * y, int size)
28
{
29
        switch (size) {
30
                case 1:
31
                        *(char *) y = x;
32
                        break;
33
                case 2:
34
                        *(short *) y = x;
35
                        break;
36
                case 4:
37
                        *(int *) y = x;
38
                        break;
39
                default:
40
                        bad_user_access_length();
41
        }
42
}
43
 
44
/* I should make this use unaligned transfers etc.. */
45
static inline unsigned long __get_user(const void * y, int size)
46
{
47
        switch (size) {
48
                case 1:
49
                        return *(unsigned char *) y;
50
                case 2:
51
                        return *(unsigned short *) y;
52
                case 4:
53
                        return *(unsigned int *) y;
54
                default:
55
                        return bad_user_access_length();
56
        }
57
}
58
 
59
/*
60
 * Deprecated routines
61
 */
62
 
63
static inline unsigned char get_user_byte(const char * addr)
64
{
65
        return *addr;
66
}
67
 
68
#define get_fs_byte(addr) get_user_byte((char *)(addr))
69
 
70
static inline unsigned short get_user_word(const short *addr)
71
{
72
        return *addr;
73
}
74
 
75
#define get_fs_word(addr) get_user_word((short *)(addr))
76
 
77
static inline unsigned long get_user_long(const int *addr)
78
{
79
        return *addr;
80
}
81
 
82
#define get_fs_long(addr) get_user_long((int *)(addr))
83
 
84
static inline void put_user_byte(char val,char *addr)
85
{
86
        *addr = val;
87
}
88
 
89
#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
90
 
91
static inline void put_user_word(short val,short * addr)
92
{
93
        *addr = val;
94
}
95
 
96
#define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
97
 
98
static inline void put_user_long(unsigned long val,int * addr)
99
{
100
        *addr = val;
101
}
102
 
103
#define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
104
 
105
#define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
106
 
107
#define memcpy_tofs(to, from, n) memcpy((to),(from),(n))
108
 
109
/* Sparc is not segmented, however we need to be able to fool verify_area()
110
 * when doing system calls from kernel mode legitimately.
111
 */
112
#define KERNEL_DS   0
113
#define USER_DS     1
114
 
115
extern int active_ds;
116
 
117
static inline int get_fs(void)
118
{
119
        return active_ds;
120
}
121
 
122
static inline int get_ds(void)
123
{
124
        return KERNEL_DS;
125
}
126
 
127
static inline void set_fs(int val)
128
{
129
        active_ds = val;
130
}
131
 
132
#endif  /* __ASSEMBLY__ */
133
 
134
#endif /* _ASM_SEGMENT_H */

powered by: WebSVN 2.1.0

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