Home | History | Annotate | Line # | Download | only in include
ctlreg.h revision 1.12.2.2
      1  1.12.2.2  bouyer /*	$NetBSD: ctlreg.h,v 1.12.2.2 2000/12/08 09:30:34 bouyer Exp $ */
      2       1.1     eeh 
      3       1.1     eeh /*
      4      1.11     eeh  * Copyright (c) 1996-1999 Eduardo Horvath
      5       1.1     eeh  *
      6       1.1     eeh  * Redistribution and use in source and binary forms, with or without
      7       1.1     eeh  * modification, are permitted provided that the following conditions
      8       1.1     eeh  * are met:
      9       1.1     eeh  * 1. Redistributions of source code must retain the above copyright
     10       1.1     eeh  *    notice, this list of conditions and the following disclaimer.
     11      1.11     eeh  *
     12      1.11     eeh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND
     13       1.1     eeh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     14       1.1     eeh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     15      1.11     eeh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR  BE LIABLE
     16       1.1     eeh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     17       1.1     eeh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     18       1.1     eeh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     19       1.1     eeh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     20       1.1     eeh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     21       1.1     eeh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     22       1.1     eeh  * SUCH DAMAGE.
     23       1.1     eeh  *
     24       1.1     eeh  */
     25       1.1     eeh 
     26       1.1     eeh /*
     27       1.1     eeh  * Sun 4u control registers. (includes address space definitions
     28       1.1     eeh  * and some registers in control space).
     29       1.1     eeh  */
     30       1.1     eeh 
     31       1.1     eeh /*
     32       1.1     eeh  * The Alternate address spaces.
     33       1.1     eeh  *
     34       1.1     eeh  * 0x00-0x7f are privileged
     35       1.1     eeh  * 0x80-0xff can be used by users
     36       1.1     eeh  */
     37       1.1     eeh 
     38       1.1     eeh #define ASI_LITTLE	0x08		/* This bit should make an ASI little endian */
     39       1.1     eeh 
     40       1.1     eeh #define ASI_NUCLEUS			0x04	/* [4u] kernel address space */
     41       1.1     eeh #define ASI_NUCLEUS_LITTLE		0x0c	/* [4u] kernel address space, little endian */
     42       1.1     eeh 
     43       1.1     eeh #define ASI_AS_IF_USER_PRIMARY		0x10	/* [4u] primary user address space */
     44       1.1     eeh #define ASI_AS_IF_USER_SECONDARY	0x11	/* [4u] secondary user address space */
     45       1.1     eeh 
     46       1.1     eeh #define ASI_PHYS_CACHED			0x14	/* [4u] MMU bypass to main memory */
     47       1.1     eeh #define ASI_PHYS_NON_CACHED		0x15	/* [4u] MMU bypass to I/O location */
     48       1.1     eeh 
     49       1.1     eeh #define ASI_AS_IF_USER_PRIMARY_LITTLE	0x18	/* [4u] primary user address space, little endian  */
     50       1.1     eeh #define ASI_AS_IF_USER_SECONDARY_LITTIE	0x19	/* [4u] secondary user address space, little endian  */
     51       1.1     eeh 
     52       1.1     eeh #define ASI_PHYS_CACHED_LITTLE		0x1c	/* [4u] MMU bypass to main memory, little endian */
     53       1.1     eeh #define ASI_PHYS_NON_CACHED_LITTLE	0x1d	/* [4u] MMU bypass to I/O location, little endian */
     54       1.1     eeh 
     55       1.1     eeh #define ASI_NUCLEUS_QUAD_LDD		0x24	/* [4u] use w/LDDA to load 128-bit item */
     56       1.1     eeh #define ASI_NUCLEUS_QUAD_LDD_LITTLE	0x2c	/* [4u] use w/LDDA to load 128-bit item, little endian */
     57       1.1     eeh 
     58       1.1     eeh #define ASI_FLUSH_D_PAGE_PRIMARY	0x38	/* [4u] flush D-cache page using primary context */
     59       1.1     eeh #define ASI_FLUSH_D_PAGE_SECONDARY	0x39	/* [4u] flush D-cache page using secondary context */
     60       1.1     eeh #define ASI_FLUSH_D_CTX_PRIMARY		0x3a	/* [4u] flush D-cache context using primary context */
     61       1.1     eeh #define ASI_FLUSH_D_CTX_SECONDARY	0x3b	/* [4u] flush D-cache context using secondary context */
     62       1.6     eeh 
     63       1.6     eeh #define ASI_LSU_CONTROL_REGISTER	0x45	/* [4u] load/store unit control register */
     64       1.6     eeh 
     65       1.1     eeh #define ASI_DCACHE_DATA			0x46	/* [4u] diagnostic access to D-cache data RAM */
     66       1.1     eeh #define ASI_DCACHE_TAG			0x47	/* [4u] diagnostic access to D-cache tag RAM */
     67       1.1     eeh 
     68       1.1     eeh #define ASI_INTR_DISPATCH_STATUS	0x48	/* [4u] interrupt dispatch status register */
     69       1.1     eeh #define ASI_INTR_RECEIVE		0x49	/* [4u] interrupt receive status register */
     70       1.1     eeh #define ASI_MID_REG			0x4a	/* [4u] hardware config and MID */
     71       1.1     eeh #define ASI_ERROR_EN_REG		0x4b	/* [4u] asynchronous error enables */
     72       1.1     eeh #define ASI_AFSR			0x4c	/* [4u] asynchronous fault status register */
     73       1.1     eeh #define ASI_AFAR			0x4d	/* [4u] asynchronous fault address register */
     74       1.1     eeh 
     75       1.1     eeh #define ASI_ICACHE_DATA			0x66	/* [4u] diagnostic access to D-cache data RAM */
     76       1.1     eeh #define ASI_ICACHE_TAG			0x67	/* [4u] diagnostic access to D-cache tag RAM */
     77       1.1     eeh #define ASI_FLUSH_I_PAGE_PRIMARY	0x68	/* [4u] flush D-cache page using primary context */
     78       1.1     eeh #define ASI_FLUSH_I_PAGE_SECONDARY	0x69	/* [4u] flush D-cache page using secondary context */
     79       1.1     eeh #define ASI_FLUSH_I_CTX_PRIMARY		0x6a	/* [4u] flush D-cache context using primary context */
     80       1.1     eeh #define ASI_FLUSH_I_CTX_SECONDARY	0x6b	/* [4u] flush D-cache context using secondary context */
     81       1.1     eeh 
     82       1.1     eeh #define ASI_BLOCK_AS_IF_USER_PRIMARY	0x70	/* [4u] primary user address space, block loads/stores */
     83       1.1     eeh #define ASI_BLOCK_AS_IF_USER_SECONDARY	0x71	/* [4u] secondary user address space, block loads/stores */
     84       1.1     eeh 
     85       1.1     eeh #define ASI_ECACHE_DIAG			0x76	/* [4u] diag access to E-cache tag and data */
     86       1.1     eeh #define ASI_DATAPATH_ERR_REG_WRITE	0x77	/* [4u] ASI is reused */
     87       1.1     eeh 
     88       1.1     eeh #define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE	0x78	/* [4u] primary user address space, block loads/stores */
     89       1.1     eeh #define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE	0x79	/* [4u] secondary user address space, block loads/stores */
     90       1.1     eeh 
     91       1.1     eeh #define ASI_INTERRUPT_RECEIVE_DATA	0x7f	/* [4u] interrupt receive data registers {0,1,2} */
     92       1.1     eeh #define ASI_DATAPATH_ERR_REG_READ	0x7f	/* [4u] read access to datapath error registers (ASI reused) */
     93       1.1     eeh 
     94       1.1     eeh #define ASI_PRIMARY			0x80	/* [4u] primary address space */
     95       1.1     eeh #define ASI_SECONDARY			0x81	/* [4u] secondary address space */
     96       1.1     eeh #define ASI_PRIMARY_NO_FAULT		0x82	/* [4u] primary address space, no fault */
     97       1.1     eeh #define ASI_SECONDARY_NO_FAULT		0x83	/* [4u] secondary address space, no fault */
     98       1.1     eeh 
     99       1.1     eeh #define ASI_PRIMARY_LITTLE		0x88	/* [4u] primary address space, little endian */
    100       1.1     eeh #define ASI_SECONDARY_LITTLE		0x89	/* [4u] secondary address space, little endian */
    101       1.1     eeh #define ASI_PRIMARY_NO_FAULT_LITTLE	0x8a	/* [4u] primary address space, no fault, little endian */
    102       1.1     eeh #define ASI_SECONDARY_NO_FAULT_LITTLE	0x8b	/* [4u] secondary address space, no fault, little endian */
    103       1.1     eeh 
    104       1.1     eeh #define ASI_PST8_PRIMARY		0xc0	/* [VIS] Eight 8-bit partial store, primary */
    105       1.1     eeh #define ASI_PST8_SECONDARY		0xc1	/* [VIS] Eight 8-bit partial store, secondary */
    106       1.1     eeh #define ASI_PST16_PRIMARY		0xc2	/* [VIS] Four 16-bit partial store, primary */
    107       1.1     eeh #define ASI_PST16_SECONDARY		0xc3	/* [VIS] Fout 16-bit partial store, secondary */
    108       1.1     eeh #define ASI_PST32_PRIMARY		0xc4	/* [VIS] Two 32-bit partial store, primary */
    109       1.1     eeh #define ASI_PST32_SECONDARY		0xc5	/* [VIS] Two 32-bit partial store, secondary */
    110       1.1     eeh 
    111       1.1     eeh #define ASI_PST8_PRIMARY_LITTLE		0xc8	/* [VIS] Eight 8-bit partial store, primary, little endian */
    112       1.1     eeh #define ASI_PST8_SECONDARY_LITTLE	0xc9	/* [VIS] Eight 8-bit partial store, secondary, little endian */
    113       1.1     eeh #define ASI_PST16_PRIMARY_LITTLE	0xca	/* [VIS] Four 16-bit partial store, primary, little endian */
    114       1.1     eeh #define ASI_PST16_SECONDARY_LITTLE	0xcb	/* [VIS] Fout 16-bit partial store, secondary, little endian */
    115       1.1     eeh #define ASI_PST32_PRIMARY_LITTLE	0xcc	/* [VIS] Two 32-bit partial store, primary, little endian */
    116       1.1     eeh #define ASI_PST32_SECONDARY_LITTLE	0xcd	/* [VIS] Two 32-bit partial store, secondary, little endian */
    117       1.1     eeh 
    118       1.1     eeh #define ASI_FL8_PRIMARY			0xd0	/* [VIS] One 8-bit load/store floating, primary */
    119       1.1     eeh #define ASI_FL8_SECONDARY		0xd1	/* [VIS] One 8-bit load/store floating, secondary */
    120       1.1     eeh #define ASI_FL16_PRIMARY		0xd2	/* [VIS] One 16-bit load/store floating, primary */
    121       1.1     eeh #define ASI_FL16_SECONDARY		0xd3	/* [VIS] One 16-bit load/store floating, secondary */
    122       1.1     eeh 
    123       1.1     eeh #define ASI_FL8_PRIMARY_LITTLE		0xd8	/* [VIS] One 8-bit load/store floating, primary, little endian */
    124       1.1     eeh #define ASI_FL8_SECONDARY_LITTLE	0xd9	/* [VIS] One 8-bit load/store floating, secondary, little endian */
    125       1.1     eeh #define ASI_FL16_PRIMARY_LITTLE		0xda	/* [VIS] One 16-bit load/store floating, primary, little endian */
    126       1.1     eeh #define ASI_FL16_SECONDARY_LITTLE	0xdb	/* [VIS] One 16-bit load/store floating, secondary, little endian */
    127       1.1     eeh 
    128       1.1     eeh #define ASI_BLOCK_COMMIT_PRIMARY	0xe0	/* [4u] block store with commit, primary */
    129       1.1     eeh #define ASI_BLOCK_COMMIT_SECONDARY	0xe1	/* [4u] block store with commit, secondary */
    130       1.1     eeh #define ASI_BLOCK_PRIMARY		0xf0	/* [4u] block load/store, primary */
    131       1.1     eeh #define ASI_BLOCK_SECONDARY		0xf1	/* [4u] block load/store, secondary */
    132       1.1     eeh #define ASI_BLOCK_PRIMARY_LITTLE	0xf8	/* [4u] block load/store, primary, little endian */
    133       1.1     eeh #define ASI_BLOCK_SECONDARY_LITTLE	0xf9	/* [4u] block load/store, secondary, little endian */
    134       1.1     eeh 
    135       1.1     eeh 
    136       1.1     eeh /*
    137       1.1     eeh  * These are the shorter names used by Solaris
    138       1.1     eeh  */
    139       1.1     eeh 
    140       1.1     eeh #define ASI_N		ASI_NUCLEUS
    141       1.1     eeh #define ASI_NL		ASI_NUCLEUS_LITTLE
    142       1.1     eeh #define ASI_AIUP	ASI_AS_IF_USER_PRIMARY
    143       1.1     eeh #define ASI_AIUS	ASI_AS_IF_USER_SECONDARY
    144       1.1     eeh #define ASI_AIUPL	ASI_AS_IF_USER_PRIMARY_LITTLE
    145       1.1     eeh #define ASI_AIUSL	ASI_AS_IF_USER_SECONDARY_LITTLE
    146       1.1     eeh #define ASI_P		ASI_PRIMARY
    147       1.1     eeh #define ASI_S		ASI_SECONDARY
    148       1.1     eeh #define ASI_PNF		ASI_PRIMARY_NO_FAULT
    149       1.1     eeh #define ASI_SNF		ASI_SECONDARY_NO_FAULT
    150       1.1     eeh #define ASI_PL		ASI_PRIMARY_LITTLE
    151       1.1     eeh #define ASI_SL		ASI_SECONDARY_LITTLE
    152       1.1     eeh #define ASI_PNFL	ASI_PRIMARY_NO_FAULT_LITTLE
    153       1.1     eeh #define ASI_SNFL	ASI_SECONDARY_NO_FAULT_LITTLE
    154       1.1     eeh #define ASI_BLK_AIUP	ASI_BLOCK_AS_IF_USER_PRIMARY
    155       1.1     eeh #define ASI_BLK_AIUPL	ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE
    156       1.1     eeh #define ASI_BLK_AIUS	ASI_BLOCK_AS_IF_USER_SECONDARY
    157       1.1     eeh #define ASI_BLK_AIUSL	ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE
    158       1.1     eeh #define ASI_BLK_COMMIT_P		ASI_BLOCK_COMMIT_PRIMARY
    159       1.1     eeh #define ASI_BLK_COMMIT_PRIMARY		ASI_BLOCK_COMMIT_PRIMARY
    160       1.1     eeh #define ASI_BLK_COMMIT_S		ASI_BLOCK_COMMIT_SECONDARY
    161       1.1     eeh #define ASI_BLK_COMMIT_SECONDARY	ASI_BLOCK_COMMIT_SECONDARY
    162       1.1     eeh #define ASI_BLK_P			ASI_BLOCK_PRIMARY
    163       1.1     eeh #define ASI_BLK_PL			ASI_BLOCK_PRIMARY_LITTLE
    164       1.1     eeh #define ASI_BLK_S			ASI_BLOCK_SECONDARY
    165       1.1     eeh #define ASI_BLK_SL			ASI_BLOCK_SECONDARY_LITTLE
    166       1.1     eeh 
    167  1.12.2.1  bouyer #define PHYS_ASI(x)	(((x) | 0x09) == 0x1d)
    168  1.12.2.1  bouyer #define LITTLE_ASI(x)	((x) & ASI_LITTLE)
    169  1.12.2.1  bouyer 
    170       1.1     eeh /*
    171       1.1     eeh  * The following are 4u control registers
    172       1.1     eeh  */
    173       1.1     eeh 
    174  1.12.2.1  bouyer 
    175  1.12.2.1  bouyer /* Get the CPU's UPAID */
    176  1.12.2.1  bouyer #define	UPA_CR_MID(x)	(((x)>>17)&0x1f)
    177  1.12.2.1  bouyer #define	CPU_UPAID	UPA_CR_MID(ldxa(0, ASI_MID_REG))
    178  1.12.2.1  bouyer 
    179       1.1     eeh /*
    180       1.1     eeh  * [4u] MMU and Cache Control Register (MCCR)
    181       1.1     eeh  * use ASI = 0x45
    182       1.1     eeh  */
    183       1.6     eeh #define ASI_MCCR	ASI_LSU_CONTROL_REGISTER
    184       1.1     eeh #define MCCR		0x00
    185       1.1     eeh 
    186       1.1     eeh /* MCCR Bits and their meanings */
    187       1.1     eeh #define MCCR_DMMU_EN	0x08
    188       1.1     eeh #define MCCR_IMMU_EN	0x04
    189       1.1     eeh #define MCCR_DCACHE_EN	0x02
    190       1.1     eeh #define MCCR_ICACHE_EN	0x01
    191       1.1     eeh 
    192       1.1     eeh 
    193       1.1     eeh /*
    194       1.1     eeh  * MMU control registers
    195       1.1     eeh  */
    196       1.1     eeh 
    197       1.1     eeh /* Choose an MMU */
    198       1.1     eeh #define ASI_DMMU		0x58
    199       1.1     eeh #define ASI_IMMU		0x50
    200       1.1     eeh 
    201       1.1     eeh /* Other assorted MMU ASIs */
    202       1.1     eeh #define ASI_IMMU_8KPTR		0x51
    203       1.1     eeh #define ASI_IMMU_64KPTR		0x52
    204       1.1     eeh #define ASI_IMMU_DATA_IN	0x54
    205       1.1     eeh #define ASI_IMMU_TLB_DATA	0x55
    206       1.1     eeh #define ASI_IMMU_TLB_TAG	0x56
    207       1.1     eeh #define ASI_DMMU_8KPTR		0x59
    208       1.1     eeh #define ASI_DMMU_64KPTR		0x5a
    209       1.1     eeh #define ASI_DMMU_DATA_IN	0x5c
    210       1.1     eeh #define ASI_DMMU_TLB_DATA	0x5d
    211       1.1     eeh #define ASI_DMMU_TLB_TAG	0x5e
    212       1.1     eeh 
    213       1.1     eeh /*
    214       1.1     eeh  * The following are the control registers
    215       1.1     eeh  * They work on both MMUs unless noted.
    216       1.1     eeh  *
    217       1.1     eeh  * Register contents are defined later on individual registers.
    218       1.1     eeh  */
    219       1.1     eeh #define TSB_TAG_TARGET		0x0
    220       1.1     eeh #define TLB_DATA_IN		0x0
    221       1.1     eeh #define CTX_PRIMARY		0x08	/* primary context -- DMMU only */
    222       1.1     eeh #define CTX_SECONDARY		0x10	/* secondary context -- DMMU only */
    223       1.1     eeh #define SFSR			0x18
    224       1.1     eeh #define SFAR			0x20	/* fault address -- DMMU only */
    225       1.1     eeh #define TSB			0x28
    226       1.1     eeh #define TLB_TAG_ACCESS		0x30
    227       1.1     eeh #define VIRTUAL_WATCHPOINT	0x38
    228       1.1     eeh #define PHYSICAL_WATCHPOINT	0x40
    229       1.1     eeh 
    230       1.1     eeh /* Tag Target bits */
    231       1.1     eeh #define TAG_TARGET_VA_MASK	0x03ffffffffffffffffLL
    232       1.1     eeh #define TAG_TARGET_VA(x)	(((x)<<22)&TAG_TARGET_VA_MASK)
    233       1.1     eeh #define TAG_TARGET_CONTEXT(x)	((x)>>48)
    234       1.1     eeh #define TAG_TARGET(c,v)		((((uint64_t)c)<<48)|(((uint64_t)v)&TAG_TARGET_VA_MASK))
    235       1.1     eeh 
    236       1.1     eeh /* SFSR bits for both D_SFSR and I_SFSR */
    237       1.1     eeh #define SFSR_ASI(x)		((x)>>16)
    238       1.1     eeh #define SFSR_FT_VA_OOR_2	0x02000 /* IMMU: jumpl or return to unsupportd VA */
    239       1.1     eeh #define SFSR_FT_VA_OOR_1	0x01000 /* fault at unsupported VA */
    240       1.1     eeh #define SFSR_FT_NFO		0x00800	/* DMMU: Access to page marked NFO */
    241       1.1     eeh #define SFSR_ILL_ASI		0x00400	/* DMMU: Illegal (unsupported) ASI */
    242       1.1     eeh #define SFSR_FT_IO_ATOMIC	0x00200	/* DMMU: Atomic access to noncacheable page */
    243       1.1     eeh #define SFSR_FT_ILL_NF		0x00100	/* DMMU: NF load or flush to page marked E (has side effects) */
    244       1.1     eeh #define SFSR_FT_PRIV		0x00080	/* Privilege violation */
    245       1.1     eeh #define SFSR_FT_E		0x00040	/* DMUU: value of E bit associated address */
    246       1.1     eeh #define SFSR_CTXT(x)		(((x)>>4)&0x3)
    247       1.1     eeh #define SFSR_CTXT_IS_PRIM(x)	(SFSR_CTXT(x)==0x00)
    248       1.1     eeh #define SFSR_CTXT_IS_SECOND(x)	(SFSR_CTXT(x)==0x01)
    249       1.1     eeh #define SFSR_CTXT_IS_NUCLEUS(x)	(SFSR_CTXT(x)==0x02)
    250       1.1     eeh #define SFSR_PRIV		0x00008	/* value of PSTATE.PRIV for faulting access */
    251       1.1     eeh #define SFSR_W			0x00004 /* DMMU: attempted write */
    252       1.1     eeh #define SFSR_OW			0x00002 /* Overwrite; prev vault was still valid */
    253       1.1     eeh #define SFSR_FV			0x00001	/* Fault is valid */
    254       1.1     eeh #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)
    255       1.1     eeh 
    256       1.3     eeh #if 0
    257       1.3     eeh /* Old bits */
    258       1.1     eeh #define SFSR_BITS "\40\16VAT\15VAD\14NFO\13ASI\12A\11NF\10PRIV\7E\6NUCLEUS\5SECONDCTX\4PRIV\3W\2OW\1FV"
    259       1.3     eeh #else
    260       1.3     eeh /* New bits */
    261       1.3     eeh #define SFSR_BITS "\177\20" \
    262       1.3     eeh 	"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" \
    263       1.3     eeh 	 "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" "b\3W\0" "b\2OW\0" "b\1FV\0"
    264       1.3     eeh #endif
    265       1.3     eeh 
    266       1.3     eeh /* ASFR bits */
    267       1.3     eeh #define ASFR_ME			0x100000000LL
    268       1.3     eeh #define ASFR_PRIV		0x080000000LL
    269       1.3     eeh #define ASFR_ISAP		0x040000000LL
    270       1.3     eeh #define ASFR_ETP		0x020000000LL
    271       1.3     eeh #define ASFR_IVUE		0x010000000LL
    272       1.3     eeh #define ASFR_TO			0x008000000LL
    273       1.3     eeh #define ASFR_BERR		0x004000000LL
    274       1.3     eeh #define ASFR_LDP		0x002000000LL
    275       1.3     eeh #define ASFR_CP			0x001000000LL
    276       1.3     eeh #define ASFR_WP			0x000800000LL
    277       1.3     eeh #define ASFR_EDP		0x000400000LL
    278       1.3     eeh #define ASFR_UE			0x000200000LL
    279       1.3     eeh #define ASFR_CE			0x000100000LL
    280       1.3     eeh #define ASFR_ETS		0x0000f0000LL
    281       1.3     eeh #define ASFT_P_SYND		0x00000ffffLL
    282       1.3     eeh 
    283       1.3     eeh #define AFSR_BITS "\177\20" \
    284       1.3     eeh         "b\40ME\0"      "b\37PRIV\0"    "b\36ISAP\0"    "b\35ETP\0" \
    285       1.3     eeh         "b\34IVUE\0"    "b\33TO\0"      "b\32BERR\0"    "b\31LDP\0" \
    286       1.3     eeh         "b\30CP\0"      "b\27WP\0"      "b\26EDP\0"     "b\25UE\0" \
    287       1.3     eeh         "b\24CE\0"      "f\20\4ETS\0"   "f\0\20P_SYND\0"
    288       1.3     eeh 
    289       1.1     eeh /*
    290       1.1     eeh  * Here's the spitfire TSB control register bits.
    291       1.1     eeh  *
    292       1.1     eeh  * Each TSB entry is 16-bytes wide.  The TSB must be size aligned
    293       1.1     eeh  */
    294       1.1     eeh #define TSB_SIZE_512		0x0	/* 8kB, etc. */
    295       1.1     eeh #define TSB_SIZE_1K		0x01
    296       1.1     eeh #define TSB_SIZE_2K		0x02
    297       1.1     eeh #define TSB_SIZE_4K		0x03
    298       1.1     eeh #define	TSB_SIZE_8K		0x04
    299       1.1     eeh #define TSB_SIZE_16K		0x05
    300       1.1     eeh #define TSB_SIZE_32K		0x06
    301       1.1     eeh #define TSB_SIZE_64K		0x07
    302       1.1     eeh #define TSB_SPLIT		0x1000
    303       1.1     eeh #define TSB_BASE		0xffffffffffffe000
    304       1.1     eeh 
    305       1.1     eeh /*  TLB Tag Access bits */
    306       1.1     eeh #define TLB_TAG_ACCESS_VA	0xffffffffffffe000
    307       1.1     eeh #define TLB_TAG_ACCESS_CTX	0x0000000000001fff
    308       1.1     eeh 
    309       1.1     eeh /*
    310       1.1     eeh  * TLB demap registers.  TTEs are defined in v9pte.h
    311       1.1     eeh  *
    312       1.1     eeh  * Use the address space to select between IMMU and DMMU.
    313       1.1     eeh  * The address of the register selects which context register
    314       1.1     eeh  * to read the ASI from.
    315       1.1     eeh  *
    316       1.1     eeh  * The data stored in the register is interpreted as the VA to
    317       1.1     eeh  * use.  The DEMAP_CTX_<> registers ignore the address and demap the
    318       1.1     eeh  * entire ASI.
    319       1.1     eeh  *
    320       1.1     eeh  */
    321       1.1     eeh #define ASI_IMMU_DEMAP			0x57	/* [4u] IMMU TLB demap */
    322       1.1     eeh #define ASI_DMMU_DEMAP			0x5f	/* [4u] IMMU TLB demap */
    323       1.1     eeh 
    324       1.1     eeh #define DEMAP_PAGE_NUCLEUS		((0x02)<<4)	/* Demap page from kernel AS */
    325       1.1     eeh #define DEMAP_PAGE_PRIMARY		((0x00)<<4)	/* Demap a page from primary CTXT */
    326       1.1     eeh #define DEMAP_PAGE_SECONDARY		((0x01)<<4)	/* Demap page from secondary CTXT (DMMU only) */
    327       1.1     eeh #define DEMAP_CTX_NUCLEUS		((0x06)<<4)	/* Demap all of kernel CTXT */
    328       1.1     eeh #define DEMAP_CTX_PRIMARY		((0x04)<<4)	/* Demap all of primary CTXT */
    329       1.1     eeh #define DEMAP_CTX_SECONDARY		((0x05)<<4)	/* Demap all of secondary CTXT */
    330       1.1     eeh 
    331       1.1     eeh /*
    332       1.1     eeh  * Interrupt registers.  This really gets hairy.
    333       1.1     eeh  */
    334       1.1     eeh 
    335       1.1     eeh /* IRSR -- Interrupt Receive Status Ragister */
    336       1.1     eeh #define ASI_IRSR	0x49
    337       1.1     eeh #define IRSR		0x00
    338  1.12.2.1  bouyer #define IRSR_BUSY	0x020
    339  1.12.2.1  bouyer #define IRSR_MID(x)	(x&0x1f)
    340       1.1     eeh 
    341       1.1     eeh /* IRDR -- Interrupt Receive Data Registers */
    342       1.1     eeh #define ASI_IRDR	0x7f
    343       1.1     eeh #define IRDR_0H		0x40
    344       1.1     eeh #define IRDR_0L		0x48	/* unimplemented */
    345       1.1     eeh #define IRDR_1H		0x50
    346       1.1     eeh #define IRDR_1L		0x58	/* unimplemented */
    347       1.1     eeh #define IRDR_2H		0x60
    348       1.1     eeh #define IRDR_2L		0x68	/* unimplemented */
    349       1.1     eeh #define IRDR_3H		0x70	/* unimplemented */
    350       1.1     eeh #define IRDR_3L		0x78	/* unimplemented */
    351       1.1     eeh 
    352       1.1     eeh /* SOFTINT ASRs */
    353       1.1     eeh #define SET_SOFTINT	%asr20	/* Sets these bits */
    354       1.1     eeh #define CLEAR_SOFTINT	%asr21	/* Clears these bits */
    355       1.1     eeh #define SOFTINT		%asr22	/* Reads the register */
    356       1.9     eeh #define TICK_CMPR	%asr23
    357       1.1     eeh 
    358       1.1     eeh #define	TICK_INT	0x01	/* level-14 clock tick */
    359       1.1     eeh #define SOFTINT1	(0x1<<1)
    360       1.1     eeh #define SOFTINT2	(0x1<<2)
    361       1.1     eeh #define SOFTINT3	(0x1<<3)
    362       1.1     eeh #define SOFTINT4	(0x1<<4)
    363       1.1     eeh #define SOFTINT5	(0x1<<5)
    364       1.1     eeh #define SOFTINT6	(0x1<<6)
    365       1.1     eeh #define SOFTINT7	(0x1<<7)
    366       1.1     eeh #define SOFTINT8	(0x1<<8)
    367       1.1     eeh #define SOFTINT9	(0x1<<9)
    368       1.1     eeh #define SOFTINT10	(0x1<<10)
    369       1.1     eeh #define SOFTINT11	(0x1<<11)
    370       1.1     eeh #define SOFTINT12	(0x1<<12)
    371       1.1     eeh #define SOFTINT13	(0x1<<13)
    372       1.1     eeh #define SOFTINT14	(0x1<<14)
    373       1.1     eeh #define SOFTINT15	(0x1<<15)
    374       1.1     eeh 
    375       1.1     eeh /* Interrupt Dispatch -- usually reserved for cross-calls */
    376       1.1     eeh #define ASR_IDSR	0x48 /* Interrupt dispatch status reg */
    377       1.1     eeh #define IDSR		0x00
    378       1.1     eeh #define IDSR_NACK	0x02
    379       1.1     eeh #define IDSR_BUSY	0x01
    380       1.1     eeh 
    381       1.1     eeh #define ASI_INTERRUPT_DISPATCH		0x77	/* [4u] spitfire interrupt dispatch regs */
    382       1.1     eeh #define IDCR(x)		(((x)<<14)&0x70)	/* Store anything to this address to dispatch crosscall to CPU (x) */
    383       1.1     eeh #define IDDR_0H		0x40			/* Store data to send in these regs */
    384       1.1     eeh #define IDDR_0L		0x48	/* unimplemented */
    385       1.1     eeh #define IDDR_1H		0x50
    386       1.1     eeh #define IDDR_1L		0x58	/* unimplemented */
    387       1.1     eeh #define IDDR_2H		0x60
    388       1.1     eeh #define IDDR_2L		0x68	/* unimplemented */
    389       1.1     eeh #define IDDR_3H		0x70	/* unimplemented */
    390       1.1     eeh #define IDDR_3L		0x78	/* unimplemented */
    391       1.1     eeh 
    392       1.1     eeh /*
    393       1.1     eeh  * Error registers
    394       1.1     eeh  */
    395       1.1     eeh 
    396       1.1     eeh /* Since we won't try to fix async errs, we don't care about the bits in the regs */
    397       1.1     eeh #define ASI_AFAR	0x4d	/* Asynchronous fault address register */
    398       1.1     eeh #define AFAR		0x00
    399       1.1     eeh #define ASI_AFSR	0x4c	/* Asynchronous fault status register */
    400       1.1     eeh #define AFSR		0x00
    401       1.1     eeh 
    402       1.1     eeh #define ASI_P_EER	0x4b	/* Error enable register */
    403       1.1     eeh #define P_EER		0x00
    404       1.1     eeh #define P_EER_ISAPEN	0x04	/* Enable fatal on ISAP */
    405       1.1     eeh #define P_EER_NCEEN	0x02	/* Enable trap on uncorrectable errs */
    406       1.1     eeh #define P_EER_CEEN	0x01	/* Enable trap on correctable errs */
    407       1.1     eeh 
    408       1.1     eeh #define ASI_DATAPATH_READ	0x7f /* Read the regs */
    409       1.1     eeh #define ASI_DATAPATH_WRITE	0x77 /* Write to the regs */
    410       1.1     eeh #define P_DPER_0	0x00	/* Datapath err reg 0 */
    411       1.1     eeh #define P_DPER_1	0x18	/* Datapath err reg 1 */
    412       1.1     eeh #define P_DCR_0		0x20	/* Datapath control reg 0 */
    413       1.1     eeh #define P_DCR_1		0x38	/* Datapath control reg 0 */
    414       1.1     eeh 
    415       1.2     eeh 
    416       1.2     eeh /* From sparc64/asm.h which I think I'll deprecate since it makes bus.h a pain. */
    417       1.2     eeh 
    418  1.12.2.1  bouyer #ifndef _LOCORE
    419       1.1     eeh /*
    420       1.2     eeh  * GCC __asm constructs for doing assembly stuff.
    421       1.1     eeh  */
    422       1.2     eeh 
    423       1.2     eeh /*
    424       1.2     eeh  * ``Routines'' to load and store from/to alternate address space.
    425       1.2     eeh  * The location can be a variable, the asi value (address space indicator)
    426       1.2     eeh  * must be a constant.
    427       1.1     eeh  *
    428       1.2     eeh  * N.B.: You can put as many special functions here as you like, since
    429       1.2     eeh  * they cost no kernel space or time if they are not used.
    430       1.1     eeh  *
    431       1.2     eeh  * These were static inline functions, but gcc screws up the constraints
    432       1.2     eeh  * on the address space identifiers (the "n"umeric value part) because
    433       1.2     eeh  * it inlines too late, so we have to use the funny valued-macro syntax.
    434       1.2     eeh  */
    435       1.6     eeh 
    436  1.12.2.1  bouyer /*
    437  1.12.2.1  bouyer  * Apparently the definition of bypass ASIs is that they all use the
    438  1.12.2.1  bouyer  * D$ so we need to flush the D$ to make sure we don't get data pollution.
    439  1.12.2.1  bouyer  */
    440  1.12.2.1  bouyer 
    441  1.12.2.1  bouyer static __inline__ u_char lduba __P((paddr_t loc, int asi));
    442  1.12.2.1  bouyer static __inline__ u_short lduha __P((paddr_t loc, int asi));
    443  1.12.2.1  bouyer static __inline__ u_int lda __P((paddr_t loc, int asi));
    444  1.12.2.1  bouyer static __inline__ int ldswa __P((paddr_t loc, int asi));
    445  1.12.2.1  bouyer static __inline__ u_int64_t ldxa __P((paddr_t loc, int asi));
    446  1.12.2.1  bouyer static __inline__ u_int64_t ldda __P((paddr_t loc, int asi));
    447  1.12.2.1  bouyer 
    448  1.12.2.1  bouyer static __inline__ void stba __P((paddr_t loc, int asi, u_char value));
    449  1.12.2.1  bouyer static __inline__ void stha __P((paddr_t loc, int asi, u_short value));
    450  1.12.2.1  bouyer static __inline__ void sta __P((paddr_t loc, int asi, u_int value));
    451  1.12.2.1  bouyer static __inline__ void stxa __P((paddr_t loc, int asi, u_int64_t value));
    452  1.12.2.1  bouyer static __inline__ void stda __P((paddr_t loc, int asi, u_int64_t value));
    453  1.12.2.1  bouyer 
    454  1.12.2.1  bouyer #if 0
    455  1.12.2.1  bouyer static __inline__ unsigned int casa __P((paddr_t loc, int asi,
    456  1.12.2.1  bouyer 	unsigned int value, unsigned int oldvalue));
    457  1.12.2.1  bouyer static __inline__ u_int64_t casxa __P((paddr_t loc, int asi,
    458  1.12.2.1  bouyer 	u_int64_t value, u_int64_t oldvalue));
    459  1.12.2.2  bouyer #endif
    460  1.12.2.1  bouyer 
    461  1.12.2.1  bouyer #ifdef __arch64__
    462  1.12.2.1  bouyer static __inline__ u_char
    463  1.12.2.1  bouyer lduba(paddr_t loc, int asi)
    464  1.12.2.1  bouyer {
    465  1.12.2.1  bouyer 	register unsigned int _lduba_v;
    466  1.12.2.1  bouyer 
    467  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    468  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    469  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    470  1.12.2.1  bouyer " lduba [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    471  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" :
    472  1.12.2.1  bouyer 				 "=&r" (_lduba_v), "=r" (loc):
    473  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    474  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    475  1.12.2.1  bouyer 	} else {
    476  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; lduba [%1]%%asi,%0" :
    477  1.12.2.1  bouyer 				 "=r" (_lduba_v) :
    478  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    479  1.12.2.1  bouyer 	}
    480  1.12.2.1  bouyer 	return (_lduba_v);
    481  1.12.2.1  bouyer }
    482  1.12.2.1  bouyer #else
    483  1.12.2.1  bouyer static __inline__ u_char
    484  1.12.2.1  bouyer lduba(paddr_t loc, int asi)
    485  1.12.2.1  bouyer {
    486  1.12.2.1  bouyer 	register unsigned int _lduba_v, _loc_hi, _pstate;
    487  1.12.2.1  bouyer 
    488  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    489  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    490  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; "
    491  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; rdpr %%pstate,%1; "
    492  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; wrpr %1,8,%%pstate; "
    493  1.12.2.1  bouyer " membar #Sync; lduba [%0]%%asi,%0; wrpr %1,0,%%pstate; "
    494  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" :
    495  1.12.2.1  bouyer 				 "=&r" (_lduba_v),  "=&r" (_pstate) :
    496  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    497  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    498  1.12.2.1  bouyer 	} else {
    499  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; "
    500  1.12.2.1  bouyer " or %0,%1,%0; lduba [%0]%%asi,%0" : "=&r" (_lduba_v) :
    501  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    502  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi));
    503  1.12.2.1  bouyer 	}
    504  1.12.2.1  bouyer 	return (_lduba_v);
    505  1.12.2.1  bouyer }
    506  1.12.2.1  bouyer #endif
    507  1.12.2.1  bouyer 
    508  1.12.2.1  bouyer #ifdef __arch64__
    509  1.12.2.1  bouyer /* load half-word from alternate address space */
    510  1.12.2.1  bouyer static __inline__ u_short
    511  1.12.2.1  bouyer lduha(paddr_t loc, int asi)
    512  1.12.2.1  bouyer {
    513  1.12.2.1  bouyer 	register unsigned int _lduha_v;
    514  1.12.2.1  bouyer 
    515  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    516  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    517  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    518  1.12.2.1  bouyer " lduha [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    519  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lduha_v), "=r" (loc) :
    520  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    521  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    522  1.12.2.1  bouyer 	} else {
    523  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; lduha [%1]%%asi,%0" :
    524  1.12.2.1  bouyer 				 "=r" (_lduha_v) :
    525  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    526  1.12.2.1  bouyer 	}
    527  1.12.2.1  bouyer 	return (_lduha_v);
    528  1.12.2.1  bouyer }
    529  1.12.2.1  bouyer #else
    530  1.12.2.1  bouyer /* load half-word from alternate address space */
    531  1.12.2.1  bouyer static __inline__ u_short
    532  1.12.2.1  bouyer lduha(paddr_t loc, int asi) {
    533  1.12.2.1  bouyer 	register unsigned int _lduha_v, _loc_hi, _pstate;
    534  1.12.2.1  bouyer 
    535  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    536  1.12.2.1  bouyer 
    537  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    538  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1; "
    539  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; sllx %3,32,%0; "
    540  1.12.2.1  bouyer " or %0,%2,%0; membar #Sync; lduha [%0]%%asi,%0; wrpr %1,0,%%pstate; "
    541  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" :
    542  1.12.2.1  bouyer 				 "=&r" (_lduha_v), "=&r" (_pstate) :
    543  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    544  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    545  1.12.2.1  bouyer 	} else {
    546  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; "
    547  1.12.2.1  bouyer " or %0,%1,%0; lduha [%0]%%asi,%0" : "=&r" (_lduha_v) :
    548  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi));
    549  1.12.2.1  bouyer 	}
    550  1.12.2.1  bouyer 	return (_lduha_v);
    551  1.12.2.1  bouyer }
    552  1.12.2.1  bouyer #endif
    553  1.12.2.1  bouyer 
    554  1.12.2.1  bouyer 
    555  1.12.2.1  bouyer #ifdef __arch64__
    556  1.12.2.1  bouyer /* load unsigned int from alternate address space */
    557  1.12.2.1  bouyer static __inline__ u_int
    558  1.12.2.1  bouyer lda(paddr_t loc, int asi)
    559  1.12.2.1  bouyer {
    560  1.12.2.1  bouyer 	register unsigned int _lda_v;
    561  1.12.2.1  bouyer 
    562  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    563  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    564  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    565  1.12.2.1  bouyer " lda [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    566  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) :
    567  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    568  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    569  1.12.2.1  bouyer 	} else {
    570  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; lda [%1]%%asi,%0" :
    571  1.12.2.1  bouyer 				 "=r" (_lda_v) :
    572  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    573  1.12.2.1  bouyer 	}
    574  1.12.2.1  bouyer 	return (_lda_v);
    575  1.12.2.1  bouyer }
    576  1.12.2.1  bouyer 
    577  1.12.2.1  bouyer /* load signed int from alternate address space */
    578  1.12.2.1  bouyer static __inline__ int
    579  1.12.2.1  bouyer ldswa(paddr_t loc, int asi)
    580  1.12.2.1  bouyer {
    581  1.12.2.1  bouyer 	register int _lda_v;
    582  1.12.2.1  bouyer 
    583  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    584  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    585  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    586  1.12.2.1  bouyer " ldswa [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    587  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) :
    588  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    589  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    590  1.12.2.1  bouyer 	} else {
    591  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; ldswa [%1]%%asi,%0" :
    592  1.12.2.1  bouyer 				 "=r" (_lda_v) :
    593  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    594  1.12.2.1  bouyer 	}
    595  1.12.2.1  bouyer 	return (_lda_v);
    596  1.12.2.1  bouyer }
    597  1.12.2.1  bouyer #else	/* __arch64__ */
    598  1.12.2.1  bouyer /* load unsigned int from alternate address space */
    599  1.12.2.1  bouyer static __inline__ u_int
    600  1.12.2.1  bouyer lda(paddr_t loc, int asi)
    601  1.12.2.1  bouyer {
    602  1.12.2.1  bouyer 	register unsigned int _lda_v, _loc_hi, _pstate;
    603  1.12.2.1  bouyer 
    604  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    605  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    606  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;"
    607  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; "
    608  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; membar #Sync;lda [%0]%%asi,%0; "
    609  1.12.2.1  bouyer " wrpr %1,0,%%pstate; andn %2,0x1f,%1; membar #Sync; "
    610  1.12.2.1  bouyer " stxa %%g0,[%1] %5; membar #Sync" : "=&r" (_lda_v), "=&r" (_pstate) :
    611  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    612  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    613  1.12.2.1  bouyer 	} else {
    614  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; "
    615  1.12.2.1  bouyer " or %0,%1,%0; lda [%0]%%asi,%0" : "=&r" (_lda_v) :
    616  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    617  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi));
    618  1.12.2.1  bouyer 	}
    619  1.12.2.1  bouyer 	return (_lda_v);
    620  1.12.2.1  bouyer }
    621  1.12.2.1  bouyer 
    622  1.12.2.1  bouyer /* load signed int from alternate address space */
    623  1.12.2.1  bouyer static __inline__ int
    624  1.12.2.1  bouyer ldswa(paddr_t loc, int asi)
    625  1.12.2.1  bouyer {
    626  1.12.2.1  bouyer 	register int _lda_v, _loc_hi, _pstate;
    627  1.12.2.1  bouyer 
    628  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    629  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    630  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;"
    631  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; sllx %3,32,%0;"
    632  1.12.2.1  bouyer " or %0,%2,%0; membar #Sync; ldswa [%0]%%asi,%0; wrpr %1,0,%%pstate; "
    633  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" :
    634  1.12.2.1  bouyer 				 "=&r" (_lda_v), "=&r" (_pstate) :
    635  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    636  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    637  1.12.2.1  bouyer 	} else {
    638  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; "
    639  1.12.2.1  bouyer " or %0,%1,%0; ldswa [%0]%%asi,%0" : "=&r" (_lda_v) :
    640  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    641  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi));
    642  1.12.2.1  bouyer 	}
    643  1.12.2.1  bouyer 	return (_lda_v);
    644  1.12.2.1  bouyer }
    645  1.12.2.1  bouyer #endif /* __arch64__ */
    646  1.12.2.1  bouyer 
    647  1.12.2.1  bouyer #ifdef	__arch64__
    648  1.12.2.1  bouyer /* load 64-bit int from alternate address space -- these should never be used */
    649  1.12.2.1  bouyer static __inline__ u_int64_t
    650  1.12.2.1  bouyer ldda(paddr_t loc, int asi)
    651  1.12.2.1  bouyer {
    652  1.12.2.1  bouyer 	register long long _lda_v;
    653  1.12.2.1  bouyer 
    654  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    655  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    656  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    657  1.12.2.1  bouyer " ldda [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    658  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=&r" (loc) :
    659  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    660  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    661  1.12.2.1  bouyer 	} else {
    662  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; ldda [%1]%%asi,%0" :
    663  1.12.2.1  bouyer 				 "=r" (_lda_v) :
    664  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    665  1.12.2.1  bouyer 	}
    666  1.12.2.1  bouyer 	return (_lda_v);
    667  1.12.2.1  bouyer }
    668  1.12.2.1  bouyer #else
    669  1.12.2.1  bouyer /* load 64-bit int from alternate address space */
    670  1.12.2.1  bouyer static __inline__ u_int64_t
    671  1.12.2.1  bouyer ldda(paddr_t loc, int asi)
    672  1.12.2.1  bouyer {
    673  1.12.2.1  bouyer 	register long long _lda_v, _loc_hi, _pstate;
    674  1.12.2.1  bouyer 
    675  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    676  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    677  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;"
    678  1.12.2.1  bouyer " andn %2,0x1f,%0; rdpr %%pstate,%1; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate;"
    679  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; membar #Sync; ldda [%0]%%asi,%0; wrpr %1,0,%%pstate; "
    680  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" :
    681  1.12.2.1  bouyer 				 "=&r" (_lda_v), "=&r" (_pstate) :
    682  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    683  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    684  1.12.2.1  bouyer 	} else {
    685  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; "
    686  1.12.2.1  bouyer " or %0,%1,%0; ldda [%0]%%asi,%0" : "=&r" (_lda_v) :
    687  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi));
    688  1.12.2.1  bouyer 	}
    689  1.12.2.1  bouyer 	return (_lda_v);
    690  1.12.2.1  bouyer }
    691  1.12.2.1  bouyer #endif
    692  1.12.2.1  bouyer 
    693  1.12.2.1  bouyer 
    694  1.12.2.1  bouyer #ifdef __arch64__
    695  1.12.2.1  bouyer /* native load 64-bit int from alternate address space w/64-bit compiler*/
    696  1.12.2.1  bouyer static __inline__ u_int64_t
    697  1.12.2.1  bouyer ldxa(paddr_t loc, int asi)
    698  1.12.2.1  bouyer {
    699  1.12.2.1  bouyer 	register unsigned long _lda_v;
    700  1.12.2.1  bouyer 
    701  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    702  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "
    703  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; "
    704  1.12.2.1  bouyer " ldxa [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; "
    705  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) :
    706  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)),
    707  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    708  1.12.2.1  bouyer 	} else {
    709  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%0" :
    710  1.12.2.1  bouyer 				 "=r" (_lda_v) :
    711  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (asi));
    712  1.12.2.1  bouyer 	}
    713  1.12.2.1  bouyer 	return (_lda_v);
    714  1.12.2.1  bouyer }
    715  1.12.2.1  bouyer #else
    716  1.12.2.1  bouyer /* native load 64-bit int from alternate address space w/32-bit compiler*/
    717  1.12.2.1  bouyer static __inline__ u_int64_t
    718  1.12.2.1  bouyer ldxa(paddr_t loc, int asi)
    719  1.12.2.1  bouyer {
    720  1.12.2.1  bouyer 	register unsigned long _ldxa_lo, _ldxa_hi, _loc_hi;
    721  1.12.2.1  bouyer 
    722  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    723  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    724  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; "
    725  1.12.2.1  bouyer " andn %2,0x1f,%0; rdpr %%pstate,%1; stxa %%g0,[%0] %5; "
    726  1.12.2.1  bouyer " sllx %3,32,%0; wrpr %1,8,%%pstate; or %0,%2,%0; membar #Sync; ldxa [%0]%%asi,%0; "
    727  1.12.2.1  bouyer " wrpr %1,0,%%pstate; andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync; "
    728  1.12.2.1  bouyer " srlx %0,32,%1; srl %0,0,%0" :
    729  1.12.2.1  bouyer 				 "=&r" (_ldxa_lo), "=&r" (_ldxa_hi) :
    730  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    731  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG));
    732  1.12.2.1  bouyer 	} else {
    733  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; "
    734  1.12.2.1  bouyer " or %0,%2,%0; ldxa [%0]%%asi,%0; srlx %0,32,%1; srl %0,0,%0;" :
    735  1.12.2.1  bouyer 				 "=&r" (_ldxa_lo), "=&r" (_ldxa_hi) :
    736  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    737  1.12.2.1  bouyer 				 "r" (asi));
    738  1.12.2.1  bouyer 	}
    739  1.12.2.1  bouyer 	return ((((int64_t)_ldxa_hi)<<32)|_ldxa_lo);
    740  1.12.2.1  bouyer }
    741  1.12.2.1  bouyer #endif
    742  1.12.2.1  bouyer 
    743  1.12.2.1  bouyer /* store byte to alternate address space */
    744  1.12.2.1  bouyer #ifdef __arch64__
    745  1.12.2.1  bouyer static __inline__ void
    746  1.12.2.1  bouyer stba(paddr_t loc, int asi, u_char value)
    747  1.12.2.1  bouyer {
    748  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    749  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stba %1,[%2]%%asi;"
    750  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" :
    751  1.12.2.1  bouyer 			"=&r" (loc) :
    752  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    753  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG));
    754  1.12.2.1  bouyer 	} else {
    755  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; stba %0,[%1]%%asi" : :
    756  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    757  1.12.2.1  bouyer 			"r" (asi));
    758  1.12.2.1  bouyer 	}
    759  1.12.2.1  bouyer }
    760  1.12.2.1  bouyer #else
    761  1.12.2.1  bouyer static __inline__ void
    762  1.12.2.1  bouyer stba(paddr_t loc, int asi, u_char value)
    763  1.12.2.1  bouyer {
    764  1.12.2.1  bouyer 	register int _loc_hi, _pstate;
    765  1.12.2.1  bouyer 
    766  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    767  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    768  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;"
    769  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stba %2,[%0]%%asi; wrpr %1,0,%%pstate; "
    770  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" :
    771  1.12.2.1  bouyer 				 "=&r" (_loc_hi), "=&r" (_pstate) :
    772  1.12.2.1  bouyer 				 "r" ((int)(value)), "r" ((unsigned long)(loc)),
    773  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG));
    774  1.12.2.1  bouyer 	} else {
    775  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; "
    776  1.12.2.1  bouyer " or %2,%0,%0; stba %1,[%0]%%asi" : "=&r" (_loc_hi) :
    777  1.12.2.1  bouyer 				 "r" ((int)(value)), "r" ((unsigned long)(loc)),
    778  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi));
    779  1.12.2.1  bouyer 	}
    780  1.12.2.1  bouyer }
    781  1.12.2.1  bouyer #endif
    782  1.12.2.1  bouyer 
    783  1.12.2.1  bouyer /* store half-word to alternate address space */
    784  1.12.2.1  bouyer #ifdef __arch64__
    785  1.12.2.1  bouyer static __inline__ void
    786  1.12.2.1  bouyer stha(paddr_t loc, int asi, u_short value)
    787  1.12.2.1  bouyer {
    788  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    789  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stha %1,[%2]%%asi;"
    790  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" :
    791  1.12.2.1  bouyer 			"=&r" (loc) :
    792  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    793  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    794  1.12.2.1  bouyer 	} else {
    795  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; stha %0,[%1]%%asi" : :
    796  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    797  1.12.2.1  bouyer 			"r" (asi) : "memory");
    798  1.12.2.1  bouyer 	}
    799  1.12.2.1  bouyer }
    800  1.12.2.1  bouyer #else
    801  1.12.2.1  bouyer static __inline__ void
    802  1.12.2.1  bouyer stha(paddr_t loc, int asi, u_short value)
    803  1.12.2.1  bouyer {
    804  1.12.2.1  bouyer 	register int _loc_hi, _pstate;
    805  1.12.2.1  bouyer 
    806  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    807  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    808  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;"
    809  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stha %2,[%0]%%asi; wrpr %1,0,%%pstate; "
    810  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" :
    811  1.12.2.1  bouyer 			"=&r" (_loc_hi), "=&r" (_pstate) :
    812  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    813  1.12.2.1  bouyer 			"r" (_loc_hi), "r" (asi),
    814  1.12.2.1  bouyer 			"n" (ASI_DCACHE_TAG) : "memory");
    815  1.12.2.1  bouyer 	} else {
    816  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; "
    817  1.12.2.1  bouyer " or %2,%0,%0; stha %1,[%0]%%asi" : "=&r" (_loc_hi) :
    818  1.12.2.1  bouyer 				 "r" ((int)(value)), "r" ((unsigned long)(loc)),
    819  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi) : "memory");
    820  1.12.2.1  bouyer 	}
    821  1.12.2.1  bouyer }
    822  1.12.2.1  bouyer #endif
    823  1.12.2.1  bouyer 
    824  1.12.2.1  bouyer 
    825  1.12.2.1  bouyer /* store int to alternate address space */
    826  1.12.2.1  bouyer #ifdef __arch64__
    827  1.12.2.1  bouyer static __inline__ void
    828  1.12.2.1  bouyer sta(paddr_t loc, int asi, u_int value)
    829  1.12.2.1  bouyer {
    830  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    831  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sta %1,[%2]%%asi;"
    832  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" :
    833  1.12.2.1  bouyer 			"=&r" (loc) :
    834  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    835  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    836  1.12.2.1  bouyer 	} else {
    837  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; sta %0,[%1]%%asi" : :
    838  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    839  1.12.2.1  bouyer 			"r" (asi) : "memory");
    840  1.12.2.1  bouyer 	}
    841  1.12.2.1  bouyer }
    842  1.12.2.1  bouyer #else
    843  1.12.2.1  bouyer static __inline__ void
    844  1.12.2.1  bouyer sta(paddr_t loc, int asi, u_int value)
    845  1.12.2.1  bouyer {
    846  1.12.2.1  bouyer 	register int _loc_hi, _pstate;
    847  1.12.2.1  bouyer 
    848  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    849  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    850  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;"
    851  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; sta %2,[%0]%%asi; wrpr %1,0,%%pstate; "
    852  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" :
    853  1.12.2.1  bouyer 			"=&r" (_loc_hi), "=&r" (_pstate) :
    854  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)),
    855  1.12.2.1  bouyer 			"r" (_loc_hi), "r" (asi),
    856  1.12.2.1  bouyer 			"n" (ASI_DCACHE_TAG) : "memory");
    857  1.12.2.1  bouyer 	} else {
    858  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; "
    859  1.12.2.1  bouyer " or %2,%0,%0; sta %1,[%0]%%asi" : "=&r" (_loc_hi) :
    860  1.12.2.1  bouyer 				 "r" ((int)(value)), "r" ((unsigned long)(loc)),
    861  1.12.2.1  bouyer 				 "r" (_loc_hi), "r" (asi) : "memory");
    862  1.12.2.1  bouyer 	}
    863  1.12.2.1  bouyer }
    864  1.12.2.1  bouyer #endif
    865  1.12.2.1  bouyer 
    866  1.12.2.1  bouyer /* store 64-bit int to alternate address space */
    867  1.12.2.1  bouyer #ifdef __arch64__
    868  1.12.2.1  bouyer static __inline__ void
    869  1.12.2.1  bouyer stda(paddr_t loc, int asi, u_int64_t value)
    870  1.12.2.1  bouyer {
    871  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    872  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stda %1,[%2]%%asi;"
    873  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" :
    874  1.12.2.1  bouyer 			"=&r" (loc) :
    875  1.12.2.1  bouyer 			"r" ((long long)(value)), "r" ((unsigned long)(loc)),
    876  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    877  1.12.2.1  bouyer 	} else {
    878  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; stda %0,[%1]%%asi" : :
    879  1.12.2.1  bouyer 			"r" ((long long)(value)), "r" ((unsigned long)(loc)),
    880  1.12.2.1  bouyer 			"r" (asi) : "memory");
    881  1.12.2.1  bouyer 	}
    882  1.12.2.1  bouyer }
    883  1.12.2.1  bouyer #else
    884  1.12.2.1  bouyer static __inline__ void
    885  1.12.2.1  bouyer stda(paddr_t loc, int asi, u_int64_t value)
    886  1.12.2.1  bouyer {
    887  1.12.2.1  bouyer 	register int _loc_hi, _pstate;
    888  1.12.2.1  bouyer 
    889  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)loc)>>32);
    890  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    891  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1; "
    892  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stda %2,[%0]%%asi; wrpr %1,0,%%pstate;"
    893  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" :
    894  1.12.2.1  bouyer 			"=&r" (_loc_hi), "=&r" (_pstate) :
    895  1.12.2.1  bouyer 			"r" ((long long)(value)), "r" ((unsigned long)(loc)),
    896  1.12.2.1  bouyer 			"r" (_loc_hi), "r" (asi),
    897  1.12.2.1  bouyer 			"n" (ASI_DCACHE_TAG) : "memory");
    898  1.12.2.1  bouyer 	} else {
    899  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; "
    900  1.12.2.1  bouyer " or %2,%0,%0; stda %1,[%0]%%asi" :
    901  1.12.2.1  bouyer 			"=&r" (_loc_hi) :
    902  1.12.2.1  bouyer 			"r" ((long long)(value)), "r" ((unsigned long)(loc)),
    903  1.12.2.1  bouyer 			"r" (_loc_hi), "r" (asi) : "memory");
    904  1.12.2.1  bouyer 	}
    905  1.12.2.1  bouyer }
    906  1.12.2.1  bouyer #endif
    907  1.12.2.1  bouyer 
    908  1.12.2.1  bouyer #ifdef __arch64__
    909  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/64-bit compiler*/
    910  1.12.2.1  bouyer static __inline__ void
    911  1.12.2.1  bouyer stxa(paddr_t loc, int asi, u_int64_t value)
    912  1.12.2.1  bouyer {
    913  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    914  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stxa %1,[%2]%%asi;"
    915  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" :
    916  1.12.2.1  bouyer 			"=&r" (asi) :
    917  1.12.2.1  bouyer 			"r" ((unsigned long)(value)),
    918  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)),
    919  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    920  1.12.2.1  bouyer 	} else {
    921  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; stxa %0,[%1]%%asi" : :
    922  1.12.2.1  bouyer 			"r" ((unsigned long)(value)),
    923  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), "r" (asi) : "memory");
    924  1.12.2.1  bouyer 	}
    925  1.12.2.1  bouyer }
    926  1.12.2.1  bouyer #else
    927  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/32-bit compiler*/
    928  1.12.2.1  bouyer static __inline__ void
    929  1.12.2.1  bouyer stxa(paddr_t loc, int asi, u_int64_t value)
    930  1.12.2.1  bouyer {
    931  1.12.2.1  bouyer 	int _stxa_lo, _stxa_hi, _loc_hi;
    932  1.12.2.1  bouyer 
    933  1.12.2.1  bouyer 	_stxa_lo = value;
    934  1.12.2.1  bouyer 	_stxa_hi = ((u_int64_t)value)>>32;
    935  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)(u_long)loc)>>32);
    936  1.12.2.1  bouyer 
    937  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    938  1.12.2.1  bouyer 		__asm __volatile("wr %7,%%g0,%%asi; sllx %4,32,%1; sllx %6,32,%0; "
    939  1.12.2.1  bouyer " or %1,%3,%1; rdpr %%pstate,%2; or %0,%5,%0; wrpr %2,8,%%pstate; "
    940  1.12.2.1  bouyer " stxa %1,[%0]%%asi; wrpr %2,0,%%pstate; "
    941  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %8; membar #Sync" :
    942  1.12.2.1  bouyer 				 "=&r" (_loc_hi), "=&r" (_stxa_hi),
    943  1.12.2.1  bouyer 				 "=&r" ((int)(_stxa_lo)) :
    944  1.12.2.1  bouyer 				 "r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)),
    945  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    946  1.12.2.1  bouyer 				 "r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    947  1.12.2.1  bouyer 	} else {
    948  1.12.2.1  bouyer 		__asm __volatile("wr %6,%%g0,%%asi; sllx %3,32,%1; sllx %5,32,%0; "
    949  1.12.2.1  bouyer " or %1,%2,%1; or %0,%4,%0; stxa %1,[%0]%%asi" :
    950  1.12.2.1  bouyer 				 "=&r" (_loc_hi), "=&r" (_stxa_hi) :
    951  1.12.2.1  bouyer 				 "r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)),
    952  1.12.2.1  bouyer 				 "r" ((unsigned long)(loc)), "r" (_loc_hi),
    953  1.12.2.1  bouyer 				 "r" (asi) : "memory");
    954  1.12.2.1  bouyer 	}
    955  1.12.2.1  bouyer }
    956  1.12.2.1  bouyer #endif
    957       1.6     eeh 
    958  1.12.2.2  bouyer #if 0
    959       1.9     eeh #ifdef __arch64__
    960  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/64-bit compiler*/
    961  1.12.2.1  bouyer static __inline__ u_int64_t
    962  1.12.2.1  bouyer casxa(paddr_t loc, int asi, u_int64_t value, u_int64_t oldvalue)
    963  1.12.2.1  bouyer {
    964  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    965  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; casxa [%3]%%asi,%2,%1;"
    966  1.12.2.1  bouyer " andn %3,0x1f,%0; membar #Sync; stxa %%g0,[%0] %5; membar #Sync" :
    967  1.12.2.1  bouyer 			"=&r" (loc), "+r" (value) :
    968  1.12.2.1  bouyer 			"r" ((unsigned long)(oldvalue)),
    969  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)),
    970  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
    971  1.12.2.1  bouyer 	} else {
    972  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; casxa [%1]%%asi,%2,%0" :
    973  1.12.2.1  bouyer 			"+r" (value) :
    974  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), "r" (oldvalue), "r" (asi) :
    975  1.12.2.1  bouyer 			"memory");
    976  1.12.2.1  bouyer 	}
    977  1.12.2.1  bouyer 	return (value);
    978  1.12.2.1  bouyer }
    979  1.12.2.1  bouyer #else
    980  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/32-bit compiler*/
    981  1.12.2.1  bouyer static __inline__ u_int64_t
    982  1.12.2.1  bouyer casxa(paddr_t loc, int asi, u_int64_t value, u_int64_t oldvalue)
    983  1.12.2.1  bouyer {
    984  1.12.2.1  bouyer 	int _casxa_lo, _casxa_hi, _loc_hi, _oval_hi;
    985  1.12.2.1  bouyer 
    986  1.12.2.1  bouyer 	_casxa_lo = value;
    987  1.12.2.1  bouyer 	_casxa_hi = ((u_int64_t)value)>>32;
    988  1.12.2.1  bouyer 	_oval_hi = ((u_int64_t)oldvalue)>>32;
    989  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)(u_long)loc)>>32);
    990  1.12.2.1  bouyer 
    991  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) {
    992  1.12.2.1  bouyer 		__asm __volatile("wr %7,%%g0,%%asi; sllx %1,32,%1; sllx %5,32,%0; "
    993  1.12.2.1  bouyer " sllx %3,32,%3; or %1,%2,%1; rdpr %%pstate,%2; or %0,%4,%0; or %3,%6,%3; "
    994  1.12.2.1  bouyer " wrpr %2,8,%%pstate; casxa [%0]%%asi,%3,%1; wrpr %2,0,%%pstate; "
    995  1.12.2.1  bouyer " andn %0,0x1f,%3;  membar #Sync; stxa %%g0,[%3] %8; membar #Sync; "
    996  1.12.2.1  bouyer " sll %1,0,%2; srax %1,32,%1 " :
    997  1.12.2.1  bouyer 			"=&r" (_loc_hi), "+r" (_casxa_hi),
    998  1.12.2.1  bouyer 			"+r" (_casxa_lo), "+r" (_oval_hi) :
    999  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), "r" (_loc_hi),
   1000  1.12.2.1  bouyer 			"r" ((unsigned int)(oval))
   1001  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG) : "memory");
   1002  1.12.2.1  bouyer 	} else {
   1003  1.12.2.1  bouyer 		__asm __volatile("wr %7,%%g0,%%asi; sllx %1,32,%1; sllx %5,32,%0; "
   1004  1.12.2.1  bouyer " or %1,%2,%1; sllx %3,32,%2; or %0,%4,%0; or %2,%4,%2; "
   1005  1.12.2.1  bouyer " casxa [%0]%%asi,%2,%1; sll %1,0,%2; srax %o1,32,%o1 " :
   1006  1.12.2.1  bouyer 			"=&r" (_loc_hi), "+r" (_casxa_hi), "+r" (_casxa_lo) :
   1007  1.12.2.1  bouyer 			"r" ((int)(_oval_hi)), "r" ((int)(oval)),
   1008  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), "r" (_loc_hi),
   1009  1.12.2.1  bouyer 			"r" (asi) : "memory");
   1010  1.12.2.1  bouyer 	}
   1011  1.12.2.1  bouyer }
   1012  1.12.2.1  bouyer #endif
   1013  1.12.2.2  bouyer #endif /* 0 */
   1014  1.12.2.1  bouyer 
   1015  1.12.2.1  bouyer #if 0
   1016  1.12.2.1  bouyer #ifdef __arch64__
   1017       1.2     eeh /* load byte from alternate address space */
   1018       1.6     eeh #define	lduba(loc, asi) ({ \
   1019  1.12.2.1  bouyer 	register unsigned int _lduba_v; \
   1020  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1021  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; " \
   1022  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1023  1.12.2.1  bouyer " lduba [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1024  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : \
   1025  1.12.2.1  bouyer 		"=&r" (_lduba_v), "=r" (loc): \
   1026  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1027       1.6     eeh 	} else { \
   1028  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; lduba [%1]%%asi,%0" : \
   1029  1.12.2.1  bouyer 		"=r" (_lduba_v) : \
   1030  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1031       1.6     eeh 	} \
   1032       1.6     eeh 	_lduba_v; \
   1033       1.6     eeh })
   1034       1.6     eeh #else
   1035       1.9     eeh /* load byte from alternate address space */
   1036       1.9     eeh #define	lduba(loc, asi) ({ \
   1037  1.12.2.1  bouyer 	register unsigned int _lduba_v, _loc_hi, _pstate; \
   1038       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1039  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1040  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; " \
   1041  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; rdpr %%pstate,%1; " \
   1042  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; wrpr %1,8,%%pstate; " \
   1043  1.12.2.1  bouyer " membar #Sync; lduba [%0]%%asi,%0; wrpr %1,0,%%pstate; " \
   1044  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" : \
   1045  1.12.2.1  bouyer 		"=&r" (_lduba_v),  "=&r" (_pstate) : \
   1046  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1047       1.9     eeh 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1048       1.9     eeh 	} else { \
   1049       1.9     eeh 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
   1050       1.9     eeh " or %0,%1,%0; lduba [%0]%%asi,%0" : "=&r" (_lduba_v) : \
   1051  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1052       1.9     eeh 	} \
   1053       1.9     eeh 	_lduba_v; \
   1054       1.9     eeh })
   1055       1.9     eeh #endif
   1056       1.2     eeh 
   1057       1.9     eeh #ifdef __arch64__
   1058       1.2     eeh /* load half-word from alternate address space */
   1059       1.6     eeh #define	lduha(loc, asi) ({ \
   1060  1.12.2.1  bouyer 	register unsigned int _lduha_v; \
   1061  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1062  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; " \
   1063  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1064  1.12.2.1  bouyer " lduha [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1065  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lduha_v), "=r" (loc) : \
   1066  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1067       1.6     eeh 	} else { \
   1068       1.6     eeh 		__asm __volatile("wr %2,%%g0,%%asi; lduha [%1]%%asi,%0" : "=r" (_lduha_v) : \
   1069  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1070       1.6     eeh 	} \
   1071       1.6     eeh 	_lduha_v; \
   1072       1.6     eeh })
   1073       1.6     eeh #else
   1074       1.9     eeh /* load half-word from alternate address space */
   1075       1.9     eeh #define	lduha(loc, asi) ({ \
   1076  1.12.2.1  bouyer 	register unsigned int _lduha_v, _loc_hi, _pstate; \
   1077       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1078  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1079  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1; " \
   1080  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; sllx %3,32,%0; " \
   1081  1.12.2.1  bouyer " or %0,%2,%0; membar #Sync; lduha [%0]%%asi,%0; wrpr %1,0,%%pstate; " \
   1082  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" : \
   1083  1.12.2.1  bouyer 		"=&r" (_lduha_v), "=&r" (_pstate) : \
   1084  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1085       1.9     eeh 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1086       1.9     eeh 	} else { \
   1087       1.9     eeh 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
   1088       1.9     eeh " or %0,%1,%0; lduha [%0]%%asi,%0" : "=&r" (_lduha_v) : \
   1089  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1090       1.9     eeh 	} \
   1091       1.9     eeh 	_lduha_v; \
   1092       1.9     eeh })
   1093       1.9     eeh #endif
   1094       1.2     eeh 
   1095       1.9     eeh #ifdef __arch64__
   1096       1.6     eeh /* load unsigned int from alternate address space */
   1097       1.6     eeh #define	lda(loc, asi) ({ \
   1098  1.12.2.1  bouyer 	register unsigned int _lda_v; \
   1099  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1100  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; " \
   1101  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1102  1.12.2.1  bouyer " lda [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1103  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) : \
   1104  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1105       1.6     eeh 	} else { \
   1106       1.6     eeh 		__asm __volatile("wr %2,%%g0,%%asi; lda [%1]%%asi,%0" : "=r" (_lda_v) : \
   1107  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1108       1.6     eeh 	} \
   1109       1.6     eeh 	_lda_v; \
   1110       1.6     eeh })
   1111       1.6     eeh 
   1112       1.6     eeh /* load signed int from alternate address space */
   1113       1.6     eeh #define	ldswa(loc, asi) ({ \
   1114       1.6     eeh 	register int _lda_v; \
   1115  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1116  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; " \
   1117  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1118  1.12.2.1  bouyer " ldswa [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1119  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) : \
   1120  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1121       1.6     eeh 	} else { \
   1122       1.6     eeh 		__asm __volatile("wr %2,%%g0,%%asi; ldswa [%1]%%asi,%0" : "=r" (_lda_v) : \
   1123  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1124       1.6     eeh 	} \
   1125       1.6     eeh 	_lda_v; \
   1126       1.6     eeh })
   1127       1.9     eeh #else	/* __arch64__ */
   1128       1.9     eeh /* load unsigned int from alternate address space */
   1129       1.9     eeh #define	lda(loc, asi) ({ \
   1130  1.12.2.1  bouyer 	register unsigned int _lda_v, _loc_hi, _pstate; \
   1131       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1132  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1133  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;" \
   1134  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; " \
   1135  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; membar #Sync;lda [%0]%%asi,%0; " \
   1136  1.12.2.1  bouyer " wrpr %1,0,%%pstate; andn %2,0x1f,%1; membar #Sync; " \
   1137  1.12.2.1  bouyer " stxa %%g0,[%1] %5; membar #Sync" : "=&r" (_lda_v), "=&r" (_pstate) : \
   1138  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1139       1.9     eeh 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1140       1.9     eeh 	} else { \
   1141       1.9     eeh 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
   1142       1.9     eeh " or %0,%1,%0; lda [%0]%%asi,%0" : "=&r" (_lda_v) : \
   1143  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1144       1.9     eeh 	} \
   1145       1.9     eeh 	_lda_v; \
   1146       1.9     eeh })
   1147       1.9     eeh 
   1148       1.9     eeh /* load signed int from alternate address space */
   1149       1.9     eeh #define	ldswa(loc, asi) ({ \
   1150  1.12.2.1  bouyer 	register int _lda_v, _loc_hi, _pstate; \
   1151       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1152  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1153  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;" \
   1154  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate; sllx %3,32,%0;" \
   1155  1.12.2.1  bouyer " or %0,%2,%0; membar #Sync; ldswa [%0]%%asi,%0; wrpr %1,0,%%pstate; " \
   1156  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" : \
   1157  1.12.2.1  bouyer 		"=&r" (_lda_v), "=&r" (_pstate) : \
   1158  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1159       1.9     eeh 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1160       1.9     eeh 	} else { \
   1161       1.9     eeh 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
   1162       1.9     eeh " or %0,%1,%0; ldswa [%0]%%asi,%0" : "=&r" (_lda_v) : \
   1163  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1164       1.9     eeh 	} \
   1165       1.9     eeh 	_lda_v; \
   1166       1.9     eeh })
   1167       1.9     eeh #endif /* __arch64__ */
   1168       1.6     eeh 
   1169       1.9     eeh #ifdef	__arch64__
   1170  1.12.2.1  bouyer /* load 64-bit int from alternate address space -- these should never be used */
   1171       1.6     eeh #define	ldda(loc, asi) ({ \
   1172       1.6     eeh 	register long long _lda_v; \
   1173  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1174  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; " \
   1175  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1176  1.12.2.1  bouyer " ldda [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1177  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=&r" (loc) : \
   1178  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1179       1.6     eeh 	} else { \
   1180       1.6     eeh 		__asm __volatile("wr %2,%%g0,%%asi; ldda [%1]%%asi,%0" : "=r" (_lda_v) : \
   1181  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1182       1.6     eeh 	} \
   1183       1.6     eeh 	_lda_v; \
   1184       1.2     eeh })
   1185       1.9     eeh #else
   1186       1.9     eeh /* load 64-bit int from alternate address space */
   1187       1.9     eeh #define	ldda(loc, asi) ({ \
   1188  1.12.2.1  bouyer 	register long long _lda_v, _loc_hi, _pstate; \
   1189       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1190  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1191  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; rdpr %%pstate,%1;" \
   1192  1.12.2.1  bouyer " andn %2,0x1f,%0; rdpr %%pstate,%1; stxa %%g0,[%0] %5; wrpr %1,8,%%pstate;" \
   1193  1.12.2.1  bouyer " sllx %3,32,%0; or %0,%2,%0; membar #Sync; ldda [%0]%%asi,%0; wrpr %1,0,%%pstate; " \
   1194  1.12.2.1  bouyer " andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync" : \
   1195  1.12.2.1  bouyer 		 "=&r" (_lda_v), "=&r" (_pstate) : \
   1196  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1197       1.9     eeh 	} else { \
   1198       1.9     eeh 		__asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
   1199       1.9     eeh " or %0,%1,%0; ldda [%0]%%asi,%0" : "=&r" (_lda_v) : \
   1200  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1201       1.9     eeh 	} \
   1202       1.9     eeh 	_lda_v; \
   1203       1.9     eeh })
   1204       1.9     eeh #endif
   1205       1.2     eeh 
   1206       1.6     eeh #ifdef __arch64__
   1207       1.6     eeh /* native load 64-bit int from alternate address space w/64-bit compiler*/
   1208       1.6     eeh #define	ldxa(loc, asi) ({ \
   1209  1.12.2.1  bouyer 	register unsigned long _lda_v; \
   1210  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1211  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; "\
   1212  1.12.2.1  bouyer " andn %2,0x1f,%0; stxa %%g0,[%0] %4; membar #Sync; " \
   1213  1.12.2.1  bouyer " ldxa [%2]%%asi,%0; andn %2,0x1f,%1; membar #Sync; " \
   1214  1.12.2.1  bouyer " stxa %%g0,[%1] %4; membar #Sync" : "=&r" (_lda_v), "=r" (loc) : \
   1215  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1216       1.6     eeh 	} else { \
   1217       1.6     eeh 		__asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%0" : "=r" (_lda_v) : \
   1218  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (asi)); \
   1219       1.6     eeh 	} \
   1220       1.6     eeh 	_lda_v; \
   1221       1.6     eeh })
   1222       1.6     eeh #else
   1223       1.6     eeh /* native load 64-bit int from alternate address space w/32-bit compiler*/
   1224       1.6     eeh #define	ldxa(loc, asi) ({ \
   1225  1.12.2.1  bouyer 	register unsigned long _ldxa_lo, _ldxa_hi, _loc_hi; \
   1226       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1227  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1228       1.9     eeh 		__asm __volatile("wr %4,%%g0,%%asi; " \
   1229  1.12.2.1  bouyer " andn %2,0x1f,%0; rdpr %%pstate,%1; stxa %%g0,[%0] %5; " \
   1230  1.12.2.1  bouyer " sllx %3,32,%0; wrpr %1,8,%%pstate; or %0,%2,%0; membar #Sync; ldxa [%0]%%asi,%0; " \
   1231  1.12.2.1  bouyer " wrpr %1,0,%%pstate; andn %2,0x1f,%1; membar #Sync; stxa %%g0,[%1] %5; membar #Sync; " \
   1232       1.9     eeh " srlx %0,32,%1; srl %0,0,%0" : \
   1233       1.9     eeh 		"=&r" (_ldxa_lo), "=&r" (_ldxa_hi) : \
   1234  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1235       1.9     eeh 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1236       1.6     eeh 	} else { \
   1237      1.10     eeh 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
   1238      1.10     eeh " or %0,%2,%0; ldxa [%0]%%asi,%0; srlx %0,32,%1; srl %0,0,%0;" : \
   1239       1.9     eeh 		"=&r" (_ldxa_lo), "=&r" (_ldxa_hi) : \
   1240  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1241       1.6     eeh 	} \
   1242       1.6     eeh 	((((int64_t)_ldxa_hi)<<32)|_ldxa_lo); \
   1243       1.2     eeh })
   1244       1.6     eeh #endif
   1245       1.2     eeh 
   1246       1.6     eeh 
   1247       1.6     eeh /* store byte to alternate address space */
   1248       1.9     eeh #ifdef __arch64__
   1249       1.6     eeh #define	stba(loc, asi, value) ({ \
   1250  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1251  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stba %1,[%2]%%asi;" \
   1252  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" : "=&r" (loc) : \
   1253  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1254  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1255  1.12.2.1  bouyer 	} else { \
   1256  1.12.2.1  bouyer 		__asm __volatile("wr %2,%%g0,%%asi; stba %0,[%1]%%asi" : : \
   1257  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), "r" (asi)); \
   1258  1.12.2.1  bouyer 	} \
   1259       1.6     eeh })
   1260       1.9     eeh #else
   1261       1.9     eeh #define	stba(loc, asi, value) ({ \
   1262  1.12.2.1  bouyer 	register int _loc_hi, _pstate; \
   1263       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1264  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1265  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;" \
   1266  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stba %2,[%0]%%asi; wrpr %1,0,%%pstate; " \
   1267  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" : \
   1268  1.12.2.1  bouyer 		"=&r" (_loc_hi), "=&r" (_pstate) : \
   1269  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1270  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1271  1.12.2.1  bouyer 	} else { \
   1272  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
   1273       1.9     eeh " or %2,%0,%0; stba %1,[%0]%%asi" : "=&r" (_loc_hi) : \
   1274  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1275  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi)); \
   1276  1.12.2.1  bouyer 	} \
   1277       1.9     eeh })
   1278       1.9     eeh #endif
   1279       1.6     eeh 
   1280       1.6     eeh /* store half-word to alternate address space */
   1281       1.9     eeh #ifdef __arch64__
   1282       1.6     eeh #define	stha(loc, asi, value) ({ \
   1283  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1284  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stha %1,[%2]%%asi;" \
   1285  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" : "=&r" (loc) : \
   1286  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1287  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1288  1.12.2.1  bouyer 	} else { \
   1289       1.6     eeh 	__asm __volatile("wr %2,%%g0,%%asi; stha %0,[%1]%%asi" : : \
   1290  1.12.2.1  bouyer 	    "r" ((int)(value)), "r" ((unsigned long)(loc)), "r" (asi)); \
   1291  1.12.2.1  bouyer 	} \
   1292       1.6     eeh })
   1293       1.9     eeh #else
   1294       1.9     eeh #define	stha(loc, asi, value) ({ \
   1295  1.12.2.1  bouyer 	register int _loc_hi, _pstate; \
   1296       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1297  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1298  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;" \
   1299  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stha %2,[%0]%%asi; wrpr %1,0,%%pstate; " \
   1300  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" : \
   1301  1.12.2.1  bouyer 		"=&r" (_loc_hi), "=&r" (_pstate) : \
   1302  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1303  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1304  1.12.2.1  bouyer 	} else { \
   1305  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
   1306       1.9     eeh " or %2,%0,%0; stha %1,[%0]%%asi" : "=&r" (_loc_hi) : \
   1307  1.12.2.1  bouyer 	    "r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1308  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi)); \
   1309  1.12.2.1  bouyer 	} \
   1310       1.9     eeh })
   1311       1.9     eeh #endif
   1312       1.6     eeh 
   1313       1.6     eeh /* store int to alternate address space */
   1314       1.9     eeh #ifdef __arch64__
   1315       1.6     eeh #define	sta(loc, asi, value) ({ \
   1316  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1317  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; sta %1,[%2]%%asi;" \
   1318  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" : "=&r" (loc) : \
   1319  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1320  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1321  1.12.2.1  bouyer 	} else { \
   1322       1.6     eeh 	__asm __volatile("wr %2,%%g0,%%asi; sta %0,[%1]%%asi" : : \
   1323  1.12.2.1  bouyer 	    "r" ((int)(value)), "r" ((unsigned long)(loc)), "r" (asi)); \
   1324  1.12.2.1  bouyer 	} \
   1325       1.6     eeh })
   1326       1.9     eeh #else
   1327       1.9     eeh #define	sta(loc, asi, value) ({ \
   1328  1.12.2.1  bouyer 	register int _loc_hi, _pstate; \
   1329       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1330  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1331  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1;" \
   1332  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; sta %2,[%0]%%asi; wrpr %1,0,%%pstate; " \
   1333  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" : \
   1334  1.12.2.1  bouyer 		"=&r" (_loc_hi), "=&r" (_pstate) : \
   1335  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1336  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1337  1.12.2.1  bouyer 	} else { \
   1338  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
   1339       1.9     eeh " or %2,%0,%0; sta %1,[%0]%%asi" : "=&r" (_loc_hi) : \
   1340  1.12.2.1  bouyer 		"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1341  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi)); \
   1342  1.12.2.1  bouyer 	} \
   1343       1.9     eeh })
   1344       1.9     eeh #endif
   1345       1.6     eeh 
   1346       1.6     eeh /* store 64-bit int to alternate address space */
   1347       1.9     eeh #ifdef __arch64__
   1348       1.6     eeh #define	stda(loc, asi, value) ({ \
   1349  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1350  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stda %1,[%2]%%asi;" \
   1351  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" : "=&r" (loc) : \
   1352  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1353  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1354  1.12.2.1  bouyer 	} else { \
   1355       1.6     eeh 	__asm __volatile("wr %2,%%g0,%%asi; stda %0,[%1]%%asi" : : \
   1356  1.12.2.1  bouyer 	    "r" ((long long)(value)), "r" ((unsigned long)(loc)), "r" (asi)); \
   1357  1.12.2.1  bouyer 	} \
   1358       1.6     eeh })
   1359       1.9     eeh #else
   1360       1.9     eeh #define	stda(loc, asi, value) ({ \
   1361  1.12.2.1  bouyer 	register int _loc_hi, _pstate; \
   1362       1.9     eeh 	_loc_hi = (((u_int64_t)loc)>>32); \
   1363  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1364  1.12.2.1  bouyer 	__asm __volatile("wr %5,%%g0,%%asi; sllx %4,32,%0; rdpr %%pstate,%1; " \
   1365  1.12.2.1  bouyer " or %3,%0,%0; wrpr %1,8,%%pstate; stda %2,[%0]%%asi; wrpr %1,0,%%pstate;" \
   1366  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %6; membar #Sync" : \
   1367  1.12.2.1  bouyer 		"=&r" (_loc_hi), "=&r" (_pstate) : \
   1368  1.12.2.1  bouyer 		"r" ((long long)(value)), "r" ((unsigned long)(loc)), \
   1369  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
   1370  1.12.2.1  bouyer 	} else { \
   1371  1.12.2.1  bouyer 		__asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
   1372       1.9     eeh " or %2,%0,%0; stda %1,[%0]%%asi" : "=&r" (_loc_hi) : \
   1373  1.12.2.1  bouyer 		"r" ((long long)(value)), "r" ((unsigned long)(loc)), \
   1374  1.12.2.1  bouyer 		"r" (_loc_hi), "r" (asi)); \
   1375  1.12.2.1  bouyer 	} \
   1376       1.9     eeh })
   1377       1.9     eeh #endif
   1378       1.1     eeh 
   1379       1.5     mrg #ifdef __arch64__
   1380       1.2     eeh /* native store 64-bit int to alternate address space w/64-bit compiler*/
   1381       1.2     eeh #define	stxa(loc, asi, value) ({ \
   1382  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1383  1.12.2.1  bouyer 		__asm __volatile("wr %3,%%g0,%%asi; stxa %1,[%2]%%asi;" \
   1384  1.12.2.1  bouyer " andn %2,0x1f,%0; membar #Sync; stxa %%g0,[%0] %4; membar #Sync" : "=&r" (loc) : \
   1385  1.12.2.1  bouyer 			"r" ((int)(value)), "r" ((unsigned long)(loc)), \
   1386  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1387  1.12.2.1  bouyer 	} else { \
   1388       1.6     eeh 	__asm __volatile("wr %2,%%g0,%%asi; stxa %0,[%1]%%asi" : : \
   1389  1.12.2.1  bouyer 	    "r" ((unsigned long)(value)), "r" ((unsigned long)(loc)), "r" (asi)); \
   1390       1.2     eeh })
   1391       1.2     eeh #else
   1392       1.2     eeh /* native store 64-bit int to alternate address space w/32-bit compiler*/
   1393       1.2     eeh #define	stxa(loc, asi, value) ({ \
   1394       1.9     eeh 	int _stxa_lo, _stxa_hi, _loc_hi; \
   1395       1.9     eeh 	_stxa_lo = value; _stxa_hi = ((u_int64_t)value)>>32; \
   1396  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)(u_long)loc)>>32); \
   1397  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1398  1.12.2.1  bouyer 		__asm __volatile("wr %7,%%g0,%%asi; sllx %4,32,%1; sllx %6,32,%0; " \
   1399  1.12.2.1  bouyer " or %1,%3,%1; rdpr %%pstate,%2; or %0,%5,%0; wrpr %2,8,%%pstate; " \
   1400  1.12.2.1  bouyer " stxa %1,[%0]%%asi; wrpr %2,0,%%pstate; "  \
   1401  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %8; membar #Sync": \
   1402  1.12.2.1  bouyer 		"=&r" (_loc_hi), "=&r" (_stxa_hi), "=&r" ((int)(_stxa_lo)): \
   1403  1.12.2.1  bouyer 		"r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)), \
   1404  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1405  1.12.2.1  bouyer 		"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1406  1.12.2.1  bouyer 	} else { \
   1407       1.9     eeh 	__asm __volatile("wr %6,%%g0,%%asi; sllx %3,32,%1; sllx %5,32,%0; " \
   1408       1.9     eeh " or %1,%2,%1; or %0,%4,%0; stxa %1,[%0]%%asi" : \
   1409       1.9     eeh 	    "=&r" (_loc_hi), "=&r" (_stxa_hi) : \
   1410       1.9     eeh 	    "r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)), \
   1411  1.12.2.1  bouyer 	    "r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1412  1.12.2.1  bouyer 	} \
   1413       1.2     eeh })
   1414       1.1     eeh #endif
   1415       1.1     eeh 
   1416  1.12.2.1  bouyer 
   1417  1.12.2.1  bouyer #ifdef __arch64__
   1418  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/64-bit compiler*/
   1419  1.12.2.1  bouyer #define	casxa(loc, asi, value, ovalue) ({ \
   1420  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1421  1.12.2.1  bouyer 		__asm __volatile("wr %5,%%g0,%%asi; casxa [%4]%%asi,%3, %1;" \
   1422  1.12.2.1  bouyer " andn %4,0x1f,%0; membar #Sync; stxa %%g0,[%0] %5; membar #Sync" : \
   1423  1.12.2.1  bouyer 			"=&r" (loc), "=&r" (value) : \
   1424  1.12.2.1  bouyer 			"r" ((unsigned long)(value)),  "r" ((unsigned long)(ovalue)), \
   1425  1.12.2.1  bouyer 			"r" ((unsigned long)(loc)), \
   1426  1.12.2.1  bouyer 			"r" (asi), "n" (ASI_DCACHE_TAG)); \
   1427  1.12.2.1  bouyer 	} else { \
   1428  1.12.2.1  bouyer 	__asm __volatile("wr %4,%%g0,%%asi; casxa [%3]%%asi,%2,%1" : \
   1429  1.12.2.1  bouyer 	    "=&r" (value) : \
   1430  1.12.2.1  bouyer 	    "r" ((unsigned long)(value)), "r" ((unsigned long)(ovalue), \
   1431  1.12.2.1  bouyer 	    "r" ((unsigned long)(loc)), "r" (asi)); \
   1432  1.12.2.1  bouyer })
   1433  1.12.2.1  bouyer #else
   1434  1.12.2.1  bouyer /* native store 64-bit int to alternate address space w/32-bit compiler*/
   1435  1.12.2.1  bouyer #define	casxa(loc, asi, value, ovalue) ({ \
   1436  1.12.2.1  bouyer 	int _casxa_lo, _casxa_hi, _oval_lo, _oval_hi, _loc_hi; \
   1437  1.12.2.1  bouyer 	_casxa_lo = value; _casxa_hi = ((u_int64_t)value)>>32; \
   1438  1.12.2.1  bouyer 	_oval_lo = ovalue; _oval_hi = ((u_int64_t)ovalue)>>32; \
   1439  1.12.2.1  bouyer 	_loc_hi = (((u_int64_t)(u_long)loc)>>32); \
   1440  1.12.2.1  bouyer 	if (PHYS_ASI(asi)) { \
   1441  1.12.2.1  bouyer 		__asm __volatile("wr %9,%%g0,%%asi; sllx %4,32,%1; sllx %8,32,%0; " \
   1442  1.12.2.1  bouyer " or %1,%3,%1; rdpr %%pstate,%3; or %0,%5,%0; wrpr %3,8,%%pstate; " \
   1443  1.12.2.1  bouyer " casxa %1,[%0]%%asi; wrpr %3,0,%%pstate; "  \
   1444  1.12.2.1  bouyer " andn %0,0x1f,%1;  membar #Sync; stxa %%g0,[%1] %8; membar #Sync": \
   1445  1.12.2.1  bouyer 		"=&r" (_casxa_hi), "=&r" ((int)(_casxa_lo)): \
   1446  1.12.2.1  bouyer 		"r" ((int)(_casxa_lo)), "r" ((int)(_casxa_hi)), \
   1447  1.12.2.1  bouyer 		"r" ((int)(_oval_lo)), "r" ((int)(_oval_hi)), \
   1448  1.12.2.1  bouyer 		"r" ((unsigned long)(loc)), "r" (_loc_hi), \
   1449  1.12.2.1  bouyer 		"r" (asi), "n" (ASI_DCACHE_TAG) : \
   1450  1.12.2.1  bouyer 		"r" (loc), "r", (oval_lo) \
   1451  1.12.2.1  bouyer 	} else { \
   1452  1.12.2.1  bouyer 	__asm __volatile("wr %6,%%g0,%%asi; sllx %3,32,%1; sllx %5,32,%0; " \
   1453  1.12.2.1  bouyer " or %1,%2,%1; or %0,%4,%0; stxa %1,[%0]%%asi" : \
   1454  1.12.2.1  bouyer 	    "=&r" (_loc_hi), "=&r" (_stxa_hi) : \
   1455  1.12.2.1  bouyer 	    "r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)), \
   1456  1.12.2.1  bouyer 	    "r" ((unsigned long)(loc)), "r" (_loc_hi), "r" (asi)); \
   1457  1.12.2.1  bouyer 	} \
   1458  1.12.2.1  bouyer })
   1459  1.12.2.1  bouyer #endif
   1460  1.12.2.1  bouyer #endif
   1461  1.12.2.1  bouyer 
   1462  1.12.2.1  bouyer 
   1463       1.2     eeh /* flush address from data cache */
   1464       1.2     eeh #define flush(loc) ({ \
   1465       1.2     eeh 	__asm __volatile("flush %0" : : \
   1466  1.12.2.1  bouyer 	     "r" ((unsigned long)(loc))); \
   1467       1.2     eeh })
   1468       1.2     eeh 
   1469       1.6     eeh /* Flush a D$ line */
   1470       1.6     eeh #if 0
   1471       1.6     eeh #define flushline(loc) ({ \
   1472       1.6     eeh 	stxa(((paddr_t)loc)&(~0x1f), (ASI_DCACHE_TAG), 0); \
   1473       1.6     eeh         membar_sync(); \
   1474       1.6     eeh })
   1475       1.6     eeh #else
   1476       1.6     eeh #define flushline(loc)
   1477       1.6     eeh #endif
   1478       1.6     eeh 
   1479       1.6     eeh /* The following two enable or disable the dcache in the LSU control register */
   1480       1.6     eeh #define dcenable() ({ \
   1481       1.6     eeh 	int res; \
   1482       1.6     eeh 	__asm __volatile("ldxa [%%g0] %1,%0; or %0,%2,%0; stxa %0,[%%g0] %1; membar #Sync" \
   1483       1.6     eeh 		: "r" (res) : "n" (ASI_MCCR), "n" (MCCR_DCACHE_EN)); \
   1484       1.6     eeh })
   1485       1.6     eeh #define dcdisable() ({ \
   1486       1.6     eeh 	int res; \
   1487       1.6     eeh 	__asm __volatile("ldxa [%%g0] %1,%0; andn %0,%2,%0; stxa %0,[%%g0] %1; membar #Sync" \
   1488       1.6     eeh 		: "r" (res) : "n" (ASI_MCCR), "n" (MCCR_DCACHE_EN)); \
   1489       1.6     eeh })
   1490       1.6     eeh 
   1491       1.6     eeh /*
   1492       1.6     eeh  * SPARC V9 memory barrier instructions.
   1493       1.6     eeh  */
   1494       1.6     eeh /* Make all stores complete before next store */
   1495       1.6     eeh #define membar_storestore() __asm __volatile("membar #StoreStore" : :)
   1496       1.6     eeh /* Make all loads complete before next store */
   1497       1.6     eeh #define membar_loadstore() __asm __volatile("membar #LoadStore" : :)
   1498       1.6     eeh /* Make all stores complete before next load */
   1499       1.6     eeh #define membar_storeload() __asm __volatile("membar #StoreLoad" : :)
   1500       1.6     eeh /* Make all loads complete before next load */
   1501       1.6     eeh #define membar_loadload() __asm __volatile("membar #LoadLoad" : :)
   1502       1.6     eeh /* Complete all outstanding memory operations and exceptions */
   1503       1.2     eeh #define membar_sync() __asm __volatile("membar #Sync" : :)
   1504       1.6     eeh /* Complete all outstanding memory operations */
   1505       1.6     eeh #define membar_memissue() __asm __volatile("membar #MemIssue" : :)
   1506       1.6     eeh /* Complete all outstanding stores before any new loads */
   1507       1.6     eeh #define membar_lookaside() __asm __volatile("membar #Lookaside" : :)
   1508       1.2     eeh 
   1509       1.5     mrg #ifdef __arch64__
   1510       1.2     eeh /* read 64-bit %tick register */
   1511       1.2     eeh #define	tick() ({ \
   1512       1.3     eeh 	register u_long _tick_tmp; \
   1513       1.2     eeh 	__asm __volatile("rdpr %%tick, %0" : "=r" (_tick_tmp) :); \
   1514       1.2     eeh 	_tick_tmp; \
   1515       1.2     eeh })
   1516       1.2     eeh #else
   1517       1.9     eeh /* read 64-bit %tick register on 32-bit system */
   1518       1.2     eeh #define	tick() ({ \
   1519      1.10     eeh 	register int _tick_hi = 0, _tick_lo = 0; \
   1520      1.10     eeh 	__asm __volatile("rdpr %%tick, %1; srlx %0,32,%2; srl %0,0,%0 " \
   1521      1.10     eeh 		: "=r" (_tick_hi), "=r" (_tick_lo) : ); \
   1522      1.10     eeh 	(((u_int64_t)_tick_hi)<<32)|((u_int64_t)_tick_lo); \
   1523       1.2     eeh })
   1524       1.1     eeh #endif
   1525       1.2     eeh 
   1526      1.12     mrg extern void next_tick __P((long));
   1527       1.9     eeh #endif
   1528