1/* $OpenBSD: icu.s,v 1.35 2018/07/09 19:20:30 guenther 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 */ 47KIDTVEC(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 */ 79KIDTVEC(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 jz 3f 1004: CLEAR_ASTPENDING(%ecx) 101 sti 102 pushl %esp 103 call _C_LABEL(ast) 104 addl $4,%esp 105 cli 106 jmp 2b 1073: 108#ifdef DIAGNOSTIC 109 movl $0xf9,%esi 110#endif 111 INTRFASTEXIT 112 113 114/* 115 * Soft interrupt handlers 116 */ 117 118KIDTVEC(softtty) 119 movl $IPL_SOFTTTY,%eax 120 movl %eax,CPL 121 sti 122 pushl $I386_SOFTINTR_SOFTTTY 123 call _C_LABEL(softintr_dispatch) 124 addl $4,%esp 125 jmp *%esi 126 127KIDTVEC(softnet) 128 movl $IPL_SOFTNET,%eax 129 movl %eax,CPL 130 sti 131 pushl $I386_SOFTINTR_SOFTNET 132 call _C_LABEL(softintr_dispatch) 133 addl $4,%esp 134 jmp *%esi 135#undef DONETISR 136 137KIDTVEC(softclock) 138 movl $IPL_SOFTCLOCK,%eax 139 movl %eax,CPL 140 sti 141 pushl $I386_SOFTINTR_SOFTCLOCK 142 call _C_LABEL(softintr_dispatch) 143 addl $4,%esp 144 jmp *%esi 145 146