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 (c) 1994, by Sun Microsytems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #ifndef DEBUG 29*7c478bd9Sstevel@tonic-gate #define NDEBUG 1 30*7c478bd9Sstevel@tonic-gate #endif 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 33*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/tnf_com.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/tnf_writer.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 38*7c478bd9Sstevel@tonic-gate #include "tnf_types.h" 39*7c478bd9Sstevel@tonic-gate #include "tnf_trace.h" 40*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 41*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 42*7c478bd9Sstevel@tonic-gate #include <string.h> 43*7c478bd9Sstevel@tonic-gate #include <tnf/com.h> 44*7c478bd9Sstevel@tonic-gate #include <tnf/writer.h> 45*7c478bd9Sstevel@tonic-gate #include <assert.h> 46*7c478bd9Sstevel@tonic-gate #include "tnf_types.h" 47*7c478bd9Sstevel@tonic-gate #include <tnf_trace.h> 48*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* 51*7c478bd9Sstevel@tonic-gate * Defines 52*7c478bd9Sstevel@tonic-gate */ 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 55*7c478bd9Sstevel@tonic-gate #define TNF_ASSERT(expr) ASSERT(expr) 56*7c478bd9Sstevel@tonic-gate #else 57*7c478bd9Sstevel@tonic-gate #define TNF_ASSERT(expr) assert(expr) 58*7c478bd9Sstevel@tonic-gate #endif 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* 61*7c478bd9Sstevel@tonic-gate * Local functions 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate static tnf_record_p tnf_root_tag_1(tnf_ops_t *, tnf_tag_data_t *); 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate /* 67*7c478bd9Sstevel@tonic-gate * TNF tag version 1 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate tnf_tag_version_t __tnf_tag_version_1_info = { 71*7c478bd9Sstevel@tonic-gate sizeof (tnf_tag_version_t), 72*7c478bd9Sstevel@tonic-gate sizeof (tnf_tag_data_t) 73*7c478bd9Sstevel@tonic-gate }; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * Pure abstract types 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate TNF_ABSTRACT_TAG(tnf_inline); 80*7c478bd9Sstevel@tonic-gate TNF_ABSTRACT_TAG(tnf_tagged); 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * Scalar types 84*7c478bd9Sstevel@tonic-gate */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **std_scalar_properties[] = { 87*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_inline), 88*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_scalar), 89*7c478bd9Sstevel@tonic-gate 0}; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_scalar_properties = std_scalar_properties; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate TNF_SCALAR_TAG(tnf_scalar, 0, 0, TNF_UNKNOWN); 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_char, TNF_UNKNOWN); /* XXX */ 96*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_int8, TNF_INT32); 97*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_uint8, TNF_UINT32); 98*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_int16, TNF_INT32); 99*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_uint16, TNF_UINT32); 100*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_int32, TNF_INT32); 101*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_uint32, TNF_UINT32); 102*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_int64, TNF_INT64); 103*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_uint64, TNF_UINT64); 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_float32, TNF_FLOAT32); 106*7c478bd9Sstevel@tonic-gate TNF_STD_SCALAR_TAG(tnf_float64, TNF_FLOAT64); 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* 109*7c478bd9Sstevel@tonic-gate * Array types 110*7c478bd9Sstevel@tonic-gate */ 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **array_properties[] = { 113*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_array), 114*7c478bd9Sstevel@tonic-gate 0 115*7c478bd9Sstevel@tonic-gate }; 116*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t ***abstract_array_properties = array_properties; 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **std_array_properties[] = { 119*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_array), 120*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tagged), 121*7c478bd9Sstevel@tonic-gate 0 122*7c478bd9Sstevel@tonic-gate }; 123*7c478bd9Sstevel@tonic-gate /* Exported */ 124*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_array_properties = std_array_properties; 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate /* Exported */ 127*7c478bd9Sstevel@tonic-gate tnf_tag_data_t **tnf_array_slots[] = { 128*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 129*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_self_size), 130*7c478bd9Sstevel@tonic-gate 0 131*7c478bd9Sstevel@tonic-gate }; 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate TNF_ARRAY_TAG(tnf_array, TNF_NULL, abstract_array_properties, 134*7c478bd9Sstevel@tonic-gate TNF_NULL, TNF_UNKNOWN); 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate TNF_STD_ARRAY_TAG(tnf_string, tnf_char, TNF_STRING); 137*7c478bd9Sstevel@tonic-gate TNF_STD_ARRAY_TAG(tnf_type_array, tnf_type, TNF_ARRAY); 138*7c478bd9Sstevel@tonic-gate TNF_STD_ARRAY_TAG(tnf_name_array, tnf_name, TNF_ARRAY); 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate /* 141*7c478bd9Sstevel@tonic-gate * Derived types 142*7c478bd9Sstevel@tonic-gate */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **derived_properties[] = { 145*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_derived), 146*7c478bd9Sstevel@tonic-gate 0 147*7c478bd9Sstevel@tonic-gate }; 148*7c478bd9Sstevel@tonic-gate /* Exported */ 149*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_derived_properties = derived_properties; 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate TNF_DERIVED_TAG(tnf_derived, TNF_NULL, 152*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_NULL, TNF_NULL, TNF_UNKNOWN); 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_align, tnf_uint32, 155*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_UINT32); 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_derived_base, tnf_type, 158*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_element_type, tnf_type, 161*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_header_size, tnf_uint32, 164*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_UINT32); 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_name, tnf_string, 167*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_STRING); 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_opaque, tnf_uint64, 172*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate #else 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_opaque, tnf_uint32, 177*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) */ 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_properties, tnf_type_array, 182*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_ARRAY); 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_self_size, tnf_uint32, 185*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_UINT32); 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_size, tnf_ulong, 188*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_ULONG); 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_slot_names, tnf_name_array, 191*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_ARRAY); 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_slot_types, tnf_type_array, 194*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_ARRAY); 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_tag, tnf_type, 197*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_tag_arg, tnf_tagged, 200*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_OPAQUE); 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate TNF_STD_DERIVED_TAG(tnf_type_size, tnf_uint32, 203*7c478bd9Sstevel@tonic-gate tnf_derived_properties, TNF_UINT32); 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate /* 206*7c478bd9Sstevel@tonic-gate * Struct types 207*7c478bd9Sstevel@tonic-gate */ 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **no_properties[] = { 0 }; 210*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_no_properties = no_properties; 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **no_slots[] = { 0 }; 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **std_struct_properties[] = { 215*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tagged), 216*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_struct), 217*7c478bd9Sstevel@tonic-gate 0}; 218*7c478bd9Sstevel@tonic-gate /* Exported */ 219*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_struct_properties = std_struct_properties; 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate TNF_STRUCT_TAG(tnf_struct, tnf_no_properties, no_slots, 0, 0); 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* 224*7c478bd9Sstevel@tonic-gate * File header - CAUTION - has to be in sync with com.h 225*7c478bd9Sstevel@tonic-gate */ 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate static char *file_header_slot_names[] = { 228*7c478bd9Sstevel@tonic-gate TNF_N_TAG, 229*7c478bd9Sstevel@tonic-gate TNF_N_FILE_VERSION, 230*7c478bd9Sstevel@tonic-gate TNF_N_FILE_HEADER_SIZE, 231*7c478bd9Sstevel@tonic-gate TNF_N_FILE_LOGICAL_SIZE, 232*7c478bd9Sstevel@tonic-gate TNF_N_BLOCK_HEADER_SIZE, 233*7c478bd9Sstevel@tonic-gate TNF_N_BLOCK_SIZE, 234*7c478bd9Sstevel@tonic-gate TNF_N_DIRECTORY_SIZE, 235*7c478bd9Sstevel@tonic-gate TNF_N_BLOCK_COUNT, 236*7c478bd9Sstevel@tonic-gate TNF_N_BLOCKS_VALID, 237*7c478bd9Sstevel@tonic-gate /* XXX add writer-specific opaque slots here for reader */ 238*7c478bd9Sstevel@tonic-gate 0}; 239*7c478bd9Sstevel@tonic-gate 240*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **file_header_slots[] = { 241*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), /* tag */ 242*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* file_version */ 243*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* file_header_size */ 244*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* file_logical_size */ 245*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* block_header_size */ 246*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* block_size */ 247*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* directory_size */ 248*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* block_count */ 249*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* blocks_valid */ 250*7c478bd9Sstevel@tonic-gate /* XXX add writer-specific opaque slots here for reader */ 251*7c478bd9Sstevel@tonic-gate 0}; 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate /* size of tnf_file_header has the size of the magic number subtracted */ 254*7c478bd9Sstevel@tonic-gate TNF_STD_STRUCT_TAG(tnf_file_header, 255*7c478bd9Sstevel@tonic-gate file_header_slots, 256*7c478bd9Sstevel@tonic-gate file_header_slot_names, 257*7c478bd9Sstevel@tonic-gate sizeof (tnf_buf_file_header_t) - sizeof (tnf_uint32_t)); 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate /* 260*7c478bd9Sstevel@tonic-gate * Block header - CAUTION - has to be in sync with com.h 261*7c478bd9Sstevel@tonic-gate */ 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate static char *block_header_slot_names[] = { 264*7c478bd9Sstevel@tonic-gate TNF_N_TAG, 265*7c478bd9Sstevel@tonic-gate TNF_N_GENERATION, 266*7c478bd9Sstevel@tonic-gate TNF_N_BYTES_VALID, 267*7c478bd9Sstevel@tonic-gate "A_lock", /* XXX */ 268*7c478bd9Sstevel@tonic-gate "B_lock", /* XXX */ 269*7c478bd9Sstevel@tonic-gate "next_block", /* XXX */ 270*7c478bd9Sstevel@tonic-gate 0}; 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **block_header_slots[] = { 273*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), /* tag */ 274*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint32), /* generation */ 275*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint16), /* bytes_valid */ 276*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint8), /* A_lock */ 277*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_uint8), /* B_lock */ 278*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_opaque), /* next_block */ 279*7c478bd9Sstevel@tonic-gate 0}; 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate TNF_STD_STRUCT_TAG(tnf_block_header, 282*7c478bd9Sstevel@tonic-gate block_header_slots, 283*7c478bd9Sstevel@tonic-gate block_header_slot_names, 284*7c478bd9Sstevel@tonic-gate sizeof (tnf_block_header_t)); 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* 287*7c478bd9Sstevel@tonic-gate * Metatypes 288*7c478bd9Sstevel@tonic-gate */ 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **type_properties[] = { 291*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tagged), 292*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_struct), 293*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_type), 294*7c478bd9Sstevel@tonic-gate 0}; 295*7c478bd9Sstevel@tonic-gate /* Exported */ 296*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_type_properties = type_properties; 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **type_slots[] = { 299*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 300*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_name), 301*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_properties), 302*7c478bd9Sstevel@tonic-gate 0}; 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate TNF_METATAG(tnf_type, tnf_type_properties, type_slots, tnf_struct_tag_1); 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **array_type_slots[] = { 307*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 308*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_name), 309*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_properties), 310*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_slot_types), 311*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_header_size), 312*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_element_type), 313*7c478bd9Sstevel@tonic-gate 0}; 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate TNF_METATAG(tnf_array_type, tnf_type_properties, 316*7c478bd9Sstevel@tonic-gate array_type_slots, tnf_struct_tag_1); 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **derived_type_slots[] = { 319*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 320*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_name), 321*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_properties), 322*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_derived_base), 323*7c478bd9Sstevel@tonic-gate 0}; 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate TNF_METATAG(tnf_derived_type, tnf_type_properties, 326*7c478bd9Sstevel@tonic-gate derived_type_slots, tnf_struct_tag_1); 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **scalar_type_slots[] = { 329*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 330*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_name), 331*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_properties), 332*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_type_size), 333*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_align), 334*7c478bd9Sstevel@tonic-gate 0}; 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate TNF_METATAG(tnf_scalar_type, tnf_type_properties, 337*7c478bd9Sstevel@tonic-gate scalar_type_slots, tnf_struct_tag_1); 338*7c478bd9Sstevel@tonic-gate 339*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t **struct_type_slots[] = { 340*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_tag), 341*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_name), 342*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_properties), 343*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_slot_types), 344*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_type_size), 345*7c478bd9Sstevel@tonic-gate &TAG_DATA(tnf_slot_names), 346*7c478bd9Sstevel@tonic-gate 0}; 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate TNF_METATAG(tnf_struct_type, tnf_type_properties, 349*7c478bd9Sstevel@tonic-gate struct_type_slots, tnf_root_tag_1); 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate /* 353*7c478bd9Sstevel@tonic-gate * Generic tnf reference - does checking on whether destination is 354*7c478bd9Sstevel@tonic-gate * a permanent block or not 355*7c478bd9Sstevel@tonic-gate */ 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /*ARGSUSED0*/ 360*7c478bd9Sstevel@tonic-gate tnf_ref32_t 361*7c478bd9Sstevel@tonic-gate tnf_ref32_1(tnf_ops_t *ops, tnf_record_p item, tnf_record_p reference) 362*7c478bd9Sstevel@tonic-gate { 363*7c478bd9Sstevel@tonic-gate tnf_ref32_t offset_delta, gen_delta; 364*7c478bd9Sstevel@tonic-gate tnf_block_header_t *dest_header_p, *src_header_p; 365*7c478bd9Sstevel@tonic-gate tnf_ref32_t result; 366*7c478bd9Sstevel@tonic-gate unsigned int offset_shift = 367*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 368*7c478bd9Sstevel@tonic-gate ((tnf_buf_file_header_t *)tnf_buf)->com.file_log_size; 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate dest_header_p = (tnf_block_header_t *) 371*7c478bd9Sstevel@tonic-gate ((uintptr_t)item & TNF_BLOCK_MASK); 372*7c478bd9Sstevel@tonic-gate 373*7c478bd9Sstevel@tonic-gate if (((char *)dest_header_p < (tnf_buf + TNF_DIRECTORY_SIZE)) || 374*7c478bd9Sstevel@tonic-gate (dest_header_p->generation == TNF_TAG_GENERATION_NUM)) { 375*7c478bd9Sstevel@tonic-gate /* reference to a permanent block */ 376*7c478bd9Sstevel@tonic-gate /* LINTED ast from 64-bit integer to 32-bit integer */ 377*7c478bd9Sstevel@tonic-gate offset_delta = (tnf_ref32_t)(item - tnf_buf); 378*7c478bd9Sstevel@tonic-gate 379*7c478bd9Sstevel@tonic-gate return (TNF_REF32_MAKE_PERMANENT(offset_delta)); 380*7c478bd9Sstevel@tonic-gate } else { 381*7c478bd9Sstevel@tonic-gate /* reference to a reclaimable block */ 382*7c478bd9Sstevel@tonic-gate /* LINTED ast from 64-bit integer to 32-bit integer */ 383*7c478bd9Sstevel@tonic-gate offset_delta = (tnf_ref32_t)(item - reference); 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate src_header_p = (tnf_block_header_t *) 386*7c478bd9Sstevel@tonic-gate ((uintptr_t)reference & TNF_BLOCK_MASK); 387*7c478bd9Sstevel@tonic-gate gen_delta = dest_header_p->generation - 388*7c478bd9Sstevel@tonic-gate src_header_p->generation; 389*7c478bd9Sstevel@tonic-gate 390*7c478bd9Sstevel@tonic-gate result = (gen_delta << offset_shift) + offset_delta; 391*7c478bd9Sstevel@tonic-gate return (TNF_REF32_MAKE_RECLAIMABLE(result)); 392*7c478bd9Sstevel@tonic-gate } 393*7c478bd9Sstevel@tonic-gate } 394*7c478bd9Sstevel@tonic-gate 395*7c478bd9Sstevel@tonic-gate #else 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /*ARGSUSED0*/ 398*7c478bd9Sstevel@tonic-gate tnf_ref32_t 399*7c478bd9Sstevel@tonic-gate tnf_ref32_1(tnf_ops_t *ops, tnf_record_p item, tnf_record_p reference) 400*7c478bd9Sstevel@tonic-gate { 401*7c478bd9Sstevel@tonic-gate volatile char *file_start = _tnfw_b_control->tnf_buffer; 402*7c478bd9Sstevel@tonic-gate tnf_ref32_t offset_delta, gen_delta; 403*7c478bd9Sstevel@tonic-gate tnf_block_header_t *dest_header_p, *src_header_p; 404*7c478bd9Sstevel@tonic-gate tnf_ref32_t result; 405*7c478bd9Sstevel@tonic-gate unsigned int offset_shift = 406*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 407*7c478bd9Sstevel@tonic-gate ((tnf_buf_file_header_t *)file_start)->com.file_log_size; 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate dest_header_p = (tnf_block_header_t *) 410*7c478bd9Sstevel@tonic-gate ((uintptr_t)item & TNF_BLOCK_MASK); 411*7c478bd9Sstevel@tonic-gate 412*7c478bd9Sstevel@tonic-gate if (((char *)dest_header_p < (file_start + TNFW_B_FW_ZONE)) || 413*7c478bd9Sstevel@tonic-gate (dest_header_p->generation == TNF_TAG_GENERATION_NUM)) { 414*7c478bd9Sstevel@tonic-gate /* reference to a permanent block */ 415*7c478bd9Sstevel@tonic-gate /* LINTED ast from 64-bit integer to 32-bit integer */ 416*7c478bd9Sstevel@tonic-gate offset_delta = (tnf_ref32_t)(item - (tnf_record_p) file_start); 417*7c478bd9Sstevel@tonic-gate 418*7c478bd9Sstevel@tonic-gate return (TNF_REF32_MAKE_PERMANENT(offset_delta)); 419*7c478bd9Sstevel@tonic-gate } else { 420*7c478bd9Sstevel@tonic-gate /* reference to a reclaimable block */ 421*7c478bd9Sstevel@tonic-gate /* LINTED ast from 64-bit integer to 32-bit integer */ 422*7c478bd9Sstevel@tonic-gate offset_delta = (tnf_ref32_t)(item - reference); 423*7c478bd9Sstevel@tonic-gate 424*7c478bd9Sstevel@tonic-gate src_header_p = (tnf_block_header_t *) 425*7c478bd9Sstevel@tonic-gate ((uintptr_t)reference & TNF_BLOCK_MASK); 426*7c478bd9Sstevel@tonic-gate gen_delta = dest_header_p->generation - 427*7c478bd9Sstevel@tonic-gate src_header_p->generation; 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate result = (gen_delta << offset_shift) + offset_delta; 430*7c478bd9Sstevel@tonic-gate return (TNF_REF32_MAKE_RECLAIMABLE(result)); 431*7c478bd9Sstevel@tonic-gate } 432*7c478bd9Sstevel@tonic-gate } 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate #endif 435*7c478bd9Sstevel@tonic-gate 436*7c478bd9Sstevel@tonic-gate /* 437*7c478bd9Sstevel@tonic-gate * Tag descriptors 438*7c478bd9Sstevel@tonic-gate */ 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate /* 441*7c478bd9Sstevel@tonic-gate * Write instances of tnf_type 442*7c478bd9Sstevel@tonic-gate */ 443*7c478bd9Sstevel@tonic-gate 444*7c478bd9Sstevel@tonic-gate tnf_record_p 445*7c478bd9Sstevel@tonic-gate tnf_abstract_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 446*7c478bd9Sstevel@tonic-gate { 447*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *metatag_data; 448*7c478bd9Sstevel@tonic-gate tnf_record_p metatag_index; 449*7c478bd9Sstevel@tonic-gate tnf_type_prototype_t *buffer; 450*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 451*7c478bd9Sstevel@tonic-gate 452*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 453*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 454*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 455*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 456*7c478bd9Sstevel@tonic-gate saved_mode); 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate metatag_data = TAG_DATA(tnf_type); 459*7c478bd9Sstevel@tonic-gate metatag_index = metatag_data->tag_index ? metatag_data->tag_index : 460*7c478bd9Sstevel@tonic-gate metatag_data->tag_desc(ops, metatag_data); 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, metatag_index); 463*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 464*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 465*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 466*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 467*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 468*7c478bd9Sstevel@tonic-gate } 469*7c478bd9Sstevel@tonic-gate 470*7c478bd9Sstevel@tonic-gate /* 471*7c478bd9Sstevel@tonic-gate * Write instances of tnf_scalar_type 472*7c478bd9Sstevel@tonic-gate */ 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate tnf_record_p 475*7c478bd9Sstevel@tonic-gate tnf_scalar_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 476*7c478bd9Sstevel@tonic-gate { 477*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *metatag_data; 478*7c478bd9Sstevel@tonic-gate tnf_record_p metatag_index; 479*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 480*7c478bd9Sstevel@tonic-gate tnf_scalar_type_prototype_t *buffer; 481*7c478bd9Sstevel@tonic-gate 482*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 483*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 484*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 485*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 486*7c478bd9Sstevel@tonic-gate saved_mode); 487*7c478bd9Sstevel@tonic-gate 488*7c478bd9Sstevel@tonic-gate metatag_data = TAG_DATA(tnf_scalar_type); 489*7c478bd9Sstevel@tonic-gate metatag_index = metatag_data->tag_index ? metatag_data->tag_index : 490*7c478bd9Sstevel@tonic-gate metatag_data->tag_desc(ops, metatag_data); 491*7c478bd9Sstevel@tonic-gate 492*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, metatag_index); 493*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 494*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 495*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 496*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, type_size, tag_data->tag_size); 497*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 498*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, align, tag_data->tag_align); 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 501*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 502*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 503*7c478bd9Sstevel@tonic-gate } 504*7c478bd9Sstevel@tonic-gate 505*7c478bd9Sstevel@tonic-gate /* 506*7c478bd9Sstevel@tonic-gate * Write instances of tnf_derived_type 507*7c478bd9Sstevel@tonic-gate */ 508*7c478bd9Sstevel@tonic-gate 509*7c478bd9Sstevel@tonic-gate tnf_record_p 510*7c478bd9Sstevel@tonic-gate tnf_derived_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 511*7c478bd9Sstevel@tonic-gate { 512*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *metatag_data; 513*7c478bd9Sstevel@tonic-gate tnf_record_p metatag_index; 514*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 515*7c478bd9Sstevel@tonic-gate tnf_derived_type_prototype_t *buffer; 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 518*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 519*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 520*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 521*7c478bd9Sstevel@tonic-gate saved_mode); 522*7c478bd9Sstevel@tonic-gate 523*7c478bd9Sstevel@tonic-gate metatag_data = TAG_DATA(tnf_derived_type); 524*7c478bd9Sstevel@tonic-gate metatag_index = metatag_data->tag_index ? metatag_data->tag_index: 525*7c478bd9Sstevel@tonic-gate metatag_data->tag_desc(ops, metatag_data); 526*7c478bd9Sstevel@tonic-gate 527*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, metatag_index); 528*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 529*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 530*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, derived_base, tag_data->tag_base); 531*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 532*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 533*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 534*7c478bd9Sstevel@tonic-gate } 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate /* 537*7c478bd9Sstevel@tonic-gate * Write instances of tnf_struct_type (except root) 538*7c478bd9Sstevel@tonic-gate */ 539*7c478bd9Sstevel@tonic-gate 540*7c478bd9Sstevel@tonic-gate tnf_record_p 541*7c478bd9Sstevel@tonic-gate tnf_struct_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 542*7c478bd9Sstevel@tonic-gate { 543*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *metatag_data; 544*7c478bd9Sstevel@tonic-gate tnf_record_p metatag_index; 545*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 546*7c478bd9Sstevel@tonic-gate tnf_struct_type_prototype_t *buffer; 547*7c478bd9Sstevel@tonic-gate 548*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 549*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 550*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 551*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 552*7c478bd9Sstevel@tonic-gate saved_mode); 553*7c478bd9Sstevel@tonic-gate 554*7c478bd9Sstevel@tonic-gate metatag_data = TAG_DATA(tnf_struct_type); 555*7c478bd9Sstevel@tonic-gate metatag_index = metatag_data->tag_index ? metatag_data->tag_index: 556*7c478bd9Sstevel@tonic-gate metatag_data->tag_desc(ops, metatag_data); 557*7c478bd9Sstevel@tonic-gate 558*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, metatag_index); 559*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 560*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 561*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, slot_types, tag_data->tag_slots); 562*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 563*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, type_size, tag_data->tag_size); 564*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, slot_names, tag_data->tag_slot_names); 565*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 566*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 567*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 568*7c478bd9Sstevel@tonic-gate } 569*7c478bd9Sstevel@tonic-gate 570*7c478bd9Sstevel@tonic-gate /* 571*7c478bd9Sstevel@tonic-gate * Write instances of tnf_array_type 572*7c478bd9Sstevel@tonic-gate */ 573*7c478bd9Sstevel@tonic-gate 574*7c478bd9Sstevel@tonic-gate tnf_record_p 575*7c478bd9Sstevel@tonic-gate tnf_array_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 576*7c478bd9Sstevel@tonic-gate { 577*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *metatag_data; 578*7c478bd9Sstevel@tonic-gate tnf_record_p metatag_index; 579*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 580*7c478bd9Sstevel@tonic-gate tnf_array_type_prototype_t *buffer; 581*7c478bd9Sstevel@tonic-gate 582*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 583*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 584*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 585*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 586*7c478bd9Sstevel@tonic-gate saved_mode); 587*7c478bd9Sstevel@tonic-gate 588*7c478bd9Sstevel@tonic-gate metatag_data = TAG_DATA(tnf_array_type); 589*7c478bd9Sstevel@tonic-gate metatag_index = metatag_data->tag_index ? metatag_data->tag_index : 590*7c478bd9Sstevel@tonic-gate metatag_data->tag_desc(ops, metatag_data); 591*7c478bd9Sstevel@tonic-gate 592*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, metatag_index); 593*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 594*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 595*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, slot_types, tag_data->tag_slots); 596*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 597*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, header_size, tag_data->tag_size); 598*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, element_type, tag_data->tag_base); 599*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 600*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 601*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 602*7c478bd9Sstevel@tonic-gate } 603*7c478bd9Sstevel@tonic-gate 604*7c478bd9Sstevel@tonic-gate /* 605*7c478bd9Sstevel@tonic-gate * Write the root metatype, and some critical bootstrap types 606*7c478bd9Sstevel@tonic-gate */ 607*7c478bd9Sstevel@tonic-gate 608*7c478bd9Sstevel@tonic-gate static tnf_record_p 609*7c478bd9Sstevel@tonic-gate tnf_root_tag_1(tnf_ops_t *ops, tnf_tag_data_t *tag_data) 610*7c478bd9Sstevel@tonic-gate { 611*7c478bd9Sstevel@tonic-gate enum tnf_alloc_mode saved_mode; 612*7c478bd9Sstevel@tonic-gate tnf_tag_t *fw_p; 613*7c478bd9Sstevel@tonic-gate tnf_struct_type_prototype_t *buffer; 614*7c478bd9Sstevel@tonic-gate 615*7c478bd9Sstevel@tonic-gate saved_mode = ops->mode; 616*7c478bd9Sstevel@tonic-gate ops->mode = TNF_ALLOC_FIXED; 617*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 618*7c478bd9Sstevel@tonic-gate ALLOC(ops, sizeof (*buffer), buffer, tag_data->tag_index, 619*7c478bd9Sstevel@tonic-gate saved_mode); 620*7c478bd9Sstevel@tonic-gate 621*7c478bd9Sstevel@tonic-gate /* 622*7c478bd9Sstevel@tonic-gate * update the root forwarding pointer to point to this root 623*7c478bd9Sstevel@tonic-gate * CAUTION: Do this before anything else... 624*7c478bd9Sstevel@tonic-gate */ 625*7c478bd9Sstevel@tonic-gate 626*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 627*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 628*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)(tnf_buf + TNF_DIRENT_ROOT); 629*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, tag_data->tag_index, (tnf_record_p)fw_p); 630*7c478bd9Sstevel@tonic-gate tag_data->tag_index = (tnf_record_p)fw_p; 631*7c478bd9Sstevel@tonic-gate #else 632*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 633*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)_tnf_buf_headers_p->fw_root; 634*7c478bd9Sstevel@tonic-gate if (fw_p) { 635*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, tag_data->tag_index, 636*7c478bd9Sstevel@tonic-gate (tnf_record_p) fw_p); 637*7c478bd9Sstevel@tonic-gate tag_data->tag_index = (tnf_record_p)fw_p; 638*7c478bd9Sstevel@tonic-gate } 639*7c478bd9Sstevel@tonic-gate #endif 640*7c478bd9Sstevel@tonic-gate 641*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 642*7c478bd9Sstevel@tonic-gate /* LINTED constant truncated by assignment */ 643*7c478bd9Sstevel@tonic-gate buffer->tag = TNF_ROOT_TAG; 644*7c478bd9Sstevel@tonic-gate #else 645*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, tag, tag_data->tag_index); /* ROOT */ 646*7c478bd9Sstevel@tonic-gate #endif 647*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, name, tag_data->tag_name); 648*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, properties, tag_data->tag_props); 649*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, slot_types, tag_data->tag_slots); 650*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 651*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, type_size, tag_data->tag_size); 652*7c478bd9Sstevel@tonic-gate ASSIGN(buffer, slot_names, tag_data->tag_slot_names); 653*7c478bd9Sstevel@tonic-gate 654*7c478bd9Sstevel@tonic-gate /* 655*7c478bd9Sstevel@tonic-gate * Write some additional bootstrap types 656*7c478bd9Sstevel@tonic-gate */ 657*7c478bd9Sstevel@tonic-gate { 658*7c478bd9Sstevel@tonic-gate static tnf_tag_data_t *bootstrap_types[] = { 659*7c478bd9Sstevel@tonic-gate &_TAG_DATA(tnf_uint16), 660*7c478bd9Sstevel@tonic-gate &_TAG_DATA(tnf_int32), 661*7c478bd9Sstevel@tonic-gate &_TAG_DATA(tnf_tag), 662*7c478bd9Sstevel@tonic-gate &_TAG_DATA(tnf_file_header), 663*7c478bd9Sstevel@tonic-gate &_TAG_DATA(tnf_block_header), 664*7c478bd9Sstevel@tonic-gate 0}; 665*7c478bd9Sstevel@tonic-gate tnf_tag_data_t **list_p, *tag_p; 666*7c478bd9Sstevel@tonic-gate 667*7c478bd9Sstevel@tonic-gate list_p = bootstrap_types; 668*7c478bd9Sstevel@tonic-gate 669*7c478bd9Sstevel@tonic-gate while (tag_p = *list_p++) { 670*7c478bd9Sstevel@tonic-gate if (!tag_p->tag_index) /* not written */ 671*7c478bd9Sstevel@tonic-gate tag_p->tag_desc(ops, tag_p); 672*7c478bd9Sstevel@tonic-gate } 673*7c478bd9Sstevel@tonic-gate } 674*7c478bd9Sstevel@tonic-gate 675*7c478bd9Sstevel@tonic-gate 676*7c478bd9Sstevel@tonic-gate /* 677*7c478bd9Sstevel@tonic-gate * fix for circularity in filling in file header tag and block 678*7c478bd9Sstevel@tonic-gate * header tag. REMIND: should also fix tag_index of 679*7c478bd9Sstevel@tonic-gate * file_header. 680*7c478bd9Sstevel@tonic-gate */ 681*7c478bd9Sstevel@tonic-gate 682*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 683*7c478bd9Sstevel@tonic-gate 684*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 685*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)(tnf_buf + TNF_DIRENT_FILE_HEADER); 686*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, _TAG_DATA(tnf_file_header).tag_index, 687*7c478bd9Sstevel@tonic-gate (tnf_record_p)fw_p); 688*7c478bd9Sstevel@tonic-gate 689*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 690*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)(tnf_buf + TNF_DIRENT_BLOCK_HEADER); 691*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, _TAG_DATA(tnf_block_header).tag_index, 692*7c478bd9Sstevel@tonic-gate (tnf_record_p)fw_p); 693*7c478bd9Sstevel@tonic-gate 694*7c478bd9Sstevel@tonic-gate #else 695*7c478bd9Sstevel@tonic-gate 696*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 697*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)_tnf_buf_headers_p->fw_file_header; 698*7c478bd9Sstevel@tonic-gate if (fw_p) { 699*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, _TAG_DATA(tnf_file_header).tag_index, 700*7c478bd9Sstevel@tonic-gate (tnf_record_p)fw_p); 701*7c478bd9Sstevel@tonic-gate } 702*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 703*7c478bd9Sstevel@tonic-gate fw_p = (tnf_tag_t *)_tnf_buf_headers_p->fw_block_header; 704*7c478bd9Sstevel@tonic-gate if (fw_p) { 705*7c478bd9Sstevel@tonic-gate *fw_p = tnf_ref32(ops, _TAG_DATA(tnf_block_header).tag_index, 706*7c478bd9Sstevel@tonic-gate (tnf_record_p) fw_p); 707*7c478bd9Sstevel@tonic-gate } 708*7c478bd9Sstevel@tonic-gate 709*7c478bd9Sstevel@tonic-gate #endif 710*7c478bd9Sstevel@tonic-gate 711*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 32-bit integer to 8-bit integer */ 712*7c478bd9Sstevel@tonic-gate ops->mode = saved_mode; 713*7c478bd9Sstevel@tonic-gate return (tag_data->tag_index); 714*7c478bd9Sstevel@tonic-gate } 715*7c478bd9Sstevel@tonic-gate 716*7c478bd9Sstevel@tonic-gate 717*7c478bd9Sstevel@tonic-gate /* 718*7c478bd9Sstevel@tonic-gate * Data encoders 719*7c478bd9Sstevel@tonic-gate */ 720*7c478bd9Sstevel@tonic-gate 721*7c478bd9Sstevel@tonic-gate /* 722*7c478bd9Sstevel@tonic-gate * Strings and derivatives 723*7c478bd9Sstevel@tonic-gate */ 724*7c478bd9Sstevel@tonic-gate 725*7c478bd9Sstevel@tonic-gate tnf_reference_t 726*7c478bd9Sstevel@tonic-gate tnf_string_1(tnf_ops_t *ops, const char *string, tnf_record_p reference, 727*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *tag_data) 728*7c478bd9Sstevel@tonic-gate { 729*7c478bd9Sstevel@tonic-gate tnf_record_p tag_index; 730*7c478bd9Sstevel@tonic-gate size_t string_size, record_size; 731*7c478bd9Sstevel@tonic-gate tnf_array_header_t *bufhdr; 732*7c478bd9Sstevel@tonic-gate 733*7c478bd9Sstevel@tonic-gate tag_index = tag_data->tag_index ? tag_data->tag_index : 734*7c478bd9Sstevel@tonic-gate tag_data->tag_desc(ops, tag_data); 735*7c478bd9Sstevel@tonic-gate 736*7c478bd9Sstevel@tonic-gate if (!string) 737*7c478bd9Sstevel@tonic-gate return ((tnf_reference_t)TNF_NULL); 738*7c478bd9Sstevel@tonic-gate 739*7c478bd9Sstevel@tonic-gate string_size = strlen(string); /* excludes terminating NUL */ 740*7c478bd9Sstevel@tonic-gate if (string_size > TNF_STRING_LIMIT) 741*7c478bd9Sstevel@tonic-gate string_size = TNF_STRING_LIMIT; 742*7c478bd9Sstevel@tonic-gate /* Allocate space for terminating NUL as well */ 743*7c478bd9Sstevel@tonic-gate record_size = sizeof (*bufhdr) + TNF_STRING_ROUNDUP(string_size + 1); 744*7c478bd9Sstevel@tonic-gate 745*7c478bd9Sstevel@tonic-gate ALLOC2(ops, record_size, bufhdr, ops->mode); 746*7c478bd9Sstevel@tonic-gate 747*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, tag, tag_index); 748*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 749*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, self_size, record_size); 750*7c478bd9Sstevel@tonic-gate 751*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 752*7c478bd9Sstevel@tonic-gate (void) bcopy((caddr_t)string, (char *)bufhdr + sizeof (*bufhdr), 753*7c478bd9Sstevel@tonic-gate string_size); 754*7c478bd9Sstevel@tonic-gate #else 755*7c478bd9Sstevel@tonic-gate (void) memcpy((char *)bufhdr + sizeof (*bufhdr), string, string_size); 756*7c478bd9Sstevel@tonic-gate #endif 757*7c478bd9Sstevel@tonic-gate /* NUL-terminate */ 758*7c478bd9Sstevel@tonic-gate ((char *)bufhdr + sizeof (*bufhdr))[string_size] = '\0'; 759*7c478bd9Sstevel@tonic-gate 760*7c478bd9Sstevel@tonic-gate return (tnf_ref32(ops, (tnf_record_p)bufhdr, reference)); 761*7c478bd9Sstevel@tonic-gate } 762*7c478bd9Sstevel@tonic-gate 763*7c478bd9Sstevel@tonic-gate /* 764*7c478bd9Sstevel@tonic-gate * Array of strings and derivatives 765*7c478bd9Sstevel@tonic-gate */ 766*7c478bd9Sstevel@tonic-gate 767*7c478bd9Sstevel@tonic-gate tnf_reference_t 768*7c478bd9Sstevel@tonic-gate tnf_string_array_1(tnf_ops_t *ops, char **strings, tnf_record_p reference, 769*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *tag_data) 770*7c478bd9Sstevel@tonic-gate { 771*7c478bd9Sstevel@tonic-gate tnf_record_p tag_index; 772*7c478bd9Sstevel@tonic-gate size_t record_size; 773*7c478bd9Sstevel@tonic-gate char **tmp; 774*7c478bd9Sstevel@tonic-gate tnf_reference_t *ref_p; 775*7c478bd9Sstevel@tonic-gate tnf_array_header_t *bufhdr; 776*7c478bd9Sstevel@tonic-gate 777*7c478bd9Sstevel@tonic-gate tag_index = tag_data->tag_index ? tag_data->tag_index : 778*7c478bd9Sstevel@tonic-gate tag_data->tag_desc(ops, tag_data); 779*7c478bd9Sstevel@tonic-gate 780*7c478bd9Sstevel@tonic-gate if (!strings) 781*7c478bd9Sstevel@tonic-gate return ((tnf_reference_t)TNF_NULL); 782*7c478bd9Sstevel@tonic-gate 783*7c478bd9Sstevel@tonic-gate record_size = sizeof (*bufhdr); 784*7c478bd9Sstevel@tonic-gate tmp = strings; 785*7c478bd9Sstevel@tonic-gate while (*tmp++) 786*7c478bd9Sstevel@tonic-gate record_size += sizeof (tnf_string_t); 787*7c478bd9Sstevel@tonic-gate 788*7c478bd9Sstevel@tonic-gate ALLOC2(ops, record_size, bufhdr, ops->mode); 789*7c478bd9Sstevel@tonic-gate 790*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, tag, tag_index); 791*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 792*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, self_size, record_size); 793*7c478bd9Sstevel@tonic-gate 794*7c478bd9Sstevel@tonic-gate tmp = strings; 795*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 796*7c478bd9Sstevel@tonic-gate ref_p = (tnf_reference_t *)((char *)bufhdr + sizeof (*bufhdr)); 797*7c478bd9Sstevel@tonic-gate while (*tmp) { 798*7c478bd9Sstevel@tonic-gate *ref_p = tnf_string(ops, *tmp, (tnf_record_p)ref_p); 799*7c478bd9Sstevel@tonic-gate tmp++; 800*7c478bd9Sstevel@tonic-gate ref_p++; 801*7c478bd9Sstevel@tonic-gate } 802*7c478bd9Sstevel@tonic-gate 803*7c478bd9Sstevel@tonic-gate return (tnf_ref32(ops, (tnf_record_p) bufhdr, reference)); 804*7c478bd9Sstevel@tonic-gate } 805*7c478bd9Sstevel@tonic-gate 806*7c478bd9Sstevel@tonic-gate /* 807*7c478bd9Sstevel@tonic-gate * Type record as generic (not tag) reference 808*7c478bd9Sstevel@tonic-gate */ 809*7c478bd9Sstevel@tonic-gate 810*7c478bd9Sstevel@tonic-gate tnf_reference_t 811*7c478bd9Sstevel@tonic-gate tnf_tag_element_1(tnf_ops_t *ops, tnf_tag_data_t **tag_data_p, 812*7c478bd9Sstevel@tonic-gate tnf_record_p reference, tnf_tag_data_t *aux_tag_data) 813*7c478bd9Sstevel@tonic-gate { 814*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *tag_data; 815*7c478bd9Sstevel@tonic-gate 816*7c478bd9Sstevel@tonic-gate if (aux_tag_data) 817*7c478bd9Sstevel@tonic-gate if (!aux_tag_data->tag_index) 818*7c478bd9Sstevel@tonic-gate aux_tag_data->tag_desc(ops, aux_tag_data); 819*7c478bd9Sstevel@tonic-gate 820*7c478bd9Sstevel@tonic-gate /* tnf_derived has derived_base == TNF_NULL */ 821*7c478bd9Sstevel@tonic-gate if (!tag_data_p) 822*7c478bd9Sstevel@tonic-gate return ((tnf_reference_t)TNF_NULL); 823*7c478bd9Sstevel@tonic-gate 824*7c478bd9Sstevel@tonic-gate tag_data = *tag_data_p; 825*7c478bd9Sstevel@tonic-gate if (!tag_data->tag_index) 826*7c478bd9Sstevel@tonic-gate tag_data->tag_desc(ops, tag_data); 827*7c478bd9Sstevel@tonic-gate 828*7c478bd9Sstevel@tonic-gate return (tnf_ref32(ops, tag_data->tag_index, reference)); 829*7c478bd9Sstevel@tonic-gate } 830*7c478bd9Sstevel@tonic-gate 831*7c478bd9Sstevel@tonic-gate 832*7c478bd9Sstevel@tonic-gate /* 833*7c478bd9Sstevel@tonic-gate * Array of type records as generic (not tag) references 834*7c478bd9Sstevel@tonic-gate */ 835*7c478bd9Sstevel@tonic-gate 836*7c478bd9Sstevel@tonic-gate tnf_reference_t 837*7c478bd9Sstevel@tonic-gate tnf_tag_array_1(tnf_ops_t *ops, 838*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tag_data_array, 839*7c478bd9Sstevel@tonic-gate tnf_record_p reference, 840*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *tag_data) 841*7c478bd9Sstevel@tonic-gate { 842*7c478bd9Sstevel@tonic-gate tnf_record_p tag_index; 843*7c478bd9Sstevel@tonic-gate size_t record_size; 844*7c478bd9Sstevel@tonic-gate tnf_array_header_t *bufhdr; 845*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tmp; 846*7c478bd9Sstevel@tonic-gate tnf_reference_t *ref_p; 847*7c478bd9Sstevel@tonic-gate 848*7c478bd9Sstevel@tonic-gate tag_index = tag_data->tag_index ? tag_data->tag_index : 849*7c478bd9Sstevel@tonic-gate tag_data->tag_desc(ops, tag_data); 850*7c478bd9Sstevel@tonic-gate 851*7c478bd9Sstevel@tonic-gate if (!tag_data_array) 852*7c478bd9Sstevel@tonic-gate return ((tnf_reference_t)TNF_NULL); 853*7c478bd9Sstevel@tonic-gate 854*7c478bd9Sstevel@tonic-gate record_size = sizeof (*bufhdr); 855*7c478bd9Sstevel@tonic-gate tmp = tag_data_array; 856*7c478bd9Sstevel@tonic-gate while (*tmp++) 857*7c478bd9Sstevel@tonic-gate record_size += sizeof (tnf_reference_t); 858*7c478bd9Sstevel@tonic-gate 859*7c478bd9Sstevel@tonic-gate ALLOC2(ops, record_size, bufhdr, ops->mode); 860*7c478bd9Sstevel@tonic-gate 861*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, tag, tag_index); 862*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 863*7c478bd9Sstevel@tonic-gate ASSIGN(bufhdr, self_size, record_size); 864*7c478bd9Sstevel@tonic-gate 865*7c478bd9Sstevel@tonic-gate tmp = tag_data_array; 866*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 867*7c478bd9Sstevel@tonic-gate ref_p = (tnf_reference_t *)((char *)bufhdr + sizeof (*bufhdr)); 868*7c478bd9Sstevel@tonic-gate while (*tmp) { 869*7c478bd9Sstevel@tonic-gate *ref_p = tnf_tag_element_1(ops, *tmp, (tnf_record_p)ref_p, 870*7c478bd9Sstevel@tonic-gate TNF_NULL); 871*7c478bd9Sstevel@tonic-gate tmp++; 872*7c478bd9Sstevel@tonic-gate ref_p++; 873*7c478bd9Sstevel@tonic-gate } 874*7c478bd9Sstevel@tonic-gate 875*7c478bd9Sstevel@tonic-gate return (tnf_ref32(ops, (tnf_record_p)bufhdr, reference)); 876*7c478bd9Sstevel@tonic-gate } 877*7c478bd9Sstevel@tonic-gate 878*7c478bd9Sstevel@tonic-gate /* 879*7c478bd9Sstevel@tonic-gate * Array of properties (type records) 880*7c478bd9Sstevel@tonic-gate */ 881*7c478bd9Sstevel@tonic-gate 882*7c478bd9Sstevel@tonic-gate tnf_reference_t 883*7c478bd9Sstevel@tonic-gate tnf_tag_properties_1(tnf_ops_t *ops, 884*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ****tag_data_array, 885*7c478bd9Sstevel@tonic-gate tnf_record_p reference, 886*7c478bd9Sstevel@tonic-gate tnf_tag_data_t *tag_data) 887*7c478bd9Sstevel@tonic-gate { 888*7c478bd9Sstevel@tonic-gate if (!(tag_data->tag_index)) 889*7c478bd9Sstevel@tonic-gate tag_data->tag_desc(ops, tag_data); 890*7c478bd9Sstevel@tonic-gate 891*7c478bd9Sstevel@tonic-gate if (!tag_data_array) 892*7c478bd9Sstevel@tonic-gate return ((tnf_reference_t)TNF_NULL); 893*7c478bd9Sstevel@tonic-gate 894*7c478bd9Sstevel@tonic-gate return (tnf_tag_array_1(ops, *tag_data_array, reference, tag_data)); 895*7c478bd9Sstevel@tonic-gate } 896*7c478bd9Sstevel@tonic-gate 897*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 898*7c478bd9Sstevel@tonic-gate /* 899*7c478bd9Sstevel@tonic-gate * Initialize all core tag pointers defined in this file. 900*7c478bd9Sstevel@tonic-gate * CAUTION: tnf_tag_core_init is a function for kernel compilation. 901*7c478bd9Sstevel@tonic-gate */ 902*7c478bd9Sstevel@tonic-gate 903*7c478bd9Sstevel@tonic-gate void 904*7c478bd9Sstevel@tonic-gate tnf_tag_core_init(void) 905*7c478bd9Sstevel@tonic-gate { 906*7c478bd9Sstevel@tonic-gate #endif 907*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_inline); 908*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_tagged); 909*7c478bd9Sstevel@tonic-gate 910*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_scalar); 911*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_char); 912*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_int8); 913*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_uint8); 914*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_int16); 915*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_uint16); 916*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_int32); 917*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_uint32); 918*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_int64); 919*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_uint64); 920*7c478bd9Sstevel@tonic-gate 921*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_float32); 922*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_float64); 923*7c478bd9Sstevel@tonic-gate 924*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_array); 925*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_string); 926*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_type_array); 927*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_name_array); 928*7c478bd9Sstevel@tonic-gate 929*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_derived); 930*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_align); 931*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_derived_base); 932*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_element_type); 933*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_header_size); 934*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_name); 935*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_opaque); 936*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_properties); 937*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_self_size); 938*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_size); 939*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_slot_names); 940*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_slot_types); 941*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_tag); 942*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_tag_arg); 943*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_type_size); 944*7c478bd9Sstevel@tonic-gate 945*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_struct); 946*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_file_header); 947*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_block_header); 948*7c478bd9Sstevel@tonic-gate 949*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_type); 950*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_array_type); 951*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_derived_type); 952*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_scalar_type); 953*7c478bd9Sstevel@tonic-gate TAG_SET(tnf_struct_type); 954*7c478bd9Sstevel@tonic-gate 955*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 956*7c478bd9Sstevel@tonic-gate 957*7c478bd9Sstevel@tonic-gate /* Snap exported properties */ 958*7c478bd9Sstevel@tonic-gate tnf_user_struct_properties = std_struct_properties; 959*7c478bd9Sstevel@tonic-gate 960*7c478bd9Sstevel@tonic-gate } 961*7c478bd9Sstevel@tonic-gate 962*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 963*7c478bd9Sstevel@tonic-gate 964*7c478bd9Sstevel@tonic-gate tnf_tag_data_t ***tnf_user_struct_properties = std_struct_properties; 965*7c478bd9Sstevel@tonic-gate 966*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 967