2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #define __NO_UNDERSCORES__
29 pushl %ebp // setup mcount's frame
31 pushl %eax // save %eax
32 pushf // save interrupt state
33 cli // disable interrupts
36 // Check that this cpu is ready.
37 // This delays the start of mcounting until a cpu is really prepared.
39 movl %gs:CPU_RUNNING,%eax
44 // Test for recursion as indicated by a per-cpu flag.
45 // Skip if nested, otherwise set the flag and call the C mount().
47 movl %gs:CPU_MCOUNT_OFF,%eax
48 testl %eax,%eax // test for recursion
51 incl %gs:CPU_MCOUNT_OFF // set recursion flag
53 movl (%ebp),%eax // frame pointer of mcount's caller
54 movl 4(%eax),%eax // mcount's caller's return address
55 pushl 4(%ebp) // push selfpc parameter for mcount()
56 pushl %eax // push frompc parameter for mcount()
57 call _mcount // call the C mcount
58 addl $8,%esp // pop args
60 decl %gs:CPU_MCOUNT_OFF // turn off recursion flag
62 popf // restore interrupt state
64 movl %ebp,%esp // tear down mcount's frame