xref: /onnv-gate/usr/src/lib/libfru/libfruraw/fru_access.h (revision 11015:0a0751599d31)
1*11015SSundeep.Panicker@Sun.COM /*
2*11015SSundeep.Panicker@Sun.COM  * CDDL HEADER START
3*11015SSundeep.Panicker@Sun.COM  *
4*11015SSundeep.Panicker@Sun.COM  * The contents of this file are subject to the terms of the
5*11015SSundeep.Panicker@Sun.COM  * Common Development and Distribution License (the "License").
6*11015SSundeep.Panicker@Sun.COM  * You may not use this file except in compliance with the License.
7*11015SSundeep.Panicker@Sun.COM  *
8*11015SSundeep.Panicker@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*11015SSundeep.Panicker@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*11015SSundeep.Panicker@Sun.COM  * See the License for the specific language governing permissions
11*11015SSundeep.Panicker@Sun.COM  * and limitations under the License.
12*11015SSundeep.Panicker@Sun.COM  *
13*11015SSundeep.Panicker@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*11015SSundeep.Panicker@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*11015SSundeep.Panicker@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*11015SSundeep.Panicker@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*11015SSundeep.Panicker@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*11015SSundeep.Panicker@Sun.COM  *
19*11015SSundeep.Panicker@Sun.COM  * CDDL HEADER END
20*11015SSundeep.Panicker@Sun.COM  */
21*11015SSundeep.Panicker@Sun.COM 
22*11015SSundeep.Panicker@Sun.COM /*
23*11015SSundeep.Panicker@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*11015SSundeep.Panicker@Sun.COM  * Use is subject to license terms.
25*11015SSundeep.Panicker@Sun.COM  */
26*11015SSundeep.Panicker@Sun.COM 
27*11015SSundeep.Panicker@Sun.COM #ifndef _FRU_ACCESS_H
28*11015SSundeep.Panicker@Sun.COM #define	_FRU_ACCESS_H
29*11015SSundeep.Panicker@Sun.COM 
30*11015SSundeep.Panicker@Sun.COM #include <sys/types.h>
31*11015SSundeep.Panicker@Sun.COM #include <picl.h>
32*11015SSundeep.Panicker@Sun.COM #include <door.h>
33*11015SSundeep.Panicker@Sun.COM 
34*11015SSundeep.Panicker@Sun.COM #ifdef	__cplusplus
35*11015SSundeep.Panicker@Sun.COM extern "C" {
36*11015SSundeep.Panicker@Sun.COM #endif
37*11015SSundeep.Panicker@Sun.COM 
38*11015SSundeep.Panicker@Sun.COM 
39*11015SSundeep.Panicker@Sun.COM #define	SEG_NAME_LEN	2
40*11015SSundeep.Panicker@Sun.COM 
41*11015SSundeep.Panicker@Sun.COM 
42*11015SSundeep.Panicker@Sun.COM typedef uint64_t  fru_hdl_t;
43*11015SSundeep.Panicker@Sun.COM 
44*11015SSundeep.Panicker@Sun.COM typedef fru_hdl_t  container_hdl_t;
45*11015SSundeep.Panicker@Sun.COM typedef fru_hdl_t  section_hdl_t;
46*11015SSundeep.Panicker@Sun.COM typedef fru_hdl_t  segment_hdl_t;
47*11015SSundeep.Panicker@Sun.COM typedef fru_hdl_t  packet_hdl_t;
48*11015SSundeep.Panicker@Sun.COM 
49*11015SSundeep.Panicker@Sun.COM typedef struct
50*11015SSundeep.Panicker@Sun.COM {
51*11015SSundeep.Panicker@Sun.COM 	section_hdl_t	handle;	/*  for use in operations on section  */
52*11015SSundeep.Panicker@Sun.COM 	uint32_t	offset;	/*  bytes from container beginning  */
53*11015SSundeep.Panicker@Sun.COM 	uint32_t	length;	/*  length of section in bytes  */
54*11015SSundeep.Panicker@Sun.COM 	uint32_t	protection; /* non-zero if section is write-protected */
55*11015SSundeep.Panicker@Sun.COM 	int32_t		version;	/*  version of section header, or -1 */
56*11015SSundeep.Panicker@Sun.COM }
57*11015SSundeep.Panicker@Sun.COM section_t;
58*11015SSundeep.Panicker@Sun.COM 
59*11015SSundeep.Panicker@Sun.COM typedef struct
60*11015SSundeep.Panicker@Sun.COM {
61*11015SSundeep.Panicker@Sun.COM 	segment_hdl_t	handle;	/*  for operations on segment  */
62*11015SSundeep.Panicker@Sun.COM 	char	name[SEG_NAME_LEN];	/*  from container section header  */
63*11015SSundeep.Panicker@Sun.COM 	uint32_t	descriptor;	/*  ditto  */
64*11015SSundeep.Panicker@Sun.COM 	uint32_t	offset;		/*  ditto  */
65*11015SSundeep.Panicker@Sun.COM 	uint32_t	length;		/*  ditto  */
66*11015SSundeep.Panicker@Sun.COM }
67*11015SSundeep.Panicker@Sun.COM segment_t;
68*11015SSundeep.Panicker@Sun.COM 
69*11015SSundeep.Panicker@Sun.COM typedef uint64_t  tag_t;
70*11015SSundeep.Panicker@Sun.COM 
71*11015SSundeep.Panicker@Sun.COM typedef struct
72*11015SSundeep.Panicker@Sun.COM {
73*11015SSundeep.Panicker@Sun.COM 	packet_hdl_t	handle;	/*  for use in operations on packet  */
74*11015SSundeep.Panicker@Sun.COM 	tag_t		tag;
75*11015SSundeep.Panicker@Sun.COM }
76*11015SSundeep.Panicker@Sun.COM packet_t;
77*11015SSundeep.Panicker@Sun.COM 
78*11015SSundeep.Panicker@Sun.COM 
79*11015SSundeep.Panicker@Sun.COM container_hdl_t fru_open_container(picl_nodehdl_t fru);
80*11015SSundeep.Panicker@Sun.COM 
81*11015SSundeep.Panicker@Sun.COM int fru_close_container(container_hdl_t container);
82*11015SSundeep.Panicker@Sun.COM int fru_get_num_sections(container_hdl_t container, door_cred_t *cred);
83*11015SSundeep.Panicker@Sun.COM int fru_get_sections(container_hdl_t container, section_t *section,
84*11015SSundeep.Panicker@Sun.COM 				int max_sections, door_cred_t *cred);
85*11015SSundeep.Panicker@Sun.COM int fru_get_num_segments(section_hdl_t section, door_cred_t *rarg);
86*11015SSundeep.Panicker@Sun.COM int fru_get_segments(section_hdl_t section, segment_t *segment,
87*11015SSundeep.Panicker@Sun.COM 				int max_segments, door_cred_t *rarg);
88*11015SSundeep.Panicker@Sun.COM int fru_add_segment(section_hdl_t section, segment_t *segment,
89*11015SSundeep.Panicker@Sun.COM 			section_hdl_t *newsection, door_cred_t *cred);
90*11015SSundeep.Panicker@Sun.COM int fru_delete_segment(segment_hdl_t segment, section_hdl_t *newsection,
91*11015SSundeep.Panicker@Sun.COM 							door_cred_t *cred);
92*11015SSundeep.Panicker@Sun.COM ssize_t fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes,
93*11015SSundeep.Panicker@Sun.COM 							door_cred_t *cred);
94*11015SSundeep.Panicker@Sun.COM int fru_write_segment(segment_hdl_t segment, const void *data, size_t nbytes,
95*11015SSundeep.Panicker@Sun.COM 				segment_hdl_t *newsegment, door_cred_t *cred);
96*11015SSundeep.Panicker@Sun.COM int fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred);
97*11015SSundeep.Panicker@Sun.COM int fru_get_packets(segment_hdl_t segment, packet_t *packet,
98*11015SSundeep.Panicker@Sun.COM 			int max_packets, door_cred_t *cred);
99*11015SSundeep.Panicker@Sun.COM ssize_t fru_get_payload(packet_hdl_t packet, void *buffer,
100*11015SSundeep.Panicker@Sun.COM 			size_t nbytes, door_cred_t *cred);
101*11015SSundeep.Panicker@Sun.COM int fru_update_payload(packet_hdl_t packet, const void *data, size_t nbytes,
102*11015SSundeep.Panicker@Sun.COM 			packet_hdl_t *newpacket, door_cred_t *cred);
103*11015SSundeep.Panicker@Sun.COM int fru_append_packet(segment_hdl_t segment, packet_t *packet,
104*11015SSundeep.Panicker@Sun.COM 	const void *payload, size_t nbytes, segment_hdl_t *newsegment,
105*11015SSundeep.Panicker@Sun.COM 						door_cred_t *cred);
106*11015SSundeep.Panicker@Sun.COM int fru_delete_packet(packet_hdl_t packet, segment_hdl_t *newsegment,
107*11015SSundeep.Panicker@Sun.COM 						door_cred_t *cred);
108*11015SSundeep.Panicker@Sun.COM int fru_is_data_available(picl_nodehdl_t fru);
109*11015SSundeep.Panicker@Sun.COM 
110*11015SSundeep.Panicker@Sun.COM #ifdef	__cplusplus
111*11015SSundeep.Panicker@Sun.COM }
112*11015SSundeep.Panicker@Sun.COM #endif
113*11015SSundeep.Panicker@Sun.COM 
114*11015SSundeep.Panicker@Sun.COM #endif /* _FRU_ACCESS_H */
115