6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / uts / common / sys / kcpc.h
blobf30e093f78aa3d8767a7bdd1d09702e16dcd1047
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_KCPC_H
27 #define _SYS_KCPC_H
29 #include <sys/cpc_impl.h>
30 #include <sys/ksynch.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * Kernel clients need this file in order to know what a request is and how to
38 * program one.
41 typedef struct _kcpc_set kcpc_set_t;
43 #ifdef _KERNEL
46 * Forward declarations.
48 struct _kthread;
49 struct cpu;
50 typedef struct _kcpc_request kcpc_request_t;
51 struct __pcbe_ops;
53 #define KCPC_SET_BOUND 0x0001 /* Used in ks_state */
55 struct _kcpc_set {
56 int ks_flags;
57 int ks_nreqs; /* Number of reqs */
58 kcpc_request_t *ks_req; /* Pointer to reqs */
59 uint64_t *ks_data; /* Data store for this set */
60 kcpc_ctx_t *ks_ctx; /* ctx this set belongs to */
61 ushort_t ks_state; /* Set is bound or unbound */
62 kmutex_t ks_lock; /* Protects ks_state */
63 kcondvar_t ks_condv; /* Wait for bind to complete */
66 struct _kcpc_request {
67 void *kr_config;
68 int kr_index; /* indx of data for this req */
69 int kr_picnum; /* Number of phys pic */
70 kcpc_pic_t *kr_picp; /* Ptr to PIC in context */
71 uint64_t *kr_data; /* Ptr to virtual 64-bit pic */
72 char kr_event[CPC_MAX_EVENT_LEN];
73 uint64_t kr_preset;
74 uint_t kr_flags;
75 uint_t kr_nattrs;
76 kcpc_attr_t *kr_attr;
80 * Bind the set to the indicated thread.
81 * Returns 0 on success, or an errno in case of error. If EINVAL is returned,
82 * a specific error code will be returned in the subcode parameter.
84 extern int kcpc_bind_thread(kcpc_set_t *set, struct _kthread *t, int *subcode);
87 * Bind the set to the indicated CPU.
88 * Same return convention as kcpc_bind_thread().
90 extern int kcpc_bind_cpu(kcpc_set_t *set, int cpuid, int *subcode);
93 * Request the system to sample the current state of the set into users buf.
95 extern int kcpc_sample(kcpc_set_t *set, uint64_t *buf, hrtime_t *hrtime,
96 uint64_t *tick);
99 * Unbind a request and release the associated resources.
101 extern int kcpc_unbind(kcpc_set_t *set);
104 * Preset the indicated request's counter and underlying PCBE config to the
105 * given value.
107 extern int kcpc_preset(kcpc_set_t *set, int index, uint64_t preset);
110 * Unfreeze the set and get it counting again.
112 extern int kcpc_restart(kcpc_set_t *set);
114 extern int kcpc_enable(struct _kthread *t, int cmd, int enable);
117 * Mark a thread's CPC context, if it exists, INVALID.
119 extern void kcpc_invalidate(struct _kthread *t);
121 extern int kcpc_overflow_ast(void);
122 extern uint_t kcpc_hw_overflow_intr(caddr_t, caddr_t);
123 extern int kcpc_hw_cpu_hook(int cpuid, ulong_t *kcpc_cpumap);
124 extern int kcpc_hw_lwp_hook(void);
125 extern void kcpc_idle_save(struct cpu *cp);
126 extern void kcpc_idle_restore(struct cpu *cp);
128 extern krwlock_t kcpc_cpuctx_lock; /* lock for 'kcpc_cpuctx' below */
129 extern int kcpc_cpuctx; /* number of cpu-specific contexts */
132 * 'dtrace_cpc_in_use' contains the number of currently active cpc provider
133 * based enablings. See the block comment in uts/common/os/dtrace_subr.c for
134 * details of its actual usage.
136 extern uint32_t dtrace_cpc_in_use;
137 extern void (*dtrace_cpc_fire)(uint64_t);
139 extern void kcpc_free_set(kcpc_set_t *set);
141 extern void *kcpc_next_config(void *token, void *current,
142 uint64_t **data);
143 extern void kcpc_invalidate_config(void *token);
144 extern char *kcpc_list_attrs(void);
145 extern char *kcpc_list_events(uint_t pic);
146 extern void kcpc_free_configs(kcpc_set_t *set);
147 extern uint_t kcpc_pcbe_capabilities(void);
148 extern int kcpc_pcbe_loaded(void);
151 * Called by a PCBE to determine if nonprivileged access to counters should be
152 * allowed. Returns non-zero if non-privileged access is allowed, 0 if not.
154 extern int kcpc_allow_nonpriv(void *token);
156 extern void kcpc_register_pcbe(struct __pcbe_ops *);
158 #endif /* _KERNEL */
160 #ifdef __cplusplus
162 #endif
164 #endif /* _SYS_KCPC_H */