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

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