1*c60cfbdcSthorpej /* $NetBSD: intr.h,v 1.26 2024/01/19 03:09:05 thorpej Exp $ */
2c1c742b4Sfredette
344ce13b2Sthorpej /*-
444ce13b2Sthorpej * Copyright (c) 2024 The NetBSD Foundation, Inc.
5c1c742b4Sfredette * All rights reserved.
6c1c742b4Sfredette *
744ce13b2Sthorpej * This code is derived from software contributed to The NetBSD Foundation
844ce13b2Sthorpej * by Jason R. Thorpe.
944ce13b2Sthorpej *
10c1c742b4Sfredette * Redistribution and use in source and binary forms, with or without
11c1c742b4Sfredette * modification, are permitted provided that the following conditions
12c1c742b4Sfredette * are met:
13c1c742b4Sfredette * 1. Redistributions of source code must retain the above copyright
14c1c742b4Sfredette * notice, this list of conditions and the following disclaimer.
15c1c742b4Sfredette * 2. Redistributions in binary form must reproduce the above copyright
16c1c742b4Sfredette * notice, this list of conditions and the following disclaimer in the
17c1c742b4Sfredette * documentation and/or other materials provided with the distribution.
18c1c742b4Sfredette *
1944ce13b2Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2044ce13b2Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2144ce13b2Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2244ce13b2Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2344ce13b2Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2444ce13b2Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2544ce13b2Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2644ce13b2Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2744ce13b2Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2844ce13b2Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2944ce13b2Sthorpej * POSSIBILITY OF SUCH DAMAGE.
30c1c742b4Sfredette */
31c1c742b4Sfredette
32c1c742b4Sfredette #ifndef _SUN68K_INTR_H_
33c1c742b4Sfredette #define _SUN68K_INTR_H_
34c1c742b4Sfredette
35*c60cfbdcSthorpej #ifdef _KERNEL
36*c60cfbdcSthorpej
37fa924b7bSchs #include <m68k/psl.h>
38c1c742b4Sfredette
3944ce13b2Sthorpej #define MACHINE_PSL_IPL_SOFTCLOCK PSL_IPL1
4044ce13b2Sthorpej #define MACHINE_PSL_IPL_SOFTBIO PSL_IPL1
4144ce13b2Sthorpej #define MACHINE_PSL_IPL_SOFTNET PSL_IPL1
4244ce13b2Sthorpej #define MACHINE_PSL_IPL_SOFTSERIAL PSL_IPL3
4344ce13b2Sthorpej #define MACHINE_PSL_IPL_VM PSL_IPL4
4444ce13b2Sthorpej #define MACHINE_PSL_IPL_SCHED PSL_IPL7
4544ce13b2Sthorpej
469ded135dSthorpej #define MACHINE_INTREVCNT_NAMES \
479ded135dSthorpej { "spur", "lev1", "lev2", "lev3", "lev4", "clock", "lev6", "nmi" }
489ded135dSthorpej
4944ce13b2Sthorpej /* Zilog Serial hardware interrupts (hard-wired at 6) */
5044ce13b2Sthorpej #define splzs() splserial() /* aliased to splhigh() */
5144ce13b2Sthorpej #define IPL_ZS IPL_SERIAL
528bf76628Syamt
53c1c742b4Sfredette #define _IPL_SOFT_LEVEL1 1
54c1c742b4Sfredette #define _IPL_SOFT_LEVEL2 2
55c1c742b4Sfredette #define _IPL_SOFT_LEVEL3 3
56c1c742b4Sfredette #define _IPL_SOFT_LEVEL_MIN 1
57c1c742b4Sfredette #define _IPL_SOFT_LEVEL_MAX 3
5829b4acdaSyamt
59*c60cfbdcSthorpej #endif /* _KERNEL */
60*c60cfbdcSthorpej
6144ce13b2Sthorpej #include <m68k/intr.h>
62ff1a985cSriastradh
63c1c742b4Sfredette #ifdef _KERNEL
648bf76628Syamt
6544ce13b2Sthorpej /*
6644ce13b2Sthorpej * Aliases for the legacy sun68k ISR routines.
6744ce13b2Sthorpej */
68aecc2565Stsutsui
6910b1a7beSchs typedef int (*isr_func_t)(void *);
70c1c742b4Sfredette
7144ce13b2Sthorpej static inline void
isr_add_autovect(isr_func_t func,void * arg,int ipl)7244ce13b2Sthorpej isr_add_autovect(isr_func_t func, void *arg, int ipl)
7344ce13b2Sthorpej {
7444ce13b2Sthorpej /* XXX leaks interrupt handle. */
7544ce13b2Sthorpej m68k_intr_establish(func, arg, (void *)0, 0, ipl, 0, 0);
7644ce13b2Sthorpej }
77fa924b7bSchs
7844ce13b2Sthorpej static inline void
isr_add_vectored(isr_func_t func,void * arg,int ipl,int vec)7944ce13b2Sthorpej isr_add_vectored(isr_func_t func, void *arg, int ipl, int vec)
8044ce13b2Sthorpej {
8144ce13b2Sthorpej /* XXX leaks interrupt handle. */
8244ce13b2Sthorpej m68k_intr_establish(func, arg, (void *)0, vec, ipl, 0, 0);
8344ce13b2Sthorpej }
84fa924b7bSchs
85fa924b7bSchs /* This returns true iff the spl given is spl0. */
86fa924b7bSchs #define is_spl0(s) (((s) & PSL_IPL7) == 0)
87fa924b7bSchs
88c1c742b4Sfredette #endif /* _KERNEL */
89fa924b7bSchs
90c1c742b4Sfredette #endif /* _SUN68K_INTR_H */
91