2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <ppc/proc_reg.h>
32 #include <mach/ppc/vm_param.h>
33 #include <ppc/exception.h>
37 * The compiler generates calls to this function and passes address
38 * of caller of the function [ from which mcount is called ] as the
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.
50 stw r0,8(r1) ; Save lr on the stack
51 stwu r1,-64(r1) ; Get a stack frame
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
58 mfsprg r7,1 ; Get the current activation
59 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
60 lhz r6,PP_CPU_FLAGS(r7) ; Get cpu flags
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
67 bl _mcount ; Call the C routine
69 mfsprg r7,1 ; Get the current activation
70 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
71 lhz r6,PP_CPU_FLAGS(r7) ; Get CPU number
73 andc r6,r6,r5 ; Clear mcount_off
74 sth r6,PP_CPU_FLAGS(r7) ; Save cpu_flags
77 mtmsr r9 ; Restore MSR