Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.14.10.6
      1  1.14.10.6      yamt /*	$NetBSD: intr.h,v 1.14.10.6 2008/02/04 09:21:53 yamt Exp $	*/
      2        1.1   thorpej 
      3        1.1   thorpej /*-
      4        1.6   thorpej  * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc.
      5        1.1   thorpej  * All rights reserved.
      6        1.1   thorpej  *
      7        1.1   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8        1.1   thorpej  * by Jason R. Thorpe.
      9        1.1   thorpej  *
     10        1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     11        1.1   thorpej  * modification, are permitted provided that the following conditions
     12        1.1   thorpej  * are met:
     13        1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     14        1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     15        1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17        1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     18        1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     19        1.1   thorpej  *    must display the following acknowledgement:
     20        1.1   thorpej  *        This product includes software developed by the NetBSD
     21        1.1   thorpej  *        Foundation, Inc. and its contributors.
     22        1.1   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23        1.1   thorpej  *    contributors may be used to endorse or promote products derived
     24        1.1   thorpej  *    from this software without specific prior written permission.
     25        1.1   thorpej  *
     26        1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27        1.1   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28        1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29        1.3       jtc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30        1.3       jtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31        1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32        1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33        1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34        1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35        1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36        1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37        1.1   thorpej  */
     38        1.1   thorpej 
     39        1.1   thorpej #ifndef _HP300_INTR_H_
     40        1.1   thorpej #define	_HP300_INTR_H_
     41        1.1   thorpej 
     42       1.12  gmcgarry #include <sys/device.h>
     43       1.12  gmcgarry #include <sys/queue.h>
     44        1.1   thorpej #include <machine/psl.h>
     45        1.1   thorpej 
     46        1.1   thorpej /*
     47        1.1   thorpej  * Interrupt "levels".  These are a more abstract representation
     48        1.1   thorpej  * of interrupt levels, and do not have the same meaning as m68k
     49  1.14.10.1      yamt  * CPU interrupt levels.  They serve the following purposes:
     50        1.1   thorpej  *
     51        1.1   thorpej  *	- properly order ISRs in the list for that CPU ipl
     52        1.1   thorpej  *	- compute CPU PSL values for the spl*() calls.
     53  1.14.10.1      yamt  *	- used to create cookie for the splraiseipl().
     54        1.1   thorpej  */
     55  1.14.10.1      yamt #define	IPL_NONE	0
     56  1.14.10.1      yamt #define	IPL_SOFTCLOCK	1
     57  1.14.10.5      yamt #define	IPL_SOFTBIO	2
     58  1.14.10.5      yamt #define	IPL_SOFTNET	3
     59  1.14.10.5      yamt #define	IPL_SOFTSERIAL	4
     60  1.14.10.5      yamt #define	IPL_VM		5
     61  1.14.10.5      yamt #define	IPL_SCHED	6
     62  1.14.10.5      yamt #define	IPL_HIGH	7
     63  1.14.10.5      yamt #define	NIPL		8
     64  1.14.10.1      yamt 
     65        1.1   thorpej /*
     66  1.14.10.1      yamt  * Convert PSL values to m68k CPU IPLs and vice-versa.
     67  1.14.10.1      yamt  * Note: CPU IPL values are different from IPL_* used by splraiseipl().
     68        1.1   thorpej  */
     69        1.1   thorpej #define	PSLTOIPL(x)	(((x) >> 8) & 0xf)
     70        1.1   thorpej #define	IPLTOPSL(x)	((((x) & 0xf) << 8) | PSL_S)
     71        1.1   thorpej 
     72  1.14.10.6      yamt extern int idepth;
     73  1.14.10.1      yamt extern u_short hp300_ipl2psl[];
     74  1.14.10.1      yamt 
     75  1.14.10.1      yamt typedef int ipl_t;
     76  1.14.10.1      yamt typedef struct {
     77  1.14.10.3      yamt 	uint16_t _psl;
     78  1.14.10.1      yamt } ipl_cookie_t;
     79  1.14.10.1      yamt 
     80  1.14.10.1      yamt static inline ipl_cookie_t
     81  1.14.10.1      yamt makeiplcookie(ipl_t ipl)
     82  1.14.10.1      yamt {
     83  1.14.10.1      yamt 
     84  1.14.10.1      yamt 	return (ipl_cookie_t){._psl = hp300_ipl2psl[ipl]};
     85  1.14.10.1      yamt }
     86  1.14.10.1      yamt 
     87  1.14.10.1      yamt static inline int
     88  1.14.10.1      yamt splraiseipl(ipl_cookie_t icookie)
     89  1.14.10.1      yamt {
     90  1.14.10.1      yamt 
     91  1.14.10.1      yamt 	return _splraise(icookie._psl);
     92  1.14.10.1      yamt }
     93        1.1   thorpej 
     94        1.1   thorpej /* These spl calls are _not_ to be used by machine-independent code. */
     95        1.7   thorpej #define	splhil()	splraise1()
     96        1.1   thorpej #define	splkbd()	splhil()
     97        1.1   thorpej 
     98        1.1   thorpej /* These spl calls are used by machine-independent code. */
     99       1.12  gmcgarry /* spl0 requires checking for software interrupts */
    100  1.14.10.5      yamt #define	splsoftbio()	splraise1()
    101  1.14.10.5      yamt #define	splsoftclock()	splraise1()
    102  1.14.10.5      yamt #define	splsoftnet()	splraise1()
    103  1.14.10.5      yamt #define	splsoftserial()	splraise1()
    104  1.14.10.1      yamt #define	splvm()		_splraise(hp300_ipl2psl[IPL_VM])
    105  1.14.10.5      yamt #define	splsched()	spl6()
    106        1.1   thorpej #define	splhigh()	spl7()
    107        1.1   thorpej 
    108        1.1   thorpej /* watch out for side effects */
    109        1.1   thorpej #define	splx(s)		((s) & PSL_IPL ? _spl((s)) : spl0())
    110        1.1   thorpej 
    111       1.12  gmcgarry struct hp300_intrhand {
    112       1.12  gmcgarry 	LIST_ENTRY(hp300_intrhand) ih_q;
    113       1.12  gmcgarry 	int (*ih_fn)(void *);
    114       1.12  gmcgarry 	void *ih_arg;
    115       1.12  gmcgarry 	int ih_ipl;
    116       1.12  gmcgarry 	int ih_priority;
    117       1.12  gmcgarry };
    118       1.12  gmcgarry 
    119       1.12  gmcgarry struct hp300_intr {
    120       1.12  gmcgarry 	LIST_HEAD(, hp300_intrhand) hi_q;
    121       1.12  gmcgarry 	struct evcnt hi_evcnt;
    122       1.12  gmcgarry };
    123       1.12  gmcgarry 
    124        1.1   thorpej /* locore.s */
    125       1.12  gmcgarry int	spl0(void);
    126        1.1   thorpej 
    127        1.1   thorpej /* intr.c */
    128       1.12  gmcgarry void	intr_init(void);
    129       1.12  gmcgarry void	*intr_establish(int (*)(void *), void *, int, int);
    130       1.12  gmcgarry void	intr_disestablish(void *);
    131       1.12  gmcgarry void	intr_dispatch(int);
    132       1.12  gmcgarry void	intr_printlevels(void);
    133        1.1   thorpej 
    134        1.1   thorpej #endif /* _HP300_INTR_H_ */
    135