1*8a1e8ccaSmiod /* $OpenBSD: intr.h,v 1.25 2024/03/29 21:29:34 miod Exp $ */ 2de24d0bcSjason /* $NetBSD: intr.h,v 1.8 2001/01/14 23:50:30 thorpej Exp $ */ 3de24d0bcSjason 4de24d0bcSjason /*- 5de24d0bcSjason * Copyright (c) 1998 The NetBSD Foundation, Inc. 6de24d0bcSjason * All rights reserved. 7de24d0bcSjason * 8de24d0bcSjason * This code is derived from software contributed to The NetBSD Foundation 9de24d0bcSjason * by Paul Kranenburg. 10de24d0bcSjason * 11de24d0bcSjason * Redistribution and use in source and binary forms, with or without 12de24d0bcSjason * modification, are permitted provided that the following conditions 13de24d0bcSjason * are met: 14de24d0bcSjason * 1. Redistributions of source code must retain the above copyright 15de24d0bcSjason * notice, this list of conditions and the following disclaimer. 16de24d0bcSjason * 2. Redistributions in binary form must reproduce the above copyright 17de24d0bcSjason * notice, this list of conditions and the following disclaimer in the 18de24d0bcSjason * documentation and/or other materials provided with the distribution. 19de24d0bcSjason * 20de24d0bcSjason * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21de24d0bcSjason * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22de24d0bcSjason * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23de24d0bcSjason * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24de24d0bcSjason * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25de24d0bcSjason * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26de24d0bcSjason * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27de24d0bcSjason * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28de24d0bcSjason * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29de24d0bcSjason * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30de24d0bcSjason * POSSIBILITY OF SUCH DAMAGE. 31de24d0bcSjason */ 32de24d0bcSjason 332fa72412Spirofti #ifndef _MACHINE_INTR_H_ 342fa72412Spirofti #define _MACHINE_INTR_H_ 3585729938Shenric 3685729938Shenric #include <sparc64/sparc64/intreg.h> 3785729938Shenric 38fc635044Saaron #include <sys/evcount.h> 39fc635044Saaron 4085729938Shenric /* 4185729938Shenric * Interrupt handler chains. Interrupt handlers should return 0 for 4285729938Shenric * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a 4385729938Shenric * handler into the list. The handler is called with its (single) 4485729938Shenric * argument, or with a pointer to a clockframe if ih_arg is NULL. 4585729938Shenric */ 4685729938Shenric struct intrhand { 4785729938Shenric int (*ih_fun)(void *); 4885729938Shenric void *ih_arg; 4985729938Shenric short ih_number; /* interrupt number */ 5085729938Shenric /* the H/W provides */ 5185729938Shenric char ih_pil; /* interrupt priority */ 52f8e9be80Skettenis char ih_mpsafe; 5385729938Shenric struct intrhand *ih_next; /* global list */ 5485729938Shenric struct intrhand *ih_pending; /* pending list */ 5585729938Shenric volatile u_int64_t *ih_map; /* interrupt map reg */ 5685729938Shenric volatile u_int64_t *ih_clr; /* clear interrupt reg */ 57a41506b6Skettenis void (*ih_ack)(struct intrhand *); 58fc635044Saaron struct evcount ih_count; /* # of interrupts */ 5985729938Shenric const void *ih_bus; /* parent bus */ 60ad41178eSkettenis struct cpu_info *ih_cpu; /* target */ 61fc635044Saaron char ih_name[32]; /* device name */ 6285729938Shenric }; 6385729938Shenric 6485729938Shenric extern struct intrhand *intrlev[MAXINTNUM]; 6585729938Shenric 66*8a1e8ccaSmiod void intr_establish(struct intrhand *); 6785729938Shenric 68de24d0bcSjason /* XXX - arbitrary numbers; no interpretation is defined yet */ 69de24d0bcSjason #define IPL_NONE 0 /* nothing */ 70de24d0bcSjason #define IPL_SOFTINT 1 /* softint */ 71de24d0bcSjason #define IPL_SOFTCLOCK 1 /* timeouts */ 720d781922Sdlg #define IPL_SOFTNET 2 /* protocol stack */ 73de24d0bcSjason #define IPL_BIO PIL_BIO /* block I/O */ 74de24d0bcSjason #define IPL_NET PIL_NET /* network */ 757c8718faSkettenis #define IPL_SOFTTTY 4 /* delayed terminal handling */ 76de24d0bcSjason #define IPL_TTY PIL_TTY /* terminal */ 77570ce7f9Sart #define IPL_VM PIL_VM /* memory allocation */ 78de24d0bcSjason #define IPL_AUDIO PIL_AUD /* audio */ 79de24d0bcSjason #define IPL_CLOCK PIL_CLOCK /* clock */ 80de24d0bcSjason #define IPL_SERIAL PIL_SER /* serial */ 81de24d0bcSjason #define IPL_SCHED PIL_SCHED /* scheduler */ 8260086351Sart #define IPL_STATCLOCK PIL_STATCLOCK /* statclock */ 83de24d0bcSjason #define IPL_HIGH PIL_HIGH /* everything */ 84de24d0bcSjason 854c1fb545Sdlg #define spl0() _spl(IPL_NONE) 864c1fb545Sdlg #define splsoftclock() _splraise(IPL_SOFTCLOCK) 874c1fb545Sdlg #define splsoftnet() _splraise(IPL_SOFTNET) 884c1fb545Sdlg #define splbio() _splraise(IPL_BIO) 894c1fb545Sdlg #define splnet() _splraise(IPL_NET) 904c1fb545Sdlg #define splsofttty() _splraise(IPL_SOFTTTY) 914c1fb545Sdlg #define spltty() _splraise(IPL_TTY) 924c1fb545Sdlg #define splvm() _splraise(IPL_VM) 934c1fb545Sdlg #define splaudio() _splraise(IPL_AUDIO) 944c1fb545Sdlg #define splclock() _splraise(IPL_CLOCK) 954c1fb545Sdlg #define splserial() _splraise(IPL_SERIAL) 964c1fb545Sdlg #define splsched() _splraise(IPL_SCHED) 974c1fb545Sdlg #define splstatclock() _splraise(IPL_STATCLOCK) 984c1fb545Sdlg #define splhigh() _splraise(IPL_HIGH) 994c1fb545Sdlg #define splx(_oldipl) _splx(_oldipl) 1004c1fb545Sdlg 1014c1fb545Sdlg #define splzs() splserial() 1024c1fb545Sdlg 1034965d1a4Smpi #define IPL_MPFLOOR IPL_SERIAL 104f258d497Skettenis #define IPL_MPSAFE 0x100 105f258d497Skettenis 1064c1fb545Sdlg int splraise(int); 107c1f97f5aSkettenis void intr_barrier(void *); 108c1f97f5aSkettenis 1097c8718faSkettenis void *softintr_establish(int, void (*)(void *), void *); 1107c8718faSkettenis void softintr_disestablish(void *); 1117c8718faSkettenis void softintr_schedule(void *); 11285729938Shenric 113bdd1b079Smiod void send_softint(int, struct intrhand *); 114dc117c2aSmiod 1152fa72412Spirofti #endif /* _MACHINE_INTR_H_ */ 116