Home | History | Annotate | Line # | Download | only in booke
intr.h revision 1.12
      1  1.12        ad /*	$NetBSD: intr.h,v 1.12 2019/11/23 19:40:36 ad Exp $	*/
      2   1.1      matt /*-
      3   1.2      matt  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      4   1.1      matt  * All rights reserved.
      5   1.1      matt  *
      6   1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
      7   1.2      matt  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      8   1.2      matt  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      9   1.2      matt  *
     10   1.2      matt  * This material is based upon work supported by the Defense Advanced Research
     11   1.2      matt  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     12   1.2      matt  * Contract No. N66001-09-C-2073.
     13   1.2      matt  * Approved for Public Release, Distribution Unlimited
     14   1.1      matt  *
     15   1.1      matt  * Redistribution and use in source and binary forms, with or without
     16   1.1      matt  * modification, are permitted provided that the following conditions
     17   1.1      matt  * are met:
     18   1.1      matt  * 1. Redistributions of source code must retain the above copyright
     19   1.1      matt  *    notice, this list of conditions and the following disclaimer.
     20   1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     21   1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     22   1.1      matt  *    documentation and/or other materials provided with the distribution.
     23   1.1      matt  *
     24   1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25   1.1      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26   1.1      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27   1.1      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28   1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29   1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30   1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31   1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32   1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33   1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34   1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     35   1.1      matt  */
     36   1.1      matt 
     37   1.1      matt #ifndef _BOOKE_INTR_H_
     38   1.1      matt #define _BOOKE_INTR_H_
     39   1.1      matt 
     40   1.1      matt /* Interrupt priority `levels'. */
     41   1.1      matt #define	IPL_NONE	0	/* nothing */
     42   1.1      matt #define	IPL_SOFTCLOCK	1	/* software clock interrupt */
     43   1.1      matt #define	IPL_SOFTBIO	2	/* software block i/o interrupt */
     44   1.1      matt #define	IPL_SOFTNET	3	/* software network interrupt */
     45   1.1      matt #define	IPL_SOFTSERIAL	4	/* software serial interrupt */
     46   1.1      matt #define	IPL_VM		5	/* memory allocation */
     47   1.1      matt #define	IPL_SCHED	6	/* clock */
     48   1.1      matt #define	IPL_HIGH	7	/* everything */
     49   1.1      matt #define	NIPL		8
     50   1.1      matt 
     51   1.1      matt /* Interrupt sharing types. */
     52   1.2      matt #define	IST_NONE	(NIPL+0) /* none */
     53   1.5      matt #define	IST_EDGE	(NIPL+1) /* edge-triggered */
     54   1.2      matt #define	IST_LEVEL	(NIPL+2) /* level-triggered active-low */
     55   1.1      matt #define	IST_LEVEL_LOW	IST_LEVEL
     56   1.2      matt #define	IST_LEVEL_HIGH	(NIPL+3) /* level-triggered active-high */
     57   1.5      matt #define	IST_PULSE	(NIPL+4) /* pulsed */
     58   1.5      matt #define	IST_MSI		(NIPL+5) /* message signaling interrupt (PCI) */
     59   1.5      matt #define	IST_ONCHIP	(NIPL+6) /* on-chip device */
     60   1.1      matt #ifdef __INTR_PRIVATE
     61   1.5      matt #define	IST_MSIGROUP	(NIPL+7) /* openpic msi groups */
     62   1.5      matt #define	IST_TIMER	(NIPL+8) /* openpic timers */
     63   1.5      matt #define	IST_IPI		(NIPL+9) /* openpic ipi */
     64   1.5      matt #define	IST_MI		(NIPL+10) /* openpic message */
     65   1.5      matt #define	IST_MAX		(NIPL+11)
     66   1.1      matt #endif
     67   1.1      matt 
     68   1.4      matt #define	IPI_DST_ALL	((cpuid_t)-2)
     69   1.4      matt #define	IPI_DST_NOTME	((cpuid_t)-1)
     70   1.4      matt 
     71   1.4      matt #define IPI_NOMESG	0x0000
     72   1.4      matt #define IPI_HALT	0x0001
     73   1.4      matt #define IPI_XCALL	0x0002
     74   1.4      matt #define	IPI_KPREEMPT	0x0004
     75   1.4      matt #define IPI_TLB1SYNC	0x0008
     76   1.8     rmind #define IPI_GENERIC	0x0010
     77   1.9    nonaka #define IPI_SUSPEND	0x0020
     78  1.12        ad #define IPI_AST		0x0040
     79   1.3      matt 
     80   1.2      matt #define	__HAVE_FAST_SOFTINTS	1
     81   1.4      matt #define	SOFTINT_KPREEMPT	SOFTINT_COUNT
     82   1.2      matt 
     83   1.1      matt #ifndef _LOCORE
     84   1.1      matt 
     85   1.6      matt struct cpu_info;
     86   1.6      matt 
     87   1.1      matt void 	*intr_establish(int, int, int, int (*)(void *), void *);
     88  1.10    nonaka void 	*intr_establish_xname(int, int, int, int (*)(void *), void *,
     89  1.10    nonaka 	    const char *);
     90   1.1      matt void 	intr_disestablish(void *);
     91   1.4      matt void	intr_cpu_attach(struct cpu_info *);
     92   1.4      matt void	intr_cpu_hatch(struct cpu_info *);
     93   1.2      matt void	intr_init(void);
     94   1.2      matt const char *
     95   1.7  christos 	intr_string(int, int, char *, size_t);
     96   1.5      matt const char *
     97   1.5      matt 	intr_typename(int);
     98   1.2      matt 
     99   1.4      matt void	cpu_send_ipi(cpuid_t, uint32_t);
    100   1.3      matt 
    101   1.2      matt void	spl0(void);
    102   1.1      matt int 	splraise(int);
    103   1.1      matt void 	splx(int);
    104   1.2      matt #ifdef __INTR_NOINLINE
    105   1.2      matt int	splhigh(void);
    106   1.2      matt int	splsched(void);
    107   1.2      matt int	splvm(void);
    108   1.2      matt int	splsoftserial(void);
    109   1.2      matt int	splsoftnet(void);
    110   1.2      matt int	splsoftbio(void);
    111   1.2      matt int	splsoftclock(void);
    112   1.2      matt #endif
    113   1.1      matt 
    114   1.1      matt typedef int ipl_t;
    115   1.1      matt typedef struct {
    116   1.1      matt 	ipl_t _ipl;
    117   1.1      matt } ipl_cookie_t;
    118   1.1      matt 
    119   1.1      matt #ifdef __INTR_PRIVATE
    120   1.1      matt 
    121   1.6      matt struct trapframe;
    122   1.6      matt 
    123   1.1      matt struct intrsw {
    124  1.10    nonaka 	void *(*intrsw_establish)(int, int, int, int (*)(void *), void *,
    125  1.10    nonaka 	    const char *);
    126   1.1      matt 	void (*intrsw_disestablish)(void *);
    127   1.4      matt 	void (*intrsw_cpu_attach)(struct cpu_info *);
    128   1.4      matt 	void (*intrsw_cpu_hatch)(struct cpu_info *);
    129   1.4      matt 	void (*intrsw_cpu_send_ipi)(cpuid_t, uint32_t);
    130   1.1      matt 	void (*intrsw_init)(void);
    131   1.1      matt 	void (*intrsw_critintr)(struct trapframe *);
    132   1.1      matt 	void (*intrsw_decrintr)(struct trapframe *);
    133   1.1      matt 	void (*intrsw_extintr)(struct trapframe *);
    134   1.1      matt 	void (*intrsw_fitintr)(struct trapframe *);
    135   1.1      matt 	void (*intrsw_wdogintr)(struct trapframe *);
    136   1.1      matt 	int (*intrsw_splraise)(int);
    137   1.2      matt 	void (*intrsw_spl0)(void);
    138   1.1      matt 	void (*intrsw_splx)(int);
    139   1.7  christos 	const char *(*intrsw_string)(int, int, char *, size_t);
    140   1.5      matt 	const char *(*intrsw_typename)(int);
    141   1.1      matt #ifdef __HAVE_FAST_SOFTINTS
    142   1.2      matt 	void (*intrsw_softint_init_md)(struct lwp *, u_int, uintptr_t *);
    143   1.1      matt 	void (*intrsw_softint_trigger)(uintptr_t);
    144   1.1      matt #endif
    145   1.1      matt };
    146   1.1      matt 
    147   1.2      matt extern const struct intrsw *powerpc_intrsw;
    148   1.2      matt void	softint_fast_dispatch(struct lwp *, int);
    149   1.1      matt #endif /* __INTR_PRIVATE */
    150   1.1      matt 
    151   1.2      matt #ifndef __INTR_NOINLINE
    152  1.11  christos static __inline int
    153   1.1      matt splhigh(void)
    154   1.1      matt {
    155   1.1      matt 
    156   1.1      matt 	return splraise(IPL_HIGH);
    157   1.1      matt }
    158   1.1      matt 
    159  1.11  christos static __inline int
    160   1.1      matt splsched(void)
    161   1.1      matt {
    162   1.1      matt 
    163   1.1      matt 	return splraise(IPL_SCHED);
    164   1.1      matt }
    165   1.1      matt 
    166  1.11  christos static __inline int
    167   1.1      matt splvm(void)
    168   1.1      matt {
    169   1.1      matt 
    170   1.1      matt 	return splraise(IPL_VM);
    171   1.1      matt }
    172   1.1      matt 
    173  1.11  christos static __inline int
    174   1.1      matt splsoftserial(void)
    175   1.1      matt {
    176   1.1      matt 
    177   1.1      matt 	return splraise(IPL_SOFTSERIAL);
    178   1.1      matt }
    179   1.1      matt 
    180  1.11  christos static __inline int
    181   1.1      matt splsoftnet(void)
    182   1.1      matt {
    183   1.1      matt 
    184   1.1      matt 	return splraise(IPL_SOFTNET);
    185   1.1      matt }
    186   1.1      matt 
    187  1.11  christos static __inline int
    188   1.1      matt splsoftbio(void)
    189   1.1      matt {
    190   1.1      matt 
    191   1.1      matt 	return splraise(IPL_SOFTBIO);
    192   1.1      matt }
    193   1.1      matt 
    194  1.11  christos static __inline int
    195   1.1      matt splsoftclock(void)
    196   1.1      matt {
    197   1.1      matt 
    198   1.1      matt 	return splraise(IPL_SOFTCLOCK);
    199   1.1      matt }
    200   1.1      matt 
    201  1.11  christos static __inline int
    202   1.1      matt splraiseipl(ipl_cookie_t icookie)
    203   1.1      matt {
    204   1.1      matt 
    205   1.1      matt 	return splraise(icookie._ipl);
    206   1.1      matt }
    207   1.1      matt 
    208  1.11  christos static __inline ipl_cookie_t
    209   1.1      matt makeiplcookie(ipl_t ipl)
    210   1.1      matt {
    211   1.1      matt 
    212   1.1      matt 	return (ipl_cookie_t){._ipl = ipl};
    213   1.1      matt }
    214   1.2      matt #endif /* !__INTR_NOINLINE */
    215   1.1      matt 
    216   1.1      matt #endif /* !_LOCORE */
    217   1.1      matt #endif /* !_BOOKE_INTR_H_ */
    218