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