2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <ppc/proc_reg.h>
26 #include <mach/ppc/vm_param.h>
27 #include <ppc/exception.h>
31 * The compiler generates calls to this function and passes address
32 * of caller of the function [ from which mcount is called ] as the
34 * mcount disables interrupts prior to call mcount() and restores
35 * interrupt upon return.
36 * To prevent recursive calls to mcount(), a flag, mcountOff, is set
37 * in cpu_flags per_proc.
44 stw r0,8(r1) ; Save lr on the stack
45 stwu r1,-64(r1) ; Get a stack frame
47 rlwinm r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
48 rlwinm r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
49 rlwinm r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1 ; Turn off interruptions
52 mfsprg r7,1 ; Get the current activation
53 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
54 lhz r6,PP_CPU_FLAGS(r7) ; Get cpu flags
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
61 bl _mcount ; Call the C routine
63 mfsprg r7,1 ; Get the current activation
64 lwz r7,ACT_PER_PROC(r7) ; Get the per_proc block
65 lhz r6,PP_CPU_FLAGS(r7) ; Get CPU number
67 andc r6,r6,r5 ; Clear mcount_off
68 sth r6,PP_CPU_FLAGS(r7) ; Save cpu_flags
71 mtmsr r9 ; Restore MSR