xref: /freebsd/sys/powerpc/include/psl.h (revision 51369649b03ece2aed3eb61b0c8214b9aa5b2fa2)
160727d8bSWarner Losh /*-
2*51369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-4-Clause
3*51369649SPedro F. Giffuni  *
4f9bac91bSBenno Rice  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5f9bac91bSBenno Rice  * Copyright (C) 1995, 1996 TooLs GmbH.
6f9bac91bSBenno Rice  * All rights reserved.
7f9bac91bSBenno Rice  *
8f9bac91bSBenno Rice  * Redistribution and use in source and binary forms, with or without
9f9bac91bSBenno Rice  * modification, are permitted provided that the following conditions
10f9bac91bSBenno Rice  * are met:
11f9bac91bSBenno Rice  * 1. Redistributions of source code must retain the above copyright
12f9bac91bSBenno Rice  *    notice, this list of conditions and the following disclaimer.
13f9bac91bSBenno Rice  * 2. Redistributions in binary form must reproduce the above copyright
14f9bac91bSBenno Rice  *    notice, this list of conditions and the following disclaimer in the
15f9bac91bSBenno Rice  *    documentation and/or other materials provided with the distribution.
16f9bac91bSBenno Rice  * 3. All advertising materials mentioning features or use of this software
17f9bac91bSBenno Rice  *    must display the following acknowledgement:
18f9bac91bSBenno Rice  *	This product includes software developed by TooLs GmbH.
19f9bac91bSBenno Rice  * 4. The name of TooLs GmbH may not be used to endorse or promote products
20f9bac91bSBenno Rice  *    derived from this software without specific prior written permission.
21f9bac91bSBenno Rice  *
22f9bac91bSBenno Rice  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23f9bac91bSBenno Rice  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24f9bac91bSBenno Rice  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25f9bac91bSBenno Rice  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26f9bac91bSBenno Rice  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27f9bac91bSBenno Rice  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28f9bac91bSBenno Rice  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29f9bac91bSBenno Rice  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30f9bac91bSBenno Rice  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31f9bac91bSBenno Rice  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32f9bac91bSBenno Rice  *
334ca98df6SBenno Rice  *	$NetBSD: psl.h,v 1.5 2000/11/19 19:52:37 matt Exp $
34f9bac91bSBenno Rice  * $FreeBSD$
35f9bac91bSBenno Rice  */
36f9bac91bSBenno Rice 
37f9bac91bSBenno Rice #ifndef	_MACHINE_PSL_H_
38f9bac91bSBenno Rice #define	_MACHINE_PSL_H_
39f9bac91bSBenno Rice 
40ffb56695SRafal Jaworowski /*
41d4602c72SNathan Whitehorn  * Machine State Register (MSR) - All cores
42ffb56695SRafal Jaworowski  */
43d4602c72SNathan Whitehorn #define	PSL_VEC		0x02000000UL	/* AltiVec/SPE vector unit available */
4435f612b8SNathan Whitehorn #define	PSL_VSX		0x00800000UL	/* Vector-Scalar unit available */
45c3e289e1SNathan Whitehorn #define	PSL_EE		0x00008000UL	/* external interrupt enable */
46c3e289e1SNathan Whitehorn #define	PSL_PR		0x00004000UL	/* privilege mode (1 == user) */
47c3e289e1SNathan Whitehorn #define	PSL_FP		0x00002000UL	/* floating point enable */
48c3e289e1SNathan Whitehorn #define	PSL_ME		0x00001000UL	/* machine check enable */
49c3e289e1SNathan Whitehorn #define	PSL_FE0		0x00000800UL	/* floating point interrupt mode 0 */
50c3e289e1SNathan Whitehorn #define	PSL_FE1		0x00000100UL	/* floating point interrupt mode 1 */
51d4602c72SNathan Whitehorn #define	PSL_PMM		0x00000004UL	/* performance monitor mark */
528ccebb44SJustin Hibbits #define	PSL_RI		0x00000002UL	/* recoverable interrupt */
53d4602c72SNathan Whitehorn 
54d4602c72SNathan Whitehorn /* Machine State Register - Book-E cores */
55e683c328SJustin Hibbits #ifdef __powerpc64__
56e683c328SJustin Hibbits #define	PSL_CM		0x80000000UL	/* Computation Mode (64-bit) */
57e683c328SJustin Hibbits #endif
58e683c328SJustin Hibbits 
598ccebb44SJustin Hibbits #define PSL_GS		0x10000000UL	/* Guest state */
60d4602c72SNathan Whitehorn #define PSL_UCLE	0x04000000UL	/* User mode cache lock enable */
61d4602c72SNathan Whitehorn #define PSL_WE		0x00040000UL	/* Wait state enable */
62d4602c72SNathan Whitehorn #define PSL_CE		0x00020000UL	/* Critical interrupt enable */
63d4602c72SNathan Whitehorn #define PSL_UBLE	0x00000400UL	/* BTB lock enable - e500 only */
64d4602c72SNathan Whitehorn #define PSL_DWE		0x00000400UL	/* Debug Wait Enable - 440 only*/
65d4602c72SNathan Whitehorn #define PSL_DE		0x00000200UL	/* Debug interrupt enable */
66d4602c72SNathan Whitehorn #define PSL_IS		0x00000020UL	/* Instruction address space */
67d4602c72SNathan Whitehorn #define PSL_DS		0x00000010UL	/* Data address space */
68d4602c72SNathan Whitehorn 
69d4602c72SNathan Whitehorn /* Machine State Register (MSR) - AIM cores */
70d4602c72SNathan Whitehorn #ifdef __powerpc64__
71d4602c72SNathan Whitehorn #define PSL_SF		0x8000000000000000UL	/* 64-bit addressing */
72d4602c72SNathan Whitehorn #define PSL_HV		0x1000000000000000UL	/* hyper-privileged mode */
73d4602c72SNathan Whitehorn #endif
74d4602c72SNathan Whitehorn 
75d4602c72SNathan Whitehorn #define	PSL_POW		0x00040000UL	/* power management */
76d4602c72SNathan Whitehorn #define	PSL_ILE		0x00010000UL	/* interrupt endian mode (1 == le) */
77d4602c72SNathan Whitehorn #define	PSL_SE		0x00000400UL	/* single-step trace enable */
788ccebb44SJustin Hibbits #define	PSL_BE		0x00000200UL	/* branch trace enable */
79d4602c72SNathan Whitehorn #define	PSL_IP		0x00000040UL	/* interrupt prefix - 601 only */
80c3e289e1SNathan Whitehorn #define	PSL_IR		0x00000020UL	/* instruction address relocation */
81c3e289e1SNathan Whitehorn #define	PSL_DR		0x00000010UL	/* data address relocation */
82c3e289e1SNathan Whitehorn #define	PSL_LE		0x00000001UL	/* endian mode (1 == le) */
83f9bac91bSBenno Rice 
84f9bac91bSBenno Rice /*
85f9bac91bSBenno Rice  * Floating-point exception modes:
86f9bac91bSBenno Rice  */
87f9bac91bSBenno Rice #define	PSL_FE_DIS	0		/* none */
88f9bac91bSBenno Rice #define	PSL_FE_NONREC	PSL_FE1		/* imprecise non-recoverable */
89f9bac91bSBenno Rice #define	PSL_FE_REC	PSL_FE0		/* imprecise recoverable */
90f9bac91bSBenno Rice #define	PSL_FE_PREC	(PSL_FE0 | PSL_FE1) /* precise */
91f9bac91bSBenno Rice #define	PSL_FE_DFLT	PSL_FE_DIS	/* default == none */
92f9bac91bSBenno Rice 
93d4602c72SNathan Whitehorn #if defined(BOOKE_E500)
94d4602c72SNathan Whitehorn /* Initial kernel MSR, use IS=1 ad DS=1. */
95d4602c72SNathan Whitehorn #define PSL_KERNSET_INIT	(PSL_IS | PSL_DS)
96e683c328SJustin Hibbits #ifdef __powerpc64__
97e683c328SJustin Hibbits #define PSL_KERNSET		(PSL_CM | PSL_CE | PSL_ME | PSL_EE)
98e683c328SJustin Hibbits #else
99d4602c72SNathan Whitehorn #define PSL_KERNSET		(PSL_CE | PSL_ME | PSL_EE)
100e683c328SJustin Hibbits #endif
101ef53f64dSWarner Losh #define PSL_SRR1_MASK	0x00000000UL	/* No mask on Book-E */
102d4602c72SNathan Whitehorn #elif defined(BOOKE_PPC4XX)
103d4602c72SNathan Whitehorn #define PSL_KERNSET	(PSL_CE | PSL_ME | PSL_EE | PSL_FP)
104196321d6SJustin Hibbits #define PSL_SRR1_MASK	0x00000000UL	/* No mask on Book-E */
105d4602c72SNathan Whitehorn #elif defined(AIM)
106c3e289e1SNathan Whitehorn #ifdef __powerpc64__
107c3e289e1SNathan Whitehorn #define	PSL_KERNSET	(PSL_SF | PSL_EE | PSL_ME | PSL_IR | PSL_DR | PSL_RI)
108c3e289e1SNathan Whitehorn #else
1090cff3937SPeter Grehan #define	PSL_KERNSET	(PSL_EE | PSL_ME | PSL_IR | PSL_DR | PSL_RI)
110c3e289e1SNathan Whitehorn #endif
111a1e7448eSJustin Hibbits #define PSL_SRR1_MASK	0x783f0000UL	/* Bits 1-4, 10-15 (ppc32), 33-36, 42-47 (ppc64) */
112d4602c72SNathan Whitehorn #endif
113d4602c72SNathan Whitehorn 
1140cff3937SPeter Grehan #define	PSL_USERSET	(PSL_KERNSET | PSL_PR)
115196321d6SJustin Hibbits #define	PSL_USERSTATIC	(~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1) & ~PSL_SRR1_MASK)
116f9bac91bSBenno Rice 
117f9bac91bSBenno Rice #endif	/* _MACHINE_PSL_H_ */
118