KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
perfctr.h File Reference

Low-level performance counter API. More...

#include <stdint.h>
#include <stdbool.h>
#include <sys/cdefs.h>

Go to the source code of this file.

Enumerations

enum  perf_cntr_t { PRFC0 , PRFC1 }
 Identifiers for the two SH4 performance counters. More...
 
enum  perf_cntr_clock_t { PMCR_COUNT_CPU_CYCLES , PMCR_COUNT_RATIO_CYCLES }
 Count clock types for the SH4 performance counters. More...
 
enum  perf_cntr_event_t {
  PMCR_INIT_NO_MODE = 0x00 , PMCR_OPERAND_READ_ACCESS_MODE = 0x01 , PMCR_OPERAND_WRITE_ACCESS_MODE = 0x02 , PMCR_UTLB_MISS_MODE = 0x03 ,
  PMCR_OPERAND_CACHE_READ_MISS_MODE = 0x04 , PMCR_OPERAND_CACHE_WRITE_MISS_MODE = 0x05 , PMCR_INSTRUCTION_FETCH_MODE = 0x06 , PMCR_INSTRUCTION_TLB_MISS_MODE = 0x07 ,
  PMCR_INSTRUCTION_CACHE_MISS_MODE = 0x08 , PMCR_ALL_OPERAND_ACCESS_MODE = 0x09 , PMCR_ALL_INSTRUCTION_FETCH_MODE = 0x0a , PMCR_ON_CHIP_RAM_OPERAND_ACCESS_MODE = 0x0b ,
  PMCR_ON_CHIP_IO_ACCESS_MODE = 0x0d , PMCR_OPERAND_ACCESS_MODE = 0x0e , PMCR_OPERAND_CACHE_MISS_MODE = 0x0f , PMCR_BRANCH_ISSUED_MODE = 0x10 ,
  PMCR_BRANCH_TAKEN_MODE = 0x11 , PMCR_SUBROUTINE_ISSUED_MODE = 0x12 , PMCR_INSTRUCTION_ISSUED_MODE = 0x13 , PMCR_PARALLEL_INSTRUCTION_ISSUED_MODE = 0x14 ,
  PMCR_FPU_INSTRUCTION_ISSUED_MODE = 0x15 , PMCR_INTERRUPT_COUNTER_MODE = 0x16 , PMCR_NMI_COUNTER_MODE = 0x17 , PMCR_TRAPA_INSTRUCTION_COUNTER_MODE = 0x18 ,
  PMCR_UBC_A_MATCH_MODE = 0x19 , PMCR_UBC_B_MATCH_MODE = 0x1a , PMCR_INSTRUCTION_CACHE_FILL_MODE = 0x21 , PMCR_OPERAND_CACHE_FILL_MODE = 0x22 ,
  PMCR_ELAPSED_TIME_MODE = 0x23 , PMCR_PIPELINE_FREEZE_BY_ICACHE_MISS_MODE = 0x24 , PMCR_PIPELINE_FREEZE_BY_DCACHE_MISS_MODE = 0x25 , PMCR_PIPELINE_FREEZE_BY_BRANCH_MODE = 0x27 ,
  PMCR_PIPELINE_FREEZE_BY_CPU_REGISTER_MODE = 0x28 , PMCR_PIPELINE_FREEZE_BY_FPU_MODE = 0x29
}
 Performance Counter Event Modes. More...
 

Functions

bool perf_cntr_config (perf_cntr_t counter, perf_cntr_event_t *event_mode, perf_cntr_clock_t *clock_type)
 Get a performance counter's settings.
 
void perf_cntr_start (perf_cntr_t counter, perf_cntr_event_t event_mode, perf_cntr_clock_t clock_type)
 Start a performance counter.
 
void perf_cntr_stop (perf_cntr_t counter)
 Stop a performance counter.
 
void perf_cntr_resume (perf_cntr_t counter)
 Resume a performance counter.
 
void perf_cntr_clear (perf_cntr_t counter)
 Clear a performance counter.
 
uint64_t perf_cntr_count (perf_cntr_t counter)
 Obtain the count of a performance counter.
 
void perf_cntr_timer_enable (void)
 Enable the nanosecond timer.
 
void perf_cntr_timer_disable (void)
 Disable the nanosecond timer.
 
bool perf_cntr_timer_enabled (void)
 Check whether the nanosecond timer is enabled.
 
uint64_t perf_cntr_timer_ns (void)
 Gets elapsed CPU time (in nanoseconds)
 

Detailed Description

Low-level performance counter API.

This file contains the low-level driver for interacting with and utilizing the SH4's two Performance Counters, which are primarily used for profiling and performance tuning.

Author
MoopTheHedgehog
Andy Barajas
Falco Girgis