| 1 | /*	$OpenBSD: i82093var.h,v 1.8 2025/09/05 16:57:48 kettenis Exp $	*/ |
| 2 | /* $NetBSD: i82093var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * This code is derived from software contributed to The NetBSD Foundation |
| 9 | * by RedBack Networks Inc. |
| 10 | * |
| 11 | * Author: Bill Sommerfeld |
| 12 | * |
| 13 | * Redistribution and use in source and binary forms, with or without |
| 14 | * modification, are permitted provided that the following conditions |
| 15 | * are met: |
| 16 | * 1. Redistributions of source code must retain the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer. |
| 18 | * 2. Redistributions in binary form must reproduce the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer in the |
| 20 | * documentation and/or other materials provided with the distribution. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 23 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 24 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 25 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 32 | * POSSIBILITY OF SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | #ifndef _MACHINE_I82093VAR_H_ |
| 36 | #define _MACHINE_I82093VAR_H_ |
| 37 | |
| 38 | #include <machine/apicvar.h> |
| 39 | |
| 40 | struct ioapic_pin { |
| 41 | 	struct ioapic_pin	*ip_next;	/* next pin on this vector */ |
| 42 | 	struct mp_intr_map 	*ip_map; |
| 43 | 	int			ip_vector;	/* IDT vector */ |
| 44 | 	int			ip_type; |
| 45 | 	struct cpu_info		*ip_cpu;	/* target CPU */ |
| 46 | }; |
| 47 | |
| 48 | struct ioapic_softc { |
| 49 | 	struct pic		sc_pic; |
| 50 | 	struct ioapic_softc	*sc_next; |
| 51 | 	int			sc_apicid; |
| 52 | 	int			sc_apic_vers; |
| 53 | 	int			sc_apic_vecbase; /* global int base if ACPI */ |
| 54 | 	int			sc_apic_sz;	/* apic size*/ |
| 55 | 	int			sc_flags; |
| 56 | 	bus_space_tag_t		sc_memt; |
| 57 | 	bus_space_handle_t	sc_memh; |
| 58 | 	struct ioapic_pin	*sc_pins;	/* sc_apic_sz entries */ |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * MP: intr_handle_t is bitfielded. |
| 63 | * ih&0xff -> legacy irq number. |
| 64 | * ih&0x10000000 -> if 0, old-style isa irq; if 1, routed via ioapic. |
| 65 | * (ih&0xff0000)>>16 -> ioapic id. |
| 66 | * (ih&0x00ff00)>>8 -> ioapic pin. |
| 67 | */ |
| 68 | |
| 69 | #define APIC_INT_VIA_APIC	0x10000000 |
| 70 | #define APIC_INT_VIA_MSG	0x20000000 |
| 71 | #define APIC_INT_VIA_MSGX	0x40000000 |
| 72 | #define APIC_INT_APIC_MASK	0x00ff0000 |
| 73 | #define APIC_INT_APIC_SHIFT	16 |
| 74 | #define APIC_INT_PIN_MASK	0x0000ff00 |
| 75 | #define APIC_INT_PIN_SHIFT	8 |
| 76 | |
| 77 | #define APIC_IRQ_APIC(x) ((x & APIC_INT_APIC_MASK) >> APIC_INT_APIC_SHIFT) |
| 78 | #define APIC_IRQ_PIN(x) ((x & APIC_INT_PIN_MASK) >> APIC_INT_PIN_SHIFT) |
| 79 | #define APIC_IRQ_ISLEGACY(x) (!((x) & APIC_INT_VIA_APIC)) |
| 80 | #define APIC_IRQ_LEGACY_IRQ(x) ((x) & 0xff) |
| 81 | |
| 82 | void ioapic_print_redir(struct ioapic_softc *, char *, int); |
| 83 | struct ioapic_softc *ioapic_find(int); |
| 84 | struct ioapic_softc *ioapic_find_bybase(int); |
| 85 | |
| 86 | void ioapic_enable(void); |
| 87 | |
| 88 | extern int ioapic_bsp_id; |
| 89 | extern int nioapics; |
| 90 | extern struct ioapic_softc *ioapics; |
| 91 | |
| 92 | #endif /* !_MACHINE_I82093VAR_H_ */ |