xref: /illumos-gate/usr/src/uts/common/sys/tnf_writer.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1994,2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_TNF_WRITER_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_TNF_WRITER_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Public interface for writing predefined TNF types
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/tnf_com.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
39*7c478bd9Sstevel@tonic-gate extern "C" {
40*7c478bd9Sstevel@tonic-gate #endif
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * Defines
44*7c478bd9Sstevel@tonic-gate  */
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #define	TNF_OFFSETOF(s, m) 	((size_t)(&(((s *)0)->m)))
47*7c478bd9Sstevel@tonic-gate #define	TNF_ALIGN(type)		TNF_OFFSETOF(struct { char _c; type _t; }, _t)
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * Typedefs
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate typedef char 		*tnf_record_p;	  /* trace buffer memory ptr */
54*7c478bd9Sstevel@tonic-gate typedef tnf_ref32_t	tnf_reference_t;  /* generic reference */
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate typedef struct _tnf_ops		tnf_ops_t; /* opaque */
57*7c478bd9Sstevel@tonic-gate typedef struct _tnf_tag_version	tnf_tag_version_t;
58*7c478bd9Sstevel@tonic-gate typedef struct _tnf_tag_data	tnf_tag_data_t;
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /*
61*7c478bd9Sstevel@tonic-gate  * In-memory reader's classification of TNF types
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate typedef enum {
65*7c478bd9Sstevel@tonic-gate 	TNF_UNKNOWN	= 0,
66*7c478bd9Sstevel@tonic-gate 	TNF_INT32,
67*7c478bd9Sstevel@tonic-gate 	TNF_UINT32,
68*7c478bd9Sstevel@tonic-gate 	TNF_INT64,
69*7c478bd9Sstevel@tonic-gate 	TNF_UINT64,
70*7c478bd9Sstevel@tonic-gate 	TNF_FLOAT32,
71*7c478bd9Sstevel@tonic-gate 	TNF_FLOAT64,
72*7c478bd9Sstevel@tonic-gate 	TNF_STRING,
73*7c478bd9Sstevel@tonic-gate 	TNF_ARRAY,
74*7c478bd9Sstevel@tonic-gate 	TNF_STRUCT,
75*7c478bd9Sstevel@tonic-gate 	TNF_OPAQUE,
76*7c478bd9Sstevel@tonic-gate #ifdef _LP64
77*7c478bd9Sstevel@tonic-gate 	TNF_ULONG = TNF_UINT64,
78*7c478bd9Sstevel@tonic-gate 	TNF_LONG = TNF_INT64
79*7c478bd9Sstevel@tonic-gate #else
80*7c478bd9Sstevel@tonic-gate 	TNF_ULONG = TNF_UINT32,
81*7c478bd9Sstevel@tonic-gate 	TNF_LONG = TNF_INT32
82*7c478bd9Sstevel@tonic-gate #endif
83*7c478bd9Sstevel@tonic-gate } tnf_arg_kind_t;
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /*
86*7c478bd9Sstevel@tonic-gate  * Structures
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate struct _tnf_tag_version {
90*7c478bd9Sstevel@tonic-gate 	size_t		version_size;	/* sizeof(tnf_tag_version_t) */
91*7c478bd9Sstevel@tonic-gate 	size_t		tag_data_size;	/* sizeof(tnf_tag_data_t) */
92*7c478bd9Sstevel@tonic-gate };
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate struct _tnf_tag_data {
95*7c478bd9Sstevel@tonic-gate 	tnf_tag_version_t *tag_version; /* TNF_TAG_VERSION */
96*7c478bd9Sstevel@tonic-gate 	tnf_record_p	(*tag_desc)(tnf_ops_t *, tnf_tag_data_t *);
97*7c478bd9Sstevel@tonic-gate 	tnf_record_p	tag_index;	/* trace buffer address */
98*7c478bd9Sstevel@tonic-gate 	const char	*tag_name;	/* name */
99*7c478bd9Sstevel@tonic-gate 	tnf_tag_data_t	****tag_props;	/* properties */
100*7c478bd9Sstevel@tonic-gate 	size_t		tag_size;	/* type_size, header_size */
101*7c478bd9Sstevel@tonic-gate 	size_t		tag_align;	/* alignment */
102*7c478bd9Sstevel@tonic-gate 	size_t		tag_ref_size;	/* reference size */
103*7c478bd9Sstevel@tonic-gate 	tnf_arg_kind_t	tag_kind;	/* type of object */
104*7c478bd9Sstevel@tonic-gate 	tnf_tag_data_t	**tag_base;	/* element_type, derived_base */
105*7c478bd9Sstevel@tonic-gate 	tnf_tag_data_t	***tag_slots;	/* slot_types, header_types */
106*7c478bd9Sstevel@tonic-gate 	char		**tag_slot_names; /* slot_names */
107*7c478bd9Sstevel@tonic-gate };
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate  * TNF tag version
111*7c478bd9Sstevel@tonic-gate  * A client can scan a binary's relocation table for data relocation
112*7c478bd9Sstevel@tonic-gate  * entries corresponding to __tnf_tag_version_1.  These identify
113*7c478bd9Sstevel@tonic-gate  * tags.  The actual version information is stored in an associated
114*7c478bd9Sstevel@tonic-gate  * structure called __tnf_tag_version_1_info
115*7c478bd9Sstevel@tonic-gate  */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate extern tnf_tag_version_t __tnf_tag_version_1_info;
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate extern tnf_tag_version_t __tnf_tag_version_1;
120*7c478bd9Sstevel@tonic-gate #pragma weak __tnf_tag_version_1	/* placeholder: never defined */
121*7c478bd9Sstevel@tonic-gate #define	TNF_TAG_VERSION	&__tnf_tag_version_1
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate /*
124*7c478bd9Sstevel@tonic-gate  * TNF primitive types
125*7c478bd9Sstevel@tonic-gate  */
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_char_tag_data;
128*7c478bd9Sstevel@tonic-gate #define	tnf_char(ops, item, ref)	(item)
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_int8_tag_data;
131*7c478bd9Sstevel@tonic-gate #define	tnf_int8(ops, item, ref)	(item)
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_uint8_tag_data;
134*7c478bd9Sstevel@tonic-gate #define	tnf_uint8(ops, item, ref)	(item)
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_int16_tag_data;
137*7c478bd9Sstevel@tonic-gate #define	tnf_int16(ops, item, ref)	(item)
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_uint16_tag_data;
140*7c478bd9Sstevel@tonic-gate #define	tnf_uint16(ops, item, ref)	(item)
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_int32_tag_data;
143*7c478bd9Sstevel@tonic-gate #define	tnf_int32(ops, item, ref) 	(item)
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_uint32_tag_data;
146*7c478bd9Sstevel@tonic-gate #define	tnf_uint32(ops, item, ref)	(item)
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_int64_tag_data;
149*7c478bd9Sstevel@tonic-gate #define	tnf_int64(ops, item, ref)	(item)
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_uint64_tag_data;
152*7c478bd9Sstevel@tonic-gate #define	tnf_uint64(ops, item, ref)	(item)
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_float32_tag_data;
155*7c478bd9Sstevel@tonic-gate #define	tnf_float32(ops, item, ref)	(item)
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_float64_tag_data;
158*7c478bd9Sstevel@tonic-gate #define	tnf_float64(ops, item, ref)	(item)
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate /*
161*7c478bd9Sstevel@tonic-gate  * ``Portable'' primitive types
162*7c478bd9Sstevel@tonic-gate  * These are defined as the well-defined TNF types they map into.
163*7c478bd9Sstevel@tonic-gate  * XXX Machine-dependent
164*7c478bd9Sstevel@tonic-gate  */
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate typedef tnf_uint8_t			tnf_uchar_t;
167*7c478bd9Sstevel@tonic-gate #define	tnf_uchar(ops, item, ref)	tnf_uint8(ops, item, ref)
168*7c478bd9Sstevel@tonic-gate #define	tnf_uchar_tag_data		tnf_uint8_tag_data
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate typedef tnf_int16_t			tnf_short_t;
171*7c478bd9Sstevel@tonic-gate #define	tnf_short(ops, item, ref)	tnf_int16(ops, item, ref)
172*7c478bd9Sstevel@tonic-gate #define	tnf_short_tag_data		tnf_int16_tag_data
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate typedef tnf_uint16_t			tnf_ushort_t;
175*7c478bd9Sstevel@tonic-gate #define	tnf_ushort(ops, item, ref)	tnf_uint16(ops, item, ref)
176*7c478bd9Sstevel@tonic-gate #define	tnf_ushort_tag_data		tnf_uint16_tag_data
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t			tnf_int_t;
179*7c478bd9Sstevel@tonic-gate #define	tnf_int(ops, item, ref)	tnf_int32(ops, item, ref)
180*7c478bd9Sstevel@tonic-gate #define	tnf_int_tag_data		tnf_int32_tag_data
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate typedef tnf_uint32_t			tnf_uint_t;
183*7c478bd9Sstevel@tonic-gate #define	tnf_uint(ops, item, ref)	tnf_uint32(ops, item, ref)
184*7c478bd9Sstevel@tonic-gate #define	tnf_uint_tag_data		tnf_uint32_tag_data
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate #if defined(_LP64)
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate typedef tnf_int64_t			tnf_long_t;
189*7c478bd9Sstevel@tonic-gate #define	tnf_long(ops, item, ref)	tnf_int64(ops, item, ref)
190*7c478bd9Sstevel@tonic-gate #define	tnf_long_tag_data		tnf_int64_tag_data
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate typedef tnf_uint64_t			tnf_ulong_t;
193*7c478bd9Sstevel@tonic-gate #define	tnf_ulong(ops, item, ref)	tnf_uint64(ops, item, ref)
194*7c478bd9Sstevel@tonic-gate #define	tnf_ulong_tag_data		tnf_uint64_tag_data
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate #else
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t			tnf_long_t;
199*7c478bd9Sstevel@tonic-gate #define	tnf_long(ops, item, ref)	tnf_int32(ops, item, ref)
200*7c478bd9Sstevel@tonic-gate #define	tnf_long_tag_data		tnf_int32_tag_data
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate typedef tnf_uint32_t			tnf_ulong_t;
203*7c478bd9Sstevel@tonic-gate #define	tnf_ulong(ops, item, ref)	tnf_uint32(ops, item, ref)
204*7c478bd9Sstevel@tonic-gate #define	tnf_ulong_tag_data		tnf_uint32_tag_data
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) */
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate typedef tnf_int64_t			tnf_longlong_t;
209*7c478bd9Sstevel@tonic-gate #define	tnf_longlong(ops, item, ref)	tnf_int64(ops, item, ref)
210*7c478bd9Sstevel@tonic-gate #define	tnf_longlong_tag_data		tnf_int64_tag_data
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate typedef tnf_uint64_t			tnf_ulonglong_t;
213*7c478bd9Sstevel@tonic-gate #define	tnf_ulonglong(ops, item, ref)	tnf_uint64(ops, item, ref)
214*7c478bd9Sstevel@tonic-gate #define	tnf_ulonglong_tag_data		tnf_uint64_tag_data
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate typedef tnf_float32_t			tnf_float_t;
217*7c478bd9Sstevel@tonic-gate #define	tnf_float(ops, item, ref)	tnf_float32(ops, item, ref)
218*7c478bd9Sstevel@tonic-gate #define	tnf_float_tag_data		tnf_float32_tag_data
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate typedef tnf_float64_t			tnf_double_t;
221*7c478bd9Sstevel@tonic-gate #define	tnf_double(ops, item, ref)	tnf_float64(ops, item, ref)
222*7c478bd9Sstevel@tonic-gate #define	tnf_double_tag_data		tnf_float64_tag_data
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate  * Derived and aggregate TNF types
226*7c478bd9Sstevel@tonic-gate  */
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate /* Not explicitly represented in type system */
229*7c478bd9Sstevel@tonic-gate #define	tnf_ref32(ops, item, ref)	\
230*7c478bd9Sstevel@tonic-gate 	tnf_ref32_1(ops, item, ref)
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_tag_tag_data;
233*7c478bd9Sstevel@tonic-gate typedef tnf_ref32_t		tnf_tag_t;
234*7c478bd9Sstevel@tonic-gate #define	tnf_tag(ops, item, ref) 	\
235*7c478bd9Sstevel@tonic-gate 	(tnf_ref32(ops, item, ref) | TNF_REF32_T_TAG)
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_string_tag_data;
238*7c478bd9Sstevel@tonic-gate typedef tnf_reference_t		tnf_string_t;
239*7c478bd9Sstevel@tonic-gate #define	tnf_string(ops, item, ref)	\
240*7c478bd9Sstevel@tonic-gate 	tnf_string_1(ops, item, ref, tnf_string_tag_data)
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_name_tag_data;
243*7c478bd9Sstevel@tonic-gate typedef tnf_string_t 		tnf_name_t;
244*7c478bd9Sstevel@tonic-gate #define	tnf_name(ops, item, ref) 	\
245*7c478bd9Sstevel@tonic-gate 	tnf_string_1(ops, item, ref, tnf_name_tag_data)
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_size_tag_data;
248*7c478bd9Sstevel@tonic-gate typedef tnf_ulong_t		tnf_size_t;
249*7c478bd9Sstevel@tonic-gate #define	tnf_size(ops, item, ref) 	\
250*7c478bd9Sstevel@tonic-gate 	tnf_ulong(ops, item, ref)
251*7c478bd9Sstevel@tonic-gate 
252*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_opaque_tag_data;
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate #if defined(_LP64)
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate typedef tnf_uint64_t			tnf_opaque_t;
257*7c478bd9Sstevel@tonic-gate #define	tnf_opaque(ops, item, ref)	\
258*7c478bd9Sstevel@tonic-gate 	((tnf_uint64_t)(item))
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate #else
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate typedef tnf_uint32_t			tnf_opaque_t;
263*7c478bd9Sstevel@tonic-gate #define	tnf_opaque(ops, item, ref)	\
264*7c478bd9Sstevel@tonic-gate 	((tnf_uint32_t)(item))
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) */
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate /*
269*7c478bd9Sstevel@tonic-gate  * TNF types for tracing
270*7c478bd9Sstevel@tonic-gate  */
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_time_base_tag_data;
273*7c478bd9Sstevel@tonic-gate typedef tnf_int64_t		tnf_time_base_t;
274*7c478bd9Sstevel@tonic-gate #define	tnf_time_base(ops, item, ref) 	\
275*7c478bd9Sstevel@tonic-gate 	tnf_int64(ops, item, ref)
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_time_delta_tag_data;
278*7c478bd9Sstevel@tonic-gate typedef tnf_uint32_t		tnf_time_delta_t;
279*7c478bd9Sstevel@tonic-gate #define	tnf_time_delta(ops, item, ref) 	\
280*7c478bd9Sstevel@tonic-gate 	tnf_uint32(ops, item, ref)
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_probe_event_tag_data;
283*7c478bd9Sstevel@tonic-gate typedef tnf_ref32_t		tnf_probe_event_t;
284*7c478bd9Sstevel@tonic-gate #define	tnf_probe_event(ops, item, ref) \
285*7c478bd9Sstevel@tonic-gate 	((tnf_ref32_t)(item) | TNF_REF32_T_PAIR)
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate /* process ID */
288*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_pid_tag_data;
289*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_pid_t;
290*7c478bd9Sstevel@tonic-gate #define	tnf_pid(ops, item, ref)		\
291*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, item, ref)
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate /* LWP ID */
294*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_lwpid_tag_data;
295*7c478bd9Sstevel@tonic-gate typedef tnf_uint32_t		tnf_lwpid_t;
296*7c478bd9Sstevel@tonic-gate #define	tnf_lwpid(ops, item, ref)	\
297*7c478bd9Sstevel@tonic-gate 	tnf_uint32(ops, item, ref)
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate /* kernel thread ID */
302*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_kthread_id_tag_data;
303*7c478bd9Sstevel@tonic-gate typedef tnf_opaque_t		tnf_kthread_id_t;
304*7c478bd9Sstevel@tonic-gate #define	tnf_kthread_id(ops, item, ref)	\
305*7c478bd9Sstevel@tonic-gate 	tnf_opaque(ops, item, ref)
306*7c478bd9Sstevel@tonic-gate 
307*7c478bd9Sstevel@tonic-gate /* processor ID */
308*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_cpuid_tag_data;
309*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_cpuid_t;
310*7c478bd9Sstevel@tonic-gate #define	tnf_cpuid(ops, item, ref)	\
311*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, item, ref)
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate /* device ID */
314*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_device_tag_data;
315*7c478bd9Sstevel@tonic-gate typedef tnf_ulong_t		tnf_device_t;
316*7c478bd9Sstevel@tonic-gate #define	tnf_device(ops, item, ref)	\
317*7c478bd9Sstevel@tonic-gate 	tnf_ulong(ops, item, ref)
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate /* kernel symbol */
320*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_symbol_tag_data;
321*7c478bd9Sstevel@tonic-gate typedef	tnf_opaque_t		tnf_symbol_t;
322*7c478bd9Sstevel@tonic-gate #define	tnf_symbol(ops, item, ref)	\
323*7c478bd9Sstevel@tonic-gate 	tnf_opaque(ops, item, ref)
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate /* array of symbols */
326*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_symbols_tag_data;
327*7c478bd9Sstevel@tonic-gate typedef tnf_ref32_t		tnf_symbols_t;
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate #if defined(__sparc)
330*7c478bd9Sstevel@tonic-gate #define	tnf_symbols(ops, item, ref)	\
331*7c478bd9Sstevel@tonic-gate 	tnf_opaque32_array_1(ops, item, ref, tnf_symbols_tag_data)
332*7c478bd9Sstevel@tonic-gate #else /* defined(__sparc) */
333*7c478bd9Sstevel@tonic-gate #define	tnf_symbols(ops, item, ref)	\
334*7c478bd9Sstevel@tonic-gate 	tnf_opaque_array_1(ops, item, ref, tnf_symbols_tag_data)
335*7c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */
336*7c478bd9Sstevel@tonic-gate 
337*7c478bd9Sstevel@tonic-gate /* system call number */
338*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_sysnum_tag_data;
339*7c478bd9Sstevel@tonic-gate typedef tnf_int16_t		tnf_sysnum_t;
340*7c478bd9Sstevel@tonic-gate #define	tnf_sysnum(ops, item, ref)	\
341*7c478bd9Sstevel@tonic-gate 	tnf_int16(ops, item, ref)
342*7c478bd9Sstevel@tonic-gate 
343*7c478bd9Sstevel@tonic-gate /* thread microstate XXX enum */
344*7c478bd9Sstevel@tonic-gate /* XXX should have a new type tnf_enum of appropriate size to map C enum's */
345*7c478bd9Sstevel@tonic-gate /* XXX cast below is to avoid lint warnings */
346*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_microstate_tag_data;
347*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_microstate_t;
348*7c478bd9Sstevel@tonic-gate #define	tnf_microstate(ops, item, ref)	\
349*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, (tnf_int32_t)(item), ref)
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate /* file offset */
352*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_offset_tag_data;
353*7c478bd9Sstevel@tonic-gate typedef tnf_int64_t		tnf_offset_t;
354*7c478bd9Sstevel@tonic-gate #define	tnf_offset(ops, item, ref)	\
355*7c478bd9Sstevel@tonic-gate 	tnf_int64(ops, item, ref)
356*7c478bd9Sstevel@tonic-gate 
357*7c478bd9Sstevel@tonic-gate /* address fault type XXX enum */
358*7c478bd9Sstevel@tonic-gate /* XXX should have a new type tnf_enum of appropriate size to map C enum's */
359*7c478bd9Sstevel@tonic-gate /* XXX cast below is to avoid lint warnings */
360*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_fault_type_tag_data;
361*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_fault_type_t;
362*7c478bd9Sstevel@tonic-gate #define	tnf_fault_type(ops, item, ref)	\
363*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, (tnf_int32_t)(item), ref)
364*7c478bd9Sstevel@tonic-gate 
365*7c478bd9Sstevel@tonic-gate /* segment access type XXX enum */
366*7c478bd9Sstevel@tonic-gate /* XXX should have a new type tnf_enum of appropriate size to map C enum's */
367*7c478bd9Sstevel@tonic-gate /* XXX cast below is to avoid lint warnings */
368*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_seg_access_tag_data;
369*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_seg_access_t;
370*7c478bd9Sstevel@tonic-gate #define	tnf_seg_access(ops, item, ref)	\
371*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, (tnf_int32_t)(item), ref)
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate /* buffered I/O flags */
374*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_bioflags_tag_data;
375*7c478bd9Sstevel@tonic-gate typedef tnf_int32_t		tnf_bioflags_t;
376*7c478bd9Sstevel@tonic-gate #define	tnf_bioflags(ops, item, ref)	\
377*7c478bd9Sstevel@tonic-gate 	tnf_int32(ops, item, ref)
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate /* disk block addresses */
380*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t		*tnf_diskaddr_tag_data;
381*7c478bd9Sstevel@tonic-gate typedef tnf_int64_t		tnf_diskaddr_t;
382*7c478bd9Sstevel@tonic-gate #define	tnf_diskaddr(ops, item, ref)	\
383*7c478bd9Sstevel@tonic-gate 	tnf_int64(ops, item, ref)
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
386*7c478bd9Sstevel@tonic-gate 
387*7c478bd9Sstevel@tonic-gate /*
388*7c478bd9Sstevel@tonic-gate  * Type extension interface
389*7c478bd9Sstevel@tonic-gate  */
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	***tnf_user_struct_properties;
392*7c478bd9Sstevel@tonic-gate 
393*7c478bd9Sstevel@tonic-gate /*
394*7c478bd9Sstevel@tonic-gate  * Data encoders
395*7c478bd9Sstevel@tonic-gate  */
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate extern tnf_ref32_t	tnf_ref32_1(tnf_ops_t *,
398*7c478bd9Sstevel@tonic-gate 					tnf_record_p,
399*7c478bd9Sstevel@tonic-gate 					tnf_record_p);
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate extern tnf_reference_t 	tnf_string_1(tnf_ops_t *,
402*7c478bd9Sstevel@tonic-gate 					const char *,
403*7c478bd9Sstevel@tonic-gate 					tnf_record_p,
404*7c478bd9Sstevel@tonic-gate 					tnf_tag_data_t *);
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
407*7c478bd9Sstevel@tonic-gate 
408*7c478bd9Sstevel@tonic-gate extern tnf_reference_t	tnf_opaque_array_1(tnf_ops_t *,
409*7c478bd9Sstevel@tonic-gate 					tnf_opaque_t *,
410*7c478bd9Sstevel@tonic-gate 					tnf_record_p,
411*7c478bd9Sstevel@tonic-gate 					tnf_tag_data_t *);
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate #ifdef __sparc
414*7c478bd9Sstevel@tonic-gate extern tnf_reference_t	tnf_opaque32_array_1(tnf_ops_t *,
415*7c478bd9Sstevel@tonic-gate 					tnf_uint32_t *,
416*7c478bd9Sstevel@tonic-gate 					tnf_record_p,
417*7c478bd9Sstevel@tonic-gate 					tnf_tag_data_t *);
418*7c478bd9Sstevel@tonic-gate #endif /* __sparc */
419*7c478bd9Sstevel@tonic-gate 
420*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
421*7c478bd9Sstevel@tonic-gate 
422*7c478bd9Sstevel@tonic-gate /*
423*7c478bd9Sstevel@tonic-gate  * Tag descriptors
424*7c478bd9Sstevel@tonic-gate  */
425*7c478bd9Sstevel@tonic-gate 
426*7c478bd9Sstevel@tonic-gate extern tnf_record_p tnf_struct_tag_1(tnf_ops_t *, tnf_tag_data_t *);
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate /*
429*7c478bd9Sstevel@tonic-gate  * Buffer memory allocator
430*7c478bd9Sstevel@tonic-gate  */
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate extern void *tnf_allocate(tnf_ops_t *, size_t);
433*7c478bd9Sstevel@tonic-gate 
434*7c478bd9Sstevel@tonic-gate /*
435*7c478bd9Sstevel@tonic-gate  * Weak symbol definitions to allow unprobed operation
436*7c478bd9Sstevel@tonic-gate  */
437*7c478bd9Sstevel@tonic-gate 
438*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(_TNF_LIBRARY)
439*7c478bd9Sstevel@tonic-gate 
440*7c478bd9Sstevel@tonic-gate #pragma weak	__tnf_tag_version_1_info
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_char_tag_data
443*7c478bd9Sstevel@tonic-gate #pragma	weak	tnf_int8_tag_data
444*7c478bd9Sstevel@tonic-gate #pragma	weak	tnf_uint8_tag_data
445*7c478bd9Sstevel@tonic-gate #pragma	weak	tnf_int16_tag_data
446*7c478bd9Sstevel@tonic-gate #pragma	weak	tnf_uint16_tag_data
447*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_int32_tag_data
448*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_uint32_tag_data
449*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_int64_tag_data
450*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_uint64_tag_data
451*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_float32_tag_data
452*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_float64_tag_data
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_tag_tag_data
455*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_string_tag_data
456*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_name_tag_data
457*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_opaque_tag_data
458*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_size_tag_data
459*7c478bd9Sstevel@tonic-gate 
460*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_probe_event_tag_data
461*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_time_delta_tag_data
462*7c478bd9Sstevel@tonic-gate 
463*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_user_struct_properties
464*7c478bd9Sstevel@tonic-gate 
465*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_ref32_1
466*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_string_1
467*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_struct_tag_1
468*7c478bd9Sstevel@tonic-gate #pragma weak	tnf_allocate
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate #endif /* !defined(_KERNEL) || !defined(_TNF_LIBRARY) */
471*7c478bd9Sstevel@tonic-gate 
472*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
473*7c478bd9Sstevel@tonic-gate }
474*7c478bd9Sstevel@tonic-gate #endif
475*7c478bd9Sstevel@tonic-gate 
476*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_TNF_WRITER_H */
477