2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #include <ppc/proc_reg.h>
34 #include <mach/ppc/vm_param.h>
35 #include <ppc/exception.h>
39 * The compiler generates calls to this function and passes address
40 * of caller of the function [ from which mcount is called ] as the
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.
52 stw r0,8(r1) ; Save lr on the stack
53 stwu r1,-64(r1) ; Get a stack frame
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
60 mfsprg r7,1 ; Get the current activation
61 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
62 lhz r6,PP_CPU_FLAGS(r7) ; Get cpu flags
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
69 bl _mcount ; Call the C routine
71 mfsprg r7,1 ; Get the current activation
72 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
73 lhz r6,PP_CPU_FLAGS(r7) ; Get CPU number
75 andc r6,r6,r5 ; Clear mcount_off
76 sth r6,PP_CPU_FLAGS(r7) ; Save cpu_flags
79 mtmsr r9 ; Restore MSR