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>
42 #include <libdevinfo.h>
43 #include <sys/systeminfo.h>
44 #include <sys/byteorder.h>
50 #include <fru_access.h>
54 typedef enum {CONTAINER_TYPE
, SECTION_TYPE
, SEGMENT_TYPE
, PACKET_TYPE
} object_t
;
56 #define TABLE_SIZE 64 /* hash table size */
60 #define SECTION_HDR_TAG 0x08
61 #define SECTION_HDR_VER 0x0001
62 #define SECTION_HDR_LENGTH 0x06
63 #define SECTION_HDR_CRC8 0x00
64 #define SECTION_HDR_VER_BIT0 0x00
65 #define SECTION_HDR_VER_BIT1 0x01
67 #define READ_ONLY_SECTION 1 /* section is read-only */
69 #define GET_SEGMENT_DESCRIPTOR \
70 (BE_16(seg_layout->descriptor[1])| \
71 BE_16(seg_layout->descriptor[0] << 16))
73 #define GET_SECTION_HDR_VERSION \
74 (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
76 /* Segment Trailer Tag */
77 #define SEG_TRAILER_TAG 0x0C
79 /* defines fixed segment */
80 #define SEGMENT_FIXED 1
85 unsigned read_only
: 1;
94 ENC_STANDARD
= 0, /* proper fruid data */
95 ENC_SPD
/* serial presence detect data */
99 sectdescbit_t description
;
100 uint32_t address
; /* for SEEPROMS this is the offset */
102 sectencoding_t encoding
;
105 typedef uint16_t headerrev_t
;
107 #define MAX_NUMOF_SECTION 2
110 headerrev_t header_ver
;
112 sectioninfo_t section_info
[MAX_NUMOF_SECTION
];
116 /* section header layout */
118 uint8_t headertag
; /* section header tag */
119 uint8_t headerversion
[2]; /* header version (msb) */
120 uint8_t headerlength
; /* header length */
121 uint8_t headercrc8
; /* crc8 */
122 uint8_t segmentcount
; /* total number of segment */
125 /* segment header layout */
127 uint16_t name
; /* segment name */
128 uint16_t descriptor
[2]; /* descriptor (msb) */
129 uint16_t offset
; /* segment data offset */
130 uint16_t length
; /* segment length */
133 /* segment information used in finding new offset for a new segment */
135 int segnum
; /* segment number */
136 int offset
; /* segment offset */
137 int length
; /* segment length */
138 int fixed
; /* fixed or non-fixed segment */
141 typedef uint64_t handle_t
;
145 /* packet hash object */
147 handle_t segment_hdl
; /* segment handle */
152 uint32_t payload_offset
;
153 struct hash_obj
*next
;
156 /* segment hash object */
158 handle_t section_hdl
; /* section handle */
159 int num_of_packets
; /* in a segment */
162 struct hash_obj
*pkt_obj_list
; /* packet object list */
163 struct hash_obj
*next
;
166 /* section hash object */
168 handle_t cont_hdl
; /* container handle */
170 sectencoding_t encoding
; /* standard or needing interpretation */
171 int num_of_segment
; /* in a section */
172 struct hash_obj
*seg_obj_list
; /* points to segment objects list */
173 struct hash_obj
*next
;
176 /* container hash object */
178 char device_pathname
[PATH_MAX
]; /* device name */
179 int num_of_section
; /* num of section in container */
180 struct hash_obj
*sec_obj_list
; /* points to section objects list */
184 typedef struct hash_obj
{
188 container_obj_t
*cont_obj
;
189 section_obj_t
*sec_obj
;
190 segment_obj_t
*seg_obj
;
191 packet_obj_t
*pkt_obj
;
193 struct hash_obj
*next
;
194 struct hash_obj
*prev
;
197 unsigned char compute_crc8(unsigned char *bytes
, int length
);
198 long compute_crc32(unsigned char *bytes
, int length
);
199 long compute_checksum32(unsigned char *bytes
, int length
);
205 #endif /* _FRU_ACCESS_IMPL_H */