Annotation of sys/arch/amd64/amd64/spl.S, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: spl.S,v 1.5 2006/05/10 12:36:39 krw Exp $ */
! 2: /* $NetBSD: spl.S,v 1.3 2004/06/28 09:13:11 fvdl Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 2003 Wasabi Systems, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * Written by Frank van der Linden for Wasabi Systems, Inc.
! 9: *
! 10: * Redistribution and use in source and binary forms, with or without
! 11: * modification, are permitted provided that the following conditions
! 12: * are met:
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: * 2. Redistributions in binary form must reproduce the above copyright
! 16: * notice, this list of conditions and the following disclaimer in the
! 17: * documentation and/or other materials provided with the distribution.
! 18: * 3. All advertising materials mentioning features or use of this software
! 19: * must display the following acknowledgement:
! 20: * This product includes software developed for the NetBSD Project by
! 21: * Wasabi Systems, Inc.
! 22: * 4. The name of Wasabi Systems, Inc. may not be used to endorse
! 23: * or promote products derived from this software without specific prior
! 24: * written permission.
! 25: *
! 26: * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
! 27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
! 30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 36: * POSSIBILITY OF SUCH DAMAGE.
! 37: */
! 38:
! 39: /*
! 40: * Copyright (c) 1998 The NetBSD Foundation, Inc.
! 41: * All rights reserved.
! 42: *
! 43: * This code is derived from software contributed to The NetBSD Foundation
! 44: * by Charles M. Hannum.
! 45: *
! 46: * Redistribution and use in source and binary forms, with or without
! 47: * modification, are permitted provided that the following conditions
! 48: * are met:
! 49: * 1. Redistributions of source code must retain the above copyright
! 50: * notice, this list of conditions and the following disclaimer.
! 51: * 2. Redistributions in binary form must reproduce the above copyright
! 52: * notice, this list of conditions and the following disclaimer in the
! 53: * documentation and/or other materials provided with the distribution.
! 54: * 3. All advertising materials mentioning features or use of this software
! 55: * must display the following acknowledgement:
! 56: * This product includes software developed by the NetBSD
! 57: * Foundation, Inc. and its contributors.
! 58: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 59: * contributors may be used to endorse or promote products derived
! 60: * from this software without specific prior written permission.
! 61: *
! 62: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 63: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 64: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 65: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 66: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 67: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 68: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 69: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 70: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 71: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 72: * POSSIBILITY OF SUCH DAMAGE.
! 73: */
! 74:
! 75: #define ALIGN_TEXT .align 16,0x90
! 76:
! 77: #include <machine/asm.h>
! 78: #include <machine/psl.h>
! 79: #include <machine/trap.h>
! 80: #include <machine/segments.h>
! 81: #include <machine/frameasm.h>
! 82:
! 83: #include "assym.h"
! 84:
! 85: .text
! 86:
! 87: #if 0
! 88: #if defined(PROF) || defined(GPROF)
! 89: /*
! 90: * XXXX TODO
! 91: */
! 92: .globl _C_LABEL(splhigh), _C_LABEL(splx)
! 93:
! 94: ALIGN_TEXT
! 95: _C_LABEL(splhigh):
! 96: movl $IPL_HIGH,%eax
! 97: xchgl %eax,CPUVAR(ILEVEL)
! 98: ret
! 99:
! 100: ALIGN_TEXT
! 101: _C_LABEL(splx):
! 102: movl 4(%esp),%eax
! 103: movl %eax,CPUVAR(ILEVEL)
! 104: testl %eax,%eax
! 105: jnz _C_LABEL(Xspllower)
! 106: ret
! 107: #endif /* PROF || GPROF */
! 108: #endif
! 109:
! 110: /*
! 111: * Process pending interrupts.
! 112: *
! 113: * Important registers:
! 114: * ebx - cpl
! 115: * r13 - address to resume loop at
! 116: *
! 117: * It is important that the bit scan instruction is bsr, it will get
! 118: * the highest 2 bits (currently the IPI and clock handlers) first,
! 119: * to avoid deadlocks where one CPU sends an IPI, another one is at
! 120: * splipi() and defers it, lands in here via splx(), and handles
! 121: * a lower-prio one first, which needs to take the kernel lock -->
! 122: * the sending CPU will never see the that CPU accept the IPI
! 123: * (see pmap_tlb_shootnow).
! 124: */
! 125: IDTVEC(spllower)
! 126: _PROF_PROLOGUE
! 127: pushq %rbx
! 128: pushq %r13
! 129: pushq %r12
! 130: movl %edi,%ebx
! 131: leaq 1f(%rip),%r13 # address to resume loop at
! 132: 1: movl %ebx,%eax # get cpl
! 133: movl CPUVAR(IUNMASK)(,%rax,4),%eax
! 134: cli
! 135: andl CPUVAR(IPENDING),%eax # any non-masked bits left?
! 136: jz 2f
! 137: bsrl %eax,%eax
! 138: btrl %eax,CPUVAR(IPENDING)
! 139: movq CPUVAR(ISOURCES)(,%rax,8),%rax
! 140: jmp *IS_RECURSE(%rax)
! 141: 2:
! 142: movl %ebx,CPUVAR(ILEVEL)
! 143: sti
! 144: popq %r12
! 145: popq %r13
! 146: popq %rbx
! 147: ret
! 148:
! 149: /*
! 150: * Handle return from interrupt after device handler finishes.
! 151: *
! 152: * Important registers:
! 153: * ebx - cpl to restore
! 154: * r13 - address to resume loop at
! 155: */
! 156: IDTVEC(doreti)
! 157: popq %rbx # get previous priority
! 158: decl CPUVAR(IDEPTH)
! 159: leaq 1f(%rip),%r13
! 160: 1: movl %ebx,%eax
! 161: movl CPUVAR(IUNMASK)(,%rax,4),%eax
! 162: cli
! 163: andl CPUVAR(IPENDING),%eax
! 164: jz 2f
! 165: bsrl %eax,%eax # slow, but not worth optimizing
! 166: btrl %eax,CPUVAR(IPENDING)
! 167: movq CPUVAR(ISOURCES)(,%rax, 8),%rax
! 168: jmp *IS_RESUME(%rax)
! 169: 2: /* Check for ASTs on exit to user mode. */
! 170: movl %ebx,CPUVAR(ILEVEL)
! 171: 5: CHECK_ASTPENDING(%r11)
! 172: je 3f
! 173: testb $SEL_RPL,TF_CS(%rsp)
! 174: jz 3f
! 175: 4: CLEAR_ASTPENDING(%r11)
! 176: sti
! 177: movl $T_ASTFLT,TF_TRAPNO(%rsp) /* XXX undo later.. */
! 178: /* Pushed T_ASTFLT into tf_trapno on entry. */
! 179: movq %rsp, %rdi
! 180: call _C_LABEL(trap)
! 181: cli
! 182: jmp 5b
! 183: 3: INTRFASTEXIT
CVSweb