1 1.23 andvar /* $NetBSD: psl.h,v 1.23 2024/02/08 20:51:24 andvar 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.21 rin 34 1.6 matt #ifndef _POWERPC_PSL_H_ 35 1.6 matt #define _POWERPC_PSL_H_ 36 1.1 ws 37 1.1 ws /* 38 1.3 thorpej * Machine State Register (MSR) 39 1.3 thorpej * 40 1.3 thorpej * The PowerPC 601 does not implement the following bits: 41 1.3 thorpej * 42 1.5 matt * VEC, POW, ILE, BE, RI, LE[*] 43 1.3 thorpej * 44 1.3 thorpej * [*] Little-endian mode on the 601 is implemented in the HID0 register. 45 1.1 ws */ 46 1.15 matt #define PSL_VEC 0x02000000 /* ..6. AltiVec vector unit available */ 47 1.16 matt #define PSL_SPV 0x02000000 /* B... (e500) SPE enable */ 48 1.15 matt #define PSL_UCLE 0x00400000 /* B... user-mode cache lock enable */ 49 1.15 matt #define PSL_POW 0x00040000 /* ..6. power management */ 50 1.15 matt #define PSL_WE PSL_POW /* B4.. wait state enable */ 51 1.15 matt #define PSL_TGPR 0x00020000 /* ..6. temp. gpr remapping (mpc603e) */ 52 1.15 matt #define PSL_CE PSL_TGPR /* B4.. critical interrupt enable */ 53 1.15 matt #define PSL_ILE 0x00010000 /* ..6. interrupt endian mode (1 == le) */ 54 1.15 matt #define PSL_EE 0x00008000 /* B468 external interrupt enable */ 55 1.15 matt #define PSL_PR 0x00004000 /* B468 privilege mode (1 == user) */ 56 1.15 matt #define PSL_FP 0x00002000 /* B.6. floating point enable */ 57 1.15 matt #define PSL_ME 0x00001000 /* B468 machine check enable */ 58 1.15 matt #define PSL_FE0 0x00000800 /* B.6. floating point mode 0 */ 59 1.15 matt #define PSL_SE 0x00000400 /* ..6. single-step trace enable */ 60 1.15 matt #define PSL_DWE PSL_SE /* .4.. debug wait enable */ 61 1.15 matt #define PSL_UBLE PSL_SE /* B... user BTB lock enable */ 62 1.15 matt #define PSL_BE 0x00000200 /* ..6. branch trace enable */ 63 1.15 matt #define PSL_DE PSL_BE /* B4.. debug interrupt enable */ 64 1.15 matt #define PSL_FE1 0x00000100 /* B.6. floating point mode 1 */ 65 1.15 matt #define PSL_IP 0x00000040 /* ..6. interrupt prefix */ 66 1.15 matt #define PSL_IR 0x00000020 /* .468 instruction address relocation */ 67 1.15 matt #define PSL_IS PSL_IR /* B... instruction address space */ 68 1.15 matt #define PSL_DR 0x00000010 /* .468 data address relocation */ 69 1.15 matt #define PSL_DS PSL_DR /* B... data address space */ 70 1.15 matt #define PSL_PM 0x00000008 /* ..6. Performance monitor */ 71 1.15 matt #define PSL_PMM PSL_PM /* B... Performance monitor */ 72 1.15 matt #define PSL_RI 0x00000002 /* ..6. recoverable interrupt */ 73 1.15 matt #define PSL_LE 0x00000001 /* ..6. endian mode (1 == le) */ 74 1.3 thorpej 75 1.12 kleink #define PSL_601_MASK ~(PSL_VEC|PSL_POW|PSL_ILE|PSL_BE|PSL_RI|PSL_LE) 76 1.1 ws 77 1.23 andvar /* The IBM 970 series does not implement LE mode */ 78 1.14 sanjayl #define PSL_970_MASK ~(PSL_ILE|PSL_LE) 79 1.14 sanjayl 80 1.1 ws /* 81 1.1 ws * Floating-point exception modes: 82 1.1 ws */ 83 1.3 thorpej #define PSL_FE_DIS 0 /* none */ 84 1.3 thorpej #define PSL_FE_NONREC PSL_FE1 /* imprecise non-recoverable */ 85 1.3 thorpej #define PSL_FE_REC PSL_FE0 /* imprecise recoverable */ 86 1.3 thorpej #define PSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */ 87 1.3 thorpej #define PSL_FE_DFLT PSL_FE_DIS /* default == none */ 88 1.1 ws 89 1.1 ws /* 90 1.1 ws * Note that PSL_POW and PSL_ILE are not in the saved copy of the MSR 91 1.1 ws */ 92 1.1 ws #define PSL_MBO 0 93 1.1 ws #define PSL_MBZ 0 94 1.1 ws 95 1.9 matt /* 96 1.9 matt * A user is not allowed to change any MSR bits except the following: 97 1.10 matt * We restrict the test to the low 16 bits of the MSR since those are the 98 1.10 matt * only ones preserved in the trap. Note that this means PSL_VEC needs to 99 1.11 kleink * be restored to SRR1 in userret. 100 1.9 matt */ 101 1.12 kleink #if defined(_KERNEL) && !defined(_LOCORE) 102 1.12 kleink #ifdef _KERNEL_OPT 103 1.12 kleink #include "opt_ppcarch.h" 104 1.12 kleink #endif /* _KERNEL_OPT */ 105 1.12 kleink 106 1.19 matt #if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) || defined (PPC_OEA64) \ 107 1.19 matt || defined(_MODULE) 108 1.18 matt extern register_t cpu_psluserset, cpu_pslusermod, cpu_pslusermask; 109 1.12 kleink 110 1.12 kleink #define PSL_USERSET cpu_psluserset 111 1.12 kleink #define PSL_USERMOD cpu_pslusermod 112 1.18 matt #define PSL_USERMASK cpu_pslusermask 113 1.16 matt #elif defined(PPC_BOOKE) 114 1.22 rin #define PSL_USERSET (PSL_EE | PSL_PR | PSL_IS | PSL_DS | PSL_ME | PSL_CE) 115 1.18 matt #define PSL_USERMASK (PSL_SPV | PSL_CE | 0xFFFF) 116 1.20 matt #define PSL_USERMOD (0) 117 1.12 kleink #else /* PPC_IBM4XX */ 118 1.18 matt #ifdef PPC_IBM403 119 1.18 matt #define PSL_USERSET (PSL_EE | PSL_PR | PSL_IR | PSL_DR | PSL_ME) 120 1.18 matt #else /* Apparently we get unexplained machine checks, so disable them. */ 121 1.18 matt #define PSL_USERSET (PSL_EE | PSL_PR | PSL_IR | PSL_DR) 122 1.18 matt #endif 123 1.18 matt #define PSL_USERMASK 0xFFFF 124 1.12 kleink #define PSL_USERMOD (0) 125 1.22 rin #endif 126 1.12 kleink 127 1.18 matt #define PSL_USERSRR1 ((PSL_USERSET|PSL_USERMOD) & PSL_USERMASK) 128 1.10 matt #define PSL_USEROK_P(psl) (((psl) & ~PSL_USERMOD) == PSL_USERSET) 129 1.12 kleink #endif /* !_LOCORE */ 130 1.1 ws 131 1.6 matt #endif /* _POWERPC_PSL_H_ */ 132