Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 1996, 99 Ralf Baechle
0007  * Copyright (C) 2000, 2002  Maciej W. Rozycki
0008  * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
0009  */
0010 #ifndef _ASM_ADDRSPACE_H
0011 #define _ASM_ADDRSPACE_H
0012 
0013 #include <spaces.h>
0014 
0015 /*
0016  *  Configure language
0017  */
0018 #ifdef __ASSEMBLY__
0019 #define _ATYPE_
0020 #define _ATYPE32_
0021 #define _ATYPE64_
0022 #define _CONST64_(x)    x
0023 #else
0024 #define _ATYPE_     __PTRDIFF_TYPE__
0025 #define _ATYPE32_   int
0026 #define _ATYPE64_   __s64
0027 #ifdef CONFIG_64BIT
0028 #define _CONST64_(x)    x ## L
0029 #else
0030 #define _CONST64_(x)    x ## LL
0031 #endif
0032 #endif
0033 
0034 /*
0035  *  32-bit MIPS address spaces
0036  */
0037 #ifdef __ASSEMBLY__
0038 #define _ACAST32_
0039 #define _ACAST64_
0040 #else
0041 #define _ACAST32_       (_ATYPE_)(_ATYPE32_)    /* widen if necessary */
0042 #define _ACAST64_       (_ATYPE64_)     /* do _not_ narrow */
0043 #endif
0044 
0045 /*
0046  * Returns the kernel segment base of a given address
0047  */
0048 #define KSEGX(a)        ((_ACAST32_(a)) & _ACAST32_(0xe0000000))
0049 
0050 /*
0051  * Returns the physical address of a CKSEGx / XKPHYS address
0052  */
0053 #define CPHYSADDR(a)        ((_ACAST32_(a)) & 0x1fffffff)
0054 #define XPHYSADDR(a)        ((_ACAST64_(a)) &           \
0055                  _CONST64_(0x0000ffffffffffff))
0056 
0057 #ifdef CONFIG_64BIT
0058 
0059 /*
0060  * Memory segments (64bit kernel mode addresses)
0061  * The compatibility segments use the full 64-bit sign extended value.  Note
0062  * the R8000 doesn't have them so don't reference these in generic MIPS code.
0063  */
0064 #define XKUSEG          _CONST64_(0x0000000000000000)
0065 #define XKSSEG          _CONST64_(0x4000000000000000)
0066 #define XKPHYS          _CONST64_(0x8000000000000000)
0067 #define XKSEG           _CONST64_(0xc000000000000000)
0068 #define CKSEG0          _CONST64_(0xffffffff80000000)
0069 #define CKSEG1          _CONST64_(0xffffffffa0000000)
0070 #define CKSSEG          _CONST64_(0xffffffffc0000000)
0071 #define CKSEG3          _CONST64_(0xffffffffe0000000)
0072 
0073 #define CKSEG0ADDR(a)       (CPHYSADDR(a) | CKSEG0)
0074 #define CKSEG1ADDR(a)       (CPHYSADDR(a) | CKSEG1)
0075 #define CKSEG2ADDR(a)       (CPHYSADDR(a) | CKSEG2)
0076 #define CKSEG3ADDR(a)       (CPHYSADDR(a) | CKSEG3)
0077 
0078 #else
0079 
0080 #define CKSEG0ADDR(a)       (CPHYSADDR(a) | KSEG0)
0081 #define CKSEG1ADDR(a)       (CPHYSADDR(a) | KSEG1)
0082 #define CKSEG2ADDR(a)       (CPHYSADDR(a) | KSEG2)
0083 #define CKSEG3ADDR(a)       (CPHYSADDR(a) | KSEG3)
0084 
0085 /*
0086  * Map an address to a certain kernel segment
0087  */
0088 #define KSEG0ADDR(a)        (CPHYSADDR(a) | KSEG0)
0089 #define KSEG1ADDR(a)        (CPHYSADDR(a) | KSEG1)
0090 #define KSEG2ADDR(a)        (CPHYSADDR(a) | KSEG2)
0091 #define KSEG3ADDR(a)        (CPHYSADDR(a) | KSEG3)
0092 
0093 /*
0094  * Memory segments (32bit kernel mode addresses)
0095  * These are the traditional names used in the 32-bit universe.
0096  */
0097 #define KUSEG           0x00000000
0098 #define KSEG0           0x80000000
0099 #define KSEG1           0xa0000000
0100 #define KSEG2           0xc0000000
0101 #define KSEG3           0xe0000000
0102 
0103 #define CKUSEG          0x00000000
0104 #define CKSEG0          0x80000000
0105 #define CKSEG1          0xa0000000
0106 #define CKSEG2          0xc0000000
0107 #define CKSEG3          0xe0000000
0108 
0109 #endif
0110 
0111 /*
0112  * Cache modes for XKPHYS address conversion macros
0113  */
0114 #define K_CALG_COH_EXCL1_NOL2   0
0115 #define K_CALG_COH_SHRL1_NOL2   1
0116 #define K_CALG_UNCACHED     2
0117 #define K_CALG_NONCOHERENT  3
0118 #define K_CALG_COH_EXCL     4
0119 #define K_CALG_COH_SHAREABLE    5
0120 #define K_CALG_NOTUSED      6
0121 #define K_CALG_UNCACHED_ACCEL   7
0122 
0123 /*
0124  * 64-bit address conversions
0125  */
0126 #define PHYS_TO_XKSEG_UNCACHED(p)   PHYS_TO_XKPHYS(K_CALG_UNCACHED, (p))
0127 #define PHYS_TO_XKSEG_CACHED(p)     PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))
0128 #define XKPHYS_TO_PHYS(p)       ((p) & TO_PHYS_MASK)
0129 #define PHYS_TO_XKPHYS(cm, a)       (XKPHYS | (_ACAST64_(cm) << 59) | (a))
0130 
0131 /*
0132  * The ultimate limited of the 64-bit MIPS architecture:  2 bits for selecting
0133  * the region, 3 bits for the CCA mode.  This leaves 59 bits of which the
0134  * R8000 implements most with its 48-bit physical address space.
0135  */
0136 #define TO_PHYS_MASK    _CONST64_(0x07ffffffffffffff)   /* 2^^59 - 1 */
0137 
0138 #define COMPAT_K1BASE32     _CONST64_(0xffffffffa0000000)
0139 #define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
0140 
0141 #define KDM_TO_PHYS(x)      (_ACAST64_ (x) & TO_PHYS_MASK)
0142 #define PHYS_TO_K0(x)       (_ACAST64_ (x) | CAC_BASE)
0143 
0144 #endif /* _ASM_ADDRSPACE_H */