Home | History | Annotate | Line # | Download | only in pic
picvar.h revision 1.2
      1 /*	$NetBSD: picvar.h,v 1.2 2008/04/27 18:58:45 matt Exp $	*/
      2 /*-
      3  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Matt Thomas.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *        This product includes software developed by the NetBSD
     20  *        Foundation, Inc. and its contributors.
     21  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  *    contributors may be used to endorse or promote products derived
     23  *    from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 #ifndef _ARM_PIC_PICVAR_H_
     38 #define _ARM_PIC_PICVAR_H_
     39 
     40 int	_splraise(int);
     41 int	_spllower(int);
     42 void	splx(int);
     43 const char *
     44 	intr_typename(int);
     45 
     46 struct pic_softc;
     47 struct intrsource;
     48 
     49 int	pic_handle_intr(void *);
     50 void	pic_mark_pending(struct pic_softc *pic, int irq);
     51 void	pic_mark_pending_source(struct pic_softc *pic, struct intrsource *is);
     52 uint32_t pic_mark_pending_sources(struct pic_softc *pic, size_t irq_base,
     53 	    uint32_t pending);
     54 void	*pic_establish_intr(struct pic_softc *pic, int irq, int ipl, int type,
     55 	    int (*func)(void *), void *arg);
     56 int	pic_alloc_irq(struct pic_softc *pic);
     57 void	pic_disestablish_source(struct intrsource *is);
     58 void	pic_do_pending_ints(register_t psw, int newipl, void *frame);
     59 void	pic_dispatch(struct intrsource *is, void *frame);
     60 
     61 void	*intr_establish(int irq, int ipl, int type, int (*func)(void *),
     62 	    void *arg);
     63 void	intr_disestablish(void *);
     64 
     65 #ifdef _INTR_PRIVATE
     66 
     67 #ifndef PIC_MAXPICS
     68 #define PIC_MAXPICS	32
     69 #endif
     70 #ifndef PIC_MAXSOURCES
     71 #define	PIC_MAXSOURCES	64
     72 #endif
     73 #ifndef PIC_MAXMAXSOURCES
     74 #define	PIC_MAXMAXSOURCES	128
     75 #endif
     76 
     77 struct intrsource {
     78 	int (*is_func)(void *);
     79 	void *is_arg;
     80 	struct pic_softc *is_pic;		/* owning PIC */
     81 	uint8_t is_type;			/* IST_xxx */
     82 	uint8_t is_ipl;				/* IPL_xxx */
     83 	uint8_t is_irq;				/* local to pic */
     84 	uint8_t is_iplidx;
     85 	struct evcnt is_ev;
     86 	char is_source[16];
     87 };
     88 
     89 struct pic_softc {
     90 	const struct pic_ops *pic_ops;
     91 	struct intrsource **pic_sources;
     92 	uint32_t pic_pending_irqs[(PIC_MAXSOURCES + 31) / 32];
     93 	uint32_t pic_blocked_irqs[(PIC_MAXSOURCES + 31) / 32];
     94 	uint32_t pic_pending_ipls;
     95 	size_t pic_maxsources;
     96 	uint8_t pic_id;
     97 	int16_t pic_irqbase;
     98 	char pic_name[14];
     99 };
    100 
    101 struct pic_ops {
    102 	void (*pic_unblock_irqs)(struct pic_softc *, size_t, uint32_t);
    103 	void (*pic_block_irqs)(struct pic_softc *, size_t, uint32_t);
    104 	int (*pic_find_pending_irqs)(struct pic_softc *);
    105 
    106 	void (*pic_establish_irq)(struct pic_softc *, struct intrsource *);
    107 	void (*pic_source_name)(struct pic_softc *, int, char *, size_t);
    108 };
    109 
    110 
    111 void	pic_add(struct pic_softc *, int);
    112 void	pic_do_pending_int(void);
    113 
    114 extern struct pic_softc * pic_list[PIC_MAXPICS];
    115 #endif /* _INTR_PRIVATE */
    116 
    117 #endif /* _ARM_PIC_PICVAR_H_ */
    118