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 #include "cfga_usb.h"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate
30*7c478bd9Sstevel@tonic-gate #define MAX_FORMAT 80 /* for info table */
31*7c478bd9Sstevel@tonic-gate
32*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t usb_rcm_offline(const char *, char **, char *,
33*7c478bd9Sstevel@tonic-gate cfga_flags_t);
34*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t usb_rcm_online(const char *, char **, char *,
35*7c478bd9Sstevel@tonic-gate cfga_flags_t);
36*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t usb_rcm_remove(const char *, char **, char *,
37*7c478bd9Sstevel@tonic-gate cfga_flags_t);
38*7c478bd9Sstevel@tonic-gate static cfga_usb_ret_t usb_rcm_info_table(rcm_info_t *, char **);
39*7c478bd9Sstevel@tonic-gate static cfga_usb_ret_t usb_rcm_init(const char *, cfga_flags_t, char **,
40*7c478bd9Sstevel@tonic-gate uint_t *);
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gate
43*7c478bd9Sstevel@tonic-gate static rcm_handle_t *rcm_handle = NULL;
44*7c478bd9Sstevel@tonic-gate static mutex_t rcm_handle_lock = DEFAULTMUTEX;
45*7c478bd9Sstevel@tonic-gate
46*7c478bd9Sstevel@tonic-gate
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate * usb_rcm_offline:
49*7c478bd9Sstevel@tonic-gate * Offline USB resource consumers.
50*7c478bd9Sstevel@tonic-gate */
51*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t
usb_rcm_offline(const char * rsrc,char ** errstring,char * rsrc_fixed,cfga_flags_t flags)52*7c478bd9Sstevel@tonic-gate usb_rcm_offline(const char *rsrc, char **errstring, char *rsrc_fixed,
53*7c478bd9Sstevel@tonic-gate cfga_flags_t flags)
54*7c478bd9Sstevel@tonic-gate {
55*7c478bd9Sstevel@tonic-gate int rret;
56*7c478bd9Sstevel@tonic-gate uint_t rflags = 0;
57*7c478bd9Sstevel@tonic-gate rcm_info_t *rinfo = NULL;
58*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t ret = CFGA_USB_OK;
59*7c478bd9Sstevel@tonic-gate
60*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_offline:\n");
61*7c478bd9Sstevel@tonic-gate
62*7c478bd9Sstevel@tonic-gate if ((ret = usb_rcm_init(rsrc, flags, errstring, &rflags)) !=
63*7c478bd9Sstevel@tonic-gate CFGA_USB_OK) {
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gate return (ret);
66*7c478bd9Sstevel@tonic-gate }
67*7c478bd9Sstevel@tonic-gate
68*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_offline: rsrc_fixed: %s\n", rsrc_fixed);
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gate if ((rret = rcm_request_offline(rcm_handle, rsrc_fixed, rflags, &rinfo))
71*7c478bd9Sstevel@tonic-gate != RCM_SUCCESS) {
72*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_offline: rcm_request_offline failed\n");
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gate if (rinfo) {
75*7c478bd9Sstevel@tonic-gate (void) usb_rcm_info_table(rinfo, errstring);
76*7c478bd9Sstevel@tonic-gate rcm_free_info(rinfo);
77*7c478bd9Sstevel@tonic-gate rinfo = NULL;
78*7c478bd9Sstevel@tonic-gate }
79*7c478bd9Sstevel@tonic-gate
80*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_offline: table = %s\n", *errstring);
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate if (rret == RCM_FAILURE) {
83*7c478bd9Sstevel@tonic-gate (void) usb_rcm_online(rsrc, errstring,
84*7c478bd9Sstevel@tonic-gate rsrc_fixed, flags);
85*7c478bd9Sstevel@tonic-gate }
86*7c478bd9Sstevel@tonic-gate ret = CFGA_USB_RCM_OFFLINE;
87*7c478bd9Sstevel@tonic-gate }
88*7c478bd9Sstevel@tonic-gate
89*7c478bd9Sstevel@tonic-gate return (ret);
90*7c478bd9Sstevel@tonic-gate }
91*7c478bd9Sstevel@tonic-gate
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate * usb_rcm_online:
95*7c478bd9Sstevel@tonic-gate * Online USB resource consumers that were previously offlined.
96*7c478bd9Sstevel@tonic-gate */
97*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t
usb_rcm_online(const char * rsrc,char ** errstring,char * rsrc_fixed,cfga_flags_t flags)98*7c478bd9Sstevel@tonic-gate usb_rcm_online(const char *rsrc, char **errstring, char *rsrc_fixed,
99*7c478bd9Sstevel@tonic-gate cfga_flags_t flags)
100*7c478bd9Sstevel@tonic-gate {
101*7c478bd9Sstevel@tonic-gate rcm_info_t *rinfo = NULL;
102*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t ret = CFGA_USB_OK;
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_online:\n");
105*7c478bd9Sstevel@tonic-gate
106*7c478bd9Sstevel@tonic-gate if ((ret = usb_rcm_init(rsrc, flags, errstring, NULL)) != CFGA_USB_OK) {
107*7c478bd9Sstevel@tonic-gate
108*7c478bd9Sstevel@tonic-gate return (ret);
109*7c478bd9Sstevel@tonic-gate }
110*7c478bd9Sstevel@tonic-gate
111*7c478bd9Sstevel@tonic-gate if (rcm_notify_online(rcm_handle, rsrc_fixed, 0, &rinfo) !=
112*7c478bd9Sstevel@tonic-gate RCM_SUCCESS && (rinfo != NULL)) {
113*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_online: rcm_notify_online failed\n");
114*7c478bd9Sstevel@tonic-gate
115*7c478bd9Sstevel@tonic-gate (void) usb_rcm_info_table(rinfo, errstring);
116*7c478bd9Sstevel@tonic-gate rcm_free_info(rinfo);
117*7c478bd9Sstevel@tonic-gate rinfo = NULL;
118*7c478bd9Sstevel@tonic-gate ret = CFGA_USB_RCM_ONLINE;
119*7c478bd9Sstevel@tonic-gate }
120*7c478bd9Sstevel@tonic-gate
121*7c478bd9Sstevel@tonic-gate return (ret);
122*7c478bd9Sstevel@tonic-gate }
123*7c478bd9Sstevel@tonic-gate
124*7c478bd9Sstevel@tonic-gate
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate * usb_rcm_remove:
127*7c478bd9Sstevel@tonic-gate * Remove USB resource consumers after their kernel removal.
128*7c478bd9Sstevel@tonic-gate */
129*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t
usb_rcm_remove(const char * rsrc,char ** errstring,char * rsrc_fixed,cfga_flags_t flags)130*7c478bd9Sstevel@tonic-gate usb_rcm_remove(const char *rsrc, char **errstring, char *rsrc_fixed,
131*7c478bd9Sstevel@tonic-gate cfga_flags_t flags)
132*7c478bd9Sstevel@tonic-gate {
133*7c478bd9Sstevel@tonic-gate rcm_info_t *rinfo = NULL;
134*7c478bd9Sstevel@tonic-gate cfga_usb_ret_t ret = CFGA_USB_OK;
135*7c478bd9Sstevel@tonic-gate
136*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_remove:\n");
137*7c478bd9Sstevel@tonic-gate
138*7c478bd9Sstevel@tonic-gate if ((ret = usb_rcm_init(rsrc, flags, errstring, NULL)) != CFGA_USB_OK) {
139*7c478bd9Sstevel@tonic-gate
140*7c478bd9Sstevel@tonic-gate return (ret);
141*7c478bd9Sstevel@tonic-gate }
142*7c478bd9Sstevel@tonic-gate
143*7c478bd9Sstevel@tonic-gate if (rcm_notify_remove(rcm_handle, rsrc_fixed, 0, &rinfo) !=
144*7c478bd9Sstevel@tonic-gate RCM_SUCCESS && (rinfo != NULL)) {
145*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_remove: rcm_notify_remove failed\n");
146*7c478bd9Sstevel@tonic-gate
147*7c478bd9Sstevel@tonic-gate (void) usb_rcm_info_table(rinfo, errstring);
148*7c478bd9Sstevel@tonic-gate rcm_free_info(rinfo);
149*7c478bd9Sstevel@tonic-gate rinfo = NULL;
150*7c478bd9Sstevel@tonic-gate ret = CFGA_USB_RCM_ONLINE;
151*7c478bd9Sstevel@tonic-gate }
152*7c478bd9Sstevel@tonic-gate
153*7c478bd9Sstevel@tonic-gate return (ret);
154*7c478bd9Sstevel@tonic-gate }
155*7c478bd9Sstevel@tonic-gate
156*7c478bd9Sstevel@tonic-gate
157*7c478bd9Sstevel@tonic-gate /*
158*7c478bd9Sstevel@tonic-gate * usb_rcm_init:
159*7c478bd9Sstevel@tonic-gate * Contains common initialization code for entering a usb_rcm_xx() routine.
160*7c478bd9Sstevel@tonic-gate */
161*7c478bd9Sstevel@tonic-gate /* ARGSUSED */
162*7c478bd9Sstevel@tonic-gate static cfga_usb_ret_t
usb_rcm_init(const char * rsrc,cfga_flags_t flags,char ** errstring,uint_t * rflags)163*7c478bd9Sstevel@tonic-gate usb_rcm_init(const char *rsrc, cfga_flags_t flags, char **errstring,
164*7c478bd9Sstevel@tonic-gate uint_t *rflags)
165*7c478bd9Sstevel@tonic-gate {
166*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_init:\n");
167*7c478bd9Sstevel@tonic-gate
168*7c478bd9Sstevel@tonic-gate /* Validate the rsrc argument */
169*7c478bd9Sstevel@tonic-gate if (rsrc == NULL) {
170*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_init: rsrc is NULL\n");
171*7c478bd9Sstevel@tonic-gate return (CFGA_USB_INTERNAL_ERROR);
172*7c478bd9Sstevel@tonic-gate }
173*7c478bd9Sstevel@tonic-gate
174*7c478bd9Sstevel@tonic-gate /* Translate the cfgadm flags to RCM flags */
175*7c478bd9Sstevel@tonic-gate if (rflags && (flags & CFGA_FLAG_FORCE)) {
176*7c478bd9Sstevel@tonic-gate *rflags |= RCM_FORCE;
177*7c478bd9Sstevel@tonic-gate }
178*7c478bd9Sstevel@tonic-gate
179*7c478bd9Sstevel@tonic-gate /* Get a handle for the RCM operations */
180*7c478bd9Sstevel@tonic-gate (void) mutex_lock(&rcm_handle_lock);
181*7c478bd9Sstevel@tonic-gate if (rcm_handle == NULL) {
182*7c478bd9Sstevel@tonic-gate if (rcm_alloc_handle(NULL, RCM_NOPID, NULL, &rcm_handle) !=
183*7c478bd9Sstevel@tonic-gate RCM_SUCCESS) {
184*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_init: alloc_handle failed\n");
185*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&rcm_handle_lock);
186*7c478bd9Sstevel@tonic-gate
187*7c478bd9Sstevel@tonic-gate return (CFGA_USB_RCM_HANDLE);
188*7c478bd9Sstevel@tonic-gate }
189*7c478bd9Sstevel@tonic-gate }
190*7c478bd9Sstevel@tonic-gate (void) mutex_unlock(&rcm_handle_lock);
191*7c478bd9Sstevel@tonic-gate
192*7c478bd9Sstevel@tonic-gate return (CFGA_USB_OK);
193*7c478bd9Sstevel@tonic-gate }
194*7c478bd9Sstevel@tonic-gate
195*7c478bd9Sstevel@tonic-gate
196*7c478bd9Sstevel@tonic-gate /*
197*7c478bd9Sstevel@tonic-gate * usb_rcm_info_table:
198*7c478bd9Sstevel@tonic-gate * Takes an opaque rcm_info_t pointer and a character pointer,
199*7c478bd9Sstevel@tonic-gate * and appends the rcm_info_t data in the form of a table to the
200*7c478bd9Sstevel@tonic-gate * given character pointer.
201*7c478bd9Sstevel@tonic-gate */
202*7c478bd9Sstevel@tonic-gate static cfga_usb_ret_t
usb_rcm_info_table(rcm_info_t * rinfo,char ** table)203*7c478bd9Sstevel@tonic-gate usb_rcm_info_table(rcm_info_t *rinfo, char **table)
204*7c478bd9Sstevel@tonic-gate {
205*7c478bd9Sstevel@tonic-gate int i;
206*7c478bd9Sstevel@tonic-gate size_t w;
207*7c478bd9Sstevel@tonic-gate size_t width = 0;
208*7c478bd9Sstevel@tonic-gate size_t w_rsrc = 0;
209*7c478bd9Sstevel@tonic-gate size_t w_info = 0;
210*7c478bd9Sstevel@tonic-gate size_t table_size = 0;
211*7c478bd9Sstevel@tonic-gate uint_t tuples = 0;
212*7c478bd9Sstevel@tonic-gate rcm_info_tuple_t *tuple = NULL;
213*7c478bd9Sstevel@tonic-gate char *rsrc;
214*7c478bd9Sstevel@tonic-gate char *info;
215*7c478bd9Sstevel@tonic-gate char *newtable;
216*7c478bd9Sstevel@tonic-gate static char format[MAX_FORMAT];
217*7c478bd9Sstevel@tonic-gate const char *infostr;
218*7c478bd9Sstevel@tonic-gate
219*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_info_table:\n");
220*7c478bd9Sstevel@tonic-gate
221*7c478bd9Sstevel@tonic-gate /* Protect against invalid arguments */
222*7c478bd9Sstevel@tonic-gate if (rinfo == NULL || table == NULL) {
223*7c478bd9Sstevel@tonic-gate return (CFGA_USB_INTERNAL_ERROR);
224*7c478bd9Sstevel@tonic-gate }
225*7c478bd9Sstevel@tonic-gate
226*7c478bd9Sstevel@tonic-gate /* Set localized table header strings */
227*7c478bd9Sstevel@tonic-gate rsrc = dgettext(TEXT_DOMAIN, "Resource");
228*7c478bd9Sstevel@tonic-gate info = dgettext(TEXT_DOMAIN, "Information");
229*7c478bd9Sstevel@tonic-gate
230*7c478bd9Sstevel@tonic-gate /* A first pass, to size up the RCM information */
231*7c478bd9Sstevel@tonic-gate while (tuple = rcm_info_next(rinfo, tuple)) {
232*7c478bd9Sstevel@tonic-gate if ((infostr = rcm_info_info(tuple)) != NULL) {
233*7c478bd9Sstevel@tonic-gate tuples++;
234*7c478bd9Sstevel@tonic-gate if ((w = strlen(rcm_info_rsrc(tuple))) > w_rsrc)
235*7c478bd9Sstevel@tonic-gate w_rsrc = w;
236*7c478bd9Sstevel@tonic-gate if ((w = strlen(infostr)) > w_info)
237*7c478bd9Sstevel@tonic-gate w_info = w;
238*7c478bd9Sstevel@tonic-gate }
239*7c478bd9Sstevel@tonic-gate }
240*7c478bd9Sstevel@tonic-gate
241*7c478bd9Sstevel@tonic-gate /* If nothing was sized up above, stop early */
242*7c478bd9Sstevel@tonic-gate if (tuples == 0) {
243*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_info_table: no tuples\n");
244*7c478bd9Sstevel@tonic-gate
245*7c478bd9Sstevel@tonic-gate return (CFGA_USB_OK);
246*7c478bd9Sstevel@tonic-gate }
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate /* Adjust column widths for column headings */
249*7c478bd9Sstevel@tonic-gate if ((w = strlen(rsrc)) > w_rsrc) {
250*7c478bd9Sstevel@tonic-gate w_rsrc = w;
251*7c478bd9Sstevel@tonic-gate } else if ((w_rsrc - w) % 2) {
252*7c478bd9Sstevel@tonic-gate w_rsrc++;
253*7c478bd9Sstevel@tonic-gate }
254*7c478bd9Sstevel@tonic-gate
255*7c478bd9Sstevel@tonic-gate if ((w = strlen(info)) > w_info) {
256*7c478bd9Sstevel@tonic-gate w_info = w;
257*7c478bd9Sstevel@tonic-gate } else if ((w_info - w) % 2) {
258*7c478bd9Sstevel@tonic-gate w_info++;
259*7c478bd9Sstevel@tonic-gate }
260*7c478bd9Sstevel@tonic-gate
261*7c478bd9Sstevel@tonic-gate /*
262*7c478bd9Sstevel@tonic-gate * Compute the total line width of each line,
263*7c478bd9Sstevel@tonic-gate * accounting for intercolumn spacing.
264*7c478bd9Sstevel@tonic-gate */
265*7c478bd9Sstevel@tonic-gate width = w_info + w_rsrc + 4;
266*7c478bd9Sstevel@tonic-gate
267*7c478bd9Sstevel@tonic-gate /* Allocate space for the table */
268*7c478bd9Sstevel@tonic-gate table_size = (2 + tuples) * (width + 1) + 2;
269*7c478bd9Sstevel@tonic-gate if (*table == NULL) {
270*7c478bd9Sstevel@tonic-gate /* zero fill for the strcat() call below */
271*7c478bd9Sstevel@tonic-gate *table = calloc(table_size, sizeof (char));
272*7c478bd9Sstevel@tonic-gate if (*table == NULL) {
273*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_info_table: no table\n");
274*7c478bd9Sstevel@tonic-gate
275*7c478bd9Sstevel@tonic-gate return (CFGA_USB_ALLOC_FAIL);
276*7c478bd9Sstevel@tonic-gate }
277*7c478bd9Sstevel@tonic-gate } else {
278*7c478bd9Sstevel@tonic-gate newtable = realloc(*table, strlen(*table) + table_size);
279*7c478bd9Sstevel@tonic-gate if (newtable == NULL) {
280*7c478bd9Sstevel@tonic-gate DPRINTF("usb_rcm_info_table: no new table\n");
281*7c478bd9Sstevel@tonic-gate
282*7c478bd9Sstevel@tonic-gate return (CFGA_USB_ALLOC_FAIL);
283*7c478bd9Sstevel@tonic-gate } else {
284*7c478bd9Sstevel@tonic-gate *table = newtable;
285*7c478bd9Sstevel@tonic-gate }
286*7c478bd9Sstevel@tonic-gate }
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate /* Place a table header into the string */
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate /* The resource header */
291*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "\n");
292*7c478bd9Sstevel@tonic-gate w = strlen(rsrc);
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate for (i = 0; i < ((w_rsrc - w) / 2); i++) {
295*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
296*7c478bd9Sstevel@tonic-gate }
297*7c478bd9Sstevel@tonic-gate (void) strcat(*table, rsrc);
298*7c478bd9Sstevel@tonic-gate
299*7c478bd9Sstevel@tonic-gate for (i = 0; i < ((w_rsrc - w) / 2); i++) {
300*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
301*7c478bd9Sstevel@tonic-gate }
302*7c478bd9Sstevel@tonic-gate
303*7c478bd9Sstevel@tonic-gate /* The information header */
304*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
305*7c478bd9Sstevel@tonic-gate w = strlen(info);
306*7c478bd9Sstevel@tonic-gate for (i = 0; i < ((w_info - w) / 2); i++) {
307*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
308*7c478bd9Sstevel@tonic-gate }
309*7c478bd9Sstevel@tonic-gate (void) strcat(*table, info);
310*7c478bd9Sstevel@tonic-gate
311*7c478bd9Sstevel@tonic-gate for (i = 0; i < ((w_info - w) / 2); i++) {
312*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
313*7c478bd9Sstevel@tonic-gate }
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "\n");
316*7c478bd9Sstevel@tonic-gate
317*7c478bd9Sstevel@tonic-gate /* Underline the headers */
318*7c478bd9Sstevel@tonic-gate for (i = 0; i < w_rsrc; i++) {
319*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "-");
320*7c478bd9Sstevel@tonic-gate }
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate (void) strcat(*table, " ");
323*7c478bd9Sstevel@tonic-gate for (i = 0; i < w_info; i++) {
324*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "-");
325*7c478bd9Sstevel@tonic-gate }
326*7c478bd9Sstevel@tonic-gate
327*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "\n");
328*7c478bd9Sstevel@tonic-gate
329*7c478bd9Sstevel@tonic-gate /* Construct the format string */
330*7c478bd9Sstevel@tonic-gate (void) snprintf(format, MAX_FORMAT, "%%-%ds %%-%ds",
331*7c478bd9Sstevel@tonic-gate (int)w_rsrc, (int)w_info);
332*7c478bd9Sstevel@tonic-gate
333*7c478bd9Sstevel@tonic-gate /* Add the tuples to the table string */
334*7c478bd9Sstevel@tonic-gate tuple = NULL;
335*7c478bd9Sstevel@tonic-gate while ((tuple = rcm_info_next(rinfo, tuple)) != NULL) {
336*7c478bd9Sstevel@tonic-gate if ((infostr = rcm_info_info(tuple)) != NULL) {
337*7c478bd9Sstevel@tonic-gate (void) sprintf(&((*table)[strlen(*table)]),
338*7c478bd9Sstevel@tonic-gate format, rcm_info_rsrc(tuple), infostr);
339*7c478bd9Sstevel@tonic-gate (void) strcat(*table, "\n");
340*7c478bd9Sstevel@tonic-gate }
341*7c478bd9Sstevel@tonic-gate }
342*7c478bd9Sstevel@tonic-gate
343*7c478bd9Sstevel@tonic-gate return (CFGA_USB_OK);
344*7c478bd9Sstevel@tonic-gate }
345