| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xen_intr.c,v 1.22 2020/04/13 22:54:12 bouyer Exp $ */ | | 1 | /* $NetBSD: xen_intr.c,v 1.23 2020/04/21 19:03:51 jdolecek Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Charles M. Hannum, and by Jason R. Thorpe. | | 8 | * by Charles M. Hannum, and by Jason R. Thorpe. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 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 | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 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 | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 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 | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.22 2020/04/13 22:54:12 bouyer Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.23 2020/04/21 19:03:51 jdolecek Exp $"); |
34 | | | 34 | |
35 | #include "opt_multiprocessor.h" | | 35 | #include "opt_multiprocessor.h" |
36 | | | 36 | |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/kernel.h> | | 38 | #include <sys/kernel.h> |
39 | #include <sys/kmem.h> | | 39 | #include <sys/kmem.h> |
40 | #include <sys/cpu.h> | | 40 | #include <sys/cpu.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | | | 42 | |
43 | #include <xen/evtchn.h> | | 43 | #include <xen/evtchn.h> |
44 | #include <xen/xenfunc.h> | | 44 | #include <xen/xenfunc.h> |
45 | | | 45 | |
46 | #include <uvm/uvm.h> | | 46 | #include <uvm/uvm.h> |
| @@ -57,26 +57,30 @@ __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v | | | @@ -57,26 +57,30 @@ __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v |
57 | #include <dev/acpi/acpivar.h> | | 57 | #include <dev/acpi/acpivar.h> |
58 | #endif | | 58 | #endif |
59 | | | 59 | |
60 | #if NIOAPIC > 0 || NACPICA > 0 | | 60 | #if NIOAPIC > 0 || NACPICA > 0 |
61 | #include <machine/i82093var.h> | | 61 | #include <machine/i82093var.h> |
62 | #endif | | 62 | #endif |
63 | | | 63 | |
64 | #if NLAPIC > 0 | | 64 | #if NLAPIC > 0 |
65 | #include <machine/i82489var.h> | | 65 | #include <machine/i82489var.h> |
66 | #endif | | 66 | #endif |
67 | | | 67 | |
68 | #if NPCI > 0 | | 68 | #if NPCI > 0 |
69 | #include <dev/pci/ppbreg.h> | | 69 | #include <dev/pci/ppbreg.h> |
| | | 70 | #ifdef __HAVE_PCI_MSI_MSIX |
| | | 71 | #include <x86/pci/msipic.h> |
| | | 72 | #include <x86/pci/pci_msi_machdep.h> |
| | | 73 | #endif |
70 | #endif | | 74 | #endif |
71 | | | 75 | |
72 | #if defined(MULTIPROCESSOR) | | 76 | #if defined(MULTIPROCESSOR) |
73 | static const char *xen_ipi_names[XEN_NIPIS] = XEN_IPI_NAMES; | | 77 | static const char *xen_ipi_names[XEN_NIPIS] = XEN_IPI_NAMES; |
74 | #endif | | 78 | #endif |
75 | | | 79 | |
76 | /* | | 80 | /* |
77 | * Restore a value to cpl (unmasking interrupts). If any unmasked | | 81 | * Restore a value to cpl (unmasking interrupts). If any unmasked |
78 | * interrupts are pending, call Xspllower() to process them. | | 82 | * interrupts are pending, call Xspllower() to process them. |
79 | */ | | 83 | */ |
80 | void xen_spllower(int nlevel); | | 84 | void xen_spllower(int nlevel); |
81 | | | 85 | |
82 | void | | 86 | void |
| @@ -517,29 +521,46 @@ xen_intr_create_intrid(int legacy_irq, s | | | @@ -517,29 +521,46 @@ xen_intr_create_intrid(int legacy_irq, s |
517 | #if NIOAPIC > 0 || NACPICA > 0 | | 521 | #if NIOAPIC > 0 || NACPICA > 0 |
518 | ih = ((pic->pic_apicid << APIC_INT_APIC_SHIFT) & APIC_INT_APIC_MASK) | | 522 | ih = ((pic->pic_apicid << APIC_INT_APIC_SHIFT) & APIC_INT_APIC_MASK) |
519 | | ((pin << APIC_INT_PIN_SHIFT) & APIC_INT_PIN_MASK); | | 523 | | ((pin << APIC_INT_PIN_SHIFT) & APIC_INT_PIN_MASK); |
520 | if (pic->pic_type == PIC_IOAPIC) { | | 524 | if (pic->pic_type == PIC_IOAPIC) { |
521 | ih |= APIC_INT_VIA_APIC; | | 525 | ih |= APIC_INT_VIA_APIC; |
522 | } | | 526 | } |
523 | ih |= pin; | | 527 | ih |= pin; |
524 | return intr_string(ih, buf, len); | | 528 | return intr_string(ih, buf, len); |
525 | #endif | | 529 | #endif |
526 | | | 530 | |
527 | return NULL; /* No pic found! */ | | 531 | return NULL; /* No pic found! */ |
528 | } | | 532 | } |
529 | | | 533 | |
| | | 534 | static struct intrsource xen_dummy_intrsource; |
| | | 535 | |
| | | 536 | struct intrsource * |
| | | 537 | xen_intr_allocate_io_intrsource(const char *intrid) |
| | | 538 | { |
| | | 539 | /* Nothing to do, required by MSI code */ |
| | | 540 | return &xen_dummy_intrsource; |
| | | 541 | } |
| | | 542 | |
| | | 543 | void |
| | | 544 | xen_intr_free_io_intrsource(const char *intrid) |
| | | 545 | { |
| | | 546 | /* Nothing to do, required by MSI code */ |
| | | 547 | } |
| | | 548 | |
530 | #if !defined(XENPVHVM) | | 549 | #if !defined(XENPVHVM) |
531 | __strong_alias(spllower, xen_spllower); | | 550 | __strong_alias(spllower, xen_spllower); |
532 | __strong_alias(x86_read_psl, xen_read_psl); | | 551 | __strong_alias(x86_read_psl, xen_read_psl); |
533 | __strong_alias(x86_write_psl, xen_write_psl); | | 552 | __strong_alias(x86_write_psl, xen_write_psl); |
534 | | | 553 | |
535 | __strong_alias(intr_string, xintr_string); | | 554 | __strong_alias(intr_string, xintr_string); |
536 | __strong_alias(intr_create_intrid, xen_intr_create_intrid); | | 555 | __strong_alias(intr_create_intrid, xen_intr_create_intrid); |
537 | __strong_alias(intr_establish, xen_intr_establish); | | 556 | __strong_alias(intr_establish, xen_intr_establish); |
538 | __strong_alias(intr_establish_xname, xen_intr_establish_xname); | | 557 | __strong_alias(intr_establish_xname, xen_intr_establish_xname); |
539 | __strong_alias(intr_mask, xen_intr_mask); | | 558 | __strong_alias(intr_mask, xen_intr_mask); |
540 | __strong_alias(intr_unmask, xen_intr_unmask); | | 559 | __strong_alias(intr_unmask, xen_intr_unmask); |
541 | __strong_alias(intr_disestablish, xen_intr_disestablish); | | 560 | __strong_alias(intr_disestablish, xen_intr_disestablish); |
542 | __strong_alias(cpu_intr_redistribute, xen_cpu_intr_redistribute); | | 561 | __strong_alias(cpu_intr_redistribute, xen_cpu_intr_redistribute); |
543 | __strong_alias(cpu_intr_count, xen_cpu_intr_count); | | 562 | __strong_alias(cpu_intr_count, xen_cpu_intr_count); |
544 | __strong_alias(cpu_intr_init, xen_cpu_intr_init); | | 563 | __strong_alias(cpu_intr_init, xen_cpu_intr_init); |
| | | 564 | __strong_alias(intr_allocate_io_intrsource, xen_intr_allocate_io_intrsource); |
| | | 565 | __strong_alias(intr_free_io_intrsource, xen_intr_free_io_intrsource); |
545 | #endif /* !XENPVHVM */ | | 566 | #endif /* !XENPVHVM */ |