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