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