Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.23
      1  1.23  riastrad /*	$NetBSD: intr.h,v 1.23 2023/07/11 11:13:32 riastradh Exp $	*/
      2   1.1       dbj 
      3   1.1       dbj /*
      4   1.1       dbj  * Copyright (C) 1997 Scott Reynolds
      5   1.1       dbj  * Copyright (C) 1998 Darrin Jewell
      6   1.1       dbj  * All rights reserved.
      7   1.1       dbj  *
      8   1.1       dbj  * Redistribution and use in source and binary forms, with or without
      9   1.1       dbj  * modification, are permitted provided that the following conditions
     10   1.1       dbj  * are met:
     11   1.1       dbj  * 1. Redistributions of source code must retain the above copyright
     12   1.1       dbj  *    notice, this list of conditions and the following disclaimer.
     13   1.1       dbj  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1       dbj  *    notice, this list of conditions and the following disclaimer in the
     15   1.1       dbj  *    documentation and/or other materials provided with the distribution.
     16   1.1       dbj  * 3. The name of the author may not be used to endorse or promote products
     17   1.1       dbj  *    derived from this software without specific prior written permission.
     18   1.1       dbj  *
     19   1.1       dbj  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20   1.1       dbj  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21   1.1       dbj  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22   1.1       dbj  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23   1.1       dbj  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24   1.1       dbj  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25   1.1       dbj  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26   1.1       dbj  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27   1.1       dbj  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28   1.1       dbj  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29   1.1       dbj  */
     30   1.1       dbj 
     31   1.1       dbj #ifndef _NEXT68K_INTR_H_
     32   1.1       dbj #define _NEXT68K_INTR_H_
     33   1.1       dbj 
     34   1.1       dbj #include <machine/psl.h>
     35   1.1       dbj 
     36   1.1       dbj /* Probably want to dealwith IPL's here @@@ */
     37   1.1       dbj 
     38  1.23  riastrad #if defined(_KERNEL) || defined(_KMEMUSER)
     39  1.23  riastrad typedef struct {
     40  1.23  riastrad 	uint16_t _psl;
     41  1.23  riastrad } ipl_cookie_t;
     42  1.23  riastrad #endif
     43  1.23  riastrad 
     44   1.1       dbj #ifdef _KERNEL
     45   1.1       dbj 
     46   1.1       dbj /* spl0 requires checking for software interrupts */
     47   1.1       dbj 
     48   1.1       dbj /* watch out for side effects */
     49   1.1       dbj #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
     50   1.1       dbj 
     51  1.20        ad #define splsoftbio()	splraise1()
     52  1.20        ad #define splsoftnet()    splraise1()
     53  1.20        ad #define splsoftclock()	splraise1()
     54  1.20        ad #define splsoftserial()	splraise1()
     55  1.18   tsutsui #define splvm()         splraise6()
     56  1.18   tsutsui #define splhigh()       spl7()
     57  1.18   tsutsui #define splsched()      spl7()
     58  1.18   tsutsui 
     59  1.18   tsutsui #define spldma()        splraise6()
     60  1.18   tsutsui 
     61   1.1       dbj /****************************************************************/
     62   1.1       dbj 
     63  1.18   tsutsui #define	IPL_NONE	0
     64  1.18   tsutsui #define	IPL_SOFTCLOCK	1
     65  1.20        ad #define	IPL_SOFTBIO	2
     66  1.20        ad #define	IPL_SOFTNET	3
     67  1.20        ad #define	IPL_SOFTSERIAL	4
     68  1.20        ad #define	IPL_VM		5
     69  1.20        ad #define	IPL_SCHED	6
     70  1.21     isaki #define	IPL_HIGH	7
     71  1.21     isaki #define	NIPL		8
     72  1.21     isaki 
     73  1.21     isaki extern const uint16_t ipl2psl_table[NIPL];
     74  1.16      yamt 
     75  1.16      yamt typedef int ipl_t;
     76  1.16      yamt 
     77  1.22  christos static __inline ipl_cookie_t
     78  1.21     isaki makeiplcookie(ipl_t ipl)
     79  1.21     isaki {
     80  1.16      yamt 
     81  1.21     isaki 	return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
     82  1.21     isaki }
     83  1.16      yamt 
     84  1.22  christos static __inline int
     85  1.16      yamt splraiseipl(ipl_cookie_t icookie)
     86  1.16      yamt {
     87  1.16      yamt 
     88  1.18   tsutsui 	return _splraise(icookie._psl);
     89  1.16      yamt }
     90  1.16      yamt 
     91   1.1       dbj /****************************************************************/
     92   1.1       dbj 
     93   1.1       dbj /* locore.s */
     94  1.12       chs int	spl0(void);
     95  1.11   mycroft 
     96  1.11   mycroft extern volatile u_long *intrstat;
     97  1.11   mycroft extern volatile u_long *intrmask;
     98  1.11   mycroft #define INTR_SETMASK(x)		(*intrmask = (x))
     99  1.11   mycroft #define INTR_ENABLE(x)		(*intrmask |= NEXT_I_BIT(x))
    100  1.11   mycroft #define INTR_DISABLE(x)		(*intrmask &= (~NEXT_I_BIT(x)))
    101  1.11   mycroft #define INTR_OCCURRED(x)	(*intrstat & NEXT_I_BIT(x))
    102  1.11   mycroft 
    103   1.1       dbj #endif /* _KERNEL */
    104   1.1       dbj 
    105   1.1       dbj #endif /* _NEXT68K_INTR_H_ */
    106