| 1 | /*	$NetBSD: intr.h,v 1.21 2020/05/17 14:11:30 ad Exp $	*/ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 2007, 2020 The NetBSD Foundation, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to The NetBSD Foundation |
| 8 | * by Andrew Doran. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #ifndef _SYS_INTR_H_ |
| 33 | #define	_SYS_INTR_H_ |
| 34 | |
| 35 | #define INTRIDBUF 64 |
| 36 | #define INTRDEVNAMEBUF 256 |
| 37 | |
| 38 | #ifdef _KERNEL |
| 39 | |
| 40 | #include <sys/types.h> |
| 41 | |
| 42 | struct cpu_info; |
| 43 | |
| 44 | /* Public interface. */ |
| 45 | void	*softint_establish(u_int, void (*)(void *), void *); |
| 46 | void	softint_disestablish(void *); |
| 47 | void	softint_schedule(void *); |
| 48 | void	softint_schedule_cpu(void *, struct cpu_info *); |
| 49 | |
| 50 | /* MI hooks. */ |
| 51 | void	softint_init(struct cpu_info *); |
| 52 | lwp_t	*softint_picklwp(void); |
| 53 | void	softint_block(lwp_t *); |
| 54 | |
| 55 | /* MD-MI interface. */ |
| 56 | void	softint_init_md(lwp_t *, u_int, uintptr_t *); |
| 57 | #ifndef __HAVE_MD_SOFTINT_TRIGGER |
| 58 | void	softint_trigger(uintptr_t); |
| 59 | #endif |
| 60 | void	softint_dispatch(lwp_t *, int); |
| 61 | |
| 62 | /* Flags for softint_establish(). */ |
| 63 | #define	SOFTINT_BIO	0x0000 |
| 64 | #define	SOFTINT_CLOCK	0x0001 |
| 65 | #define	SOFTINT_SERIAL	0x0002 |
| 66 | #define	SOFTINT_NET	0x0003 |
| 67 | #define	SOFTINT_MPSAFE	0x0100 |
| 68 | #define	SOFTINT_RCPU	0x0200 |
| 69 | |
| 70 | /* Implementation private flags. */ |
| 71 | #define	SOFTINT_PENDING	0x1000 |
| 72 | |
| 73 | #define	SOFTINT_COUNT	0x0004 |
| 74 | #define	SOFTINT_LVLMASK	0x00ff |
| 75 | #define	SOFTINT_IMPMASK	0xf000 |
| 76 | |
| 77 | extern u_int	softint_timing; |
| 78 | |
| 79 | /* |
| 80 | * Historical aliases. |
| 81 | */ |
| 82 | #define	IPL_BIO		IPL_VM |
| 83 | #define	IPL_NET		IPL_VM |
| 84 | #define	IPL_TTY		IPL_VM |
| 85 | #define	IPL_AUDIO	IPL_SCHED |
| 86 | #define	IPL_CLOCK	IPL_SCHED |
| 87 | #define	IPL_SERIAL	IPL_HIGH |
| 88 | |
| 89 | #define	splbio()	splvm() |
| 90 | #define	splnet()	splvm() |
| 91 | #define	spltty()	splvm() |
| 92 | #define	splaudio()	splsched() |
| 93 | #define	splclock()	splsched() |
| 94 | #define	splserial()	splhigh() |
| 95 | |
| 96 | #include <machine/intr.h> |
| 97 | |
| 98 | #elif defined(_KMEMUSER) |
| 99 | #define	SOFTINT_COUNT	0x0004 |
| 100 | #endif	/* _KERNEL */ |
| 101 | |
| 102 | #endif	/* _SYS_INTR_H_ */ |