18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2001-2003 Hewlett-Packard Co 48c2ecf20Sopenharmony_ci * Stephane Eranian <eranian@hpl.hp.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_IA64_PERFMON_H 88c2ecf20Sopenharmony_ci#define _UAPI_ASM_IA64_PERFMON_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci * perfmon commands supported on all CPU models 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci#define PFM_WRITE_PMCS 0x01 148c2ecf20Sopenharmony_ci#define PFM_WRITE_PMDS 0x02 158c2ecf20Sopenharmony_ci#define PFM_READ_PMDS 0x03 168c2ecf20Sopenharmony_ci#define PFM_STOP 0x04 178c2ecf20Sopenharmony_ci#define PFM_START 0x05 188c2ecf20Sopenharmony_ci#define PFM_ENABLE 0x06 /* obsolete */ 198c2ecf20Sopenharmony_ci#define PFM_DISABLE 0x07 /* obsolete */ 208c2ecf20Sopenharmony_ci#define PFM_CREATE_CONTEXT 0x08 218c2ecf20Sopenharmony_ci#define PFM_DESTROY_CONTEXT 0x09 /* obsolete use close() */ 228c2ecf20Sopenharmony_ci#define PFM_RESTART 0x0a 238c2ecf20Sopenharmony_ci#define PFM_PROTECT_CONTEXT 0x0b /* obsolete */ 248c2ecf20Sopenharmony_ci#define PFM_GET_FEATURES 0x0c 258c2ecf20Sopenharmony_ci#define PFM_DEBUG 0x0d 268c2ecf20Sopenharmony_ci#define PFM_UNPROTECT_CONTEXT 0x0e /* obsolete */ 278c2ecf20Sopenharmony_ci#define PFM_GET_PMC_RESET_VAL 0x0f 288c2ecf20Sopenharmony_ci#define PFM_LOAD_CONTEXT 0x10 298c2ecf20Sopenharmony_ci#define PFM_UNLOAD_CONTEXT 0x11 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* 328c2ecf20Sopenharmony_ci * PMU model specific commands (may not be supported on all PMU models) 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci#define PFM_WRITE_IBRS 0x20 358c2ecf20Sopenharmony_ci#define PFM_WRITE_DBRS 0x21 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * context flags 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci#define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user level notifications */ 418c2ecf20Sopenharmony_ci#define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */ 428c2ecf20Sopenharmony_ci#define PFM_FL_OVFL_NO_MSG 0x80 /* do not post overflow/end messages for notification */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* 458c2ecf20Sopenharmony_ci * event set flags 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci#define PFM_SETFL_EXCL_IDLE 0x01 /* exclude idle task (syswide only) XXX: DO NOT USE YET */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* 508c2ecf20Sopenharmony_ci * PMC flags 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci#define PFM_REGFL_OVFL_NOTIFY 0x1 /* send notification on overflow */ 538c2ecf20Sopenharmony_ci#define PFM_REGFL_RANDOM 0x2 /* randomize sampling interval */ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* 568c2ecf20Sopenharmony_ci * PMD/PMC/IBR/DBR return flags (ignored on input) 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * Those flags are used on output and must be checked in case EAGAIN is returned 598c2ecf20Sopenharmony_ci * by any of the calls using a pfarg_reg_t or pfarg_dbreg_t structure. 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci#define PFM_REG_RETFL_NOTAVAIL (1UL<<31) /* set if register is implemented but not available */ 628c2ecf20Sopenharmony_ci#define PFM_REG_RETFL_EINVAL (1UL<<30) /* set if register entry is invalid */ 638c2ecf20Sopenharmony_ci#define PFM_REG_RETFL_MASK (PFM_REG_RETFL_NOTAVAIL|PFM_REG_RETFL_EINVAL) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define PFM_REG_HAS_ERROR(flag) (((flag) & PFM_REG_RETFL_MASK) != 0) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_citypedef unsigned char pfm_uuid_t[16]; /* custom sampling buffer identifier type */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* 708c2ecf20Sopenharmony_ci * Request structure used to define a context 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_citypedef struct { 738c2ecf20Sopenharmony_ci pfm_uuid_t ctx_smpl_buf_id; /* which buffer format to use (if needed) */ 748c2ecf20Sopenharmony_ci unsigned long ctx_flags; /* noblock/block */ 758c2ecf20Sopenharmony_ci unsigned short ctx_nextra_sets; /* number of extra event sets (you always get 1) */ 768c2ecf20Sopenharmony_ci unsigned short ctx_reserved1; /* for future use */ 778c2ecf20Sopenharmony_ci int ctx_fd; /* return arg: unique identification for context */ 788c2ecf20Sopenharmony_ci void *ctx_smpl_vaddr; /* return arg: virtual address of sampling buffer, is used */ 798c2ecf20Sopenharmony_ci unsigned long ctx_reserved2[11];/* for future use */ 808c2ecf20Sopenharmony_ci} pfarg_context_t; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* 838c2ecf20Sopenharmony_ci * Request structure used to write/read a PMC or PMD 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_citypedef struct { 868c2ecf20Sopenharmony_ci unsigned int reg_num; /* which register */ 878c2ecf20Sopenharmony_ci unsigned short reg_set; /* event set for this register */ 888c2ecf20Sopenharmony_ci unsigned short reg_reserved1; /* for future use */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci unsigned long reg_value; /* initial pmc/pmd value */ 918c2ecf20Sopenharmony_ci unsigned long reg_flags; /* input: pmc/pmd flags, return: reg error */ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci unsigned long reg_long_reset; /* reset after buffer overflow notification */ 948c2ecf20Sopenharmony_ci unsigned long reg_short_reset; /* reset after counter overflow */ 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci unsigned long reg_reset_pmds[4]; /* which other counters to reset on overflow */ 978c2ecf20Sopenharmony_ci unsigned long reg_random_seed; /* seed value when randomization is used */ 988c2ecf20Sopenharmony_ci unsigned long reg_random_mask; /* bitmask used to limit random value */ 998c2ecf20Sopenharmony_ci unsigned long reg_last_reset_val;/* return: PMD last reset value */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci unsigned long reg_smpl_pmds[4]; /* which pmds are accessed when PMC overflows */ 1028c2ecf20Sopenharmony_ci unsigned long reg_smpl_eventid; /* opaque sampling event identifier */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci unsigned long reg_reserved2[3]; /* for future use */ 1058c2ecf20Sopenharmony_ci} pfarg_reg_t; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_citypedef struct { 1088c2ecf20Sopenharmony_ci unsigned int dbreg_num; /* which debug register */ 1098c2ecf20Sopenharmony_ci unsigned short dbreg_set; /* event set for this register */ 1108c2ecf20Sopenharmony_ci unsigned short dbreg_reserved1; /* for future use */ 1118c2ecf20Sopenharmony_ci unsigned long dbreg_value; /* value for debug register */ 1128c2ecf20Sopenharmony_ci unsigned long dbreg_flags; /* return: dbreg error */ 1138c2ecf20Sopenharmony_ci unsigned long dbreg_reserved2[1]; /* for future use */ 1148c2ecf20Sopenharmony_ci} pfarg_dbreg_t; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_citypedef struct { 1178c2ecf20Sopenharmony_ci unsigned int ft_version; /* perfmon: major [16-31], minor [0-15] */ 1188c2ecf20Sopenharmony_ci unsigned int ft_reserved; /* reserved for future use */ 1198c2ecf20Sopenharmony_ci unsigned long reserved[4]; /* for future use */ 1208c2ecf20Sopenharmony_ci} pfarg_features_t; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_citypedef struct { 1238c2ecf20Sopenharmony_ci pid_t load_pid; /* process to load the context into */ 1248c2ecf20Sopenharmony_ci unsigned short load_set; /* first event set to load */ 1258c2ecf20Sopenharmony_ci unsigned short load_reserved1; /* for future use */ 1268c2ecf20Sopenharmony_ci unsigned long load_reserved2[3]; /* for future use */ 1278c2ecf20Sopenharmony_ci} pfarg_load_t; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_citypedef struct { 1308c2ecf20Sopenharmony_ci int msg_type; /* generic message header */ 1318c2ecf20Sopenharmony_ci int msg_ctx_fd; /* generic message header */ 1328c2ecf20Sopenharmony_ci unsigned long msg_ovfl_pmds[4]; /* which PMDs overflowed */ 1338c2ecf20Sopenharmony_ci unsigned short msg_active_set; /* active set at the time of overflow */ 1348c2ecf20Sopenharmony_ci unsigned short msg_reserved1; /* for future use */ 1358c2ecf20Sopenharmony_ci unsigned int msg_reserved2; /* for future use */ 1368c2ecf20Sopenharmony_ci unsigned long msg_tstamp; /* for perf tuning/debug */ 1378c2ecf20Sopenharmony_ci} pfm_ovfl_msg_t; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_citypedef struct { 1408c2ecf20Sopenharmony_ci int msg_type; /* generic message header */ 1418c2ecf20Sopenharmony_ci int msg_ctx_fd; /* generic message header */ 1428c2ecf20Sopenharmony_ci unsigned long msg_tstamp; /* for perf tuning */ 1438c2ecf20Sopenharmony_ci} pfm_end_msg_t; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_citypedef struct { 1468c2ecf20Sopenharmony_ci int msg_type; /* type of the message */ 1478c2ecf20Sopenharmony_ci int msg_ctx_fd; /* unique identifier for the context */ 1488c2ecf20Sopenharmony_ci unsigned long msg_tstamp; /* for perf tuning */ 1498c2ecf20Sopenharmony_ci} pfm_gen_msg_t; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define PFM_MSG_OVFL 1 /* an overflow happened */ 1528c2ecf20Sopenharmony_ci#define PFM_MSG_END 2 /* task to which context was attached ended */ 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_citypedef union { 1558c2ecf20Sopenharmony_ci pfm_ovfl_msg_t pfm_ovfl_msg; 1568c2ecf20Sopenharmony_ci pfm_end_msg_t pfm_end_msg; 1578c2ecf20Sopenharmony_ci pfm_gen_msg_t pfm_gen_msg; 1588c2ecf20Sopenharmony_ci} pfm_msg_t; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/* 1618c2ecf20Sopenharmony_ci * Define the version numbers for both perfmon as a whole and the sampling buffer format. 1628c2ecf20Sopenharmony_ci */ 1638c2ecf20Sopenharmony_ci#define PFM_VERSION_MAJ 2U 1648c2ecf20Sopenharmony_ci#define PFM_VERSION_MIN 0U 1658c2ecf20Sopenharmony_ci#define PFM_VERSION (((PFM_VERSION_MAJ&0xffff)<<16)|(PFM_VERSION_MIN & 0xffff)) 1668c2ecf20Sopenharmony_ci#define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff) 1678c2ecf20Sopenharmony_ci#define PFM_VERSION_MINOR(x) ((x) & 0xffff) 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* 1718c2ecf20Sopenharmony_ci * miscellaneous architected definitions 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci#define PMU_FIRST_COUNTER 4 /* first counting monitor (PMC/PMD) */ 1748c2ecf20Sopenharmony_ci#define PMU_MAX_PMCS 256 /* maximum architected number of PMC registers */ 1758c2ecf20Sopenharmony_ci#define PMU_MAX_PMDS 256 /* maximum architected number of PMD registers */ 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_IA64_PERFMON_H */ 179