2 * Copyright (c) 2003 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 #define __NO_UNDERSCORES__
28 pushl %ebp // setup mcount's frame
30 pushl %eax // save %eax
31 pushf // save interrupt state
32 cli // disable interrupts
35 // Check that this cpu is ready.
36 // This delays the start of mcounting until a cpu is really prepared.
38 movl %gs:CPU_RUNNING,%eax
43 // Test for recursion as indicated by a per-cpu flag.
44 // Skip if nested, otherwise set the flag and call the C mount().
46 movl %gs:CPU_MCOUNT_OFF,%eax
47 testl %eax,%eax // test for recursion
50 incl %gs:CPU_MCOUNT_OFF // set recursion flag
52 movl (%ebp),%eax // frame pointer of mcount's caller
53 movl 4(%eax),%eax // mcount's caller's return address
54 pushl 4(%ebp) // push selfpc parameter for mcount()
55 pushl %eax // push frompc parameter for mcount()
56 call _mcount // call the C mcount
57 addl $8,%esp // pop args
59 decl %gs:CPU_MCOUNT_OFF // turn off recursion flag
61 popf // restore interrupt state
63 movl %ebp,%esp // tear down mcount's frame