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
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]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _FRU_ACCESS_IMPL_H
28 #define _FRU_ACCESS_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
38 #include <sys/types.h>
43 #include <libdevinfo.h>
44 #include <sys/systeminfo.h>
53 #include "fru_access.h"
57 typedef enum {CONTAINER_TYPE
, SECTION_TYPE
, SEGMENT_TYPE
, PACKET_TYPE
} object_t
;
59 #define TABLE_SIZE 64 /* hash table size */
61 /* container configuration file name */
62 #define FRU_CONTAINER_CONF "fru_container.conf"
63 #define CONTAINER_DIR "/usr/platform/sun4u/lib"
66 #define SECTION_HDR_TAG 0x08
67 #define SECTION_HDR_VER 0x0001
68 #define SECTION_HDR_LENGTH 0x06
69 #define SECTION_HDR_CRC8 0x00
70 #define SECTION_HDR_VER_BIT0 0x00
71 #define SECTION_HDR_VER_BIT1 0x01
73 #define READ_ONLY_SECTION 1 /* section is read-only */
75 #define GET_SEGMENT_DESCRIPTOR \
76 (seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16)
78 #define GET_SECTION_HDR_VERSION \
79 (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
81 /* Segment Trailer Tag */
82 #define SEG_TRAILER_TAG 0x0C
84 /* defines fixed segment */
85 #define SEGMENT_FIXED 1
90 unsigned read_only
: 1;
99 ENC_STANDARD
= 0, /* proper fruid data */
100 ENC_SPD
/* serial presence detect data */
104 sectdescbit_t description
;
105 uint32_t address
; /* for SEEPROMS this is the offset */
107 sectencoding_t encoding
;
110 typedef uint16_t headerrev_t
;
112 #define MAX_NUMOF_SECTION 2
115 headerrev_t header_ver
;
117 sectioninfo_t section_info
[MAX_NUMOF_SECTION
];
121 /* section header layout */
123 uint8_t headertag
; /* section header tag */
124 uint8_t headerversion
[2]; /* header version (msb) */
125 uint8_t headerlength
; /* header length */
126 uint8_t headercrc8
; /* crc8 */
127 uint8_t segmentcount
; /* total number of segment */
130 /* segment header layout */
132 uint16_t name
; /* segment name */
133 uint16_t descriptor
[2]; /* descriptor (msb) */
134 uint16_t offset
; /* segment data offset */
135 uint16_t length
; /* segment length */
138 /* segment information used in finding new offset for a new segment */
140 int segnum
; /* segment number */
141 int offset
; /* segment offset */
142 int length
; /* segment length */
143 int fixed
; /* fixed or non-fixed segment */
146 typedef uint64_t handle_t
;
150 /* packet hash object */
152 handle_t segment_hdl
; /* segment handle */
157 uint32_t payload_offset
;
158 struct hash_obj
*next
;
161 /* segment hash object */
163 handle_t section_hdl
; /* section handle */
164 int num_of_packets
; /* in a segment */
167 struct hash_obj
*pkt_obj_list
; /* packet object list */
168 struct hash_obj
*next
;
171 /* section hash object */
173 handle_t cont_hdl
; /* container handle */
175 sectencoding_t encoding
; /* standard or needing interpretation */
176 int num_of_segment
; /* in a section */
177 struct hash_obj
*seg_obj_list
; /* points to segment objects list */
178 struct hash_obj
*next
;
181 /* container hash object */
183 char device_pathname
[PATH_MAX
]; /* device name */
184 int num_of_section
; /* num of section in container */
185 struct hash_obj
*sec_obj_list
; /* points to section objects list */
189 typedef struct hash_obj
{
193 container_obj_t
*cont_obj
;
194 section_obj_t
*sec_obj
;
195 segment_obj_t
*seg_obj
;
196 packet_obj_t
*pkt_obj
;
198 struct hash_obj
*next
;
199 struct hash_obj
*prev
;
202 unsigned char compute_crc8(unsigned char *bytes
, int length
);
203 long compute_crc32(unsigned char *bytes
, int length
);
204 long compute_checksum32(unsigned char *bytes
, int length
);
210 #endif /* _FRU_ACCESS_IMPL_H */