root/include/asm-sparc/segment.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __put_user
  2. __get_user
  3. get_user_byte
  4. get_user_word
  5. get_user_long
  6. put_user_byte
  7. put_user_word
  8. put_user_long
  9. get_fs
  10. get_ds
  11. set_fs

   1 /* $Id: segment.h,v 1.10 1996/03/08 01:19:38 miguel 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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
 118 {
 119         return active_ds;
 120 }
 121 
 122 static inline int get_ds(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 123 {
 124         return KERNEL_DS;
 125 }
 126 
 127 static inline void set_fs(int val)
     /* [previous][next][first][last][top][bottom][index][help] */
 128 {
 129         active_ds = val;
 130 }
 131 
 132 #endif  /* __ASSEMBLY__ */
 133 
 134 #endif /* _ASM_SEGMENT_H */

/* [previous][next][first][last][top][bottom][index][help] */