Path: blob/master/arch/mips/include/asm/addrspace.h
17281 views
/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 1996, 99 Ralf Baechle6* Copyright (C) 2000, 2002 Maciej W. Rozycki7* Copyright (C) 1990, 1999 by Silicon Graphics, Inc.8*/9#ifndef _ASM_ADDRSPACE_H10#define _ASM_ADDRSPACE_H1112#include <spaces.h>1314/*15* Configure language16*/17#ifdef __ASSEMBLY__18#define _ATYPE_19#define _ATYPE32_20#define _ATYPE64_21#define _CONST64_(x) x22#else23#define _ATYPE_ __PTRDIFF_TYPE__24#define _ATYPE32_ int25#define _ATYPE64_ __s6426#ifdef CONFIG_64BIT27#define _CONST64_(x) x ## L28#else29#define _CONST64_(x) x ## LL30#endif31#endif3233/*34* 32-bit MIPS address spaces35*/36#ifdef __ASSEMBLY__37#define _ACAST32_38#define _ACAST64_39#else40#define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */41#define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */42#endif4344/*45* Returns the kernel segment base of a given address46*/47#define KSEGX(a) ((_ACAST32_ (a)) & 0xe0000000)4849/*50* Returns the physical address of a CKSEGx / XKPHYS address51*/52#define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff)53#define XPHYSADDR(a) ((_ACAST64_(a)) & \54_CONST64_(0x000000ffffffffff))5556#ifdef CONFIG_64BIT5758/*59* Memory segments (64bit kernel mode addresses)60* The compatibility segments use the full 64-bit sign extended value. Note61* the R8000 doesn't have them so don't reference these in generic MIPS code.62*/63#define XKUSEG _CONST64_(0x0000000000000000)64#define XKSSEG _CONST64_(0x4000000000000000)65#define XKPHYS _CONST64_(0x8000000000000000)66#define XKSEG _CONST64_(0xc000000000000000)67#define CKSEG0 _CONST64_(0xffffffff80000000)68#define CKSEG1 _CONST64_(0xffffffffa0000000)69#define CKSSEG _CONST64_(0xffffffffc0000000)70#define CKSEG3 _CONST64_(0xffffffffe0000000)7172#define CKSEG0ADDR(a) (CPHYSADDR(a) | CKSEG0)73#define CKSEG1ADDR(a) (CPHYSADDR(a) | CKSEG1)74#define CKSEG2ADDR(a) (CPHYSADDR(a) | CKSEG2)75#define CKSEG3ADDR(a) (CPHYSADDR(a) | CKSEG3)7677#else7879#define CKSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)80#define CKSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)81#define CKSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)82#define CKSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)8384/*85* Map an address to a certain kernel segment86*/87#define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)88#define KSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)89#define KSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)90#define KSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)9192/*93* Memory segments (32bit kernel mode addresses)94* These are the traditional names used in the 32-bit universe.95*/96#define KUSEG 0x0000000097#define KSEG0 0x8000000098#define KSEG1 0xa000000099#define KSEG2 0xc0000000100#define KSEG3 0xe0000000101102#define CKUSEG 0x00000000103#define CKSEG0 0x80000000104#define CKSEG1 0xa0000000105#define CKSEG2 0xc0000000106#define CKSEG3 0xe0000000107108#endif109110/*111* Cache modes for XKPHYS address conversion macros112*/113#define K_CALG_COH_EXCL1_NOL2 0114#define K_CALG_COH_SHRL1_NOL2 1115#define K_CALG_UNCACHED 2116#define K_CALG_NONCOHERENT 3117#define K_CALG_COH_EXCL 4118#define K_CALG_COH_SHAREABLE 5119#define K_CALG_NOTUSED 6120#define K_CALG_UNCACHED_ACCEL 7121122/*123* 64-bit address conversions124*/125#define PHYS_TO_XKSEG_UNCACHED(p) PHYS_TO_XKPHYS(K_CALG_UNCACHED, (p))126#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))127#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK)128#define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) | \129(_CONST64_(cm) << 59) | (a))130131/*132* The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting133* the region, 3 bits for the CCA mode. This leaves 59 bits of which the134* R8000 implements most with its 48-bit physical address space.135*/136#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff) /* 2^^59 - 1 */137138#ifndef CONFIG_CPU_R8000139140/*141* The R8000 doesn't have the 32-bit compat spaces so we don't define them142* in order to catch bugs in the source code.143*/144145#define COMPAT_K1BASE32 _CONST64_(0xffffffffa0000000)146#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */147148#endif149150#define KDM_TO_PHYS(x) (_ACAST64_ (x) & TO_PHYS_MASK)151#define PHYS_TO_K0(x) (_ACAST64_ (x) | CAC_BASE)152153#endif /* _ASM_ADDRSPACE_H */154155156