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 2004 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"
55 /* converts slot# to ipmb addr */
56 #define IPMB_ADDR(_X) (((_X) < 10) ? (0xb0 + 2 * ((_X) - 1)) :\
58 #define MANR_TAG 0xF80010B7 /* ManR tag */
59 #define SEG_NAME_LEN 2
61 #define MANR_TIME_LEN 4
62 #define MANR_FRUDESCR_LEN 80
63 #define MANR_MFRLOC_LEN 64
64 #define MANR_PARTNUM_LEN 7
65 #define MANR_SERIALNUM_LEN 6
66 #define MANR_VENDORNAME_LEN 2
67 #define MANR_DASHLVL_LEN 2
68 #define MANR_REVLVL_LEN 2
69 #define MANR_FRUNAME_LEN 16
71 #define NO_FRUDATA 0x0
72 #define IPMI_FORMAT 0x1
73 #define SUN_FORMAT 0x2
75 /* These are newly introduced #defines for Snowbird */
76 #define INPUT_FILE "/dev/ctsmc"
77 #define NUM_OF_SECTIONS 2
78 #define DYNAMIC_OFFSET 0x0
79 #define STATIC_OFFSET 0x1800
80 #define WRITE_SECTION 0
81 #define DYNAMIC_LENGTH (6 * 1024); /* 6k bytes */
82 #define STATIC_LENGTH (2 * 1024); /* 2k bytes */
83 #define MANR_SIZE 183 /* MANR record size in bytes */
85 #define PICL_SLOT_CPCI "cpci"
86 #define PICL_SLOT_PCI "pci"
87 #define PICL_NODE_CHASSIS "chassis"
88 #define SD_SEGMENT_NAME "SD"
89 #define SD_SEGMENT_DESCRIPTOR 0x00004924
90 #define SEGMENT_TRAILER_LEN 1
91 #define SEGMENT_CHKSM_LEN 4
93 /* format structure */
96 int sun_lun
; /* this info comes from SDR */
97 int sun_device_id
; /* this info comes from SDR */
102 /* ManR payload structure */
104 char timestamp
[MANR_TIME_LEN
];
105 char fru_descr
[MANR_FRUDESCR_LEN
];
106 char manufacture_loc
[MANR_MFRLOC_LEN
];
107 char sun_part_no
[MANR_PARTNUM_LEN
];
108 char sun_serial_no
[MANR_SERIALNUM_LEN
];
109 char vendor_name
[MANR_VENDORNAME_LEN
]; /* JEDEC CODE */
110 char inital_hw_dash_lvl
[MANR_DASHLVL_LEN
];
111 char inital_hw_rev_lvl
[MANR_REVLVL_LEN
];
112 char fru_short_name
[MANR_FRUNAME_LEN
];
115 typedef enum {CONTAINER_TYPE
, SECTION_TYPE
, SEGMENT_TYPE
, PACKET_TYPE
} object_t
;
117 #define TABLE_SIZE 64 /* hash table size */
120 #define SECTION_HDR_TAG 0x08
121 #define SECTION_HDR_VER 0x0001
122 #define SECTION_HDR_LENGTH 0x06
123 #define SECTION_HDR_CRC8 0x00
124 #define SECTION_HDR_VER_BIT0 0x00
125 #define SECTION_HDR_VER_BIT1 0x01
127 #define READ_ONLY_SECTION 1 /* section is read-only */
129 #define GET_SEGMENT_DESCRIPTOR \
130 (seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16)
132 #define GET_SECTION_HDR_VERSION \
133 (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
135 /* Segment Trailer Tag */
136 #define SEG_TRAILER_TAG 0x0C
138 /* defines fixed segment */
139 #define SEGMENT_FIXED 1
141 #define DEFAULT_FD -1
142 #define DEFAULT_SEQN -1
143 #define FRUACCESS_MSG_ID 11
148 unsigned read_only
: 1;
157 sectdescbit_t description
;
158 uint32_t address
; /* for SEEPROMS this is the offset */
162 typedef uint16_t headerrev_t
;
164 #define MAX_NUMOF_SECTION 2
167 headerrev_t header_ver
;
169 sectioninfo_t section_info
[MAX_NUMOF_SECTION
];
172 /* section header layout */
174 uint8_t headertag
; /* section header tag */
175 uint8_t headerversion
[2]; /* header version (msb) */
176 uint8_t headerlength
; /* header length */
177 uint8_t headercrc8
; /* crc8 */
178 uint8_t segmentcount
; /* total number of segment */
181 /* segment header layout */
183 uint16_t name
; /* segment name */
184 uint16_t descriptor
[2]; /* descriptor (msb) */
185 uint16_t offset
; /* segment data offset */
186 uint16_t length
; /* segment length */
189 /* segment information used in finding new offset for a new segment */
191 int segnum
; /* segment number */
192 int offset
; /* segment offset */
193 int length
; /* segment length */
194 int fixed
; /* fixed or non-fixed segment */
197 typedef uint64_t handle_t
;
201 /* packet hash object */
203 handle_t segment_hdl
; /* segment handle */
207 payload_t payload_data
; /* reqd for ipmi format */
209 uint32_t payload_offset
;
210 struct hash_obj
*next
;
213 /* segment hash object */
215 handle_t section_hdl
; /* section handle */
216 int num_of_packets
; /* in a segment */
219 struct hash_obj
*pkt_obj_list
; /* packet object list */
220 struct hash_obj
*next
;
223 /* section hash object */
225 handle_t cont_hdl
; /* container handle */
227 int num_of_segment
; /* in a section */
228 struct hash_obj
*seg_obj_list
; /* points to segment objects list */
229 struct hash_obj
*next
;
232 /* contianer hash object */
234 char device_pathname
[PATH_MAX
]; /* device name */
235 int num_of_section
; /* num of section in container */
237 struct hash_obj
*sec_obj_list
; /* points to section objects list */
241 typedef struct hash_obj
{
245 container_obj_t
*cont_obj
;
246 section_obj_t
*sec_obj
;
247 segment_obj_t
*seg_obj
;
248 packet_obj_t
*pkt_obj
;
250 struct hash_obj
*next
;
251 struct hash_obj
*prev
;
254 extern unsigned char compute_crc8(unsigned char *bytes
, int length
);
255 extern long compute_crc32(unsigned char *bytes
, int length
);
256 extern long compute_checksum32(unsigned char *bytes
, int length
);
262 #endif /* _FRU_ACCESS_IMPL_H */