patch-2.1.44 linux/include/asm-sparc64/uaccess.h

Next file: linux/include/asm-sparc64/uctx.h
Previous file: linux/include/asm-sparc64/system.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.43/linux/include/asm-sparc64/uaccess.h linux/include/asm-sparc64/uaccess.h
@@ -1,4 +1,4 @@
-/* $Id: uaccess.h,v 1.13 1997/05/29 12:45:04 jj Exp $ */
+/* $Id: uaccess.h,v 1.19 1997/06/30 10:31:46 jj Exp $ */
 #ifndef _ASM_UACCESS_H
 #define _ASM_UACCESS_H
 
@@ -22,26 +22,26 @@
  *
  * "For historical reasons, these macros are grossly misnamed." -Linus
  */
-#define KERNEL_DS   0
-#define USER_DS     -1
+#define KERNEL_DS   0x00
+#define USER_DS     0x2B /* har har har */
 
 #define VERIFY_READ	0
 #define VERIFY_WRITE	1
 
 #define get_fs() (current->tss.current_ds)
 #define get_ds() (KERNEL_DS)
-extern __inline__ void set_fs(int val)
-{
-	if (val != current->tss.current_ds) {
-		if (val == KERNEL_DS) {
-			flushw_user ();
-			spitfire_set_secondary_context (0);
-		} else {
-			spitfire_set_secondary_context (current->mm->context);
-		}
-		current->tss.current_ds = val;
-	}
-}
+#define set_fs(val)				\
+do {						\
+	current->tss.current_ds = (val);	\
+	if ((val) == KERNEL_DS) {		\
+		flushw_user ();			\
+		current->tss.ctx = 0;		\
+	} else {				\
+		current->tss.ctx = (current->mm->context & 0x1fff); \
+	}					\
+	spitfire_set_secondary_context(current->tss.ctx); \
+	__asm__ __volatile__("flush %g6");	\
+} while(0)
 
 #define __user_ok(addr,size) 1
 #define __kernel_ok (get_fs() == KERNEL_DS)
@@ -255,8 +255,47 @@
 
 extern int __get_user_bad(void);
 
-extern __kernel_size_t __copy_to_user(void *to, void *from, __kernel_size_t size);
-extern __kernel_size_t __copy_from_user(void *to, void *from, __kernel_size_t size);
+extern __kernel_size_t __memcpy_short(void *to, const void *from, __kernel_size_t size, long asi_src, long asi_dst);
+extern __kernel_size_t __memcpy_entry(void *to, const void *from, __kernel_size_t size, long asi_src, long asi_dst);
+extern __kernel_size_t __memcpy_16plus(void *to, const void *from, __kernel_size_t size, long asi_src, long asi_dst);
+extern __kernel_size_t __memcpy_386plus(void *to, const void *from, __kernel_size_t size, long asi_src, long asi_dst);
+
+#if 0
+extern __inline__ __kernel_size_t __copy_to_user(void *to, void *from, __kernel_size_t size)
+{
+	if (__builtin_constant_p(size)) {
+		if (!size) return 0;
+		if (size < 16)
+			return __memcpy_short(to,(const void *)from,size,ASI_BLK_P,ASI_BLK_S);
+		else if (size < 384)
+			return __memcpy_16plus(to,(const void *)from,size,ASI_BLK_P,ASI_BLK_S);
+		else
+			return __memcpy_386plus(to,(const void *)from,size,ASI_BLK_P,ASI_BLK_S);
+	} else {
+		if (!size) return 0;
+		return __memcpy_entry(to,(const void *)from,size,ASI_BLK_P,ASI_BLK_S);
+	}
+}
+
+extern __inline__ __kernel_size_t __copy_from_user(void *to, void *from, __kernel_size_t size)
+{
+	if (__builtin_constant_p(size)) {
+		if (!size) return 0;
+		if (size < 16)
+			return __memcpy_short(to,(const void *)from,size,ASI_BLK_S,ASI_BLK_P);
+		else if (size < 384)
+			return __memcpy_16plus(to,(const void *)from,size,ASI_BLK_S,ASI_BLK_P);
+		else
+			return __memcpy_386plus(to,(const void *)from,size,ASI_BLK_S,ASI_BLK_P);
+	} else {
+		if (!size) return 0;
+		return __memcpy_entry(to,(const void *)from,size,ASI_BLK_S,ASI_BLK_P);
+	}
+}
+#else
+extern __kernel_size_t __copy_from_user(void *to, const void *from, __kernel_size_t size);
+extern __kernel_size_t __copy_to_user(void *to, const void *from, __kernel_size_t size);
+#endif
 
 #define copy_to_user(to,from,n) \
 	__copy_to_user((void *)(to), \
@@ -288,21 +327,11 @@
 
 extern __inline__ __kernel_size_t __clear_user(void *addr, __kernel_size_t size)
 {
-  __kernel_size_t ret;
-  __asm__ __volatile__ ("
-	.section __ex_table,#alloc
-	.align 8
-	.xword 1f,3
-	.previous
-1:
-	wr %%g0, %3, %%asi
-	mov %2, %%o1
-	call __bzero_noasi
-	 mov %1, %%o0
-	mov %%o0, %0
-	" : "=r" (ret) : "r" (addr), "r" (size), "i" (ASI_S) :
-	"cc", "o0", "o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g5", "g7");
-  return ret;
+	extern __kernel_size_t __bzero_noasi(void *addr, __kernel_size_t size);
+	
+	
+	__asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "i" (ASI_S));
+	return __bzero_noasi(addr, size);
 }
 
 #define clear_user(addr,n) \

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov