The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/osfmk/ppc/Performance.s

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    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
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   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.
   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>
   41 #include <ppc/exception.h>
   42 #include <ppc/Performance.h>
   43 #include <mach/machine/vm_param.h>
   44 #include <assym.s>
   45 
   46 #if PERF_HIST
   47 /*
   48  *                      This routine is used to interface to the performance monitor
   49  */
   50 
   51 ENTRY(PerfCtl, TAG_NO_FRAME_USED)
   52 
   53                         lis             r0,PerfCtlCall@h                                /* Get the top part of the SC number */
   54                         ori             r0,r0,PerfCtlCall@l                             /* and the bottom part */
   55                         sc                                                                              /* Do it to it */
   56                         blr                                                                             /* Bye bye, Birdie... */
   57                         
   58 
   59 ENTRY(PerfCtlLL, TAG_NO_FRAME_USED)
   60 
   61                         cmplwi  r3,maxPerf                                              /* See if we are within range */
   62                         mflr    r11                                                             /* Get the return point */
   63                         li              r3,0                                                    /* Show failure */
   64                         bgelrl-                                                                 /* Load up current address and, also, leave if out of range */
   65 prfBase:        mflr    r12                                                             /* Get our address */
   66                         rlwinm  r10,r3,2,0,31                                   /* Get displacement into branch table */
   67                         addi    r12,r12,prfBrnch-prfBase                /* Point to the branch address */
   68                         add             r12,r12,r10                                             /* Point to the branch */
   69                         mtlr    r12                                                             /* Get it in the link register */
   70                         blr                                                                             /* Vector to the specific performance command... */
   71                         
   72 prfBrnch:       b               prfClear                                                /* Clear the histogram table */
   73                         b               prfStart                                                /* Start the performance monitor */
   74                         b               prfStop                                                 /* Stop the performance monitor */
   75                         b               prfMap                                                  /* Map the histogram into an address space */
   76                         .equ    maxPerf, (.-prfBrnch)/4                 /* Set the highest valid address */
   77                         
   78 /*
   79  *                      Clear the monitor histogram
   80  */
   81 prfClear:
   82                         li              r4,PMIhist@l                                    /* We know this to be in page 0, so no need for the high part */
   83                         lis             r8,PMIHIST_SIZE@h                               /* Get high half of the table size */
   84                         lwz             r4,0(r4)                                                /* Get the real address of the histgram */
   85                         ori             r8,r8,PMIHIST_SIZE@l                    /* Get the low half of the table size */
   86                         li              r6,32                                                   /* Get a displacement */
   87                         li              r3,1                                                    /* Set up a good return code */
   88                         mtlr    r11                                                             /* Restore the return address */
   89                                                 
   90 clrloop:        subi    r8,r8,32                                                /* Back off a cache line */
   91                         dcbz    0,r4                                                    /* Do the even line */
   92                         sub.    r8,r8,r6                                                /* Back off a second time (we only do this to generate a CR */
   93                         dcbz    r6,r4                                                   /* Clear the even line */
   94                         addi    r4,r4,64                                                /* Move up to every other line */
   95                         bgt+    clrloop                                                 /* Go until we've done it all... */
   96 
   97                         blr                                                                             /* Leave... */
   98                         
   99 /*
  100  *                      Start the monitor histogram
  101  */
  102  prfStart:
  103                         mtlr    r11                                                             /* Restore the return address */
  104                         blr                                                                             /* Return... */
  105                         
  106 /*
  107  *                      Stop the monitor histogram
  108  */
  109  prfStop:
  110                         mtlr    r11                                                             /* Restore the return address */
  111                         blr                                                                             /* Return... */
  112                         
  113 /*
  114  *                      Maps the monitor histogram into another address space
  115  */
  116  prfMap:
  117                         mtlr    r11                                                             /* Restore the return address */
  118                         blr                                                                             /* Return... */
  119 
  120 #endif
  121 

Cache object: eb78e9d253d7810dca973eeb0f08ff01


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.