2003-11-03 21:25:52 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MACHINE_INTR_MACHDEP_H__
|
|
|
|
#define __MACHINE_INTR_MACHDEP_H__
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
|
2005-11-02 20:11:47 +00:00
|
|
|
/*
|
|
|
|
* The maximum number of I/O interrupts we allow. This number is rather
|
|
|
|
* arbitrary as it is just the maximum IRQ resource value. The interrupt
|
|
|
|
* source for a given IRQ maps that I/O interrupt to device interrupt
|
|
|
|
* source whether it be a pin on an interrupt controller or an MSI interrupt.
|
|
|
|
* The 16 ISA IRQs are assigned fixed IDT vectors, but all other device
|
|
|
|
* interrupts allocate IDT vectors on demand. Currently we have 191 IDT
|
|
|
|
* vectors available for device interrupts. On many systems with I/O APICs,
|
|
|
|
* a lot of the IRQs are not used, so this number can be much larger than
|
|
|
|
* 191 and still be safe since only interrupt sources in actual use will
|
|
|
|
* allocate IDT vectors.
|
|
|
|
*
|
2006-11-13 22:23:34 +00:00
|
|
|
* The first 255 IRQs (0 - 254) are reserved for ISA IRQs and PCI intline IRQs.
|
Implement vector callback for PVHVM and unify event channel implementations
Re-structure Xen HVM support so that:
- Xen is detected and hypercalls can be performed very
early in system startup.
- Xen interrupt services are implemented using FreeBSD's native
interrupt delivery infrastructure.
- the Xen interrupt service implementation is shared between PV
and HVM guests.
- Xen interrupt handlers can optionally use a filter handler
in order to avoid the overhead of dispatch to an interrupt
thread.
- interrupt load can be distributed among all available CPUs.
- the overhead of accessing the emulated local and I/O apics
on HVM is removed for event channel port events.
- a similar optimization can eventually, and fairly easily,
be used to optimize MSI.
Early Xen detection, HVM refactoring, PVHVM interrupt infrastructure,
and misc Xen cleanups:
Sponsored by: Spectra Logic Corporation
Unification of PV & HVM interrupt infrastructure, bug fixes,
and misc Xen cleanups:
Submitted by: Roger Pau Monné
Sponsored by: Citrix Systems R&D
sys/x86/x86/local_apic.c:
sys/amd64/include/apicvar.h:
sys/i386/include/apicvar.h:
sys/amd64/amd64/apic_vector.S:
sys/i386/i386/apic_vector.s:
sys/amd64/amd64/machdep.c:
sys/i386/i386/machdep.c:
sys/i386/xen/exception.s:
sys/x86/include/segments.h:
Reserve IDT vector 0x93 for the Xen event channel upcall
interrupt handler. On Hypervisors that support the direct
vector callback feature, we can request that this vector be
called directly by an injected HVM interrupt event, instead
of a simulated PCI interrupt on the Xen platform PCI device.
This avoids all of the overhead of dealing with the emulated
I/O APIC and local APIC. It also means that the Hypervisor
can inject these events on any CPU, allowing upcalls for
different ports to be handled in parallel.
sys/amd64/amd64/mp_machdep.c:
sys/i386/i386/mp_machdep.c:
Map Xen per-vcpu area during AP startup.
sys/amd64/include/intr_machdep.h:
sys/i386/include/intr_machdep.h:
Increase the FreeBSD IRQ vector table to include space
for event channel interrupt sources.
sys/amd64/include/pcpu.h:
sys/i386/include/pcpu.h:
Remove Xen HVM per-cpu variable data. These fields are now
allocated via the dynamic per-cpu scheme. See xen_intr.c
for details.
sys/amd64/include/xen/hypercall.h:
sys/dev/xen/blkback/blkback.c:
sys/i386/include/xen/xenvar.h:
sys/i386/xen/clock.c:
sys/i386/xen/xen_machdep.c:
sys/xen/gnttab.c:
Prefer FreeBSD primatives to Linux ones in Xen support code.
sys/amd64/include/xen/xen-os.h:
sys/i386/include/xen/xen-os.h:
sys/xen/xen-os.h:
sys/dev/xen/balloon/balloon.c:
sys/dev/xen/blkback/blkback.c:
sys/dev/xen/blkfront/blkfront.c:
sys/dev/xen/console/xencons_ring.c:
sys/dev/xen/control/control.c:
sys/dev/xen/netback/netback.c:
sys/dev/xen/netfront/netfront.c:
sys/dev/xen/xenpci/xenpci.c:
sys/i386/i386/machdep.c:
sys/i386/include/pmap.h:
sys/i386/include/xen/xenfunc.h:
sys/i386/isa/npx.c:
sys/i386/xen/clock.c:
sys/i386/xen/mp_machdep.c:
sys/i386/xen/mptable.c:
sys/i386/xen/xen_clock_util.c:
sys/i386/xen/xen_machdep.c:
sys/i386/xen/xen_rtc.c:
sys/xen/evtchn/evtchn_dev.c:
sys/xen/features.c:
sys/xen/gnttab.c:
sys/xen/gnttab.h:
sys/xen/hvm.h:
sys/xen/xenbus/xenbus.c:
sys/xen/xenbus/xenbus_if.m:
sys/xen/xenbus/xenbusb_front.c:
sys/xen/xenbus/xenbusvar.h:
sys/xen/xenstore/xenstore.c:
sys/xen/xenstore/xenstore_dev.c:
sys/xen/xenstore/xenstorevar.h:
Pull common Xen OS support functions/settings into xen/xen-os.h.
sys/amd64/include/xen/xen-os.h:
sys/i386/include/xen/xen-os.h:
sys/xen/xen-os.h:
Remove constants, macros, and functions unused in FreeBSD's Xen
support.
sys/xen/xen-os.h:
sys/i386/xen/xen_machdep.c:
sys/x86/xen/hvm.c:
Introduce new functions xen_domain(), xen_pv_domain(), and
xen_hvm_domain(). These are used in favor of #ifdefs so that
FreeBSD can dynamically detect and adapt to the presence of
a hypervisor. The goal is to have an HVM optimized GENERIC,
but more is necessary before this is possible.
sys/amd64/amd64/machdep.c:
sys/dev/xen/xenpci/xenpcivar.h:
sys/dev/xen/xenpci/xenpci.c:
sys/x86/xen/hvm.c:
sys/sys/kernel.h:
Refactor magic ioport, Hypercall table and Hypervisor shared
information page setup, and move it to a dedicated HVM support
module.
HVM mode initialization is now triggered during the
SI_SUB_HYPERVISOR phase of system startup. This currently
occurs just after the kernel VM is fully setup which is
just enough infrastructure to allow the hypercall table
and shared info page to be properly mapped.
sys/xen/hvm.h:
sys/x86/xen/hvm.c:
Add definitions and a method for configuring Hypervisor event
delievery via a direct vector callback.
sys/amd64/include/xen/xen-os.h:
sys/x86/xen/hvm.c:
sys/conf/files:
sys/conf/files.amd64:
sys/conf/files.i386:
Adjust kernel build to reflect the refactoring of early
Xen startup code and Xen interrupt services.
sys/dev/xen/blkback/blkback.c:
sys/dev/xen/blkfront/blkfront.c:
sys/dev/xen/blkfront/block.h:
sys/dev/xen/control/control.c:
sys/dev/xen/evtchn/evtchn_dev.c:
sys/dev/xen/netback/netback.c:
sys/dev/xen/netfront/netfront.c:
sys/xen/xenstore/xenstore.c:
sys/xen/evtchn/evtchn_dev.c:
sys/dev/xen/console/console.c:
sys/dev/xen/console/xencons_ring.c
Adjust drivers to use new xen_intr_*() API.
sys/dev/xen/blkback/blkback.c:
Since blkback defers all event handling to a taskqueue,
convert this task queue to a "fast" taskqueue, and schedule
it via an interrupt filter. This avoids an unnecessary
ithread context switch.
sys/xen/xenstore/xenstore.c:
The xenstore driver is MPSAFE. Indicate as much when
registering its interrupt handler.
sys/xen/xenbus/xenbus.c:
sys/xen/xenbus/xenbusvar.h:
Remove unused event channel APIs.
sys/xen/evtchn.h:
Remove all kernel Xen interrupt service API definitions
from this file. It is now only used for structure and
ioctl definitions related to the event channel userland
device driver.
Update the definitions in this file to match those from
NetBSD. Implementing this interface will be necessary for
Dom0 support.
sys/xen/evtchn/evtchnvar.h:
Add a header file for implemenation internal APIs related
to managing event channels event delivery. This is used
to allow, for example, the event channel userland device
driver to access low-level routines that typical kernel
consumers of event channel services should never access.
sys/xen/interface/event_channel.h:
sys/xen/xen_intr.h:
Standardize on the evtchn_port_t type for referring to
an event channel port id. In order to prevent low-level
event channel APIs from leaking to kernel consumers who
should not have access to this data, the type is defined
twice: Once in the Xen provided event_channel.h, and again
in xen/xen_intr.h. The double declaration is protected by
__XEN_EVTCHN_PORT_DEFINED__ to ensure it is never declared
twice within a given compilation unit.
sys/xen/xen_intr.h:
sys/xen/evtchn/evtchn.c:
sys/x86/xen/xen_intr.c:
sys/dev/xen/xenpci/evtchn.c:
sys/dev/xen/xenpci/xenpcivar.h:
New implementation of Xen interrupt services. This is
similar in many respects to the i386 PV implementation with
the exception that events for bound to event channel ports
(i.e. not IPI, virtual IRQ, or physical IRQ) are further
optimized to avoid mask/unmask operations that aren't
necessary for these edge triggered events.
Stubs exist for supporting physical IRQ binding, but will
need additional work before this implementation can be
fully shared between PV and HVM.
sys/amd64/amd64/mp_machdep.c:
sys/i386/i386/mp_machdep.c:
sys/i386/xen/mp_machdep.c
sys/x86/xen/hvm.c:
Add support for placing vcpu_info into an arbritary memory
page instead of using HYPERVISOR_shared_info->vcpu_info.
This allows the creation of domains with more than 32 vcpus.
sys/i386/i386/machdep.c:
sys/i386/xen/clock.c:
sys/i386/xen/xen_machdep.c:
sys/i386/xen/exception.s:
Add support for new event channle implementation.
2013-08-29 19:52:18 +00:00
|
|
|
* IRQ values from 256 to 767 are used by MSI. When running under the Xen
|
|
|
|
* Hypervisor, IRQ values from 768 to 4863 are available for binding to
|
|
|
|
* event channel events. We leave 255 unused to avoid confusion since 255 is
|
|
|
|
* used in PCI to indicate an invalid IRQ.
|
2005-11-02 20:11:47 +00:00
|
|
|
*/
|
2009-01-29 09:22:56 +00:00
|
|
|
#define NUM_MSI_INTS 512
|
2006-11-13 22:23:34 +00:00
|
|
|
#define FIRST_MSI_INT 256
|
Implement vector callback for PVHVM and unify event channel implementations
Re-structure Xen HVM support so that:
- Xen is detected and hypercalls can be performed very
early in system startup.
- Xen interrupt services are implemented using FreeBSD's native
interrupt delivery infrastructure.
- the Xen interrupt service implementation is shared between PV
and HVM guests.
- Xen interrupt handlers can optionally use a filter handler
in order to avoid the overhead of dispatch to an interrupt
thread.
- interrupt load can be distributed among all available CPUs.
- the overhead of accessing the emulated local and I/O apics
on HVM is removed for event channel port events.
- a similar optimization can eventually, and fairly easily,
be used to optimize MSI.
Early Xen detection, HVM refactoring, PVHVM interrupt infrastructure,
and misc Xen cleanups:
Sponsored by: Spectra Logic Corporation
Unification of PV & HVM interrupt infrastructure, bug fixes,
and misc Xen cleanups:
Submitted by: Roger Pau Monné
Sponsored by: Citrix Systems R&D
sys/x86/x86/local_apic.c:
sys/amd64/include/apicvar.h:
sys/i386/include/apicvar.h:
sys/amd64/amd64/apic_vector.S:
sys/i386/i386/apic_vector.s:
sys/amd64/amd64/machdep.c:
sys/i386/i386/machdep.c:
sys/i386/xen/exception.s:
sys/x86/include/segments.h:
Reserve IDT vector 0x93 for the Xen event channel upcall
interrupt handler. On Hypervisors that support the direct
vector callback feature, we can request that this vector be
called directly by an injected HVM interrupt event, instead
of a simulated PCI interrupt on the Xen platform PCI device.
This avoids all of the overhead of dealing with the emulated
I/O APIC and local APIC. It also means that the Hypervisor
can inject these events on any CPU, allowing upcalls for
different ports to be handled in parallel.
sys/amd64/amd64/mp_machdep.c:
sys/i386/i386/mp_machdep.c:
Map Xen per-vcpu area during AP startup.
sys/amd64/include/intr_machdep.h:
sys/i386/include/intr_machdep.h:
Increase the FreeBSD IRQ vector table to include space
for event channel interrupt sources.
sys/amd64/include/pcpu.h:
sys/i386/include/pcpu.h:
Remove Xen HVM per-cpu variable data. These fields are now
allocated via the dynamic per-cpu scheme. See xen_intr.c
for details.
sys/amd64/include/xen/hypercall.h:
sys/dev/xen/blkback/blkback.c:
sys/i386/include/xen/xenvar.h:
sys/i386/xen/clock.c:
sys/i386/xen/xen_machdep.c:
sys/xen/gnttab.c:
Prefer FreeBSD primatives to Linux ones in Xen support code.
sys/amd64/include/xen/xen-os.h:
sys/i386/include/xen/xen-os.h:
sys/xen/xen-os.h:
sys/dev/xen/balloon/balloon.c:
sys/dev/xen/blkback/blkback.c:
sys/dev/xen/blkfront/blkfront.c:
sys/dev/xen/console/xencons_ring.c:
sys/dev/xen/control/control.c:
sys/dev/xen/netback/netback.c:
sys/dev/xen/netfront/netfront.c:
sys/dev/xen/xenpci/xenpci.c:
sys/i386/i386/machdep.c:
sys/i386/include/pmap.h:
sys/i386/include/xen/xenfunc.h:
sys/i386/isa/npx.c:
sys/i386/xen/clock.c:
sys/i386/xen/mp_machdep.c:
sys/i386/xen/mptable.c:
sys/i386/xen/xen_clock_util.c:
sys/i386/xen/xen_machdep.c:
sys/i386/xen/xen_rtc.c:
sys/xen/evtchn/evtchn_dev.c:
sys/xen/features.c:
sys/xen/gnttab.c:
sys/xen/gnttab.h:
sys/xen/hvm.h:
sys/xen/xenbus/xenbus.c:
sys/xen/xenbus/xenbus_if.m:
sys/xen/xenbus/xenbusb_front.c:
sys/xen/xenbus/xenbusvar.h:
sys/xen/xenstore/xenstore.c:
sys/xen/xenstore/xenstore_dev.c:
sys/xen/xenstore/xenstorevar.h:
Pull common Xen OS support functions/settings into xen/xen-os.h.
sys/amd64/include/xen/xen-os.h:
sys/i386/include/xen/xen-os.h:
sys/xen/xen-os.h:
Remove constants, macros, and functions unused in FreeBSD's Xen
support.
sys/xen/xen-os.h:
sys/i386/xen/xen_machdep.c:
sys/x86/xen/hvm.c:
Introduce new functions xen_domain(), xen_pv_domain(), and
xen_hvm_domain(). These are used in favor of #ifdefs so that
FreeBSD can dynamically detect and adapt to the presence of
a hypervisor. The goal is to have an HVM optimized GENERIC,
but more is necessary before this is possible.
sys/amd64/amd64/machdep.c:
sys/dev/xen/xenpci/xenpcivar.h:
sys/dev/xen/xenpci/xenpci.c:
sys/x86/xen/hvm.c:
sys/sys/kernel.h:
Refactor magic ioport, Hypercall table and Hypervisor shared
information page setup, and move it to a dedicated HVM support
module.
HVM mode initialization is now triggered during the
SI_SUB_HYPERVISOR phase of system startup. This currently
occurs just after the kernel VM is fully setup which is
just enough infrastructure to allow the hypercall table
and shared info page to be properly mapped.
sys/xen/hvm.h:
sys/x86/xen/hvm.c:
Add definitions and a method for configuring Hypervisor event
delievery via a direct vector callback.
sys/amd64/include/xen/xen-os.h:
sys/x86/xen/hvm.c:
sys/conf/files:
sys/conf/files.amd64:
sys/conf/files.i386:
Adjust kernel build to reflect the refactoring of early
Xen startup code and Xen interrupt services.
sys/dev/xen/blkback/blkback.c:
sys/dev/xen/blkfront/blkfront.c:
sys/dev/xen/blkfront/block.h:
sys/dev/xen/control/control.c:
sys/dev/xen/evtchn/evtchn_dev.c:
sys/dev/xen/netback/netback.c:
sys/dev/xen/netfront/netfront.c:
sys/xen/xenstore/xenstore.c:
sys/xen/evtchn/evtchn_dev.c:
sys/dev/xen/console/console.c:
sys/dev/xen/console/xencons_ring.c
Adjust drivers to use new xen_intr_*() API.
sys/dev/xen/blkback/blkback.c:
Since blkback defers all event handling to a taskqueue,
convert this task queue to a "fast" taskqueue, and schedule
it via an interrupt filter. This avoids an unnecessary
ithread context switch.
sys/xen/xenstore/xenstore.c:
The xenstore driver is MPSAFE. Indicate as much when
registering its interrupt handler.
sys/xen/xenbus/xenbus.c:
sys/xen/xenbus/xenbusvar.h:
Remove unused event channel APIs.
sys/xen/evtchn.h:
Remove all kernel Xen interrupt service API definitions
from this file. It is now only used for structure and
ioctl definitions related to the event channel userland
device driver.
Update the definitions in this file to match those from
NetBSD. Implementing this interface will be necessary for
Dom0 support.
sys/xen/evtchn/evtchnvar.h:
Add a header file for implemenation internal APIs related
to managing event channels event delivery. This is used
to allow, for example, the event channel userland device
driver to access low-level routines that typical kernel
consumers of event channel services should never access.
sys/xen/interface/event_channel.h:
sys/xen/xen_intr.h:
Standardize on the evtchn_port_t type for referring to
an event channel port id. In order to prevent low-level
event channel APIs from leaking to kernel consumers who
should not have access to this data, the type is defined
twice: Once in the Xen provided event_channel.h, and again
in xen/xen_intr.h. The double declaration is protected by
__XEN_EVTCHN_PORT_DEFINED__ to ensure it is never declared
twice within a given compilation unit.
sys/xen/xen_intr.h:
sys/xen/evtchn/evtchn.c:
sys/x86/xen/xen_intr.c:
sys/dev/xen/xenpci/evtchn.c:
sys/dev/xen/xenpci/xenpcivar.h:
New implementation of Xen interrupt services. This is
similar in many respects to the i386 PV implementation with
the exception that events for bound to event channel ports
(i.e. not IPI, virtual IRQ, or physical IRQ) are further
optimized to avoid mask/unmask operations that aren't
necessary for these edge triggered events.
Stubs exist for supporting physical IRQ binding, but will
need additional work before this implementation can be
fully shared between PV and HVM.
sys/amd64/amd64/mp_machdep.c:
sys/i386/i386/mp_machdep.c:
sys/i386/xen/mp_machdep.c
sys/x86/xen/hvm.c:
Add support for placing vcpu_info into an arbritary memory
page instead of using HYPERVISOR_shared_info->vcpu_info.
This allows the creation of domains with more than 32 vcpus.
sys/i386/i386/machdep.c:
sys/i386/xen/clock.c:
sys/i386/xen/xen_machdep.c:
sys/i386/xen/exception.s:
Add support for new event channle implementation.
2013-08-29 19:52:18 +00:00
|
|
|
#ifdef XENHVM
|
|
|
|
#include <xen/xen-os.h>
|
|
|
|
#define NUM_EVTCHN_INTS NR_EVENT_CHANNELS
|
|
|
|
#define FIRST_EVTCHN_INT \
|
|
|
|
(FIRST_MSI_INT + NUM_MSI_INTS)
|
|
|
|
#define LAST_EVTCHN_INT \
|
|
|
|
(FIRST_EVTCHN_INT + NUM_EVTCHN_INTS - 1)
|
|
|
|
#elif defined(XEN)
|
|
|
|
#include <xen/xen-os.h>
|
|
|
|
#define NUM_EVTCHN_INTS NR_EVENT_CHANNELS
|
|
|
|
#define FIRST_EVTCHN_INT 0
|
|
|
|
#define LAST_EVTCHN_INT \
|
|
|
|
(FIRST_EVTCHN_INT + NUM_EVTCHN_INTS - 1)
|
|
|
|
#else /* !XEN && !XENHVM */
|
|
|
|
#define NUM_EVTCHN_INTS 0
|
|
|
|
#endif
|
|
|
|
#define NUM_IO_INTS (FIRST_MSI_INT + NUM_MSI_INTS + NUM_EVTCHN_INTS)
|
2006-11-13 22:23:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default base address for MSI messages on x86 platforms.
|
|
|
|
*/
|
|
|
|
#define MSI_INTEL_ADDR_BASE 0xfee00000
|
2005-11-02 20:11:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* - 1 ??? dummy counter.
|
|
|
|
* - 2 counters for each I/O interrupt.
|
|
|
|
* - 1 counter for each CPU for lapic timer.
|
2012-04-13 07:15:40 +00:00
|
|
|
* - 9 counters for each CPU for IPI counters for SMP.
|
2005-11-02 20:11:47 +00:00
|
|
|
*/
|
|
|
|
#ifdef SMP
|
2012-04-13 07:15:40 +00:00
|
|
|
#define INTRCNT_COUNT (1 + NUM_IO_INTS * 2 + (1 + 9) * MAXCPU)
|
2006-10-10 19:26:35 +00:00
|
|
|
#else
|
|
|
|
#define INTRCNT_COUNT (1 + NUM_IO_INTS * 2 + 1)
|
2005-11-02 20:11:47 +00:00
|
|
|
#endif
|
2003-11-03 21:25:52 +00:00
|
|
|
|
|
|
|
#ifndef LOCORE
|
|
|
|
|
|
|
|
typedef void inthand_t(u_int cs, u_int ef, u_int esp, u_int ss);
|
|
|
|
|
|
|
|
#define IDTVEC(name) __CONCAT(X,name)
|
|
|
|
|
|
|
|
struct intsrc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Methods that a PIC provides to mask/unmask a given interrupt source,
|
|
|
|
* "turn on" the interrupt on the CPU side by setting up an IDT entry, and
|
|
|
|
* return the vector associated with this source.
|
|
|
|
*/
|
|
|
|
struct pic {
|
|
|
|
void (*pic_enable_source)(struct intsrc *);
|
2004-08-02 15:31:10 +00:00
|
|
|
void (*pic_disable_source)(struct intsrc *, int);
|
2003-11-03 21:25:52 +00:00
|
|
|
void (*pic_eoi_source)(struct intsrc *);
|
|
|
|
void (*pic_enable_intr)(struct intsrc *);
|
2007-05-08 21:29:14 +00:00
|
|
|
void (*pic_disable_intr)(struct intsrc *);
|
2003-11-03 21:25:52 +00:00
|
|
|
int (*pic_vector)(struct intsrc *);
|
|
|
|
int (*pic_source_pending)(struct intsrc *);
|
2006-10-10 23:23:12 +00:00
|
|
|
void (*pic_suspend)(struct pic *);
|
2013-09-20 05:06:03 +00:00
|
|
|
void (*pic_resume)(struct pic *, bool suspend_cancelled);
|
2004-05-04 21:02:56 +00:00
|
|
|
int (*pic_config_intr)(struct intsrc *, enum intr_trigger,
|
|
|
|
enum intr_polarity);
|
2009-07-01 17:20:07 +00:00
|
|
|
int (*pic_assign_cpu)(struct intsrc *, u_int apic_id);
|
2013-02-02 12:02:42 +00:00
|
|
|
TAILQ_ENTRY(pic) pics;
|
2003-11-03 21:25:52 +00:00
|
|
|
};
|
|
|
|
|
2004-08-02 15:31:10 +00:00
|
|
|
/* Flags for pic_disable_source() */
|
|
|
|
enum {
|
|
|
|
PIC_EOI,
|
|
|
|
PIC_NO_EOI,
|
|
|
|
};
|
|
|
|
|
2003-11-03 21:25:52 +00:00
|
|
|
/*
|
|
|
|
* An interrupt source. The upper-layer code uses the PIC methods to
|
|
|
|
* control a given source. The lower-layer PIC drivers can store additional
|
|
|
|
* private data in a given interrupt source such as an interrupt pin number
|
|
|
|
* or an I/O APIC pointer.
|
|
|
|
*/
|
|
|
|
struct intsrc {
|
|
|
|
struct pic *is_pic;
|
Reorganize the interrupt handling code a bit to make a few things cleaner
and increase flexibility to allow various different approaches to be tried
in the future.
- Split struct ithd up into two pieces. struct intr_event holds the list
of interrupt handlers associated with interrupt sources.
struct intr_thread contains the data relative to an interrupt thread.
Currently we still provide a 1:1 relationship of events to threads
with the exception that events only have an associated thread if there
is at least one threaded interrupt handler attached to the event. This
means that on x86 we no longer have 4 bazillion interrupt threads with
no handlers. It also means that interrupt events with only INTR_FAST
handlers no longer have an associated thread either.
- Renamed struct intrhand to struct intr_handler to follow the struct
intr_foo naming convention. This did require renaming the powerpc
MD struct intr_handler to struct ppc_intr_handler.
- INTR_FAST no longer implies INTR_EXCL on all architectures except for
powerpc. This means that multiple INTR_FAST handlers can attach to the
same interrupt and that INTR_FAST and non-INTR_FAST handlers can attach
to the same interrupt. Sharing INTR_FAST handlers may not always be
desirable, but having sio(4) and uhci(4) fight over an IRQ isn't fun
either. Drivers can always still use INTR_EXCL to ask for an interrupt
exclusively. The way this sharing works is that when an interrupt
comes in, all the INTR_FAST handlers are executed first, and if any
threaded handlers exist, the interrupt thread is scheduled afterwards.
This type of layout also makes it possible to investigate using interrupt
filters ala OS X where the filter determines whether or not its companion
threaded handler should run.
- Aside from the INTR_FAST changes above, the impact on MD interrupt code
is mostly just 's/ithread/intr_event/'.
- A new MI ddb command 'show intrs' walks the list of interrupt events
dumping their state. It also has a '/v' verbose switch which dumps
info about all of the handlers attached to each event.
- We currently don't destroy an interrupt thread when the last threaded
handler is removed because it would suck for things like ppbus(8)'s
braindead behavior. The code is present, though, it is just under
#if 0 for now.
- Move the code to actually execute the threaded handlers for an interrrupt
event into a separate function so that ithread_loop() becomes more
readable. Previously this code was all in the middle of ithread_loop()
and indented halfway across the screen.
- Made struct intr_thread private to kern_intr.c and replaced td_ithd
with a thread private flag TDP_ITHREAD.
- In statclock, check curthread against idlethread directly rather than
curthread's proc against idlethread's proc. (Not really related to intr
changes)
Tested on: alpha, amd64, i386, sparc64
Tested on: arm, ia64 (older version of patch by cognet and marcel)
2005-10-25 19:48:48 +00:00
|
|
|
struct intr_event *is_event;
|
2003-11-03 21:25:52 +00:00
|
|
|
u_long *is_count;
|
|
|
|
u_long *is_straycount;
|
|
|
|
u_int is_index;
|
2007-05-08 21:29:14 +00:00
|
|
|
u_int is_handlers;
|
2003-11-03 21:25:52 +00:00
|
|
|
};
|
|
|
|
|
2005-12-05 22:39:09 +00:00
|
|
|
struct trapframe;
|
2003-11-03 21:25:52 +00:00
|
|
|
|
|
|
|
extern struct mtx icu_lock;
|
2005-01-18 20:24:47 +00:00
|
|
|
extern int elcr_found;
|
2003-11-03 21:25:52 +00:00
|
|
|
|
2012-03-09 19:42:48 +00:00
|
|
|
#ifndef DEV_ATPIC
|
|
|
|
void atpic_reset(void);
|
|
|
|
#endif
|
2004-05-04 20:07:46 +00:00
|
|
|
/* XXX: The elcr_* prototypes probably belong somewhere else. */
|
|
|
|
int elcr_probe(void);
|
|
|
|
enum intr_trigger elcr_read_trigger(u_int irq);
|
|
|
|
void elcr_resume(void);
|
|
|
|
void elcr_write_trigger(u_int irq, enum intr_trigger trigger);
|
2012-10-09 12:22:43 +00:00
|
|
|
#ifdef SMP
|
2007-03-06 17:16:47 +00:00
|
|
|
void intr_add_cpu(u_int cpu);
|
2012-10-09 12:22:43 +00:00
|
|
|
#endif
|
2007-02-23 12:19:07 +00:00
|
|
|
int intr_add_handler(const char *name, int vector, driver_filter_t filter,
|
|
|
|
driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep);
|
2012-05-03 21:44:01 +00:00
|
|
|
#ifdef SMP
|
2008-03-14 19:41:48 +00:00
|
|
|
int intr_bind(u_int vector, u_char cpu);
|
2012-05-03 21:44:01 +00:00
|
|
|
#endif
|
2004-05-04 21:02:56 +00:00
|
|
|
int intr_config_intr(int vector, enum intr_trigger trig,
|
|
|
|
enum intr_polarity pol);
|
2009-10-15 14:54:35 +00:00
|
|
|
int intr_describe(u_int vector, void *ih, const char *descr);
|
2005-12-05 22:39:09 +00:00
|
|
|
void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
|
2009-06-25 18:13:46 +00:00
|
|
|
u_int intr_next_cpu(void);
|
2003-11-03 21:25:52 +00:00
|
|
|
struct intsrc *intr_lookup_source(int vector);
|
2006-10-10 23:23:12 +00:00
|
|
|
int intr_register_pic(struct pic *pic);
|
2003-11-03 21:25:52 +00:00
|
|
|
int intr_register_source(struct intsrc *isrc);
|
|
|
|
int intr_remove_handler(void *cookie);
|
2013-09-20 05:06:03 +00:00
|
|
|
void intr_resume(bool suspend_cancelled);
|
2003-11-03 21:25:52 +00:00
|
|
|
void intr_suspend(void);
|
2004-12-23 20:34:18 +00:00
|
|
|
void intrcnt_add(const char *name, u_long **countp);
|
2007-05-08 21:29:14 +00:00
|
|
|
void nexus_add_irq(u_long irq);
|
|
|
|
int msi_alloc(device_t dev, int count, int maxcount, int *irqs);
|
2006-12-12 19:24:45 +00:00
|
|
|
void msi_init(void);
|
2007-05-02 17:50:36 +00:00
|
|
|
int msi_map(int irq, uint64_t *addr, uint32_t *data);
|
2006-11-13 22:23:34 +00:00
|
|
|
int msi_release(int* irqs, int count);
|
2007-05-08 21:29:14 +00:00
|
|
|
int msix_alloc(device_t dev, int *irq);
|
2006-11-13 22:23:34 +00:00
|
|
|
int msix_release(int irq);
|
2003-11-03 21:25:52 +00:00
|
|
|
|
|
|
|
#endif /* !LOCORE */
|
|
|
|
#endif /* _KERNEL */
|
|
|
|
#endif /* !__MACHINE_INTR_MACHDEP_H__ */
|