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
6 * Copyright (C) 1996, 1999 by Ralf Baechle
7 * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
8 * Copyright (C) 2002 Maciej W. Rozycki
10 #ifndef __ASM_MIPS64_ADDRSPACE_H
11 #define __ASM_MIPS64_ADDRSPACE_H
13 #include <linux/config.h>
23 #define _ATYPE_ __PTRDIFF_TYPE__
25 #define _ATYPE64_ long long
29 * 32-bit MIPS address spaces
35 #define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */
36 #define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */
40 * Memory segments (32bit kernel mode addresses)
42 #define KUSEG 0x0000000000000000
43 #define KSEG0 0xffffffff80000000
44 #define KSEG1 0xffffffffa0000000
45 #define KSEG2 0xffffffffc0000000
46 #define KSEG3 0xffffffffe0000000
49 * Returns the kernel segment base of a given address
51 #define KSEGX(a) ((_ACAST64_ (a)) & 0xffffffffe0000000)
54 * Returns the physical address of a KSEG0/KSEG1 address
56 #define XPHYSADDR(a) ((_ACAST64_ (a)) & 0x000000ffffffffff)
57 #define CPHYSADDR(a) ((_ACAST64_ (a)) & 0x000000001fffffff)
60 #define PHYSADDR(a) ({ \
61 const _ATYPE64_ _a = _ACAST64_ (a); \
62 _a == _ACAST32_ _a ? CPHYSADDR(_a) : XPHYSADDR(_a); })
66 * Map an address to a certain kernel segment
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)
74 * Memory segments (64bit kernel mode addresses)
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
85 #if defined (CONFIG_CPU_R4300) \
86 || defined (CONFIG_CPU_R4X00) \
87 || defined (CONFIG_CPU_RM7000) \
88 || defined (CONFIG_CPU_RM9000) \
89 || defined (CONFIG_CPU_R5000) \
90 || defined (CONFIG_CPU_NEVADA) \
91 || defined (CONFIG_CPU_MIPS64)
92 #define KUSIZE 0x0000010000000000 /* 2^^40 */
93 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
94 #define K0SIZE 0x0000001000000000 /* 2^^36 */
95 #define K1SIZE 0x0000001000000000 /* 2^^36 */
96 #define K2SIZE 0x000000ff80000000
97 #define KSEGSIZE 0x000000ff80000000 /* max syssegsz */
98 #define TO_PHYS_MASK 0x0000000fffffffff /* 2^^36 - 1 */
101 #if defined (CONFIG_CPU_R8000)
102 /* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
103 #define KUSIZE 0x0000010000000000 /* 2^^40 */
104 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
105 #define K0SIZE 0x0000010000000000 /* 2^^40 */
106 #define K1SIZE 0x0000010000000000 /* 2^^40 */
107 #define K2SIZE 0x0001000000000000
108 #define KSEGSIZE 0x0000010000000000 /* max syssegsz */
109 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
112 #if defined (CONFIG_CPU_R10000)
113 #define KUSIZE 0x0000010000000000 /* 2^^40 */
114 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
115 #define K0SIZE 0x0000010000000000 /* 2^^40 */
116 #define K1SIZE 0x0000010000000000 /* 2^^40 */
117 #define K2SIZE 0x00000fff80000000
118 #define KSEGSIZE 0x00000fff80000000 /* max syssegsz */
119 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
123 * Further names for SGI source compatibility. These are stolen from
124 * IRIX's <sys/mips_addrspace.h>.
127 #define KUSIZE_32 0x0000000080000000 /* KUSIZE
129 #ifdef CONFIG_CPU_RM7000
130 #define K0BASE 0x9800000000000000UL
132 #define K0BASE 0xa800000000000000
134 #define K0BASE_EXL_WR K0BASE /* exclusive on write */
135 #define K0BASE_NONCOH 0x9800000000000000 /* noncoherent */
136 #define K0BASE_EXL 0xa000000000000000 /* exclusive */
138 #ifdef CONFIG_SGI_IP27
139 #define K1BASE 0x9600000000000000 /* uncached attr 3,
142 #define K1BASE 0x9000000000000000
144 #define K2BASE 0xc000000000000000
146 #if !defined (CONFIG_CPU_R8000)
147 #define COMPAT_K1BASE32 0xffffffffa0000000
148 #define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
151 #define KDM_TO_PHYS(x) (_ACAST64_ (x) & TO_PHYS_MASK)
152 #define PHYS_TO_K0(x) (_ACAST64_ (x) | K0BASE)
154 #endif /* __ASM_MIPS64_ADDRSPACE_H */