File: /usr/src/linux/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 */
9 #ifndef _ASM_ADDRSPACE_H
10 #define _ASM_ADDRSPACE_H
11
12 #include <linux/config.h>
13
14 /*
15 * Memory segments (32bit kernel mode addresses)
16 */
17 #define KUSEG 0x0000000000000000
18 #define KSEG0 0xffffffff80000000
19 #define KSEG1 0xffffffffa0000000
20 #define KSEG2 0xffffffffc0000000
21 #define KSEG3 0xffffffffe0000000
22
23 /*
24 * Returns the kernel segment base of a given address
25 */
26 #define KSEGX(a) (((unsigned long)(a)) & 0xe0000000)
27
28 /*
29 * Returns the physical address of a KSEG0/KSEG1 address
30 */
31 #define CPHYSADDR(a) (((unsigned long)(a)) & 0x000000001fffffffUL)
32 #define PHYSADDR(a) (((unsigned long)(a)) & 0x000000ffffffffffUL)
33
34 /*
35 * Map an address to a certain kernel segment
36 */
37 #define KSEG0ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x000000ffffffffffUL) | KSEG0))
38 #define KSEG1ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x000000ffffffffffUL) | KSEG1))
39 #define KSEG2ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x000000ffffffffffUL) | KSEG2))
40 #define KSEG3ADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x000000ffffffffffUL) | KSEG3))
41
42 /*
43 * Memory segments (64bit kernel mode addresses)
44 */
45 #define XKUSEG 0x0000000000000000
46 #define XKSSEG 0x4000000000000000
47 #define XKPHYS 0x8000000000000000
48 #define XKSEG 0xc000000000000000
49 #define CKSEG0 0xffffffff80000000
50 #define CKSEG1 0xffffffffa0000000
51 #define CKSSEG 0xffffffffc0000000
52 #define CKSEG3 0xffffffffe0000000
53
54 #if defined (CONFIG_CPU_R4300) \
55 || defined (CONFIG_CPU_R4X00) \
56 || defined (CONFIG_CPU_R5000) \
57 || defined (CONFIG_CPU_NEVADA)
58 #define KUSIZE 0x0000010000000000 /* 2^^40 */
59 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
60 #define K0SIZE 0x0000001000000000 /* 2^^36 */
61 #define K1SIZE 0x0000001000000000 /* 2^^36 */
62 #define K2SIZE 0x000000ff80000000
63 #define KSEGSIZE 0x000000ff80000000 /* max syssegsz */
64 #define TO_PHYS_MASK 0x0000000fffffffff /* 2^^36 - 1 */
65 #endif
66
67 #if defined (CONFIG_CPU_R8000)
68 /* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
69 #define KUSIZE 0x0000010000000000 /* 2^^40 */
70 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
71 #define K0SIZE 0x0000010000000000 /* 2^^40 */
72 #define K1SIZE 0x0000010000000000 /* 2^^40 */
73 #define K2SIZE 0x0001000000000000
74 #define KSEGSIZE 0x0000010000000000 /* max syssegsz */
75 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
76 #endif
77
78 #if defined (CONFIG_CPU_R10000)
79 #define KUSIZE 0x0000010000000000 /* 2^^40 */
80 #define KUSIZE_64 0x0000010000000000 /* 2^^40 */
81 #define K0SIZE 0x0000010000000000 /* 2^^40 */
82 #define K1SIZE 0x0000010000000000 /* 2^^40 */
83 #define K2SIZE 0x00000fff80000000
84 #define KSEGSIZE 0x00000fff80000000 /* max syssegsz */
85 #define TO_PHYS_MASK 0x000000ffffffffff /* 2^^40 - 1 */
86 #endif
87
88 /*
89 * Further names for SGI source compatibility. These are stolen from
90 * IRIX's <sys/mips_addrspace.h>.
91 */
92 #define KUBASE 0
93 #define KUSIZE_32 0x0000000080000000 /* KUSIZE for a 32 bit proc */
94 #define K0BASE 0xa800000000000000
95 #define K0BASE_EXL_WR K0BASE /* exclusive on write */
96 #define K0BASE_NONCOH 0x9800000000000000 /* noncoherent */
97 #define K0BASE_EXL 0xa000000000000000 /* exclusive */
98
99 #ifdef CONFIG_SGI_IP27
100 #define K1BASE 0x9600000000000000 /* Uncached attr 3, uncac */
101 #else
102 #define K1BASE 0x9000000000000000
103 #endif
104 #define K2BASE 0xc000000000000000
105
106 #if !defined (CONFIG_CPU_R8000)
107 #define COMPAT_K1BASE32 0xffffffffa0000000
108 #define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
109 #endif
110
111 #define KDM_TO_PHYS(x) ((unsigned long)(x) & TO_PHYS_MASK)
112 #define PHYS_TO_K0(x) ((unsigned long)(x) | K0BASE)
113
114 #endif /* _ASM_ADDRSPACE_H */
115