Back to home page

LXR

 
 

    


0001 /*
0002  * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
0003  *
0004  * Based on alpha version.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License
0008  * as published by the Free Software Foundation; either version
0009  * 2 of the License, or (at your option) any later version.
0010  */
0011 
0012 #ifndef _ASM_POWERPC_OPROFILE_IMPL_H
0013 #define _ASM_POWERPC_OPROFILE_IMPL_H
0014 #ifdef __KERNEL__
0015 
0016 #define OP_MAX_COUNTER 8
0017 
0018 /* Per-counter configuration as set via oprofilefs.  */
0019 struct op_counter_config {
0020     unsigned long enabled;
0021     unsigned long event;
0022     unsigned long count;
0023     /* Classic doesn't support per-counter user/kernel selection */
0024     unsigned long kernel;
0025     unsigned long user;
0026     unsigned long unit_mask;
0027 };
0028 
0029 /* System-wide configuration as set via oprofilefs.  */
0030 struct op_system_config {
0031 #ifdef CONFIG_PPC64
0032     unsigned long mmcr0;
0033     unsigned long mmcr1;
0034     unsigned long mmcra;
0035 #ifdef CONFIG_OPROFILE_CELL
0036     /* Register for oprofile user tool to check cell kernel profiling
0037      * support.
0038      */
0039     unsigned long cell_support;
0040 #endif
0041 #endif
0042     unsigned long enable_kernel;
0043     unsigned long enable_user;
0044 };
0045 
0046 /* Per-arch configuration */
0047 struct op_powerpc_model {
0048     int (*reg_setup) (struct op_counter_config *,
0049                struct op_system_config *,
0050                int num_counters);
0051     int  (*cpu_setup) (struct op_counter_config *);
0052     int  (*start) (struct op_counter_config *);
0053     int  (*global_start) (struct op_counter_config *);
0054     void (*stop) (void);
0055     void (*global_stop) (void);
0056     int (*sync_start)(void);
0057     int (*sync_stop)(void);
0058     void (*handle_interrupt) (struct pt_regs *,
0059                   struct op_counter_config *);
0060     int num_counters;
0061 };
0062 
0063 extern struct op_powerpc_model op_model_fsl_emb;
0064 extern struct op_powerpc_model op_model_power4;
0065 extern struct op_powerpc_model op_model_7450;
0066 extern struct op_powerpc_model op_model_cell;
0067 extern struct op_powerpc_model op_model_pa6t;
0068 
0069 
0070 /* All the classic PPC parts use these */
0071 static inline unsigned int classic_ctr_read(unsigned int i)
0072 {
0073     switch(i) {
0074     case 0:
0075         return mfspr(SPRN_PMC1);
0076     case 1:
0077         return mfspr(SPRN_PMC2);
0078     case 2:
0079         return mfspr(SPRN_PMC3);
0080     case 3:
0081         return mfspr(SPRN_PMC4);
0082     case 4:
0083         return mfspr(SPRN_PMC5);
0084     case 5:
0085         return mfspr(SPRN_PMC6);
0086 
0087 /* No PPC32 chip has more than 6 so far */
0088 #ifdef CONFIG_PPC64
0089     case 6:
0090         return mfspr(SPRN_PMC7);
0091     case 7:
0092         return mfspr(SPRN_PMC8);
0093 #endif
0094     default:
0095         return 0;
0096     }
0097 }
0098 
0099 static inline void classic_ctr_write(unsigned int i, unsigned int val)
0100 {
0101     switch(i) {
0102     case 0:
0103         mtspr(SPRN_PMC1, val);
0104         break;
0105     case 1:
0106         mtspr(SPRN_PMC2, val);
0107         break;
0108     case 2:
0109         mtspr(SPRN_PMC3, val);
0110         break;
0111     case 3:
0112         mtspr(SPRN_PMC4, val);
0113         break;
0114     case 4:
0115         mtspr(SPRN_PMC5, val);
0116         break;
0117     case 5:
0118         mtspr(SPRN_PMC6, val);
0119         break;
0120 
0121 /* No PPC32 chip has more than 6, yet */
0122 #ifdef CONFIG_PPC64
0123     case 6:
0124         mtspr(SPRN_PMC7, val);
0125         break;
0126     case 7:
0127         mtspr(SPRN_PMC8, val);
0128         break;
0129 #endif
0130     default:
0131         break;
0132     }
0133 }
0134 
0135 
0136 extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth);
0137 
0138 #endif /* __KERNEL__ */
0139 #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */