1*33a78575Sryo /* $NetBSD: intr.h,v 1.15 2021/11/02 11:26:04 ryo Exp $ */
2e8300f36Such
3e8300f36Such /*-
4e8300f36Such * Copyright (c) 2002 The NetBSD Foundation, Inc.
5e8300f36Such * All rights reserved.
6e8300f36Such *
7e8300f36Such * Redistribution and use in source and binary forms, with or without
8e8300f36Such * modification, are permitted provided that the following conditions
9e8300f36Such * are met:
10e8300f36Such * 1. Redistributions of source code must retain the above copyright
11e8300f36Such * notice, this list of conditions and the following disclaimer.
12e8300f36Such * 2. Redistributions in binary form must reproduce the above copyright
13e8300f36Such * notice, this list of conditions and the following disclaimer in the
14e8300f36Such * documentation and/or other materials provided with the distribution.
15e8300f36Such *
16e8300f36Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17e8300f36Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18e8300f36Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19e8300f36Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20e8300f36Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21e8300f36Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22e8300f36Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23e8300f36Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24e8300f36Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25e8300f36Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26e8300f36Such * POSSIBILITY OF SUCH DAMAGE.
27e8300f36Such */
28e8300f36Such
2965363da2Sitojun #ifndef _EVBSH3_INTR_H_
3065363da2Sitojun #define _EVBSH3_INTR_H_
3165363da2Sitojun
3265363da2Sitojun #include <sh3/intr.h>
3365363da2Sitojun
34e8300f36Such /* Number of interrupt source */
35238763f6Snonaka #define _INTR_N 16 /* TMU0, TMU1, TMU2, (SCIF and SCI) * 4 */
3665363da2Sitojun
37e8300f36Such /* Interrupt priority levels */
384b293a84Sad #define IPL_VM 12
394b293a84Sad #define IPL_SCHED 14 /* clock */
40e8300f36Such #define IPL_HIGH 15 /* everything */
417ae4a95cSmsaitoh
42b07ec3fcSad typedef uint8_t ipl_t;
438bf76628Syamt typedef struct {
448bf76628Syamt ipl_t _ipl;
458bf76628Syamt } ipl_cookie_t;
468bf76628Syamt
47*33a78575Sryo static inline __always_inline ipl_cookie_t
makeiplcookie(ipl_t ipl)488bf76628Syamt makeiplcookie(ipl_t ipl)
498bf76628Syamt {
508bf76628Syamt
518bf76628Syamt return (ipl_cookie_t){._ipl = ipl << 4};
528bf76628Syamt }
538bf76628Syamt
54*33a78575Sryo static inline __always_inline int
splraiseipl(ipl_cookie_t icookie)558bf76628Syamt splraiseipl(ipl_cookie_t icookie)
568bf76628Syamt {
578bf76628Syamt
588bf76628Syamt return _cpu_intr_raise(icookie._ipl);
598bf76628Syamt }
60ba380162Syamt
61ba380162Syamt #include <sys/spl.h>
6265363da2Sitojun
63e8300f36Such #define spl0() _cpu_intr_resume(0)
64e8300f36Such #define splx(x) _cpu_intr_resume(x)
657ae4a95cSmsaitoh
66e8300f36Such #endif /* !_EVBSH3_INTR_H_ */
67