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