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