]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i386/i386/apic_vector.s
sys: Remove $FreeBSD$: one-line .c comment pattern
[FreeBSD/FreeBSD.git] / sys / i386 / i386 / apic_vector.s
1 /*-
2  * Copyright (c) 1989, 1990 William F. Jolitz.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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  * 3. 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.
17  *
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
28  * SUCH DAMAGE.
29  *
30  *      from: vector.s, 386BSD 0.1 unknown origin
31  */
32
33 /*
34  * Interrupt entry points for external interrupts triggered by I/O APICs
35  * as well as IPI handlers.
36  */
37
38 #include "opt_smp.h"
39
40 #include <machine/asmacros.h>
41 #include <machine/psl.h>
42 #include <machine/specialreg.h>
43 #include <x86/apicreg.h>
44
45 #include "assym.inc"
46
47         .text
48         SUPERALIGN_TEXT
49         /* End Of Interrupt to APIC */
50 as_lapic_eoi:
51         cmpl    $0,x2apic_mode
52         jne     1f
53         movl    lapic_map,%eax
54         movl    $0,LA_EOI(%eax)
55         ret
56 1:
57         movl    $MSR_APIC_EOI,%ecx
58         xorl    %eax,%eax
59         xorl    %edx,%edx
60         wrmsr
61         ret
62
63 /*
64  * I/O Interrupt Entry Point.  Rather than having one entry point for
65  * each interrupt source, we use one entry point for each 32-bit word
66  * in the ISR.  The handler determines the highest bit set in the ISR,
67  * translates that into a vector, and passes the vector to the
68  * lapic_handle_intr() function.
69  */
70         .macro  ISR_VEC index, vec_name
71         .text
72         SUPERALIGN_TEXT
73         .globl  X\()\vec_name\()_pti, X\()\vec_name
74
75 X\()\vec_name\()_pti:
76 X\()\vec_name:
77         PUSH_FRAME
78         SET_KERNEL_SREGS
79         cld
80         KENTER
81         FAKE_MCOUNT(TF_EIP(%esp))
82         cmpl    $0,x2apic_mode
83         je      2f
84         movl    $(MSR_APIC_ISR0 + \index),%ecx
85         rdmsr
86         jmp     3f
87 2:
88         movl    lapic_map, %edx         /* pointer to local APIC */
89         movl    LA_ISR + 16 * \index(%edx), %eax        /* load ISR */
90 3:
91         bsrl    %eax, %eax      /* index of highest set bit in ISR */
92         jz      4f
93         addl    $(32 * \index),%eax
94         pushl   %esp
95         pushl   %eax            /* pass the IRQ */
96         movl    $lapic_handle_intr, %eax
97         call    *%eax
98         addl    $8, %esp        /* discard parameter */
99 4:
100         MEXITCOUNT
101         jmp     doreti
102         .endm
103
104 /*
105  * Handle "spurious INTerrupts".
106  * Notes:
107  *  This is different than the "spurious INTerrupt" generated by an
108  *   8259 PIC for missing INTs.  See the APIC documentation for details.
109  *  This routine should NOT do an 'EOI' cycle.
110  */
111         .text
112         SUPERALIGN_TEXT
113 IDTVEC(spuriousint)
114
115         /* No EOI cycle used here */
116
117         iret
118
119         ISR_VEC 1, apic_isr1
120         ISR_VEC 2, apic_isr2
121         ISR_VEC 3, apic_isr3
122         ISR_VEC 4, apic_isr4
123         ISR_VEC 5, apic_isr5
124         ISR_VEC 6, apic_isr6
125         ISR_VEC 7, apic_isr7
126
127 /*
128  * Local APIC periodic timer handler.
129  */
130         .text
131         SUPERALIGN_TEXT
132 IDTVEC(timerint_pti)
133 IDTVEC(timerint)
134         PUSH_FRAME
135         SET_KERNEL_SREGS
136         cld
137         KENTER
138         FAKE_MCOUNT(TF_EIP(%esp))
139         pushl   %esp
140         movl    $lapic_handle_timer, %eax
141         call    *%eax
142         add     $4, %esp
143         MEXITCOUNT
144         jmp     doreti
145
146 /*
147  * Local APIC CMCI handler.
148  */
149         .text
150         SUPERALIGN_TEXT
151 IDTVEC(cmcint_pti)
152 IDTVEC(cmcint)
153         PUSH_FRAME
154         SET_KERNEL_SREGS
155         cld
156         KENTER
157         FAKE_MCOUNT(TF_EIP(%esp))
158         movl    $lapic_handle_cmc, %eax
159         call    *%eax
160         MEXITCOUNT
161         jmp     doreti
162
163 /*
164  * Local APIC error interrupt handler.
165  */
166         .text
167         SUPERALIGN_TEXT
168 IDTVEC(errorint_pti)
169 IDTVEC(errorint)
170         PUSH_FRAME
171         SET_KERNEL_SREGS
172         cld
173         KENTER
174         FAKE_MCOUNT(TF_EIP(%esp))
175         movl    $lapic_handle_error, %eax
176         call    *%eax
177         MEXITCOUNT
178         jmp     doreti
179
180 #ifdef XENHVM
181 /*
182  * Xen event channel upcall interrupt handler.
183  * Only used when the hypervisor supports direct vector callbacks.
184  */
185         .text
186         SUPERALIGN_TEXT
187 IDTVEC(xen_intr_upcall)
188         PUSH_FRAME
189         SET_KERNEL_SREGS
190         cld
191         KENTER
192         FAKE_MCOUNT(TF_EIP(%esp))
193         pushl   %esp
194         movl    $xen_intr_handle_upcall, %eax
195         call    *%eax
196         add     $4, %esp
197         MEXITCOUNT
198         jmp     doreti
199 #endif
200
201 #ifdef SMP
202 /*
203  * Global address space TLB shootdown.
204  */
205         .text
206         SUPERALIGN_TEXT
207 invltlb_ret:
208         call    as_lapic_eoi
209         jmp     doreti
210
211         SUPERALIGN_TEXT
212 IDTVEC(invltlb)
213         PUSH_FRAME
214         SET_KERNEL_SREGS
215         cld
216         KENTER
217         movl    $invltlb_handler, %eax
218         call    *%eax
219         jmp     invltlb_ret
220
221 /*
222  * Single page TLB shootdown
223  */
224         .text
225         SUPERALIGN_TEXT
226 IDTVEC(invlpg)
227         PUSH_FRAME
228         SET_KERNEL_SREGS
229         cld
230         KENTER
231         movl    $invlpg_handler, %eax
232         call    *%eax
233         jmp     invltlb_ret
234
235 /*
236  * Page range TLB shootdown.
237  */
238         .text
239         SUPERALIGN_TEXT
240 IDTVEC(invlrng)
241         PUSH_FRAME
242         SET_KERNEL_SREGS
243         cld
244         KENTER
245         movl    $invlrng_handler, %eax
246         call    *%eax
247         jmp     invltlb_ret
248
249 /*
250  * Invalidate cache.
251  */
252         .text
253         SUPERALIGN_TEXT
254 IDTVEC(invlcache)
255         PUSH_FRAME
256         SET_KERNEL_SREGS
257         cld
258         KENTER
259         movl    $invlcache_handler, %eax
260         call    *%eax
261         jmp     invltlb_ret
262
263 /*
264  * Handler for IPIs sent via the per-cpu IPI bitmap.
265  */
266         .text
267         SUPERALIGN_TEXT
268 IDTVEC(ipi_intr_bitmap_handler) 
269         PUSH_FRAME
270         SET_KERNEL_SREGS
271         cld
272         KENTER
273         call    as_lapic_eoi
274         FAKE_MCOUNT(TF_EIP(%esp))
275         movl    $ipi_bitmap_handler, %eax
276         call    *%eax
277         MEXITCOUNT
278         jmp     doreti
279
280 /*
281  * Executed by a CPU when it receives an IPI_STOP from another CPU.
282  */
283         .text
284         SUPERALIGN_TEXT
285 IDTVEC(cpustop)
286         PUSH_FRAME
287         SET_KERNEL_SREGS
288         cld
289         KENTER
290         call    as_lapic_eoi
291         movl    $cpustop_handler, %eax
292         call    *%eax
293         jmp     doreti
294
295 /*
296  * Executed by a CPU when it receives an IPI_SUSPEND from another CPU.
297  */
298         .text
299         SUPERALIGN_TEXT
300 IDTVEC(cpususpend)
301         PUSH_FRAME
302         SET_KERNEL_SREGS
303         cld
304         KENTER
305         call    as_lapic_eoi
306         movl    $cpususpend_handler, %eax
307         call    *%eax
308         jmp     doreti
309
310 /*
311  * Executed by a CPU when it receives an IPI_SWI.
312  */
313         .text
314         SUPERALIGN_TEXT
315 IDTVEC(ipi_swi)
316         PUSH_FRAME
317         SET_KERNEL_SREGS
318         cld
319         KENTER
320         call    as_lapic_eoi
321         FAKE_MCOUNT(TF_EIP(%esp))
322         movl    $ipi_swi_handler, %eax
323         call    *%eax
324         MEXITCOUNT
325         jmp     doreti
326
327 /*
328  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
329  *
330  * - Calls the generic rendezvous action function.
331  */
332         .text
333         SUPERALIGN_TEXT
334 IDTVEC(rendezvous)
335         PUSH_FRAME
336         SET_KERNEL_SREGS
337         cld
338         KENTER
339 #ifdef COUNT_IPIS
340         movl    PCPU(CPUID), %eax
341         movl    ipi_rendezvous_counts(,%eax,4), %eax
342         incl    (%eax)
343 #endif
344         movl    $smp_rendezvous_action, %eax
345         call    *%eax
346         call    as_lapic_eoi
347         jmp     doreti
348         
349 #endif /* SMP */