2 * include/asm-mips/segment.h 4 * This file is subject to the terms and conditions of the GNU General Public 5 * License. See the file "COPYING" in the main directory of this archive 8 * Copyright (C) 1994, 1995 by Ralf Baechle 10 * Note that the quad functions are only being used for the 64 bit kernel and 11 * therefore it isn't really important that they will be miscompiled for 14 #ifndef __ASM_MIPS_SEGMENT_H 15 #define __ASM_MIPS_SEGMENT_H 17 #ifndef __LANGUAGE_ASSEMBLY__ 21 #include <linux/string.h> 24 * This is a gcc optimization barrier, which essentially 25 * inserts a sequence point in the gcc RTL tree that gcc 26 * can't move code around. This is needed when we enter 27 * or exit a critical region (in this case around user-level 28 * accesses that may sleep, and we can't let gcc optimize 29 * global state around them). 31 #define __gcc_barrier() __asm__ __volatile__("": : :"memory") 34 * Uh, these should become the main single-value transfer routines.. 35 * They automatically use the right size if we just have the right 38 #define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))) 39 #define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr)))) 42 * This is a silly but good way to make sure that 43 * the __put_user function is indeed always optimized, 44 * and that we use the correct sizes.. 46 externintbad_user_access_length(void); 48 /* I should make this use unaligned transfers etc.. */ 49 staticinlinevoid__put_user(unsigned long x
,void* y
,int size
) 66 bad_user_access_length(); 71 /* I should make this use unaligned transfers etc.. */ 72 staticinlineunsigned long__get_user(const void* y
,int size
) 79 result
= *(unsigned char*) y
; 82 result
= *(unsigned short*) y
; 85 result
= *(unsigned int*) y
; 88 result
= *(unsigned long*) y
; 91 result
=bad_user_access_length(); 99 #define get_fs_byte(addr) get_user((unsigned char *)(addr)) 100 #define get_fs_word(addr) get_user((unsigned short *)(addr)) 101 #define get_fs_long(addr) get_user((unsigned int *)(addr)) 102 #define get_fs_quad(addr) get_user((unsigned long *)(addr)) 104 #define put_fs_byte(x,addr) put_user((x),(char *)(addr)) 105 #define put_fs_word(x,addr) put_user((x),(short *)(addr)) 106 #define put_fs_long(x,addr) put_user((x),(int *)(addr)) 107 #define put_fs_quad(x,addr) put_user((x),(long *)(addr)) 109 staticinlinevoidmemcpy_fromfs(void* to
,const void* from
,unsigned long n
) 116 staticinlinevoidmemcpy_tofs(void* to
,const void* from
,unsigned long n
) 124 * For segmented architectures, these are used to specify which segment 125 * to use for the above functions. 127 * MIPS is not segmented, so these are just dummies. 133 staticinlineunsigned longget_fs(void) 138 staticinlineunsigned longget_ds(void) 143 staticinlinevoidset_fs(unsigned long val
) 147 #endif/* !__LANGUAGE_ASSEMBLY__ */ 150 * Memory segments (32bit kernel mode addresses) 152 #define KUSEG 0x00000000 153 #define KSEG0 0x80000000 154 #define KSEG1 0xa0000000 155 #define KSEG2 0xc0000000 156 #define KSEG3 0xe0000000 159 * Returns the kernel segment base of a given address 161 #define KSEGX(a) (((unsigned long)(a)) & 0xe0000000) 164 * Returns the physical address of a KSEG0/KSEG1 address 166 #define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) 169 * Map an address to a certain kernel segment 171 #define KSEG0ADDR(a) ((((unsigned long)(a)) & 0x1fffffff) | KSEG0) 172 #define KSEG1ADDR(a) ((((unsigned long)(a)) & 0x1fffffff) | KSEG1) 173 #define KSEG2ADDR(a) ((((unsigned long)(a)) & 0x1fffffff) | KSEG2) 174 #define KSEG3ADDR(a) ((((unsigned long)(a)) & 0x1fffffff) | KSEG3) 177 * Memory segments (64bit kernel mode addresses) 179 #define XKUSEG 0x0000 0000 0000 0000 180 #define XKSSEG 0x4000 0000 0000 0000 181 #define XKPHYS 0x8000 0000 0000 0000 182 #define XKSEG 0xc000 0000 0000 0000 183 #define CKSEG0 0xffff ffff 8000 0000 184 #define CKSEG1 0xffff ffff a000 0000 185 #define CKSSEG 0xffff ffff c000 0000 186 #define CKSEG3 0xffff ffff e000 0000 188 #endif/* __ASM_MIPS_SEGMENT_H */