]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/mcount.s
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / ppc / mcount.s
CommitLineData
55e303ae
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
8ad349bb
A
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
37839358 15 *
8ad349bb
A
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
37839358 19 *
8ad349bb
A
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
37839358 27 *
8ad349bb 28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
55e303ae
A
29 */
30#include <ppc/asm.h>
31#include <ppc/proc_reg.h>
55e303ae
A
32#include <assym.s>
33#include <debug.h>
34#include <mach/ppc/vm_param.h>
35#include <ppc/exception.h>
36
37
38/*
39 * The compiler generates calls to this function and passes address
40 * of caller of the function [ from which mcount is called ] as the
41 * first parameter.
42 * mcount disables interrupts prior to call mcount() and restores
43 * interrupt upon return.
44 * To prevent recursive calls to mcount(), a flag, mcountOff, is set
45 * in cpu_flags per_proc.
46 */
47
48 .align 4
49 .globl mcount
50mcount:
51 mflr r0 ; Load lr
52 stw r0,8(r1) ; Save lr on the stack
53 stwu r1,-64(r1) ; Get a stack frame
54 mfmsr r9 ; Get msr
55 rlwinm r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
56 rlwinm r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
57 rlwinm r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1 ; Turn off interruptions
58 mtmsr r8 ; Update msr
59 isync
91447636
A
60 mfsprg r7,1 ; Get the current activation
61 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
55e303ae
A
62 lhz r6,PP_CPU_FLAGS(r7) ; Get cpu flags
63 ori r5,r6,mcountOff ;
64 cmplw r5,r6 ; is mount off
65 beq mcount_ret ; return if off
66 sth r5,PP_CPU_FLAGS(r7) ; Update cpu_flags
67 stw r9,FM_ARG0(r1) ; Save MSR
68 mr r4, r0
69 bl _mcount ; Call the C routine
70 lwz r9,FM_ARG0(r1)
91447636
A
71 mfsprg r7,1 ; Get the current activation
72 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
55e303ae
A
73 lhz r6,PP_CPU_FLAGS(r7) ; Get CPU number
74 li r5,mcountOff ;
75 andc r6,r6,r5 ; Clear mcount_off
76 sth r6,PP_CPU_FLAGS(r7) ; Save cpu_flags
77mcount_ret:
78 addi r1,r1,64
79 mtmsr r9 ; Restore MSR
80 lwz r0,8(r1)
81 mtlr r0
82 blr
83