1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 
28 #ifndef	_FRU_DATA_IMPL_H
29 #define	_FRU_DATA_IMPL_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <dlfcn.h>
36 #include <errno.h>
37 #include <fcntl.h>
38 #include <stdio.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include <strings.h>
42 #include "libfru.h"
43 #include "picldefs.h"
44 #include "fru_access.h"
45 
46 #define	TABLE_SIZE			64	/* hash table size */
47 
48 #define	NUM_OF_COL_IN_PKT_TABLE		2
49 
50 #define	FRUTREE_PATH		"/frutree"  /* picltree path of frutree node */
51 
52 #define	FRUDATA_CONFFILE_NAME	\
53 		"/usr/platform/%s/lib/picl/plugins/libpiclfrudata.conf"
54 
55 #define	SECNAMESIZE		10	/* section name length */
56 
57 typedef	enum {CONTAINER_NODE, SECTION_NODE, SEGMENT_NODE, PACKET_NODE} node_t;
58 
59 typedef	uint64_t		fru_access_hdl_t;
60 
61 struct	hash_obj;
62 
63 typedef struct {
64 	fru_access_hdl_t	pkt_handle;	/* fru access handle */
65 	size_t			paylen;		/* payload length */
66 	fru_tag_t		tag;
67 	struct hash_obj		*next;
68 } packet_node_t;
69 
70 typedef struct {
71 	fru_access_hdl_t	segment_hdl;	/* fru_access handle */
72 	picl_nodehdl_t		sec_nodehdl;	/* section node handle */
73 	int			num_of_pkt;	/* number of packet */
74 	struct hash_obj		*packet_list;
75 	struct hash_obj		*next;
76 } segment_node_t;
77 
78 typedef struct {
79 	fru_access_hdl_t	section_hdl;	/* fru_access handle */
80 	picl_nodehdl_t		container_hdl;	/* container node hdl. */
81 	int			num_of_segment; /* number of segment */
82 	struct hash_obj		*segment_list;
83 	struct hash_obj		*next;
84 } section_node_t;
85 
86 typedef struct {
87 	fru_access_hdl_t	cont_hdl;	/* fru_access handle */
88 	int			num_of_section; /* number of section */
89 	struct hash_obj		*section_list;
90 } container_node_t;
91 
92 typedef	struct	hash_obj {
93 	uint64_t	picl_hdl;		/* picl node/property handle */
94 	node_t		object_type;
95 	union	{
96 		container_node_t	*cont_node;	/* container */
97 		section_node_t		*sec_node;	/* section   */
98 		segment_node_t		*seg_node;	/* segment   */
99 		packet_node_t		*pkt_node;	/* packet    */
100 	} u;
101 	struct hash_obj		*next;
102 	struct hash_obj		*prev;
103 } hash_obj_t;
104 
105 typedef	struct  container_tbl {
106 	uint64_t		picl_hdl;
107 	pthread_rwlock_t	rwlock;
108 	pthread_cond_t		cond_var;
109 	hash_obj_t		*hash_obj;
110 	struct  container_tbl	*next;
111 	struct  container_tbl	*prev;
112 } container_tbl_t;
113 
114 #ifdef	__cplusplus
115 }
116 #endif
117 
118 #endif	/* _FRU_DATA_IMPL_H */
119