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