451
452 static struct ecpp_transfer_parms default_xfer_parms = {
453 FWD_TIMEOUT_DEFAULT, /* write timeout in seconds */
454 ECPP_CENTRONICS /* supported mode */
455 };
456
457 /* prnio interface info string */
458 static const char prn_ifinfo[] = PRN_PARALLEL;
459
460 /* prnio timeouts */
461 static const struct prn_timeouts prn_timeouts_default = {
462 FWD_TIMEOUT_DEFAULT, /* forward timeout */
463 REV_TIMEOUT_DEFAULT /* reverse timeout */
464 };
465
466 static int ecpp_isr_max_delay = ECPP_ISR_MAX_DELAY;
467 static int ecpp_def_timeout = 90; /* left in for 2.7 compatibility */
468
469 static void *ecppsoft_statep;
470
471 /*
472 * STREAMS framework manages locks for these structures
473 */
474 _NOTE(SCHEME_PROTECTS_DATA("unique per call", iocblk))
475 _NOTE(SCHEME_PROTECTS_DATA("unique per call", datab))
476 _NOTE(SCHEME_PROTECTS_DATA("unique per call", msgb))
477 _NOTE(SCHEME_PROTECTS_DATA("unique per call", queue))
478 _NOTE(SCHEME_PROTECTS_DATA("unique per call", copyreq))
479 _NOTE(SCHEME_PROTECTS_DATA("unique per call", stroptions))
480
481 struct module_info ecppinfo = {
482 /* id, name, min pkt siz, max pkt siz, hi water, low water */
483 42, "ecpp", 0, IO_BLOCK_SZ, ECPPHIWAT, ECPPLOWAT
484 };
485
486 static struct qinit ecpp_rinit = {
487 putq, ecpp_rsrv, ecpp_open, ecpp_close, NULL, &ecppinfo, NULL
488 };
489
490 static struct qinit ecpp_wint = {
491 ecpp_wput, ecpp_wsrv, ecpp_open, ecpp_close, NULL, &ecppinfo, NULL
492 };
493
494 struct streamtab ecpp_str_info = {
495 &ecpp_rinit, &ecpp_wint, NULL, NULL
496 };
497
498 static struct cb_ops ecpp_cb_ops = {
499 nodev, /* cb_open */
500 nodev, /* cb_close */
3560 ecpp_untimeout_unblock(pp, &pp->timeout_id);
3561
3562 qenable(pp->writeq);
3563 }
3564
3565 /*VARARGS*/
3566 static void
3567 ecpp_error(dev_info_t *dip, char *fmt, ...)
3568 {
3569 static long last;
3570 static char *lastfmt;
3571 char msg_buffer[255];
3572 va_list ap;
3573 time_t now;
3574
3575 if (!ecpp_debug) {
3576 return;
3577 }
3578
3579 /*
3580 * This function is supposed to be a quick non-blockable
3581 * wrapper for cmn_err(9F), which provides a sensible degree
3582 * of debug message throttling. Not using any type of lock
3583 * is a requirement, but this also leaves two static variables
3584 * - last and lastfmt - unprotected. However, this will not do
3585 * any harm to driver functionality, it can only weaken throttling.
3586 * The following directive asks warlock to not worry about these
3587 * variables.
3588 */
3589 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(last, lastfmt))
3590
3591 /*
3592 * Don't print same error message too often.
3593 */
3594 now = gethrestime_sec();
3595 if ((last == (now & ~1)) && (lastfmt == fmt))
3596 return;
3597
3598 last = now & ~1;
3599 lastfmt = fmt;
3600
3601 va_start(ap, fmt);
3602 (void) vsprintf(msg_buffer, fmt, ap);
3603 cmn_err(CE_CONT, "%s%d: %s", ddi_get_name(dip),
3604 ddi_get_instance(dip), msg_buffer);
3605 va_end(ap);
3606 }
3607
3608 /*
3609 * Forward transfer timeout
3610 */
3611 static void
|
451
452 static struct ecpp_transfer_parms default_xfer_parms = {
453 FWD_TIMEOUT_DEFAULT, /* write timeout in seconds */
454 ECPP_CENTRONICS /* supported mode */
455 };
456
457 /* prnio interface info string */
458 static const char prn_ifinfo[] = PRN_PARALLEL;
459
460 /* prnio timeouts */
461 static const struct prn_timeouts prn_timeouts_default = {
462 FWD_TIMEOUT_DEFAULT, /* forward timeout */
463 REV_TIMEOUT_DEFAULT /* reverse timeout */
464 };
465
466 static int ecpp_isr_max_delay = ECPP_ISR_MAX_DELAY;
467 static int ecpp_def_timeout = 90; /* left in for 2.7 compatibility */
468
469 static void *ecppsoft_statep;
470
471 struct module_info ecppinfo = {
472 /* id, name, min pkt siz, max pkt siz, hi water, low water */
473 42, "ecpp", 0, IO_BLOCK_SZ, ECPPHIWAT, ECPPLOWAT
474 };
475
476 static struct qinit ecpp_rinit = {
477 putq, ecpp_rsrv, ecpp_open, ecpp_close, NULL, &ecppinfo, NULL
478 };
479
480 static struct qinit ecpp_wint = {
481 ecpp_wput, ecpp_wsrv, ecpp_open, ecpp_close, NULL, &ecppinfo, NULL
482 };
483
484 struct streamtab ecpp_str_info = {
485 &ecpp_rinit, &ecpp_wint, NULL, NULL
486 };
487
488 static struct cb_ops ecpp_cb_ops = {
489 nodev, /* cb_open */
490 nodev, /* cb_close */
3550 ecpp_untimeout_unblock(pp, &pp->timeout_id);
3551
3552 qenable(pp->writeq);
3553 }
3554
3555 /*VARARGS*/
3556 static void
3557 ecpp_error(dev_info_t *dip, char *fmt, ...)
3558 {
3559 static long last;
3560 static char *lastfmt;
3561 char msg_buffer[255];
3562 va_list ap;
3563 time_t now;
3564
3565 if (!ecpp_debug) {
3566 return;
3567 }
3568
3569 /*
3570 * Don't print same error message too often.
3571 */
3572 now = gethrestime_sec();
3573 if ((last == (now & ~1)) && (lastfmt == fmt))
3574 return;
3575
3576 last = now & ~1;
3577 lastfmt = fmt;
3578
3579 va_start(ap, fmt);
3580 (void) vsprintf(msg_buffer, fmt, ap);
3581 cmn_err(CE_CONT, "%s%d: %s", ddi_get_name(dip),
3582 ddi_get_instance(dip), msg_buffer);
3583 va_end(ap);
3584 }
3585
3586 /*
3587 * Forward transfer timeout
3588 */
3589 static void
|