2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <mach_kgdb.h>
24 #include <mach_debug.h>
27 #include <ppc/proc_reg.h>
28 #include <mach/ppc/vm_param.h>
30 /* void kdp_call_with_ctx(int type, struct ppc_thread_state *ssp)
32 * Switch on kdp stack and enter the debugger. On return,
33 * switch back to the previous stack
35 * If the kdp stack is not free, we allocate ourselves a frame below
36 * the current kdp frame. This should never occur in a perfect world.
39 ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
41 mfmsr r7 /* Get the MSR */
43 rlwinm r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1 /* Turn off interruptions enable bit */
45 mfsprg r8,0 /* Get the per_proc block address */
46 stw r0, FM_LR_SAVE(r1) /* save lr in the current frame */
48 lwz r9, PP_DEBSTACKPTR(r8) /* get kdp stack pointer */
52 #ifdef LET_KDP_REENTER
53 mr r9, r1 /* get current stack pointer */
54 subi r9, r9, FM_REDZONE + SS_SIZE
56 bl EXT(kdp_print_backtrace)
60 stw r1, FM_ARG0(r9) /* Store old stack pointer */
62 stw r0, PP_DEBSTACKPTR(r8) /* Mark kdp stack as busy */
65 stw r0, FM_BACKPTR(r1)
69 mfmsr r0 /* Get the MSR */
71 rlwinm r0,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1 /* Turn off interruptions enable bit */
74 mfsprg r8,0 /* Get the per_proc block address */
76 stw r1, PP_DEBSTACKPTR(r8) /* Mark gdb stack as free */
78 lwz r0, FM_LR_SAVE(r1)