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.
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.
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]
23 * Copyright 2009 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
36 #include <sys/types.h>
41 #include <libdevinfo.h>
42 #include <sys/systeminfo.h>
43 #include <sys/byteorder.h>
49 #include <fru_access.h>
53 typedef enum {CONTAINER_TYPE
, SECTION_TYPE
, SEGMENT_TYPE
, PACKET_TYPE
} object_t
;
55 #define TABLE_SIZE 64 /* hash table size */
59 #define SECTION_HDR_TAG 0x08
60 #define SECTION_HDR_VER 0x0001
61 #define SECTION_HDR_LENGTH 0x06
62 #define SECTION_HDR_CRC8 0x00
63 #define SECTION_HDR_VER_BIT0 0x00
64 #define SECTION_HDR_VER_BIT1 0x01
66 #define READ_ONLY_SECTION 1 /* section is read-only */
68 #define GET_SEGMENT_DESCRIPTOR \
69 (BE_16(seg_layout->descriptor[1])| \
70 BE_16(seg_layout->descriptor[0] << 16))
72 #define GET_SECTION_HDR_VERSION \
73 (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
75 /* Segment Trailer Tag */
76 #define SEG_TRAILER_TAG 0x0C
78 /* defines fixed segment */
79 #define SEGMENT_FIXED 1
84 unsigned read_only
: 1;
93 ENC_STANDARD
= 0, /* proper fruid data */
94 ENC_SPD
/* serial presence detect data */
98 sectdescbit_t description
;
99 uint32_t address
; /* for SEEPROMS this is the offset */
101 sectencoding_t encoding
;
104 typedef uint16_t headerrev_t
;
106 #define MAX_NUMOF_SECTION 2
109 headerrev_t header_ver
;
111 sectioninfo_t section_info
[MAX_NUMOF_SECTION
];
115 /* section header layout */
117 uint8_t headertag
; /* section header tag */
118 uint8_t headerversion
[2]; /* header version (msb) */
119 uint8_t headerlength
; /* header length */
120 uint8_t headercrc8
; /* crc8 */
121 uint8_t segmentcount
; /* total number of segment */
124 /* segment header layout */
126 uint16_t name
; /* segment name */
127 uint16_t descriptor
[2]; /* descriptor (msb) */
128 uint16_t offset
; /* segment data offset */
129 uint16_t length
; /* segment length */
132 /* segment information used in finding new offset for a new segment */
134 int segnum
; /* segment number */
135 int offset
; /* segment offset */
136 int length
; /* segment length */
137 int fixed
; /* fixed or non-fixed segment */
140 typedef uint64_t handle_t
;
144 /* packet hash object */
146 handle_t segment_hdl
; /* segment handle */
151 uint32_t payload_offset
;
152 struct hash_obj
*next
;
155 /* segment hash object */
157 handle_t section_hdl
; /* section handle */
158 int num_of_packets
; /* in a segment */
161 struct hash_obj
*pkt_obj_list
; /* packet object list */
162 struct hash_obj
*next
;
165 /* section hash object */
167 handle_t cont_hdl
; /* container handle */
169 sectencoding_t encoding
; /* standard or needing interpretation */
170 int num_of_segment
; /* in a section */
171 struct hash_obj
*seg_obj_list
; /* points to segment objects list */
172 struct hash_obj
*next
;
175 /* container hash object */
177 char device_pathname
[PATH_MAX
]; /* device name */
178 int num_of_section
; /* num of section in container */
179 struct hash_obj
*sec_obj_list
; /* points to section objects list */
183 typedef struct hash_obj
{
187 container_obj_t
*cont_obj
;
188 section_obj_t
*sec_obj
;
189 segment_obj_t
*seg_obj
;
190 packet_obj_t
*pkt_obj
;
192 struct hash_obj
*next
;
193 struct hash_obj
*prev
;
196 unsigned char compute_crc8(unsigned char *bytes
, int length
);
197 long compute_crc32(unsigned char *bytes
, int length
);
198 long compute_checksum32(unsigned char *bytes
, int length
);
204 #endif /* _FRU_ACCESS_IMPL_H */