Home | History | Annotate | Line # | Download | only in include
psl.h revision 1.18
      1  1.18     matt /*	$NetBSD: psl.h,v 1.18 2011/06/20 07:23:36 matt Exp $	*/
      2   1.1       ws 
      3   1.1       ws /*
      4   1.1       ws  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5   1.1       ws  * Copyright (C) 1995, 1996 TooLs GmbH.
      6   1.1       ws  * All rights reserved.
      7   1.1       ws  *
      8   1.1       ws  * Redistribution and use in source and binary forms, with or without
      9   1.1       ws  * modification, are permitted provided that the following conditions
     10   1.1       ws  * are met:
     11   1.1       ws  * 1. Redistributions of source code must retain the above copyright
     12   1.1       ws  *    notice, this list of conditions and the following disclaimer.
     13   1.1       ws  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1       ws  *    notice, this list of conditions and the following disclaimer in the
     15   1.1       ws  *    documentation and/or other materials provided with the distribution.
     16   1.1       ws  * 3. All advertising materials mentioning features or use of this software
     17   1.1       ws  *    must display the following acknowledgement:
     18   1.1       ws  *	This product includes software developed by TooLs GmbH.
     19   1.1       ws  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20   1.1       ws  *    derived from this software without specific prior written permission.
     21   1.1       ws  *
     22   1.1       ws  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23   1.1       ws  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1       ws  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1       ws  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26   1.1       ws  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27   1.1       ws  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28   1.1       ws  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29   1.1       ws  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30   1.1       ws  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31   1.1       ws  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1       ws  */
     33   1.6     matt #ifndef	_POWERPC_PSL_H_
     34   1.6     matt #define	_POWERPC_PSL_H_
     35   1.1       ws 
     36   1.1       ws /*
     37   1.3  thorpej  * Machine State Register (MSR)
     38   1.3  thorpej  *
     39   1.3  thorpej  * The PowerPC 601 does not implement the following bits:
     40   1.3  thorpej  *
     41   1.5     matt  *	VEC, POW, ILE, BE, RI, LE[*]
     42   1.3  thorpej  *
     43   1.3  thorpej  * [*] Little-endian mode on the 601 is implemented in the HID0 register.
     44   1.1       ws  */
     45  1.15     matt #define	PSL_VEC		0x02000000	/* ..6. AltiVec vector unit available */
     46  1.16     matt #define	PSL_SPV		0x02000000	/* B... (e500) SPE enable */
     47  1.15     matt #define	PSL_UCLE	0x00400000	/* B... user-mode cache lock enable */
     48  1.15     matt #define	PSL_POW		0x00040000	/* ..6. power management */
     49  1.15     matt #define	PSL_WE		PSL_POW		/* B4.. wait state enable */
     50  1.15     matt #define	PSL_TGPR	0x00020000	/* ..6. temp. gpr remapping (mpc603e) */
     51  1.15     matt #define	PSL_CE		PSL_TGPR	/* B4.. critical interrupt enable */
     52  1.15     matt #define	PSL_ILE		0x00010000	/* ..6. interrupt endian mode (1 == le) */
     53  1.15     matt #define	PSL_EE		0x00008000	/* B468 external interrupt enable */
     54  1.15     matt #define	PSL_PR		0x00004000	/* B468 privilege mode (1 == user) */
     55  1.15     matt #define	PSL_FP		0x00002000	/* B.6. floating point enable */
     56  1.15     matt #define	PSL_ME		0x00001000	/* B468 machine check enable */
     57  1.15     matt #define	PSL_FE0		0x00000800	/* B.6. floating point mode 0 */
     58  1.15     matt #define	PSL_SE		0x00000400	/* ..6. single-step trace enable */
     59  1.15     matt #define	PSL_DWE		PSL_SE		/* .4.. debug wait enable */
     60  1.15     matt #define	PSL_UBLE	PSL_SE		/* B... user BTB lock enable */
     61  1.15     matt #define	PSL_BE		0x00000200	/* ..6. branch trace enable */
     62  1.15     matt #define	PSL_DE		PSL_BE		/* B4.. debug interrupt enable */
     63  1.15     matt #define	PSL_FE1		0x00000100	/* B.6. floating point mode 1 */
     64  1.15     matt #define	PSL_IP		0x00000040	/* ..6. interrupt prefix */
     65  1.15     matt #define	PSL_IR		0x00000020	/* .468 instruction address relocation */
     66  1.15     matt #define	PSL_IS		PSL_IR		/* B... instruction address space */
     67  1.15     matt #define	PSL_DR		0x00000010	/* .468 data address relocation */
     68  1.15     matt #define	PSL_DS		PSL_DR		/* B... data address space */
     69  1.15     matt #define	PSL_PM		0x00000008	/* ..6. Performance monitor */
     70  1.15     matt #define	PSL_PMM		PSL_PM		/* B... Performance monitor */
     71  1.15     matt #define	PSL_RI		0x00000002	/* ..6. recoverable interrupt */
     72  1.15     matt #define	PSL_LE		0x00000001	/* ..6. endian mode (1 == le) */
     73   1.3  thorpej 
     74  1.12   kleink #define	PSL_601_MASK	~(PSL_VEC|PSL_POW|PSL_ILE|PSL_BE|PSL_RI|PSL_LE)
     75   1.1       ws 
     76  1.14  sanjayl /* The IBM 970 series does not implemnt LE mode */
     77  1.14  sanjayl #define PSL_970_MASK	~(PSL_ILE|PSL_LE)
     78  1.14  sanjayl 
     79   1.1       ws /*
     80   1.1       ws  * Floating-point exception modes:
     81   1.1       ws  */
     82   1.3  thorpej #define	PSL_FE_DIS	0		/* none */
     83   1.3  thorpej #define	PSL_FE_NONREC	PSL_FE1		/* imprecise non-recoverable */
     84   1.3  thorpej #define	PSL_FE_REC	PSL_FE0		/* imprecise recoverable */
     85   1.3  thorpej #define	PSL_FE_PREC	(PSL_FE0 | PSL_FE1) /* precise */
     86   1.3  thorpej #define	PSL_FE_DFLT	PSL_FE_DIS	/* default == none */
     87   1.1       ws 
     88   1.1       ws /*
     89   1.1       ws  * Note that PSL_POW and PSL_ILE are not in the saved copy of the MSR
     90   1.1       ws  */
     91   1.1       ws #define	PSL_MBO		0
     92   1.1       ws #define	PSL_MBZ		0
     93   1.1       ws 
     94   1.9     matt /*
     95   1.9     matt  * A user is not allowed to change any MSR bits except the following:
     96  1.10     matt  * We restrict the test to the low 16 bits of the MSR since those are the
     97  1.10     matt  * only ones preserved in the trap.  Note that this means PSL_VEC needs to
     98  1.11   kleink  * be restored to SRR1 in userret.
     99   1.9     matt  */
    100  1.12   kleink #if defined(_KERNEL) && !defined(_LOCORE)
    101  1.12   kleink #ifdef _KERNEL_OPT
    102  1.12   kleink #include "opt_ppcarch.h"
    103  1.12   kleink #endif /* _KERNEL_OPT */
    104  1.12   kleink 
    105  1.18     matt #if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) || defined(_MODULE)
    106  1.18     matt extern register_t cpu_psluserset, cpu_pslusermod, cpu_pslusermask;
    107  1.12   kleink 
    108  1.12   kleink #define	PSL_USERSET		cpu_psluserset
    109  1.12   kleink #define	PSL_USERMOD		cpu_pslusermod
    110  1.18     matt #define	PSL_USERMASK		cpu_pslusermask
    111  1.16     matt #elif defined(PPC_BOOKE)
    112  1.18     matt #define	PSL_USERSET		(PSL_EE | PSL_PR | PSL_IS | PSL_DS | PSL_ME | PSL_CE | PSL_DE)
    113  1.18     matt #define	PSL_USERMASK		(PSL_SPV | PSL_CE | 0xFFFF)
    114  1.17     matt #define	PSL_USERMOD		(PSL_SPV)
    115  1.12   kleink #else /* PPC_IBM4XX */
    116  1.18     matt #ifdef PPC_IBM403
    117  1.18     matt #define	PSL_USERSET		(PSL_EE | PSL_PR | PSL_IR | PSL_DR | PSL_ME)
    118  1.18     matt #else /* Apparently we get unexplained machine checks, so disable them. */
    119  1.18     matt #define	PSL_USERSET		(PSL_EE | PSL_PR | PSL_IR | PSL_DR)
    120  1.18     matt #endif
    121  1.18     matt #define	PSL_USERMASK		0xFFFF
    122  1.12   kleink #define	PSL_USERMOD		(0)
    123  1.18     matt /*
    124  1.18     matt  * We also need to override the PSL_SE bit.  4xx have completely different
    125  1.18     matt  * debug register support.  The SE bit is actually the DWE bit.  We want to
    126  1.18     matt  * set the DE bit to enable the debug regs instead of the DWE bit.
    127  1.18     matt  */
    128  1.18     matt #undef	PSL_SE
    129  1.18     matt #define	PSL_SE			PSL_DE
    130  1.12   kleink #endif /* PPC_OEA */
    131  1.12   kleink 
    132  1.18     matt #define	PSL_USERSRR1		((PSL_USERSET|PSL_USERMOD) & PSL_USERMASK)
    133  1.10     matt #define	PSL_USEROK_P(psl)	(((psl) & ~PSL_USERMOD) == PSL_USERSET)
    134  1.12   kleink #endif /* !_LOCORE */
    135   1.1       ws 
    136   1.6     matt #endif	/* _POWERPC_PSL_H_ */
    137