2 * Copyright (c) 1989, 1990 William F. Jolitz.
3 * Copyright (c) 1990 The Regents of the University of California.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 4. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * from: vector.s, 386BSD 0.1 unknown origin
35 * Interrupt entry points for external interrupts triggered by I/O APICs
36 * as well as IPI handlers.
39 #include <machine/asmacros.h>
40 #include <machine/apicreg.h>
45 * I/O Interrupt Entry Point. Rather than having one entry point for
46 * each interrupt source, we use one entry point for each 32-bit word
47 * in the ISR. The handler determines the highest bit set in the ISR,
48 * translates that into a vector, and passes the vector to the
49 * lapic_handle_intr() function.
51 #define ISR_VEC(index, vec_name) \
56 FAKE_MCOUNT(TF_RIP(%rsp)) ; \
57 movq lapic, %rdx ; /* pointer to local APIC */ \
58 movl LA_ISR + 16 * (index)(%rdx), %eax ; /* load ISR */ \
59 bsrl %eax, %eax ; /* index of highset set bit in ISR */ \
61 addl $(32 * index),%eax ; \
63 movl %eax, %edi ; /* pass the IRQ */ \
64 call lapic_handle_intr ; \
67 2: movl $-1, %eax ; /* send a vector of -1 */ \
71 * Handle "spurious INTerrupts".
73 * This is different than the "spurious INTerrupt" generated by an
74 * 8259 PIC for missing INTs. See the APIC documentation for details.
75 * This routine should NOT do an 'EOI' cycle.
81 /* No EOI cycle used here */
94 * Local APIC periodic timer handler.
100 FAKE_MCOUNT(TF_RIP(%rsp))
102 call lapic_handle_timer
108 * Global address space TLB shootdown.
115 movq %cr3, %rax /* invalidate the TLB */
119 movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */
128 * Single page TLB shootdown
135 movq smp_tlb_addr1, %rax
136 invlpg (%rax) /* invalidate single page */
139 movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */
148 * Page range TLB shootdown.
156 movq smp_tlb_addr1, %rdx
157 movq smp_tlb_addr2, %rax
158 1: invlpg (%rdx) /* invalidate single page */
159 addq $PAGE_SIZE, %rdx
164 movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */
174 * Handler for IPIs sent via the per-cpu IPI bitmap.
178 IDTVEC(ipi_intr_bitmap_handler)
182 movl $0, LA_EOI(%rdx) /* End Of Interrupt to APIC */
184 FAKE_MCOUNT(TF_RIP(%rsp))
186 call ipi_bitmap_handler
191 * Executed by a CPU when it receives an Xcpustop IPI from another CPU,
193 * - Signals its receipt.
194 * - Waits for permission to restart.
195 * - Signals its restart.
203 movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */
211 * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
213 * - Calls the generic rendezvous action function.
219 call smp_rendezvous_action
221 movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */
222 POP_FRAME /* Why not doreti? */