1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #ifndef	_FRU_DATA_IMPL_H
29*7c478bd9Sstevel@tonic-gate #define	_FRU_DATA_IMPL_H
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
34*7c478bd9Sstevel@tonic-gate extern "C" {
35*7c478bd9Sstevel@tonic-gate #endif
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include <dlfcn.h>
38*7c478bd9Sstevel@tonic-gate #include <errno.h>
39*7c478bd9Sstevel@tonic-gate #include <fcntl.h>
40*7c478bd9Sstevel@tonic-gate #include <stdio.h>
41*7c478bd9Sstevel@tonic-gate #include <string.h>
42*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
43*7c478bd9Sstevel@tonic-gate #include <strings.h>
44*7c478bd9Sstevel@tonic-gate #include "libfru.h"
45*7c478bd9Sstevel@tonic-gate #include "picldefs.h"
46*7c478bd9Sstevel@tonic-gate #include "fru_access.h"
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #define	TABLE_SIZE			64	/* hash table size */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	NUM_OF_COL_IN_PKT_TABLE		2
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #define	FRUTREE_PATH		"/frutree"  /* picltree path of frutree node */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	FRUDATA_CONFFILE_NAME	\
55*7c478bd9Sstevel@tonic-gate 		"/usr/platform/%s/lib/picl/plugins/libpiclfrudata.conf"
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	SECNAMESIZE		10	/* section name length */
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate typedef	enum {CONTAINER_NODE, SECTION_NODE, SEGMENT_NODE, PACKET_NODE} node_t;
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate typedef	uint64_t		fru_access_hdl_t;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate struct	hash_obj;
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate typedef struct {
66*7c478bd9Sstevel@tonic-gate 	fru_access_hdl_t	pkt_handle;	/* fru access handle */
67*7c478bd9Sstevel@tonic-gate 	size_t			paylen;		/* payload length */
68*7c478bd9Sstevel@tonic-gate 	fru_tag_t		tag;
69*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*next;
70*7c478bd9Sstevel@tonic-gate } packet_node_t;
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate typedef struct {
73*7c478bd9Sstevel@tonic-gate 	fru_access_hdl_t	segment_hdl;	/* fru_access handle */
74*7c478bd9Sstevel@tonic-gate 	picl_nodehdl_t		sec_nodehdl;	/* section node handle */
75*7c478bd9Sstevel@tonic-gate 	int			num_of_pkt;	/* number of packet */
76*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*packet_list;
77*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*next;
78*7c478bd9Sstevel@tonic-gate } segment_node_t;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate typedef struct {
81*7c478bd9Sstevel@tonic-gate 	fru_access_hdl_t	section_hdl;	/* fru_access handle */
82*7c478bd9Sstevel@tonic-gate 	picl_nodehdl_t		container_hdl;	/* container node hdl. */
83*7c478bd9Sstevel@tonic-gate 	int			num_of_segment; /* number of segment */
84*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*segment_list;
85*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*next;
86*7c478bd9Sstevel@tonic-gate } section_node_t;
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate typedef struct {
89*7c478bd9Sstevel@tonic-gate 	fru_access_hdl_t	cont_hdl;	/* fru_access handle */
90*7c478bd9Sstevel@tonic-gate 	int			num_of_section; /* number of section */
91*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*section_list;
92*7c478bd9Sstevel@tonic-gate } container_node_t;
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate typedef	struct	hash_obj {
95*7c478bd9Sstevel@tonic-gate 	uint64_t	picl_hdl;		/* picl node/property handle */
96*7c478bd9Sstevel@tonic-gate 	node_t		object_type;
97*7c478bd9Sstevel@tonic-gate 	union	{
98*7c478bd9Sstevel@tonic-gate 		container_node_t	*cont_node;	/* container */
99*7c478bd9Sstevel@tonic-gate 		section_node_t		*sec_node;	/* section   */
100*7c478bd9Sstevel@tonic-gate 		segment_node_t		*seg_node;	/* segment   */
101*7c478bd9Sstevel@tonic-gate 		packet_node_t		*pkt_node;	/* packet    */
102*7c478bd9Sstevel@tonic-gate 	} u;
103*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*next;
104*7c478bd9Sstevel@tonic-gate 	struct hash_obj		*prev;
105*7c478bd9Sstevel@tonic-gate } hash_obj_t;
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate typedef	struct  container_tbl {
108*7c478bd9Sstevel@tonic-gate 	uint64_t		picl_hdl;
109*7c478bd9Sstevel@tonic-gate 	pthread_rwlock_t	rwlock;
110*7c478bd9Sstevel@tonic-gate 	pthread_cond_t		cond_var;
111*7c478bd9Sstevel@tonic-gate 	hash_obj_t		*hash_obj;
112*7c478bd9Sstevel@tonic-gate 	struct  container_tbl	*next;
113*7c478bd9Sstevel@tonic-gate 	struct  container_tbl	*prev;
114*7c478bd9Sstevel@tonic-gate } container_tbl_t;
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
117*7c478bd9Sstevel@tonic-gate }
118*7c478bd9Sstevel@tonic-gate #endif
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #endif	/* _FRU_DATA_IMPL_H */
121