]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kdp/ml/ppc/kdp_asm.s
xnu-792.6.61.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 *
37839358
A
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.
1c79356b 11 *
37839358
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#include <mach_kdb.h>
23#include <mach_kgdb.h>
24#include <mach_debug.h>
25#include <assym.s>
26#include <ppc/asm.h>
27#include <ppc/proc_reg.h>
28#include <mach/ppc/vm_param.h>
29
30/* void kdp_call_with_ctx(int type, struct ppc_thread_state *ssp)
31 *
32 * Switch on kdp stack and enter the debugger. On return,
33 * switch back to the previous stack
34 *
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.
37 */
38
39ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
40
55e303ae
A
41 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
42 mfmsr r7 ; Get the MSR
43 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
1c79356b 44 mflr r0
55e303ae 45 andc r7,r7,r2 ; Clear FP, VEC, and EE
1c79356b 46 mtmsr r7
9bccf70c 47 isync ; Need this because we may have ditched fp/vec
1c79356b
A
48 mfsprg r8,0 /* Get the per_proc block address */
49 stw r0, FM_LR_SAVE(r1) /* save lr in the current frame */
50
51 lwz r9, PP_DEBSTACKPTR(r8) /* get kdp stack pointer */
52 cmpwi r9, 0
53 bne 0f
54
55#ifdef LET_KDP_REENTER
56 mr r9, r1 /* get current stack pointer */
0b4e3aa0 57 subi r9, r9, FM_REDZONE + FM_SIZE
1c79356b
A
58#else
59 bl EXT(kdp_print_backtrace)
60#endif
61
620:
63 stw r1, FM_ARG0(r9) /* Store old stack pointer */
64 li r0, 0
65 stw r0, PP_DEBSTACKPTR(r8) /* Mark kdp stack as busy */
66
67 subi r1, r9, FM_SIZE
68 stw r0, FM_BACKPTR(r1)
69
70 bl EXT(kdp_trap)
71
55e303ae 72 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
1c79356b 73 mfmsr r0 /* Get the MSR */
55e303ae 74 ori r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP)) ; Get FP and EE
1c79356b 75 addi r1, r1, FM_SIZE
55e303ae 76 andc r0,r0,r2 ; Clear FP, VEC, and EE
1c79356b 77 mtmsr r0
55e303ae 78 isync ; Need this because we may have ditched fp/vec
1c79356b
A
79
80 mfsprg r8,0 /* Get the per_proc block address */
81
82 stw r1, PP_DEBSTACKPTR(r8) /* Mark gdb stack as free */
83 lwz r1, FM_ARG0(r1)
84 lwz r0, FM_LR_SAVE(r1)
85 mtlr r0
86
87 blr
88
89