cmd: remove sparc-only virtinfo
[unleashed.git] / usr / src / cmd / picl / plugins / sun4u / blade / fruaccess / fru_access_impl.h
blob85d9d36e73d3b9451c400603f9f95bf6412f3acc
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
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"
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <sys/types.h>
40 #include <unistd.h>
41 #include <sys/stat.h>
42 #include <fcntl.h>
43 #include <strings.h>
44 #include <libdevinfo.h>
45 #include <sys/systeminfo.h>
46 #include <picl.h>
47 #include <picltree.h>
48 #include "picldefs.h"
49 #include <syslog.h>
50 #include <errno.h>
51 #include "libfru.h"
52 #include "fru_tag.h"
53 #include "fru_access.h"
55 /* object types */
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"
64 /* section header */
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
89 typedef union {
90 uint32_t all_bits;
91 struct {
92 unsigned read_only : 1;
93 unsigned chk_type : 1;
94 unsigned unused : 8;
95 unsigned : 8;
96 unsigned : 8;
97 unsigned : 6;
98 } field;
99 } sectdescbit_t;
101 typedef struct {
102 sectdescbit_t description;
103 uint32_t address; /* for SEEPROMS this is the offset */
104 uint32_t size;
105 } sectioninfo_t;
107 typedef uint16_t headerrev_t;
109 #define MAX_NUMOF_SECTION 2
111 typedef struct {
112 headerrev_t header_ver;
113 int num_sections;
114 sectioninfo_t section_info[MAX_NUMOF_SECTION];
115 } container_info_t;
118 /* section header layout */
119 typedef struct {
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 */
125 } section_layout_t;
127 /* segment header layout */
128 typedef struct {
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 */
133 } segment_layout_t;
135 /* segment information used in finding new offset for a new segment */
136 typedef struct {
137 int segnum; /* segment number */
138 int offset; /* segment offset */
139 int length; /* segment length */
140 int fixed; /* fixed or non-fixed segment */
141 } seg_info_t;
143 typedef uint64_t handle_t;
145 struct hash_obj;
147 /* packet hash object */
148 typedef struct {
149 handle_t segment_hdl; /* segment handle */
150 fru_tag_t tag;
151 int tag_size;
152 uint32_t paylen;
153 uint32_t payload_offset;
154 struct hash_obj *next;
155 } packet_obj_t;
157 /* segment hash object */
158 typedef struct {
159 handle_t section_hdl; /* section handle */
160 int num_of_packets; /* in a segment */
161 int trailer_offset;
162 segment_t segment;
163 struct hash_obj *pkt_obj_list; /* packet object list */
164 struct hash_obj *next;
165 } segment_obj_t;
167 /* section hash object */
168 typedef struct {
169 handle_t cont_hdl; /* container handle */
170 section_t section;
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;
175 } section_obj_t;
177 /* container hash object */
178 typedef struct {
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 */
182 } container_obj_t;
184 /* hash object */
185 typedef struct hash_obj {
186 int object_type;
187 handle_t obj_hdl;
188 union {
189 container_obj_t *cont_obj;
190 section_obj_t *sec_obj;
191 segment_obj_t *seg_obj;
192 packet_obj_t *pkt_obj;
193 } u;
194 struct hash_obj *next;
195 struct hash_obj *prev;
196 } hash_obj_t;
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);
202 #ifdef __cplusplus
204 #endif
206 #endif /* _FRU_ACCESS_IMPL_H */