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) 1992-1999,2001-2003 Silicon Graphics, Inc. All rights reserved.
9 #ifndef _ASM_IA64_SN_ADDRS_H
10 #define _ASM_IA64_SN_ADDRS_H
12 #include <asm/sn/sn2/addrs.h>
15 #include <asm/sn/types.h>
18 #define HUBREG_CAST (volatile mmr_t *)
22 * The following macros are used to index to the beginning of a specific
23 * node's address space.
26 #define NODE_OFFSET(_n) ((uint64_t) (_n) << NASID_SHFT)
28 #define NODE_CAC_BASE(_n) (CAC_BASE + NODE_OFFSET(_n))
29 #define NODE_HSPEC_BASE(_n) (HSPEC_BASE + NODE_OFFSET(_n))
30 #define NODE_IO_BASE(_n) (IO_BASE + NODE_OFFSET(_n))
31 #define NODE_MSPEC_BASE(_n) (MSPEC_BASE + NODE_OFFSET(_n))
32 #define NODE_UNCAC_BASE(_n) (UNCAC_BASE + NODE_OFFSET(_n))
34 #define TO_NODE(_n, _x) (NODE_OFFSET(_n) | ((_x) ))
35 #define TO_NODE_CAC(_n, _x) (NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
36 #define TO_NODE_UNCAC(_n, _x) (NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
37 #define TO_NODE_MSPEC(_n, _x) (NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
38 #define TO_NODE_HSPEC(_n, _x) (NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
41 #define RAW_NODE_SWIN_BASE(nasid, widget) \
42 (NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
44 #define WIDGETID_GET(addr) ((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))
47 * The following definitions pertain to the IO special address
48 * space. They define the location of the big and little windows
52 #define SWIN_SIZE_BITS 24
53 #define SWIN_SIZE (1UL << 24)
54 #define SWIN_SIZEMASK (SWIN_SIZE - 1)
55 #define SWIN_WIDGET_MASK 0xF
58 * Convert smallwindow address to xtalk address.
60 * 'addr' can be physical or virtual address, but will be converted
61 * to Xtalk address in the range 0 -> SWINZ_SIZEMASK
63 #define SWIN_WIDGETADDR(addr) ((addr) & SWIN_SIZEMASK)
64 #define SWIN_WIDGETNUM(addr) (((addr) >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK)
66 * Verify if addr belongs to small window address on node with "nasid"
69 * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
74 #define NODE_SWIN_ADDR(nasid, addr) \
75 (((addr) >= NODE_SWIN_BASE(nasid, 0)) && \
76 ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\
80 * The following define the major position-independent aliases used
82 * LBOOT -- 256MB in size, reads in the LBOOT area result in
83 * uncached references to the local hub's boot prom and
84 * other directory-bus connected devices.
85 * IALIAS -- 8MB in size, reads in the IALIAS result in uncached
86 * references to the local hub's registers.
89 #define HUB_REGISTER_WIDGET 1
90 #define IALIAS_BASE LOCAL_SWIN_BASE(HUB_REGISTER_WIDGET)
91 #define IALIAS_SIZE 0x800000 /* 8 Megabytes */
92 #define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) && \
93 ((_a) < (IALIAS_BASE + IALIAS_SIZE)))
96 * The following macros produce the correct base virtual address for
97 * the hub registers. The LOCAL_HUB_* macros produce the appropriate
98 * address for the local registers. The REMOTE_HUB_* macro produce
99 * the address for the specified hub's registers. The intent is
100 * that the appropriate PI, MD, NI, or II register would be substituted
106 * SN2 has II mmr's located inside small window space.
107 * As all other non-II mmr's located at the top of big window
110 #define LOCAL_HUB_BASE(_x) (LOCAL_MMR_ADDR(_x) | (((~(_x)) & BWIN_TOP)>>8))
111 #define REMOTE_HUB_BASE(_x) \
112 (UNCACHED | GLOBAL_MMR_SPACE | \
113 (((~(_x)) & BWIN_TOP)>>8) | \
114 (((~(_x)) & BWIN_TOP)>>9) | (_x))
116 #define LOCAL_HUB(_x) (HUBREG_CAST LOCAL_HUB_BASE(_x))
117 #define REMOTE_HUB(_n, _x) \
118 (HUBREG_CAST (REMOTE_HUB_BASE(_x) | ((((long)(_n))<<NASID_SHFT))))
123 * When certain Hub chip workaround are defined, it's not sufficient
124 * to dereference the *_HUB_ADDR() macros. You should instead use
125 * HUB_L() and HUB_S() if you must deal with pointers to hub registers.
126 * Otherwise, the recommended approach is to use *_HUB_L() and *_HUB_S().
127 * They're always safe.
129 #define LOCAL_HUB_ADDR(_x) \
130 (((_x) & BWIN_TOP) ? (HUBREG_CAST (LOCAL_MMR_ADDR(_x))) \
131 : (HUBREG_CAST (IALIAS_BASE + (_x))))
132 #define REMOTE_HUB_ADDR(_n, _x) \
133 (((_x) & BWIN_TOP) ? (HUBREG_CAST (GLOBAL_MMR_ADDR(_n, _x))) \
134 : (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + 0x800000 + (_x))))
138 #define HUB_L(_a) (*((volatile typeof(*_a) *)_a))
139 #define HUB_S(_a, _d) (*((volatile typeof(*_a) *)_a) = (_d))
141 #define LOCAL_HUB_L(_r) HUB_L(LOCAL_HUB_ADDR(_r))
142 #define LOCAL_HUB_S(_r, _d) HUB_S(LOCAL_HUB_ADDR(_r), (_d))
143 #define REMOTE_HUB_L(_n, _r) HUB_L(REMOTE_HUB_ADDR((_n), (_r)))
144 #define REMOTE_HUB_S(_n, _r, _d) HUB_S(REMOTE_HUB_ADDR((_n), (_r)), (_d))
145 #define REMOTE_HUB_PI_L(_n, _sn, _r) HUB_L(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)))
146 #define REMOTE_HUB_PI_S(_n, _sn, _r, _d) HUB_S(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)), (_d))
148 #endif /* __ASSEMBLY__ */
151 * The following macros are used to get to a hub/bridge register, given
152 * the base of the register space.
154 #define HUB_REG_PTR(_base, _off) \
155 (HUBREG_CAST ((unsigned long)(_base) + (__psunsigned_t)(_off)))
157 #define HUB_REG_PTR_L(_base, _off) \
158 HUB_L(HUB_REG_PTR((_base), (_off)))
160 #define HUB_REG_PTR_S(_base, _off, _data) \
161 HUB_S(HUB_REG_PTR((_base), (_off)), (_data))
164 * Software structure locations -- permanently fixed
165 * See diagram in kldir.h
168 #define PHYS_RAMBASE 0x0
169 #define K0_RAMBASE PHYS_TO_K0(PHYS_RAMBASE)
171 #define ARCS_SPB_OFFSET 0x1000
172 #define ARCS_SPB_ADDR(nasid) \
173 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET)
174 #define ARCS_SPB_SIZE 0x0400
176 #define KLDIR_OFFSET 0x2000
177 #define KLDIR_ADDR(nasid) \
178 TO_NODE_CAC((nasid), KLDIR_OFFSET)
179 #define KLDIR_SIZE 0x0400
183 * Software structure locations -- indirected through KLDIR
184 * See diagram in kldir.h
186 * Important: All low memory structures must only be accessed
187 * uncached, except for the symmon stacks.
190 #define KLI_LAUNCH 0 /* Dir. entries */
191 #define KLI_KLCONFIG 1
194 #define KLI_FREEMEM 4
195 #define KLI_SYMMON_STK 5
196 #define KLI_PI_ERROR 6
197 #define KLI_KERN_VARS 7
198 #define KLI_KERN_XP 8
199 #define KLI_KERN_PARTID 9
203 #define KLD_BASE(nasid) ((kldir_ent_t *) KLDIR_ADDR(nasid))
204 #define KLD_LAUNCH(nasid) (KLD_BASE(nasid) + KLI_LAUNCH)
205 #define KLD_NMI(nasid) (KLD_BASE(nasid) + KLI_NMI)
206 #define KLD_KLCONFIG(nasid) (KLD_BASE(nasid) + KLI_KLCONFIG)
207 #define KLD_PI_ERROR(nasid) (KLD_BASE(nasid) + KLI_PI_ERROR)
208 #define KLD_GDA(nasid) (KLD_BASE(nasid) + KLI_GDA)
209 #define KLD_SYMMON_STK(nasid) (KLD_BASE(nasid) + KLI_SYMMON_STK)
210 #define KLD_FREEMEM(nasid) (KLD_BASE(nasid) + KLI_FREEMEM)
211 #define KLD_KERN_VARS(nasid) (KLD_BASE(nasid) + KLI_KERN_VARS)
212 #define KLD_KERN_XP(nasid) (KLD_BASE(nasid) + KLI_KERN_XP)
213 #define KLD_KERN_PARTID(nasid) (KLD_BASE(nasid) + KLI_KERN_PARTID)
215 #define KLCONFIG_OFFSET(nasid) ia64_sn_get_klconfig_addr(nasid)
217 #define KLCONFIG_ADDR(nasid) \
218 TO_NODE_CAC((nasid), KLCONFIG_OFFSET(nasid))
219 #define KLCONFIG_SIZE(nasid) KLD_KLCONFIG(nasid)->size
221 #define GDA_ADDR(nasid) KLD_GDA(nasid)->pointer
222 #define GDA_SIZE(nasid) KLD_GDA(nasid)->size
224 #define NODE_OFFSET_TO_K0(_nasid, _off) \
225 (CACHEABLE_MEM_SPACE | NODE_OFFSET(_nasid) | (_off))
227 #endif /* __ASSEMBLY__ */
229 #endif /* _ASM_IA64_SN_ADDRS_H */