1/* $NetBSD: debug.s,v 1.8 2001/05/30 15:24:27 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * NASA Ames Research Center. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40__KERNEL_RCSID(6, "$NetBSD: debug.s,v 1.8 2001/05/30 15:24:27 lukem Exp $") 41 42#include "opt_kgdb.h" 43 44/* 45 * Debugger glue. 46 */ 47 48 .text 49inc6: .stabs __FILE__,132,0,0,inc6; .loc 1 __LINE__ 50 51/* 52 * Debugger stack. 53 */ 54BSS(debug_stack_bottom, NBPG) 55ABS(debug_stack_top, debug_stack_bottom + NBPG) 56 57/* 58 * alpha_debug: 59 * 60 * Single debugger entry point, handling the housekeeping 61 * chores we need to deal with. 62 * 63 * Arguments are: 64 * 65 * a0 a0 from trap 66 * a1 a1 from trap 67 * a2 a2 from trap 68 * a3 kernel trap entry point 69 * a4 frame pointer 70 */ 71NESTED_NOPROFILE(alpha_debug, 5, 32, ra, IM_RA|IM_S0, 0) 72 br pv, 1f 731: LDGP(pv) 74 lda t0, FRAME_SIZE*8(a4) /* what would sp have been? */ 75 stq t0, FRAME_SP*8(a4) /* belatedly save sp for ddb view */ 76 lda sp, -32(sp) /* set up stack frame */ 77 stq ra, (32-8)(sp) /* save ra */ 78 stq s0, (32-16)(sp) /* save s0 */ 79 80 /* Remember our current stack pointer. */ 81 mov sp, s0 82 83#if defined(MULTIPROCESSOR) 84 /* Pause all other CPUs. */ 85 ldiq a0, 1 86 CALL(cpu_pause_resume_all) 87#endif 88 89 /* 90 * Switch to the debug stack if we're not on it already. 91 */ 92 lda t0, debug_stack_bottom 93 cmpule sp, t0, t1 /* sp <= debug_stack_bottom */ 94 bne t1, 2f /* yes, switch now */ 95 96 lda t0, debug_stack_top 97 cmpule t0, sp, t1 /* debug_stack_top <= sp? */ 98 bne t1, 3f /* yes, we're on the debug stack */ 99 1002: lda sp, debug_stack_top /* sp <- debug_stack_top */ 101 1023: /* Dispatch to the debugger - arguments are already in place. */ 103#if defined(KGDB) 104 mov a3, a0 /* a0 == entry (trap type) */ 105 mov a4, a1 /* a1 == frame pointer */ 106 CALL(kgdb_trap) 107 br 9f 108#endif 109#if defined(DDB) 110 CALL(ddb_trap) 111 br 9f 112#endif 1139: /* Debugger return value in v0; switch back to our previous stack. */ 114 mov s0, sp 115 116#if defined(MULTIPROCESSOR) 117 mov v0, s0 118 119 /* Resume all other CPUs. */ 120 mov zero, a0 121 CALL(cpu_pause_resume_all) 122 123 mov s0, v0 124#endif 125 126 ldq ra, (32-8)(sp) /* restore ra */ 127 ldq s0, (32-16)(sp) /* restore s0 */ 128 lda sp, 32(sp) /* pop stack frame */ 129 RET 130 END(alpha_debug) 131