Home | History | Annotate | Line # | Download | only in include
ctlreg.h revision 1.3
      1 /*	$NetBSD: ctlreg.h,v 1.3 1998/09/05 23:57:26 eeh Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1996
      5  *	The President and Fellows of Harvard College. All rights reserved.
      6  * Copyright (c) 1992, 1993
      7  *	The Regents of the University of California.  All rights reserved.
      8  *
      9  * This software was developed by the Computer Systems Engineering group
     10  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     11  * contributed to Berkeley.
     12  *
     13  * All advertising materials mentioning features or use of this software
     14  * must display the following acknowledgement:
     15  *	This product includes software developed by Harvard University.
     16  *	This product includes software developed by the University of
     17  *	California, Lawrence Berkeley Laboratory.
     18  *
     19  * Redistribution and use in source and binary forms, with or without
     20  * modification, are permitted provided that the following conditions
     21  * are met:
     22  * 1. Redistributions of source code must retain the above copyright
     23  *    notice, this list of conditions and the following disclaimer.
     24  * 2. Redistributions in binary form must reproduce the above copyright
     25  *    notice, this list of conditions and the following disclaimer in the
     26  *    documentation and/or other materials provided with the distribution.
     27  * 3. All advertising materials mentioning features or use of this software
     28  *    must display the following acknowledgement:
     29  *	This product includes software developed by the University of
     30  *	California, Berkeley and its contributors.
     31  * 4. Neither the name of the University nor the names of its contributors
     32  *    may be used to endorse or promote products derived from this software
     33  *    without specific prior written permission.
     34  *
     35  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     36  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     37  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     38  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     39  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     40  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     41  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     42  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     43  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     44  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     45  * SUCH DAMAGE.
     46  *
     47  *	@(#)ctlreg.h	8.1 (Berkeley) 6/11/93
     48  */
     49 
     50 /*
     51  * Sun4u support by Eduardo Horvath
     52  * Changes Copyright (c) 1996 Eduardo Horvath
     53  * All rights reserved.
     54  */
     55 
     56 /*
     57  * Sun 4u control registers. (includes address space definitions
     58  * and some registers in control space).
     59  */
     60 
     61 /*
     62  * The Alternate address spaces.
     63  *
     64  * 0x00-0x7f are privileged
     65  * 0x80-0xff can be used by users
     66  */
     67 
     68 #define ASI_LITTLE	0x08		/* This bit should make an ASI little endian */
     69 
     70 #define ASI_NUCLEUS			0x04	/* [4u] kernel address space */
     71 #define ASI_NUCLEUS_LITTLE		0x0c	/* [4u] kernel address space, little endian */
     72 
     73 #define ASI_AS_IF_USER_PRIMARY		0x10	/* [4u] primary user address space */
     74 #define ASI_AS_IF_USER_SECONDARY	0x11	/* [4u] secondary user address space */
     75 
     76 #define ASI_PHYS_CACHED			0x14	/* [4u] MMU bypass to main memory */
     77 #define ASI_PHYS_NON_CACHED		0x15	/* [4u] MMU bypass to I/O location */
     78 
     79 #define ASI_AS_IF_USER_PRIMARY_LITTLE	0x18	/* [4u] primary user address space, little endian  */
     80 #define ASI_AS_IF_USER_SECONDARY_LITTIE	0x19	/* [4u] secondary user address space, little endian  */
     81 
     82 #define ASI_PHYS_CACHED_LITTLE		0x1c	/* [4u] MMU bypass to main memory, little endian */
     83 #define ASI_PHYS_NON_CACHED_LITTLE	0x1d	/* [4u] MMU bypass to I/O location, little endian */
     84 
     85 #define ASI_NUCLEUS_QUAD_LDD		0x24	/* [4u] use w/LDDA to load 128-bit item */
     86 #define ASI_NUCLEUS_QUAD_LDD_LITTLE	0x2c	/* [4u] use w/LDDA to load 128-bit item, little endian */
     87 
     88 #define ASI_FLUSH_D_PAGE_PRIMARY	0x38	/* [4u] flush D-cache page using primary context */
     89 #define ASI_FLUSH_D_PAGE_SECONDARY	0x39	/* [4u] flush D-cache page using secondary context */
     90 #define ASI_FLUSH_D_CTX_PRIMARY		0x3a	/* [4u] flush D-cache context using primary context */
     91 #define ASI_FLUSH_D_CTX_SECONDARY	0x3b	/* [4u] flush D-cache context using secondary context */
     92 #define ASI_DCACHE_DATA			0x46	/* [4u] diagnostic access to D-cache data RAM */
     93 #define ASI_DCACHE_TAG			0x47	/* [4u] diagnostic access to D-cache tag RAM */
     94 
     95 #define ASI_INTR_DISPATCH_STATUS	0x48	/* [4u] interrupt dispatch status register */
     96 #define ASI_INTR_RECEIVE		0x49	/* [4u] interrupt receive status register */
     97 #define ASI_MID_REG			0x4a	/* [4u] hardware config and MID */
     98 #define ASI_ERROR_EN_REG		0x4b	/* [4u] asynchronous error enables */
     99 #define ASI_AFSR			0x4c	/* [4u] asynchronous fault status register */
    100 #define ASI_AFAR			0x4d	/* [4u] asynchronous fault address register */
    101 
    102 #define ASI_ICACHE_DATA			0x66	/* [4u] diagnostic access to D-cache data RAM */
    103 #define ASI_ICACHE_TAG			0x67	/* [4u] diagnostic access to D-cache tag RAM */
    104 #define ASI_FLUSH_I_PAGE_PRIMARY	0x68	/* [4u] flush D-cache page using primary context */
    105 #define ASI_FLUSH_I_PAGE_SECONDARY	0x69	/* [4u] flush D-cache page using secondary context */
    106 #define ASI_FLUSH_I_CTX_PRIMARY		0x6a	/* [4u] flush D-cache context using primary context */
    107 #define ASI_FLUSH_I_CTX_SECONDARY	0x6b	/* [4u] flush D-cache context using secondary context */
    108 
    109 #define ASI_BLOCK_AS_IF_USER_PRIMARY	0x70	/* [4u] primary user address space, block loads/stores */
    110 #define ASI_BLOCK_AS_IF_USER_SECONDARY	0x71	/* [4u] secondary user address space, block loads/stores */
    111 
    112 #define ASI_ECACHE_DIAG			0x76	/* [4u] diag access to E-cache tag and data */
    113 #define ASI_DATAPATH_ERR_REG_WRITE	0x77	/* [4u] ASI is reused */
    114 
    115 #define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE	0x78	/* [4u] primary user address space, block loads/stores */
    116 #define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE	0x79	/* [4u] secondary user address space, block loads/stores */
    117 
    118 #define ASI_INTERRUPT_RECEIVE_DATA	0x7f	/* [4u] interrupt receive data registers {0,1,2} */
    119 #define ASI_DATAPATH_ERR_REG_READ	0x7f	/* [4u] read access to datapath error registers (ASI reused) */
    120 
    121 #define ASI_PRIMARY			0x80	/* [4u] primary address space */
    122 #define ASI_SECONDARY			0x81	/* [4u] secondary address space */
    123 #define ASI_PRIMARY_NO_FAULT		0x82	/* [4u] primary address space, no fault */
    124 #define ASI_SECONDARY_NO_FAULT		0x83	/* [4u] secondary address space, no fault */
    125 
    126 #define ASI_PRIMARY_LITTLE		0x88	/* [4u] primary address space, little endian */
    127 #define ASI_SECONDARY_LITTLE		0x89	/* [4u] secondary address space, little endian */
    128 #define ASI_PRIMARY_NO_FAULT_LITTLE	0x8a	/* [4u] primary address space, no fault, little endian */
    129 #define ASI_SECONDARY_NO_FAULT_LITTLE	0x8b	/* [4u] secondary address space, no fault, little endian */
    130 
    131 #define ASI_PST8_PRIMARY		0xc0	/* [VIS] Eight 8-bit partial store, primary */
    132 #define ASI_PST8_SECONDARY		0xc1	/* [VIS] Eight 8-bit partial store, secondary */
    133 #define ASI_PST16_PRIMARY		0xc2	/* [VIS] Four 16-bit partial store, primary */
    134 #define ASI_PST16_SECONDARY		0xc3	/* [VIS] Fout 16-bit partial store, secondary */
    135 #define ASI_PST32_PRIMARY		0xc4	/* [VIS] Two 32-bit partial store, primary */
    136 #define ASI_PST32_SECONDARY		0xc5	/* [VIS] Two 32-bit partial store, secondary */
    137 
    138 #define ASI_PST8_PRIMARY_LITTLE		0xc8	/* [VIS] Eight 8-bit partial store, primary, little endian */
    139 #define ASI_PST8_SECONDARY_LITTLE	0xc9	/* [VIS] Eight 8-bit partial store, secondary, little endian */
    140 #define ASI_PST16_PRIMARY_LITTLE	0xca	/* [VIS] Four 16-bit partial store, primary, little endian */
    141 #define ASI_PST16_SECONDARY_LITTLE	0xcb	/* [VIS] Fout 16-bit partial store, secondary, little endian */
    142 #define ASI_PST32_PRIMARY_LITTLE	0xcc	/* [VIS] Two 32-bit partial store, primary, little endian */
    143 #define ASI_PST32_SECONDARY_LITTLE	0xcd	/* [VIS] Two 32-bit partial store, secondary, little endian */
    144 
    145 #define ASI_FL8_PRIMARY			0xd0	/* [VIS] One 8-bit load/store floating, primary */
    146 #define ASI_FL8_SECONDARY		0xd1	/* [VIS] One 8-bit load/store floating, secondary */
    147 #define ASI_FL16_PRIMARY		0xd2	/* [VIS] One 16-bit load/store floating, primary */
    148 #define ASI_FL16_SECONDARY		0xd3	/* [VIS] One 16-bit load/store floating, secondary */
    149 
    150 #define ASI_FL8_PRIMARY_LITTLE		0xd8	/* [VIS] One 8-bit load/store floating, primary, little endian */
    151 #define ASI_FL8_SECONDARY_LITTLE	0xd9	/* [VIS] One 8-bit load/store floating, secondary, little endian */
    152 #define ASI_FL16_PRIMARY_LITTLE		0xda	/* [VIS] One 16-bit load/store floating, primary, little endian */
    153 #define ASI_FL16_SECONDARY_LITTLE	0xdb	/* [VIS] One 16-bit load/store floating, secondary, little endian */
    154 
    155 #define ASI_BLOCK_COMMIT_PRIMARY	0xe0	/* [4u] block store with commit, primary */
    156 #define ASI_BLOCK_COMMIT_SECONDARY	0xe1	/* [4u] block store with commit, secondary */
    157 #define ASI_BLOCK_PRIMARY		0xf0	/* [4u] block load/store, primary */
    158 #define ASI_BLOCK_SECONDARY		0xf1	/* [4u] block load/store, secondary */
    159 #define ASI_BLOCK_PRIMARY_LITTLE	0xf8	/* [4u] block load/store, primary, little endian */
    160 #define ASI_BLOCK_SECONDARY_LITTLE	0xf9	/* [4u] block load/store, secondary, little endian */
    161 
    162 
    163 /*
    164  * These are the shorter names used by Solaris
    165  */
    166 
    167 #define ASI_N		ASI_NUCLEUS
    168 #define ASI_NL		ASI_NUCLEUS_LITTLE
    169 #define ASI_AIUP	ASI_AS_IF_USER_PRIMARY
    170 #define ASI_AIUS	ASI_AS_IF_USER_SECONDARY
    171 #define ASI_AIUPL	ASI_AS_IF_USER_PRIMARY_LITTLE
    172 #define ASI_AIUSL	ASI_AS_IF_USER_SECONDARY_LITTLE
    173 #define ASI_P		ASI_PRIMARY
    174 #define ASI_S		ASI_SECONDARY
    175 #define ASI_PNF		ASI_PRIMARY_NO_FAULT
    176 #define ASI_SNF		ASI_SECONDARY_NO_FAULT
    177 #define ASI_PL		ASI_PRIMARY_LITTLE
    178 #define ASI_SL		ASI_SECONDARY_LITTLE
    179 #define ASI_PNFL	ASI_PRIMARY_NO_FAULT_LITTLE
    180 #define ASI_SNFL	ASI_SECONDARY_NO_FAULT_LITTLE
    181 #define ASI_BLK_AIUP	ASI_BLOCK_AS_IF_USER_PRIMARY
    182 #define ASI_BLK_AIUPL	ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE
    183 #define ASI_BLK_AIUS	ASI_BLOCK_AS_IF_USER_SECONDARY
    184 #define ASI_BLK_AIUSL	ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE
    185 #define ASI_BLK_COMMIT_P		ASI_BLOCK_COMMIT_PRIMARY
    186 #define ASI_BLK_COMMIT_PRIMARY		ASI_BLOCK_COMMIT_PRIMARY
    187 #define ASI_BLK_COMMIT_S		ASI_BLOCK_COMMIT_SECONDARY
    188 #define ASI_BLK_COMMIT_SECONDARY	ASI_BLOCK_COMMIT_SECONDARY
    189 #define ASI_BLK_P			ASI_BLOCK_PRIMARY
    190 #define ASI_BLK_PL			ASI_BLOCK_PRIMARY_LITTLE
    191 #define ASI_BLK_S			ASI_BLOCK_SECONDARY
    192 #define ASI_BLK_SL			ASI_BLOCK_SECONDARY_LITTLE
    193 
    194 /*
    195  * The following are 4u control registers
    196  */
    197 
    198 /*
    199  * [4u] MMU and Cache Control Register (MCCR)
    200  * use ASI = 0x45
    201  */
    202 #define ASI_MCCR	0x45
    203 #define MCCR		0x00
    204 
    205 /* MCCR Bits and their meanings */
    206 #define MCCR_DMMU_EN	0x08
    207 #define MCCR_IMMU_EN	0x04
    208 #define MCCR_DCACHE_EN	0x02
    209 #define MCCR_ICACHE_EN	0x01
    210 
    211 
    212 /*
    213  * MMU control registers
    214  */
    215 
    216 /* Choose an MMU */
    217 #define ASI_DMMU		0x58
    218 #define ASI_IMMU		0x50
    219 
    220 /* Other assorted MMU ASIs */
    221 #define ASI_IMMU_8KPTR		0x51
    222 #define ASI_IMMU_64KPTR		0x52
    223 #define ASI_IMMU_DATA_IN	0x54
    224 #define ASI_IMMU_TLB_DATA	0x55
    225 #define ASI_IMMU_TLB_TAG	0x56
    226 #define ASI_DMMU_8KPTR		0x59
    227 #define ASI_DMMU_64KPTR		0x5a
    228 #define ASI_DMMU_DATA_IN	0x5c
    229 #define ASI_DMMU_TLB_DATA	0x5d
    230 #define ASI_DMMU_TLB_TAG	0x5e
    231 
    232 /*
    233  * The following are the control registers
    234  * They work on both MMUs unless noted.
    235  *
    236  * Register contents are defined later on individual registers.
    237  */
    238 #define TSB_TAG_TARGET		0x0
    239 #define TLB_DATA_IN		0x0
    240 #define CTX_PRIMARY		0x08	/* primary context -- DMMU only */
    241 #define CTX_SECONDARY		0x10	/* secondary context -- DMMU only */
    242 #define SFSR			0x18
    243 #define SFAR			0x20	/* fault address -- DMMU only */
    244 #define TSB			0x28
    245 #define TLB_TAG_ACCESS		0x30
    246 #define VIRTUAL_WATCHPOINT	0x38
    247 #define PHYSICAL_WATCHPOINT	0x40
    248 
    249 /* Tag Target bits */
    250 #define TAG_TARGET_VA_MASK	0x03ffffffffffffffffLL
    251 #define TAG_TARGET_VA(x)	(((x)<<22)&TAG_TARGET_VA_MASK)
    252 #define TAG_TARGET_CONTEXT(x)	((x)>>48)
    253 #define TAG_TARGET(c,v)		((((uint64_t)c)<<48)|(((uint64_t)v)&TAG_TARGET_VA_MASK))
    254 
    255 /* SFSR bits for both D_SFSR and I_SFSR */
    256 #define SFSR_ASI(x)		((x)>>16)
    257 #define SFSR_FT_VA_OOR_2	0x02000 /* IMMU: jumpl or return to unsupportd VA */
    258 #define SFSR_FT_VA_OOR_1	0x01000 /* fault at unsupported VA */
    259 #define SFSR_FT_NFO		0x00800	/* DMMU: Access to page marked NFO */
    260 #define SFSR_ILL_ASI		0x00400	/* DMMU: Illegal (unsupported) ASI */
    261 #define SFSR_FT_IO_ATOMIC	0x00200	/* DMMU: Atomic access to noncacheable page */
    262 #define SFSR_FT_ILL_NF		0x00100	/* DMMU: NF load or flush to page marked E (has side effects) */
    263 #define SFSR_FT_PRIV		0x00080	/* Privilege violation */
    264 #define SFSR_FT_E		0x00040	/* DMUU: value of E bit associated address */
    265 #define SFSR_CTXT(x)		(((x)>>4)&0x3)
    266 #define SFSR_CTXT_IS_PRIM(x)	(SFSR_CTXT(x)==0x00)
    267 #define SFSR_CTXT_IS_SECOND(x)	(SFSR_CTXT(x)==0x01)
    268 #define SFSR_CTXT_IS_NUCLEUS(x)	(SFSR_CTXT(x)==0x02)
    269 #define SFSR_PRIV		0x00008	/* value of PSTATE.PRIV for faulting access */
    270 #define SFSR_W			0x00004 /* DMMU: attempted write */
    271 #define SFSR_OW			0x00002 /* Overwrite; prev vault was still valid */
    272 #define SFSR_FV			0x00001	/* Fault is valid */
    273 #define SFSR_FT	(SFSR_FT_VA_OOR_2|SFSR_FT_VA_OOR_1|SFSR_FT_NFO|SFSR_ILL_ASI|SFSR_FT_IO_ATOMIC|SFSR_FT_ILL_NF|SFSR_FT_PRIV)
    274 
    275 #if 0
    276 /* Old bits */
    277 #define SFSR_BITS "\40\16VAT\15VAD\14NFO\13ASI\12A\11NF\10PRIV\7E\6NUCLEUS\5SECONDCTX\4PRIV\3W\2OW\1FV"
    278 #else
    279 /* New bits */
    280 #define SFSR_BITS "\177\20" \
    281 	"f\20\30ASI\0" "b\16VAT\0" "b\15VAD\0" "b\14NFO\0" "b\13ASI\0" "b\12A\0" "b\11NF\0" "b\10PRIV\0" \
    282 	 "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" "b\3W\0" "b\2OW\0" "b\1FV\0"
    283 #endif
    284 
    285 /* ASFR bits */
    286 #define ASFR_ME			0x100000000LL
    287 #define ASFR_PRIV		0x080000000LL
    288 #define ASFR_ISAP		0x040000000LL
    289 #define ASFR_ETP		0x020000000LL
    290 #define ASFR_IVUE		0x010000000LL
    291 #define ASFR_TO			0x008000000LL
    292 #define ASFR_BERR		0x004000000LL
    293 #define ASFR_LDP		0x002000000LL
    294 #define ASFR_CP			0x001000000LL
    295 #define ASFR_WP			0x000800000LL
    296 #define ASFR_EDP		0x000400000LL
    297 #define ASFR_UE			0x000200000LL
    298 #define ASFR_CE			0x000100000LL
    299 #define ASFR_ETS		0x0000f0000LL
    300 #define ASFT_P_SYND		0x00000ffffLL
    301 
    302 #define AFSR_BITS "\177\20" \
    303         "b\40ME\0"      "b\37PRIV\0"    "b\36ISAP\0"    "b\35ETP\0" \
    304         "b\34IVUE\0"    "b\33TO\0"      "b\32BERR\0"    "b\31LDP\0" \
    305         "b\30CP\0"      "b\27WP\0"      "b\26EDP\0"     "b\25UE\0" \
    306         "b\24CE\0"      "f\20\4ETS\0"   "f\0\20P_SYND\0"
    307 
    308 /*
    309  * Here's the spitfire TSB control register bits.
    310  *
    311  * Each TSB entry is 16-bytes wide.  The TSB must be size aligned
    312  */
    313 #define TSB_SIZE_512		0x0	/* 8kB, etc. */
    314 #define TSB_SIZE_1K		0x01
    315 #define TSB_SIZE_2K		0x02
    316 #define TSB_SIZE_4K		0x03
    317 #define	TSB_SIZE_8K		0x04
    318 #define TSB_SIZE_16K		0x05
    319 #define TSB_SIZE_32K		0x06
    320 #define TSB_SIZE_64K		0x07
    321 #define TSB_SPLIT		0x1000
    322 #define TSB_BASE		0xffffffffffffe000
    323 
    324 /*  TLB Tag Access bits */
    325 #define TLB_TAG_ACCESS_VA	0xffffffffffffe000
    326 #define TLB_TAG_ACCESS_CTX	0x0000000000001fff
    327 
    328 /*
    329  * TLB demap registers.  TTEs are defined in v9pte.h
    330  *
    331  * Use the address space to select between IMMU and DMMU.
    332  * The address of the register selects which context register
    333  * to read the ASI from.
    334  *
    335  * The data stored in the register is interpreted as the VA to
    336  * use.  The DEMAP_CTX_<> registers ignore the address and demap the
    337  * entire ASI.
    338  *
    339  */
    340 #define ASI_IMMU_DEMAP			0x57	/* [4u] IMMU TLB demap */
    341 #define ASI_DMMU_DEMAP			0x5f	/* [4u] IMMU TLB demap */
    342 
    343 #define DEMAP_PAGE_NUCLEUS		((0x02)<<4)	/* Demap page from kernel AS */
    344 #define DEMAP_PAGE_PRIMARY		((0x00)<<4)	/* Demap a page from primary CTXT */
    345 #define DEMAP_PAGE_SECONDARY		((0x01)<<4)	/* Demap page from secondary CTXT (DMMU only) */
    346 #define DEMAP_CTX_NUCLEUS		((0x06)<<4)	/* Demap all of kernel CTXT */
    347 #define DEMAP_CTX_PRIMARY		((0x04)<<4)	/* Demap all of primary CTXT */
    348 #define DEMAP_CTX_SECONDARY		((0x05)<<4)	/* Demap all of secondary CTXT */
    349 
    350 /*
    351  * Interrupt registers.  This really gets hairy.
    352  */
    353 
    354 /* IRSR -- Interrupt Receive Status Ragister */
    355 #define ASI_IRSR	0x49
    356 #define IRSR		0x00
    357 #define IRSR_BUSY	0x010
    358 #define IRSR_MID(x)	(x&0xf)
    359 
    360 /* IRDR -- Interrupt Receive Data Registers */
    361 #define ASI_IRDR	0x7f
    362 #define IRDR_0H		0x40
    363 #define IRDR_0L		0x48	/* unimplemented */
    364 #define IRDR_1H		0x50
    365 #define IRDR_1L		0x58	/* unimplemented */
    366 #define IRDR_2H		0x60
    367 #define IRDR_2L		0x68	/* unimplemented */
    368 #define IRDR_3H		0x70	/* unimplemented */
    369 #define IRDR_3L		0x78	/* unimplemented */
    370 
    371 /* SOFTINT ASRs */
    372 #define SET_SOFTINT	%asr20	/* Sets these bits */
    373 #define CLEAR_SOFTINT	%asr21	/* Clears these bits */
    374 #define SOFTINT		%asr22	/* Reads the register */
    375 
    376 #define	TICK_INT	0x01	/* level-14 clock tick */
    377 #define SOFTINT1	(0x1<<1)
    378 #define SOFTINT2	(0x1<<2)
    379 #define SOFTINT3	(0x1<<3)
    380 #define SOFTINT4	(0x1<<4)
    381 #define SOFTINT5	(0x1<<5)
    382 #define SOFTINT6	(0x1<<6)
    383 #define SOFTINT7	(0x1<<7)
    384 #define SOFTINT8	(0x1<<8)
    385 #define SOFTINT9	(0x1<<9)
    386 #define SOFTINT10	(0x1<<10)
    387 #define SOFTINT11	(0x1<<11)
    388 #define SOFTINT12	(0x1<<12)
    389 #define SOFTINT13	(0x1<<13)
    390 #define SOFTINT14	(0x1<<14)
    391 #define SOFTINT15	(0x1<<15)
    392 
    393 /* Interrupt Dispatch -- usually reserved for cross-calls */
    394 #define ASR_IDSR	0x48 /* Interrupt dispatch status reg */
    395 #define IDSR		0x00
    396 #define IDSR_NACK	0x02
    397 #define IDSR_BUSY	0x01
    398 
    399 #define ASI_INTERRUPT_DISPATCH		0x77	/* [4u] spitfire interrupt dispatch regs */
    400 #define IDCR(x)		(((x)<<14)&0x70)	/* Store anything to this address to dispatch crosscall to CPU (x) */
    401 #define IDDR_0H		0x40			/* Store data to send in these regs */
    402 #define IDDR_0L		0x48	/* unimplemented */
    403 #define IDDR_1H		0x50
    404 #define IDDR_1L		0x58	/* unimplemented */
    405 #define IDDR_2H		0x60
    406 #define IDDR_2L		0x68	/* unimplemented */
    407 #define IDDR_3H		0x70	/* unimplemented */
    408 #define IDDR_3L		0x78	/* unimplemented */
    409 
    410 /*
    411  * Error registers
    412  */
    413 
    414 /* Since we won't try to fix async errs, we don't care about the bits in the regs */
    415 #define ASI_AFAR	0x4d	/* Asynchronous fault address register */
    416 #define AFAR		0x00
    417 #define ASI_AFSR	0x4c	/* Asynchronous fault status register */
    418 #define AFSR		0x00
    419 
    420 #define ASI_P_EER	0x4b	/* Error enable register */
    421 #define P_EER		0x00
    422 #define P_EER_ISAPEN	0x04	/* Enable fatal on ISAP */
    423 #define P_EER_NCEEN	0x02	/* Enable trap on uncorrectable errs */
    424 #define P_EER_CEEN	0x01	/* Enable trap on correctable errs */
    425 
    426 #define ASI_DATAPATH_READ	0x7f /* Read the regs */
    427 #define ASI_DATAPATH_WRITE	0x77 /* Write to the regs */
    428 #define P_DPER_0	0x00	/* Datapath err reg 0 */
    429 #define P_DPER_1	0x18	/* Datapath err reg 1 */
    430 #define P_DCR_0		0x20	/* Datapath control reg 0 */
    431 #define P_DCR_1		0x38	/* Datapath control reg 0 */
    432 
    433 
    434 /* From sparc64/asm.h which I think I'll deprecate since it makes bus.h a pain. */
    435 
    436 /*
    437  * GCC __asm constructs for doing assembly stuff.
    438  */
    439 
    440 /*
    441  * ``Routines'' to load and store from/to alternate address space.
    442  * The location can be a variable, the asi value (address space indicator)
    443  * must be a constant.
    444  *
    445  * N.B.: You can put as many special functions here as you like, since
    446  * they cost no kernel space or time if they are not used.
    447  *
    448  * These were static inline functions, but gcc screws up the constraints
    449  * on the address space identifiers (the "n"umeric value part) because
    450  * it inlines too late, so we have to use the funny valued-macro syntax.
    451  */
    452 /* load byte from alternate address space */
    453 #define	lduba(loc, asi) ({ \
    454 	register int _lduba_v; \
    455 	__asm __volatile("wr %2,%%g0,%%asi; lduba [%1]%%asi,%0" : "=r" (_lduba_v) : \
    456 	    "r" ((long long)(loc)), "r" (asi)); \
    457 	_lduba_v; \
    458 })
    459 
    460 /* load half-word from alternate address space */
    461 #define	lduha(loc, asi) ({ \
    462 	register int _lduha_v; \
    463 	__asm __volatile("wr %2,%%g0,%%asi; lduha [%1]%%asi,%0" : "=r" (_lduha_v) : \
    464 	    "r" ((long long)(loc)), "r" (asi)); \
    465 	_lduha_v; \
    466 })
    467 
    468 /* load int from alternate address space */
    469 #define	lda(loc, asi) ({ \
    470 	register int _lda_v; \
    471 	__asm __volatile("wr %2,%%g0,%%asi; lda [%1]%%asi,%0" : "=r" (_lda_v) : \
    472 	    "r" ((int)(loc)), "r" (asi)); \
    473 	_lda_v; \
    474 })
    475 
    476 #define	ldswa(loc, asi) ({ \
    477 	register int _lda_v; \
    478 	__asm __volatile("wr %2,%%g0,%%asi; ldswa [%1]%%asi,%0" : "=r" (_lda_v) : \
    479 	    "r" ((int)(loc)), "r" (asi)); \
    480 	_lda_v; \
    481 })
    482 
    483 /* store byte to alternate address space */
    484 #define	stba(loc, asi, value) ({ \
    485 	__asm __volatile("wr %2,%%g0,%%asi; stba %0,[%1]%%asi; membar #Sync" : : \
    486 	    "r" ((int)(value)), "r" ((int)(loc)), "r" (asi)); \
    487 })
    488 
    489 /* store half-word to alternate address space */
    490 #define	stha(loc, asi, value) ({ \
    491 	__asm __volatile("wr %2,%%g0,%%asi; stha %0,[%1]%%asi; membar #Sync" : : \
    492 	    "r" ((int)(value)), "r" ((int)(loc)), "r" (asi)); \
    493 })
    494 
    495 /* store int to alternate address space */
    496 #define	sta(loc, asi, value) ({ \
    497 	__asm __volatile("wr %2,%%g0,%%asi; sta %0,[%1]%%asi; membar #Sync" : : \
    498 	    "r" ((int)(value)), "r" ((int)(loc)), "r" (asi)); \
    499 })
    500 
    501 /* load 64-bit int from alternate address space */
    502 #define	ldda(loc, asi) ({ \
    503 	register long long _lda_v; \
    504 	__asm __volatile("wr %2,%%g0,%%asi; ldda [%1]%%asi,%0" : "=r" (_lda_v) : \
    505 	    "r" ((int)(loc)), "r" (asi)); \
    506 	_lda_v; \
    507 })
    508 
    509 /* store 64-bit int to alternate address space */
    510 #define	stda(loc, asi, value) ({ \
    511 	__asm __volatile("wr %2,%%g0,%%asi; stda %0,[%1]%%asi; membar #Sync" : : \
    512 	    "r" ((long long)(value)), "r" ((int)(loc)), "r" (asi)); \
    513 })
    514 
    515 #ifdef _LP64
    516 /* native load 64-bit int from alternate address space w/64-bit compiler*/
    517 #define	ldxa(loc, asi) ({ \
    518 	register long _lda_v; \
    519 	__asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%0" : "=r" (_lda_v) : \
    520 	    "r" ((long)(loc)), "r" (asi)); \
    521 	_lda_v; \
    522 })
    523 #else
    524 /* native load 64-bit int from alternate address space w/32-bit compiler*/
    525 #define	ldxa(loc, asi) ({ \
    526 	volatile register long _ldxa_tmp = 0; \
    527 	volatile int64_t _ldxa_v; \
    528 	volatile int64_t *_ldxa_a = &_ldxa_v; \
    529 	__asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%1; stx %1,[%3]; membar #Sync" : "=r" (_ldxa_tmp) : \
    530 	    "r" ((long)(loc)), "r" (asi), "r" ((long)(_ldxa_a))); \
    531 	_ldxa_v; \
    532 })
    533 #endif
    534 
    535 #ifdef _LP64
    536 /* native store 64-bit int to alternate address space w/64-bit compiler*/
    537 #define	stxa(loc, asi, value) ({ \
    538 	__asm __volatile("wr %2,%%g0,%%asi; stxa %0,[%1]%%asi; membar #Sync" : : \
    539 	    "r" ((long)(value)), "r" ((long)(loc)), "r" (asi)); \
    540 })
    541 #else
    542 /* native store 64-bit int to alternate address space w/32-bit compiler*/
    543 #define	stxa(loc, asi, value) ({ \
    544 	int64_t _stxa_v; \
    545 	int64_t *_stxa_a = &_stxa_v; \
    546 	_stxa_v = value; \
    547 	__asm __volatile("wr %2,%%g0,%%asi; ldx [%0],%3; stxa %3,[%1]%%asi; membar #Sync" : : \
    548 	    "r" ((long)(_stxa_a)), "r" ((long)(loc)), "r" (asi), "r" ((long)(_stxa_v))); \
    549 })
    550 #endif
    551 
    552 /* flush address from data cache */
    553 #define flush(loc) ({ \
    554 	__asm __volatile("flush %0" : : \
    555 	     "r" ((long)(loc))); \
    556 })
    557 
    558 #define membar_sync() __asm __volatile("membar #Sync" : :)
    559 
    560 #ifdef _LP64
    561 /* read 64-bit %tick register */
    562 #define	tick() ({ \
    563 	register u_long _tick_tmp; \
    564 	__asm __volatile("rdpr %%tick, %0" : "=r" (_tick_tmp) :); \
    565 	_tick_tmp; \
    566 })
    567 #else
    568 /* native load 64-bit int from alternate address space w/32-bit compiler*/
    569 #define	tick() ({ \
    570 	volatile register u_long _tick_tmp = 0; \
    571 	volatile u_int64_t _tick_v; \
    572 	volatile u_int64_t *_tick_a = &_tick_v; \
    573 	__asm __volatile("rdpr %%tick, %0; stx %0,[%1]; membar #StoreLoad" : "=r" (_tick_tmp) : \
    574 	    "r" ((long)(_tick_a))); \
    575 	_tick_v; \
    576 })
    577 #endif
    578 
    579