]>
Commit | Line | Data |
---|---|---|
55e303ae A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
8ad349bb | 5 | * |
8f6c56a5 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. | |
14 | * | |
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 | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
55e303ae A |
27 | */ |
28 | #include <ppc/asm.h> | |
29 | #include <ppc/proc_reg.h> | |
55e303ae A |
30 | #include <assym.s> |
31 | #include <debug.h> | |
32 | #include <mach/ppc/vm_param.h> | |
33 | #include <ppc/exception.h> | |
34 | ||
35 | ||
36 | /* | |
37 | * The compiler generates calls to this function and passes address | |
38 | * of caller of the function [ from which mcount is called ] as the | |
39 | * first parameter. | |
40 | * mcount disables interrupts prior to call mcount() and restores | |
41 | * interrupt upon return. | |
42 | * To prevent recursive calls to mcount(), a flag, mcountOff, is set | |
43 | * in cpu_flags per_proc. | |
44 | */ | |
45 | ||
46 | .align 4 | |
47 | .globl mcount | |
48 | mcount: | |
49 | mflr r0 ; Load lr | |
50 | stw r0,8(r1) ; Save lr on the stack | |
51 | stwu r1,-64(r1) ; Get a stack frame | |
52 | mfmsr r9 ; Get msr | |
53 | rlwinm r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off | |
54 | rlwinm r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off | |
55 | rlwinm r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1 ; Turn off interruptions | |
56 | mtmsr r8 ; Update msr | |
57 | isync | |
91447636 A |
58 | mfsprg r7,1 ; Get the current activation |
59 | lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block | |
55e303ae A |
60 | lhz r6,PP_CPU_FLAGS(r7) ; Get cpu flags |
61 | ori r5,r6,mcountOff ; | |
62 | cmplw r5,r6 ; is mount off | |
63 | beq mcount_ret ; return if off | |
64 | sth r5,PP_CPU_FLAGS(r7) ; Update cpu_flags | |
65 | stw r9,FM_ARG0(r1) ; Save MSR | |
66 | mr r4, r0 | |
67 | bl _mcount ; Call the C routine | |
68 | lwz r9,FM_ARG0(r1) | |
91447636 A |
69 | mfsprg r7,1 ; Get the current activation |
70 | lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block | |
55e303ae A |
71 | lhz r6,PP_CPU_FLAGS(r7) ; Get CPU number |
72 | li r5,mcountOff ; | |
73 | andc r6,r6,r5 ; Clear mcount_off | |
74 | sth r6,PP_CPU_FLAGS(r7) ; Save cpu_flags | |
75 | mcount_ret: | |
76 | addi r1,r1,64 | |
77 | mtmsr r9 ; Restore MSR | |
78 | lwz r0,8(r1) | |
79 | mtlr r0 | |
80 | blr | |
81 |