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