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