1*fabcfecbSjsg /* $OpenBSD: i82093var.h,v 1.13 2024/10/22 21:50:02 jsg Exp $ */ 2012ea299Sniklas /* $NetBSD: i82093var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */ 3012ea299Sniklas 4012ea299Sniklas /*- 5012ea299Sniklas * Copyright (c) 2000 The NetBSD Foundation, Inc. 6012ea299Sniklas * All rights reserved. 7012ea299Sniklas * 8012ea299Sniklas * This code is derived from software contributed to The NetBSD Foundation 9012ea299Sniklas * by RedBack Networks Inc. 10012ea299Sniklas * 11012ea299Sniklas * Author: Bill Sommerfeld 12012ea299Sniklas * 13012ea299Sniklas * Redistribution and use in source and binary forms, with or without 14012ea299Sniklas * modification, are permitted provided that the following conditions 15012ea299Sniklas * are met: 16012ea299Sniklas * 1. Redistributions of source code must retain the above copyright 17012ea299Sniklas * notice, this list of conditions and the following disclaimer. 18012ea299Sniklas * 2. Redistributions in binary form must reproduce the above copyright 19012ea299Sniklas * notice, this list of conditions and the following disclaimer in the 20012ea299Sniklas * documentation and/or other materials provided with the distribution. 21012ea299Sniklas * 22012ea299Sniklas * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23012ea299Sniklas * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24012ea299Sniklas * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25012ea299Sniklas * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26012ea299Sniklas * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27012ea299Sniklas * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28012ea299Sniklas * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29012ea299Sniklas * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30012ea299Sniklas * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31012ea299Sniklas * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32012ea299Sniklas * POSSIBILITY OF SUCH DAMAGE. 33012ea299Sniklas */ 34012ea299Sniklas 352fa72412Spirofti #ifndef _MACHINE_I82093VAR_H_ 362fa72412Spirofti #define _MACHINE_I82093VAR_H_ 37012ea299Sniklas 38012ea299Sniklas #include <machine/apicvar.h> 39012ea299Sniklas 40*fabcfecbSjsg struct ioapic_pin { 41012ea299Sniklas struct intrhand *ip_handler; 42012ea299Sniklas struct ioapic_pin *ip_next; /* next pin on this vector */ 43012ea299Sniklas struct mp_intr_map *ip_map; 44012ea299Sniklas int ip_vector; /* IDT vector */ 45012ea299Sniklas int ip_type; 46012ea299Sniklas int ip_minlevel; 47012ea299Sniklas int ip_maxlevel; 48012ea299Sniklas }; 49012ea299Sniklas 50012ea299Sniklas struct ioapic_softc { 51329fe926Skettenis struct pic sc_pic; 52012ea299Sniklas struct ioapic_softc *sc_next; 53012ea299Sniklas int sc_apicid; 54012ea299Sniklas int sc_apic_vers; 555f148e86Skettenis int sc_apic_vecbase; /* global int base if ACPI */ 56012ea299Sniklas int sc_apic_sz; /* apic size*/ 57012ea299Sniklas int sc_flags; 58012ea299Sniklas paddr_t sc_pa; /* PA of ioapic */ 59012ea299Sniklas volatile u_int32_t *sc_reg; /* KVA of ioapic addr */ 60012ea299Sniklas volatile u_int32_t *sc_data; /* KVA of ioapic data */ 61012ea299Sniklas struct ioapic_pin *sc_pins; /* sc_apic_sz entries */ 62012ea299Sniklas }; 63012ea299Sniklas 64012ea299Sniklas /* 65012ea299Sniklas * MP: intr_handle_t is bitfielded. 66012ea299Sniklas * ih&0xff -> line number. 67012ea299Sniklas * ih&0x10000000 -> if 0, old-style isa irq; if 1, routed via ioapic. 68012ea299Sniklas * (ih&0xff0000)>>16 -> ioapic id. 69012ea299Sniklas * (ih&0x00ff00)>>8 -> ioapic line. 70012ea299Sniklas */ 71012ea299Sniklas 72012ea299Sniklas #define APIC_INT_VIA_APIC 0x10000000 73c3586275Skettenis #define APIC_INT_VIA_MSG 0x20000000 74012ea299Sniklas #define APIC_INT_APIC_MASK 0x00ff0000 75012ea299Sniklas #define APIC_INT_APIC_SHIFT 16 76012ea299Sniklas #define APIC_INT_PIN_MASK 0x0000ff00 77012ea299Sniklas #define APIC_INT_PIN_SHIFT 8 78a25c7806Smickey #define APIC_INT_LINE_MASK 0x000000ff 79012ea299Sniklas 80012ea299Sniklas #define APIC_IRQ_APIC(x) ((x & APIC_INT_APIC_MASK) >> APIC_INT_APIC_SHIFT) 81012ea299Sniklas #define APIC_IRQ_PIN(x) ((x & APIC_INT_PIN_MASK) >> APIC_INT_PIN_SHIFT) 82012ea299Sniklas 83c03b1b92Smk void *apic_intr_establish(int, int, int, int (*)(void *), void *, 84c03b1b92Smk const char *); 85012ea299Sniklas void apic_intr_disestablish(void *); 86012ea299Sniklas 87012ea299Sniklas void ioapic_print_redir(struct ioapic_softc *, char *, int); 88012ea299Sniklas struct ioapic_softc *ioapic_find(int); 89012ea299Sniklas struct ioapic_softc *ioapic_find_bybase(int); 90012ea299Sniklas 91012ea299Sniklas void ioapic_enable(void); 92012ea299Sniklas 93012ea299Sniklas extern int ioapic_bsp_id; 94012ea299Sniklas extern int nioapics; 95012ea299Sniklas extern struct ioapic_softc *ioapics; 969c5868a9Sniklas extern u_int16_t ioapic_id_map; 979c5868a9Sniklas extern u_int8_t ioapic_id_remap[]; 98012ea299Sniklas 992fa72412Spirofti #endif /* !_MACHINE_I82093VAR_H_ */ 100