📄 addrs.h
字号:
/* $Id$ * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc. * Copyright (C) 1999 by Ralf Baechle */#ifndef _ASM_SN_ADDRS_H#define _ASM_SN_ADDRS_H#include <linux/config.h>#if _LANGUAGE_C#include <linux/types.h>#endif /* _LANGUAGE_C */#if !defined(CONFIG_IA64_SGI_SN1) && !defined(CONFIG_IA64_GENERIC)#include <asm/addrspace.h>#include <asm/reg.h>#include <asm/sn/kldir.h>#endif /* CONFIG_IA64_SGI_SN1 */#if defined(CONFIG_SGI_IP35) || defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)#include <asm/sn/sn1/addrs.h>#endif#if _LANGUAGE_C#define PS_UINT_CAST (__psunsigned_t)#define UINT64_CAST (uint64_t)#define HUBREG_CAST (volatile hubreg_t *)#elif _LANGUAGE_ASSEMBLY#define PS_UINT_CAST#define UINT64_CAST#define HUBREG_CAST#endif#define NASID_GET_META(_n) ((_n) >> NASID_LOCAL_BITS)#if defined CONFIG_SGI_IP35 || defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)#define NASID_GET_LOCAL(_n) ((_n) & 0x7f)#endif#define NASID_MAKE(_m, _l) (((_m) << NASID_LOCAL_BITS) | (_l))#define NODE_ADDRSPACE_MASK (NODE_ADDRSPACE_SIZE - 1)#define TO_NODE_ADDRSPACE(_pa) (UINT64_CAST (_pa) & NODE_ADDRSPACE_MASK)#define CHANGE_ADDR_NASID(_pa, _nasid) \ ((UINT64_CAST (_pa) & ~NASID_MASK) | \ (UINT64_CAST(_nasid) << NASID_SHFT))/* * The following macros are used to index to the beginning of a specific * node's address space. */#define NODE_OFFSET(_n) (UINT64_CAST (_n) << NODE_SIZE_BITS)#define NODE_CAC_BASE(_n) (CAC_BASE + NODE_OFFSET(_n))#define NODE_HSPEC_BASE(_n) (HSPEC_BASE + NODE_OFFSET(_n))#define NODE_IO_BASE(_n) (IO_BASE + NODE_OFFSET(_n))#define NODE_MSPEC_BASE(_n) (MSPEC_BASE + NODE_OFFSET(_n))#define NODE_UNCAC_BASE(_n) (UNCAC_BASE + NODE_OFFSET(_n))#define TO_NODE(_n, _x) (NODE_OFFSET(_n) | ((_x) ))#define TO_NODE_CAC(_n, _x) (NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK))#define TO_NODE_UNCAC(_n, _x) (NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK))#define TO_NODE_MSPEC(_n, _x) (NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))#define TO_NODE_HSPEC(_n, _x) (NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))#define RAW_NODE_SWIN_BASE(nasid, widget) \ (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS))#define WIDGETID_GET(addr) ((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))/* * The following definitions pertain to the IO special address * space. They define the location of the big and little windows * of any given node. */#define SWIN_SIZE_BITS 24#define SWIN_SIZE (UINT64_CAST 1 << 24)#define SWIN_SIZEMASK (SWIN_SIZE - 1)#define SWIN_WIDGET_MASK 0xF/* * Convert smallwindow address to xtalk address. * * 'addr' can be physical or virtual address, but will be converted * to Xtalk address in the range 0 -> SWINZ_SIZEMASK */#define SWIN_WIDGETADDR(addr) ((addr) & SWIN_SIZEMASK)#define SWIN_WIDGETNUM(addr) (((addr) >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK)/* * Verify if addr belongs to small window address on node with "nasid" * * * NOTE: "addr" is expected to be XKPHYS address, and NOT physical * address * * */#define NODE_SWIN_ADDR(nasid, addr) \ (((addr) >= NODE_SWIN_BASE(nasid, 0)) && \ ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\ ))/* * The following define the major position-independent aliases used * in SN. * UALIAS -- 256MB in size, reads in the UALIAS result in * uncached references to the memory of the reader's node. * CPU_UALIAS -- 128kb in size, the bottom part of UALIAS is flipped * depending on which CPU does the access to provide * all CPUs with unique uncached memory at low addresses. * LBOOT -- 256MB in size, reads in the LBOOT area result in * uncached references to the local hub's boot prom and * other directory-bus connected devices. * IALIAS -- 8MB in size, reads in the IALIAS result in uncached * references to the local hub's registers. */#define UALIAS_BASE HSPEC_BASE#define UALIAS_SIZE 0x10000000 /* 256 Megabytes */#define CPU_UALIAS 0x20000 /* 128 Kilobytes */#define UALIAS_CPU_SIZE (CPU_UALIAS / CPUS_PER_NODE)#define UALIAS_LIMIT (UALIAS_BASE + UALIAS_SIZE)/* * The bottom of ualias space is flipped depending on whether you're * processor 0 or 1 within a node. */#if defined(CONFIG_SGI_IP35) || defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)#define LREG_BASE (HSPEC_BASE + 0x10000000)#define LREG_SIZE 0x8000000 /* 128 MB */#define LREG_LIMIT (LREG_BASE + LREG_SIZE)#define LBOOT_BASE (LREG_LIMIT)#define LBOOT_SIZE 0x8000000 /* 128 MB */#define LBOOT_LIMIT (LBOOT_BASE + LBOOT_SIZE)#define LBOOT_STRIDE 0x2000000 /* two PROMs, on 32M boundaries */#endif#define HUB_REGISTER_WIDGET 1#define IALIAS_BASE NODE_SWIN_BASE(0, HUB_REGISTER_WIDGET)#define IALIAS_SIZE 0x800000 /* 8 Megabytes */#define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) && \ ((_a) < (IALIAS_BASE + IALIAS_SIZE)))/* * Macro for referring to Hub's RBOOT space */#if defined(CONFIG_SGI_IP35) || defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)#define NODE_LREG_BASE(_n) (NODE_HSPEC_BASE(_n) + 0x30000000)#define NODE_LREG_LIMIT(_n) (NODE_LREG_BASE(_n) + LREG_SIZE)#define RREG_BASE(_n) (NODE_LREG_BASE(_n))#define RREG_LIMIT(_n) (NODE_LREG_LIMIT(_n))#define RBOOT_SIZE 0x8000000 /* 128 Megabytes */#define NODE_RBOOT_BASE(_n) (NODE_HSPEC_BASE(_n) + 0x38000000)#define NODE_RBOOT_LIMIT(_n) (NODE_RBOOT_BASE(_n) + RBOOT_SIZE)#endif/* * Macros for referring the Hub's back door space * * These macros correctly process addresses in any node's space. * WARNING: They won't work in assembler. * * BDDIR_ENTRY_LO returns the address of the low double-word of the dir * entry corresponding to a physical (Cac or Uncac) address. * BDDIR_ENTRY_HI returns the address of the high double-word of the entry. * BDPRT_ENTRY returns the address of the double-word protection entry * corresponding to the page containing the physical address. * BDPRT_ENTRY_S Stores the value into the protection entry. * BDPRT_ENTRY_L Load the value from the protection entry. * BDECC_ENTRY returns the address of the ECC byte corresponding to a * double-word at a specified physical address. * BDECC_ENTRY_H returns the address of the two ECC bytes corresponding to a * quad-word at a specified physical address. */#define NODE_BDOOR_BASE(_n) (NODE_HSPEC_BASE(_n) + (NODE_ADDRSPACE_SIZE/2))#define NODE_BDECC_BASE(_n) (NODE_BDOOR_BASE(_n))#define NODE_BDDIR_BASE(_n) (NODE_BDOOR_BASE(_n) + (NODE_ADDRSPACE_SIZE/4))#if defined(CONFIG_SGI_IP35) || defined(CONFIG_IA64_SGI_SN1) || defined(CONFIG_IA64_GENERIC)/* * Bedrock's directory entries are a single word: no low/high */#define BDDIR_ENTRY(_pa) (HSPEC_BASE + \ NODE_ADDRSPACE_SIZE * 7 / 8 | \ UINT64_CAST (_pa) & NASID_MASK | \ UINT64_CAST (_pa) >> 3 & BDDIR_UPPER_MASK)#ifdef BRINGUP /* minimize source changes by mapping *_LO() & *_HI() */#define BDDIR_ENTRY_LO(_pa) BDDIR_ENTRY(_pa)#define BDDIR_ENTRY_HI(_pa) BDDIR_ENTRY(_pa)#endif /* BRINGUP */#define BDDIR_PAGE_MASK (BDDIR_UPPER_MASK & 0x7ffff << 11)#define BDDIR_PAGE_BASE_MASK (UINT64_CAST 0xfffffffffffff800)#ifdef _LANGUAGE_C#define BDPRT_ENTRY_ADDR(_pa, _rgn) ((uint64_t *) ( (HSPEC_BASE + \ NODE_ADDRSPACE_SIZE * 7 / 8 + 0x408) | \ (UINT64_CAST (_pa) & NASID_MASK) | \ (UINT64_CAST (_pa) >> 3 & BDDIR_PAGE_MASK) | \ (UINT64_CAST (_pa) >> 3 & 0x3 << 4) | \ ((_rgn) & 0x1e) << 5))static __inline uint64_t BDPRT_ENTRY_L(paddr_t pa,uint32_t rgn) { uint64_t word=*BDPRT_ENTRY_ADDR(pa,rgn); if(rgn&0x20) /*If the region is > 32, move it down*/ word = word >> 32; if(rgn&0x1) /*If the region is odd, get that part */ word = word >> 16; word = word & 0xffff; /*Get the 16 bits we are interested in*/ return word;}static __inline void BDPRT_ENTRY_S(paddr_t pa,uint32_t rgn,uint64_t val) { uint64_t *addr=(uint64_t *)BDPRT_ENTRY_ADDR(pa,rgn); uint64_t word,mask; word=*addr; mask=0; if(rgn&0x1) { mask|=0x0000ffff0000ffff; val=val<<16; } else mask|=0xffff0000ffff0000; if(rgn&0x20) { mask|=0x00000000ffffffff; val=val<<32; } else mask|=0xffffffff00000000; word &= mask; word |= val; *(addr++)=word; addr++; *(addr++)=word; addr++; *(addr++)=word; addr++; *addr=word;}#endif /*_LANGUAGE_C*/#define BDCNT_ENTRY(_pa) (HSPEC_BASE + \ NODE_ADDRSPACE_SIZE * 7 / 8 + 0x8 | \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -