2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #include <mach_kgdb.h>
32 #include <mach_debug.h>
35 #include <ppc/proc_reg.h>
36 #include <mach/ppc/vm_param.h>
38 /* void kdp_call_with_ctx(int type, struct ppc_thread_state *ssp)
40 * Switch on kdp stack and enter the debugger. On return,
41 * switch back to the previous stack
43 * If the kdp stack is not free, we allocate ourselves a frame below
44 * the current kdp frame. This should never occur in a perfect world.
47 ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
49 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
50 mfmsr r7 ; Get the MSR
51 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
53 andc r7,r7,r2 ; Clear FP, VEC, and EE
55 isync ; Need this because we may have ditched fp/vec
56 mfsprg r8,0 /* Get the per_proc block address */
57 stw r0, FM_LR_SAVE(r1) /* save lr in the current frame */
59 lwz r9, PP_DEBSTACKPTR(r8) /* get kdp stack pointer */
63 #ifdef LET_KDP_REENTER
64 mr r9, r1 /* get current stack pointer */
65 subi r9, r9, FM_REDZONE + FM_SIZE
67 bl EXT(kdp_print_backtrace)
71 stw r1, FM_ARG0(r9) /* Store old stack pointer */
73 stw r0, PP_DEBSTACKPTR(r8) /* Mark kdp stack as busy */
76 stw r0, FM_BACKPTR(r1)
80 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
81 mfmsr r0 /* Get the MSR */
82 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
84 andc r0,r0,r2 ; Clear FP, VEC, and EE
86 isync ; Need this because we may have ditched fp/vec
88 mfsprg r8,0 /* Get the per_proc block address */
90 stw r1, PP_DEBSTACKPTR(r8) /* Mark gdb stack as free */
92 lwz r0, FM_LR_SAVE(r1)