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 2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #ifndef _FRU_ACCESS_IMPL_H
29 #define _FRU_ACCESS_IMPL_H
31 #pragma ident "%Z%%M% %I% %E% SMI"
39 #include <sys/types.h>
44 #include <libdevinfo.h>
45 #include <sys/systeminfo.h>
53 #include "fru_access.h"
56 typedef enum {CONTAINER_TYPE
, SECTION_TYPE
, SEGMENT_TYPE
, PACKET_TYPE
} object_t
;
58 #define TABLE_SIZE 64 /* hash table size */
60 /* container configuration file name */
61 #define CONTAINER_CONF_FILE \
62 "/usr/platform/SUNW,Serverblade1/lib/fru_container.conf"
65 #define SECTION_HDR_TAG 0x08
66 #define SECTION_HDR_VER 0x0001
67 #define SECTION_HDR_LENGTH 0x06
68 #define SECTION_HDR_CRC8 0x00
69 #define SECTION_HDR_VER_BIT0 0x00
70 #define SECTION_HDR_VER_BIT1 0x01
72 #define READ_ONLY_SECTION 1 /* section is read-only */
74 #define CRC32_SECTION 0
75 #define CHECKSUM32_SECTION 1
77 #define GET_SEGMENT_DESCRIPTOR \
78 (seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16)
80 #define GET_SECTION_HDR_VERSION \
81 (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
83 /* Segment Trailer Tag */
84 #define SEG_TRAILER_TAG 0x0C
86 /* defines fixed segment */
87 #define SEGMENT_FIXED 1
92 unsigned read_only
: 1;
93 unsigned chk_type
: 1;
102 sectdescbit_t description
;
103 uint32_t address
; /* for SEEPROMS this is the offset */
107 typedef uint16_t headerrev_t
;
109 #define MAX_NUMOF_SECTION 2
112 headerrev_t header_ver
;
114 sectioninfo_t section_info
[MAX_NUMOF_SECTION
];
118 /* section header layout */
120 uint8_t headertag
; /* section header tag */
121 uint8_t headerversion
[2]; /* header version (msb) */
122 uint8_t headerlength
; /* header length */
123 uint8_t headercrc8
; /* crc8 */
124 uint8_t segmentcount
; /* total number of segment */
127 /* segment header layout */
129 uint16_t name
; /* segment name */
130 uint16_t descriptor
[2]; /* descriptor (msb) */
131 uint16_t offset
; /* segment data offset */
132 uint16_t length
; /* segment length */
135 /* segment information used in finding new offset for a new segment */
137 int segnum
; /* segment number */
138 int offset
; /* segment offset */
139 int length
; /* segment length */
140 int fixed
; /* fixed or non-fixed segment */
143 typedef uint64_t handle_t
;
147 /* packet hash object */
149 handle_t segment_hdl
; /* segment handle */
153 uint32_t payload_offset
;
154 struct hash_obj
*next
;
157 /* segment hash object */
159 handle_t section_hdl
; /* section handle */
160 int num_of_packets
; /* in a segment */
163 struct hash_obj
*pkt_obj_list
; /* packet object list */
164 struct hash_obj
*next
;
167 /* section hash object */
169 handle_t cont_hdl
; /* container handle */
171 int num_of_segment
; /* in a section */
172 int checksum_method
; /* indicates the checksum method used */
173 struct hash_obj
*seg_obj_list
; /* points to segment objects list */
174 struct hash_obj
*next
;
177 /* container hash object */
179 char device_pathname
[PATH_MAX
]; /* device name */
180 int num_of_section
; /* num of section in container */
181 struct hash_obj
*sec_obj_list
; /* points to section objects list */
185 typedef struct hash_obj
{
189 container_obj_t
*cont_obj
;
190 section_obj_t
*sec_obj
;
191 segment_obj_t
*seg_obj
;
192 packet_obj_t
*pkt_obj
;
194 struct hash_obj
*next
;
195 struct hash_obj
*prev
;
198 unsigned char compute_crc8(unsigned char *bytes
, int length
);
199 long compute_crc32(unsigned char *bytes
, int length
);
200 long compute_checksum32(unsigned char *bytes
, int length
);
206 #endif /* _FRU_ACCESS_IMPL_H */