1 // CPU Performance monitoring counters API 2 3 /*---------------------------------------------------------------------------* 4 Project: PMCPU Library 5 File: pmcpu.h 6 7 Copyright (C) 2011 Nintendo. All rights reserved. 8 9 These coded instructions, statements, and computer programs contain 10 proprietary information of Nintendo of America Inc. and/or Nintendo 11 Company Ltd., and are protected by Federal copyright law. They may 12 not be disclosed to third parties or copied or duplicated in any form, 13 in whole or in part, without the prior written consent of Nintendo. 14 15 *---------------------------------------------------------------------------*/ 16 17 #ifndef __PMCPU_H 18 #define __PMCPU_H 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 25 #include <cafe/base/ppc_asm_user.h> 26 #include <cafe/os/OSPerformanceMonitor.h> 27 typedef enum { 28 PMC_ACTION_NONE, 29 PMC_ACTION_STOP, 30 PMC_ACTION_CLEAR_START, 31 PMC_ACTION_RESUME, 32 PMC_ACTION_CLEAR 33 } PMCPUAction; //This is not used in current version - for later use 34 35 36 37 typedef enum { 38 PMC_MODE_ALL, 39 PMC_MODE_USER, 40 PMC_MODE_SUPERVISOR 41 } PMCPUMode; //This is not used in current version - for later use 42 43 44 45 // Basic structure of the Group to be used for 46 typedef struct { 47 u32 pmc_e1; // PMC Event for Counter 1 - Allowed events listed in ppc_asm_user.h 48 u32 pmc_e2; 49 u32 pmc_e3; 50 u32 pmc_e4; 51 u32 pm_mask; // Internal mask value for the group 52 u32 pmc1; // Counter values after a read operation as set according to PMCSetGroup 53 u32 pmc2; 54 u32 pmc3; 55 u32 pmc4; 56 } PMCPUGroup; 57 58 59 // Set Group pmc1 through pmc4 are the events desired, 0 for no use of the counter 60 void PMCPUSetGroup(PMCPUGroup *group, u32 e1, u32 e2, u32 e3, u32 e4); 61 62 //Start counting for *group -- this also acts as a resume 63 void PMCPUStartGroup(PMCPUGroup *group); 64 65 void PMCPUResetStartGroup(PMCPUGroup *pmc_g); 66 67 //Stop counting for *group 68 void PMCPUStopGroup(PMCPUGroup *group); 69 70 71 //Read the counter values for the group. e.g. group->pmc1 gives the read out of counter 1, etc. 72 void PMCPUReadGroup(PMCPUGroup *group); 73 74 //Reset the group counters to zero 75 void PMCPUResetGroup(PMCPUGroup *group); 76 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif // __PMPU_H 83