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