Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.36
      1  1.36  knakahar /*	$NetBSD: intr.h,v 1.36 2015/04/27 07:03:58 knakahara Exp $	*/
      2   1.3    bouyer /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
      3   1.3    bouyer 
      4   1.3    bouyer /*-
      5   1.3    bouyer  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
      6   1.3    bouyer  * All rights reserved.
      7   1.3    bouyer  *
      8   1.3    bouyer  * This code is derived from software contributed to The NetBSD Foundation
      9   1.3    bouyer  * by Charles M. Hannum, and by Jason R. Thorpe.
     10   1.3    bouyer  *
     11   1.3    bouyer  * Redistribution and use in source and binary forms, with or without
     12   1.3    bouyer  * modification, are permitted provided that the following conditions
     13   1.3    bouyer  * are met:
     14   1.3    bouyer  * 1. Redistributions of source code must retain the above copyright
     15   1.3    bouyer  *    notice, this list of conditions and the following disclaimer.
     16   1.3    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.3    bouyer  *    notice, this list of conditions and the following disclaimer in the
     18   1.3    bouyer  *    documentation and/or other materials provided with the distribution.
     19   1.3    bouyer  *
     20   1.3    bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21   1.3    bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22   1.3    bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23   1.3    bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24   1.3    bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25   1.3    bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26   1.3    bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27   1.3    bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28   1.3    bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29   1.3    bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30   1.3    bouyer  * POSSIBILITY OF SUCH DAMAGE.
     31   1.3    bouyer  */
     32   1.1        cl 
     33   1.1        cl #ifndef _XEN_INTR_H_
     34   1.1        cl #define	_XEN_INTR_H_
     35   1.1        cl 
     36  1.22    bouyer #include <machine/intrdefs.h>
     37   1.1        cl 
     38   1.1        cl #ifndef _LOCORE
     39  1.19    bouyer #include <xen/xen.h>
     40  1.19    bouyer #include <xen/hypervisor.h>
     41   1.3    bouyer #include <machine/pic.h>
     42  1.30    dyoung #include <sys/evcnt.h>
     43   1.3    bouyer 
     44  1.10    bouyer #include "opt_xen.h"
     45  1.10    bouyer 
     46  1.34    bouyer 
     47  1.34    bouyer struct cpu_info;
     48   1.3    bouyer /*
     49   1.3    bouyer  * Struct describing an event channel.
     50   1.3    bouyer  */
     51   1.3    bouyer 
     52   1.3    bouyer struct evtsource {
     53   1.3    bouyer 	int ev_maxlevel;		/* max. IPL for this source */
     54  1.24    cegger 	uint32_t ev_imask;		/* interrupt mask */
     55   1.3    bouyer 	struct intrhand *ev_handlers;	/* handler chain */
     56   1.3    bouyer 	struct evcnt ev_evcnt;		/* interrupt counter */
     57  1.33    cherry 	struct cpu_info *ev_cpu;        /* cpu on which this event is bound */
     58   1.3    bouyer 	char ev_evname[32];		/* event counter name */
     59   1.3    bouyer };
     60   1.3    bouyer 
     61   1.3    bouyer /*
     62   1.3    bouyer  * Structure describing an interrupt level. struct cpu_info has an array of
     63   1.3    bouyer  * IPL_MAX of theses. The index in the array is equal to the stub number of
     64   1.3    bouyer  * the stubcode as present in vector.s
     65   1.3    bouyer  */
     66   1.3    bouyer 
     67   1.3    bouyer struct intrstub {
     68   1.3    bouyer #if 0
     69   1.3    bouyer 	void *ist_entry;
     70   1.3    bouyer #endif
     71   1.3    bouyer 	void *ist_recurse;
     72   1.3    bouyer 	void *ist_resume;
     73   1.3    bouyer };
     74   1.3    bouyer 
     75  1.11    dogcow /* for x86 compatibility */
     76  1.11    dogcow extern struct intrstub i8259_stubs[];
     77  1.12    bouyer extern struct intrstub ioapic_edge_stubs[];
     78  1.12    bouyer extern struct intrstub ioapic_level_stubs[];
     79  1.11    dogcow 
     80   1.3    bouyer struct iplsource {
     81   1.3    bouyer 	struct intrhand *ipl_handlers;   /* handler chain */
     82   1.3    bouyer 	void *ipl_recurse;               /* entry for spllower */
     83   1.3    bouyer 	void *ipl_resume;                /* entry for doreti */
     84  1.20        ad 	struct lwp *ipl_lwp;
     85  1.23    bouyer 	u_long ipl_evt_mask1;	/* pending events for this IPL */
     86  1.23    bouyer 	u_long ipl_evt_mask2[NR_EVENT_CHANNELS];
     87   1.3    bouyer };
     88   1.3    bouyer 
     89   1.3    bouyer 
     90   1.3    bouyer 
     91   1.3    bouyer /*
     92   1.3    bouyer  * Interrupt handler chains. These are linked in both the evtsource and
     93   1.3    bouyer  * the iplsource.
     94   1.3    bouyer  * The handler is called with its (single) argument.
     95   1.3    bouyer  */
     96   1.3    bouyer 
     97   1.3    bouyer struct intrhand {
     98   1.3    bouyer 	int	(*ih_fun)(void *);
     99   1.3    bouyer 	void	*ih_arg;
    100   1.3    bouyer 	int	ih_level;
    101  1.25    cegger 	int	(*ih_realfun)(void *);
    102  1.25    cegger 	void	*ih_realarg;
    103   1.3    bouyer 	struct	intrhand *ih_ipl_next;
    104   1.3    bouyer 	struct	intrhand *ih_evt_next;
    105   1.3    bouyer 	struct cpu_info *ih_cpu;
    106   1.3    bouyer };
    107   1.1        cl 
    108  1.12    bouyer struct xen_intr_handle {
    109  1.12    bouyer 	int pirq; /* also contains the  APIC_INT_* flags if NIOAPIC > 0 */
    110  1.12    bouyer 	int evtch;
    111  1.12    bouyer };
    112   1.1        cl 
    113   1.1        cl extern struct intrstub xenev_stubs[];
    114   1.1        cl 
    115   1.3    bouyer #define IUNMASK(ci,level) (ci)->ci_iunmask[(level)]
    116   1.3    bouyer 
    117   1.3    bouyer extern void Xspllower(int);
    118   1.3    bouyer 
    119  1.16      yamt int splraise(int);
    120  1.16      yamt void spllower(int);
    121   1.3    bouyer 
    122   1.3    bouyer #define SPL_ASSERT_BELOW(x) KDASSERT(curcpu()->ci_ilevel < (x))
    123   1.3    bouyer 
    124   1.3    bouyer /*
    125   1.3    bouyer  * Miscellaneous
    126   1.3    bouyer  */
    127   1.3    bouyer #define	spl0()		spllower(IPL_NONE)
    128   1.3    bouyer #define	splx(x)		spllower(x)
    129   1.3    bouyer 
    130  1.14        ad typedef uint8_t ipl_t;
    131  1.13      yamt typedef struct {
    132  1.13      yamt 	ipl_t _ipl;
    133  1.13      yamt } ipl_cookie_t;
    134  1.13      yamt 
    135  1.13      yamt static inline ipl_cookie_t
    136  1.13      yamt makeiplcookie(ipl_t ipl)
    137  1.13      yamt {
    138  1.13      yamt 
    139  1.13      yamt 	return (ipl_cookie_t){._ipl = ipl};
    140  1.13      yamt }
    141  1.13      yamt 
    142  1.13      yamt static inline int
    143  1.13      yamt splraiseipl(ipl_cookie_t icookie)
    144  1.13      yamt {
    145  1.13      yamt 
    146  1.13      yamt 	return splraise(icookie._ipl);
    147  1.13      yamt }
    148  1.13      yamt 
    149   1.6      yamt #include <sys/spl.h>
    150   1.6      yamt 
    151   1.3    bouyer /*
    152   1.3    bouyer  * Stub declarations.
    153   1.3    bouyer  */
    154   1.3    bouyer 
    155   1.3    bouyer struct pcibus_attach_args;
    156   1.1        cl 
    157  1.36  knakahar typedef int intr_handle_t;
    158  1.36  knakahar 
    159  1.25    cegger #ifdef MULTIPROCESSOR
    160  1.25    cegger int intr_biglock_wrapper(void *);
    161  1.25    cegger #endif
    162  1.25    cegger 
    163   1.3    bouyer void intr_default_setup(void);
    164   1.3    bouyer int x86_nmi(void);
    165  1.10    bouyer 
    166  1.29        ad void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *, bool);
    167   1.3    bouyer void intr_disestablish(struct intrhand *);
    168  1.36  knakahar const char *intr_string(intr_handle_t);
    169   1.3    bouyer void cpu_intr_init(struct cpu_info *);
    170  1.12    bouyer int xen_intr_map(int *, int);
    171   1.3    bouyer #ifdef INTRDEBUG
    172   1.3    bouyer void intr_printconfig(void);
    173   1.2      yamt #endif
    174  1.12    bouyer int intr_find_mpmapping(int, int, struct xen_intr_handle *);
    175  1.12    bouyer struct pic *intr_findpic(int);
    176  1.12    bouyer void intr_add_pcibus(struct pcibus_attach_args *);
    177  1.10    bouyer 
    178  1.32    cherry #ifdef MULTIPROCESSOR
    179  1.32    cherry void xen_ipi_init(void);
    180  1.32    cherry int xen_send_ipi(struct cpu_info *, uint32_t);
    181  1.32    cherry void xen_broadcast_ipi(uint32_t);
    182  1.32    cherry #else
    183  1.33    cherry #define xen_ipi_init(_1) ((void) 0) /* nothing */
    184  1.33    cherry #define xen_send_ipi(_i1, _i2) (0) /* nothing */
    185  1.33    cherry #define xen_broadcast_ipi(_i1) ((void) 0) /* nothing */
    186  1.32    cherry #endif /* MULTIPROCESSOR */
    187  1.26        ad 
    188   1.3    bouyer #endif /* !_LOCORE */
    189   1.3    bouyer 
    190   1.1        cl #endif /* _XEN_INTR_H_ */
    191