intr.h revision 296138
1295459Sadrian/* $NetBSD: intr.h,v 1.7 2003/06/16 20:01:00 thorpej Exp $ */ 2295459Sadrian 3295459Sadrian/*- 4295459Sadrian * Copyright (c) 1997 Mark Brinicombe. 5295459Sadrian * All rights reserved. 6295459Sadrian * 7295459Sadrian * Redistribution and use in source and binary forms, with or without 8295459Sadrian * modification, are permitted provided that the following conditions 9295459Sadrian * are met: 10295459Sadrian * 1. Redistributions of source code must retain the above copyright 11295459Sadrian * notice, this list of conditions and the following disclaimer. 12295459Sadrian * 2. Redistributions in binary form must reproduce the above copyright 13295459Sadrian * notice, this list of conditions and the following disclaimer in the 14295459Sadrian * documentation and/or other materials provided with the distribution. 15295459Sadrian * 3. All advertising materials mentioning features or use of this software 16295459Sadrian * must display the following acknowledgement: 17295459Sadrian * This product includes software developed by Mark Brinicombe 18295459Sadrian * for the NetBSD Project. 19295459Sadrian * 4. The name of the company nor the name of the author may be used to 20295459Sadrian * endorse or promote products derived from this software without specific 21295459Sadrian * prior written permission. 22295459Sadrian * 23295459Sadrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24295459Sadrian * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25295459Sadrian * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26295459Sadrian * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27295459Sadrian * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28295459Sadrian * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29295459Sadrian * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30295459Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31295459Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32295459Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33295459Sadrian * SUCH DAMAGE. 34295459Sadrian * 35295459Sadrian * $FreeBSD: head/sys/sys/intr.h 296138 2016-02-27 12:03:07Z skra $ 36295459Sadrian * 37295459Sadrian */ 38295459Sadrian 39295459Sadrian#ifndef _SYS_INTR_H_ 40295459Sadrian#define _SYS_INTR_H_ 41295459Sadrian 42296138Sskra#include <sys/systm.h> 43296138Sskra 44295459Sadrian#ifdef notyet 45295459Sadrian#define INTR_SOLO INTR_MD1 46295459Sadriantypedef int intr_irq_filter_t(void *arg, struct trapframe *tf); 47295459Sadrian#else 48295459Sadriantypedef int intr_irq_filter_t(void *arg); 49295459Sadrian#endif 50295459Sadrian 51295459Sadrian#define INTR_ISRC_NAMELEN (MAXCOMLEN + 1) 52295459Sadrian 53295459Sadriantypedef void intr_ipi_filter_t(void *arg); 54295459Sadrian 55295459Sadrianenum intr_isrc_type { 56295459Sadrian INTR_ISRCT_NAMESPACE, 57295459Sadrian INTR_ISRCT_FDT 58295459Sadrian}; 59295459Sadrian 60295459Sadrian#define INTR_ISRCF_REGISTERED 0x01 /* registered in a controller */ 61295459Sadrian#define INTR_ISRCF_PERCPU 0x02 /* per CPU interrupt */ 62295459Sadrian#define INTR_ISRCF_BOUND 0x04 /* bound to a CPU */ 63295459Sadrian 64295459Sadrian/* Interrupt source definition. */ 65295459Sadrianstruct intr_irqsrc { 66295459Sadrian device_t isrc_dev; /* where isrc is mapped */ 67295459Sadrian intptr_t isrc_xref; /* device reference key */ 68295459Sadrian uintptr_t isrc_data; /* device data for isrc */ 69295459Sadrian u_int isrc_irq; /* unique identificator */ 70295459Sadrian enum intr_isrc_type isrc_type; /* how is isrc decribed */ 71295459Sadrian u_int isrc_flags; 72295459Sadrian char isrc_name[INTR_ISRC_NAMELEN]; 73295459Sadrian uint16_t isrc_nspc_type; 74295459Sadrian uint16_t isrc_nspc_num; 75295459Sadrian enum intr_trigger isrc_trig; 76295459Sadrian enum intr_polarity isrc_pol; 77295459Sadrian cpuset_t isrc_cpu; /* on which CPUs is enabled */ 78295459Sadrian u_int isrc_index; 79295459Sadrian u_long * isrc_count; 80295459Sadrian u_int isrc_handlers; 81295459Sadrian struct intr_event * isrc_event; 82295459Sadrian intr_irq_filter_t * isrc_filter; 83295459Sadrian intr_ipi_filter_t * isrc_ipifilter; 84295459Sadrian void * isrc_arg; 85295459Sadrian#ifdef FDT 86295459Sadrian u_int isrc_ncells; 87295459Sadrian pcell_t isrc_cells[]; /* leave it last */ 88295459Sadrian#endif 89295459Sadrian}; 90295459Sadrian 91295459Sadrianvoid intr_irq_set_name(struct intr_irqsrc *isrc, const char *fmt, ...) 92295459Sadrian __printflike(2, 3); 93295459Sadrian 94295459Sadrianvoid intr_irq_dispatch(struct intr_irqsrc *isrc, struct trapframe *tf); 95295459Sadrian 96295459Sadrian#define INTR_IRQ_NSPC_NONE 0 97295459Sadrian#define INTR_IRQ_NSPC_PLAIN 1 98295459Sadrian#define INTR_IRQ_NSPC_IRQ 2 99295459Sadrian#define INTR_IRQ_NSPC_IPI 3 100295459Sadrian 101295459Sadrianu_int intr_namespace_map_irq(device_t dev, uint16_t type, uint16_t num); 102295459Sadrian#ifdef FDT 103295459Sadrianu_int intr_fdt_map_irq(phandle_t, pcell_t *, u_int); 104295459Sadrian#endif 105295459Sadrian 106296138Sskraextern device_t intr_irq_root_dev; 107296138Sskra 108295459Sadrianint intr_pic_register(device_t dev, intptr_t xref); 109295459Sadrianint intr_pic_unregister(device_t dev, intptr_t xref); 110295459Sadrianint intr_pic_claim_root(device_t dev, intptr_t xref, intr_irq_filter_t *filter, 111295459Sadrian void *arg, u_int ipicount); 112295459Sadrian 113295459Sadrianint intr_irq_add_handler(device_t dev, driver_filter_t, driver_intr_t, void *, 114295459Sadrian u_int, int, void **); 115295459Sadrianint intr_irq_remove_handler(device_t dev, u_int, void *); 116295459Sadrianint intr_irq_config(u_int, enum intr_trigger, enum intr_polarity); 117295459Sadrianint intr_irq_describe(u_int, void *, const char *); 118295459Sadrian 119295459Sadrianu_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask); 120295459Sadrian 121295459Sadrian#ifdef SMP 122295459Sadrianint intr_irq_bind(u_int, int); 123295459Sadrian 124296138Sskravoid intr_pic_init_secondary(void); 125295459Sadrian 126296138Sskra/* Virtualization for interrupt source IPI counter increment. */ 127296138Sskrastatic inline void 128296138Sskraintr_ipi_increment_count(u_long *counter, u_int cpu) 129296138Sskra{ 130295459Sadrian 131296138Sskra KASSERT(cpu < MAXCPU, ("%s: too big cpu %u", __func__, cpu)); 132296138Sskra counter[cpu]++; 133296138Sskra} 134295459Sadrian 135296138Sskra/* Virtualization for interrupt source IPI counters setup. */ 136296138Sskrau_long * intr_ipi_setup_counters(const char *name); 137295459Sadrian 138295459Sadrian#endif 139295459Sadrian#endif /* _SYS_INTR_H */ 140