1*864f2f83Svisa /* $OpenBSD: intr.h,v 1.14 2018/08/20 15:02:07 visa Exp $ */ 2d5f250e9Smiod /* 3d5f250e9Smiod * Copyright (c) 2001 Wasabi Systems, Inc. 4d5f250e9Smiod * All rights reserved. 5d5f250e9Smiod * 6d5f250e9Smiod * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7d5f250e9Smiod * 8d5f250e9Smiod * Redistribution and use in source and binary forms, with or without 9d5f250e9Smiod * modification, are permitted provided that the following conditions 10d5f250e9Smiod * are met: 11d5f250e9Smiod * 1. Redistributions of source code must retain the above copyright 12d5f250e9Smiod * notice, this list of conditions and the following disclaimer. 13d5f250e9Smiod * 2. Redistributions in binary form must reproduce the above copyright 14d5f250e9Smiod * notice, this list of conditions and the following disclaimer in the 15d5f250e9Smiod * documentation and/or other materials provided with the distribution. 16d5f250e9Smiod * 3. All advertising materials mentioning features or use of this software 17d5f250e9Smiod * must display the following acknowledgement: 18d5f250e9Smiod * This product includes software developed for the NetBSD Project by 19d5f250e9Smiod * Wasabi Systems, Inc. 20d5f250e9Smiod * 4. The name of Wasabi Systems, Inc. may not be used to endorse 21d5f250e9Smiod * or promote products derived from this software without specific prior 22d5f250e9Smiod * written permission. 23d5f250e9Smiod * 24d5f250e9Smiod * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 25d5f250e9Smiod * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26d5f250e9Smiod * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27d5f250e9Smiod * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 28d5f250e9Smiod * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29d5f250e9Smiod * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30d5f250e9Smiod * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31d5f250e9Smiod * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32d5f250e9Smiod * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33d5f250e9Smiod * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34d5f250e9Smiod * POSSIBILITY OF SUCH DAMAGE. 35d5f250e9Smiod */ 363180e169Smiod /* 373180e169Smiod * Copyright (C) 2000 Steve Murphree, Jr. 383180e169Smiod * All rights reserved. 393180e169Smiod * 403180e169Smiod * Redistribution and use in source and binary forms, with or without 413180e169Smiod * modification, are permitted provided that the following conditions 423180e169Smiod * are met: 433180e169Smiod * 1. Redistributions of source code must retain the above copyright 443180e169Smiod * notice, this list of conditions and the following disclaimer. 453180e169Smiod * 2. Redistributions in binary form must reproduce the above copyright 463180e169Smiod * notice, this list of conditions and the following disclaimer in the 473180e169Smiod * documentation and/or other materials provided with the distribution. 483180e169Smiod * 3. The name of the author may not be used to endorse or promote products 493180e169Smiod * derived from this software without specific prior written permission. 503180e169Smiod * 513180e169Smiod * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 523180e169Smiod * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 533180e169Smiod * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 543180e169Smiod * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 553180e169Smiod * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 563180e169Smiod * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 573180e169Smiod * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 583180e169Smiod * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 593180e169Smiod * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 603180e169Smiod * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 613180e169Smiod */ 623180e169Smiod 633180e169Smiod #ifndef _M88K_INTR_H_ 643180e169Smiod #define _M88K_INTR_H_ 653180e169Smiod 663180e169Smiod #ifdef _KERNEL 673180e169Smiod #ifndef _LOCORE 683596c44cSmiod int getipl(void); 693596c44cSmiod int setipl(int level); 701fd203a6Sdlg int splraise(int); 713180e169Smiod int spl0(void); 723180e169Smiod 733180e169Smiod /* SPL asserts */ 743180e169Smiod #ifdef DIAGNOSTIC 753180e169Smiod /* 763180e169Smiod * Although this function is implemented in MI code, it must be in this MD 773180e169Smiod * header because we don't want this header to include MI includes. 783180e169Smiod */ 793180e169Smiod void splassert_fail(int, int, const char *); 803180e169Smiod extern int splassert_ctl; 813180e169Smiod void splassert_check(int, const char *); 823180e169Smiod #define splassert(__wantipl) do { \ 83032bee17Sthib if (splassert_ctl > 0) { \ 843180e169Smiod splassert_check(__wantipl, __func__); \ 853180e169Smiod } \ 863180e169Smiod } while (0) 87d5f250e9Smiod #define splsoftassert(wantipl) splassert(IPL_SOFTINT) 883180e169Smiod #else 893180e169Smiod #define splassert(wantipl) do { /* nothing */ } while (0) 90312f6203Smiod #define splsoftassert(wantipl) do { /* nothing */ } while (0) 913180e169Smiod #endif 923180e169Smiod 933180e169Smiod #endif /* _LOCORE */ 943180e169Smiod 951fd203a6Sdlg #define splsoftclock() splraise(IPL_SOFTINT) 961fd203a6Sdlg #define splsoftnet() splraise(IPL_SOFTINT) 971fd203a6Sdlg #define splbio() splraise(IPL_BIO) 981fd203a6Sdlg #define splnet() splraise(IPL_NET) 991fd203a6Sdlg #define spltty() splraise(IPL_TTY) 1001fd203a6Sdlg #define splclock() splraise(IPL_CLOCK) 1011fd203a6Sdlg #define splstatclock() splraise(IPL_STATCLOCK) 1021fd203a6Sdlg #define splsched() splraise(IPL_SCHED) 1031fd203a6Sdlg #define splvm() splraise(IPL_VM) 1043180e169Smiod #define splhigh() setipl(IPL_HIGH) 1053180e169Smiod 1063180e169Smiod #define splx(x) ((x) ? setipl((x)) : spl0()) 1073180e169Smiod 108d5f250e9Smiod /* 109d5f250e9Smiod * Generic software interrupt support for all m88k platforms. 110d5f250e9Smiod */ 111d5f250e9Smiod 112d5f250e9Smiod #ifndef _LOCORE 113d5f250e9Smiod 114d5f250e9Smiod #define IPL_SOFT 0 115d5f250e9Smiod #define IPL_SOFTCLOCK 1 116d5f250e9Smiod #define IPL_SOFTNET 2 117d5f250e9Smiod #define IPL_SOFTTTY 3 118d5f250e9Smiod 119d5f250e9Smiod #define SI_SOFT 0 /* for IPL_SOFT */ 120d5f250e9Smiod #define SI_SOFTCLOCK 1 /* for IPL_SOFTCLOCK */ 121d5f250e9Smiod #define SI_SOFTNET 2 /* for IPL_SOFTNET */ 122d5f250e9Smiod #define SI_SOFTTTY 3 /* for IPL_SOFTTTY */ 123d5f250e9Smiod 124d5f250e9Smiod #define SI_NQUEUES 4 125d5f250e9Smiod 126d5f250e9Smiod #include <machine/mutex.h> 127d5f250e9Smiod #include <sys/queue.h> 128d5f250e9Smiod 129d5f250e9Smiod struct soft_intrhand { 130d5f250e9Smiod TAILQ_ENTRY(soft_intrhand) sih_list; 131d5f250e9Smiod void (*sih_func)(void *); 132d5f250e9Smiod void *sih_arg; 133d5f250e9Smiod struct soft_intrq *sih_siq; 134d5f250e9Smiod int sih_pending; 135d5f250e9Smiod }; 136d5f250e9Smiod 137d5f250e9Smiod struct soft_intrq { 138d5f250e9Smiod TAILQ_HEAD(, soft_intrhand) siq_list; 139d5f250e9Smiod int siq_si; 140d5f250e9Smiod struct mutex siq_mtx; 141d5f250e9Smiod }; 142d5f250e9Smiod 143d5f250e9Smiod void softintr_disestablish(void *); 144d5f250e9Smiod void softintr_dispatch(int); 145d5f250e9Smiod void *softintr_establish(int, void (*)(void *), void *); 146d5f250e9Smiod void softintr_init(void); 147d5f250e9Smiod void softintr_schedule(void *); 148d5f250e9Smiod 149d5f250e9Smiod extern int softpending; 150d5f250e9Smiod 151d5f250e9Smiod #endif /* _LOCORE */ 152d5f250e9Smiod 1533180e169Smiod #endif /* _KERNEL */ 1543934398eSmiod #endif /* _M88K_INTR_H_ */ 155