xref: /openbmc/linux/arch/sparc/include/asm/head_64.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a439fe51SSam Ravnborg #ifndef _SPARC64_HEAD_H
3a439fe51SSam Ravnborg #define _SPARC64_HEAD_H
4a439fe51SSam Ravnborg 
5a439fe51SSam Ravnborg #include <asm/pstate.h>
6a439fe51SSam Ravnborg 
7a439fe51SSam Ravnborg 	/* wrpr	%g0, val, %gl */
8a439fe51SSam Ravnborg #define SET_GL(val)	\
9a439fe51SSam Ravnborg 	.word	0xa1902000 | val
10a439fe51SSam Ravnborg 
11a439fe51SSam Ravnborg 	/* rdpr %gl, %gN */
12a439fe51SSam Ravnborg #define GET_GL_GLOBAL(N)	\
13a439fe51SSam Ravnborg 	.word	0x81540000 | (N << 25)
14a439fe51SSam Ravnborg 
15a439fe51SSam Ravnborg #define KERNBASE	0x400000
16a439fe51SSam Ravnborg 
17a439fe51SSam Ravnborg #define	PTREGS_OFF	(STACK_BIAS + STACKFRAME_SZ)
18a439fe51SSam Ravnborg 
197cafc0b8SDavid S. Miller #define	RTRAP_PSTATE		(PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_IE)
207cafc0b8SDavid S. Miller #define	RTRAP_PSTATE_IRQOFF	(PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV)
217cafc0b8SDavid S. Miller #define RTRAP_PSTATE_AG_IRQOFF	(PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG)
227cafc0b8SDavid S. Miller 
23a439fe51SSam Ravnborg #define __CHEETAH_ID	0x003e0014
24a439fe51SSam Ravnborg #define __JALAPENO_ID	0x003e0016
25a439fe51SSam Ravnborg #define __SERRANO_ID	0x003e0022
26a439fe51SSam Ravnborg 
27a439fe51SSam Ravnborg #define CHEETAH_MANUF		0x003e
28a439fe51SSam Ravnborg #define CHEETAH_IMPL		0x0014 /* Ultra-III   */
29a439fe51SSam Ravnborg #define CHEETAH_PLUS_IMPL	0x0015 /* Ultra-III+  */
30a439fe51SSam Ravnborg #define JALAPENO_IMPL		0x0016 /* Ultra-IIIi  */
31a439fe51SSam Ravnborg #define JAGUAR_IMPL		0x0018 /* Ultra-IV    */
32a439fe51SSam Ravnborg #define PANTHER_IMPL		0x0019 /* Ultra-IV+   */
33a439fe51SSam Ravnborg #define SERRANO_IMPL		0x0022 /* Ultra-IIIi+ */
34a439fe51SSam Ravnborg 
35a439fe51SSam Ravnborg #define BRANCH_IF_SUN4V(tmp1,label)		\
36a439fe51SSam Ravnborg 	sethi	%hi(is_sun4v), %tmp1;		\
37a439fe51SSam Ravnborg 	lduw	[%tmp1 + %lo(is_sun4v)], %tmp1; \
38a439fe51SSam Ravnborg 	brnz,pn	%tmp1, label;			\
39a439fe51SSam Ravnborg 	 nop
40a439fe51SSam Ravnborg 
41a439fe51SSam Ravnborg #define BRANCH_IF_CHEETAH_BASE(tmp1,tmp2,label)	\
42a439fe51SSam Ravnborg 	rdpr	%ver, %tmp1;			\
43a439fe51SSam Ravnborg 	sethi	%hi(__CHEETAH_ID), %tmp2;	\
44a439fe51SSam Ravnborg 	srlx	%tmp1, 32, %tmp1;		\
45a439fe51SSam Ravnborg 	or	%tmp2, %lo(__CHEETAH_ID), %tmp2;\
46a439fe51SSam Ravnborg 	cmp	%tmp1, %tmp2;			\
47a439fe51SSam Ravnborg 	be,pn	%icc, label;			\
48a439fe51SSam Ravnborg 	 nop;
49a439fe51SSam Ravnborg 
50a439fe51SSam Ravnborg #define BRANCH_IF_JALAPENO(tmp1,tmp2,label)	\
51a439fe51SSam Ravnborg 	rdpr	%ver, %tmp1;			\
52a439fe51SSam Ravnborg 	sethi	%hi(__JALAPENO_ID), %tmp2;	\
53a439fe51SSam Ravnborg 	srlx	%tmp1, 32, %tmp1;		\
54a439fe51SSam Ravnborg 	or	%tmp2, %lo(__JALAPENO_ID), %tmp2;\
55a439fe51SSam Ravnborg 	cmp	%tmp1, %tmp2;			\
56a439fe51SSam Ravnborg 	be,pn	%icc, label;			\
57a439fe51SSam Ravnborg 	 nop;
58a439fe51SSam Ravnborg 
59a439fe51SSam Ravnborg #define BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(tmp1,tmp2,label)	\
60a439fe51SSam Ravnborg 	rdpr	%ver, %tmp1;			\
61a439fe51SSam Ravnborg 	srlx	%tmp1, (32 + 16), %tmp2;	\
62a439fe51SSam Ravnborg 	cmp	%tmp2, CHEETAH_MANUF;		\
63a439fe51SSam Ravnborg 	bne,pt	%xcc, 99f;			\
64a439fe51SSam Ravnborg 	 sllx	%tmp1, 16, %tmp1;		\
65a439fe51SSam Ravnborg 	srlx	%tmp1, (32 + 16), %tmp2;	\
66a439fe51SSam Ravnborg 	cmp	%tmp2, CHEETAH_PLUS_IMPL;	\
67a439fe51SSam Ravnborg 	bgeu,pt	%xcc, label;			\
68a439fe51SSam Ravnborg 99:	 nop;
69a439fe51SSam Ravnborg 
70a439fe51SSam Ravnborg #define BRANCH_IF_ANY_CHEETAH(tmp1,tmp2,label)	\
71a439fe51SSam Ravnborg 	rdpr	%ver, %tmp1;			\
72a439fe51SSam Ravnborg 	srlx	%tmp1, (32 + 16), %tmp2;	\
73a439fe51SSam Ravnborg 	cmp	%tmp2, CHEETAH_MANUF;		\
74a439fe51SSam Ravnborg 	bne,pt	%xcc, 99f;			\
75a439fe51SSam Ravnborg 	 sllx	%tmp1, 16, %tmp1;		\
76a439fe51SSam Ravnborg 	srlx	%tmp1, (32 + 16), %tmp2;	\
77a439fe51SSam Ravnborg 	cmp	%tmp2, CHEETAH_IMPL;		\
78a439fe51SSam Ravnborg 	bgeu,pt	%xcc, label;			\
79a439fe51SSam Ravnborg 99:	 nop;
80a439fe51SSam Ravnborg 
81a439fe51SSam Ravnborg #endif /* !(_SPARC64_HEAD_H) */
82