cpc_impl.h revision af4595ed84fc11745bc4136f8510c528996355f6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CPC_IMPL_H
#define _SYS_CPC_IMPL_H
#if defined(_KERNEL) && defined(_MULTI_DATAMODEL)
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char *ca_name;
} cpc_attr_t;
/*
* Flag arguments to cpc_bind_event and cpc_ctx_bind_event
*/
#define CPC_BIND_LWP_INHERIT (0x1)
#define CPC_BIND_EMT_OVF (0x2)
#define CPC_OVF_NOTIFY_EMT 0x1
#define CPC_COUNT_USER 0x2
#define CPC_COUNT_SYSTEM 0x4
#define CPC_COUNT_HV 0x8
#define CPC_COUNT_SAMPLE_MODE 0x10
#define KCPC_REQ_VALID_FLAGS(flags) \
/*
* CPC Capabilities
*/
#define CPC_CAP_OVERFLOW_INTERRUPT 0x1
#define CPC_CAP_OVERFLOW_PRECISE 0x2
/*
* The only valid per-set flag is CPC_BIND_LWP_INHERIT, which must remain in
* cpc_event.h for backwards compatibility.
*/
#define CPC_SET_ALL_FLAGS 0x1
#define CPC_SET_VALID_FLAGS(flags) \
/*
* These system call subcodes and ioctls allow the implementation of the
* libcpc library to store and retrieve performance counter data. Subject
* to arbitrary change without notice at any time. Do not invoke them
* directly!
*/
#define CPC_BIND 0
#define CPC_SAMPLE 1
#define CPC_INVALIDATE 2
#define CPC_RELE 3
#define CPC_EVLIST_SIZE 4
#define CPC_LIST_EVENTS 5
#define CPC_ATTRLIST_SIZE 6
#define CPC_LIST_ATTRS 7
#define CPC_IMPL_NAME 8
#define CPC_CPUREF 9
#define CPC_USR_EVENTS 10
#define CPC_SYS_EVENTS 11
#define CPC_NPIC 12
#define CPC_CAPS 13
#define CPC_ENABLE 14
#define CPC_DISABLE 15
#define CPC_PRESET 16
#define CPC_RESTART 17
/*
* Forward declarations.
*/
struct _kthread;
struct _kcpc_set;
#define CPC_MAX_EVENT_LEN 512
#define CPC_MAX_ATTR_LEN 32
typedef struct _kcpc_attr {
char ka_name[CPC_MAX_ATTR_LEN];
} kcpc_attr_t;
typedef struct _kcpc_pic {
} kcpc_pic_t;
typedef struct _kcpc_ctx kcpc_ctx_t;
struct _kcpc_ctx {
int kc_cpuid; /* CPU this context is measuring */
};
typedef struct __cpc_args {
void *udata1;
void *udata2;
void *udata3;
} __cpc_args_t;
#ifdef _KERNEL
#ifdef _MULTI_DATAMODEL
typedef struct __cpc_args32 {
#endif /* _MULTI_DATAMODEL */
(CPC_HASH_BUCKETS - 1))
/*
* Context flags.
*/
/*
* PIC flags.
*/
/*
* The following flags are used by the DTrace CPU performance counter provider
* and the overflow handler. The 'DCPC_INTR_*' flags are used to synchronize
* performance counter configuration events performed by the cpc provider and
* interrupt processing carried out by the overflow handler. The 'DCPC_?MASK'
* flags are used by the dcpc provider to indicate which type of mask attribute
* a platform supports.
*/
enum dcpc_intr_state {
DCPC_INTR_INACTIVE, /* The dcpc provider is currently not in use */
DCPC_INTR_FREE, /* No config events or ovf ints in progress */
DCPC_INTR_PROCESSING, /* An overflow interrupt is being processed */
DCPC_INTR_CONFIG /* cpc subsystem being configured by dcpc */
};
enum dcpc_mask_attr {
};
#ifdef __sparc
extern uint64_t ultra_gettick(void);
#define KCPC_GET_TICK ultra_gettick
#else
#define KCPC_GET_TICK tsc_read
#endif /* __sparc */
struct cpu;
extern uint_t cpc_ncounters;
extern int kcpc_cpuctx; /* number of cpu-specific contexts */
extern void kcpc_invalidate_all(void);
extern void kcpc_passivate(void);
extern void kcpc_unregister_dcpc(void);
extern kcpc_ctx_t *kcpc_ctx_alloc(int);
extern void kcpc_ctx_free(kcpc_ctx_t *);
extern void kcpc_free_configs(struct _kcpc_set *);
#endif /* _KERNEL */
/*
* Error subcodes.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CPC_IMPL_H */