make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-mips64 / addrspace.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1996, 1999 by Ralf Baechle
7  * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
8  * Copyright (C) 2002  Maciej W. Rozycki
9  */
10 #ifndef __ASM_MIPS64_ADDRSPACE_H
11 #define __ASM_MIPS64_ADDRSPACE_H
12
13 #include <linux/config.h>
14
15 /*
16  *  Configure language
17  */
18 #ifdef __ASSEMBLY__
19 #define _ATYPE_
20 #define _ATYPE32_
21 #define _ATYPE64_
22 #else
23 #define _ATYPE_         __PTRDIFF_TYPE__
24 #define _ATYPE32_       int
25 #define _ATYPE64_       long long
26 #endif
27
28 /*
29  *  32-bit MIPS address spaces
30  */
31 #ifdef __ASSEMBLY__
32 #define _ACAST32_
33 #define _ACAST64_
34 #else
35 #define _ACAST32_               (_ATYPE_)(_ATYPE32_)    /* widen if necessary */
36 #define _ACAST64_               (_ATYPE64_)             /* do _not_ narrow */
37 #endif
38
39 /*
40  * Memory segments (32bit kernel mode addresses)
41  */
42 #define KUSEG                   0x0000000000000000
43 #define KSEG0                   0xffffffff80000000
44 #define KSEG1                   0xffffffffa0000000
45 #define KSEG2                   0xffffffffc0000000
46 #define KSEG3                   0xffffffffe0000000
47
48 /*
49  * Returns the kernel segment base of a given address
50  */
51 #define KSEGX(a)                ((_ACAST64_ (a)) & 0xffffffffe0000000)
52
53 /*
54  * Returns the physical address of a KSEG0/KSEG1 address
55  */
56 #define XPHYSADDR(a)            ((_ACAST64_ (a)) & 0x000000ffffffffff)
57 #define CPHYSADDR(a)            ((_ACAST64_ (a)) & 0x000000001fffffff)
58
59 #ifndef __ASSEMBLY__
60 #define PHYSADDR(a) ({                                          \
61         const _ATYPE64_ _a = (a);                               \
62         _a == _ACAST32_ _a ? CPHYSADDR(_a) : XPHYSADDR(_a); })
63 #endif
64
65 /*
66  * Map an address to a certain kernel segment
67  */
68 #define KSEG0ADDR(a)            (CPHYSADDR(a) | KSEG0)
69 #define KSEG1ADDR(a)            (CPHYSADDR(a) | KSEG1)
70 #define KSEG2ADDR(a)            (CPHYSADDR(a) | KSEG2)
71 #define KSEG3ADDR(a)            (CPHYSADDR(a) | KSEG3)
72
73 /*
74  * Memory segments (64bit kernel mode addresses)
75  */
76 #define XKUSEG                  0x0000000000000000
77 #define XKSSEG                  0x4000000000000000
78 #define XKPHYS                  0x8000000000000000
79 #define XKSEG                   0xc000000000000000
80 #define CKSEG0                  0xffffffff80000000
81 #define CKSEG1                  0xffffffffa0000000
82 #define CKSSEG                  0xffffffffc0000000
83 #define CKSEG3                  0xffffffffe0000000
84
85 #if defined (CONFIG_CPU_R4300)                                          \
86     || defined (CONFIG_CPU_R4X00)                                       \
87     || defined (CONFIG_CPU_R5000)                                       \
88     || defined (CONFIG_CPU_NEVADA)                                      \
89     || defined (CONFIG_CPU_MIPS64)
90 #define KUSIZE                  0x0000010000000000      /* 2^^40 */
91 #define KUSIZE_64               0x0000010000000000      /* 2^^40 */
92 #define K0SIZE                  0x0000001000000000      /* 2^^36 */
93 #define K1SIZE                  0x0000001000000000      /* 2^^36 */
94 #define K2SIZE                  0x000000ff80000000
95 #define KSEGSIZE                0x000000ff80000000      /* max syssegsz */
96 #define TO_PHYS_MASK            0x0000000fffffffff      /* 2^^36 - 1 */
97 #endif
98
99 #if defined (CONFIG_CPU_R8000)
100 /* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
101 #define KUSIZE                  0x0000010000000000      /* 2^^40 */
102 #define KUSIZE_64               0x0000010000000000      /* 2^^40 */
103 #define K0SIZE                  0x0000010000000000      /* 2^^40 */
104 #define K1SIZE                  0x0000010000000000      /* 2^^40 */
105 #define K2SIZE                  0x0001000000000000
106 #define KSEGSIZE                0x0000010000000000      /* max syssegsz */
107 #define TO_PHYS_MASK            0x000000ffffffffff      /* 2^^40 - 1 */
108 #endif
109
110 #if defined (CONFIG_CPU_R10000)
111 #define KUSIZE                  0x0000010000000000      /* 2^^40 */
112 #define KUSIZE_64               0x0000010000000000      /* 2^^40 */
113 #define K0SIZE                  0x0000010000000000      /* 2^^40 */
114 #define K1SIZE                  0x0000010000000000      /* 2^^40 */
115 #define K2SIZE                  0x00000fff80000000
116 #define KSEGSIZE                0x00000fff80000000      /* max syssegsz */
117 #define TO_PHYS_MASK            0x000000ffffffffff      /* 2^^40 - 1 */
118 #endif
119
120 /*
121  * Further names for SGI source compatibility.  These are stolen from
122  * IRIX's <sys/mips_addrspace.h>.
123  */
124 #define KUBASE                  0
125 #define KUSIZE_32               0x0000000080000000      /* KUSIZE
126                                                            for a 32 bit proc */
127 #define K0BASE                  0xa800000000000000
128 #define K0BASE_EXL_WR           K0BASE                  /* exclusive on write */
129 #define K0BASE_NONCOH           0x9800000000000000      /* noncoherent */
130 #define K0BASE_EXL              0xa000000000000000      /* exclusive */
131
132 #ifdef CONFIG_SGI_IP27
133 #define K1BASE                  0x9600000000000000      /* uncached attr 3,
134                                                            uncac */
135 #else
136 #define K1BASE                  0x9000000000000000
137 #endif
138 #define K2BASE                  0xc000000000000000
139
140 #if !defined (CONFIG_CPU_R8000)
141 #define COMPAT_K1BASE32         0xffffffffa0000000
142 #define PHYS_TO_COMPATK1(x)     ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
143 #endif
144
145 #define KDM_TO_PHYS(x)          (_ACAST64_ (x) & TO_PHYS_MASK)
146 #define PHYS_TO_K0(x)           (_ACAST64_ (x) | K0BASE)
147
148 #endif /* __ASM_MIPS64_ADDRSPACE_H */