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