Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.23
      1  1.23   martin /*	$NetBSD: intr.h,v 1.23 2008/04/28 20:23:30 martin 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  *
     19  1.13  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.13  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.13  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.13  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.13  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.13  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.13  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.13  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.13  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.13  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.13  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1   tsubai  */
     31   1.1   tsubai 
     32   1.1   tsubai #ifndef _MACHINE_INTR_H_
     33   1.1   tsubai #define _MACHINE_INTR_H_
     34   1.1   tsubai 
     35   1.4   tsubai #define IPL_NONE	0	/* disable only this interrupt */
     36  1.22       ad #define IPL_SOFTCLOCK	1	/* clock software interrupts (SI 0) */
     37  1.22       ad #define IPL_SOFTBIO	1	/* bio software interrupts (SI 0) */
     38  1.22       ad #define IPL_SOFTNET	2	/* network software interrupts (SI 1) */
     39  1.22       ad #define IPL_SOFTSERIAL	2	/* serial software interrupts (SI 1) */
     40  1.22       ad #define	IPL_VM		3
     41  1.22       ad #define IPL_SCHED	4	/* disable clock interrupts */
     42  1.22       ad #define IPL_HIGH	4	/* disable all interrupts */
     43  1.13  tsutsui 
     44  1.22       ad #define _IPL_N		5
     45  1.13  tsutsui 
     46  1.22       ad #define _IPL_SI0_FIRST	IPL_SOFTCLOCK
     47  1.22       ad #define _IPL_SI0_LAST	IPL_SOFTBIO
     48  1.13  tsutsui 
     49  1.13  tsutsui #define _IPL_SI1_FIRST	IPL_SOFTNET
     50  1.13  tsutsui #define _IPL_SI1_LAST	IPL_SOFTSERIAL
     51  1.13  tsutsui 
     52   1.4   tsubai #ifdef _KERNEL
     53   1.2   tsubai #ifndef _LOCORE
     54  1.13  tsutsui 
     55  1.12  tsutsui #include <sys/device.h>
     56  1.20  tsutsui #include <mips/locore.h>
     57  1.13  tsutsui 
     58  1.15  tsutsui extern const uint32_t ipl_sr_bits[_IPL_N];
     59   1.2   tsubai 
     60   1.4   tsubai #define spl0()		(void)_spllower(0)
     61   1.4   tsubai #define splx(s)		(void)_splset(s)
     62  1.13  tsutsui 
     63  1.13  tsutsui #define splsoft()	_splraise(ipl_sr_bits[IPL_SOFT])
     64  1.13  tsutsui 
     65  1.18     yamt typedef int ipl_t;
     66  1.18     yamt typedef struct {
     67  1.18     yamt 	ipl_t _sr;
     68  1.18     yamt } ipl_cookie_t;
     69  1.18     yamt 
     70  1.18     yamt static inline ipl_cookie_t
     71  1.18     yamt makeiplcookie(ipl_t ipl)
     72  1.18     yamt {
     73  1.18     yamt 
     74  1.18     yamt 	return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
     75  1.18     yamt }
     76  1.18     yamt 
     77  1.18     yamt static inline int
     78  1.18     yamt splraiseipl(ipl_cookie_t icookie)
     79  1.18     yamt {
     80  1.18     yamt 
     81  1.18     yamt 	return _splraise(icookie._sr);
     82  1.18     yamt }
     83  1.18     yamt 
     84  1.18     yamt #include <sys/spl.h>
     85  1.18     yamt 
     86  1.12  tsutsui struct newsmips_intrhand {
     87  1.12  tsutsui 	LIST_ENTRY(newsmips_intrhand) ih_q;
     88  1.12  tsutsui 	struct evcnt intr_count;
     89  1.12  tsutsui 	int (*ih_func)(void *);
     90  1.12  tsutsui 	void *ih_arg;
     91  1.12  tsutsui 	u_int ih_level;
     92  1.12  tsutsui 	u_int ih_mask;
     93  1.12  tsutsui 	u_int ih_priority;
     94  1.12  tsutsui };
     95  1.12  tsutsui 
     96  1.12  tsutsui struct newsmips_intr {
     97  1.12  tsutsui 	LIST_HEAD(,newsmips_intrhand) intr_q;
     98  1.12  tsutsui };
     99   1.1   tsubai 
    100   1.1   tsubai /*
    101   1.1   tsubai  * Index into intrcnt[], which is defined in locore
    102   1.1   tsubai  */
    103  1.13  tsutsui #define SERIAL0_INTR	0
    104  1.13  tsutsui #define SERIAL1_INTR	1
    105  1.13  tsutsui #define SERIAL2_INTR	2
    106  1.13  tsutsui #define LANCE_INTR	3
    107  1.13  tsutsui #define SCSI_INTR	4
    108  1.13  tsutsui #define ERROR_INTR	5
    109  1.13  tsutsui #define HARDCLOCK_INTR	6
    110  1.13  tsutsui #define FPU_INTR	7
    111  1.13  tsutsui #define SLOT1_INTR	8
    112  1.13  tsutsui #define SLOT2_INTR	9
    113  1.13  tsutsui #define SLOT3_INTR	10
    114  1.13  tsutsui #define FLOPPY_INTR	11
    115  1.13  tsutsui #define STRAY_INTR	12
    116   1.1   tsubai 
    117   1.2   tsubai extern u_int intrcnt[];
    118   1.1   tsubai 
    119   1.2   tsubai /* handle i/o device interrupts */
    120  1.13  tsutsui #ifdef news3400
    121  1.16  tsutsui void news3400_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    122  1.13  tsutsui #endif
    123  1.13  tsutsui #ifdef news5000
    124  1.16  tsutsui void news5000_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    125  1.13  tsutsui #endif
    126  1.16  tsutsui extern void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
    127   1.5   tsubai 
    128  1.15  tsutsui extern void (*enable_intr)(void);
    129  1.15  tsutsui extern void (*disable_intr)(void);
    130  1.15  tsutsui extern void (*enable_timer)(void);
    131   1.4   tsubai 
    132   1.2   tsubai #endif /* !_LOCORE */
    133   1.4   tsubai #endif /* _KERNEL */
    134   1.1   tsubai #endif /* _MACHINE_INTR_H_ */
    135