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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [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 __ASM_ARM_SEGMENT_H
2
#define __ASM_ARM_SEGMENT_H
3
 
4
#define KERNEL_CS   0x0
5
#define KERNEL_DS   0x0
6
 
7
#define USER_CS     0x1
8
#define USER_DS     0x1
9
 
10
#ifndef __ASSEMBLY__
11
 
12
#ifdef NO_INLINE
13
#define __INLINE__
14
#else
15
#define __INLINE__ inline
16
#endif
17
 
18
#include <linux/sched.h>
19
 
20
/*
21
 * A better way to do this might be to pass to put/get user a flag
22
 * indicating the possibility of kernel memory accesses...  That
23
 * would allow gcc to optimize the following routines a bit better
24
 * than that which is possible at the moment.
25
 */
26
#define IS_USER_SEG (current->tss.fs != KERNEL_DS)
27
 
28
/*
29
 * Uh, these should become the main single-value transfer routines..
30
 * They automatically use the right size if we just have the right
31
 * pointer type..
32
 */
33
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
34
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
35
 
36
/*
37
 * This is a silly but good way to make sure that
38
 * the __put_user function is indeed always optimized,
39
 * and that we use the correct sizes..
40
 */
41
extern int bad_user_access_length(void);
42
 
43
#ifdef __KERNEL__
44
 
45
#include <asm/proc/segment.h>
46
 
47
/*
48
 * these are depreciated..
49
 */
50
static __INLINE__ unsigned char get_user_byte(const char *addr)
51
{
52
        return __get_user(addr, 1);
53
}
54
 
55
#define get_fs_byte(addr) get_user_byte((char *)(addr))
56
 
57
static __INLINE__ unsigned short get_user_word(const short *addr)
58
{
59
        return __get_user(addr, 2);
60
}
61
 
62
#define get_fs_word(addr) get_user_word((short *)(addr))
63
 
64
static __INLINE__ unsigned long get_user_long(const long *addr)
65
{
66
        return __get_user(addr, 4);
67
}
68
 
69
#define get_fs_long(addr) get_user_long((long *)(addr))
70
 
71
static __INLINE__ void put_user_byte(char val,char *addr)
72
{
73
        __put_user(val, addr, 1);
74
}
75
 
76
#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
77
 
78
static __INLINE__ void put_user_word(short val,short *addr)
79
{
80
        __put_user(val, addr, 2);
81
}
82
 
83
#define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
84
 
85
static __INLINE__ void put_user_long(long val,long *addr)
86
{
87
        __put_user(val, addr, 4);
88
}
89
 
90
#define put_fs_long(x,addr) put_user_long((x),(long *)(addr))
91
 
92
 
93
extern void memcpy_fromfs(void * to, const void * from, unsigned long n);
94
extern void __memcpy_tofs(void * to, const void * from, unsigned long n);
95
static __INLINE__ void memcpy_tofs(void *to, const void *from, unsigned long n)
96
{
97
        if(IS_USER_SEG)
98
                __memcpy_tofs(to, from, n);
99
        else
100
                memcpy(to, from, n);
101
}
102
 
103
static inline unsigned long get_fs(void)
104
{
105
        return current->tss.fs;
106
}
107
 
108
static inline unsigned long get_ds(void)
109
{
110
        return KERNEL_DS;
111
}
112
 
113
static inline void set_fs(unsigned long val)
114
{
115
        current->tss.fs = val;
116
}
117
 
118
#endif /* __KERNEL__ */
119
 
120
#endif /* __ASSEMBLY__ */
121
 
122
#endif /* __ASM_ARM_SEGMENT_H */
123
 

powered by: WebSVN 2.1.0

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