icu.s revision 1.26
1/* $OpenBSD: icu.s,v 1.26 2008/04/25 19:50:08 kettenis 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(netisr) 37_C_LABEL(imen): 38 .long 0xffff # interrupt mask enable (all off) 39_C_LABEL(netisr): 40 .long 0 # scheduling bits for network 41 42 .text 43/* 44 * Process pending interrupts. 45 * 46 * Important registers: 47 * ebx - cpl 48 * esi - address to resume loop at 49 * edi - scratch for Xsoftnet 50 */ 51IDTVEC(spllower) 52 pushl %ebx 53 pushl %esi 54 pushl %edi 55 movl CPL,%ebx # save priority 56 movl $1f,%esi # address to resume loop at 571: movl %ebx,%eax # get cpl 58 shrl $4,%eax # find its mask. 59 movl _C_LABEL(iunmask)(,%eax,4),%eax 60 cli 61 andl CPUVAR(IPENDING),%eax # any non-masked bits left? 62 jz 2f 63 sti 64 bsfl %eax,%eax 65 btrl %eax,CPUVAR(IPENDING) 66 jnc 1b 67 jmp *_C_LABEL(Xrecurse)(,%eax,4) 682: movl %ebx,CPL 69 sti 70 popl %edi 71 popl %esi 72 popl %ebx 73 ret 74 75/* 76 * Handle return from interrupt after device handler finishes. 77 * 78 * Important registers: 79 * ebx - cpl to restore 80 * esi - address to resume loop at 81 * edi - scratch for Xsoftnet 82 */ 83IDTVEC(doreti) 84 popl %ebx # get previous priority 85 movl $1f,%esi # address to resume loop at 861: movl %ebx,%eax 87 shrl $4,%eax 88 movl _C_LABEL(iunmask)(,%eax,4),%eax 89 cli 90 andl CPUVAR(IPENDING),%eax 91 jz 2f 92 sti 93 bsfl %eax,%eax # slow, but not worth optimizing 94 btrl %eax,CPUVAR(IPENDING) 95 jnc 1b # some intr cleared the in-memory bit 96 cli 97 jmp *_C_LABEL(Xresume)(,%eax,4) 982: /* Check for ASTs on exit to user mode. */ 99 CHECK_ASTPENDING(%ecx) 100 movl %ebx,CPL 101 je 3f 102 testb $SEL_RPL,TF_CS(%esp) 103#ifdef VM86 104 jnz 4f 105 testl $PSL_VM,TF_EFLAGS(%esp) 106#endif 107 jz 3f 1084: CLEAR_ASTPENDING(%ecx) 109 sti 110 movl $T_ASTFLT,TF_TRAPNO(%esp) /* XXX undo later. */ 111 /* Pushed T_ASTFLT into tf_trapno on entry. */ 112 call _C_LABEL(trap) 113 cli 114 jmp 2b 1153: INTRFASTEXIT 116 117 118/* 119 * Soft interrupt handlers 120 */ 121 122#include "pccom.h" 123 124IDTVEC(softast) 125 movl $IPL_SOFTAST,%eax 126 movl %eax,CPL 127 sti 128 jmp *%esi 129 130IDTVEC(softtty) 131#if NPCCOM > 0 132 movl $IPL_SOFTTTY,%eax 133 movl %eax,CPL 134 sti 135#ifdef MULTIPROCESSOR 136 call _C_LABEL(i386_softintlock) 137#endif 138 call _C_LABEL(comsoft) 139#ifdef MULTIPROCESSOR 140 call _C_LABEL(i386_softintunlock) 141#endif 142#endif 143 jmp *%esi 144 145#define DONETISR(s, c) \ 146 .globl _C_LABEL(c) ;\ 147 testl $(1 << s),%edi ;\ 148 jz 1f ;\ 149 call _C_LABEL(c) ;\ 1501: 151 152IDTVEC(softnet) 153 movl $IPL_SOFTNET,%eax 154 movl %eax,CPL 155 sti 156#ifdef MULTIPROCESSOR 157 call _C_LABEL(i386_softintlock) 158#endif 159 xorl %edi,%edi 160 xchgl _C_LABEL(netisr),%edi 161#include <net/netisr_dispatch.h> 162#ifdef MULTIPROCESSOR 163 call _C_LABEL(i386_softintunlock) 164#endif 165 jmp *%esi 166#undef DONETISR 167 168IDTVEC(softclock) 169 movl $IPL_SOFTCLOCK,%eax 170 movl %eax,CPL 171 sti 172#ifdef MULTIPROCESSOR 173 call _C_LABEL(i386_softintlock) 174#endif 175 call _C_LABEL(softclock) 176#ifdef MULTIPROCESSOR 177 call _C_LABEL(i386_softintunlock) 178#endif 179 jmp *%esi 180 181