1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1994, by Sun Microsytems, Inc. 24*0Sstevel@tonic-gate */ 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate #ifndef _TNF_TRACE_H 27*0Sstevel@tonic-gate #define _TNF_TRACE_H 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #include <sys/types.h> 32*0Sstevel@tonic-gate #include <sys/time.h> 33*0Sstevel@tonic-gate #include <sys/tnf_probe.h> 34*0Sstevel@tonic-gate #include <sys/thread.h> 35*0Sstevel@tonic-gate #include <sys/processor.h> 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include "tnf_buf.h" 38*0Sstevel@tonic-gate #include "tnf_types.h" 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Minimum and default size of trace file 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define TNF_TRACE_FILE_MIN (128 * 1024) 45*0Sstevel@tonic-gate #define TNF_TRACE_FILE_DEFAULT (1 * 1024 * 1024) 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate /* 48*0Sstevel@tonic-gate * Specification of index field of probe control block 49*0Sstevel@tonic-gate */ 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #define PROBE_INDEX_TYPE_MASK 0x3 52*0Sstevel@tonic-gate #define PROBE_INDEX_MEM_PTR 0x0 /* index is a normal memory ptr */ 53*0Sstevel@tonic-gate #define PROBE_INDEX_FILE_PTR 0x1 /* index is a file abs ptr */ 54*0Sstevel@tonic-gate #define PROBE_INDEX_LOW_MASK 0xffff0000 55*0Sstevel@tonic-gate #define PROBE_INDEX_SHIFT 16 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate #define PROBE_IS_FILE_PTR(x) \ 58*0Sstevel@tonic-gate (((x) & PROBE_INDEX_TYPE_MASK) == PROBE_INDEX_FILE_PTR) 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate #define ATTR_SEPARATOR ';' 61*0Sstevel@tonic-gate #define VAL_SEPARATOR ' ' 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* 64*0Sstevel@tonic-gate * Flags in proc struct 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate #define PROC_F_FILTER 0x1 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate #define PROC_IS_FILTER(pp) ((pp)->p_tnf_flags & PROC_F_FILTER) 69*0Sstevel@tonic-gate #define PROC_FILTER_SET(pp) ((pp)->p_tnf_flags |= PROC_F_FILTER) 70*0Sstevel@tonic-gate #define PROC_FILTER_CLR(pp) ((pp)->p_tnf_flags &= ~PROC_F_FILTER) 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate /* 73*0Sstevel@tonic-gate * In-memory scheduling info, maintained per thread 74*0Sstevel@tonic-gate */ 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate typedef struct { 77*0Sstevel@tonic-gate tnf_record_p record_p; 78*0Sstevel@tonic-gate tnf_uint32_t record_gen; 79*0Sstevel@tonic-gate hrtime_t time_base; 80*0Sstevel@tonic-gate processorid_t cpuid; 81*0Sstevel@tonic-gate } tnf_schedule_t; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* 84*0Sstevel@tonic-gate * Per-thread tracing operations and state 85*0Sstevel@tonic-gate */ 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate struct _tnf_ops { 88*0Sstevel@tonic-gate char mode; /* allocation mode */ 89*0Sstevel@tonic-gate tnf_byte_lock_t busy; /* currently in a probe */ 90*0Sstevel@tonic-gate TNFW_B_WCB wcb; /* write control info */ 91*0Sstevel@tonic-gate tnf_schedule_t schedule; /* scheduling info */ 92*0Sstevel@tonic-gate }; 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 95*0Sstevel@tonic-gate * File layout of a kernel schedule record 96*0Sstevel@tonic-gate */ 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate typedef struct { 99*0Sstevel@tonic-gate tnf_tag_t tag; 100*0Sstevel@tonic-gate tnf_kthread_id_t tid; 101*0Sstevel@tonic-gate tnf_lwpid_t lwpid; 102*0Sstevel@tonic-gate tnf_pid_t pid; 103*0Sstevel@tonic-gate /* 104*0Sstevel@tonic-gate * time base should be on a double word boundary to avoid pads 105*0Sstevel@tonic-gate */ 106*0Sstevel@tonic-gate tnf_time_base_t time_base; 107*0Sstevel@tonic-gate tnf_cpuid_t cpuid; 108*0Sstevel@tonic-gate } tnf_schedule_prototype_t; 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate /* 111*0Sstevel@tonic-gate * File layout of a probe (event tag) record 112*0Sstevel@tonic-gate */ 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate typedef struct { 115*0Sstevel@tonic-gate tnf_tag_t tag; 116*0Sstevel@tonic-gate tnf_name_t name; 117*0Sstevel@tonic-gate tnf_properties_t properties; 118*0Sstevel@tonic-gate tnf_slot_types_t slot_types; 119*0Sstevel@tonic-gate tnf_type_size_t type_size; 120*0Sstevel@tonic-gate tnf_slot_names_t slot_names; 121*0Sstevel@tonic-gate tnf_string_t string; /* XXX detail */ 122*0Sstevel@tonic-gate } tnf_probe_prototype_t; 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* 125*0Sstevel@tonic-gate * Tag data variables 126*0Sstevel@tonic-gate */ 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate extern tnf_tag_data_t *tnf_probe_type_tag_data; 129*0Sstevel@tonic-gate extern tnf_tag_data_t *tnf_kernel_schedule_tag_data; 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate /* 132*0Sstevel@tonic-gate * 133*0Sstevel@tonic-gate */ 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate extern size_t tnf_trace_file_size; 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate /* 138*0Sstevel@tonic-gate * Function prototypes 139*0Sstevel@tonic-gate */ 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate /* Encoder functions */ 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate tnf_record_p tnf_kernel_schedule(tnf_ops_t *, tnf_schedule_t *); 144*0Sstevel@tonic-gate uintptr_t tnf_probe_tag(tnf_ops_t *, tnf_probe_control_t *); 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate /* Trace functions */ 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate void *tnf_trace_alloc(tnf_ops_t *, tnf_probe_control_t *, tnf_probe_setup_t *); 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate void tnf_trace_commit(tnf_probe_setup_t *); 151*0Sstevel@tonic-gate void tnf_trace_rollback(tnf_probe_setup_t *); 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate /* Trace control functions */ 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate void tnf_trace_init(void); 156*0Sstevel@tonic-gate void tnf_trace_on(void); 157*0Sstevel@tonic-gate void tnf_trace_off(void); 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate #endif /* _TNF_TRACE_H */ 160