Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.17.20.1
      1  1.17.20.1       ad /*	$NetBSD: intr.h,v 1.17.20.1 2007/01/12 01:00:55 ad Exp $	*/
      2        1.1   tsubai 
      3       1.13  tsutsui /*-
      4       1.13  tsutsui  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
      5       1.13  tsutsui  * All rights reserved.
      6       1.13  tsutsui  *
      7       1.13  tsutsui  * This code is derived from software contributed to The NetBSD Foundation
      8       1.13  tsutsui  * by Jason R. Thorpe.
      9        1.1   tsubai  *
     10        1.1   tsubai  * Redistribution and use in source and binary forms, with or without
     11        1.1   tsubai  * modification, are permitted provided that the following conditions
     12        1.1   tsubai  * are met:
     13        1.1   tsubai  * 1. Redistributions of source code must retain the above copyright
     14        1.1   tsubai  *    notice, this list of conditions and the following disclaimer.
     15        1.1   tsubai  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1   tsubai  *    notice, this list of conditions and the following disclaimer in the
     17        1.1   tsubai  *    documentation and/or other materials provided with the distribution.
     18        1.1   tsubai  * 3. All advertising materials mentioning features or use of this software
     19        1.1   tsubai  *    must display the following acknowledgement:
     20       1.13  tsutsui  *	This product includes software developed by the NetBSD
     21       1.13  tsutsui  *	Foundation, Inc. and its contributors.
     22       1.13  tsutsui  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.13  tsutsui  *    contributors may be used to endorse or promote products derived
     24       1.13  tsutsui  *    from this software without specific prior written permission.
     25        1.1   tsubai  *
     26       1.13  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.13  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.13  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.13  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.13  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.13  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.13  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.13  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.13  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.13  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.13  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     37        1.1   tsubai  */
     38        1.1   tsubai 
     39        1.1   tsubai #ifndef _MACHINE_INTR_H_
     40        1.1   tsubai #define _MACHINE_INTR_H_
     41        1.1   tsubai 
     42        1.4   tsubai #define IPL_NONE	0	/* disable only this interrupt */
     43       1.13  tsutsui #define IPL_SOFT	1	/* generic software interrupts (SI 0) */
     44       1.13  tsutsui #define IPL_SOFTCLOCK	2	/* clock software interrupts (SI 0) */
     45       1.13  tsutsui #define IPL_SOFTNET	3	/* network software interrupts (SI 1) */
     46       1.13  tsutsui #define IPL_SOFTSERIAL	4	/* serial software interrupts (SI 1) */
     47       1.13  tsutsui #define IPL_BIO		5	/* disable block I/O interrupts */
     48       1.13  tsutsui #define IPL_NET		6	/* disable network interrupts */
     49       1.13  tsutsui #define IPL_TTY		7	/* disable terminal interrupts */
     50  1.17.20.1       ad #define	IPL_LPT		IPL_TTY
     51  1.17.20.1       ad #define	IPL_VM		IPL_TTY
     52       1.13  tsutsui #define IPL_SERIAL	7	/* disable serial hardware interrupts */
     53       1.13  tsutsui #define IPL_CLOCK	8	/* disable clock interrupts */
     54  1.17.20.1       ad #define	IPL_STATCLOCK	IPL_CLOCK
     55  1.17.20.1       ad #define	IPL_SCHED	IPL_CLOCK
     56       1.13  tsutsui #define IPL_HIGH	8	/* disable all interrupts */
     57  1.17.20.1       ad #define	IPL_LOCK	IPL_HIGH
     58       1.13  tsutsui 
     59       1.13  tsutsui #define _IPL_N		9
     60       1.13  tsutsui 
     61       1.13  tsutsui #define _IPL_SI0_FIRST	IPL_SOFT
     62       1.13  tsutsui #define _IPL_SI0_LAST	IPL_SOFTCLOCK
     63       1.13  tsutsui 
     64       1.13  tsutsui #define _IPL_SI1_FIRST	IPL_SOFTNET
     65       1.13  tsutsui #define _IPL_SI1_LAST	IPL_SOFTSERIAL
     66       1.13  tsutsui 
     67  1.17.20.1       ad #define	SI_SOFT		0
     68  1.17.20.1       ad #define	SI_SOFTCLOCK	1
     69  1.17.20.1       ad #define	SI_SOFTNET	2
     70  1.17.20.1       ad #define	SI_SOFTSERIAL	3
     71  1.17.20.1       ad 
     72  1.17.20.1       ad #define	SI_NQUEUES	4
     73  1.17.20.1       ad 
     74  1.17.20.1       ad #define	SI_QUEUENAMES {							\
     75       1.13  tsutsui 	"misc",								\
     76       1.13  tsutsui 	"clock",							\
     77       1.13  tsutsui 	"net",								\
     78       1.13  tsutsui 	"serial",							\
     79       1.13  tsutsui }
     80        1.2   tsubai 
     81        1.4   tsubai #ifdef _KERNEL
     82        1.2   tsubai #ifndef _LOCORE
     83       1.13  tsutsui 
     84       1.12  tsutsui #include <sys/device.h>
     85       1.13  tsutsui 
     86       1.15  tsutsui extern const uint32_t ipl_sr_bits[_IPL_N];
     87        1.2   tsubai 
     88       1.15  tsutsui extern int _splraise(int);
     89       1.15  tsutsui extern int _spllower(int);
     90       1.15  tsutsui extern int _splset(int);
     91       1.15  tsutsui extern int _splget(void);
     92       1.15  tsutsui extern void _splnone(void);
     93       1.15  tsutsui extern void _setsoftintr(int);
     94       1.15  tsutsui extern void _clrsoftintr(int);
     95        1.4   tsubai 
     96        1.4   tsubai #define spl0()		(void)_spllower(0)
     97        1.4   tsubai #define splx(s)		(void)_splset(s)
     98       1.13  tsutsui 
     99       1.13  tsutsui #define splsoft()	_splraise(ipl_sr_bits[IPL_SOFT])
    100       1.13  tsutsui 
    101       1.13  tsutsui #define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
    102       1.12  tsutsui 
    103  1.17.20.1       ad typedef int ipl_t;
    104  1.17.20.1       ad typedef struct {
    105  1.17.20.1       ad 	ipl_t _sr;
    106  1.17.20.1       ad } ipl_cookie_t;
    107  1.17.20.1       ad 
    108  1.17.20.1       ad static inline ipl_cookie_t
    109  1.17.20.1       ad makeiplcookie(ipl_t ipl)
    110  1.17.20.1       ad {
    111  1.17.20.1       ad 
    112  1.17.20.1       ad 	return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
    113  1.17.20.1       ad }
    114  1.17.20.1       ad 
    115  1.17.20.1       ad static inline int
    116  1.17.20.1       ad splraiseipl(ipl_cookie_t icookie)
    117  1.17.20.1       ad {
    118  1.17.20.1       ad 
    119  1.17.20.1       ad 	return _splraise(icookie._sr);
    120  1.17.20.1       ad }
    121  1.17.20.1       ad 
    122  1.17.20.1       ad #include <sys/spl.h>
    123  1.17.20.1       ad 
    124       1.12  tsutsui struct newsmips_intrhand {
    125       1.12  tsutsui 	LIST_ENTRY(newsmips_intrhand) ih_q;
    126       1.12  tsutsui 	struct evcnt intr_count;
    127       1.12  tsutsui 	int (*ih_func)(void *);
    128       1.12  tsutsui 	void *ih_arg;
    129       1.12  tsutsui 	u_int ih_level;
    130       1.12  tsutsui 	u_int ih_mask;
    131       1.12  tsutsui 	u_int ih_priority;
    132       1.12  tsutsui };
    133       1.12  tsutsui 
    134       1.12  tsutsui struct newsmips_intr {
    135       1.12  tsutsui 	LIST_HEAD(,newsmips_intrhand) intr_q;
    136       1.12  tsutsui };
    137        1.1   tsubai 
    138       1.13  tsutsui #include <mips/softintr.h>
    139       1.13  tsutsui 
    140        1.1   tsubai /*
    141        1.1   tsubai  * Index into intrcnt[], which is defined in locore
    142        1.1   tsubai  */
    143       1.13  tsutsui #define SERIAL0_INTR	0
    144       1.13  tsutsui #define SERIAL1_INTR	1
    145       1.13  tsutsui #define SERIAL2_INTR	2
    146       1.13  tsutsui #define LANCE_INTR	3
    147       1.13  tsutsui #define SCSI_INTR	4
    148       1.13  tsutsui #define ERROR_INTR	5
    149       1.13  tsutsui #define HARDCLOCK_INTR	6
    150       1.13  tsutsui #define FPU_INTR	7
    151       1.13  tsutsui #define SLOT1_INTR	8
    152       1.13  tsutsui #define SLOT2_INTR	9
    153       1.13  tsutsui #define SLOT3_INTR	10
    154       1.13  tsutsui #define FLOPPY_INTR	11
    155       1.13  tsutsui #define STRAY_INTR	12
    156        1.1   tsubai 
    157        1.2   tsubai extern u_int intrcnt[];
    158        1.1   tsubai 
    159        1.2   tsubai /* handle i/o device interrupts */
    160       1.13  tsutsui #ifdef news3400
    161       1.16  tsutsui void news3400_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    162       1.13  tsutsui #endif
    163       1.13  tsutsui #ifdef news5000
    164       1.16  tsutsui void news5000_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    165       1.13  tsutsui #endif
    166       1.16  tsutsui extern void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
    167        1.5   tsubai 
    168       1.15  tsutsui extern void (*enable_intr)(void);
    169       1.15  tsutsui extern void (*disable_intr)(void);
    170       1.15  tsutsui extern void (*enable_timer)(void);
    171        1.4   tsubai 
    172        1.2   tsubai #endif /* !_LOCORE */
    173        1.4   tsubai #endif /* _KERNEL */
    174        1.1   tsubai #endif /* _MACHINE_INTR_H_ */
    175