Home | History | Annotate | Line # | Download | only in include
ia64_cpu.h revision 1.2.40.1
      1  1.2.40.1     skrll /*	$NetBSD: ia64_cpu.h,v 1.2.40.1 2016/10/05 20:55:29 skrll Exp $	*/
      2       1.1    cherry 
      3       1.1    cherry /*-
      4  1.2.40.1     skrll  * Copyright (c) 2007 Marcel Moolenaar
      5       1.1    cherry  * Copyright (c) 2000 Doug Rabson
      6       1.1    cherry  * All rights reserved.
      7       1.1    cherry  *
      8       1.1    cherry  * Redistribution and use in source and binary forms, with or without
      9       1.1    cherry  * modification, are permitted provided that the following conditions
     10       1.1    cherry  * are met:
     11       1.1    cherry  * 1. Redistributions of source code must retain the above copyright
     12       1.1    cherry  *    notice, this list of conditions and the following disclaimer.
     13       1.1    cherry  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1    cherry  *    notice, this list of conditions and the following disclaimer in the
     15       1.1    cherry  *    documentation and/or other materials provided with the distribution.
     16       1.1    cherry  *
     17       1.1    cherry  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     18       1.1    cherry  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19       1.1    cherry  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20       1.1    cherry  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     21       1.1    cherry  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22       1.1    cherry  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23       1.1    cherry  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24       1.1    cherry  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25       1.1    cherry  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26       1.1    cherry  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27       1.1    cherry  * SUCH DAMAGE.
     28       1.1    cherry  *
     29  1.2.40.1     skrll  * $FreeBSD: releng/10.1/sys/ia64/include/ia64_cpu.h 223170 2011-06-17 04:26:03Z marcel $
     30       1.1    cherry  */
     31       1.1    cherry 
     32       1.1    cherry #ifndef _MACHINE_IA64_CPU_H_
     33       1.1    cherry #define _MACHINE_IA64_CPU_H_
     34       1.1    cherry 
     35       1.1    cherry /*
     36  1.2.40.1     skrll  * Local Interrupt ID.
     37  1.2.40.1     skrll  */
     38  1.2.40.1     skrll #define	IA64_LID_GET_SAPIC_ID(x)	((u_int)((x) >> 16) & 0xffff)
     39  1.2.40.1     skrll #define	IA64_LID_SET_SAPIC_ID(x)	((u_int)((x) & 0xffff) << 16)
     40  1.2.40.1     skrll 
     41  1.2.40.1     skrll /*
     42  1.2.40.1     skrll  * Definition of DCR bits.
     43  1.2.40.1     skrll  */
     44  1.2.40.1     skrll #define	IA64_DCR_PP		0x0000000000000001
     45  1.2.40.1     skrll #define	IA64_DCR_BE		0x0000000000000002
     46  1.2.40.1     skrll #define	IA64_DCR_LC		0x0000000000000004
     47  1.2.40.1     skrll #define	IA64_DCR_DM		0x0000000000000100
     48  1.2.40.1     skrll #define	IA64_DCR_DP		0x0000000000000200
     49  1.2.40.1     skrll #define	IA64_DCR_DK		0x0000000000000400
     50  1.2.40.1     skrll #define	IA64_DCR_DX		0x0000000000000800
     51  1.2.40.1     skrll #define	IA64_DCR_DR		0x0000000000001000
     52  1.2.40.1     skrll #define	IA64_DCR_DA		0x0000000000002000
     53  1.2.40.1     skrll #define	IA64_DCR_DD		0x0000000000004000
     54  1.2.40.1     skrll 
     55  1.2.40.1     skrll #define	IA64_DCR_DEFAULT					\
     56  1.2.40.1     skrll     (IA64_DCR_DM | IA64_DCR_DP | IA64_DCR_DK | IA64_DCR_DX |	\
     57  1.2.40.1     skrll      IA64_DCR_DR | IA64_DCR_DA | IA64_DCR_DD)
     58  1.2.40.1     skrll 
     59  1.2.40.1     skrll /*
     60       1.1    cherry  * Definition of PSR and IPSR bits.
     61       1.1    cherry  */
     62       1.1    cherry #define IA64_PSR_BE		0x0000000000000002
     63       1.1    cherry #define IA64_PSR_UP		0x0000000000000004
     64       1.1    cherry #define IA64_PSR_AC		0x0000000000000008
     65       1.1    cherry #define IA64_PSR_MFL		0x0000000000000010
     66       1.1    cherry #define IA64_PSR_MFH		0x0000000000000020
     67       1.1    cherry #define IA64_PSR_IC		0x0000000000002000
     68       1.1    cherry #define IA64_PSR_I		0x0000000000004000
     69       1.1    cherry #define IA64_PSR_PK		0x0000000000008000
     70       1.1    cherry #define IA64_PSR_DT		0x0000000000020000
     71       1.1    cherry #define IA64_PSR_DFL		0x0000000000040000
     72       1.1    cherry #define IA64_PSR_DFH		0x0000000000080000
     73       1.1    cherry #define IA64_PSR_SP		0x0000000000100000
     74       1.1    cherry #define IA64_PSR_PP		0x0000000000200000
     75       1.1    cherry #define IA64_PSR_DI		0x0000000000400000
     76       1.1    cherry #define IA64_PSR_SI		0x0000000000800000
     77       1.1    cherry #define IA64_PSR_DB		0x0000000001000000
     78       1.1    cherry #define IA64_PSR_LP		0x0000000002000000
     79       1.1    cherry #define IA64_PSR_TB		0x0000000004000000
     80       1.1    cherry #define IA64_PSR_RT		0x0000000008000000
     81       1.1    cherry #define IA64_PSR_CPL		0x0000000300000000
     82       1.1    cherry #define IA64_PSR_CPL_KERN	0x0000000000000000
     83       1.1    cherry #define IA64_PSR_CPL_1		0x0000000100000000
     84       1.1    cherry #define IA64_PSR_CPL_2		0x0000000200000000
     85       1.1    cherry #define IA64_PSR_CPL_USER	0x0000000300000000
     86       1.1    cherry #define IA64_PSR_IS		0x0000000400000000
     87       1.1    cherry #define IA64_PSR_MC		0x0000000800000000
     88       1.1    cherry #define IA64_PSR_IT		0x0000001000000000
     89       1.1    cherry #define IA64_PSR_ID		0x0000002000000000
     90       1.1    cherry #define IA64_PSR_DA		0x0000004000000000
     91       1.1    cherry #define IA64_PSR_DD		0x0000008000000000
     92       1.1    cherry #define IA64_PSR_SS		0x0000010000000000
     93       1.1    cherry #define IA64_PSR_RI		0x0000060000000000
     94       1.1    cherry #define IA64_PSR_RI_0		0x0000000000000000
     95       1.1    cherry #define IA64_PSR_RI_1		0x0000020000000000
     96       1.1    cherry #define IA64_PSR_RI_2		0x0000040000000000
     97       1.1    cherry #define IA64_PSR_ED		0x0000080000000000
     98       1.1    cherry #define IA64_PSR_BN		0x0000100000000000
     99       1.1    cherry #define IA64_PSR_IA		0x0000200000000000
    100       1.1    cherry 
    101       1.1    cherry /*
    102       1.1    cherry  * Definition of ISR bits.
    103       1.1    cherry  */
    104       1.1    cherry #define IA64_ISR_CODE		0x000000000000ffff
    105       1.1    cherry #define IA64_ISR_VECTOR		0x0000000000ff0000
    106       1.1    cherry #define IA64_ISR_X		0x0000000100000000
    107       1.1    cherry #define IA64_ISR_W		0x0000000200000000
    108       1.1    cherry #define IA64_ISR_R		0x0000000400000000
    109       1.1    cherry #define IA64_ISR_NA		0x0000000800000000
    110       1.1    cherry #define IA64_ISR_SP		0x0000001000000000
    111       1.1    cherry #define IA64_ISR_RS		0x0000002000000000
    112       1.1    cherry #define IA64_ISR_IR		0x0000004000000000
    113       1.1    cherry #define IA64_ISR_NI		0x0000008000000000
    114       1.1    cherry #define IA64_ISR_SO		0x0000010000000000
    115       1.1    cherry #define IA64_ISR_EI		0x0000060000000000
    116       1.1    cherry #define IA64_ISR_EI_0		0x0000000000000000
    117       1.1    cherry #define IA64_ISR_EI_1		0x0000020000000000
    118       1.1    cherry #define IA64_ISR_EI_2		0x0000040000000000
    119       1.1    cherry #define IA64_ISR_ED		0x0000080000000000
    120       1.1    cherry 
    121       1.1    cherry /*
    122       1.1    cherry  * Vector numbers for various ia64 interrupts.
    123       1.1    cherry  */
    124       1.1    cherry #define IA64_VEC_VHPT			0
    125       1.1    cherry #define IA64_VEC_ITLB			1
    126       1.1    cherry #define IA64_VEC_DTLB			2
    127       1.1    cherry #define IA64_VEC_ALT_ITLB		3
    128       1.1    cherry #define IA64_VEC_ALT_DTLB		4
    129       1.1    cherry #define IA64_VEC_NESTED_DTLB		5
    130       1.1    cherry #define IA64_VEC_IKEY_MISS		6
    131       1.1    cherry #define IA64_VEC_DKEY_MISS		7
    132       1.1    cherry #define IA64_VEC_DIRTY_BIT		8
    133       1.1    cherry #define IA64_VEC_INST_ACCESS		9
    134       1.1    cherry #define IA64_VEC_DATA_ACCESS		10
    135       1.1    cherry #define IA64_VEC_BREAK			11
    136       1.1    cherry #define IA64_VEC_EXT_INTR		12
    137       1.1    cherry #define IA64_VEC_PAGE_NOT_PRESENT	20
    138       1.1    cherry #define IA64_VEC_KEY_PERMISSION		21
    139       1.1    cherry #define IA64_VEC_INST_ACCESS_RIGHTS	22
    140       1.1    cherry #define IA64_VEC_DATA_ACCESS_RIGHTS	23
    141       1.1    cherry #define IA64_VEC_GENERAL_EXCEPTION	24
    142       1.1    cherry #define IA64_VEC_DISABLED_FP		25
    143       1.1    cherry #define IA64_VEC_NAT_CONSUMPTION	26
    144       1.1    cherry #define IA64_VEC_SPECULATION		27
    145       1.1    cherry #define IA64_VEC_DEBUG			29
    146       1.1    cherry #define IA64_VEC_UNALIGNED_REFERENCE	30
    147       1.1    cherry #define IA64_VEC_UNSUPP_DATA_REFERENCE	31
    148       1.1    cherry #define IA64_VEC_FLOATING_POINT_FAULT	32
    149       1.1    cherry #define IA64_VEC_FLOATING_POINT_TRAP	33
    150       1.1    cherry #define IA64_VEC_LOWER_PRIVILEGE_TRANSFER 34
    151       1.1    cherry #define IA64_VEC_TAKEN_BRANCH_TRAP	35
    152       1.1    cherry #define IA64_VEC_SINGLE_STEP_TRAP	36
    153       1.1    cherry #define IA64_VEC_IA32_EXCEPTION		45
    154       1.1    cherry #define IA64_VEC_IA32_INTERCEPT		46
    155       1.1    cherry #define IA64_VEC_IA32_INTERRUPT		47
    156       1.1    cherry 
    157       1.1    cherry /*
    158       1.1    cherry  * IA-32 exceptions.
    159       1.1    cherry  */
    160       1.1    cherry #define IA32_EXCEPTION_DIVIDE		0
    161       1.1    cherry #define IA32_EXCEPTION_DEBUG		1
    162       1.1    cherry #define IA32_EXCEPTION_BREAK		3
    163       1.1    cherry #define IA32_EXCEPTION_OVERFLOW		4
    164       1.1    cherry #define IA32_EXCEPTION_BOUND		5
    165       1.1    cherry #define IA32_EXCEPTION_DNA		7
    166       1.1    cherry #define IA32_EXCEPTION_NOT_PRESENT	11
    167       1.1    cherry #define IA32_EXCEPTION_STACK_FAULT	12
    168       1.1    cherry #define IA32_EXCEPTION_GPFAULT		13
    169       1.1    cherry #define IA32_EXCEPTION_FPERROR		16
    170       1.1    cherry #define IA32_EXCEPTION_ALIGNMENT_CHECK	17
    171       1.1    cherry #define IA32_EXCEPTION_STREAMING_SIMD	19
    172       1.1    cherry 
    173       1.1    cherry #define IA32_INTERCEPT_INSTRUCTION	0
    174       1.1    cherry #define IA32_INTERCEPT_GATE		1
    175       1.1    cherry #define IA32_INTERCEPT_SYSTEM_FLAG	2
    176       1.1    cherry #define IA32_INTERCEPT_LOCK		4
    177       1.1    cherry 
    178       1.1    cherry #ifndef _LOCORE
    179       1.1    cherry 
    180       1.1    cherry /*
    181       1.1    cherry  * Various special ia64 instructions.
    182       1.1    cherry  */
    183       1.1    cherry 
    184       1.1    cherry /*
    185       1.1    cherry  * Memory Fence.
    186       1.1    cherry  */
    187       1.1    cherry static __inline void
    188       1.1    cherry ia64_mf(void)
    189       1.1    cherry {
    190       1.1    cherry 	__asm __volatile("mf");
    191       1.1    cherry }
    192       1.1    cherry 
    193       1.1    cherry static __inline void
    194       1.1    cherry ia64_mf_a(void)
    195       1.1    cherry {
    196       1.1    cherry 	__asm __volatile("mf.a");
    197       1.1    cherry }
    198       1.1    cherry 
    199       1.1    cherry /*
    200       1.1    cherry  * Flush Cache.
    201       1.1    cherry  */
    202       1.1    cherry static __inline void
    203       1.2  kiyohara ia64_fc(uint64_t va)
    204       1.1    cherry {
    205       1.1    cherry 	__asm __volatile("fc %0" :: "r"(va));
    206       1.1    cherry }
    207       1.1    cherry 
    208       1.1    cherry static __inline void
    209       1.2  kiyohara ia64_fc_i(uint64_t va)
    210       1.1    cherry {
    211       1.1    cherry 	__asm __volatile("fc.i %0" :: "r"(va));
    212       1.1    cherry }
    213       1.1    cherry 
    214       1.1    cherry /*
    215       1.1    cherry  * Sync instruction stream.
    216       1.1    cherry  */
    217       1.1    cherry static __inline void
    218       1.1    cherry ia64_sync_i(void)
    219       1.1    cherry {
    220       1.1    cherry 	__asm __volatile("sync.i");
    221       1.1    cherry }
    222       1.1    cherry 
    223       1.1    cherry /*
    224       1.1    cherry  * Calculate address in VHPT for va.
    225       1.1    cherry  */
    226       1.2  kiyohara static __inline uint64_t
    227       1.2  kiyohara ia64_thash(uint64_t va)
    228       1.1    cherry {
    229       1.2  kiyohara 	uint64_t result;
    230       1.1    cherry 	__asm __volatile("thash %0=%1" : "=r" (result) : "r" (va));
    231       1.1    cherry 	return result;
    232       1.1    cherry }
    233       1.1    cherry 
    234       1.1    cherry /*
    235       1.1    cherry  * Calculate VHPT tag for va.
    236       1.1    cherry  */
    237       1.2  kiyohara static __inline uint64_t
    238       1.2  kiyohara ia64_ttag(uint64_t va)
    239       1.1    cherry {
    240       1.2  kiyohara 	uint64_t result;
    241       1.1    cherry 	__asm __volatile("ttag %0=%1" : "=r" (result) : "r" (va));
    242       1.1    cherry 	return result;
    243       1.1    cherry }
    244       1.1    cherry 
    245       1.1    cherry /*
    246       1.1    cherry  * Convert virtual address to physical.
    247       1.1    cherry  */
    248       1.2  kiyohara static __inline uint64_t
    249       1.2  kiyohara ia64_tpa(uint64_t va)
    250       1.1    cherry {
    251       1.2  kiyohara 	uint64_t result;
    252       1.1    cherry 	__asm __volatile("tpa %0=%1" : "=r" (result) : "r" (va));
    253       1.1    cherry 	return result;
    254       1.1    cherry }
    255       1.1    cherry 
    256       1.1    cherry /*
    257       1.1    cherry  * Generate a ptc.e instruction.
    258       1.1    cherry  */
    259       1.1    cherry static __inline void
    260       1.2  kiyohara ia64_ptc_e(uint64_t v)
    261       1.1    cherry {
    262  1.2.40.1     skrll 	__asm __volatile("ptc.e %0;; srlz.i;;" :: "r"(v));
    263       1.1    cherry }
    264       1.1    cherry 
    265       1.1    cherry /*
    266       1.1    cherry  * Generate a ptc.g instruction.
    267       1.1    cherry  */
    268       1.1    cherry static __inline void
    269       1.2  kiyohara ia64_ptc_g(uint64_t va, uint64_t log2size)
    270       1.1    cherry {
    271  1.2.40.1     skrll 	__asm __volatile("ptc.g %0,%1;;" :: "r"(va), "r"(log2size));
    272       1.1    cherry }
    273       1.1    cherry 
    274       1.1    cherry /*
    275       1.1    cherry  * Generate a ptc.ga instruction.
    276       1.1    cherry  */
    277       1.1    cherry static __inline void
    278       1.2  kiyohara ia64_ptc_ga(uint64_t va, uint64_t log2size)
    279       1.1    cherry {
    280  1.2.40.1     skrll 	__asm __volatile("ptc.ga %0,%1;;" :: "r"(va), "r"(log2size));
    281       1.1    cherry }
    282       1.1    cherry 
    283       1.1    cherry /*
    284       1.1    cherry  * Generate a ptc.l instruction.
    285       1.1    cherry  */
    286       1.1    cherry static __inline void
    287       1.2  kiyohara ia64_ptc_l(uint64_t va, uint64_t log2size)
    288       1.1    cherry {
    289  1.2.40.1     skrll 	__asm __volatile("ptc.l %0,%1;; srlz.i;;" :: "r"(va), "r"(log2size));
    290  1.2.40.1     skrll }
    291  1.2.40.1     skrll 
    292  1.2.40.1     skrll /*
    293  1.2.40.1     skrll  * Invalidate the ALAT on the local processor.
    294  1.2.40.1     skrll  */
    295  1.2.40.1     skrll static __inline void
    296  1.2.40.1     skrll ia64_invala(void)
    297  1.2.40.1     skrll {
    298  1.2.40.1     skrll 	__asm __volatile("invala;;");
    299  1.2.40.1     skrll }
    300  1.2.40.1     skrll 
    301  1.2.40.1     skrll /*
    302  1.2.40.1     skrll  * Unordered memory load.
    303  1.2.40.1     skrll  */
    304  1.2.40.1     skrll 
    305  1.2.40.1     skrll static __inline uint8_t
    306  1.2.40.1     skrll ia64_ld1(uint8_t *p)
    307  1.2.40.1     skrll {
    308  1.2.40.1     skrll 	uint8_t v;
    309  1.2.40.1     skrll 
    310  1.2.40.1     skrll 	__asm __volatile("ld1 %0=[%1];;" : "=r"(v) : "r"(p));
    311  1.2.40.1     skrll 	return (v);
    312  1.2.40.1     skrll }
    313  1.2.40.1     skrll 
    314  1.2.40.1     skrll static __inline uint16_t
    315  1.2.40.1     skrll ia64_ld2(uint16_t *p)
    316  1.2.40.1     skrll {
    317  1.2.40.1     skrll 	uint16_t v;
    318  1.2.40.1     skrll 
    319  1.2.40.1     skrll 	__asm __volatile("ld2 %0=[%1];;" : "=r"(v) : "r"(p));
    320  1.2.40.1     skrll 	return (v);
    321  1.2.40.1     skrll }
    322  1.2.40.1     skrll 
    323  1.2.40.1     skrll static __inline uint32_t
    324  1.2.40.1     skrll ia64_ld4(uint32_t *p)
    325  1.2.40.1     skrll {
    326  1.2.40.1     skrll 	uint32_t v;
    327  1.2.40.1     skrll 
    328  1.2.40.1     skrll 	__asm __volatile("ld4 %0=[%1];;" : "=r"(v) : "r"(p));
    329  1.2.40.1     skrll 	return (v);
    330  1.2.40.1     skrll }
    331  1.2.40.1     skrll 
    332  1.2.40.1     skrll static __inline uint64_t
    333  1.2.40.1     skrll ia64_ld8(uint64_t *p)
    334  1.2.40.1     skrll {
    335  1.2.40.1     skrll 	uint64_t v;
    336  1.2.40.1     skrll 
    337  1.2.40.1     skrll 	__asm __volatile("ld8 %0=[%1];;" : "=r"(v) : "r"(p));
    338  1.2.40.1     skrll 	return (v);
    339  1.2.40.1     skrll }
    340  1.2.40.1     skrll 
    341  1.2.40.1     skrll /*
    342  1.2.40.1     skrll  * Unordered memory store.
    343  1.2.40.1     skrll  */
    344  1.2.40.1     skrll 
    345  1.2.40.1     skrll static __inline void
    346  1.2.40.1     skrll ia64_st1(uint8_t *p, uint8_t v)
    347  1.2.40.1     skrll {
    348  1.2.40.1     skrll 	__asm __volatile("st1 [%0]=%1;;" :: "r"(p), "r"(v));
    349  1.2.40.1     skrll }
    350  1.2.40.1     skrll 
    351  1.2.40.1     skrll static __inline void
    352  1.2.40.1     skrll ia64_st2(uint16_t *p, uint16_t v)
    353  1.2.40.1     skrll {
    354  1.2.40.1     skrll 	__asm __volatile("st2 [%0]=%1;;" :: "r"(p), "r"(v));
    355  1.2.40.1     skrll }
    356  1.2.40.1     skrll 
    357  1.2.40.1     skrll static __inline void
    358  1.2.40.1     skrll ia64_st4(uint32_t *p, uint32_t v)
    359  1.2.40.1     skrll {
    360  1.2.40.1     skrll 	__asm __volatile("st4 [%0]=%1;;" :: "r"(p), "r"(v));
    361  1.2.40.1     skrll }
    362  1.2.40.1     skrll 
    363  1.2.40.1     skrll static __inline void
    364  1.2.40.1     skrll ia64_st8(uint64_t *p, uint64_t v)
    365  1.2.40.1     skrll {
    366  1.2.40.1     skrll 	__asm __volatile("st8 [%0]=%1;;" :: "r"(p), "r"(v));
    367       1.1    cherry }
    368       1.1    cherry 
    369       1.1    cherry /*
    370       1.1    cherry  * Read the value of psr.
    371       1.1    cherry  */
    372       1.2  kiyohara static __inline uint64_t
    373       1.1    cherry ia64_get_psr(void)
    374       1.1    cherry {
    375       1.2  kiyohara 	uint64_t result;
    376       1.1    cherry 	__asm __volatile("mov %0=psr;;" : "=r" (result));
    377       1.1    cherry 	return result;
    378       1.1    cherry }
    379       1.1    cherry 
    380       1.1    cherry /*
    381       1.1    cherry  * Define accessors for application registers.
    382       1.1    cherry  */
    383       1.1    cherry 
    384       1.1    cherry #define IA64_AR(name)						\
    385       1.1    cherry 								\
    386       1.2  kiyohara static __inline uint64_t					\
    387       1.1    cherry ia64_get_##name(void)						\
    388       1.1    cherry {								\
    389       1.2  kiyohara 	uint64_t result;					\
    390       1.1    cherry 	__asm __volatile("mov %0=ar." #name : "=r" (result));	\
    391       1.1    cherry 	return result;						\
    392       1.1    cherry }								\
    393       1.1    cherry 								\
    394       1.1    cherry static __inline void						\
    395       1.2  kiyohara ia64_set_##name(uint64_t v)					\
    396       1.1    cherry {								\
    397       1.1    cherry 	__asm __volatile("mov ar." #name "=%0;;" :: "r" (v));	\
    398       1.1    cherry }
    399       1.1    cherry 
    400       1.1    cherry IA64_AR(k0)
    401       1.1    cherry IA64_AR(k1)
    402       1.1    cherry IA64_AR(k2)
    403       1.1    cherry IA64_AR(k3)
    404       1.1    cherry IA64_AR(k4)
    405       1.1    cherry IA64_AR(k5)
    406       1.1    cherry IA64_AR(k6)
    407       1.1    cherry IA64_AR(k7)
    408       1.1    cherry 
    409       1.1    cherry IA64_AR(rsc)
    410       1.1    cherry IA64_AR(bsp)
    411       1.1    cherry IA64_AR(bspstore)
    412       1.1    cherry IA64_AR(rnat)
    413       1.1    cherry 
    414       1.1    cherry IA64_AR(fcr)
    415       1.1    cherry 
    416       1.1    cherry IA64_AR(eflag)
    417       1.1    cherry IA64_AR(csd)
    418       1.1    cherry IA64_AR(ssd)
    419       1.1    cherry IA64_AR(cflg)
    420       1.1    cherry IA64_AR(fsr)
    421       1.1    cherry IA64_AR(fir)
    422       1.1    cherry IA64_AR(fdr)
    423       1.1    cherry 
    424       1.1    cherry IA64_AR(ccv)
    425       1.1    cherry 
    426       1.1    cherry IA64_AR(unat)
    427       1.1    cherry 
    428       1.1    cherry IA64_AR(fpsr)
    429       1.1    cherry 
    430       1.1    cherry IA64_AR(itc)
    431       1.1    cherry 
    432       1.1    cherry IA64_AR(pfs)
    433       1.1    cherry IA64_AR(lc)
    434       1.1    cherry IA64_AR(ec)
    435       1.1    cherry 
    436       1.1    cherry /*
    437       1.1    cherry  * Define accessors for control registers.
    438       1.1    cherry  */
    439       1.1    cherry 
    440       1.1    cherry #define IA64_CR(name)						\
    441       1.1    cherry 								\
    442       1.2  kiyohara static __inline uint64_t					\
    443       1.1    cherry ia64_get_##name(void)						\
    444       1.1    cherry {								\
    445       1.2  kiyohara 	uint64_t result;					\
    446       1.1    cherry 	__asm __volatile("mov %0=cr." #name : "=r" (result));	\
    447       1.1    cherry 	return result;						\
    448       1.1    cherry }								\
    449       1.1    cherry 								\
    450       1.1    cherry static __inline void						\
    451       1.2  kiyohara ia64_set_##name(uint64_t v)					\
    452       1.1    cherry {								\
    453       1.1    cherry 	__asm __volatile("mov cr." #name "=%0;;" :: "r" (v));	\
    454       1.1    cherry }
    455       1.1    cherry 
    456       1.1    cherry IA64_CR(dcr)
    457       1.1    cherry IA64_CR(itm)
    458       1.1    cherry IA64_CR(iva)
    459       1.1    cherry 
    460       1.1    cherry IA64_CR(pta)
    461       1.1    cherry 
    462       1.1    cherry IA64_CR(ipsr)
    463       1.1    cherry IA64_CR(isr)
    464       1.1    cherry 
    465       1.1    cherry IA64_CR(iip)
    466       1.1    cherry IA64_CR(ifa)
    467       1.1    cherry IA64_CR(itir)
    468       1.1    cherry IA64_CR(iipa)
    469       1.1    cherry IA64_CR(ifs)
    470       1.1    cherry IA64_CR(iim)
    471       1.1    cherry IA64_CR(iha)
    472       1.1    cherry 
    473       1.1    cherry IA64_CR(lid)
    474       1.1    cherry IA64_CR(ivr)
    475       1.1    cherry IA64_CR(tpr)
    476       1.1    cherry IA64_CR(eoi)
    477       1.1    cherry IA64_CR(irr0)
    478       1.1    cherry IA64_CR(irr1)
    479       1.1    cherry IA64_CR(irr2)
    480       1.1    cherry IA64_CR(irr3)
    481       1.1    cherry IA64_CR(itv)
    482       1.1    cherry IA64_CR(pmv)
    483       1.1    cherry IA64_CR(cmcv)
    484       1.1    cherry 
    485       1.1    cherry IA64_CR(lrr0)
    486       1.1    cherry IA64_CR(lrr1)
    487       1.1    cherry 
    488       1.1    cherry /*
    489       1.1    cherry  * Write a region register.
    490       1.1    cherry  */
    491       1.1    cherry static __inline void
    492       1.2  kiyohara ia64_set_rr(uint64_t rrbase, uint64_t v)
    493       1.1    cherry {
    494  1.2.40.1     skrll 	__asm __volatile("mov rr[%0]=%1"
    495       1.1    cherry 			 :: "r"(rrbase), "r"(v) : "memory");
    496       1.1    cherry }
    497       1.1    cherry 
    498       1.1    cherry /*
    499       1.1    cherry  * Read a CPUID register.
    500       1.1    cherry  */
    501       1.2  kiyohara static __inline uint64_t
    502       1.1    cherry ia64_get_cpuid(int i)
    503       1.1    cherry {
    504       1.2  kiyohara 	uint64_t result;
    505       1.1    cherry 	__asm __volatile("mov %0=cpuid[%1]"
    506       1.1    cherry 			 : "=r" (result) : "r"(i));
    507       1.1    cherry 	return result;
    508       1.1    cherry }
    509       1.1    cherry 
    510       1.1    cherry static __inline void
    511       1.1    cherry ia64_disable_highfp(void)
    512       1.1    cherry {
    513       1.1    cherry 	__asm __volatile("ssm psr.dfh;; srlz.d");
    514       1.1    cherry }
    515       1.1    cherry 
    516       1.1    cherry static __inline void
    517       1.1    cherry ia64_enable_highfp(void)
    518       1.1    cherry {
    519       1.1    cherry 	__asm __volatile("rsm psr.dfh;; srlz.d");
    520       1.1    cherry }
    521       1.1    cherry 
    522  1.2.40.1     skrll /*
    523  1.2.40.1     skrll  * Avoid inline functions for the following so that they still work
    524  1.2.40.1     skrll  * correctly when inlining is not enabled (e.g. -O0). Function calls
    525  1.2.40.1     skrll  * need data serialization after setting psr, which results in a
    526  1.2.40.1     skrll  * hazard.
    527  1.2.40.1     skrll  */
    528  1.2.40.1     skrll #define	ia64_srlz_d()	__asm __volatile("srlz.d")
    529  1.2.40.1     skrll #define	ia64_srlz_i()	__asm __volatile("srlz.i;;")
    530       1.2  kiyohara 
    531       1.1    cherry #endif /* !_LOCORE */
    532       1.1    cherry 
    533       1.1    cherry #endif /* _MACHINE_IA64_CPU_H_ */
    534       1.1    cherry 
    535