1/* $OpenBSD: icu.s,v 1.31 2010/12/21 14:56:23 claudio 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 .data 34 .globl _C_LABEL(imen) 35_C_LABEL(imen): 36 .long 0xffff # interrupt mask enable (all off) 37 38 .text 39/* 40 * Process pending interrupts. 41 * 42 * Important registers: 43 * ebx - cpl 44 * esi - address to resume loop at 45 * edi - scratch for Xsoftnet 46 */ 47IDTVEC(spllower) 48 pushl %ebx 49 pushl %esi 50 pushl %edi 51 movl CPL,%ebx # save priority 52 movl $1f,%esi # address to resume loop at 531: movl %ebx,%eax # get cpl 54 shrl $4,%eax # find its mask. 55 movl _C_LABEL(iunmask)(,%eax,4),%eax 56 cli 57 andl CPUVAR(IPENDING),%eax # any non-masked bits left? 58 jz 2f 59 sti 60 bsfl %eax,%eax 61 btrl %eax,CPUVAR(IPENDING) 62 jnc 1b 63 jmp *_C_LABEL(Xrecurse)(,%eax,4) 642: movl %ebx,CPL 65 sti 66 popl %edi 67 popl %esi 68 popl %ebx 69 ret 70 71/* 72 * Handle return from interrupt after device handler finishes. 73 * 74 * Important registers: 75 * ebx - cpl to restore 76 * esi - address to resume loop at 77 * edi - scratch for Xsoftnet 78 */ 79IDTVEC(doreti) 80 popl %ebx # get previous priority 81 movl $1f,%esi # address to resume loop at 821: movl %ebx,%eax 83 shrl $4,%eax 84 movl _C_LABEL(iunmask)(,%eax,4),%eax 85 cli 86 andl CPUVAR(IPENDING),%eax 87 jz 2f 88 sti 89 bsfl %eax,%eax # slow, but not worth optimizing 90 btrl %eax,CPUVAR(IPENDING) 91 jnc 1b # some intr cleared the in-memory bit 92 cli 93 jmp *_C_LABEL(Xresume)(,%eax,4) 942: /* Check for ASTs on exit to user mode. */ 95 CHECK_ASTPENDING(%ecx) 96 movl %ebx,CPL 97 je 3f 98 testb $SEL_RPL,TF_CS(%esp) 99#ifdef VM86 100 jnz 4f 101 testl $PSL_VM,TF_EFLAGS(%esp) 102#endif 103 jz 3f 1044: CLEAR_ASTPENDING(%ecx) 105 sti 106 movl $T_ASTFLT,TF_TRAPNO(%esp) /* XXX undo later. */ 107 /* Pushed T_ASTFLT into tf_trapno on entry. */ 108 pushl %esp 109 call _C_LABEL(trap) 110 addl $4,%esp 111 cli 112 jmp 2b 1133: INTRFASTEXIT 114 115 116/* 117 * Soft interrupt handlers 118 */ 119 120IDTVEC(softtty) 121 movl $IPL_SOFTTTY,%eax 122 movl %eax,CPL 123 sti 124#ifdef MULTIPROCESSOR 125 call _C_LABEL(i386_softintlock) 126#endif 127 pushl $I386_SOFTINTR_SOFTTTY 128 call _C_LABEL(softintr_dispatch) 129 addl $4,%esp 130#ifdef MULTIPROCESSOR 131 call _C_LABEL(i386_softintunlock) 132#endif 133 jmp *%esi 134 135IDTVEC(softnet) 136 movl $IPL_SOFTNET,%eax 137 movl %eax,CPL 138 sti 139#ifdef MULTIPROCESSOR 140 call _C_LABEL(i386_softintlock) 141#endif 142 pushl $I386_SOFTINTR_SOFTNET 143 call _C_LABEL(softintr_dispatch) 144 addl $4,%esp 145#ifdef MULTIPROCESSOR 146 call _C_LABEL(i386_softintunlock) 147#endif 148 jmp *%esi 149#undef DONETISR 150 151IDTVEC(softclock) 152 movl $IPL_SOFTCLOCK,%eax 153 movl %eax,CPL 154 sti 155#ifdef MULTIPROCESSOR 156 call _C_LABEL(i386_softintlock) 157#endif 158 pushl $I386_SOFTINTR_SOFTCLOCK 159 call _C_LABEL(softintr_dispatch) 160 addl $4,%esp 161#ifdef MULTIPROCESSOR 162 call _C_LABEL(i386_softintunlock) 163#endif 164 jmp *%esi 165 166