The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386/i386/apic_vector.s

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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: releng/11.1/sys/i386/i386/apic_vector.s 330908 2018-03-14 04:00:00Z gordon $
   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 "opt_smp.h"
   40 
   41 #include <machine/asmacros.h>
   42 #include <machine/specialreg.h>
   43 #include <x86/apicreg.h>
   44 
   45 #include "assym.s"
   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 #define ISR_VEC(index, vec_name)                                        \
   71         .text ;                                                         \
   72         SUPERALIGN_TEXT ;                                               \
   73 IDTVEC(vec_name ## _pti) ;                                              \
   74 IDTVEC(vec_name) ;                                                      \
   75         PUSH_FRAME ;                                                    \
   76         SET_KERNEL_SREGS ;                                              \
   77         cld ;                                                           \
   78         FAKE_MCOUNT(TF_EIP(%esp)) ;                                     \
   79         cmpl    $0,x2apic_mode ;                                        \
   80         je      1f ;                                                    \
   81         movl    $(MSR_APIC_ISR0 + index),%ecx ;                         \
   82         rdmsr ;                                                         \
   83         jmp     2f ;                                                    \
   84 1: ;                                                                    \
   85         movl    lapic_map, %edx ;/* pointer to local APIC */            \
   86         movl    LA_ISR + 16 * (index)(%edx), %eax ;     /* load ISR */  \
   87 2: ;                                                                    \
   88         bsrl    %eax, %eax ;    /* index of highest set bit in ISR */   \
   89         jz      3f ;                                                    \
   90         addl    $(32 * index),%eax ;                                    \
   91         pushl   %esp            ;                                       \
   92         pushl   %eax ;          /* pass the IRQ */                      \
   93         call    lapic_handle_intr ;                                     \
   94         addl    $8, %esp ;      /* discard parameter */                 \
   95 3: ;                                                                    \
   96         MEXITCOUNT ;                                                    \
   97         jmp     doreti
   98 
   99 /*
  100  * Handle "spurious INTerrupts".
  101  * Notes:
  102  *  This is different than the "spurious INTerrupt" generated by an
  103  *   8259 PIC for missing INTs.  See the APIC documentation for details.
  104  *  This routine should NOT do an 'EOI' cycle.
  105  */
  106         .text
  107         SUPERALIGN_TEXT
  108 IDTVEC(spuriousint)
  109 
  110         /* No EOI cycle used here */
  111 
  112         iret
  113 
  114         ISR_VEC(1, apic_isr1)
  115         ISR_VEC(2, apic_isr2)
  116         ISR_VEC(3, apic_isr3)
  117         ISR_VEC(4, apic_isr4)
  118         ISR_VEC(5, apic_isr5)
  119         ISR_VEC(6, apic_isr6)
  120         ISR_VEC(7, apic_isr7)
  121 
  122 /*
  123  * Local APIC periodic timer handler.
  124  */
  125         .text
  126         SUPERALIGN_TEXT
  127 IDTVEC(timerint_pti)
  128 IDTVEC(timerint)
  129         PUSH_FRAME
  130         SET_KERNEL_SREGS
  131         cld
  132         FAKE_MCOUNT(TF_EIP(%esp))
  133         pushl   %esp
  134         call    lapic_handle_timer
  135         add     $4, %esp
  136         MEXITCOUNT
  137         jmp     doreti
  138 
  139 /*
  140  * Local APIC CMCI handler.
  141  */
  142         .text
  143         SUPERALIGN_TEXT
  144 IDTVEC(cmcint_pti)
  145 IDTVEC(cmcint)
  146         PUSH_FRAME
  147         SET_KERNEL_SREGS
  148         cld
  149         FAKE_MCOUNT(TF_EIP(%esp))
  150         call    lapic_handle_cmc
  151         MEXITCOUNT
  152         jmp     doreti
  153 
  154 /*
  155  * Local APIC error interrupt handler.
  156  */
  157         .text
  158         SUPERALIGN_TEXT
  159 IDTVEC(errorint_pti)
  160 IDTVEC(errorint)
  161         PUSH_FRAME
  162         SET_KERNEL_SREGS
  163         cld
  164         FAKE_MCOUNT(TF_EIP(%esp))
  165         call    lapic_handle_error
  166         MEXITCOUNT
  167         jmp     doreti
  168 
  169 #ifdef XENHVM
  170 /*
  171  * Xen event channel upcall interrupt handler.
  172  * Only used when the hypervisor supports direct vector callbacks.
  173  */
  174         .text
  175         SUPERALIGN_TEXT
  176 IDTVEC(xen_intr_upcall)
  177         PUSH_FRAME
  178         SET_KERNEL_SREGS
  179         cld
  180         FAKE_MCOUNT(TF_EIP(%esp))
  181         pushl   %esp
  182         call    xen_intr_handle_upcall
  183         add     $4, %esp
  184         MEXITCOUNT
  185         jmp     doreti
  186 #endif
  187 
  188 #ifdef SMP
  189 /*
  190  * Global address space TLB shootdown.
  191  */
  192         .text
  193         SUPERALIGN_TEXT
  194 invltlb_ret:
  195         call    as_lapic_eoi
  196         POP_FRAME
  197         iret
  198 
  199         SUPERALIGN_TEXT
  200 IDTVEC(invltlb)
  201         PUSH_FRAME
  202         SET_KERNEL_SREGS
  203         cld
  204 
  205         call    invltlb_handler
  206 
  207         jmp     invltlb_ret
  208 
  209 /*
  210  * Single page TLB shootdown
  211  */
  212         .text
  213         SUPERALIGN_TEXT
  214 IDTVEC(invlpg)
  215         PUSH_FRAME
  216         SET_KERNEL_SREGS
  217         cld
  218 
  219         call    invlpg_handler
  220 
  221         jmp     invltlb_ret
  222 
  223 /*
  224  * Page range TLB shootdown.
  225  */
  226         .text
  227         SUPERALIGN_TEXT
  228 IDTVEC(invlrng)
  229         PUSH_FRAME
  230         SET_KERNEL_SREGS
  231         cld
  232 
  233         call    invlrng_handler
  234 
  235         jmp     invltlb_ret
  236 
  237 /*
  238  * Invalidate cache.
  239  */
  240         .text
  241         SUPERALIGN_TEXT
  242 IDTVEC(invlcache)
  243         PUSH_FRAME
  244         SET_KERNEL_SREGS
  245         cld
  246 
  247         call    invlcache_handler
  248 
  249         jmp     invltlb_ret
  250 
  251 /*
  252  * Handler for IPIs sent via the per-cpu IPI bitmap.
  253  */
  254         .text
  255         SUPERALIGN_TEXT
  256 IDTVEC(ipi_intr_bitmap_handler) 
  257         PUSH_FRAME
  258         SET_KERNEL_SREGS
  259         cld
  260 
  261         call    as_lapic_eoi
  262         
  263         FAKE_MCOUNT(TF_EIP(%esp))
  264 
  265         call    ipi_bitmap_handler
  266         MEXITCOUNT
  267         jmp     doreti
  268 
  269 /*
  270  * Executed by a CPU when it receives an IPI_STOP from another CPU.
  271  */
  272         .text
  273         SUPERALIGN_TEXT
  274 IDTVEC(cpustop)
  275         PUSH_FRAME
  276         SET_KERNEL_SREGS
  277         cld
  278 
  279         call    as_lapic_eoi
  280         call    cpustop_handler
  281 
  282         POP_FRAME
  283         iret
  284 
  285 /*
  286  * Executed by a CPU when it receives an IPI_SUSPEND from another CPU.
  287  */
  288         .text
  289         SUPERALIGN_TEXT
  290 IDTVEC(cpususpend)
  291         PUSH_FRAME
  292         SET_KERNEL_SREGS
  293         cld
  294 
  295         call    as_lapic_eoi
  296         call    cpususpend_handler
  297 
  298         POP_FRAME
  299         jmp     doreti_iret
  300 
  301 /*
  302  * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
  303  *
  304  * - Calls the generic rendezvous action function.
  305  */
  306         .text
  307         SUPERALIGN_TEXT
  308 IDTVEC(rendezvous)
  309         PUSH_FRAME
  310         SET_KERNEL_SREGS
  311         cld
  312 
  313 #ifdef COUNT_IPIS
  314         movl    PCPU(CPUID), %eax
  315         movl    ipi_rendezvous_counts(,%eax,4), %eax
  316         incl    (%eax)
  317 #endif
  318         call    smp_rendezvous_action
  319 
  320         call    as_lapic_eoi
  321         POP_FRAME
  322         iret
  323         
  324 #endif /* SMP */

Cache object: 65a5b4ccb9c15eb504cabc648e8ae8ed


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.