1*33a78575Sryo /* $NetBSD: intr.h,v 1.10 2021/11/02 11:26:03 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
2983334549Smarcus #ifndef _DREAMCAST_INTR_H_
3083334549Smarcus #define _DREAMCAST_INTR_H_
3183334549Smarcus
3283334549Smarcus #include <sh3/intr.h>
3383334549Smarcus
34e8300f36Such /* Number of interrupt source */
357710d527Sitohy #define _INTR_N 10 /* TMU0, TMU1, TMU2, SCIF * 4, IRL * 3 */
3683334549Smarcus
37e8300f36Such /* Interrupt priority levels */
384b293a84Sad #define IPL_VM 12
394b293a84Sad #define IPL_SCHED 14
404b293a84Sad #define IPL_HIGH 15
4183334549Smarcus
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 }
608bf76628Syamt
618bf76628Syamt #include <sys/spl.h>
6283334549Smarcus
63e8300f36Such #define spl0() _cpu_intr_resume(0)
64e8300f36Such #define splx(x) _cpu_intr_resume(x)
6583334549Smarcus
66e8300f36Such #endif /* !_DREAMCAST_INTR_H_ */
67