These are already identical ... 508 lines of code, goodbye.
[linux-2.6/linux-mips.git] / include / asm-mips64 / addrspace.h
blob19cdd947e5cbee771736f825328d8cd661d47923
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.
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_ADDRSPACE_H
11 #define __ASM_ADDRSPACE_H
13 #include <linux/config.h>
16 * Configure language
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
29 * 32-bit MIPS address spaces
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
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)
59 #define PHYSADDR(a) ({ \
60 const _ATYPE64_ _a = _ACAST64_ (a); \
61 _a == _ACAST32_ _a ? CPHYSADDR(_a) : XPHYSADDR(_a); })
64 * Map an address to a certain kernel segment
66 #define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
67 #define KSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)
68 #define KSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)
69 #define KSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)
72 * Memory segments (64bit kernel mode addresses)
74 #define XKUSEG 0x0000000000000000
75 #define XKSSEG 0x4000000000000000
76 #define XKPHYS 0x8000000000000000
77 #define XKSEG 0xc000000000000000
78 #define CKSEG0 0xffffffff80000000
79 #define CKSEG1 0xffffffffa0000000
80 #define CKSSEG 0xffffffffc0000000
81 #define CKSEG3 0xffffffffe0000000
83 #if defined (CONFIG_CPU_R4300) \
84 || defined (CONFIG_CPU_R4X00) \
85 || defined (CONFIG_CPU_R5000) \
86 || defined (CONFIG_CPU_NEVADA) \
87 || defined (CONFIG_CPU_MIPS64)
88 #define KUSIZE 0x0000010000000000 /* 2^^40 */
89 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
90 #define K0SIZE 0x0000001000000000 /* 2^^36 */
91 #define K1SIZE 0x0000001000000000 /* 2^^36 */
92 #define K2SIZE 0x000000ff80000000
93 #define KSEGSIZE 0x000000ff80000000 /* max syssegsz */
94 #define TO_PHYS_MASK 0x0000000fffffffff /* 2^^36 - 1 */
95 #endif
97 #if defined (CONFIG_CPU_R8000)
98 /* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
99 #define KUSIZE 0x0000010000000000 /* 2^^40 */
100 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
101 #define K0SIZE 0x0000010000000000 /* 2^^40 */
102 #define K1SIZE 0x0000010000000000 /* 2^^40 */
103 #define K2SIZE 0x0001000000000000
104 #define KSEGSIZE 0x0000010000000000 /* max syssegsz */
105 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
106 #endif
108 #if defined (CONFIG_CPU_R10000)
109 #define KUSIZE 0x0000010000000000 /* 2^^40 */
110 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
111 #define K0SIZE 0x0000010000000000 /* 2^^40 */
112 #define K1SIZE 0x0000010000000000 /* 2^^40 */
113 #define K2SIZE 0x00000fff80000000
114 #define KSEGSIZE 0x00000fff80000000 /* max syssegsz */
115 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
116 #endif
119 * Further names for SGI source compatibility. These are stolen from
120 * IRIX's <sys/mips_addrspace.h>.
122 #define KUBASE 0
123 #define KUSIZE_32 0x0000000080000000 /* KUSIZE
124 for a 32 bit proc */
125 #define K0BASE 0xa800000000000000
126 #define K0BASE_EXL_WR K0BASE /* exclusive on write */
127 #define K0BASE_NONCOH 0x9800000000000000 /* noncoherent */
128 #define K0BASE_EXL 0xa000000000000000 /* exclusive */
130 #ifdef CONFIG_SGI_IP27
131 #define K1BASE 0x9600000000000000 /* uncached attr 3,
132 uncac */
133 #else
134 #define K1BASE 0x9000000000000000
135 #endif
136 #define K2BASE 0xc000000000000000
138 #if !defined (CONFIG_CPU_R8000)
139 #define COMPAT_K1BASE32 0xffffffffa0000000
140 #define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
141 #endif
143 #define KDM_TO_PHYS(x) (_ACAST64_ (x) & TO_PHYS_MASK)
144 #define PHYS_TO_K0(x) (_ACAST64_ (x) | K0BASE)
146 #endif /* __ASM_ADDRSPACE_H */