xref: /titanic_52/usr/src/common/sgsrtcid/sgsrtcid.h (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SGSRTCID_H
27 #define	_SGSRTCID_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 
36 /*
37  * This file defines the Rtc_id structure that is found at the beginning
38  * of linker configuration files. It resides at this level so that
39  * it can be accessed by file(1) as well as by crle(1) and the
40  * runtime linker (ld.so.1). The rest of the data structures for
41  * config files are found in usr/src/cmd/sgs/include/rtc.h
42  *
43  * The use of sizeof(char) data (no byte order issue) and explicit
44  * padding in the definition of Rtc_id ensures that it will have
45  * exactly the same layout on all systems, and will have a
46  * size of 16 bytes. The same layout means all systems can read it.
47  * the same size means that any data can be safely placed immediately
48  * following it, without the need for alignment.
49  */
50 
51 /*
52  * Identification header.
53  */
54 typedef struct {
55 	uchar_t	id_magic0;	/* RTC_ID_MAG0 */
56 	uchar_t	id_magic1;	/* RTC_ID_MAG1 */
57 	uchar_t	id_magic2;	/* RTC_ID_MAG2 */
58 	uchar_t	id_magic3;	/* RTC_ID_MAG0 */
59 	uchar_t	id_class;	/* File class/capacity (ELFCLASS constant) */
60 	uchar_t	id_data;	/* Data encoding (ELFDATA constant) */
61 	uchar_t	id_machine;	/* Architecture (ELF EM_ constant) */
62 	uchar_t	id_pad[9];	/* Ensure size is 16 bytes */
63 } Rtc_id;
64 
65 #define	RTC_ID_MAG0 '\077'	/* ? */
66 #define	RTC_ID_MAG1 'R'		/* Runtime */
67 #define	RTC_ID_MAG2 'L'		/* Linker */
68 #define	RTC_ID_MAG3 'C'		/* Configuration */
69 
70 /*
71  * Ensure that the largest machine constant will not grow beyond
72  * maximum value representable by an unsigned byte without our
73  * being alerted to it.
74  */
75 #if EM_NUM > 256
76 #error "Maximum machine constant size exceeded. Format requires revision."
77 #endif
78 
79 /*
80  * Check the 4 bytes starting at the given address to see if
81  * they contain the Rtc_id magic number. The type of the address
82  * is unimportant as long as it is valid, because RTC_ID_TEST()
83  * will cast it to (uchar_t *).
84  */
85 #define	RTC_ID_TEST(addr) \
86 	((RTC_ID_MAG0 == *((uchar_t *)addr)) && \
87 	(RTC_ID_MAG1 == *(((uchar_t *)addr) + 1)) && \
88 	(RTC_ID_MAG2 == *(((uchar_t *)addr) + 2)) && \
89 	(RTC_ID_MAG3 == *(((uchar_t *)addr) + 3)))
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _SGSRTCID_H */
96