xref: /titanic_52/usr/src/lib/fm/libldom/sparc/ldmsvcs_utils.h (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LDMSVCS_UTILS_H
27 #define	_LDMSVCS_UTILS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <stdlib.h>
32 #include <sys/types.h>
33 #include <sys/ldc.h>
34 #include <sys/vldc.h>
35 #include <sys/ds.h>
36 #include <sys/ds_impl.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Service Information
44  */
45 typedef struct fds_svc {
46 	ds_svc_hdl_t hdl;	/* handle assigned by DS */
47 	ds_svc_state_t state;	/* current service state */
48 	ds_ver_t ver;		/* svc protocol version in use */
49 	char *name;
50 } fds_svc_t;
51 
52 /*
53  * table of registered services
54  */
55 typedef struct fds_reg_svcs {
56 	pthread_mutex_t mt;
57 	pthread_cond_t cv;
58 	fds_svc_t **tbl;		/* the table itself */
59 	uint_t nsvcs;		/* current number of items */
60 } fds_reg_svcs_t;
61 
62 
63 typedef enum {
64 	CHANNEL_UNINITIALIZED,	/* status of channel unknown */
65 	CHANNEL_CLOSED,		/* port structure not in use */
66 	CHANNEL_OPEN,		/* open but not initialized/reset */
67 	CHANNEL_READY,		/* init/reset done */
68 	CHANNEL_UNUSABLE,	/* cannot be used (possibly busy) */
69 	CHANNEL_EXIT		/* normal exit */
70 } fds_chan_state_t;
71 
72 typedef struct fds_channel {
73 	int fd;			/* FD for this channel */
74 	fds_chan_state_t state; /* state of the port */
75 	ds_ver_t ver;		/* DS protocol version in use */
76 } fds_channel_t;
77 
78 
79 /*
80  * FMA services
81  */
82 typedef struct {
83 	uint64_t req_num;
84 } fma_req_pri_t;
85 
86 /*
87  * definition of fma_pri_resp_t is not shown here.  for more details,
88  * see ldmsvcs_utils.c:ldmsvcs_get_core_md().
89  */
90 
91 #define	FMA_CPU_REQ_STATUS	0
92 #define	FMA_CPU_REQ_OFFLINE	1
93 #define	FMA_CPU_REQ_ONLINE	2
94 
95 #define	FMA_CPU_RESP_OK		0
96 #define	FMA_CPU_RESP_FAILURE	1
97 
98 #define	FMA_CPU_STAT_ONLINE	0
99 #define	FMA_CPU_STAT_OFFLINE	1
100 #define	FMA_CPU_STAT_ILLEGAL	2
101 
102 typedef struct {
103 	uint64_t req_num;
104 	uint32_t msg_type;
105 	uint32_t cpu_id;
106 } fma_cpu_service_req_t;
107 
108 typedef struct {
109 	uint64_t req_num;
110 	uint32_t result;
111 	uint32_t status;
112 } fma_cpu_resp_t;
113 
114 #define	FMA_MEM_REQ_STATUS	0
115 #define	FMA_MEM_REQ_RETIRE	1
116 #define	FMA_MEM_REQ_RESURRECT	2
117 
118 #define	FMA_MEM_RESP_OK		0
119 #define	FMA_MEM_RESP_FAILURE	1
120 
121 #define	FMA_MEM_STAT_NOTRETIRED	0
122 #define	FMA_MEM_STAT_RETIRED	1
123 #define	FMA_MEM_STAT_ILLEGAL	2
124 
125 typedef struct {
126 	uint64_t req_num;
127 	uint32_t msg_type;
128 	uint32_t _resvd;
129 	uint64_t real_addr;
130 	uint64_t length;
131 } fma_mem_service_req_t;
132 
133 typedef struct {
134 	uint64_t req_num;
135 	uint32_t result;
136 	uint32_t status;
137 	uint64_t res_addr;
138 	uint64_t res_length;
139 } fma_mem_resp_t;
140 
141 
142 struct ldom_hdl {
143 	int major_version;
144 	int service_ldom;
145 	void *(*allocp)(size_t size);
146 	void (*freep)(void *addr, size_t size);
147 	struct ldmsvcs_info *lsinfo;
148 };
149 
150 
151 extern int ldmsvcs_check_channel(void);
152 
153 extern void ldmsvcs_init(struct ldom_hdl *lhp);
154 
155 extern void ldmsvcs_fini(struct ldom_hdl *lhp);
156 
157 extern ssize_t ldmsvcs_get_core_md(struct ldom_hdl *lhp, uint64_t **buf);
158 
159 extern int ldmsvcs_cpu_req_status(struct ldom_hdl *lhp, uint32_t cpuid);
160 
161 extern int ldmsvcs_mem_req_status(struct ldom_hdl *lhp, uint64_t pa);
162 
163 extern int ldmsvcs_cpu_req_offline(struct ldom_hdl *lhp, uint32_t cpuid);
164 
165 extern int ldmsvcs_mem_req_retire(struct ldom_hdl *lhp, uint64_t pa);
166 
167 #ifdef	__cplusplus
168 }
169 #endif
170 
171 #endif	/* _LDMSVCS_UTILS_H */
172