]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/amd64/amd64/apic_vector.S
Make PV entries dynamic on amd64. i386 has a pre-reserved block of kva
[FreeBSD/FreeBSD.git] / sys / amd64 / amd64 / 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  * 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.
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  * $FreeBSD$
32  */
33
34 /*
35  * Interrupt entry points for external interrupts triggered by I/O APICs
36  * as well as IPI handlers.
37  */
38
39 #include <machine/asmacros.h>
40 #include <machine/apicreg.h>
41
42 #include "assym.s"
43
44 /*
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.
50  */
51 #define ISR_VEC(index, vec_name)                                        \
52         .text ;                                                         \
53         SUPERALIGN_TEXT ;                                               \
54 IDTVEC(vec_name) ;                                                      \
55         PUSH_FRAME ;                                                    \
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 */   \
60         jz      2f ;                                                    \
61         addl    $(32 * index),%eax ;                                    \
62 1: ;                                                                    \
63         movl    %eax, %edi ;    /* pass the IRQ */                      \
64         call    lapic_handle_intr ;                                     \
65         MEXITCOUNT ;                                                    \
66         jmp     doreti ;                                                \
67 2:      movl    $-1, %eax ;     /* send a vector of -1 */               \
68         jmp     1b
69
70 /*
71  * Handle "spurious INTerrupts".
72  * Notes:
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.
76  */
77         .text
78         SUPERALIGN_TEXT
79 IDTVEC(spuriousint)
80
81         /* No EOI cycle used here */
82
83         iretq
84
85         ISR_VEC(1, apic_isr1)
86         ISR_VEC(2, apic_isr2)
87         ISR_VEC(3, apic_isr3)
88         ISR_VEC(4, apic_isr4)
89         ISR_VEC(5, apic_isr5)
90         ISR_VEC(6, apic_isr6)
91         ISR_VEC(7, apic_isr7)
92
93 /*
94  * Local APIC periodic timer handler.
95  */
96         .text
97         SUPERALIGN_TEXT
98 IDTVEC(timerint)
99         PUSH_FRAME
100         FAKE_MCOUNT(TF_RIP(%rsp))
101
102         call    lapic_handle_timer
103         MEXITCOUNT
104         jmp     doreti
105
106 #ifdef SMP
107 /*
108  * Global address space TLB shootdown.
109  */
110         .text
111         SUPERALIGN_TEXT
112 IDTVEC(invltlb)
113         pushq   %rax
114
115         movq    %cr3, %rax              /* invalidate the TLB */
116         movq    %rax, %cr3
117
118         movq    lapic, %rax
119         movl    $0, LA_EOI(%rax)        /* End Of Interrupt to APIC */
120
121         lock
122         incl    smp_tlb_wait
123
124         popq    %rax
125         iretq
126
127 /*
128  * Single page TLB shootdown
129  */
130         .text
131         SUPERALIGN_TEXT
132 IDTVEC(invlpg)
133         pushq   %rax
134
135         movq    smp_tlb_addr1, %rax
136         invlpg  (%rax)                  /* invalidate single page */
137
138         movq    lapic, %rax
139         movl    $0, LA_EOI(%rax)        /* End Of Interrupt to APIC */
140
141         lock
142         incl    smp_tlb_wait
143
144         popq    %rax
145         iretq
146
147 /*
148  * Page range TLB shootdown.
149  */
150         .text
151         SUPERALIGN_TEXT
152 IDTVEC(invlrng)
153         pushq   %rax
154         pushq   %rdx
155
156         movq    smp_tlb_addr1, %rdx
157         movq    smp_tlb_addr2, %rax
158 1:      invlpg  (%rdx)                  /* invalidate single page */
159         addq    $PAGE_SIZE, %rdx
160         cmpq    %rax, %rdx
161         jb      1b
162
163         movq    lapic, %rax
164         movl    $0, LA_EOI(%rax)        /* End Of Interrupt to APIC */
165
166         lock
167         incl    smp_tlb_wait
168
169         popq    %rdx
170         popq    %rax
171         iretq
172
173 /*
174  * Handler for IPIs sent via the per-cpu IPI bitmap.
175  */
176         .text
177         SUPERALIGN_TEXT
178 IDTVEC(ipi_intr_bitmap_handler)         
179         PUSH_FRAME
180
181         movq    lapic, %rdx
182         movl    $0, LA_EOI(%rdx)        /* End Of Interrupt to APIC */
183         
184         FAKE_MCOUNT(TF_RIP(%rsp))
185
186         call    ipi_bitmap_handler
187         MEXITCOUNT
188         jmp     doreti
189
190 /*
191  * Executed by a CPU when it receives an Xcpustop IPI from another CPU,
192  *
193  *  - Signals its receipt.
194  *  - Waits for permission to restart.
195  *  - Signals its restart.
196  */
197         .text
198         SUPERALIGN_TEXT
199 IDTVEC(cpustop)
200         PUSH_FRAME
201
202         movq    lapic, %rax
203         movl    $0, LA_EOI(%rax)        /* End Of Interrupt to APIC */
204
205         call    cpustop_handler
206
207         POP_FRAME
208         iretq
209
210 /*
211  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
212  *
213  * - Calls the generic rendezvous action function.
214  */
215         .text
216         SUPERALIGN_TEXT
217 IDTVEC(rendezvous)
218         PUSH_FRAME
219         call    smp_rendezvous_action
220         movq    lapic, %rax
221         movl    $0, LA_EOI(%rax)        /* End Of Interrupt to APIC */
222         POP_FRAME                       /* Why not doreti? */
223         iretq
224 #endif /* SMP */