Home | History | Annotate | Line # | Download | only in pic
picvar.h revision 1.2
      1 /*	$NetBSD: picvar.h,v 1.2 2007/10/17 19:56:46 garbled Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2007 Michael Lorenz
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. Neither the name of The NetBSD Foundation nor the names of its
     16  *    contributors may be used to endorse or promote products derived
     17  *    from this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include <sys/cdefs.h>
     33 __KERNEL_RCSID(0, "$NetBSD: picvar.h,v 1.2 2007/10/17 19:56:46 garbled Exp $");
     34 
     35 #ifndef PIC_VAR_H
     36 #define PIC_VAR_H
     37 
     38 #include <machine/intr.h>
     39 
     40 struct pic_ops {
     41 	void *pic_cookie;	/* private stuff / hardware info */
     42 	int pic_intrbase;	/* global number of the 1st IRQ we handle */
     43 	int pic_numintrs;	/* how many IRQs do we handle? */
     44 	/*
     45 	 * all functions that take an IRQ number as argument need a local
     46 	 * interrupt number
     47 	 */
     48 	void (*pic_enable_irq)(struct pic_ops *, int, int);
     49 	void (*pic_reenable_irq)(struct pic_ops *, int, int);
     50 	void (*pic_disable_irq)(struct pic_ops *, int);
     51 	int (*pic_get_irq)(struct pic_ops *);
     52 	void (*pic_ack_irq)(struct pic_ops *, int); /* IRQ numbner */
     53 	/* IRQ number, type, priority */
     54 	void (*pic_establish_irq)(struct pic_ops *, int, int, int);
     55 	/* finish setup after CPUs are attached */
     56 	void (*pic_finish_setup)(struct pic_ops *);
     57 	char pic_name[16];
     58 };
     59 
     60 struct intr_source {
     61 	int is_type;
     62 	int is_level;
     63 	int is_hwirq;
     64 	int is_mask;
     65 	struct intrhand *is_hand;
     66 	struct pic_ops *is_pic;
     67 	struct evcnt is_ev;
     68 	char is_source[16];
     69 };
     70 
     71 struct i8259_ops {
     72 	struct pic_ops pic;
     73 	uint32_t pending_events;
     74 	uint32_t enable_mask;
     75 	uint32_t irqs;
     76 };
     77 
     78 /*
     79  * add a pic, fill in pic_intrbase, return pic_intrbase on success,
     80  * -1 otherwise
     81  * the PIC must be initialized and ready for use
     82  */
     83 int	pic_add(struct pic_ops *);
     84 
     85 void	pic_do_pending_int(void);
     86 void	pic_enable_irq(int);
     87 void	pic_disable_irq(int);
     88 int	pic_handle_intr(void *);
     89 void	pic_mark_pending(int);
     90 void	pic_ext_intr(void);
     91 void	pic_init(void);
     92 const char *intr_typename(int);
     93 void	dummy_pic_establish_intr(struct pic_ops *, int, int, int);
     94 
     95 /* this is called after attaching CPUs so PICs can setup interrupt routing */
     96 void pic_finish_setup(void);
     97 
     98 /* address, enable passthrough */
     99 #define PIC_IVR_IBM	0
    100 #define PIC_IVR_MOT	1
    101 struct pic_ops *setup_openpic(void *, int);
    102 struct pic_ops *setup_prepivr(int);
    103 struct pic_ops *setup_i8259(void);
    104 
    105 /* i8259 common decls */
    106 void i8259_initialize(void);
    107 void i8259_enable_irq(struct pic_ops *, int, int);
    108 void i8259_disable_irq(struct pic_ops *, int);
    109 void i8259_ack_irq(struct pic_ops *, int);
    110 int i8259_get_irq(struct pic_ops *);
    111 
    112 /* IPI handler */
    113 int cpuintr(void *);
    114 /* XXX - may need to be PIC specific */
    115 #define IPI_VECTOR 64
    116 
    117 #endif /* PIC_VAR_H */
    118