]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/Performance.s
xnu-1228.3.13.tar.gz
[apple/xnu.git] / osfmk / ppc / Performance.s
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT_INTERNAL_USE_ONLY@
30 */
31
32/*
33 Performance.s
34
35 Handle things that should are related to the hardware performance monitor
36
37 Lovingly crafted by Bill Angell using traditional methods and only natural or recycled materials.
38 No more than 7500 chinchillas were killed in the production of the code.
39
40*/
41
42#include <ppc/asm.h>
43#include <ppc/proc_reg.h>
1c79356b
A
44#include <ppc/exception.h>
45#include <ppc/Performance.h>
46#include <mach/machine/vm_param.h>
47#include <assym.s>
48
49#if PERF_HIST
50/*
51 * This routine is used to interface to the performance monitor
52 */
53
54ENTRY(PerfCtl, TAG_NO_FRAME_USED)
55
56 lis r0,PerfCtlCall@h /* Get the top part of the SC number */
57 ori r0,r0,PerfCtlCall@l /* and the bottom part */
58 sc /* Do it to it */
59 blr /* Bye bye, Birdie... */
60
61
62ENTRY(PerfCtlLL, TAG_NO_FRAME_USED)
63
64 cmplwi r3,maxPerf /* See if we are within range */
65 mflr r11 /* Get the return point */
66 li r3,0 /* Show failure */
67 bgelrl- /* Load up current address and, also, leave if out of range */
68prfBase: mflr r12 /* Get our address */
69 rlwinm r10,r3,2,0,31 /* Get displacement into branch table */
70 addi r12,r12,prfBrnch-prfBase /* Point to the branch address */
71 add r12,r12,r10 /* Point to the branch */
72 mtlr r12 /* Get it in the link register */
73 blr /* Vector to the specific performance command... */
74
75prfBrnch: b prfClear /* Clear the histogram table */
76 b prfStart /* Start the performance monitor */
77 b prfStop /* Stop the performance monitor */
78 b prfMap /* Map the histogram into an address space */
79 .equ maxPerf, (.-prfBrnch)/4 /* Set the highest valid address */
80
81/*
82 * Clear the monitor histogram
83 */
84prfClear:
85 li r4,PMIhist@l /* We know this to be in page 0, so no need for the high part */
86 lis r8,PMIHIST_SIZE@h /* Get high half of the table size */
87 lwz r4,0(r4) /* Get the real address of the histgram */
88 ori r8,r8,PMIHIST_SIZE@l /* Get the low half of the table size */
89 li r6,32 /* Get a displacement */
90 li r3,1 /* Set up a good return code */
91 mtlr r11 /* Restore the return address */
92
93clrloop: subi r8,r8,32 /* Back off a cache line */
94 dcbz 0,r4 /* Do the even line */
95 sub. r8,r8,r6 /* Back off a second time (we only do this to generate a CR */
96 dcbz r6,r4 /* Clear the even line */
97 addi r4,r4,64 /* Move up to every other line */
98 bgt+ clrloop /* Go until we've done it all... */
99
100 blr /* Leave... */
101
102/*
103 * Start the monitor histogram
104 */
105 prfStart:
106 mtlr r11 /* Restore the return address */
107 blr /* Return... */
108
109/*
110 * Stop the monitor histogram
111 */
112 prfStop:
113 mtlr r11 /* Restore the return address */
114 blr /* Return... */
115
116/*
117 * Maps the monitor histogram into another address space
118 */
119 prfMap:
120 mtlr r11 /* Restore the return address */
121 blr /* Return... */
122
123#endif
124