]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kdp/ml/ppc/kdp_asm.s
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / kdp / ml / ppc / kdp_asm.s
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 #include <mach_kdb.h>
31 #include <mach_kgdb.h>
32 #include <mach_debug.h>
33 #include <assym.s>
34 #include <ppc/asm.h>
35 #include <ppc/proc_reg.h>
36 #include <mach/ppc/vm_param.h>
37
38 /* void kdp_call_with_ctx(int type, struct ppc_thread_state *ssp)
39 *
40 * Switch on kdp stack and enter the debugger. On return,
41 * switch back to the previous stack
42 *
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.
45 */
46
47 ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
48
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
52 mflr r0
53 andc r7,r7,r2 ; Clear FP, VEC, and EE
54 mtmsr r7
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 */
58
59 lwz r9, PP_DEBSTACKPTR(r8) /* get kdp stack pointer */
60 cmpwi r9, 0
61 bne 0f
62
63 #ifdef LET_KDP_REENTER
64 mr r9, r1 /* get current stack pointer */
65 subi r9, r9, FM_REDZONE + FM_SIZE
66 #else
67 bl EXT(kdp_print_backtrace)
68 #endif
69
70 0:
71 stw r1, FM_ARG0(r9) /* Store old stack pointer */
72 li r0, 0
73 stw r0, PP_DEBSTACKPTR(r8) /* Mark kdp stack as busy */
74
75 subi r1, r9, FM_SIZE
76 stw r0, FM_BACKPTR(r1)
77
78 bl EXT(kdp_trap)
79
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
83 addi r1, r1, FM_SIZE
84 andc r0,r0,r2 ; Clear FP, VEC, and EE
85 mtmsr r0
86 isync ; Need this because we may have ditched fp/vec
87
88 mfsprg r8,0 /* Get the per_proc block address */
89
90 stw r1, PP_DEBSTACKPTR(r8) /* Mark gdb stack as free */
91 lwz r1, FM_ARG0(r1)
92 lwz r0, FM_LR_SAVE(r1)
93 mtlr r0
94
95 blr
96
97