Lines Matching +full:assert +full:- +full:falling +full:- +full:edge
98 * As we don't yet support on-chip flow control, it's a bad idea to put a
138 #define ASY_DEBUG(asy, x) (asy->asy_debug & (x))
278 * by the default crystal frequency, although the highest termios.h-defined
333 [ASY_ILLEGAL] = { 0, -1, NULL, NULL },
514 /* free "motherboard-serial-ports" property if allocated */ in _fini()
532 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_put_idx()
534 ASSERT(reg >= ASY_ACR); in asy_put_idx()
535 ASSERT(reg <= ASY_NREG); in asy_put_idx()
543 * I'd prefer to ASSERT this, but I'm not sure it's worth the hassle. in asy_put_idx()
558 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_get_idx()
560 ASSERT(reg >= ASY_ACR); in asy_get_idx()
561 ASSERT(reg <= ASY_NREG); in asy_get_idx()
564 asy_put(asy, ASY_ACR, ASY_ACR_ICR | asy->asy_acr); in asy_get_idx()
573 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_get_idx()
581 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_put_add()
583 /* Only ASR is writable, RFL and TFL are read-only. */ in asy_put_add()
584 ASSERT(reg == ASY_ASR); in asy_put_add()
590 ASSERT((val & ~(ASY_ASR_TD | ASY_ASR_RTD)) == 0); in asy_put_add()
593 asy_put(asy, ASY_ACR, ASY_ACR_ASR | asy->asy_acr); in asy_put_add()
599 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_put_add()
607 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_get_add()
609 ASSERT(reg >= ASY_ASR); in asy_get_add()
610 ASSERT(reg <= ASY_TFL); in asy_get_add()
618 * I'd prefer to ASSERT this, but I'm not sure it's worth the hassle. in asy_get_add()
622 asy_put(asy, ASY_ACR, ASY_ACR_ASR | asy->asy_acr); in asy_get_add()
628 asy_put(asy, ASY_ACR, 0 | asy->asy_acr); in asy_get_add()
645 ASSERT(asy->asy_hwtype >= ASY_16650); in asy_put_ext()
647 ASSERT(reg >= ASY_EFR); in asy_put_ext()
648 ASSERT(reg <= ASY_XOFF2); in asy_put_ext()
675 ASSERT(asy->asy_hwtype >= ASY_16650); in asy_get_ext()
677 ASSERT(reg >= ASY_EFR); in asy_get_ext()
678 ASSERT(reg <= ASY_XOFF2); in asy_get_ext()
698 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_put_reg()
700 ddi_put8(asy->asy_iohandle, in asy_put_reg()
701 asy->asy_ioaddr + asy_reg_table[reg].asy_reg_off, val); in asy_put_reg()
707 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_get_reg()
709 return (ddi_get8(asy->asy_iohandle, in asy_get_reg()
710 asy->asy_ioaddr + asy_reg_table[reg].asy_reg_off)); in asy_get_reg()
716 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_put()
718 ASSERT(reg > ASY_ILLEGAL); in asy_put()
719 ASSERT(reg < ASY_NREG); in asy_put()
721 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_put()
722 ASSERT(asy_reg_table[reg].asy_put_reg != NULL); in asy_put()
732 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_get()
734 ASSERT(reg > ASY_ILLEGAL); in asy_get()
735 ASSERT(reg < ASY_NREG); in asy_get()
737 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_get()
738 ASSERT(asy_reg_table[reg].asy_get_reg != NULL); in asy_get()
792 if (tcr != 0 && asy->asy_hwtype < ASY_16950) in asy_set_baudrate()
795 if (asy->asy_hwtype >= ASY_16950) { in asy_set_baudrate()
805 ASSERT(tcr == 0x00 || tcr >= 0x04 || tcr <= 0x0f); in asy_set_baudrate()
834 struct asyncline *async = asy->asy_priv; in asy_wait_baudrate()
835 int rate = BAUDINDEX(async->async_ttycommon.t_cflag); in asy_wait_baudrate()
840 ASSERT(mutex_owned(&asy->asy_excl)); in asy_wait_baudrate()
841 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_wait_baudrate()
844 mutex_exit(&asy->asy_excl_hi); in asy_wait_baudrate()
845 mutex_exit(&asy->asy_excl); in asy_wait_baudrate()
847 mutex_enter(&asy->asy_excl); in asy_wait_baudrate()
848 mutex_enter(&asy->asy_excl_hi); in asy_wait_baudrate()
856 struct asyncline *async = asy->asy_priv; in async_put_suspq()
858 ASSERT(mutex_owned(&asy->asy_excl)); in async_put_suspq()
860 if (async->async_suspqf == NULL) in async_put_suspq()
861 async->async_suspqf = mp; in async_put_suspq()
863 async->async_suspqb->b_next = mp; in async_put_suspq()
865 async->async_suspqb = mp; in async_put_suspq()
871 struct asyncline *async = asy->asy_priv; in async_get_suspq()
874 ASSERT(mutex_owned(&asy->asy_excl)); in async_get_suspq()
876 if ((mp = async->async_suspqf) != NULL) { in async_get_suspq()
877 async->async_suspqf = mp->b_next; in async_get_suspq()
878 mp->b_next = NULL; in async_get_suspq()
880 async->async_suspqb = NULL; in async_get_suspq()
888 struct asyncline *async = asy->asy_priv; in async_process_suspq()
891 ASSERT(mutex_owned(&asy->asy_excl)); in async_process_suspq()
896 q = async->async_ttycommon.t_writeq; in async_process_suspq()
897 ASSERT(q != NULL); in async_process_suspq()
898 mutex_exit(&asy->asy_excl); in async_process_suspq()
900 mutex_enter(&asy->asy_excl); in async_process_suspq()
902 async->async_flags &= ~ASYNC_DDI_SUSPENDED; in async_process_suspq()
903 cv_broadcast(&async->async_flags_cv); in async_process_suspq()
914 ddi_prop_lookup_string(DDI_DEV_T_ANY, devinfo, 0, "bus-type", in asy_get_bus_type()
947 return (-1); in asy_get_io_regnum_pci()
950 regnum = -1; in asy_get_io_regnum_pci()
955 if (regnum == -1) /* use only the first one */ in asy_get_io_regnum_pci()
969 regnum = -1; in asy_get_io_regnum_pci()
978 int regnum = -1; in asy_get_io_regnum_isa()
990 return (-1); in asy_get_io_regnum_isa()
998 for (int i = 0; i < nregs && regnum == -1; i++) { in asy_get_io_regnum_isa()
1007 regnum = -1; in asy_get_io_regnum_isa()
1023 return (-1); in asy_get_io_regnum()
1032 for (i = 0; i < asy->asy_intr_cnt; i++) { in asy_intr_free()
1033 if (asy->asy_inth[i] == NULL) in asy_intr_free()
1036 if ((asy->asy_intr_cap & DDI_INTR_FLAG_BLOCK) != 0) in asy_intr_free()
1037 (void) ddi_intr_block_disable(&asy->asy_inth[i], 1); in asy_intr_free()
1039 (void) ddi_intr_disable(asy->asy_inth[i]); in asy_intr_free()
1041 (void) ddi_intr_remove_handler(asy->asy_inth[i]); in asy_intr_free()
1042 (void) ddi_intr_free(asy->asy_inth[i]); in asy_intr_free()
1045 kmem_free(asy->asy_inth, asy->asy_inth_sz); in asy_intr_free()
1046 asy->asy_inth = NULL; in asy_intr_free()
1047 asy->asy_inth_sz = 0; in asy_intr_free()
1057 if (asy->asy_intr_types == 0) { in asy_intr_setup()
1058 ret = ddi_intr_get_supported_types(asy->asy_dip, in asy_intr_setup()
1059 &asy->asy_intr_types); in asy_intr_setup()
1067 if ((asy->asy_intr_types & intr_type) == 0) in asy_intr_setup()
1070 ret = ddi_intr_get_nintrs(asy->asy_dip, intr_type, &nintrs); in asy_intr_setup()
1082 ret = ddi_intr_get_navail(asy->asy_dip, intr_type, &navail); in asy_intr_setup()
1099 asy->asy_inth_sz = sizeof (ddi_intr_handle_t); in asy_intr_setup()
1100 asy->asy_inth = kmem_zalloc(asy->asy_inth_sz, KM_SLEEP); in asy_intr_setup()
1101 ret = ddi_intr_alloc(asy->asy_dip, asy->asy_inth, intr_type, 0, 1, in asy_intr_setup()
1115 asy->asy_intr_cnt = count; in asy_intr_setup()
1117 ret = ddi_intr_get_pri(asy->asy_inth[0], &asy->asy_intr_pri); in asy_intr_setup()
1125 ret = ddi_intr_add_handler(asy->asy_inth[i], asyintr, in asy_intr_setup()
1134 (void) ddi_intr_get_cap(asy->asy_inth[0], &asy->asy_intr_cap); in asy_intr_setup()
1137 if (asy->asy_intr_cap & DDI_INTR_FLAG_BLOCK) in asy_intr_setup()
1138 ret = ddi_intr_block_enable(&asy->asy_inth[i], 1); in asy_intr_setup()
1140 ret = ddi_intr_enable(asy->asy_inth[i]); in asy_intr_setup()
1150 asy->asy_intr_type = intr_type; in asy_intr_setup()
1161 (void) ddi_intr_remove_softint(asy->asy_soft_inth); in asy_softintr_free()
1169 ret = ddi_intr_add_softint(asy->asy_dip, &asy->asy_soft_inth, in asy_softintr_setup()
1182 ret = ddi_intr_get_softint_pri(asy->asy_soft_inth, in asy_softintr_setup()
1183 &asy->asy_soft_intr_pri); in asy_softintr_setup()
1208 mutex_enter(&asy->asy_soft_sr); in asy_resume()
1209 mutex_enter(&asy->asy_excl); in asy_resume()
1210 mutex_enter(&asy->asy_excl_hi); in asy_resume()
1212 async = asy->asy_priv; in asy_resume()
1215 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1216 mutex_exit(&asy->asy_excl); in asy_resume()
1217 mutex_exit(&asy->asy_soft_sr); in asy_resume()
1220 (void *)asy->asy_ioaddr); in asy_resume()
1223 asy->asy_flags &= ~ASY_DDI_SUSPENDED; in asy_resume()
1224 if (async->async_flags & ASYNC_ISOPEN) { in asy_resume()
1227 if (async->async_ocnt > 0) { in asy_resume()
1230 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1231 if (async->async_xmitblk) in asy_resume()
1232 freeb(async->async_xmitblk); in asy_resume()
1233 async->async_xmitblk = NULL; in asy_resume()
1235 mutex_enter(&asy->asy_excl_hi); in asy_resume()
1239 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1240 mutex_exit(&asy->asy_excl); in asy_resume()
1241 mutex_exit(&asy->asy_soft_sr); in asy_resume()
1243 mutex_enter(&asy->asy_excl); in asy_resume()
1244 if (async->async_flags & ASYNC_RESUME_BUFCALL) { in asy_resume()
1245 async->async_wbufcid = bufcall(async->async_wbufcds, in asy_resume()
1247 (void *)(intptr_t)async->async_common->asy_unit); in asy_resume()
1248 async->async_flags &= ~ASYNC_RESUME_BUFCALL; in asy_resume()
1251 mutex_exit(&asy->asy_excl); in asy_resume()
1258 struct asyncline *async = asy->asy_priv; in asy_suspend()
1266 mutex_enter(&asy->asy_excl); in asy_suspend()
1268 ASSERT(async->async_ops >= 0); in asy_suspend()
1269 while (async->async_ops > 0) in asy_suspend()
1270 cv_wait(&async->async_ops_cv, &asy->asy_excl); in asy_suspend()
1272 async->async_flags |= ASYNC_DDI_SUSPENDED; in asy_suspend()
1275 while ((async->async_flags & (ASYNC_BREAK|ASYNC_DELAY))) { in asy_suspend()
1276 if (cv_wait_sig(&async->async_flags_cv, &asy->asy_excl) == 0) { in asy_suspend()
1278 mutex_exit(&asy->asy_excl); in asy_suspend()
1284 if (async->async_flags & ASYNC_OUT_SUSPEND) in asy_suspend()
1287 mutex_exit(&asy->asy_excl); in asy_suspend()
1289 mutex_enter(&asy->asy_soft_sr); in asy_suspend()
1290 mutex_enter(&asy->asy_excl); in asy_suspend()
1291 if (async->async_wbufcid != 0) { in asy_suspend()
1292 bufcall_id_t bcid = async->async_wbufcid; in asy_suspend()
1293 async->async_wbufcid = 0; in asy_suspend()
1294 async->async_flags |= ASYNC_RESUME_BUFCALL; in asy_suspend()
1295 mutex_exit(&asy->asy_excl); in asy_suspend()
1297 mutex_enter(&asy->asy_excl); in asy_suspend()
1299 mutex_enter(&asy->asy_excl_hi); in asy_suspend()
1302 asy->asy_flags |= ASY_DDI_SUSPENDED; in asy_suspend()
1308 mutex_exit(&asy->asy_excl_hi); in asy_suspend()
1315 for (i = 1000; i > 0; i--) { in asy_suspend()
1326 mutex_exit(&asy->asy_excl); in asy_suspend()
1327 mutex_exit(&asy->asy_soft_sr); in asy_suspend()
1361 if ((asy->asy_progress & ASY_PROGRESS_INT) != 0) in asydetach()
1364 if ((asy->asy_progress & ASY_PROGRESS_SOFTINT) != 0) in asydetach()
1367 if ((asy->asy_progress & ASY_PROGRESS_ASYNC) != 0) { in asydetach()
1368 struct asyncline *async = asy->asy_priv; in asydetach()
1370 asy->asy_priv = NULL; in asydetach()
1372 if (async->async_dtrtid != 0) { in asydetach()
1373 (void) untimeout(async->async_dtrtid); in asydetach()
1374 async->async_dtrtid = 0; in asydetach()
1376 cv_destroy(&async->async_flags_cv); in asydetach()
1380 if ((asy->asy_progress & ASY_PROGRESS_MINOR) != 0) in asydetach()
1383 if ((asy->asy_progress & ASY_PROGRESS_MUTEX) != 0) { in asydetach()
1384 mutex_destroy(&asy->asy_excl); in asydetach()
1385 mutex_destroy(&asy->asy_excl_hi); in asydetach()
1386 mutex_destroy(&asy->asy_soft_lock); in asydetach()
1389 if ((asy->asy_progress & ASY_PROGRESS_REGS) != 0) in asydetach()
1390 ddi_regs_map_free(&asy->asy_iohandle); in asydetach()
1401 * nodes are only created for auto-detected hardware or nodes explicitly
1446 "motherboard-serial-ports", &com_ports, &num_com_ports) != in asyattach()
1448 /* Use our built-in COM[1234] values */ in asyattach()
1457 "%s: more than %d motherboard-serial-ports", in asyattach()
1469 asy->asy_dip = devi; in asyattach()
1471 asy->asy_debug = debug; in asyattach()
1473 asy->asy_unit = instance; in asyattach()
1478 ddi_regs_map_setup(devi, regnum, (caddr_t *)&asy->asy_ioaddr, in asyattach()
1479 (offset_t)0, (offset_t)0, &ioattr, &asy->asy_iohandle) in asyattach()
1482 (void *)asy->asy_ioaddr); in asyattach()
1486 asy->asy_progress |= ASY_PROGRESS_REGS; in asyattach()
1488 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "UART @ %p", (void *)asy->asy_ioaddr); in asyattach()
1492 * in which case we assign it the correct tty[a-d] to match the in asyattach()
1498 if (asy->asy_ioaddr == (uint8_t *)(uintptr_t)com_ports[i]) { in asyattach()
1499 asy->asy_com_port = i + 1; in asyattach()
1512 ddi_put8(asy->asy_iohandle, in asyattach()
1513 asy->asy_ioaddr + asy_reg_table[ASY_IER].asy_reg_off, 0); in asyattach()
1517 * - use RTS/DTR after open in asyattach()
1518 * - 8N1 data format in asyattach()
1519 * - 9600 baud in asyattach()
1521 asy->asy_mcr |= ASY_MCR_RTS | ASY_MCR_DTR; in asyattach()
1522 asy->asy_lcr = ASY_LCR_STOP1 | ASY_LCR_BITS8; in asyattach()
1523 asy->asy_bidx = B9600; in asyattach()
1524 asy->asy_fifo_buf = 1; in asyattach()
1525 asy->asy_use_fifo = ASY_FCR_FIFO_OFF; in asyattach()
1528 asy->asy_msint_cnt = 0; /* # of times in async_msint */ in asyattach()
1532 if (asy->asy_com_port != 0) { in asyattach()
1538 switch (asy_getproperty(devi, asy, "ignore-cd")) { in asyattach()
1539 case 0: /* *-ignore-cd=False */ in asyattach()
1542 asy->asy_flags &= ~ASY_IGNORE_CD; /* wait for cd */ in asyattach()
1544 case 1: /* *-ignore-cd=True */ in asyattach()
1546 default: /* *-ignore-cd not defined */ in asyattach()
1554 mcr = asy->asy_mcr; /* rts/dtr on */ in asyattach()
1555 asy->asy_flags |= ASY_IGNORE_CD; /* ignore cd */ in asyattach()
1560 switch (asy_getproperty(devi, asy, "rts-dtr-off")) { in asyattach()
1561 case 0: /* *-rts-dtr-off=False */ in asyattach()
1562 asy->asy_flags |= ASY_RTS_DTR_OFF; /* OFF */ in asyattach()
1563 mcr = asy->asy_mcr; /* rts/dtr on */ in asyattach()
1567 case 1: /* *-rts-dtr-off=True */ in asyattach()
1569 default: /* *-rts-dtr-off undefined */ in asyattach()
1578 asy->asy_flags &= ~ASY_IGNORE_CD; /* wait for cd */ in asyattach()
1589 asy->asy_progress |= ASY_PROGRESS_SOFTINT; in asyattach()
1601 asy->asy_progress |= ASY_PROGRESS_INT; in asyattach()
1606 mutex_init(&asy->asy_soft_lock, NULL, MUTEX_DRIVER, in asyattach()
1607 DDI_INTR_PRI(asy->asy_soft_intr_pri)); in asyattach()
1608 mutex_init(&asy->asy_soft_sr, NULL, MUTEX_DRIVER, in asyattach()
1609 DDI_INTR_PRI(asy->asy_soft_intr_pri)); in asyattach()
1611 mutex_init(&asy->asy_excl, NULL, MUTEX_DRIVER, NULL); in asyattach()
1612 mutex_init(&asy->asy_excl_hi, NULL, MUTEX_DRIVER, in asyattach()
1613 DDI_INTR_PRI(asy->asy_intr_pri)); in asyattach()
1615 asy->asy_progress |= ASY_PROGRESS_MUTEX; in asyattach()
1617 mutex_enter(&asy->asy_excl); in asyattach()
1618 mutex_enter(&asy->asy_excl_hi); in asyattach()
1623 (void *)asy->asy_ioaddr); in asyattach()
1628 asy_put(asy, ASY_LCR, asy->asy_lcr); in asyattach()
1629 asy_set_baudrate(asy, asy->asy_bidx); in asyattach()
1632 mutex_exit(&asy->asy_excl_hi); in asyattach()
1633 mutex_exit(&asy->asy_excl); in asyattach()
1636 asy->asy_progress |= ASY_PROGRESS_ASYNC; in asyattach()
1639 if (asy->asy_com_port != 0) { in asyattach()
1644 name[0] = asy->asy_com_port + 'a' - 1; in asyattach()
1654 asy->asy_com_port != 0 ? DDI_NT_SERIAL_MB : DDI_NT_SERIAL, 0); in asyattach()
1659 asy->asy_com_port != 0 ? DDI_NT_SERIAL_MB_DO : in asyattach()
1666 asy->asy_progress |= ASY_PROGRESS_MINOR; in asyattach()
1671 asy->polledio.cons_polledio_version = CONSPOLLEDIO_V0; in asyattach()
1672 asy->polledio.cons_polledio_argument = (cons_polledio_arg_t)asy; in asyattach()
1673 asy->polledio.cons_polledio_putchar = asyputchar; in asyattach()
1674 asy->polledio.cons_polledio_getchar = asygetchar; in asyattach()
1675 asy->polledio.cons_polledio_ischar = asyischar; in asyattach()
1676 asy->polledio.cons_polledio_enter = NULL; in asyattach()
1677 asy->polledio.cons_polledio_exit = NULL; in asyattach()
1701 if ((asy == NULL) || (asy->asy_dip == NULL)) in asyinfo()
1704 *result = (void *) asy->asy_dip; in asyinfo()
1718 /* asy_getproperty -- walk through all name variants until we find a match */
1725 char letter = asy->asy_com_port + 'a' - 1; /* for ttya */ in asy_getproperty()
1726 char number = asy->asy_com_port + '0'; /* for COM1 */ in asy_getproperty()
1731 (void) sprintf(name, "tty%c-%s", letter, property); in asy_getproperty()
1735 (void) sprintf(name, "com%c-%s", number, property); in asy_getproperty()
1740 (void) sprintf(name, "tty0%c-%s", number, property); in asy_getproperty()
1745 (void) sprintf(name, "port-%c-%s", letter, property); in asy_getproperty()
1750 return (-1); /* property non-existant */ in asy_getproperty()
1756 /* asy_soft_state_free - local wrapper for ddi_soft_state_free(9F) */
1761 if (asy->asy_priv != NULL) { in asy_soft_state_free()
1762 kmem_free(asy->asy_priv, sizeof (struct asyncline)); in asy_soft_state_free()
1763 asy->asy_priv = NULL; in asy_soft_state_free()
1765 ddi_soft_state_free(asy_soft_state, asy->asy_unit); in asy_soft_state_free()
1771 switch (asy->asy_hwtype) { in asy_hw_name()
1787 asy->asy_hwtype); in asy_hw_name()
1795 if (ddi_prop_get_int(DDI_DEV_T_ANY, asy->asy_dip, DDI_PROP_DONTPASS, in asy_is_devid()
1800 if (ddi_prop_get_int(DDI_DEV_T_ANY, asy->asy_dip, DDI_PROP_DONTPASS, in asy_is_devid()
1811 if (asy_get_bus_type(asy->asy_dip) != ASY_BUS_PCI) in asy_check_loopback()
1815 if (asy_is_devid(asy, "vendor-id", "device-id", 0x11c1, 0x0480) || in asy_check_loopback()
1816 asy_is_devid(asy, "subsystem-vendor-id", "subsystem-id", 0x11c1, in asy_check_loopback()
1818 asy->asy_flags2 |= ASY2_NO_LOOPBACK; in asy_check_loopback()
1832 asy->asy_hwtype = ASY_MAXCHIP; in asy_identify_chip()
1858 (void *)asy->asy_ioaddr, spr); in asy_identify_chip()
1881 asy->asy_fifor = 0; in asy_identify_chip()
1883 asy->asy_fifor |= in asy_identify_chip()
1891 asy->asy_fifor |= ASY_FCR_FIFO64; in asy_identify_chip()
1904 (void *)asy->asy_ioaddr); in asy_identify_chip()
1910 asy->asy_fifor | ASY_FCR_THR_FL | ASY_FCR_RHR_FL, isr, mcr); in asy_identify_chip()
1926 asy->asy_fifor = 0; in asy_identify_chip()
1931 asy->asy_fifo_buf = 16; in asy_identify_chip()
1932 asy->asy_use_fifo = ASY_FCR_FIFO_EN; in asy_identify_chip()
1933 asy->asy_fifor &= ~ASY_FCR_FIFO64; in asy_identify_chip()
1938 asy->asy_fifo_buf = 64; in asy_identify_chip()
1939 asy->asy_use_fifo = ASY_FCR_FIFO_EN; in asy_identify_chip()
1944 asy->asy_fifor = 0; in asy_identify_chip()
1951 (void *)asy->asy_ioaddr, in asy_identify_chip()
1952 asy->asy_fifor | ASY_FCR_THR_FL | ASY_FCR_RHR_FL, isr, mcr); in asy_identify_chip()
1959 * downgrade of the asy->asy_hwtype, or it may not disable in asy_identify_chip()
1980 /* looks like we have an ST16650 -- enable it */ in asy_identify_chip()
1985 * Some 16650-compatible chips are also compatible with in asy_identify_chip()
1989 if (asy->asy_fifo_buf < 32) in asy_identify_chip()
1990 asy->asy_fifo_buf = 32; in asy_identify_chip()
1997 if (asy_max_tx_fifo >= asy->asy_fifo_buf) in asy_identify_chip()
1998 asy->asy_fifor |= ASY_FCR_THR_TRIG_24; in asy_identify_chip()
2011 * First, clear IER and read it back. That should be a no-op as in asy_identify_chip()
2018 dev_err(asy->asy_dip, CE_WARN, "!%s: UART @ %p " in asy_identify_chip()
2020 (void *)asy->asy_ioaddr, ier); in asy_identify_chip()
2044 asy->asy_fifo_buf = 128; in asy_identify_chip()
2046 asy->asy_fifo_buf = 16; in asy_identify_chip()
2054 asy->asy_acr = ASY_ACR_TRIG | ASY_ACR_DTR_NORM; in asy_identify_chip()
2055 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_identify_chip()
2058 asy_put(asy, ASY_RTL, asy->asy_fifo_buf/2); in asy_identify_chip()
2102 asy->asy_hwtype = hwtype; in asy_identify_chip()
2109 !(asy->asy_flags2 & ASY2_NO_LOOPBACK) && in asy_identify_chip()
2110 (asy->asy_fifo_buf > 16 || in asy_identify_chip()
2111 (asy_fifo_test > 1 && asy->asy_use_fifo == ASY_FCR_FIFO_EN) || in asy_identify_chip()
2123 for (i = 0; i < asy->asy_fifo_buf * 2; i++) { in asy_identify_chip()
2143 * In theory, 200 * asy->asy_fifo_buf * 2 should be in asy_identify_chip()
2149 delay(drv_usectohz(400 * asy->asy_fifo_buf * 3)); in asy_identify_chip()
2152 for (i = 0; i < asy->asy_fifo_buf * 3; i++) { in asy_identify_chip()
2161 asy->asy_fifo_buf, i); in asy_identify_chip()
2163 hwtype = asy->asy_hwtype; in asy_identify_chip()
2164 if (i < asy->asy_fifo_buf) { in asy_identify_chip()
2173 if (i >= 16 && asy->asy_fifo_buf >= 16) { in asy_identify_chip()
2176 asy->asy_fifo_buf = 16; in asy_identify_chip()
2177 asy->asy_fifor &= in asy_identify_chip()
2182 asy->asy_fifo_buf = 1; in asy_identify_chip()
2183 asy->asy_use_fifo = ASY_FCR_FIFO_OFF; in asy_identify_chip()
2184 asy->asy_fifor = 0; in asy_identify_chip()
2186 } else if (i > asy->asy_fifo_buf) { in asy_identify_chip()
2192 asy->asy_fifo_buf = i; in asy_identify_chip()
2201 * before any possible downgrade of asy->asy_hwtype. in asy_identify_chip()
2203 if (asy->asy_hwtype >= ASY_16650 && hwtype < ASY_16650) { in asy_identify_chip()
2208 asy->asy_hwtype = hwtype; in asy_identify_chip()
2215 asy_hw_name(asy), (void *)asy->asy_ioaddr); in asy_identify_chip()
2218 dev = makedevice(DDI_MAJOR_T_UNKNOWN, asy->asy_unit); in asy_identify_chip()
2221 if (asy->asy_hwtype == ASY_16550) /* for broken 16550's, */ in asy_identify_chip()
2222 asy->asy_hwtype = ASY_8250A; /* drive them as 8250A */ in asy_identify_chip()
2228 * asyinit() initializes the TTY protocol-private data for this channel
2236 asy->asy_priv = kmem_zalloc(sizeof (struct asyncline), KM_SLEEP); in asyinit()
2237 async = asy->asy_priv; in asyinit()
2238 mutex_enter(&asy->asy_excl); in asyinit()
2239 async->async_common = asy; in asyinit()
2240 cv_init(&async->async_flags_cv, NULL, CV_DRIVER, NULL); in asyinit()
2241 mutex_exit(&asy->asy_excl); in asyinit()
2258 async = asy->asy_priv; in asyopen()
2259 mutex_enter(&asy->asy_excl); in asyopen()
2262 mutex_enter(&asy->asy_excl_hi); in asyopen()
2265 * Block waiting for carrier to come up, unless this is a no-delay open. in asyopen()
2267 if (!(async->async_flags & ASYNC_ISOPEN)) { in asyopen()
2272 mutex_exit(&asy->asy_excl_hi); in asyopen()
2278 async->async_ttycommon.t_cflag = termiosp->c_cflag; in asyopen()
2284 mutex_enter(&asy->asy_excl_hi); in asyopen()
2286 /* eeprom mode support - respect properties */ in asyopen()
2287 if (asy->asy_cflag) in asyopen()
2288 async->async_ttycommon.t_cflag = asy->asy_cflag; in asyopen()
2290 async->async_ttycommon.t_iflag = 0; in asyopen()
2291 async->async_ttycommon.t_iocpending = NULL; in asyopen()
2292 async->async_ttycommon.t_size.ws_row = 0; in asyopen()
2293 async->async_ttycommon.t_size.ws_col = 0; in asyopen()
2294 async->async_ttycommon.t_size.ws_xpixel = 0; in asyopen()
2295 async->async_ttycommon.t_size.ws_ypixel = 0; in asyopen()
2296 async->async_dev = *dev; in asyopen()
2297 async->async_wbufcid = 0; in asyopen()
2299 async->async_startc = CSTART; in asyopen()
2300 async->async_stopc = CSTOP; in asyopen()
2302 } else if ((async->async_ttycommon.t_flags & TS_XCLUDE) && in asyopen()
2304 mutex_exit(&asy->asy_excl_hi); in asyopen()
2305 mutex_exit(&asy->asy_excl); in asyopen()
2307 } else if ((*dev & OUTLINE) && !(async->async_flags & ASYNC_OUT)) { in asyopen()
2308 mutex_exit(&asy->asy_excl_hi); in asyopen()
2309 mutex_exit(&asy->asy_excl); in asyopen()
2314 async->async_flags |= ASYNC_OUT; in asyopen()
2317 while (async->async_flags & ASYNC_DTR_DELAY) { in asyopen()
2320 mutex_exit(&asy->asy_excl_hi); in asyopen()
2321 if (cv_wait_sig(&async->async_flags_cv, in asyopen()
2322 &asy->asy_excl) == 0) { in asyopen()
2325 mutex_exit(&asy->asy_excl); in asyopen()
2328 mutex_enter(&asy->asy_excl_hi); in asyopen()
2331 asy_set(asy, ASY_MCR, asy->asy_mcr & ASY_MCR_DTR); in asyopen()
2335 (asy->asy_flags & ASY_IGNORE_CD) ? "ON" : "OFF"); in asyopen()
2337 if (asy->asy_flags & ASY_IGNORE_CD) { in asyopen()
2340 async->async_ttycommon.t_flags |= TS_SOFTCAR; in asyopen()
2342 async->async_ttycommon.t_flags &= ~TS_SOFTCAR; in asyopen()
2348 asy->asy_msr = asy_get(asy, ASY_MSR); in asyopen()
2350 (async->async_ttycommon.t_flags & TS_SOFTCAR) ? "set" : "clear", in asyopen()
2351 (asy->asy_msr & ASY_MSR_DCD) ? "set" : "clear"); in asyopen()
2353 if (asy->asy_msr & ASY_MSR_DCD) in asyopen()
2354 async->async_flags |= ASYNC_CARR_ON; in asyopen()
2356 async->async_flags &= ~ASYNC_CARR_ON; in asyopen()
2357 mutex_exit(&asy->asy_excl_hi); in asyopen()
2364 !(async->async_ttycommon.t_cflag & CLOCAL)) { in asyopen()
2365 if ((!(async->async_flags & (ASYNC_CARR_ON|ASYNC_OUT)) && in asyopen()
2366 !(async->async_ttycommon.t_flags & TS_SOFTCAR)) || in asyopen()
2367 ((async->async_flags & ASYNC_OUT) && in asyopen()
2369 async->async_flags |= ASYNC_WOPEN; in asyopen()
2370 if (cv_wait_sig(&async->async_flags_cv, in asyopen()
2371 &asy->asy_excl) == B_FALSE) { in asyopen()
2372 async->async_flags &= ~ASYNC_WOPEN; in asyopen()
2373 mutex_exit(&asy->asy_excl); in asyopen()
2376 async->async_flags &= ~ASYNC_WOPEN; in asyopen()
2379 } else if ((async->async_flags & ASYNC_OUT) && !(*dev & OUTLINE)) { in asyopen()
2380 mutex_exit(&asy->asy_excl); in asyopen()
2384 async->async_ttycommon.t_readq = rq; in asyopen()
2385 async->async_ttycommon.t_writeq = WR(rq); in asyopen()
2386 rq->q_ptr = WR(rq)->q_ptr = (caddr_t)async; in asyopen()
2387 mutex_exit(&asy->asy_excl); in asyopen()
2389 * Caution here -- qprocson sets the pointers that are used by canput in asyopen()
2394 async->async_flags |= ASYNC_ISOPEN; in asyopen()
2395 async->async_polltid = 0; in asyopen()
2404 struct asycom *asy = async->async_common; in async_progress_check()
2412 mutex_enter(&asy->asy_excl); in async_progress_check()
2413 mutex_enter(&asy->asy_excl_hi); in async_progress_check()
2414 if (!(async->async_flags & (ASYNC_BREAK|ASYNC_DELAY|ASYNC_PROGRESS))) { in async_progress_check()
2415 async->async_ocnt = 0; in async_progress_check()
2416 async->async_flags &= ~ASYNC_BUSY; in async_progress_check()
2417 async->async_timer = 0; in async_progress_check()
2418 bp = async->async_xmitblk; in async_progress_check()
2419 async->async_xmitblk = NULL; in async_progress_check()
2420 mutex_exit(&asy->asy_excl_hi); in async_progress_check()
2429 flushq(async->async_ttycommon.t_writeq, FLUSHALL); in async_progress_check()
2430 cv_broadcast(&async->async_flags_cv); in async_progress_check()
2432 async->async_flags &= ~ASYNC_PROGRESS; in async_progress_check()
2433 async->async_timer = timeout(async_progress_check, async, in async_progress_check()
2435 mutex_exit(&asy->asy_excl_hi); in async_progress_check()
2437 mutex_exit(&asy->asy_excl); in async_progress_check()
2446 struct asycom *asy = async->async_common; in async_dtr_free()
2450 mutex_enter(&asy->asy_excl); in async_dtr_free()
2451 async->async_flags &= ~ASYNC_DTR_DELAY; in async_dtr_free()
2452 async->async_dtrtid = 0; in async_dtr_free()
2453 cv_broadcast(&async->async_flags_cv); in async_dtr_free()
2454 mutex_exit(&asy->asy_excl); in async_dtr_free()
2466 async = (struct asyncline *)q->q_ptr; in asyclose()
2467 ASSERT(async != NULL); in asyclose()
2469 asy = async->async_common; in asyclose()
2473 mutex_enter(&asy->asy_excl); in asyclose()
2474 async->async_flags |= ASYNC_CLOSING; in asyclose()
2478 * close. Also reset the DCD edge monitoring bit. in asyclose()
2480 mutex_enter(&asy->asy_excl_hi); in asyclose()
2481 asy->asy_flags &= ~(ASY_PPS | ASY_PPS_EDGE); in asyclose()
2482 mutex_exit(&asy->asy_excl_hi); in asyclose()
2485 * There are two flavors of break -- timed (M_BREAK or TCSBRK) and in asyclose()
2493 if (async->async_flags & ASYNC_OUT_SUSPEND) { in asyclose()
2494 if (async->async_utbrktid != 0) { in asyclose()
2495 (void) untimeout(async->async_utbrktid); in asyclose()
2496 async->async_utbrktid = 0; in asyclose()
2498 mutex_enter(&asy->asy_excl_hi); in asyclose()
2500 mutex_exit(&asy->asy_excl_hi); in asyclose()
2501 async->async_flags &= ~ASYNC_OUT_SUSPEND; in asyclose()
2506 * If the user told us not to delay the close ("non-blocking"), then in asyclose()
2516 (async->async_flags & ASYNC_STOPPED)) { in asyclose()
2523 * - called by close(2): need to drain until done or until in asyclose()
2525 * - called by exit(2): need to drain while making progress in asyclose()
2530 * to check for progress in sending the output data -- all that we ask in asyclose()
2539 async->async_flags &= ~ASYNC_PROGRESS; in asyclose()
2540 async->async_timer = timeout(async_progress_check, async, in asyclose()
2543 while (async->async_ocnt > 0 || in asyclose()
2544 async->async_ttycommon.t_writeq->q_first != NULL || in asyclose()
2545 (async->async_flags & (ASYNC_BUSY|ASYNC_BREAK|ASYNC_DELAY))) { in asyclose()
2546 if (cv_wait_sig(&async->async_flags_cv, &asy->asy_excl) == 0) in asyclose()
2549 if (async->async_timer != 0) { in asyclose()
2550 (void) untimeout(async->async_timer); in asyclose()
2551 async->async_timer = 0; in asyclose()
2555 async->async_ocnt = 0; in asyclose()
2556 if (async->async_xmitblk != NULL) in asyclose()
2557 freeb(async->async_xmitblk); in asyclose()
2558 async->async_xmitblk = NULL; in asyclose()
2565 mutex_enter(&asy->asy_excl_hi); in asyclose()
2566 if ((async->async_ttycommon.t_cflag & HUPCL) || in asyclose()
2567 (async->async_flags & ASYNC_WOPEN)) { in asyclose()
2570 async->async_ttycommon.t_cflag & HUPCL, in asyclose()
2571 async->async_ttycommon.t_cflag & ASYNC_WOPEN); in asyclose()
2572 async->async_flags |= ASYNC_DTR_DELAY; in asyclose()
2575 if (asy->asy_flags & (ASY_IGNORE_CD|ASY_RTS_DTR_OFF)) { in asyclose()
2579 asy->asy_flags & ASY_IGNORE_CD, in asyclose()
2580 asy->asy_flags & ASY_RTS_DTR_OFF); in asyclose()
2582 asy_put(asy, ASY_MCR, asy->asy_mcr | ASY_MCR_OUT2); in asyclose()
2588 async->async_dtrtid = in asyclose()
2595 if ((async->async_flags & (ASYNC_WOPEN|ASYNC_ISOPEN)) == 0) in asyclose()
2598 mutex_exit(&asy->asy_excl_hi); in asyclose()
2600 ttycommon_close(&async->async_ttycommon); in asyclose()
2605 if (async->async_wbufcid != 0) { in asyclose()
2606 unbufcall(async->async_wbufcid); in asyclose()
2607 async->async_wbufcid = 0; in asyclose()
2612 q->q_ptr = WR(q)->q_ptr = NULL; in asyclose()
2613 async->async_ttycommon.t_readq = NULL; in asyclose()
2614 async->async_ttycommon.t_writeq = NULL; in asyclose()
2619 async->async_flags &= (ASYNC_DTR_DELAY|ASY_RTS_DTR_OFF); in asyclose()
2620 cv_broadcast(&async->async_flags_cv); in asyclose()
2621 mutex_exit(&asy->asy_excl); in asyclose()
2633 async = asy->asy_priv; in asy_isbusy()
2634 ASSERT(mutex_owned(&asy->asy_excl)); in asy_isbusy()
2635 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_isbusy()
2639 return ((async->async_ocnt > 0) || in asy_isbusy()
2652 ASSERT(mutex_owned(&asy->asy_excl)); in asy_waiteot()
2653 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_waiteot()
2655 mutex_exit(&asy->asy_excl_hi); in asy_waiteot()
2656 mutex_exit(&asy->asy_excl); in asy_waiteot()
2658 mutex_enter(&asy->asy_excl); in asy_waiteot()
2659 mutex_enter(&asy->asy_excl_hi); in asy_waiteot()
2663 /* asy_reset_fifo -- flush fifos and [re]program fifo control register */
2667 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_reset_fifo()
2670 if (asy->asy_hwtype >= ASY_16750) in asy_reset_fifo()
2673 asy_put(asy, ASY_FCR, asy->asy_fifor | flush); in asy_reset_fifo()
2676 if (asy->asy_hwtype >= ASY_16750) in asy_reset_fifo()
2693 ASSERT(mutex_owned(&asy->asy_excl)); in asy_program()
2694 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_program()
2696 async = asy->asy_priv; in asy_program()
2699 baudrate = BAUDINDEX(async->async_ttycommon.t_cflag); in asy_program()
2701 async->async_ttycommon.t_cflag &= ~(CIBAUD); in asy_program()
2704 async->async_ttycommon.t_cflag |= CIBAUDEXT; in asy_program()
2705 async->async_ttycommon.t_cflag |= in asy_program()
2706 (((baudrate - CBAUD - 1) << IBSHIFT) & CIBAUD); in asy_program()
2708 async->async_ttycommon.t_cflag &= ~CIBAUDEXT; in asy_program()
2709 async->async_ttycommon.t_cflag |= in asy_program()
2713 c_flag = async->async_ttycommon.t_cflag & in asy_program()
2718 ocflags = asy->asy_ocflag; in asy_program()
2723 asy->asy_msr = flush_reg = asy_get(asy, ASY_MSR); in asy_program()
2730 if ((CRTSCTS & async->async_ttycommon.t_cflag) && in asy_program()
2739 async->async_flags &= ~ASYNC_HW_OUT_FLW; in asy_program()
2747 * Because of handling IXON in the driver, we also should re-calculate in asy_program()
2753 if (!(IXON & async->async_ttycommon.t_iflag)) in asy_program()
2754 async->async_flags &= ~ASYNC_SW_OUT_FLW; in asy_program()
2758 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asy_program()
2759 for (flush_reg = asy->asy_fifo_buf; flush_reg-- > 0; ) { in asy_program()
2807 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) in asy_program()
2812 asy->asy_ocflag = c_flag & ~CLOCAL; in asy_program()
2817 (asy->asy_mcr & ASY_MCR_RTS) | ASY_MCR_OUT2); in asy_program()
2819 asy_put(asy, ASY_MCR, asy->asy_mcr | ASY_MCR_OUT2); in asy_program()
2831 c_flag & CLOCAL, async->async_ttycommon.t_cflag & CRTSCTS); in asy_program()
2839 * this isn't a direct-wired (local) line, which ignores DCD. in asy_program()
2842 (async->async_ttycommon.t_cflag & CRTSCTS)) in asy_program()
2855 struct asyncline *async = asy->asy_priv; in asy_baudok()
2859 baudrate = BAUDINDEX(async->async_ttycommon.t_cflag); in asy_baudok()
2877 * This routine checks the Bit 0 (interrupt-not-pending) to determine if
2887 mutex_enter(&asy->asy_excl_hi); in asyintr()
2888 async = asy->asy_priv; in asyintr()
2890 (async->async_flags & (ASYNC_ISOPEN|ASYNC_WOPEN)) == 0) { in asyintr()
2895 async, async == NULL ? 0 : async->async_flags, intr_id); in asyintr()
2906 asy->asy_msr = asy_get(asy, ASY_MSR); in asyintr()
2909 mutex_exit(&asy->asy_excl_hi); in asyintr()
2920 if (asy->asy_flags & ASY_DDI_SUSPENDED) { in asyintr()
2921 mutex_exit(&asy->asy_excl_hi); in asyintr()
2927 * interrupt is edge triggered. in asyintr()
2934 * async_rxint() and not re-read there. In the unexpected event in asyintr()
2959 * The transmit-ready interrupt implies an empty in asyintr()
2960 * transmit-hold register (or FIFO). Check that it is in asyintr()
2987 if ((lsr & ASY_LSR_THRE) && (async->async_flags & ASYNC_BUSY) && in asyintr()
2988 async->async_ocnt > 0) in asyintr()
2992 mutex_exit(&asy->asy_excl_hi); in asyintr()
2998 * If there is more data to transmit in the current pseudo-DMA block,
3002 * XXX - Needs review for HW FIFOs.
3007 struct asyncline *async = asy->asy_priv; in async_txint()
3010 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_txint()
3018 if (async->async_flags & (ASYNC_BREAK|ASYNC_OUT_SUSPEND)) in async_txint()
3021 fifo_len = asy->asy_fifo_buf; /* with FIFO buffers */ in async_txint()
3026 fifo_len--; in async_txint()
3028 if (async->async_ocnt > 0 && fifo_len > 0 && in async_txint()
3029 !(async->async_flags & in async_txint()
3031 while (fifo_len-- > 0 && async->async_ocnt-- > 0) { in async_txint()
3032 asy_put(asy, ASY_THR, *async->async_optr++); in async_txint()
3034 async->async_flags |= ASYNC_PROGRESS; in async_txint()
3050 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in asy_ppsevent()
3052 if (asy->asy_flags & ASY_PPS_EDGE) { in asy_ppsevent()
3053 /* Have seen leading edge, now look for and record drop */ in asy_ppsevent()
3055 asy->asy_flags &= ~ASY_PPS_EDGE; in asy_ppsevent()
3057 * Waiting for leading edge, look for rise; stamp event and in asy_ppsevent()
3068 * NTP requires micro based, an in-line fast algorithm in asy_ppsevent()
3069 * to convert nsec to usec is used here -- see hrt2ts() in asy_ppsevent()
3076 asy->asy_flags |= ASY_PPS_EDGE; in asy_ppsevent()
3085 usec = nsec - (usec >> 3); in asy_ppsevent()
3091 tvp->tv_usec = usec >> 10; in asy_ppsevent()
3092 tvp->tv_sec = ts.tv_sec; in asy_ppsevent()
3097 * Because the kernel keeps a high-resolution time, in asy_ppsevent()
3113 * XXX - needs review for hw FIFOs support.
3119 struct asyncline *async = asy->asy_priv; in async_rxint()
3123 int looplim = asy->asy_fifo_buf * 2; in async_rxint()
3125 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_rxint()
3127 tp = &async->async_ttycommon; in async_rxint()
3128 if (!(tp->t_cflag & CREAD)) { in async_rxint()
3133 if (looplim-- < 0) /* limit loop */ in async_rxint()
3150 if (tp->t_iflag & IXON) { in async_rxint()
3151 if ((c == async->async_stopc) && in async_rxint()
3156 } else if ((c == async->async_startc) && in async_rxint()
3163 if ((tp->t_iflag & IXANY) && in async_rxint()
3164 (async->async_flags & ASYNC_SW_OUT_FLW)) { in async_rxint()
3176 (asy->asy_flags & ASY_CONSOLE)) { in async_rxint()
3184 if (tp->t_iflag & INPCK) /* parity enabled */ in async_rxint()
3191 async->async_hw_overrun = 1; in async_rxint()
3197 if ((tp->t_iflag & PARMRK) && in async_rxint()
3198 !(tp->t_iflag & (IGNPAR|ISTRIP)) && in async_rxint()
3204 async->async_sw_overrun = 1; in async_rxint()
3209 async->async_sw_overrun = 1; in async_rxint()
3213 if ((asy->asy_flags & ASY_CONSOLE) && in async_rxint()
3218 async->async_break++; in async_rxint()
3223 async->async_sw_overrun = 1; in async_rxint()
3228 async->async_sw_overrun = 1; in async_rxint()
3231 if (looplim-- < 0) /* limit loop */ in async_rxint()
3235 !(async->async_inflow_source & IN_FLOW_RINGBUFF)) { in async_rxint()
3241 if ((async->async_flags & ASYNC_SERVICEIMM) || needsoft || in async_rxint()
3242 (RING_FRAC(async)) || (async->async_polltid == 0)) { in async_rxint()
3256 struct asyncline *async = asy->asy_priv; in async_msint()
3257 int msr, t_cflag = async->async_ttycommon.t_cflag; in async_msint()
3259 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_msint()
3265 ++(asy->asy_msint_cnt)); in async_msint()
3278 if ((t_cflag & CRTSCTS) && (((asy->asy_msr ^ msr) & ASY_MSR_CTS) != 0)) in async_msint()
3286 asy->asy_msr = (uchar_t)msr; in async_msint()
3289 if (asy->asy_flags & ASY_PPS) in async_msint()
3292 async->async_ext++; in async_msint()
3297 * the modem status on the falling edge of the interrupt line, in async_msint()
3303 if (ASY_MSR_STATES(msr) != ASY_MSR_STATES(asy->asy_msr)) in async_msint()
3313 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in asysetsoft()
3315 if (mutex_tryenter(&asy->asy_soft_lock) == 0) in asysetsoft()
3318 asy->asy_flags |= ASY_NEEDSOFT; in asysetsoft()
3319 if (!asy->asysoftpend) { in asysetsoft()
3320 asy->asysoftpend = 1; in asysetsoft()
3321 mutex_exit(&asy->asy_soft_lock); in asysetsoft()
3322 (void) ddi_intr_trigger_softint(asy->asy_soft_inth, NULL); in asysetsoft()
3324 mutex_exit(&asy->asy_soft_lock); in asysetsoft()
3335 struct asyncline *async = asy->asy_priv; in asy_carrier_check()
3336 tty_common_t *tp = &async->async_ttycommon; in asy_carrier_check()
3337 queue_t *q = tp->t_readq; in asy_carrier_check()
3342 "asy_msr & DCD = %x, tp->t_flags & TS_SOFTCAR = %x", in asy_carrier_check()
3343 asy->asy_msr & ASY_MSR_DCD, tp->t_flags & TS_SOFTCAR); in asy_carrier_check()
3345 if (asy->asy_msr & ASY_MSR_DCD) { in asy_carrier_check()
3350 if ((async->async_flags & ASYNC_CARR_ON) != 0) in asy_carrier_check()
3354 async->async_flags |= ASYNC_CARR_ON; in asy_carrier_check()
3355 if (async->async_flags & ASYNC_ISOPEN) { in asy_carrier_check()
3356 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3357 mutex_exit(&asy->asy_excl); in asy_carrier_check()
3359 mutex_enter(&asy->asy_excl); in asy_carrier_check()
3360 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3362 cv_broadcast(&async->async_flags_cv); in asy_carrier_check()
3371 if ((async->async_flags & ASYNC_CARR_ON) == 0) in asy_carrier_check()
3379 if ((tp->t_cflag & CLOCAL) != 0 || (tp->t_flags & TS_SOFTCAR) != 0) in asy_carrier_check()
3389 if (async->async_flags & ASYNC_BUSY) { in asy_carrier_check()
3392 async->async_ocnt = 0; in asy_carrier_check()
3395 async->async_flags &= ~ASYNC_STOPPED; in asy_carrier_check()
3398 if ((async->async_flags & ASYNC_ISOPEN) == 0) in asy_carrier_check()
3402 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3403 mutex_exit(&asy->asy_excl); in asy_carrier_check()
3405 mutex_enter(&asy->asy_excl); in asy_carrier_check()
3411 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asy_carrier_check()
3412 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3414 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3423 flushflag = (async->async_flags & ASYNC_CLOSING) ? FLUSHALL : FLUSHDATA; in asy_carrier_check()
3424 flushq(tp->t_writeq, flushflag); in asy_carrier_check()
3427 bp = async->async_xmitblk; in asy_carrier_check()
3430 async->async_xmitblk = NULL; in asy_carrier_check()
3433 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3434 async->async_flags &= ~ASYNC_BUSY; in asy_carrier_check()
3439 async->async_flags &= ~ASYNC_CARR_ON; in asy_carrier_check()
3440 cv_broadcast(&async->async_flags_cv); in asy_carrier_check()
3444 * Handle a second-stage interrupt.
3457 mutex_enter(&asy->asy_soft_lock); in asysoftintr()
3459 rv = asy->asysoftpend; in asysoftintr()
3461 asy->asysoftpend = 0; in asysoftintr()
3462 mutex_exit(&asy->asy_soft_lock); in asysoftintr()
3465 if (asy->asy_priv == NULL) in asysoftintr()
3467 async = (struct asyncline *)asy->asy_priv; in asysoftintr()
3468 mutex_enter(&asy->asy_excl_hi); in asysoftintr()
3469 if (asy->asy_flags & ASY_NEEDSOFT) { in asysoftintr()
3470 asy->asy_flags &= ~ASY_NEEDSOFT; in asysoftintr()
3471 mutex_exit(&asy->asy_excl_hi); in asysoftintr()
3473 mutex_enter(&asy->asy_excl_hi); in asysoftintr()
3484 mutex_exit(&asy->asy_excl_hi); in asysoftintr()
3497 struct asyncline *async = asy->asy_priv; in async_softint()
3506 mutex_enter(&asy->asy_excl_hi); in async_softint()
3507 if (asy->asy_flags & ASY_DOINGSOFT) { in async_softint()
3508 asy->asy_flags |= ASY_DOINGSOFT_RETRY; in async_softint()
3509 mutex_exit(&asy->asy_excl_hi); in async_softint()
3512 asy->asy_flags |= ASY_DOINGSOFT; in async_softint()
3514 asy->asy_flags &= ~ASY_DOINGSOFT_RETRY; in async_softint()
3515 mutex_exit(&asy->asy_excl_hi); in async_softint()
3516 mutex_enter(&asy->asy_excl); in async_softint()
3517 tp = &async->async_ttycommon; in async_softint()
3518 q = tp->t_readq; in async_softint()
3520 if (async->async_flags & ASYNC_OUT_FLW_RESUME) { in async_softint()
3521 if (async->async_ocnt > 0) { in async_softint()
3522 mutex_enter(&asy->asy_excl_hi); in async_softint()
3524 mutex_exit(&asy->asy_excl_hi); in async_softint()
3526 if (async->async_xmitblk) in async_softint()
3527 freeb(async->async_xmitblk); in async_softint()
3528 async->async_xmitblk = NULL; in async_softint()
3531 async->async_flags &= ~ASYNC_OUT_FLW_RESUME; in async_softint()
3534 mutex_enter(&asy->asy_excl_hi); in async_softint()
3535 if (async->async_ext) { in async_softint()
3536 async->async_ext = 0; in async_softint()
3539 mutex_exit(&asy->asy_excl_hi); in async_softint()
3548 mutex_enter(&asy->asy_excl_hi); in async_softint()
3549 if (!(async->async_flags & ASYNC_ISOPEN)) { in async_softint()
3555 mutex_exit(&asy->asy_excl_hi); in async_softint()
3558 mutex_enter(&asy->asy_excl_hi); in async_softint()
3559 if (!(async->async_inflow_source & IN_FLOW_STREAMS)) { in async_softint()
3567 if (async->async_inflow_source & IN_FLOW_STREAMS) { in async_softint()
3568 mutex_enter(&asy->asy_excl_hi); in async_softint()
3573 mutex_exit(&asy->asy_excl_hi); in async_softint()
3579 mutex_exit(&asy->asy_excl); in async_softint()
3580 ttycommon_qfull(&async->async_ttycommon, q); in async_softint()
3581 mutex_enter(&asy->asy_excl); in async_softint()
3582 mutex_enter(&asy->asy_excl_hi); in async_softint()
3585 mutex_enter(&asy->asy_excl_hi); in async_softint()
3592 *bp->b_wptr++ = RING_GET(async); in async_softint()
3594 } while (--cc); in async_softint()
3595 mutex_exit(&asy->asy_excl_hi); in async_softint()
3596 mutex_exit(&asy->asy_excl); in async_softint()
3597 if (bp->b_wptr > bp->b_rptr) { in async_softint()
3615 mutex_enter(&asy->asy_excl); in async_softint()
3616 mutex_enter(&asy->asy_excl_hi); in async_softint()
3622 (async->async_inflow_source & IN_FLOW_RINGBUFF)) { in async_softint()
3632 if (async->async_break > 0) { in async_softint()
3633 nb = async->async_break; in async_softint()
3634 async->async_break = 0; in async_softint()
3635 if (async->async_flags & ASYNC_ISOPEN) { in async_softint()
3636 mutex_exit(&asy->asy_excl_hi); in async_softint()
3637 mutex_exit(&asy->asy_excl); in async_softint()
3638 for (; nb > 0; nb--) in async_softint()
3640 mutex_enter(&asy->asy_excl); in async_softint()
3641 mutex_enter(&asy->asy_excl_hi); in async_softint()
3644 if (async->async_ocnt <= 0 && (async->async_flags & ASYNC_BUSY)) { in async_softint()
3646 "Clearing ASYNC_BUSY, async_ocnt=%d", async->async_ocnt); in async_softint()
3647 async->async_flags &= ~ASYNC_BUSY; in async_softint()
3648 mutex_exit(&asy->asy_excl_hi); in async_softint()
3649 if (async->async_xmitblk) in async_softint()
3650 freeb(async->async_xmitblk); in async_softint()
3651 async->async_xmitblk = NULL; in async_softint()
3658 if (!(async->async_flags & ASYNC_BUSY)) in async_softint()
3659 cv_broadcast(&async->async_flags_cv); in async_softint()
3660 mutex_enter(&asy->asy_excl_hi); in async_softint()
3664 * about an error- They do not track multiple errors. In fact, in async_softint()
3669 if (async->async_hw_overrun) { in async_softint()
3670 if (async->async_flags & ASYNC_ISOPEN) { in async_softint()
3671 mutex_exit(&asy->asy_excl_hi); in async_softint()
3672 mutex_exit(&asy->asy_excl); in async_softint()
3674 mutex_enter(&asy->asy_excl); in async_softint()
3675 mutex_enter(&asy->asy_excl_hi); in async_softint()
3677 async->async_hw_overrun = 0; in async_softint()
3679 if (async->async_sw_overrun) { in async_softint()
3680 if (async->async_flags & ASYNC_ISOPEN) { in async_softint()
3681 mutex_exit(&asy->asy_excl_hi); in async_softint()
3682 mutex_exit(&asy->asy_excl); in async_softint()
3684 mutex_enter(&asy->asy_excl); in async_softint()
3685 mutex_enter(&asy->asy_excl_hi); in async_softint()
3687 async->async_sw_overrun = 0; in async_softint()
3689 if (asy->asy_flags & ASY_DOINGSOFT_RETRY) { in async_softint()
3690 mutex_exit(&asy->asy_excl); in async_softint()
3693 asy->asy_flags &= ~ASY_DOINGSOFT; in async_softint()
3694 mutex_exit(&asy->asy_excl_hi); in async_softint()
3695 mutex_exit(&asy->asy_excl); in async_softint()
3706 struct asycom *asy = async->async_common; in async_restart()
3714 mutex_enter(&asy->asy_excl); in async_restart()
3719 if ((async->async_flags & ASYNC_BREAK) && in async_restart()
3720 !(async->async_flags & ASYNC_OUT_SUSPEND)) { in async_restart()
3721 mutex_enter(&asy->asy_excl_hi); in async_restart()
3723 mutex_exit(&asy->asy_excl_hi); in async_restart()
3725 async->async_flags &= ~(ASYNC_DELAY|ASYNC_BREAK); in async_restart()
3726 cv_broadcast(&async->async_flags_cv); in async_restart()
3729 mutex_exit(&asy->asy_excl); in async_restart()
3738 struct asycom *asy = async->async_common; in async_start()
3749 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in async_start()
3750 fifo_len = asy->asy_fifo_buf; /* with FIFO buffers */ in async_start()
3755 ASSERT(mutex_owned(&asy->asy_excl)); in async_start()
3762 if (async->async_flags & (ASYNC_BREAK|ASYNC_BUSY)) { in async_start()
3764 async->async_flags & ASYNC_BREAK ? "break" : "busy"); in async_start()
3771 mutex_enter(&asy->asy_excl_hi); in async_start()
3773 fifo_len--; in async_start()
3774 mutex_exit(&asy->asy_excl_hi); in async_start()
3780 if (async->async_flags & ASYNC_DELAY) { in async_start()
3785 if ((q = async->async_ttycommon.t_writeq) == NULL) { in async_start()
3800 switch (bp->b_datap->db_type) { in async_start()
3809 mutex_enter(&asy->asy_excl_hi); in async_start()
3811 mutex_exit(&asy->asy_excl_hi); in async_start()
3812 async->async_flags |= ASYNC_BREAK; in async_start()
3825 (int)(*(unsigned char *)bp->b_rptr + 6)); in async_start()
3826 async->async_flags |= ASYNC_DELAY; in async_start()
3836 mutex_exit(&asy->asy_excl); in async_start()
3838 mutex_enter(&asy->asy_excl); in async_start()
3843 nbp = bp->b_cont; in async_start()
3855 if (async->async_flags & (ASYNC_HW_OUT_FLW | ASYNC_SW_OUT_FLW | in async_start()
3861 async->async_xmitblk = bp; in async_start()
3862 xmit_addr = bp->b_rptr; in async_start()
3863 bp = bp->b_cont; in async_start()
3868 * In 5-bit mode, the high order bits are used in async_start()
3872 if ((async->async_ttycommon.t_cflag & CSIZE) == CS5) { in async_start()
3876 while (cnt--) in async_start()
3881 * Set up this block for pseudo-DMA. in async_start()
3883 mutex_enter(&asy->asy_excl_hi); in async_start()
3889 while (--fifo_len >= 0 && cc > 0) { in async_start()
3893 cc--; in async_start()
3896 async->async_optr = xmit_addr; in async_start()
3897 async->async_ocnt = cc; in async_start()
3899 async->async_flags |= ASYNC_PROGRESS; in async_start()
3901 async->async_ocnt); in async_start()
3902 async->async_flags |= ASYNC_BUSY; in async_start()
3903 mutex_exit(&asy->asy_excl_hi); in async_start()
3912 struct asycom *asy = async->async_common; in async_resume()
3915 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_resume()
3920 if (async->async_ocnt > 0 && in async_resume()
3921 !(async->async_flags & in async_resume()
3923 asy_put(asy, ASY_THR, *async->async_optr++); in async_resume()
3924 async->async_ocnt--; in async_resume()
3925 async->async_flags |= ASYNC_PROGRESS; in async_resume()
3937 struct asycom *asy = async->async_common; in async_hold_utbrk()
3939 mutex_enter(&asy->asy_excl); in async_hold_utbrk()
3940 async->async_flags &= ~ASYNC_HOLD_UTBRK; in async_hold_utbrk()
3941 cv_broadcast(&async->async_flags_cv); in async_hold_utbrk()
3942 async->async_utbrktid = 0; in async_hold_utbrk()
3943 mutex_exit(&asy->asy_excl); in async_hold_utbrk()
3952 struct asycom *asy = async->async_common; in async_resume_utbrk()
3953 ASSERT(mutex_owned(&asy->asy_excl)); in async_resume_utbrk()
3959 while (async->async_flags & ASYNC_HOLD_UTBRK) { in async_resume_utbrk()
3960 cv_wait(&async->async_flags_cv, &asy->asy_excl); in async_resume_utbrk()
3962 mutex_enter(&asy->asy_excl_hi); in async_resume_utbrk()
3968 if (!(async->async_flags & ASYNC_BREAK)) in async_resume_utbrk()
3971 async->async_flags &= ~ASYNC_OUT_SUSPEND; in async_resume_utbrk()
3972 cv_broadcast(&async->async_flags_cv); in async_resume_utbrk()
3973 if (async->async_ocnt > 0) { in async_resume_utbrk()
3975 mutex_exit(&asy->asy_excl_hi); in async_resume_utbrk()
3977 async->async_flags &= ~ASYNC_BUSY; in async_resume_utbrk()
3978 mutex_exit(&asy->asy_excl_hi); in async_resume_utbrk()
3979 if (async->async_xmitblk != NULL) { in async_resume_utbrk()
3980 freeb(async->async_xmitblk); in async_resume_utbrk()
3981 async->async_xmitblk = NULL; in async_resume_utbrk()
3997 struct asycom *asy = async->async_common; in async_ioctl()
3998 tty_common_t *tp = &async->async_ttycommon; in async_ioctl()
4006 if (tp->t_iocpending != NULL) { in async_ioctl()
4013 freemsg(async->async_ttycommon.t_iocpending); in async_ioctl()
4014 async->async_ttycommon.t_iocpending = NULL; in async_ioctl()
4017 iocp = (struct iocblk *)mp->b_rptr; in async_ioctl()
4021 * because this function frees up the message block (mp->b_cont) that in async_ioctl()
4029 iocp->ioc_cmd == TIOCMGET ? "TIOCMGET" : in async_ioctl()
4030 iocp->ioc_cmd == TIOCMSET ? "TIOCMSET" : in async_ioctl()
4031 iocp->ioc_cmd == TIOCMBIS ? "TIOCMBIS" : in async_ioctl()
4032 iocp->ioc_cmd == TIOCMBIC ? "TIOCMBIC" : in async_ioctl()
4035 switch (iocp->ioc_cmd) { in async_ioctl()
4044 error = -1; /* Do Nothing */ in async_ioctl()
4053 * and do any state-changes the "ioctl" calls for. If we in async_ioctl()
4060 if (async->async_wbufcid) in async_ioctl()
4061 unbufcall(async->async_wbufcid); in async_ioctl()
4062 async->async_wbufcid = bufcall(datasize, BPRI_HI, in async_ioctl()
4064 (void *)(intptr_t)async->async_common->asy_unit); in async_ioctl()
4069 mutex_enter(&asy->asy_excl); in async_ioctl()
4076 switch (iocp->ioc_cmd) { in async_ioctl()
4079 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4084 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4091 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4099 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4107 switch (iocp->ioc_cmd) { in async_ioctl()
4113 if (mp->b_cont != NULL) in async_ioctl()
4114 freemsg(mp->b_cont); in async_ioctl()
4116 mp->b_cont = allocb(sizeof (int), BPRI_HI); in async_ioctl()
4117 if (mp->b_cont == NULL) { in async_ioctl()
4121 if (asy->asy_flags & ASY_PPS) in async_ioctl()
4122 *(int *)mp->b_cont->b_wptr = 1; in async_ioctl()
4124 *(int *)mp->b_cont->b_wptr = 0; in async_ioctl()
4125 mp->b_cont->b_wptr += sizeof (int); in async_ioctl()
4126 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4127 iocp->ioc_count = sizeof (int); in async_ioctl()
4138 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4139 if (*(int *)mp->b_cont->b_rptr) in async_ioctl()
4140 asy->asy_flags |= ASY_PPS; in async_ioctl()
4142 asy->asy_flags &= ~ASY_PPS; in async_ioctl()
4143 /* Reset edge sense */ in async_ioctl()
4144 asy->asy_flags &= ~ASY_PPS_EDGE; in async_ioctl()
4145 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4146 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4161 if (mp->b_cont != NULL) { in async_ioctl()
4162 freemsg(mp->b_cont); in async_ioctl()
4163 mp->b_cont = NULL; in async_ioctl()
4166 if ((asy->asy_flags & ASY_PPS) == 0) { in async_ioctl()
4172 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4174 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4177 if ((iocp->ioc_flag & IOC_MODELS) != IOC_NATIVE) { in async_ioctl()
4181 iocp->ioc_count = sizeof (struct ppsclockev32); in async_ioctl()
4186 iocp->ioc_count = sizeof (struct ppsclockev); in async_ioctl()
4189 if ((bp = allocb(iocp->ioc_count, BPRI_HI)) == NULL) { in async_ioctl()
4193 mp->b_cont = bp; in async_ioctl()
4195 bcopy(buf, bp->b_wptr, iocp->ioc_count); in async_ioctl()
4196 bp->b_wptr += iocp->ioc_count; in async_ioctl()
4197 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4206 if (*(int *)mp->b_cont->b_rptr == 0) { in async_ioctl()
4219 while (async->async_flags & ASYNC_BREAK) { in async_ioctl()
4220 cv_wait(&async->async_flags_cv, in async_ioctl()
4221 &asy->asy_excl); in async_ioctl()
4223 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4231 async->async_flags |= ASYNC_BREAK; in async_ioctl()
4240 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4246 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4248 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4255 if (!(async->async_flags & ASYNC_OUT_SUSPEND)) { in async_ioctl()
4256 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4257 async->async_flags |= ASYNC_OUT_SUSPEND; in async_ioctl()
4258 async->async_flags |= ASYNC_HOLD_UTBRK; in async_ioctl()
4260 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4262 async->async_utbrktid = in async_ioctl()
4271 if (async->async_flags & ASYNC_OUT_SUSPEND) in async_ioctl()
4279 if (iocp->ioc_count != TRANSPARENT) { in async_ioctl()
4281 "non-transparent"); in async_ioctl()
4287 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4289 dmtoasy(asy, *(int *)mp->b_cont->b_rptr), in async_ioctl()
4290 iocp->ioc_cmd); in async_ioctl()
4291 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4292 iocp->ioc_error = 0; in async_ioctl()
4293 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4308 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4309 *(int *)datamp->b_rptr = asymctl(asy, 0, TIOCMGET); in async_ioctl()
4310 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4312 if (iocp->ioc_count == TRANSPARENT) { in async_ioctl()
4318 "non-transparent"); in async_ioctl()
4328 *(struct cons_polledio **)mp->b_cont->b_rptr = in async_ioctl()
4329 &asy->polledio; in async_ioctl()
4331 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4335 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4336 iocp->ioc_error = 0; in async_ioctl()
4337 iocp->ioc_rval = 0; in async_ioctl()
4341 error = secpolicy_console(iocp->ioc_cr); in async_ioctl()
4345 if (iocp->ioc_count != TRANSPARENT) { in async_ioctl()
4350 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4351 if (*(intptr_t *)mp->b_cont->b_rptr) in async_ioctl()
4352 asy->asy_flags |= ASY_CONSOLE; in async_ioctl()
4354 asy->asy_flags &= ~ASY_CONSOLE; in async_ioctl()
4355 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4357 mp->b_datap->db_type = M_IOCACK; in async_ioctl()
4358 iocp->ioc_error = 0; in async_ioctl()
4359 iocp->ioc_rval = 0; in async_ioctl()
4364 ASSERT(sizeof (boolean_t) <= sizeof (boolean_t *)); in async_ioctl()
4370 *(boolean_t *)mp->b_cont->b_rptr = in async_ioctl()
4371 (asy->asy_flags & ASY_CONSOLE) != 0; in async_ioctl()
4383 iocp->ioc_error = error; in async_ioctl()
4384 mp->b_datap->db_type = M_IOCNAK; in async_ioctl()
4386 mutex_exit(&asy->asy_excl); in async_ioctl()
4398 async = (struct asyncline *)q->q_ptr; in asyrsrv()
4399 asy = (struct asycom *)async->async_common; in asyrsrv()
4403 mutex_enter(&asy->asy_excl_hi); in asyrsrv()
4405 mutex_exit(&asy->asy_excl_hi); in asyrsrv()
4406 async->async_polltid = 0; in asyrsrv()
4417 !((wput) && ((async)->async_flags & ASYNC_DDI_SUSPENDED))
4437 async = (struct asyncline *)q->q_ptr; in asywputdo()
4438 asy = async->async_common; in asywputdo()
4440 switch (mp->b_datap->db_type) { in asywputdo()
4447 mutex_enter(&asy->asy_excl); in asywputdo()
4448 async->async_flags |= ASYNC_STOPPED; in asywputdo()
4449 mutex_exit(&asy->asy_excl); in asywputdo()
4454 mutex_enter(&asy->asy_excl); in asywputdo()
4455 if (async->async_flags & ASYNC_STOPPED) { in asywputdo()
4456 async->async_flags &= ~ASYNC_STOPPED; in asywputdo()
4463 if (async->async_ocnt > 0) { in asywputdo()
4464 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4466 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4472 mutex_exit(&asy->asy_excl); in asywputdo()
4477 switch (((struct iocblk *)mp->b_rptr)->ioc_cmd) { in asywputdo()
4486 if (*(int *)mp->b_cont->b_rptr != 0) { in asywputdo()
4491 mutex_enter(&asy->asy_excl); in asywputdo()
4502 mutex_exit(&asy->asy_excl); in asywputdo()
4520 mutex_enter(&asy->asy_excl); in asywputdo()
4531 mutex_exit(&asy->asy_excl); in asywputdo()
4538 mutex_enter(&asy->asy_excl); in asywputdo()
4540 mutex_exit(&asy->asy_excl); in asywputdo()
4545 mutex_exit(&asy->asy_excl); in asywputdo()
4551 if (*mp->b_rptr & FLUSHW) { in asywputdo()
4552 mutex_enter(&asy->asy_excl); in asywputdo()
4557 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4558 if (async->async_flags & ASYNC_BUSY) { in asywputdo()
4562 async->async_ocnt = 0; in asywputdo()
4563 async->async_flags &= ~ASYNC_BUSY; in asywputdo()
4568 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asywputdo()
4572 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4578 if (async->async_xmitblk != NULL) { in asywputdo()
4579 freeb(async->async_xmitblk); in asywputdo()
4580 async->async_xmitblk = NULL; in asywputdo()
4582 mutex_exit(&asy->asy_excl); in asywputdo()
4583 *mp->b_rptr &= ~FLUSHW; /* it has been flushed */ in asywputdo()
4585 if (*mp->b_rptr & FLUSHR) { in asywputdo()
4587 mutex_enter(&asy->asy_excl); in asywputdo()
4588 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4590 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asywputdo()
4593 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4594 mutex_exit(&asy->asy_excl); in asywputdo()
4604 * write-side flush. in asywputdo()
4607 mutex_enter(&asy->asy_excl); in asywputdo()
4609 mutex_exit(&asy->asy_excl); in asywputdo()
4622 mutex_enter(&asy->asy_excl); in asywputdo()
4624 mutex_exit(&asy->asy_excl); in asywputdo()
4629 mutex_enter(&asy->asy_excl); in asywputdo()
4631 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4632 if (!(async->async_inflow_source & IN_FLOW_USER)) { in asywputdo()
4638 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4639 mutex_exit(&asy->asy_excl); in asywputdo()
4644 mutex_exit(&asy->asy_excl); in asywputdo()
4648 mutex_enter(&asy->asy_excl); in asywputdo()
4650 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4651 if (async->async_inflow_source & IN_FLOW_USER) { in asywputdo()
4657 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4658 mutex_exit(&asy->asy_excl); in asywputdo()
4663 mutex_exit(&asy->asy_excl); in asywputdo()
4668 ((struct iocblk *)mp->b_rptr)->ioc_cmd == MC_POSIXQUERY) { in asywputdo()
4669 mutex_enter(&asy->asy_excl); in asywputdo()
4671 ((struct iocblk *)mp->b_rptr)->ioc_cmd = in asywputdo()
4673 mutex_exit(&asy->asy_excl); in asywputdo()
4686 * (XXX - for x86?) in asywputdo()
4688 mutex_enter(&asy->asy_excl); in asywputdo()
4689 switch (*mp->b_rptr) { in asywputdo()
4692 async->async_flags |= ASYNC_SERVICEIMM; in asywputdo()
4696 async->async_flags &= ~ASYNC_SERVICEIMM; in asywputdo()
4699 mutex_exit(&asy->asy_excl); in asywputdo()
4705 mutex_enter(&asy->asy_excl); in asywputdo()
4707 mutex_exit(&asy->asy_excl); in asywputdo()
4712 mutex_exit(&asy->asy_excl); in asywputdo()
4742 ASSERT(asy != NULL); in async_reioctl()
4743 async = asy->asy_priv; in async_reioctl()
4748 mutex_enter(&asy->asy_excl); in async_reioctl()
4749 async->async_wbufcid = 0; in async_reioctl()
4750 if ((q = async->async_ttycommon.t_writeq) == NULL) { in async_reioctl()
4751 mutex_exit(&asy->asy_excl); in async_reioctl()
4754 if ((mp = async->async_ttycommon.t_iocpending) != NULL) { in async_reioctl()
4756 async->async_ttycommon.t_iocpending = NULL; in async_reioctl()
4757 mutex_exit(&asy->asy_excl); in async_reioctl()
4760 mutex_exit(&asy->asy_excl); in async_reioctl()
4766 struct asyncline *async = (struct asyncline *)q->q_ptr; in async_iocdata()
4771 asy = async->async_common; in async_iocdata()
4772 ip = (struct iocblk *)mp->b_rptr; in async_iocdata()
4773 csp = (struct copyresp *)mp->b_rptr; in async_iocdata()
4775 if (csp->cp_rval != 0) { in async_iocdata()
4776 if (csp->cp_private) in async_iocdata()
4777 freemsg(csp->cp_private); in async_iocdata()
4782 mutex_enter(&asy->asy_excl); in async_iocdata()
4784 csp->cp_cmd == TIOCMGET ? "TIOCMGET" : in async_iocdata()
4785 csp->cp_cmd == TIOCMSET ? "TIOCMSET" : in async_iocdata()
4786 csp->cp_cmd == TIOCMBIS ? "TIOCMBIS" : in async_iocdata()
4788 switch (csp->cp_cmd) { in async_iocdata()
4791 if (mp->b_cont) { in async_iocdata()
4792 freemsg(mp->b_cont); in async_iocdata()
4793 mp->b_cont = NULL; in async_iocdata()
4795 mp->b_datap->db_type = M_IOCACK; in async_iocdata()
4796 ip->ioc_error = 0; in async_iocdata()
4797 ip->ioc_count = 0; in async_iocdata()
4798 ip->ioc_rval = 0; in async_iocdata()
4799 mp->b_wptr = mp->b_rptr + sizeof (struct iocblk); in async_iocdata()
4805 mutex_enter(&asy->asy_excl_hi); in async_iocdata()
4806 (void) asymctl(asy, dmtoasy(asy, *(int *)mp->b_cont->b_rptr), in async_iocdata()
4807 csp->cp_cmd); in async_iocdata()
4808 mutex_exit(&asy->asy_excl_hi); in async_iocdata()
4813 mp->b_datap->db_type = M_IOCNAK; in async_iocdata()
4814 ip->ioc_error = EINVAL; in async_iocdata()
4818 mutex_exit(&asy->asy_excl); in async_iocdata()
4879 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asymctl()
4880 ASSERT(mutex_owned(&asy->asy_excl)); in asymctl()
4909 msr_r = asy->asy_msr; in asymctl()
4998 * to non-sense. in asyerror()
5008 vdev_err(asy->asy_dip, level, fmt, adx); in asyerror()
5014 * The value of this property is in the form of "9600,8,n,1,-"
5019 * 5) handshake: -(none), h(hardware: rts/cts), s(software: xon/off)
5033 ASSERT(asy->asy_com_port != 0); in asy_parse_mode()
5036 * Parse the ttyx-mode property in asy_parse_mode()
5038 (void) sprintf(name, "tty%c-mode", asy->asy_com_port + 'a' - 1); in asy_parse_mode()
5042 (void) sprintf(name, "com%c-mode", asy->asy_com_port + '0'); in asy_parse_mode()
5048 asy->asy_cflag = 0; in asy_parse_mode()
5053 /* ---- baud rate ---- */ in asy_parse_mode()
5054 asy->asy_cflag = CREAD|B9600; /* initial default */ in asy_parse_mode()
5058 asy->asy_cflag |= ASY_LCR_BITS8; /* add default bits */ in asy_parse_mode()
5063 asy->asy_bidx = B110; in asy_parse_mode()
5065 asy->asy_bidx = B150; in asy_parse_mode()
5067 asy->asy_bidx = B300; in asy_parse_mode()
5069 asy->asy_bidx = B600; in asy_parse_mode()
5071 asy->asy_bidx = B1200; in asy_parse_mode()
5073 asy->asy_bidx = B2400; in asy_parse_mode()
5075 asy->asy_bidx = B4800; in asy_parse_mode()
5077 asy->asy_bidx = B9600; in asy_parse_mode()
5079 asy->asy_bidx = B19200; in asy_parse_mode()
5081 asy->asy_bidx = B38400; in asy_parse_mode()
5083 asy->asy_bidx = B57600; in asy_parse_mode()
5085 asy->asy_bidx = B115200; in asy_parse_mode()
5087 asy->asy_bidx = B9600; in asy_parse_mode()
5089 asy->asy_cflag &= ~CBAUD; in asy_parse_mode()
5090 if (asy->asy_bidx > CBAUD) { /* > 38400 uses the CBAUDEXT bit */ in asy_parse_mode()
5091 asy->asy_cflag |= CBAUDEXT; in asy_parse_mode()
5092 asy->asy_cflag |= asy->asy_bidx - CBAUD - 1; in asy_parse_mode()
5094 asy->asy_cflag |= asy->asy_bidx; in asy_parse_mode()
5097 ASSERT(asy->asy_bidx == BAUDINDEX(asy->asy_cflag)); in asy_parse_mode()
5099 /* ---- Next item is data bits ---- */ in asy_parse_mode()
5104 asy->asy_cflag |= ASY_LCR_BITS8; /* add default bits */ in asy_parse_mode()
5110 asy->asy_cflag |= CS8; in asy_parse_mode()
5111 asy->asy_lcr = ASY_LCR_BITS8; in asy_parse_mode()
5114 asy->asy_cflag |= CS7; in asy_parse_mode()
5115 asy->asy_lcr = ASY_LCR_BITS7; in asy_parse_mode()
5118 asy->asy_cflag |= CS6; in asy_parse_mode()
5119 asy->asy_lcr = ASY_LCR_BITS6; in asy_parse_mode()
5123 asy->asy_cflag |= CS5; in asy_parse_mode()
5124 asy->asy_lcr = ASY_LCR_BITS5; in asy_parse_mode()
5128 /* ---- Parity info ---- */ in asy_parse_mode()
5140 asy->asy_cflag |= PARENB; in asy_parse_mode()
5141 asy->asy_lcr |= ASY_LCR_PEN; in asy_parse_mode()
5144 asy->asy_cflag |= PARENB|PARODD; in asy_parse_mode()
5145 asy->asy_lcr |= ASY_LCR_PEN | ASY_LCR_EPS; in asy_parse_mode()
5149 /* ---- Find stop bits ---- */ in asy_parse_mode()
5157 asy->asy_cflag |= CSTOPB; in asy_parse_mode()
5158 asy->asy_lcr |= ASY_LCR_STB; in asy_parse_mode()
5161 /* ---- handshake is next ---- */ in asy_parse_mode()
5168 asy->asy_cflag |= CRTSCTS; in asy_parse_mode()
5170 asy->asy_cflag |= CRTSXOFF; in asy_parse_mode()
5221 struct asyncline *async = asy->asy_priv; in async_flowcontrol_sw_input()
5224 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_sw_input()
5226 if (!(async->async_ttycommon.t_iflag & IXOFF)) in async_flowcontrol_sw_input()
5234 async->async_inflow_source |= type; in async_flowcontrol_sw_input()
5243 if (async->async_inflow_source & (IN_FLOW_RINGBUFF | in async_flowcontrol_sw_input()
5245 async->async_flags |= ASYNC_SW_IN_FLOW | in async_flowcontrol_sw_input()
5248 async->async_inflow_source); in async_flowcontrol_sw_input()
5251 async->async_inflow_source &= ~type; in async_flowcontrol_sw_input()
5252 if (async->async_inflow_source == 0) { in async_flowcontrol_sw_input()
5253 async->async_flags = (async->async_flags & in async_flowcontrol_sw_input()
5262 if (((async->async_flags & (ASYNC_SW_IN_NEEDED | ASYNC_BREAK | in async_flowcontrol_sw_input()
5269 async->async_flags = (async->async_flags & in async_flowcontrol_sw_input()
5272 async->async_flags & ASYNC_SW_IN_FLOW ? in async_flowcontrol_sw_input()
5273 async->async_stopc : async->async_startc); in async_flowcontrol_sw_input()
5293 struct asyncline *async = asy->asy_priv; in async_flowcontrol_sw_output()
5295 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_sw_output()
5297 if (!(async->async_ttycommon.t_iflag & IXON)) in async_flowcontrol_sw_output()
5302 async->async_flags |= ASYNC_SW_OUT_FLW; in async_flowcontrol_sw_output()
5303 async->async_flags &= ~ASYNC_OUT_FLW_RESUME; in async_flowcontrol_sw_output()
5307 async->async_flags &= ~ASYNC_SW_OUT_FLW; in async_flowcontrol_sw_output()
5308 if (!(async->async_flags & ASYNC_HW_OUT_FLW)) in async_flowcontrol_sw_output()
5309 async->async_flags |= ASYNC_OUT_FLW_RESUME; in async_flowcontrol_sw_output()
5337 struct asyncline *async = asy->asy_priv; in async_flowcontrol_hw_input()
5339 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_hw_input()
5341 if (!(async->async_ttycommon.t_cflag & CRTSXOFF)) in async_flowcontrol_hw_input()
5346 async->async_inflow_source |= type; in async_flowcontrol_hw_input()
5347 if (async->async_inflow_source & (IN_FLOW_RINGBUFF | in async_flowcontrol_hw_input()
5349 async->async_flags |= ASYNC_HW_IN_FLOW; in async_flowcontrol_hw_input()
5351 async->async_inflow_source); in async_flowcontrol_hw_input()
5354 async->async_inflow_source &= ~type; in async_flowcontrol_hw_input()
5355 if (async->async_inflow_source == 0) { in async_flowcontrol_hw_input()
5356 async->async_flags &= ~ASYNC_HW_IN_FLOW; in async_flowcontrol_hw_input()
5364 flag = (async->async_flags & ASYNC_HW_IN_FLOW) ? 0 : ASY_MCR_RTS; in async_flowcontrol_hw_input()
5387 struct asyncline *async = asy->asy_priv; in async_flowcontrol_hw_output()
5389 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_hw_output()
5391 if (!(async->async_ttycommon.t_cflag & CRTSCTS)) in async_flowcontrol_hw_output()
5396 async->async_flags |= ASYNC_HW_OUT_FLW; in async_flowcontrol_hw_output()
5397 async->async_flags &= ~ASYNC_OUT_FLW_RESUME; in async_flowcontrol_hw_output()
5401 async->async_flags &= ~ASYNC_HW_OUT_FLW; in async_flowcontrol_hw_output()
5402 if (!(async->async_flags & ASYNC_SW_OUT_FLW)) in async_flowcontrol_hw_output()
5403 async->async_flags |= ASYNC_OUT_FLW_RESUME; in async_flowcontrol_hw_output()
5414 * This function is called when the system is single-threaded at high
5436 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asyquiesce()