1*09292d52Suwe /* $NetBSD: psl.h,v 1.12 2020/08/03 16:43:44 uwe Exp $ */
265363da2Sitojun
365363da2Sitojun /*-
465363da2Sitojun * Copyright (c) 1990 The Regents of the University of California.
565363da2Sitojun * All rights reserved.
665363da2Sitojun *
765363da2Sitojun * This code is derived from software contributed to Berkeley by
865363da2Sitojun * William Jolitz.
965363da2Sitojun *
1065363da2Sitojun * Redistribution and use in source and binary forms, with or without
1165363da2Sitojun * modification, are permitted provided that the following conditions
1265363da2Sitojun * are met:
1365363da2Sitojun * 1. Redistributions of source code must retain the above copyright
1465363da2Sitojun * notice, this list of conditions and the following disclaimer.
1565363da2Sitojun * 2. Redistributions in binary form must reproduce the above copyright
1665363da2Sitojun * notice, this list of conditions and the following disclaimer in the
1765363da2Sitojun * documentation and/or other materials provided with the distribution.
18aad01611Sagc * 3. Neither the name of the University nor the names of its contributors
1965363da2Sitojun * may be used to endorse or promote products derived from this software
2065363da2Sitojun * without specific prior written permission.
2165363da2Sitojun *
2265363da2Sitojun * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2365363da2Sitojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2465363da2Sitojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2565363da2Sitojun * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2665363da2Sitojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2765363da2Sitojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2865363da2Sitojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2965363da2Sitojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3065363da2Sitojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3165363da2Sitojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3265363da2Sitojun * SUCH DAMAGE.
3365363da2Sitojun *
3465363da2Sitojun * @(#)psl.h 5.2 (Berkeley) 1/18/91
3565363da2Sitojun */
3665363da2Sitojun
3765363da2Sitojun #ifndef _SH3_PSL_H_
3865363da2Sitojun #define _SH3_PSL_H_
3965363da2Sitojun
4065363da2Sitojun /*
4190baa8b2Such * SuperH Processer Status Register.
4265363da2Sitojun */
4365363da2Sitojun #define PSL_TBIT 0x00000001 /* T bit */
4465363da2Sitojun #define PSL_SBIT 0x00000002 /* S bit */
4565363da2Sitojun #define PSL_IMASK 0x000000f0 /* Interrupt Mask bit */
4665363da2Sitojun #define PSL_QBIT 0x00000100 /* Q bit */
4765363da2Sitojun #define PSL_MBIT 0x00000200 /* M bit */
489e17c3f5Suwe #define PSL_FD 0x00008000 /* FPU Disable bit */
4990baa8b2Such #define PSL_BL 0x10000000 /* Exception Block bit */
5065363da2Sitojun #define PSL_RB 0x20000000 /* Register Bank bit */
5165363da2Sitojun #define PSL_MD 0x40000000 /* Processor Mode bit */
5290baa8b2Such /* 1 = kernel, 0 = user */
5365363da2Sitojun
5465363da2Sitojun #define PSL_MBO 0x00000000 /* must be one bits */
5565363da2Sitojun #define PSL_MBZ 0x8ffffc0c /* must be zero bits */
5665363da2Sitojun
5765363da2Sitojun #define PSL_USERSET 0
58cbcd644cSmsaitoh #define PSL_USERSTATIC (PSL_BL|PSL_RB|PSL_MD|PSL_IMASK|PSL_MBO|PSL_MBZ)
5965363da2Sitojun
6090baa8b2Such #define KERNELMODE(sr) ((sr) & PSL_MD)
6190baa8b2Such
6265363da2Sitojun #ifdef _KERNEL
6390baa8b2Such #ifndef _LOCORE
6492dc06bfSuwe
65*09292d52Suwe static inline __always_inline void
_cpu_set_sr(uint32_t sr)66*09292d52Suwe _cpu_set_sr(uint32_t sr)
67*09292d52Suwe {
68*09292d52Suwe __asm volatile("ldc %0, sr" :: "r"(sr));
69*09292d52Suwe }
70*09292d52Suwe
7124ec477aSuch /* SR.IMASK */
7224ec477aSuch int _cpu_intr_raise(int);
7324ec477aSuch int _cpu_intr_suspend(void);
7424ec477aSuch int _cpu_intr_resume(int);
7592dc06bfSuwe
7624ec477aSuch /* SR.BL */
7724ec477aSuch int _cpu_exception_suspend(void);
7824ec477aSuch void _cpu_exception_resume(int);
7990baa8b2Such
8092dc06bfSuwe #endif /* !_LOCORE */
8190baa8b2Such #endif /* _KERNEL */
8265363da2Sitojun
8365363da2Sitojun #endif /* !_SH3_PSL_H_ */
84