root/arch/i386/isa/icu.s

/* [<][>][^][v][top][bottom][index][help] */
    1 /*      $OpenBSD: icu.s,v 1.25 2007/05/25 21:27:15 krw Exp $    */
    2 /*      $NetBSD: icu.s,v 1.45 1996/01/07 03:59:34 mycroft Exp $ */
    3 
    4 /*-
    5  * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by Charles M. Hannum.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <net/netisr.h>
   34 
   35         .data
   36         .globl  _C_LABEL(imen),_C_LABEL(ipending),_C_LABEL(netisr)
   37 _C_LABEL(imen):
   38         .long   0xffff          # interrupt mask enable (all off)
   39 _C_LABEL(ipending):
   40         .long   0               # interrupts pending
   41 _C_LABEL(netisr):
   42         .long   0               # scheduling bits for network
   43 
   44         .text
   45 /*
   46  * Process pending interrupts.
   47  *
   48  * Important registers:
   49  *   ebx - cpl
   50  *   esi - address to resume loop at
   51  *   edi - scratch for Xsoftnet
   52  */
   53 IDTVEC(spllower)
   54         pushl   %ebx
   55         pushl   %esi
   56         pushl   %edi
   57         movl    CPL,%ebx                # save priority
   58         movl    $1f,%esi                # address to resume loop at
   59 1:      movl    %ebx,%eax               # get cpl
   60         shrl    $4,%eax                 # find its mask.
   61         movl    _C_LABEL(iunmask)(,%eax,4),%eax
   62         cli
   63         andl    _C_LABEL(ipending),%eax         # any non-masked bits left?
   64         jz      2f
   65         sti
   66         bsfl    %eax,%eax
   67         btrl    %eax,_C_LABEL(ipending)
   68         jnc     1b
   69         jmp     *_C_LABEL(Xrecurse)(,%eax,4)
   70 2:      movl    %ebx,CPL
   71         sti
   72         popl    %edi
   73         popl    %esi
   74         popl    %ebx
   75         ret
   76 
   77 /*
   78  * Handle return from interrupt after device handler finishes.
   79  *
   80  * Important registers:
   81  *   ebx - cpl to restore
   82  *   esi - address to resume loop at
   83  *   edi - scratch for Xsoftnet
   84  */
   85 IDTVEC(doreti)
   86         popl    %ebx                    # get previous priority
   87         movl    $1f,%esi                # address to resume loop at
   88 1:      movl    %ebx,%eax
   89         shrl    $4,%eax
   90         movl    _C_LABEL(iunmask)(,%eax,4),%eax
   91         cli
   92         andl    _C_LABEL(ipending),%eax
   93         jz      2f
   94         sti
   95         bsfl    %eax,%eax               # slow, but not worth optimizing
   96         btrl    %eax,_C_LABEL(ipending)
   97         jnc     1b                      # some intr cleared the in-memory bit
   98         cli
   99         jmp     *_C_LABEL(Xresume)(,%eax,4)
  100 2:      /* Check for ASTs on exit to user mode. */
  101         CHECK_ASTPENDING(%ecx)
  102         movl    %ebx,CPL
  103         je      3f
  104         testb   $SEL_RPL,TF_CS(%esp)
  105 #ifdef VM86
  106         jnz     4f
  107         testl   $PSL_VM,TF_EFLAGS(%esp)
  108 #endif
  109         jz      3f
  110 4:      CLEAR_ASTPENDING(%ecx)
  111         sti
  112         movl    $T_ASTFLT,TF_TRAPNO(%esp)       /* XXX undo later. */
  113         /* Pushed T_ASTFLT into tf_trapno on entry. */
  114         call    _C_LABEL(trap)
  115         cli
  116         jmp     2b
  117 3:      INTRFASTEXIT
  118 
  119 
  120 /*
  121  * Soft interrupt handlers
  122  */
  123 
  124 #include "pccom.h"
  125 
  126 IDTVEC(softast)
  127         movl    $IPL_SOFTAST,%eax
  128         movl    %eax,CPL
  129         sti
  130         jmp     *%esi
  131 
  132 IDTVEC(softtty)
  133 #if NPCCOM > 0
  134         movl    $IPL_SOFTTTY,%eax
  135         movl    %eax,CPL
  136         sti
  137 #ifdef MULTIPROCESSOR
  138         call    _C_LABEL(i386_softintlock)
  139 #endif
  140         call    _C_LABEL(comsoft)
  141 #ifdef MULTIPROCESSOR   
  142         call    _C_LABEL(i386_softintunlock)
  143 #endif
  144 #endif
  145         jmp     *%esi
  146 
  147 #define DONETISR(s, c) \
  148         .globl  _C_LABEL(c)     ;\
  149         testl   $(1 << s),%edi  ;\
  150         jz      1f              ;\
  151         call    _C_LABEL(c)     ;\
  152 1:
  153 
  154 IDTVEC(softnet)
  155         movl    $IPL_SOFTNET,%eax
  156         movl    %eax,CPL
  157         sti
  158 #ifdef MULTIPROCESSOR
  159         call    _C_LABEL(i386_softintlock)
  160 #endif
  161         xorl    %edi,%edi
  162         xchgl   _C_LABEL(netisr),%edi
  163 #include <net/netisr_dispatch.h>
  164 #ifdef MULTIPROCESSOR   
  165         call    _C_LABEL(i386_softintunlock)
  166 #endif
  167         jmp     *%esi
  168 #undef DONETISR
  169 
  170 IDTVEC(softclock)
  171         movl    $IPL_SOFTCLOCK,%eax
  172         movl    %eax,CPL
  173         sti
  174 #ifdef MULTIPROCESSOR
  175         call    _C_LABEL(i386_softintlock)
  176 #endif
  177         call    _C_LABEL(softclock)
  178 #ifdef MULTIPROCESSOR   
  179         call    _C_LABEL(i386_softintunlock)
  180 #endif
  181         jmp     *%esi
  182 

/* [<][>][^][v][top][bottom][index][help] */