Home | History | Annotate | Line # | Download | only in include
i82093var.h revision 1.2
      1 /* $NetBSD: i82093var.h,v 1.2 2002/10/01 12:57:05 fvdl Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by RedBack Networks Inc.
      9  *
     10  * Author: Bill Sommerfeld
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *        This product includes software developed by the NetBSD
     23  *        Foundation, Inc. and its contributors.
     24  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  *    contributors may be used to endorse or promote products derived
     26  *    from this software without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38  * POSSIBILITY OF SUCH DAMAGE.
     39  */
     40 
     41 #ifndef _I386_I82093VAR_H_
     42 #define _I386_I82093VAR_H_
     43 
     44 #include <machine/apicvar.h>
     45 
     46 struct ioapic_pin
     47 {
     48 	struct intrhand		*ip_handler;
     49 	struct ioapic_pin	*ip_next; /* next pin on this vector */
     50 	struct mp_intr_map 	*ip_map;
     51 	int			ip_vector; /* IDT vector */
     52 	int			ip_type;
     53 	int			ip_minlevel;
     54 	int			ip_maxlevel;
     55 };
     56 
     57 struct ioapic_softc {
     58 	struct device		sc_dev;	/* generic device glue */
     59 	struct ioapic_softc	*sc_next;
     60 	int			sc_apicid;
     61 	int			sc_apic_vers;
     62 	int			sc_apic_sz;	/* apic size*/
     63 	int			sc_flags;
     64 	paddr_t			sc_pa;		/* PA of ioapic */
     65 	volatile u_int32_t	*sc_reg;	/* KVA of ioapic addr */
     66 	volatile u_int32_t	*sc_data;	/* KVA of ioapic data */
     67 	struct ioapic_pin	*sc_pins;	/* sc_apic_sz entries */
     68 };
     69 
     70 /*
     71  * MP: intr_handle_t is bitfielded.
     72  * ih&0xff -> legacy irq number.
     73  * ih&0x10000000 -> if 0, old-style isa irq; if 1, routed via ioapic.
     74  * (ih&0xff0000)>>16 -> ioapic id.
     75  * (ih&0x00ff00)>>8 -> ioapic pin.
     76  */
     77 
     78 #define APIC_INT_VIA_APIC	0x10000000
     79 #define APIC_INT_APIC_MASK	0x00ff0000
     80 #define APIC_INT_APIC_SHIFT	16
     81 #define APIC_INT_PIN_MASK	0x0000ff00
     82 #define APIC_INT_PIN_SHIFT	8
     83 
     84 #define APIC_IRQ_APIC(x) ((x & APIC_INT_APIC_MASK) >> APIC_INT_APIC_SHIFT)
     85 #define APIC_IRQ_PIN(x) ((x & APIC_INT_PIN_MASK) >> APIC_INT_PIN_SHIFT)
     86 
     87 void *apic_intr_establish __P((int, int, int, int (*)(void *), void *));
     88 void apic_intr_disestablish __P((void *));
     89 
     90 void ioapic_print_redir (struct ioapic_softc *, char *, int);
     91 void ioapic_format_redir (char *, char *, int, u_int32_t, u_int32_t);
     92 struct ioapic_softc *ioapic_find (int);
     93 
     94 void ioapic_enable __P((void));
     95 void lapic_vectorset __P((void)); /* XXX */
     96 
     97 extern int ioapic_bsp_id;
     98 
     99 #endif /* !_I386_I82093VAR_H_ */
    100