Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.13-rc5 458 lines 16 kB view raw
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) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc. 7 * Copyright (C) 1999, 2000 by Ralf Baechle 8 */ 9#ifndef _ASM_SN_ADDRS_H 10#define _ASM_SN_ADDRS_H 11 12#include <linux/config.h> 13 14#ifndef __ASSEMBLY__ 15#include <linux/types.h> 16#endif /* !__ASSEMBLY__ */ 17 18#include <asm/addrspace.h> 19#include <asm/sn/kldir.h> 20 21#if defined(CONFIG_SGI_IP27) 22#include <asm/sn/sn0/addrs.h> 23#elif defined(CONFIG_SGI_IP35) 24#include <asm/sn/sn1/addrs.h> 25#endif 26 27 28#ifndef __ASSEMBLY__ 29 30#if defined(CONFIG_SGI_IO) /* FIXME */ 31#define PS_UINT_CAST (__psunsigned_t) 32#define UINT64_CAST (__uint64_t) 33#else /* CONFIG_SGI_IO */ 34#define PS_UINT_CAST (unsigned long) 35#define UINT64_CAST (unsigned long) 36#endif /* CONFIG_SGI_IO */ 37 38#define HUBREG_CAST (volatile hubreg_t *) 39 40#else /* __ASSEMBLY__ */ 41 42#define PS_UINT_CAST 43#define UINT64_CAST 44#define HUBREG_CAST 45 46#endif /* __ASSEMBLY__ */ 47 48 49#define NASID_GET_META(_n) ((_n) >> NASID_LOCAL_BITS) 50#ifdef CONFIG_SGI_IP27 51#define NASID_GET_LOCAL(_n) ((_n) & 0xf) 52#endif 53#define NASID_MAKE(_m, _l) (((_m) << NASID_LOCAL_BITS) | (_l)) 54 55#define NODE_ADDRSPACE_MASK (NODE_ADDRSPACE_SIZE - 1) 56#define TO_NODE_ADDRSPACE(_pa) (UINT64_CAST (_pa) & NODE_ADDRSPACE_MASK) 57 58#define CHANGE_ADDR_NASID(_pa, _nasid) \ 59 ((UINT64_CAST (_pa) & ~NASID_MASK) | \ 60 (UINT64_CAST(_nasid) << NASID_SHFT)) 61 62 63/* 64 * The following macros are used to index to the beginning of a specific 65 * node's address space. 66 */ 67 68#define NODE_OFFSET(_n) (UINT64_CAST (_n) << NODE_SIZE_BITS) 69 70#define NODE_CAC_BASE(_n) (CAC_BASE + NODE_OFFSET(_n)) 71#define NODE_HSPEC_BASE(_n) (HSPEC_BASE + NODE_OFFSET(_n)) 72#define NODE_IO_BASE(_n) (IO_BASE + NODE_OFFSET(_n)) 73#define NODE_MSPEC_BASE(_n) (MSPEC_BASE + NODE_OFFSET(_n)) 74#define NODE_UNCAC_BASE(_n) (UNCAC_BASE + NODE_OFFSET(_n)) 75 76#define TO_NODE(_n, _x) (NODE_OFFSET(_n) | ((_x) )) 77#define TO_NODE_CAC(_n, _x) (NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK)) 78#define TO_NODE_UNCAC(_n, _x) (NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK)) 79#define TO_NODE_MSPEC(_n, _x) (NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK)) 80#define TO_NODE_HSPEC(_n, _x) (NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK)) 81 82 83#define RAW_NODE_SWIN_BASE(nasid, widget) \ 84 (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS)) 85 86#define WIDGETID_GET(addr) ((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff)) 87 88/* 89 * The following definitions pertain to the IO special address 90 * space. They define the location of the big and little windows 91 * of any given node. 92 */ 93 94#define SWIN_SIZE_BITS 24 95#define SWIN_SIZE (UINT64_CAST 1 << 24) 96#define SWIN_SIZEMASK (SWIN_SIZE - 1) 97#define SWIN_WIDGET_MASK 0xF 98 99/* 100 * Convert smallwindow address to xtalk address. 101 * 102 * 'addr' can be physical or virtual address, but will be converted 103 * to Xtalk address in the range 0 -> SWINZ_SIZEMASK 104 */ 105#define SWIN_WIDGETADDR(addr) ((addr) & SWIN_SIZEMASK) 106#define SWIN_WIDGETNUM(addr) (((addr) >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK) 107/* 108 * Verify if addr belongs to small window address on node with "nasid" 109 * 110 * 111 * NOTE: "addr" is expected to be XKPHYS address, and NOT physical 112 * address 113 * 114 * 115 */ 116#define NODE_SWIN_ADDR(nasid, addr) \ 117 (((addr) >= NODE_SWIN_BASE(nasid, 0)) && \ 118 ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\ 119 )) 120 121/* 122 * The following define the major position-independent aliases used 123 * in SN. 124 * UALIAS -- 256MB in size, reads in the UALIAS result in 125 * uncached references to the memory of the reader's node. 126 * CPU_UALIAS -- 128kb in size, the bottom part of UALIAS is flipped 127 * depending on which CPU does the access to provide 128 * all CPUs with unique uncached memory at low addresses. 129 * LBOOT -- 256MB in size, reads in the LBOOT area result in 130 * uncached references to the local hub's boot prom and 131 * other directory-bus connected devices. 132 * IALIAS -- 8MB in size, reads in the IALIAS result in uncached 133 * references to the local hub's registers. 134 */ 135 136#define UALIAS_BASE HSPEC_BASE 137#define UALIAS_SIZE 0x10000000 /* 256 Megabytes */ 138#define UALIAS_LIMIT (UALIAS_BASE + UALIAS_SIZE) 139 140/* 141 * The bottom of ualias space is flipped depending on whether you're 142 * processor 0 or 1 within a node. 143 */ 144#ifdef CONFIG_SGI_IP27 145#define UALIAS_FLIP_BASE UALIAS_BASE 146#define UALIAS_FLIP_SIZE 0x20000 147#define UALIAS_FLIP_BIT 0x10000 148#define UALIAS_FLIP_ADDR(_x) (cputoslice(smp_processor_id()) ? \ 149 (_x) ^ UALIAS_FLIP_BIT : (_x)) 150 151#define LBOOT_BASE (HSPEC_BASE + 0x10000000) 152#define LBOOT_SIZE 0x10000000 153#define LBOOT_LIMIT (LBOOT_BASE + LBOOT_SIZE) 154#define LBOOT_STRIDE 0 /* IP27 has only one CPU PROM */ 155 156#endif 157 158#define HUB_REGISTER_WIDGET 1 159#define IALIAS_BASE NODE_SWIN_BASE(0, HUB_REGISTER_WIDGET) 160#define IALIAS_SIZE 0x800000 /* 8 Megabytes */ 161#define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) && \ 162 ((_a) < (IALIAS_BASE + IALIAS_SIZE))) 163 164/* 165 * Macro for referring to Hub's RBOOT space 166 */ 167 168#ifdef CONFIG_SGI_IP27 169#define RBOOT_SIZE 0x10000000 /* 256 Megabytes */ 170#define NODE_RBOOT_BASE(_n) (NODE_HSPEC_BASE(_n) + 0x30000000) 171#define NODE_RBOOT_LIMIT(_n) (NODE_RBOOT_BASE(_n) + RBOOT_SIZE) 172 173#endif 174 175/* 176 * Macros for referring the Hub's back door space 177 * 178 * These macros correctly process addresses in any node's space. 179 * WARNING: They won't work in assembler. 180 * 181 * BDDIR_ENTRY_LO returns the address of the low double-word of the dir 182 * entry corresponding to a physical (Cac or Uncac) address. 183 * BDDIR_ENTRY_HI returns the address of the high double-word of the entry. 184 * BDPRT_ENTRY returns the address of the double-word protection entry 185 * corresponding to the page containing the physical address. 186 * BDPRT_ENTRY_S Stores the value into the protection entry. 187 * BDPRT_ENTRY_L Load the value from the protection entry. 188 * BDECC_ENTRY returns the address of the ECC byte corresponding to a 189 * double-word at a specified physical address. 190 * BDECC_ENTRY_H returns the address of the two ECC bytes corresponding to a 191 * quad-word at a specified physical address. 192 */ 193#define NODE_BDOOR_BASE(_n) (NODE_HSPEC_BASE(_n) + (NODE_ADDRSPACE_SIZE/2)) 194 195#define NODE_BDECC_BASE(_n) (NODE_BDOOR_BASE(_n)) 196#define NODE_BDDIR_BASE(_n) (NODE_BDOOR_BASE(_n) + (NODE_ADDRSPACE_SIZE/4)) 197#ifdef CONFIG_SGI_IP27 198#define BDDIR_ENTRY_LO(_pa) ((HSPEC_BASE + \ 199 NODE_ADDRSPACE_SIZE * 3 / 4 + \ 200 0x200) | \ 201 UINT64_CAST (_pa) & NASID_MASK | \ 202 UINT64_CAST (_pa) >> 2 & BDDIR_UPPER_MASK | \ 203 UINT64_CAST (_pa) >> 3 & 0x1f << 4) 204 205#define BDDIR_ENTRY_HI(_pa) ((HSPEC_BASE + \ 206 NODE_ADDRSPACE_SIZE * 3 / 4 + \ 207 0x208) | \ 208 UINT64_CAST (_pa) & NASID_MASK | \ 209 UINT64_CAST (_pa) >> 2 & BDDIR_UPPER_MASK | \ 210 UINT64_CAST (_pa) >> 3 & 0x1f << 4) 211 212#define BDPRT_ENTRY(_pa, _rgn) ((HSPEC_BASE + \ 213 NODE_ADDRSPACE_SIZE * 3 / 4) | \ 214 UINT64_CAST (_pa) & NASID_MASK | \ 215 UINT64_CAST (_pa) >> 2 & BDDIR_UPPER_MASK | \ 216 (_rgn) << 3) 217#define BDPRT_ENTRY_ADDR(_pa,_rgn) (BDPRT_ENTRY((_pa),(_rgn))) 218#define BDPRT_ENTRY_S(_pa,_rgn,_val) (*(__psunsigned_t *)BDPRT_ENTRY((_pa),(_rgn))=(_val)) 219#define BDPRT_ENTRY_L(_pa,_rgn) (*(__psunsigned_t *)BDPRT_ENTRY((_pa),(_rgn))) 220 221#define BDECC_ENTRY(_pa) ((HSPEC_BASE + \ 222 NODE_ADDRSPACE_SIZE / 2) | \ 223 UINT64_CAST (_pa) & NASID_MASK | \ 224 UINT64_CAST (_pa) >> 2 & BDECC_UPPER_MASK | \ 225 UINT64_CAST (_pa) >> 3 & 3) 226 227/* 228 * Macro to convert a back door directory or protection address into the 229 * raw physical address of the associated cache line or protection page. 230 */ 231#define BDADDR_IS_DIR(_ba) ((UINT64_CAST (_ba) & 0x200) != 0) 232#define BDADDR_IS_PRT(_ba) ((UINT64_CAST (_ba) & 0x200) == 0) 233 234#define BDDIR_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \ 235 (UINT64_CAST (_ba) & BDDIR_UPPER_MASK)<<2 | \ 236 (UINT64_CAST (_ba) & 0x1f << 4) << 3) 237 238#define BDPRT_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \ 239 (UINT64_CAST (_ba) & BDDIR_UPPER_MASK)<<2) 240 241#define BDECC_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \ 242 (UINT64_CAST (_ba) & BDECC_UPPER_MASK)<<2 | \ 243 (UINT64_CAST (_ba) & 3) << 3) 244#endif /* CONFIG_SGI_IP27 */ 245 246 247/* 248 * The following macros produce the correct base virtual address for 249 * the hub registers. The LOCAL_HUB_* macros produce the appropriate 250 * address for the local registers. The REMOTE_HUB_* macro produce 251 * the address for the specified hub's registers. The intent is 252 * that the appropriate PI, MD, NI, or II register would be substituted 253 * for _x. 254 */ 255 256#ifdef _STANDALONE 257 258/* DO NOT USE THESE DIRECTLY IN THE KERNEL. SEE BELOW. */ 259#define LOCAL_HUB(_x) (HUBREG_CAST (IALIAS_BASE + (_x))) 260#define REMOTE_HUB(_n, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \ 261 0x800000 + (_x))) 262#endif /* _STANDALONE */ 263 264/* 265 * WARNING: 266 * When certain Hub chip workaround are defined, it's not sufficient 267 * to dereference the *_HUB_ADDR() macros. You should instead use 268 * HUB_L() and HUB_S() if you must deal with pointers to hub registers. 269 * Otherwise, the recommended approach is to use *_HUB_L() and *_HUB_S(). 270 * They're always safe. 271 */ 272#define LOCAL_HUB_ADDR(_x) (HUBREG_CAST (IALIAS_BASE + (_x))) 273#define REMOTE_HUB_ADDR(_n, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \ 274 0x800000 + (_x))) 275#ifdef CONFIG_SGI_IP27 276#define REMOTE_HUB_PI_ADDR(_n, _sn, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \ 277 0x800000 + (_x))) 278#endif /* CONFIG_SGI_IP27 */ 279 280#ifndef __ASSEMBLY__ 281 282#define HUB_L(_a) *(_a) 283#define HUB_S(_a, _d) *(_a) = (_d) 284 285#define LOCAL_HUB_L(_r) HUB_L(LOCAL_HUB_ADDR(_r)) 286#define LOCAL_HUB_S(_r, _d) HUB_S(LOCAL_HUB_ADDR(_r), (_d)) 287#define REMOTE_HUB_L(_n, _r) HUB_L(REMOTE_HUB_ADDR((_n), (_r))) 288#define REMOTE_HUB_S(_n, _r, _d) HUB_S(REMOTE_HUB_ADDR((_n), (_r)), (_d)) 289#define REMOTE_HUB_PI_L(_n, _sn, _r) HUB_L(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r))) 290#define REMOTE_HUB_PI_S(_n, _sn, _r, _d) HUB_S(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)), (_d)) 291 292#endif /* !__ASSEMBLY__ */ 293 294/* 295 * The following macros are used to get to a hub/bridge register, given 296 * the base of the register space. 297 */ 298#define HUB_REG_PTR(_base, _off) \ 299 (HUBREG_CAST ((__psunsigned_t)(_base) + (__psunsigned_t)(_off))) 300 301#define HUB_REG_PTR_L(_base, _off) \ 302 HUB_L(HUB_REG_PTR((_base), (_off))) 303 304#define HUB_REG_PTR_S(_base, _off, _data) \ 305 HUB_S(HUB_REG_PTR((_base), (_off)), (_data)) 306 307/* 308 * Software structure locations -- permanently fixed 309 * See diagram in kldir.h 310 */ 311 312#define PHYS_RAMBASE 0x0 313#define K0_RAMBASE PHYS_TO_K0(PHYS_RAMBASE) 314 315#define EX_HANDLER_OFFSET(slice) ((slice) << 16) 316#define EX_HANDLER_ADDR(nasid, slice) \ 317 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_HANDLER_OFFSET(slice)) 318#define EX_HANDLER_SIZE 0x0400 319 320#define EX_FRAME_OFFSET(slice) ((slice) << 16 | 0x400) 321#define EX_FRAME_ADDR(nasid, slice) \ 322 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_FRAME_OFFSET(slice)) 323#define EX_FRAME_SIZE 0x0c00 324 325#define ARCS_SPB_OFFSET 0x1000 326#define ARCS_SPB_ADDR(nasid) \ 327 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET) 328#define ARCS_SPB_SIZE 0x0400 329 330#ifdef _STANDALONE 331 332#define ARCS_TVECTOR_OFFSET 0x2800 333#define ARCS_PVECTOR_OFFSET 0x2c00 334 335/* 336 * These addresses are used by the master CPU to install the transfer 337 * and private vectors. All others use the SPB to find them. 338 */ 339#define TVADDR (NODE_CAC_BASE(get_nasid()) + ARCS_TVECTOR_OFFSET) 340#define PVADDR (NODE_CAC_BASE(get_nasid()) + ARCS_PVECTOR_OFFSET) 341 342#endif /* _STANDALONE */ 343 344#define KLDIR_OFFSET 0x2000 345#define KLDIR_ADDR(nasid) \ 346 TO_NODE_UNCAC((nasid), KLDIR_OFFSET) 347#define KLDIR_SIZE 0x0400 348 349 350/* 351 * Software structure locations -- indirected through KLDIR 352 * See diagram in kldir.h 353 * 354 * Important: All low memory structures must only be accessed 355 * uncached, except for the symmon stacks. 356 */ 357 358#define KLI_LAUNCH 0 /* Dir. entries */ 359#define KLI_KLCONFIG 1 360#define KLI_NMI 2 361#define KLI_GDA 3 362#define KLI_FREEMEM 4 363#define KLI_SYMMON_STK 5 364#define KLI_PI_ERROR 6 365#define KLI_KERN_VARS 7 366#define KLI_KERN_XP 8 367#define KLI_KERN_PARTID 9 368 369#ifndef __ASSEMBLY__ 370 371#define KLD_BASE(nasid) ((kldir_ent_t *) KLDIR_ADDR(nasid)) 372#define KLD_LAUNCH(nasid) (KLD_BASE(nasid) + KLI_LAUNCH) 373#define KLD_NMI(nasid) (KLD_BASE(nasid) + KLI_NMI) 374#define KLD_KLCONFIG(nasid) (KLD_BASE(nasid) + KLI_KLCONFIG) 375#define KLD_PI_ERROR(nasid) (KLD_BASE(nasid) + KLI_PI_ERROR) 376#define KLD_GDA(nasid) (KLD_BASE(nasid) + KLI_GDA) 377#define KLD_SYMMON_STK(nasid) (KLD_BASE(nasid) + KLI_SYMMON_STK) 378#define KLD_FREEMEM(nasid) (KLD_BASE(nasid) + KLI_FREEMEM) 379#define KLD_KERN_VARS(nasid) (KLD_BASE(nasid) + KLI_KERN_VARS) 380#define KLD_KERN_XP(nasid) (KLD_BASE(nasid) + KLI_KERN_XP) 381#define KLD_KERN_PARTID(nasid) (KLD_BASE(nasid) + KLI_KERN_PARTID) 382 383#define LAUNCH_OFFSET(nasid, slice) \ 384 (KLD_LAUNCH(nasid)->offset + \ 385 KLD_LAUNCH(nasid)->stride * (slice)) 386#define LAUNCH_ADDR(nasid, slice) \ 387 TO_NODE_UNCAC((nasid), LAUNCH_OFFSET(nasid, slice)) 388#define LAUNCH_SIZE(nasid) KLD_LAUNCH(nasid)->size 389 390#define NMI_OFFSET(nasid, slice) \ 391 (KLD_NMI(nasid)->offset + \ 392 KLD_NMI(nasid)->stride * (slice)) 393#define NMI_ADDR(nasid, slice) \ 394 TO_NODE_UNCAC((nasid), NMI_OFFSET(nasid, slice)) 395#define NMI_SIZE(nasid) KLD_NMI(nasid)->size 396 397#define KLCONFIG_OFFSET(nasid) KLD_KLCONFIG(nasid)->offset 398#define KLCONFIG_ADDR(nasid) \ 399 TO_NODE_UNCAC((nasid), KLCONFIG_OFFSET(nasid)) 400#define KLCONFIG_SIZE(nasid) KLD_KLCONFIG(nasid)->size 401 402#define GDA_ADDR(nasid) KLD_GDA(nasid)->pointer 403#define GDA_SIZE(nasid) KLD_GDA(nasid)->size 404 405#define SYMMON_STK_OFFSET(nasid, slice) \ 406 (KLD_SYMMON_STK(nasid)->offset + \ 407 KLD_SYMMON_STK(nasid)->stride * (slice)) 408#define SYMMON_STK_STRIDE(nasid) KLD_SYMMON_STK(nasid)->stride 409 410#define SYMMON_STK_ADDR(nasid, slice) \ 411 TO_NODE_CAC((nasid), SYMMON_STK_OFFSET(nasid, slice)) 412 413#define SYMMON_STK_SIZE(nasid) KLD_SYMMON_STK(nasid)->stride 414 415#define SYMMON_STK_END(nasid) (SYMMON_STK_ADDR(nasid, 0) + KLD_SYMMON_STK(nasid)->size) 416 417/* loading symmon 4k below UNIX. the arcs loader needs the topaddr for a 418 * relocatable program 419 */ 420#define UNIX_DEBUG_LOADADDR 0x300000 421#define SYMMON_LOADADDR(nasid) \ 422 TO_NODE(nasid, PHYS_TO_K0(UNIX_DEBUG_LOADADDR - 0x1000)) 423 424#define FREEMEM_OFFSET(nasid) KLD_FREEMEM(nasid)->offset 425#define FREEMEM_ADDR(nasid) SYMMON_STK_END(nasid) 426/* 427 * XXX 428 * Fix this. FREEMEM_ADDR should be aware of if symmon is loaded. 429 * Also, it should take into account what prom thinks to be a safe 430 * address 431 PHYS_TO_K0(NODE_OFFSET(nasid) + FREEMEM_OFFSET(nasid)) 432 */ 433#define FREEMEM_SIZE(nasid) KLD_FREEMEM(nasid)->size 434 435#define PI_ERROR_OFFSET(nasid) KLD_PI_ERROR(nasid)->offset 436#define PI_ERROR_ADDR(nasid) \ 437 TO_NODE_UNCAC((nasid), PI_ERROR_OFFSET(nasid)) 438#define PI_ERROR_SIZE(nasid) KLD_PI_ERROR(nasid)->size 439 440#define NODE_OFFSET_TO_K0(_nasid, _off) \ 441 PHYS_TO_K0((NODE_OFFSET(_nasid) + (_off)) | CAC_BASE) 442#define NODE_OFFSET_TO_K1(_nasid, _off) \ 443 TO_UNCAC((NODE_OFFSET(_nasid) + (_off)) | UNCAC_BASE) 444#define K0_TO_NODE_OFFSET(_k0addr) \ 445 ((__psunsigned_t)(_k0addr) & NODE_ADDRSPACE_MASK) 446 447#define KERN_VARS_ADDR(nasid) KLD_KERN_VARS(nasid)->pointer 448#define KERN_VARS_SIZE(nasid) KLD_KERN_VARS(nasid)->size 449 450#define KERN_XP_ADDR(nasid) KLD_KERN_XP(nasid)->pointer 451#define KERN_XP_SIZE(nasid) KLD_KERN_XP(nasid)->size 452 453#define GPDA_ADDR(nasid) TO_NODE_CAC(nasid, GPDA_OFFSET) 454 455#endif /* !__ASSEMBLY__ */ 456 457 458#endif /* _ASM_SN_ADDRS_H */