]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kdp/ml/ppc/kdp_asm.s
3520708617166d0aa6dd47738496ee8a9809bf95
[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_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 #include <mach_kdb.h>
24 #include <mach_kgdb.h>
25 #include <mach_debug.h>
26 #include <assym.s>
27 #include <ppc/asm.h>
28 #include <ppc/proc_reg.h>
29 #include <mach/ppc/vm_param.h>
30
31 /* void kdp_call_with_ctx(int type, struct ppc_thread_state *ssp)
32 *
33 * Switch on kdp stack and enter the debugger. On return,
34 * switch back to the previous stack
35 *
36 * If the kdp stack is not free, we allocate ourselves a frame below
37 * the current kdp frame. This should never occur in a perfect world.
38 */
39
40 ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
41
42 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
43 mfmsr r7 ; Get the MSR
44 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
45 mflr r0
46 andc r7,r7,r2 ; Clear FP, VEC, and EE
47 mtmsr r7
48 isync ; Need this because we may have ditched fp/vec
49 mfsprg r8,0 /* Get the per_proc block address */
50 stw r0, FM_LR_SAVE(r1) /* save lr in the current frame */
51
52 lwz r9, PP_DEBSTACKPTR(r8) /* get kdp stack pointer */
53 cmpwi r9, 0
54 bne 0f
55
56 #ifdef LET_KDP_REENTER
57 mr r9, r1 /* get current stack pointer */
58 subi r9, r9, FM_REDZONE + FM_SIZE
59 #else
60 bl EXT(kdp_print_backtrace)
61 #endif
62
63 0:
64 stw r1, FM_ARG0(r9) /* Store old stack pointer */
65 li r0, 0
66 stw r0, PP_DEBSTACKPTR(r8) /* Mark kdp stack as busy */
67
68 subi r1, r9, FM_SIZE
69 stw r0, FM_BACKPTR(r1)
70
71 bl EXT(kdp_trap)
72
73 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
74 mfmsr r0 /* Get the MSR */
75 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
76 addi r1, r1, FM_SIZE
77 andc r0,r0,r2 ; Clear FP, VEC, and EE
78 mtmsr r0
79 isync ; Need this because we may have ditched fp/vec
80
81 mfsprg r8,0 /* Get the per_proc block address */
82
83 stw r1, PP_DEBSTACKPTR(r8) /* Mark gdb stack as free */
84 lwz r1, FM_ARG0(r1)
85 lwz r0, FM_LR_SAVE(r1)
86 mtlr r0
87
88 blr
89
90