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