docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / tnf_com.h
bloba562bc2538b496ed33719d8190095648bef02ca8
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 (c) 1994, by Sun Microsytems, Inc.
26 #ifndef _SYS_TNF_COM_H
27 #define _SYS_TNF_COM_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/types.h>
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
38 * NOTE: All types are in host (not necessarily file) format.
39 * Readers are responsible for endian or other transformation.
43 * Magic number(s): first word of TNF file.
45 * A writer stores the native unsigned 32-bit integer TNF_MAGIC.
46 * A same-endian reader will load it as TNF_MAGIC.
47 * A different-endian reader will load it as TNF_MAGIC_1.
50 #define TNF_MAGIC 0x544e4600
51 #define TNF_MAGIC_1 0x00464e54
54 * Fundamental types. Machine dependent.
57 typedef char tnf_char_t;
58 typedef signed char tnf_int8_t;
59 typedef unsigned char tnf_uint8_t;
60 typedef short tnf_int16_t;
61 typedef unsigned short tnf_uint16_t;
62 typedef int tnf_int32_t;
63 typedef unsigned int tnf_uint32_t;
64 typedef longlong_t tnf_int64_t;
65 typedef u_longlong_t tnf_uint64_t;
66 typedef float tnf_float32_t;
67 typedef double tnf_float64_t;
70 * TNF references
73 typedef tnf_int32_t tnf_ref32_t; /* self-relative, 32 bits */
74 typedef tnf_int16_t tnf_ref16_t; /* self-relative, 16 bits */
75 typedef tnf_uint16_t tnf_abs16_t; /* absolute, 16 bits */
77 /* Generation number for tag blocks */
78 #define TNF_TAG_GENERATION_NUM 0xffffffff
80 /* definition of space values */
81 #define TNF_SPACE_MASK 0x80000000
82 #define TNF_SPACE_PERMANENT 0x80000000
83 #define TNF_SPACE_RECLAIMABLE 0x0
84 #define TNF_SPACE_SIGN_BIT 0x40000000
86 /* Macros on setting or checking space values */
87 #define TNF_REF32_MAKE_PERMANENT(x) ((x) | TNF_SPACE_PERMANENT)
88 #define TNF_REF32_MAKE_RECLAIMABLE(x) ((x) & ~TNF_SPACE_MASK)
89 #define TNF_REF32_SPACE(x) \
90 ((tnf_uint32_t)(x) & TNF_SPACE_MASK)
91 #define TNF_REF32_IS_PERMANENT(x) \
92 (TNF_REF32_SPACE(x) == TNF_SPACE_PERMANENT)
93 #define TNF_REF32_IS_RECLAIMABLE(x) \
94 (TNF_REF32_SPACE(x) == TNF_SPACE_RECLAIMABLE)
95 #define TNF_REF32_SIGN_EXTEND(x) \
96 ((((tnf_uint32_t)(x) & TNF_SPACE_SIGN_BIT) == TNF_SPACE_SIGN_BIT) ? \
97 ((tnf_ref32_t)((tnf_uint32_t)(x) | TNF_SPACE_MASK)) : \
98 (x))
100 /* definition of references */
101 #define TNF_REF32_TYPE_MASK 0x3
102 #define TNF_REF32_T_FULL 0x0
103 #define TNF_REF32_T_FWD TNF_REF32_T_FULL
104 #define TNF_REF32_T_PAIR 0x1
105 #define TNF_REF32_T_TAG 0x2
106 #define TNF_REF32_T_RSVD 0x3
108 #define TNF_REF32_REF16_MASK 0xffff
110 #define TNF_REF32_TAG16_SHIFT 16
111 #define TNF_REF32_TAG16_MASK 0xffff
113 #define TNF_REF16_TYPE_MASK 0x3
115 #define TNF_TAG16_TYPE_MASK 0x3
116 #define TNF_TAG16_T_ABS TNF_REF32_T_PAIR
117 #define TNF_TAG16_T_REL TNF_REF32_T_FWD
119 #define TNF_NULL 0
121 /* Macros on tnf_ref32_t values: */
123 #define TNF_REF32_TYPE(x) \
124 ((tnf_uint32_t)(x) & TNF_REF32_TYPE_MASK)
125 #define TNF_REF32_VALUE(x) \
126 ((tnf_ref32_t)(((tnf_uint32_t)(x) & ~TNF_REF32_TYPE_MASK) & \
127 ~TNF_SPACE_MASK))
129 #define TNF_REF32_IS_FULL(x) (TNF_REF32_TYPE(x) == TNF_REF32_T_FULL)
130 #define TNF_REF32_IS_FWD(x) (TNF_REF32_TYPE(x) == TNF_REF32_T_FWD)
131 #define TNF_REF32_IS_PAIR(x) (TNF_REF32_TYPE(x) == TNF_REF32_T_PAIR)
132 #define TNF_REF32_IS_TAG(x) (TNF_REF32_TYPE(x) == TNF_REF32_T_TAG)
133 #define TNF_REF32_IS_RSVD(x) (TNF_REF32_TYPE(x) == TNF_REF32_T_RSVD)
134 #define TNF_REF32_IS_NULL(x) ((x) == TNF_NULL)
136 #define TNF_REF32_REF16(x) \
137 ((tnf_ref16_t)((tnf_uint32_t)(x) & TNF_REF32_REF16_MASK))
139 #define TNF_REF32_TAG16(x) \
140 ((tnf_ref16_t)(((tnf_uint32_t)(x) >> TNF_REF32_TAG16_SHIFT) \
141 & TNF_REF32_TAG16_MASK))
143 /* Macros on tnf_ref16_t values: */
145 #define TNF_REF16_TYPE(x) \
146 ((tnf_uint32_t)(x) & TNF_REF16_TYPE_MASK)
147 #define TNF_REF16_VALUE(x) \
148 ((tnf_ref16_t)((tnf_uint32_t)(x) & ~TNF_REF16_TYPE_MASK))
150 #define TNF_TAG16_TYPE(x) \
151 ((tnf_uint32_t)(x) & TNF_TAG16_TYPE_MASK)
153 #define TNF_TAG16_IS_REL(x) (TNF_TAG16_TYPE(x) == TNF_TAG16_T_REL)
154 #define TNF_TAG16_IS_ABS(x) (TNF_TAG16_TYPE(x) == TNF_TAG16_T_ABS)
156 /* The two kinds of values a tag16 can have: */
158 #define TNF_TAG16_REF16(x) \
159 ((tnf_ref16_t)((tnf_uint32_t)(x) & ~TNF_TAG16_TYPE_MASK))
160 #define TNF_TAG16_ABS16(x) \
161 ((tnf_abs16_t)((tnf_uint32_t)(x) & ~TNF_TAG16_TYPE_MASK))
164 * TNF binary layouts
167 struct tnf_tagged_hdr {
168 tnf_ref32_t tag; /* type record */
171 struct tnf_array_hdr {
172 tnf_ref32_t tag; /* type record */
173 tnf_uint32_t self_size; /* total size */
176 struct tnf_type_hdr {
177 tnf_ref32_t tag; /* type record */
178 tnf_ref32_t name; /* string record */
179 tnf_ref32_t properties; /* array of type records */
182 struct tnf_struct_type_hdr {
183 tnf_ref32_t tag; /* type record */
184 tnf_ref32_t name; /* string record */
185 tnf_ref32_t properties; /* array of type records */
186 tnf_ref32_t slot_types; /* array of type records */
187 tnf_uint32_t type_size; /* size of struct */
190 struct tnf_array_type_hdr {
191 tnf_ref32_t tag; /* type record */
192 tnf_ref32_t name; /* string record */
193 tnf_ref32_t properties; /* array of type records */
194 tnf_ref32_t slot_types; /* array of type records */
195 tnf_uint32_t header_size; /* size of array header */
198 struct tnf_derived_type_hdr {
199 tnf_ref32_t tag; /* type record */
200 tnf_ref32_t name; /* string record */
201 tnf_ref32_t properties; /* array of type records */
202 tnf_ref32_t derived_base; /* type record */
206 * File header, after magic #
209 #define TNF_FILE_VERSION 1
211 typedef struct tnf_file_header {
212 tnf_ref32_t tag;
213 tnf_uint32_t file_version; /* TNF_FILE_VERSION */
214 tnf_uint32_t file_header_size;
215 tnf_uint32_t file_log_size;
216 tnf_uint32_t block_header_size;
217 tnf_uint32_t block_size;
218 tnf_uint32_t directory_size;
219 tnf_uint32_t block_count;
220 tnf_uint32_t blocks_valid;
221 /* writer-specific information after this */
222 /* zero padding to end of block */
223 } tnf_file_header_t;
226 * Block header
229 typedef unsigned char tnf_byte_lock_t;
231 typedef struct tnf_block_header {
232 tnf_ref32_t tag;
233 tnf_uint32_t generation; /* (-1) => tag block */
234 tnf_uint16_t bytes_valid;
235 tnf_byte_lock_t A_lock;
236 tnf_byte_lock_t B_lock;
237 struct tnf_block_header *next_block; /* release list */
238 } tnf_block_header_t;
241 * TNF type names
244 #define TNF_N_INLINE "tnf_inline"
245 #define TNF_N_TAGGED "tnf_tagged"
247 #define TNF_N_SCALAR "tnf_scalar"
248 #define TNF_N_CHAR "tnf_char"
249 #define TNF_N_INT8 "tnf_int8"
250 #define TNF_N_UINT8 "tnf_uint8"
251 #define TNF_N_INT16 "tnf_int16"
252 #define TNF_N_UINT16 "tnf_uint16"
253 #define TNF_N_INT32 "tnf_int32"
254 #define TNF_N_UINT32 "tnf_uint32"
255 #define TNF_N_INT64 "tnf_int64"
256 #define TNF_N_UINT64 "tnf_uint64"
257 #define TNF_N_FLOAT32 "tnf_float32"
258 #define TNF_N_FLOAT64 "tnf_float64"
260 #define TNF_N_ARRAY "tnf_array"
261 #define TNF_N_STRING "tnf_string"
262 #define TNF_N_TYPE_ARRAY "tnf_type_array"
263 #define TNF_N_NAME_ARRAY "tnf_name_array"
265 #define TNF_N_ALIGN "tnf_align"
266 #define TNF_N_DERIVED "tnf_derived"
267 #define TNF_N_DERIVED_BASE "tnf_derived_base"
268 #define TNF_N_ELEMENT_TYPE "tnf_element_type"
269 #define TNF_N_HEADER_SIZE "tnf_header_size"
270 #define TNF_N_NAME "tnf_name"
271 #define TNF_N_OPAQUE "tnf_opaque"
272 #define TNF_N_PROPERTIES "tnf_properties"
273 #define TNF_N_SELF_SIZE "tnf_self_size"
274 #define TNF_N_SIZE "tnf_size"
275 #define TNF_N_SLOT_NAMES "tnf_slot_names"
276 #define TNF_N_SLOT_TYPES "tnf_slot_types"
277 #define TNF_N_TAG "tnf_tag"
278 #define TNF_N_TAG_ARG "tnf_tag_arg"
279 #define TNF_N_TYPE_SIZE "tnf_type_size"
281 #define TNF_N_STRUCT "tnf_struct"
283 #define TNF_N_ARRAY_TYPE "tnf_array_type"
284 #define TNF_N_DERIVED_TYPE "tnf_derived_type"
285 #define TNF_N_SCALAR_TYPE "tnf_scalar_type"
286 #define TNF_N_STRUCT_TYPE "tnf_struct_type"
287 #define TNF_N_TYPE "tnf_type"
290 * Reserved names for block and file header information
293 #define TNF_N_FILE_HEADER "tnf_file_header"
294 #define TNF_N_FILE_VERSION "file_version"
295 #define TNF_N_FILE_HEADER_SIZE "file_header_size"
296 #define TNF_N_FILE_LOGICAL_SIZE "file_logical_size"
297 #define TNF_N_BLOCK_HEADER_SIZE "block_header_size"
298 #define TNF_N_BLOCK_SIZE "block_size"
299 #define TNF_N_DIRECTORY_SIZE "directory_size"
300 #define TNF_N_BLOCK_COUNT "block_count"
301 #define TNF_N_BLOCKS_VALID "blocks_valid"
303 #define TNF_N_BLOCK_HEADER "tnf_block_header"
304 #define TNF_N_GENERATION "generation"
305 #define TNF_N_BYTES_VALID "bytes_valid"
308 * Reserved names for schedule record information
311 #define TNF_N_USER_SCHEDULE "tnf_user_schedule"
312 #define TNF_N_KERNEL_SCHEDULE "tnf_kernel_schedule"
314 #define TNF_N_PID "pid"
315 #define TNF_N_LWPID "lwpid"
316 #define TNF_N_TID "tid"
317 #define TNF_N_TIME_BASE "time_base"
318 #define TNF_N_TIME_DELTA "time_delta"
320 /* XXX TODO: kernel type names */
322 #ifdef __cplusplus
324 #endif
326 #endif /* _SYS_TNF_COM_H */