Home | History | Annotate | Line # | Download | only in include
      1  1.13    simonb /* $NetBSD: intr.h,v 1.13 2021/02/16 05:11:26 simonb Exp $ */
      2   1.7       mrg 
      3   1.4      matt /*-
      4   1.4      matt  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
      5   1.4      matt  * All rights reserved.
      6   1.4      matt  *
      7   1.4      matt  * This code is derived from software contributed to The NetBSD Foundation
      8   1.4      matt  * by Matt Thomas <matt (at) 3am-software.com>.
      9   1.1  jonathan  *
     10   1.1  jonathan  * Redistribution and use in source and binary forms, with or without
     11   1.1  jonathan  * modification, are permitted provided that the following conditions
     12   1.1  jonathan  * are met:
     13   1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     14   1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     15   1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     17   1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     18   1.1  jonathan  *
     19   1.4      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.4      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.4      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.4      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.4      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.4      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.4      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.4      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.4      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.4      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.4      matt  * POSSIBILITY OF SUCH DAMAGE.
     30   1.4      matt  */
     31   1.4      matt 
     32   1.4      matt #ifndef _MIPS_INTR_H_
     33   1.4      matt #define	_MIPS_INTR_H_
     34   1.4      matt 
     35   1.4      matt #ifdef _KERNEL_OPT
     36   1.4      matt #include "opt_multiprocessor.h"
     37   1.4      matt #endif
     38   1.4      matt 
     39   1.4      matt /*
     40   1.4      matt  * This is a common <machine/intr.h> for all MIPS platforms.
     41   1.1  jonathan  */
     42   1.1  jonathan 
     43   1.4      matt #define	IPL_NONE	0
     44   1.4      matt #define	IPL_SOFTCLOCK	(IPL_NONE+1)
     45   1.4      matt #define	IPL_SOFTBIO	(IPL_SOFTCLOCK)	/* shares SWINT with softclock */
     46   1.4      matt #define	IPL_SOFTNET	(IPL_SOFTBIO+1)
     47   1.4      matt #define	IPL_SOFTSERIAL	(IPL_SOFTNET)	/* shares SWINT with softnet */
     48   1.4      matt #define	IPL_VM		(IPL_SOFTSERIAL+1)
     49   1.4      matt #define	IPL_SCHED	(IPL_VM+1)
     50   1.4      matt #define	IPL_DDB		(IPL_SCHED+1)
     51   1.4      matt #define	IPL_HIGH	(IPL_DDB+1)
     52   1.4      matt 
     53   1.6      matt #define	IPL_SAFEPRI	IPL_SOFTSERIAL
     54   1.6      matt 
     55   1.4      matt #define	_IPL_N		(IPL_HIGH+1)
     56   1.4      matt #define	_IPL_NAMES(pfx)	{ pfx"none", pfx"softclock/bio", pfx"softnet/serial", \
     57   1.4      matt 			  pfx"vm", pfx"sched", pfx"ddb", pfx"high" }
     58   1.4      matt 
     59   1.4      matt #define	IST_UNUSABLE	-1		/* interrupt cannot be used */
     60   1.4      matt #define	IST_NONE	0		/* none (dummy) */
     61   1.4      matt #define	IST_PULSE	1		/* pulsed */
     62   1.4      matt #define	IST_EDGE	2		/* edge-triggered */
     63   1.4      matt #define	IST_LEVEL	3		/* level-triggered */
     64   1.4      matt #define	IST_LEVEL_HIGH	4		/* level triggered, active high */
     65   1.4      matt #define	IST_LEVEL_LOW	5		/* level triggered, active low */
     66   1.4      matt 
     67  1.11    simonb #define	IST_MPSAFE	0x100		/* interrupt is MPSAFE */
     68   1.9      matt 
     69   1.4      matt #define	IPI_NOP		0		/* do nothing, interrupt only */
     70   1.4      matt #define	IPI_AST		1		/* force ast */
     71   1.4      matt #define	IPI_SHOOTDOWN	2		/* do a tlb shootdown */
     72   1.4      matt #define	IPI_SYNCICACHE	3		/* sync icache for pages */
     73   1.4      matt #define	IPI_KPREEMPT	4		/* schedule a kernel preemption */
     74   1.4      matt #define	IPI_SUSPEND	5		/* DDB suspend signaling */
     75   1.4      matt #define	IPI_HALT	6		/* halt cpu */
     76   1.5      matt #define	IPI_XCALL	7		/* xcall */
     77   1.8     rmind #define	IPI_GENERIC	8		/* generic IPI */
     78  1.10      matt #define	IPI_WDOG	9		/* tickle a wdog */
     79  1.10      matt #define	NIPIS		10
     80   1.4      matt 
     81   1.4      matt #ifdef __INTR_PRIVATE
     82   1.4      matt struct splsw {
     83   1.4      matt 	int	(*splsw_splhigh)(void);
     84   1.4      matt 	int	(*splsw_splsched)(void);
     85   1.4      matt 	int	(*splsw_splvm)(void);
     86   1.4      matt 	int	(*splsw_splsoftserial)(void);
     87   1.4      matt 	int	(*splsw_splsoftnet)(void);
     88   1.4      matt 	int	(*splsw_splsoftbio)(void);
     89   1.4      matt 	int	(*splsw_splsoftclock)(void);
     90   1.4      matt 	int	(*splsw_splraise)(int);
     91   1.4      matt 	void	(*splsw_spl0)(void);
     92   1.4      matt 	void	(*splsw_splx)(int);
     93   1.4      matt 	int	(*splsw_splhigh_noprof)(void);
     94   1.4      matt 	void	(*splsw_splx_noprof)(int);
     95   1.4      matt 	void	(*splsw__setsoftintr)(uint32_t);
     96   1.4      matt 	void	(*splsw__clrsoftintr)(uint32_t);
     97   1.4      matt 	int	(*splsw_splintr)(uint32_t *);
     98   1.4      matt 	void	(*splsw_splcheck)(void);
     99   1.4      matt };
    100   1.4      matt 
    101   1.4      matt struct ipl_sr_map {
    102   1.4      matt 	uint32_t sr_bits[_IPL_N];
    103   1.4      matt };
    104   1.4      matt #else
    105   1.4      matt struct splsw;
    106   1.4      matt #endif /* __INTR_PRIVATE */
    107   1.4      matt 
    108   1.4      matt typedef int ipl_t;
    109   1.4      matt typedef struct {
    110   1.4      matt         ipl_t _spl;
    111   1.4      matt } ipl_cookie_t;
    112   1.4      matt 
    113   1.4      matt #ifdef _KERNEL
    114   1.4      matt 
    115  1.12     skrll #if 0
    116   1.4      matt #if defined(MULTIPROCESSOR) && defined(__HAVE_FAST_SOFTINTS)
    117  1.11    simonb #define	__HAVE_PREEMPTION	1
    118  1.11    simonb #define	SOFTINT_KPREEMPT	(SOFTINT_COUNT+0)
    119   1.4      matt #endif
    120  1.12     skrll #endif
    121   1.4      matt 
    122   1.4      matt #ifdef __INTR_PRIVATE
    123   1.4      matt extern	struct splsw	mips_splsw;
    124   1.4      matt extern	struct ipl_sr_map ipl_sr_map;
    125   1.4      matt #endif /* __INTR_PRIVATE */
    126   1.4      matt 
    127   1.4      matt int	splhigh(void);
    128  1.13    simonb int	__noprofile splhigh_noprof(void);
    129   1.4      matt int	splsched(void);
    130   1.4      matt int	splvm(void);
    131   1.4      matt int	splsoftserial(void);
    132   1.4      matt int	splsoftnet(void);
    133   1.4      matt int	splsoftbio(void);
    134   1.4      matt int	splsoftclock(void);
    135   1.4      matt int	splraise(int);
    136   1.4      matt void	splx(int);
    137  1.13    simonb void	__noprofile splx_noprof(int);
    138   1.4      matt void	spl0(void);
    139   1.4      matt int	splintr(uint32_t *);
    140   1.4      matt void	_setsoftintr(uint32_t);
    141   1.4      matt void	_clrsoftintr(uint32_t);
    142   1.4      matt 
    143   1.4      matt struct cpu_info;
    144   1.4      matt 
    145   1.4      matt void	ipi_init(struct cpu_info *);
    146   1.4      matt void	ipi_process(struct cpu_info *, uint64_t);
    147   1.1  jonathan 
    148   1.1  jonathan /*
    149   1.4      matt  * These make no sense *NOT* to be inlined.
    150   1.1  jonathan  */
    151   1.4      matt static inline ipl_cookie_t
    152   1.4      matt makeiplcookie(ipl_t s)
    153   1.4      matt {
    154   1.4      matt 	return (ipl_cookie_t){._spl = s};
    155   1.4      matt }
    156   1.1  jonathan 
    157   1.4      matt static inline int
    158   1.4      matt splraiseipl(ipl_cookie_t icookie)
    159   1.4      matt {
    160   1.4      matt 	return splraise(icookie._spl);
    161   1.4      matt }
    162   1.1  jonathan 
    163   1.4      matt #endif /* _KERNEL */
    164   1.4      matt #endif /* _MIPS_INTR_H_ */
    165