icu.s revision 1.27
1/* $OpenBSD: icu.s,v 1.27 2008/04/26 14:33:27 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(softtty) 125#if NPCCOM > 0 126 movl $IPL_SOFTTTY,%eax 127 movl %eax,CPL 128 sti 129#ifdef MULTIPROCESSOR 130 call _C_LABEL(i386_softintlock) 131#endif 132 call _C_LABEL(comsoft) 133#ifdef MULTIPROCESSOR 134 call _C_LABEL(i386_softintunlock) 135#endif 136#endif 137 jmp *%esi 138 139#define DONETISR(s, c) \ 140 .globl _C_LABEL(c) ;\ 141 testl $(1 << s),%edi ;\ 142 jz 1f ;\ 143 call _C_LABEL(c) ;\ 1441: 145 146IDTVEC(softnet) 147 movl $IPL_SOFTNET,%eax 148 movl %eax,CPL 149 sti 150#ifdef MULTIPROCESSOR 151 call _C_LABEL(i386_softintlock) 152#endif 153 xorl %edi,%edi 154 xchgl _C_LABEL(netisr),%edi 155#include <net/netisr_dispatch.h> 156#ifdef MULTIPROCESSOR 157 call _C_LABEL(i386_softintunlock) 158#endif 159 jmp *%esi 160#undef DONETISR 161 162IDTVEC(softclock) 163 movl $IPL_SOFTCLOCK,%eax 164 movl %eax,CPL 165 sti 166#ifdef MULTIPROCESSOR 167 call _C_LABEL(i386_softintlock) 168#endif 169 call _C_LABEL(softclock) 170#ifdef MULTIPROCESSOR 171 call _C_LABEL(i386_softintunlock) 172#endif 173 jmp *%esi 174 175