uslsa.c revision 1.20 1 /* $NetBSD: uslsa.c,v 1.20 2016/04/23 10:15:32 skrll Exp $ */
2
3 /* from ugensa.c */
4
5 /*
6 * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Roland C. Dowdeswell <elric (at) netbsd.org>.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * Copyright (c) 2007, 2009 Jonathan A. Kollasch.
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 *
58 */
59
60 #include <sys/cdefs.h>
61 __KERNEL_RCSID(0, "$NetBSD: uslsa.c,v 1.20 2016/04/23 10:15:32 skrll Exp $");
62
63 #include <sys/param.h>
64 #include <sys/systm.h>
65 #include <sys/kernel.h>
66 #include <sys/device.h>
67 #include <sys/conf.h>
68 #include <sys/tty.h>
69
70 #include <dev/usb/usb.h>
71
72 #include <dev/usb/usbdi.h>
73 #include <dev/usb/usbdi_util.h>
74 #include <dev/usb/usbdevs.h>
75
76 #include <dev/usb/ucomvar.h>
77
78 #include <dev/usb/uslsareg.h>
79
80 #include <fs/unicode.h>
81
82 #ifdef USLSA_DEBUG
83 #define DPRINTF(x) if (uslsadebug) device_printf x
84 int uslsadebug = 0;
85 #else
86 #define DPRINTF(x)
87 #endif
88
89 struct uslsa_softc {
90 device_t sc_dev; /* base device */
91 device_t sc_subdev; /* ucom device */
92 struct usbd_device * sc_udev; /* usb device */
93 struct usbd_interface * sc_iface; /* interface */
94 uint8_t sc_ifnum; /* interface number */
95 bool sc_dying; /* disconnecting */
96 };
97
98 static void uslsa_get_status(void *sc, int, u_char *, u_char *);
99 static void uslsa_set(void *, int, int, int);
100 static int uslsa_param(void *, int, struct termios *);
101 static int uslsa_ioctl(void *, int, u_long, void *, int, proc_t *);
102
103 static int uslsa_open(void *, int);
104 static void uslsa_close(void *, int);
105
106 static int uslsa_usbd_errno(usbd_status);
107 static int uslsa_request_set(struct uslsa_softc *, uint8_t, uint16_t);
108 static int uslsa_set_flow(struct uslsa_softc *, tcflag_t, tcflag_t);
109
110 static const struct ucom_methods uslsa_methods = {
111 .ucom_get_status = uslsa_get_status,
112 .ucom_set = uslsa_set,
113 .ucom_param = uslsa_param,
114 .ucom_ioctl = uslsa_ioctl,
115 .ucom_open = uslsa_open,
116 .ucom_close = uslsa_close,
117 .ucom_read = NULL,
118 .ucom_write = NULL,
119 };
120
121 #define USLSA_CONFIG_INDEX 0
122 #define USLSA_IFACE_INDEX 0
123 #define USLSA_BUFSIZE 256
124
125 static const struct usb_devno uslsa_devs[] = {
126 { USB_VENDOR_BALTECH, USB_PRODUCT_BALTECH_CARDREADER },
127 { USB_VENDOR_DYNASTREAM, USB_PRODUCT_DYNASTREAM_ANTDEVBOARD },
128 { USB_VENDOR_JABLOTRON, USB_PRODUCT_JABLOTRON_PC60B },
129 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_ARGUSISP },
130 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_CRUMB128 },
131 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_DEGREECONT },
132 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_DESKTOPMOBILE },
133 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_IPLINK1220 },
134 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_LIPOWSKY_HARP },
135 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_LIPOWSKY_JTAG },
136 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_LIPOWSKY_LIN },
137 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_POLOLU },
138 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_CP210X_1 },
139 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_CP210X_2 },
140 { USB_VENDOR_SILABS, USB_PRODUCT_SILABS_SUNNTO },
141 { USB_VENDOR_SILABS2, USB_PRODUCT_SILABS2_DCU11CLONE },
142 { USB_VENDOR_USI, USB_PRODUCT_USI_MC60 }
143 };
144
145 static int uslsa_match(device_t, cfdata_t, void *);
146 static void uslsa_attach(device_t, device_t, void *);
147 static void uslsa_childdet(device_t, device_t);
148 static int uslsa_detach(device_t, int);
149 static int uslsa_activate(device_t, enum devact);
150
151 CFATTACH_DECL2_NEW(uslsa, sizeof(struct uslsa_softc), uslsa_match,
152 uslsa_attach, uslsa_detach, uslsa_activate, NULL, uslsa_childdet);
153
154 static int
155 uslsa_match(device_t parent, cfdata_t match, void *aux)
156 {
157 const struct usbif_attach_arg *uiaa = aux;
158
159 if (usb_lookup(uslsa_devs, uiaa->uiaa_vendor, uiaa->uiaa_product) != NULL) {
160 return UMATCH_VENDOR_PRODUCT;
161 } else {
162 return UMATCH_NONE;
163 }
164 }
165
166 static void
167 uslsa_attach(device_t parent, device_t self, void *aux)
168 {
169 struct uslsa_softc *sc;
170 const struct usbif_attach_arg *uiaa = aux;
171 const usb_interface_descriptor_t *id;
172 const usb_endpoint_descriptor_t *ed;
173 char *devinfop;
174 struct ucom_attach_args ucaa;
175 int i;
176
177 sc = device_private(self);
178
179 sc->sc_dev = self;
180 sc->sc_udev = uiaa->uiaa_device;
181 sc->sc_iface = uiaa->uiaa_iface;
182
183 aprint_naive("\n");
184 aprint_normal("\n");
185
186 devinfop = usbd_devinfo_alloc(sc->sc_udev, 0);
187 aprint_normal_dev(self, "%s\n", devinfop);
188 usbd_devinfo_free(devinfop);
189
190 id = usbd_get_interface_descriptor(sc->sc_iface);
191
192 sc->sc_ifnum = id->bInterfaceNumber;
193
194 ucaa.ucaa_info = "Silicon Labs CP210x";
195 ucaa.ucaa_portno = UCOM_UNK_PORTNO;
196 ucaa.ucaa_ibufsize = USLSA_BUFSIZE;
197 ucaa.ucaa_obufsize = USLSA_BUFSIZE;
198 ucaa.ucaa_ibufsizepad = USLSA_BUFSIZE;
199 ucaa.ucaa_opkthdrlen = 0;
200 ucaa.ucaa_device = sc->sc_udev;
201 ucaa.ucaa_iface = sc->sc_iface;
202 ucaa.ucaa_methods = &uslsa_methods;
203 ucaa.ucaa_arg = sc;
204
205 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
206 sc->sc_dev);
207
208 ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1;
209 for (i = 0; i < id->bNumEndpoints; i++) {
210 int addr, dir, attr;
211
212 ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
213 if (ed == NULL) {
214 aprint_error_dev(self,
215 "could not read endpoint descriptor\n");
216 sc->sc_dying = true;
217 return;
218 }
219 addr = ed->bEndpointAddress;
220 dir = UE_GET_DIR(ed->bEndpointAddress);
221 attr = ed->bmAttributes & UE_XFERTYPE;
222 if (dir == UE_DIR_IN && attr == UE_BULK) {
223 ucaa.ucaa_bulkin = addr;
224 } else if (dir == UE_DIR_OUT && attr == UE_BULK) {
225 ucaa.ucaa_bulkout = addr;
226 } else {
227 aprint_error_dev(self, "unexpected endpoint\n");
228 }
229 }
230 aprint_debug_dev(sc->sc_dev, "EPs: in=%#x out=%#x\n",
231 ucaa.ucaa_bulkin, ucaa.ucaa_bulkout);
232 if ((ucaa.ucaa_bulkin == -1) || (ucaa.ucaa_bulkout == -1)) {
233 aprint_error_dev(self, "could not find endpoints\n");
234 sc->sc_dying = true;
235 return;
236 }
237
238 sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &ucaa,
239 ucomprint, ucomsubmatch);
240
241 return;
242 }
243
244 static int
245 uslsa_activate(device_t self, enum devact act)
246 {
247 struct uslsa_softc *sc = device_private(self);
248
249 switch (act) {
250 case DVACT_DEACTIVATE:
251 sc->sc_dying = true;
252 return 0;
253 default:
254 return EOPNOTSUPP;
255 }
256 }
257
258 static void
259 uslsa_childdet(device_t self, device_t child)
260 {
261 struct uslsa_softc *sc = device_private(self);
262
263 KASSERT(sc->sc_subdev == child);
264 sc->sc_subdev = NULL;
265 }
266
267 static int
268 uslsa_detach(device_t self, int flags)
269 {
270 struct uslsa_softc *sc = device_private(self);
271 int rv = 0;
272
273 DPRINTF((self, "%s(%p, %#x)\n", __func__, self, flags));
274
275 sc->sc_dying = true;
276
277 if (sc->sc_subdev != NULL) {
278 rv = config_detach(sc->sc_subdev, flags);
279 }
280
281 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
282 sc->sc_dev);
283
284 return (rv);
285 }
286
287 static int
288 uslsa_usbd_errno(usbd_status status)
289 {
290 switch (status) {
291 case USBD_NORMAL_COMPLETION:
292 return 0;
293 case USBD_STALLED:
294 return EINVAL;
295 default:
296 return EIO;
297 }
298 }
299
300 static void
301 uslsa_get_status(void *vsc, int portno, u_char *lsr, u_char *msr)
302 {
303 struct uslsa_softc *sc;
304 usb_device_request_t req;
305 usbd_status status;
306 uint8_t mdmsts;
307
308 sc = vsc;
309
310 DPRINTF((sc->sc_dev, "%s(%p, %d, ....)\n", __func__, vsc, portno));
311
312 if (sc->sc_dying) {
313 return;
314 }
315
316 req.bmRequestType = UT_READ_VENDOR_INTERFACE;
317 req.bRequest = SLSA_R_GET_MDMSTS;
318 USETW(req.wValue, 0);
319 USETW(req.wIndex, sc->sc_ifnum);
320 USETW(req.wLength, SLSA_RL_GET_MDMSTS);
321
322 status = usbd_do_request(sc->sc_udev, &req, &mdmsts);
323 if (status != USBD_NORMAL_COMPLETION) {
324 device_printf(sc->sc_dev, "%s: GET_MDMSTS %s\n",
325 __func__, usbd_errstr(status));
326 return;
327 }
328
329 DPRINTF((sc->sc_dev, "%s: GET_MDMSTS %#x\n", __func__, mdmsts));
330
331 if (lsr != NULL) {
332 *lsr = 0;
333 }
334
335 if (msr != NULL) {
336 *msr = 0;
337 *msr |= ISSET(mdmsts, SLSA_MDMSTS_CTS) ? UMSR_CTS : 0;
338 *msr |= ISSET(mdmsts, SLSA_MDMSTS_DSR) ? UMSR_DSR : 0;
339 *msr |= ISSET(mdmsts, SLSA_MDMSTS_RI) ? UMSR_RI : 0;
340 *msr |= ISSET(mdmsts, SLSA_MDMSTS_DCD) ? UMSR_DCD : 0;
341 }
342 }
343
344 static void
345 uslsa_set(void *vsc, int portno, int reg, int onoff)
346 {
347 struct uslsa_softc *sc;
348
349 sc = vsc;
350
351 DPRINTF((sc->sc_dev, "%s(%p, %d, %d, %d)\n", __func__, vsc, portno, reg, onoff));
352
353 if (sc->sc_dying) {
354 return;
355 }
356
357 switch (reg) {
358 case UCOM_SET_DTR:
359 if (uslsa_request_set(sc, SLSA_R_SET_MHS,
360 SLSA_RV_SET_MHS_DTR_MASK |
361 (onoff ? SLSA_RV_SET_MHS_DTR : 0))) {
362 device_printf(sc->sc_dev, "SET_MHS/DTR failed\n");
363 }
364 break;
365 case UCOM_SET_RTS:
366 if (uslsa_request_set(sc, SLSA_R_SET_MHS,
367 SLSA_RV_SET_MHS_RTS_MASK |
368 (onoff ? SLSA_RV_SET_MHS_RTS : 0))) {
369 device_printf(sc->sc_dev, "SET_MHS/RTS failed\n");
370 }
371 break;
372 case UCOM_SET_BREAK:
373 if (uslsa_request_set(sc, SLSA_R_SET_BREAK,
374 (onoff ? SLSA_RV_SET_BREAK_ENABLE :
375 SLSA_RV_SET_BREAK_DISABLE))) {
376 device_printf(sc->sc_dev, "SET_BREAK failed\n");
377 }
378 break;
379 default:
380 break;
381 }
382 }
383
384 static int
385 uslsa_param(void *vsc, int portno, struct termios *t)
386 {
387 struct uslsa_softc *sc;
388 usb_device_request_t req;
389 usbd_status status;
390 uint16_t value;
391 uint32_t baud;
392 int ret;
393
394 sc = vsc;
395
396 DPRINTF((sc->sc_dev, "%s(%p, %d, %p)\n", __func__, vsc, portno, t));
397
398 if (sc->sc_dying) {
399 return EIO;
400 }
401
402 req.bmRequestType = UT_WRITE_VENDOR_INTERFACE;
403 req.bRequest = SLSA_R_SET_BAUDRATE;
404 USETW(req.wValue, 0);
405 USETW(req.wIndex, sc->sc_ifnum);
406 USETW(req.wLength, 4);
407
408 baud = t->c_ospeed;
409 status = usbd_do_request(sc->sc_udev, &req, &baud);
410 if (status != USBD_NORMAL_COMPLETION) {
411 /* fallback method for devices that don't know SET_BAUDRATE */
412 /* hope we calculate it right */
413 device_printf(sc->sc_dev, "%s: set baudrate %d, failed %s,"
414 " using set bauddiv\n",
415 __func__, baud, usbd_errstr(status));
416
417 value = SLSA_RV_BAUDDIV(t->c_ospeed);
418 if ((ret = uslsa_request_set(sc, SLSA_R_SET_BAUDDIV, value)) != 0) {
419 device_printf(sc->sc_dev, "%s: SET_BAUDDIV failed\n",
420 __func__);
421 return ret;
422 }
423 }
424
425 value = 0;
426
427 if (ISSET(t->c_cflag, CSTOPB)) {
428 value |= SLSA_RV_LINE_CTL_STOP_2;
429 } else {
430 value |= SLSA_RV_LINE_CTL_STOP_1;
431 }
432
433 if (ISSET(t->c_cflag, PARENB)) {
434 if (ISSET(t->c_cflag, PARODD)) {
435 value |= SLSA_RV_LINE_CTL_PARITY_ODD;
436 } else {
437 value |= SLSA_RV_LINE_CTL_PARITY_EVEN;
438 }
439 } else {
440 value |= SLSA_RV_LINE_CTL_PARITY_NONE;
441 }
442
443 switch (ISSET(t->c_cflag, CSIZE)) {
444 case CS5:
445 value |= SLSA_RV_LINE_CTL_LEN_5;
446 break;
447 case CS6:
448 value |= SLSA_RV_LINE_CTL_LEN_6;
449 break;
450 case CS7:
451 value |= SLSA_RV_LINE_CTL_LEN_7;
452 break;
453 case CS8:
454 value |= SLSA_RV_LINE_CTL_LEN_8;
455 break;
456 }
457
458 DPRINTF((sc->sc_dev, "%s: setting LINE_CTL to 0x%x\n",
459 __func__, value));
460 if ((ret = uslsa_request_set(sc, SLSA_R_SET_LINE_CTL, value)) != 0) {
461 device_printf(sc->sc_dev, "SET_LINE_CTL failed\n");
462 return ret;
463 }
464
465 if ((ret = uslsa_set_flow(sc, t->c_cflag, t->c_iflag)) != 0) {
466 device_printf(sc->sc_dev, "SET_LINE_CTL failed\n");
467 }
468
469 return ret;
470 }
471
472 static int
473 uslsa_ioctl(void *vsc, int portno, u_long cmd, void *data, int flag, proc_t *p)
474 {
475 struct uslsa_softc *sc;
476
477 sc = vsc;
478
479 switch (cmd) {
480 case TIOCMGET:
481 ucom_status_change(device_private(sc->sc_subdev));
482 return EPASSTHROUGH;
483 default:
484 return EPASSTHROUGH;
485 }
486
487 return 0;
488 }
489
490 static int
491 uslsa_open(void *vsc, int portno)
492 {
493 struct uslsa_softc *sc;
494
495 sc = vsc;
496
497 DPRINTF((sc->sc_dev, "%s(%p, %d)\n", __func__, vsc, portno));
498
499 if (sc->sc_dying) {
500 return EIO;
501 }
502
503 return uslsa_request_set(sc, SLSA_R_IFC_ENABLE,
504 SLSA_RV_IFC_ENABLE_ENABLE);
505 }
506
507 static void
508 uslsa_close(void *vsc, int portno)
509 {
510 struct uslsa_softc *sc;
511
512 sc = vsc;
513
514 DPRINTF((sc->sc_dev, "%s(%p, %d)\n", __func__, vsc, portno));
515
516 if (sc->sc_dying) {
517 return;
518 }
519
520 (void)uslsa_request_set(sc, SLSA_R_IFC_ENABLE,
521 SLSA_RV_IFC_ENABLE_DISABLE);
522 }
523
524 static int
525 uslsa_request_set(struct uslsa_softc * sc, uint8_t request, uint16_t value)
526 {
527 usb_device_request_t req;
528 usbd_status status;
529
530 req.bmRequestType = UT_WRITE_VENDOR_INTERFACE;
531 req.bRequest = request;
532 USETW(req.wValue, value);
533 USETW(req.wIndex, sc->sc_ifnum);
534 USETW(req.wLength, 0);
535
536 status = usbd_do_request(sc->sc_udev, &req, NULL);
537
538 return uslsa_usbd_errno(status);
539 }
540
541 static int
542 uslsa_set_flow(struct uslsa_softc *sc, tcflag_t cflag, tcflag_t iflag)
543 {
544 struct slsa_fcs fcs;
545 usb_device_request_t req;
546 uint32_t ulControlHandshake;
547 uint32_t ulFlowReplace;
548 usbd_status status;
549
550 DPRINTF((sc->sc_dev, "%s(%p, %#x, %#x)\n", __func__, sc, cflag, iflag));
551
552 req.bmRequestType = UT_READ_VENDOR_INTERFACE;
553 req.bRequest = SLSA_R_GET_FLOW;
554 USETW(req.wValue, 0);
555 USETW(req.wIndex, sc->sc_ifnum);
556 USETW(req.wLength, SLSA_RL_GET_FLOW);
557
558 status = usbd_do_request(sc->sc_udev, &req, &fcs);
559 if (status != USBD_NORMAL_COMPLETION) {
560 device_printf(sc->sc_dev, "%s: GET_FLOW %s\n",
561 __func__, usbd_errstr(status));
562 return uslsa_usbd_errno(status);
563 }
564
565 ulControlHandshake = le32toh(fcs.ulControlHandshake);
566 ulFlowReplace = le32toh(fcs.ulFlowReplace);
567
568 if (ISSET(cflag, CRTSCTS)) {
569 ulControlHandshake =
570 SERIAL_CTS_HANDSHAKE | __SHIFTIN(1, SERIAL_DTR_MASK);
571 ulFlowReplace = __SHIFTIN(2, SERIAL_RTS_MASK);
572 } else {
573 ulControlHandshake = __SHIFTIN(1, SERIAL_DTR_MASK);
574 ulFlowReplace = __SHIFTIN(1, SERIAL_RTS_MASK);
575 }
576
577 fcs.ulControlHandshake = htole32(ulControlHandshake);
578 fcs.ulFlowReplace = htole32(ulFlowReplace);
579
580 req.bmRequestType = UT_WRITE_VENDOR_INTERFACE;
581 req.bRequest = SLSA_R_SET_FLOW;
582 USETW(req.wValue, 0);
583 USETW(req.wIndex, sc->sc_ifnum);
584 USETW(req.wLength, SLSA_RL_SET_FLOW);
585
586 status = usbd_do_request(sc->sc_udev, &req, &fcs);
587
588 return uslsa_usbd_errno(status);
589 }
590