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 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _FRU_ACCESS_H
28*7c478bd9Sstevel@tonic-gate #define	_FRU_ACCESS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
31*7c478bd9Sstevel@tonic-gate #include <picl.h>
32*7c478bd9Sstevel@tonic-gate #include <door.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #define	SEG_NAME_LEN	2
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate typedef uint64_t  fru_hdl_t;
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate typedef fru_hdl_t  container_hdl_t;
45*7c478bd9Sstevel@tonic-gate typedef fru_hdl_t  section_hdl_t;
46*7c478bd9Sstevel@tonic-gate typedef fru_hdl_t  segment_hdl_t;
47*7c478bd9Sstevel@tonic-gate typedef fru_hdl_t  packet_hdl_t;
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate typedef struct
50*7c478bd9Sstevel@tonic-gate {
51*7c478bd9Sstevel@tonic-gate 	section_hdl_t	handle;	/*  for use in operations on section  */
52*7c478bd9Sstevel@tonic-gate 	uint32_t	offset;	/*  bytes from container beginning  */
53*7c478bd9Sstevel@tonic-gate 	uint32_t	length;	/*  length of section in bytes  */
54*7c478bd9Sstevel@tonic-gate 	uint32_t	protection; /* non-zero if section is write-protected */
55*7c478bd9Sstevel@tonic-gate 	int32_t		version;	/*  version of section header, or -1 */
56*7c478bd9Sstevel@tonic-gate }
57*7c478bd9Sstevel@tonic-gate section_t;
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate typedef struct
60*7c478bd9Sstevel@tonic-gate {
61*7c478bd9Sstevel@tonic-gate 	segment_hdl_t	handle;	/*  for operations on segment  */
62*7c478bd9Sstevel@tonic-gate 	char	name[SEG_NAME_LEN];	/*  from container section header  */
63*7c478bd9Sstevel@tonic-gate 	uint32_t	descriptor;	/*  ditto  */
64*7c478bd9Sstevel@tonic-gate 	uint32_t	offset;		/*  ditto  */
65*7c478bd9Sstevel@tonic-gate 	uint32_t	length;		/*  ditto  */
66*7c478bd9Sstevel@tonic-gate }
67*7c478bd9Sstevel@tonic-gate segment_t;
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate typedef uint64_t  tag_t;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate typedef struct
72*7c478bd9Sstevel@tonic-gate {
73*7c478bd9Sstevel@tonic-gate 	packet_hdl_t	handle;	/*  for use in operations on packet  */
74*7c478bd9Sstevel@tonic-gate 	tag_t		tag;
75*7c478bd9Sstevel@tonic-gate }
76*7c478bd9Sstevel@tonic-gate packet_t;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate container_hdl_t fru_open_container(picl_nodehdl_t fru);
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate int fru_close_container(container_hdl_t container);
82*7c478bd9Sstevel@tonic-gate int fru_get_num_sections(container_hdl_t container, door_cred_t *cred);
83*7c478bd9Sstevel@tonic-gate int fru_get_sections(container_hdl_t container, section_t *section,
84*7c478bd9Sstevel@tonic-gate 				int max_sections, door_cred_t *cred);
85*7c478bd9Sstevel@tonic-gate int fru_get_num_segments(section_hdl_t section, door_cred_t *rarg);
86*7c478bd9Sstevel@tonic-gate int fru_get_segments(section_hdl_t section, segment_t *segment,
87*7c478bd9Sstevel@tonic-gate 				int max_segments, door_cred_t *rarg);
88*7c478bd9Sstevel@tonic-gate int fru_add_segment(section_hdl_t section, segment_t *segment,
89*7c478bd9Sstevel@tonic-gate 			section_hdl_t *newsection, door_cred_t *cred);
90*7c478bd9Sstevel@tonic-gate int fru_delete_segment(segment_hdl_t segment, section_hdl_t *newsection,
91*7c478bd9Sstevel@tonic-gate 							door_cred_t *cred);
92*7c478bd9Sstevel@tonic-gate ssize_t fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes,
93*7c478bd9Sstevel@tonic-gate 							door_cred_t *cred);
94*7c478bd9Sstevel@tonic-gate int fru_write_segment(segment_hdl_t segment, const void *data, size_t nbytes,
95*7c478bd9Sstevel@tonic-gate 				segment_hdl_t *newsegment, door_cred_t *cred);
96*7c478bd9Sstevel@tonic-gate int fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred);
97*7c478bd9Sstevel@tonic-gate int fru_get_packets(segment_hdl_t segment, packet_t *packet,
98*7c478bd9Sstevel@tonic-gate 			int max_packets, door_cred_t *cred);
99*7c478bd9Sstevel@tonic-gate ssize_t fru_get_payload(packet_hdl_t packet, void *buffer,
100*7c478bd9Sstevel@tonic-gate 			size_t nbytes, door_cred_t *cred);
101*7c478bd9Sstevel@tonic-gate int fru_update_payload(packet_hdl_t packet, const void *data, size_t nbytes,
102*7c478bd9Sstevel@tonic-gate 			packet_hdl_t *newpacket, door_cred_t *cred);
103*7c478bd9Sstevel@tonic-gate int fru_append_packet(segment_hdl_t segment, packet_t *packet,
104*7c478bd9Sstevel@tonic-gate 	const void *payload, size_t nbytes, segment_hdl_t *newsegment,
105*7c478bd9Sstevel@tonic-gate 						door_cred_t *cred);
106*7c478bd9Sstevel@tonic-gate int fru_delete_packet(packet_hdl_t packet, segment_hdl_t *newsegment,
107*7c478bd9Sstevel@tonic-gate 						door_cred_t *cred);
108*7c478bd9Sstevel@tonic-gate int fru_is_data_available(picl_nodehdl_t fru);
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
111*7c478bd9Sstevel@tonic-gate }
112*7c478bd9Sstevel@tonic-gate #endif
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #endif /* _FRU_ACCESS_H */
115