Go to the documentation of this file.
9 #ifndef _ASM_SN_ADDRS_H
10 #define _ASM_SN_ADDRS_H
15 #include <linux/types.h>
18 #include <asm/addrspace.h>
21 #if defined(CONFIG_SGI_IP27)
23 #elif defined(CONFIG_SGI_IP35)
24 #include <asm/sn/sn1/addrs.h>
30 #define PS_UINT_CAST (unsigned long)
31 #define UINT64_CAST (unsigned long)
33 #define HUBREG_CAST (volatile hubreg_t *)
44 #define NASID_GET_META(_n) ((_n) >> NASID_LOCAL_BITS)
45 #ifdef CONFIG_SGI_IP27
46 #define NASID_GET_LOCAL(_n) ((_n) & 0xf)
48 #define NASID_MAKE(_m, _l) (((_m) << NASID_LOCAL_BITS) | (_l))
50 #define NODE_ADDRSPACE_MASK (NODE_ADDRSPACE_SIZE - 1)
51 #define TO_NODE_ADDRSPACE(_pa) (UINT64_CAST (_pa) & NODE_ADDRSPACE_MASK)
53 #define CHANGE_ADDR_NASID(_pa, _nasid) \
54 ((UINT64_CAST(_pa) & ~NASID_MASK) | \
55 (UINT64_CAST(_nasid) << NASID_SHFT))
63 #define NODE_OFFSET(_n) (UINT64_CAST (_n) << NODE_SIZE_BITS)
65 #define NODE_CAC_BASE(_n) (CAC_BASE + NODE_OFFSET(_n))
66 #define NODE_HSPEC_BASE(_n) (HSPEC_BASE + NODE_OFFSET(_n))
67 #define NODE_IO_BASE(_n) (IO_BASE + NODE_OFFSET(_n))
68 #define NODE_MSPEC_BASE(_n) (MSPEC_BASE + NODE_OFFSET(_n))
69 #define NODE_UNCAC_BASE(_n) (UNCAC_BASE + NODE_OFFSET(_n))
71 #define TO_NODE(_n, _x) (NODE_OFFSET(_n) | ((_x) ))
72 #define TO_NODE_CAC(_n, _x) (NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
73 #define TO_NODE_UNCAC(_n, _x) (NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
74 #define TO_NODE_MSPEC(_n, _x) (NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
75 #define TO_NODE_HSPEC(_n, _x) (NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
78 #define RAW_NODE_SWIN_BASE(nasid, widget) \
79 (NODE_IO_BASE(nasid) + (UINT64_CAST(widget) << SWIN_SIZE_BITS))
81 #define WIDGETID_GET(addr) ((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))
89 #define SWIN_SIZE_BITS 24
90 #define SWIN_SIZE (UINT64_CAST 1 << 24)
91 #define SWIN_SIZEMASK (SWIN_SIZE - 1)
92 #define SWIN_WIDGET_MASK 0xF
100 #define SWIN_WIDGETADDR(addr) ((addr) & SWIN_SIZEMASK)
101 #define SWIN_WIDGETNUM(addr) (((addr) >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK)
111 #define NODE_SWIN_ADDR(nasid, addr) \
112 (((addr) >= NODE_SWIN_BASE(nasid, 0)) && \
113 ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\
131 #define UALIAS_BASE HSPEC_BASE
132 #define UALIAS_SIZE 0x10000000
133 #define UALIAS_LIMIT (UALIAS_BASE + UALIAS_SIZE)
139 #ifdef CONFIG_SGI_IP27
140 #define UALIAS_FLIP_BASE UALIAS_BASE
141 #define UALIAS_FLIP_SIZE 0x20000
142 #define UALIAS_FLIP_BIT 0x10000
143 #define UALIAS_FLIP_ADDR(_x) (cputoslice(smp_processor_id()) ? \
144 (_x) ^ UALIAS_FLIP_BIT : (_x))
146 #define LBOOT_BASE (HSPEC_BASE + 0x10000000)
147 #define LBOOT_SIZE 0x10000000
148 #define LBOOT_LIMIT (LBOOT_BASE + LBOOT_SIZE)
149 #define LBOOT_STRIDE 0
153 #define HUB_REGISTER_WIDGET 1
154 #define IALIAS_BASE NODE_SWIN_BASE(0, HUB_REGISTER_WIDGET)
155 #define IALIAS_SIZE 0x800000
156 #define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) && \
157 ((_a) < (IALIAS_BASE + IALIAS_SIZE)))
163 #ifdef CONFIG_SGI_IP27
164 #define RBOOT_SIZE 0x10000000
165 #define NODE_RBOOT_BASE(_n) (NODE_HSPEC_BASE(_n) + 0x30000000)
166 #define NODE_RBOOT_LIMIT(_n) (NODE_RBOOT_BASE(_n) + RBOOT_SIZE)
188 #define NODE_BDOOR_BASE(_n) (NODE_HSPEC_BASE(_n) + (NODE_ADDRSPACE_SIZE/2))
190 #define NODE_BDECC_BASE(_n) (NODE_BDOOR_BASE(_n))
191 #define NODE_BDDIR_BASE(_n) (NODE_BDOOR_BASE(_n) + (NODE_ADDRSPACE_SIZE/4))
192 #ifdef CONFIG_SGI_IP27
193 #define BDDIR_ENTRY_LO(_pa) ((HSPEC_BASE + \
194 NODE_ADDRSPACE_SIZE * 3 / 4 + \
196 UINT64_CAST(_pa) & NASID_MASK | \
197 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
198 UINT64_CAST(_pa) >> 3 & 0x1f << 4)
200 #define BDDIR_ENTRY_HI(_pa) ((HSPEC_BASE + \
201 NODE_ADDRSPACE_SIZE * 3 / 4 + \
203 UINT64_CAST(_pa) & NASID_MASK | \
204 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
205 UINT64_CAST(_pa) >> 3 & 0x1f << 4)
207 #define BDPRT_ENTRY(_pa, _rgn) ((HSPEC_BASE + \
208 NODE_ADDRSPACE_SIZE * 3 / 4) | \
209 UINT64_CAST(_pa) & NASID_MASK | \
210 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
212 #define BDPRT_ENTRY_ADDR(_pa, _rgn) (BDPRT_ENTRY((_pa), (_rgn)))
213 #define BDPRT_ENTRY_S(_pa, _rgn, _val) (*(__psunsigned_t *)BDPRT_ENTRY((_pa), (_rgn))=(_val))
214 #define BDPRT_ENTRY_L(_pa, _rgn) (*(__psunsigned_t *)BDPRT_ENTRY((_pa), (_rgn)))
216 #define BDECC_ENTRY(_pa) ((HSPEC_BASE + \
217 NODE_ADDRSPACE_SIZE / 2) | \
218 UINT64_CAST(_pa) & NASID_MASK | \
219 UINT64_CAST(_pa) >> 2 & BDECC_UPPER_MASK | \
220 UINT64_CAST(_pa) >> 3 & 3)
226 #define BDADDR_IS_DIR(_ba) ((UINT64_CAST (_ba) & 0x200) != 0)
227 #define BDADDR_IS_PRT(_ba) ((UINT64_CAST (_ba) & 0x200) == 0)
229 #define BDDIR_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
230 (UINT64_CAST(_ba) & BDDIR_UPPER_MASK)<<2 | \
231 (UINT64_CAST(_ba) & 0x1f << 4) << 3)
233 #define BDPRT_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
234 (UINT64_CAST(_ba) & BDDIR_UPPER_MASK)<<2)
236 #define BDECC_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
237 (UINT64_CAST(_ba) & BDECC_UPPER_MASK)<<2 | \
238 (UINT64_CAST(_ba) & 3) << 3)
259 #define LOCAL_HUB_ADDR(_x) (HUBREG_CAST (IALIAS_BASE + (_x)))
260 #define REMOTE_HUB_ADDR(_n, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \
262 #ifdef CONFIG_SGI_IP27
263 #define REMOTE_HUB_PI_ADDR(_n, _sn, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \
269 #define HUB_L(_a) *(_a)
270 #define HUB_S(_a, _d) *(_a) = (_d)
272 #define LOCAL_HUB_L(_r) HUB_L(LOCAL_HUB_ADDR(_r))
273 #define LOCAL_HUB_S(_r, _d) HUB_S(LOCAL_HUB_ADDR(_r), (_d))
274 #define REMOTE_HUB_L(_n, _r) HUB_L(REMOTE_HUB_ADDR((_n), (_r)))
275 #define REMOTE_HUB_S(_n, _r, _d) HUB_S(REMOTE_HUB_ADDR((_n), (_r)), (_d))
276 #define REMOTE_HUB_PI_L(_n, _sn, _r) HUB_L(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)))
277 #define REMOTE_HUB_PI_S(_n, _sn, _r, _d) HUB_S(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)), (_d))
285 #define HUB_REG_PTR(_base, _off) \
286 (HUBREG_CAST((__psunsigned_t)(_base) + (__psunsigned_t)(_off)))
288 #define HUB_REG_PTR_L(_base, _off) \
289 HUB_L(HUB_REG_PTR((_base), (_off)))
291 #define HUB_REG_PTR_S(_base, _off, _data) \
292 HUB_S(HUB_REG_PTR((_base), (_off)), (_data))
299 #define PHYS_RAMBASE 0x0
300 #define K0_RAMBASE PHYS_TO_K0(PHYS_RAMBASE)
302 #define EX_HANDLER_OFFSET(slice) ((slice) << 16)
303 #define EX_HANDLER_ADDR(nasid, slice) \
304 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_HANDLER_OFFSET(slice))
305 #define EX_HANDLER_SIZE 0x0400
307 #define EX_FRAME_OFFSET(slice) ((slice) << 16 | 0x400)
308 #define EX_FRAME_ADDR(nasid, slice) \
309 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_FRAME_OFFSET(slice))
310 #define EX_FRAME_SIZE 0x0c00
312 #define ARCS_SPB_OFFSET 0x1000
313 #define ARCS_SPB_ADDR(nasid) \
314 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET)
315 #define ARCS_SPB_SIZE 0x0400
317 #define KLDIR_OFFSET 0x2000
318 #define KLDIR_ADDR(nasid) \
319 TO_NODE_UNCAC((nasid), KLDIR_OFFSET)
320 #define KLDIR_SIZE 0x0400
332 #define KLI_KLCONFIG 1
335 #define KLI_FREEMEM 4
336 #define KLI_SYMMON_STK 5
337 #define KLI_PI_ERROR 6
338 #define KLI_KERN_VARS 7
339 #define KLI_KERN_XP 8
340 #define KLI_KERN_PARTID 9
344 #define KLD_BASE(nasid) ((kldir_ent_t *) KLDIR_ADDR(nasid))
345 #define KLD_LAUNCH(nasid) (KLD_BASE(nasid) + KLI_LAUNCH)
346 #define KLD_NMI(nasid) (KLD_BASE(nasid) + KLI_NMI)
347 #define KLD_KLCONFIG(nasid) (KLD_BASE(nasid) + KLI_KLCONFIG)
348 #define KLD_PI_ERROR(nasid) (KLD_BASE(nasid) + KLI_PI_ERROR)
349 #define KLD_GDA(nasid) (KLD_BASE(nasid) + KLI_GDA)
350 #define KLD_SYMMON_STK(nasid) (KLD_BASE(nasid) + KLI_SYMMON_STK)
351 #define KLD_FREEMEM(nasid) (KLD_BASE(nasid) + KLI_FREEMEM)
352 #define KLD_KERN_VARS(nasid) (KLD_BASE(nasid) + KLI_KERN_VARS)
353 #define KLD_KERN_XP(nasid) (KLD_BASE(nasid) + KLI_KERN_XP)
354 #define KLD_KERN_PARTID(nasid) (KLD_BASE(nasid) + KLI_KERN_PARTID)
356 #define LAUNCH_OFFSET(nasid, slice) \
357 (KLD_LAUNCH(nasid)->offset + \
358 KLD_LAUNCH(nasid)->stride * (slice))
359 #define LAUNCH_ADDR(nasid, slice) \
360 TO_NODE_UNCAC((nasid), LAUNCH_OFFSET(nasid, slice))
361 #define LAUNCH_SIZE(nasid) KLD_LAUNCH(nasid)->size
363 #define SN_NMI_OFFSET(nasid, slice) \
364 (KLD_NMI(nasid)->offset + \
365 KLD_NMI(nasid)->stride * (slice))
366 #define NMI_ADDR(nasid, slice) \
367 TO_NODE_UNCAC((nasid), SN_NMI_OFFSET(nasid, slice))
368 #define NMI_SIZE(nasid) KLD_NMI(nasid)->size
370 #define KLCONFIG_OFFSET(nasid) KLD_KLCONFIG(nasid)->offset
371 #define KLCONFIG_ADDR(nasid) \
372 TO_NODE_UNCAC((nasid), KLCONFIG_OFFSET(nasid))
373 #define KLCONFIG_SIZE(nasid) KLD_KLCONFIG(nasid)->size
375 #define GDA_ADDR(nasid) KLD_GDA(nasid)->pointer
376 #define GDA_SIZE(nasid) KLD_GDA(nasid)->size
378 #define SYMMON_STK_OFFSET(nasid, slice) \
379 (KLD_SYMMON_STK(nasid)->offset + \
380 KLD_SYMMON_STK(nasid)->stride * (slice))
381 #define SYMMON_STK_STRIDE(nasid) KLD_SYMMON_STK(nasid)->stride
383 #define SYMMON_STK_ADDR(nasid, slice) \
384 TO_NODE_CAC((nasid), SYMMON_STK_OFFSET(nasid, slice))
386 #define SYMMON_STK_SIZE(nasid) KLD_SYMMON_STK(nasid)->stride
388 #define SYMMON_STK_END(nasid) (SYMMON_STK_ADDR(nasid, 0) + KLD_SYMMON_STK(nasid)->size)
393 #define UNIX_DEBUG_LOADADDR 0x300000
394 #define SYMMON_LOADADDR(nasid) \
395 TO_NODE(nasid, PHYS_TO_K0(UNIX_DEBUG_LOADADDR - 0x1000))
397 #define FREEMEM_OFFSET(nasid) KLD_FREEMEM(nasid)->offset
398 #define FREEMEM_ADDR(nasid) SYMMON_STK_END(nasid)
406 #define FREEMEM_SIZE(nasid) KLD_FREEMEM(nasid)->size
408 #define PI_ERROR_OFFSET(nasid) KLD_PI_ERROR(nasid)->offset
409 #define PI_ERROR_ADDR(nasid) \
410 TO_NODE_UNCAC((nasid), PI_ERROR_OFFSET(nasid))
411 #define PI_ERROR_SIZE(nasid) KLD_PI_ERROR(nasid)->size
413 #define NODE_OFFSET_TO_K0(_nasid, _off) \
414 PHYS_TO_K0((NODE_OFFSET(_nasid) + (_off)) | CAC_BASE)
415 #define NODE_OFFSET_TO_K1(_nasid, _off) \
416 TO_UNCAC((NODE_OFFSET(_nasid) + (_off)) | UNCAC_BASE)
417 #define K0_TO_NODE_OFFSET(_k0addr) \
418 ((__psunsigned_t)(_k0addr) & NODE_ADDRSPACE_MASK)
420 #define KERN_VARS_ADDR(nasid) KLD_KERN_VARS(nasid)->pointer
421 #define KERN_VARS_SIZE(nasid) KLD_KERN_VARS(nasid)->size
423 #define KERN_XP_ADDR(nasid) KLD_KERN_XP(nasid)->pointer
424 #define KERN_XP_SIZE(nasid) KLD_KERN_XP(nasid)->size
426 #define GPDA_ADDR(nasid) TO_NODE_CAC(nasid, GPDA_OFFSET)