Lines Matching refs:qcn_state
87 static qcn_t *qcn_state; variable
200 qcn_state = kmem_zalloc(sizeof (qcn_t), KM_SLEEP); in _init()
201 qcn_state->qcn_ring = contig_mem_alloc(RINGSIZE); in _init()
202 if (qcn_state->qcn_ring == NULL) in _init()
207 contig_mem_free(qcn_state->qcn_ring, RINGSIZE); in _init()
208 kmem_free(qcn_state, sizeof (qcn_t)); in _init()
218 qcn_state->cons_write_buffer = in _init()
220 if (qcn_state->cons_write_buffer != NULL) { in _init()
221 qcn_state->cons_write_buf_ra = in _init()
222 va_to_pa(qcn_state->cons_write_buffer); in _init()
223 qcn_state->cons_transmit = qcn_transmit_write; in _init()
224 qcn_state->cons_receive = qcn_receive_read; in _init()
225 qcn_state->cons_read_buf_ra = in _init()
226 va_to_pa((char *)RING_ADDR(qcn_state)); in _init()
229 if (qcn_state->cons_transmit == NULL) { in _init()
230 qcn_state->cons_transmit = qcn_transmit_putchr; in _init()
231 qcn_state->cons_receive = qcn_receive_getchr; in _init()
252 dev_info_t *devinfo = qcn_state->qcn_dip; in qcn_add_intrs()
264 qcn_state->qcn_intr_size = count * sizeof (ddi_intr_handle_t); in qcn_add_intrs()
265 qcn_state->qcn_htable = kmem_zalloc(qcn_state->qcn_intr_size, KM_SLEEP); in qcn_add_intrs()
268 rc = ddi_intr_alloc(devinfo, qcn_state->qcn_htable, in qcn_add_intrs()
273 kmem_free(qcn_state->qcn_htable, qcn_state->qcn_intr_size); in qcn_add_intrs()
279 (void) ddi_intr_free(qcn_state->qcn_htable[x]); in qcn_add_intrs()
282 kmem_free(qcn_state->qcn_htable, qcn_state->qcn_intr_size); in qcn_add_intrs()
286 qcn_state->qcn_intr_cnt = actual; in qcn_add_intrs()
289 if (ddi_intr_get_pri(qcn_state->qcn_htable[0], in qcn_add_intrs()
290 &qcn_state->qcn_intr_pri) != DDI_SUCCESS) { in qcn_add_intrs()
292 (void) ddi_intr_free(qcn_state->qcn_htable[x]); in qcn_add_intrs()
295 kmem_free(qcn_state->qcn_htable, qcn_state->qcn_intr_size); in qcn_add_intrs()
301 if (ddi_intr_add_handler(qcn_state->qcn_htable[x], in qcn_add_intrs()
303 (caddr_t)qcn_state, NULL) != DDI_SUCCESS) { in qcn_add_intrs()
307 qcn_state->qcn_htable[y]); in qcn_add_intrs()
311 (void) ddi_intr_free(qcn_state->qcn_htable[y]); in qcn_add_intrs()
314 kmem_free(qcn_state->qcn_htable, in qcn_add_intrs()
315 qcn_state->qcn_intr_size); in qcn_add_intrs()
327 for (x = 0; x < qcn_state->qcn_intr_cnt; x++) { in qcn_remove_intrs()
328 (void) ddi_intr_disable(qcn_state->qcn_htable[x]); in qcn_remove_intrs()
329 (void) ddi_intr_remove_handler(qcn_state->qcn_htable[x]); in qcn_remove_intrs()
330 (void) ddi_intr_free(qcn_state->qcn_htable[x]); in qcn_remove_intrs()
332 kmem_free(qcn_state->qcn_htable, qcn_state->qcn_intr_size); in qcn_remove_intrs()
340 for (x = 0; x < qcn_state->qcn_intr_cnt; x++) { in qcn_intr_enable()
341 (void) ddi_intr_enable(qcn_state->qcn_htable[x]); in qcn_intr_enable()
366 qcn_state->qcn_soft_pend = 0; in qcn_attach()
367 qcn_state->qcn_hangup = 0; in qcn_attach()
368 qcn_state->qcn_rbuf_overflow = 0; in qcn_attach()
372 qcn_state->qcn_dip = dip; in qcn_attach()
374 qcn_state->qcn_polling = 0; in qcn_attach()
381 binding_name = ddi_binding_name(qcn_state->qcn_dip); in qcn_attach()
384 qcn_state->qcn_polling = 1; in qcn_attach()
386 if (qcn_state->qcn_polling) { in qcn_attach()
397 if (!qcn_state->qcn_polling) { in qcn_attach()
402 if (ddi_intr_add_softint(dip, &qcn_state->qcn_softint_hdl, in qcn_attach()
404 (caddr_t)qcn_state) != DDI_SUCCESS) { in qcn_attach()
409 if (ddi_intr_get_softint_pri(qcn_state->qcn_softint_hdl, in qcn_attach()
413 qcn_state->qcn_softint_hdl); in qcn_attach()
418 mutex_init(&qcn_state->qcn_hi_lock, NULL, MUTEX_DRIVER, in qcn_attach()
419 (void *)(uintptr_t)(qcn_state->qcn_intr_pri)); in qcn_attach()
422 mutex_init(&qcn_state->qcn_lock, NULL, MUTEX_DRIVER, NULL); in qcn_attach()
427 qcn_state->qcn_polledio.cons_polledio_version = CONSPOLLEDIO_V1; in qcn_attach()
428 qcn_state->qcn_polledio.cons_polledio_argument = in qcn_attach()
429 (cons_polledio_arg_t)qcn_state; in qcn_attach()
430 qcn_state->qcn_polledio.cons_polledio_putchar = qcn_polledio_putchar; in qcn_attach()
431 qcn_state->qcn_polledio.cons_polledio_getchar = qcn_polledio_getchar; in qcn_attach()
432 qcn_state->qcn_polledio.cons_polledio_ischar = qcn_polledio_ischar; in qcn_attach()
433 qcn_state->qcn_polledio.cons_polledio_enter = qcn_polledio_enter; in qcn_attach()
434 qcn_state->qcn_polledio.cons_polledio_exit = qcn_polledio_exit; in qcn_attach()
439 if (!qcn_state->qcn_polling) { in qcn_attach()
464 if (qcn_state->qcn_polling) { in qcn_detach()
473 if (!qcn_state->qcn_polling) in qcn_detach()
487 if (qcn_state) { in qcn_getinfo()
491 *result = (void *)qcn_state->qcn_dip; in qcn_getinfo()
529 if (!qcn_state) { in qcn_open()
535 mutex_enter(&qcn_state->qcn_lock); in qcn_open()
536 tty = &(qcn_state->qcn_tty); in qcn_open()
542 q->q_ptr = WR(q)->q_ptr = (caddr_t)qcn_state; in qcn_open()
543 qcn_state->qcn_readq = RD(q); in qcn_open()
544 qcn_state->qcn_writeq = WR(q); in qcn_open()
547 mutex_exit(&qcn_state->qcn_lock); in qcn_open()
561 ASSERT(qcn_state == q->q_ptr); in qcn_close()
563 if (qcn_state->qcn_wbufcid != 0) { in qcn_close()
564 unbufcall(qcn_state->qcn_wbufcid); in qcn_close()
566 ttycommon_close(&qcn_state->qcn_tty); in qcn_close()
570 qcn_state->qcn_readq = NULL; in qcn_close()
571 qcn_state->qcn_writeq = NULL; in qcn_close()
590 ASSERT(qcn_state == q->q_ptr); in qcn_wput()
601 mutex_enter(&qcn_state->qcn_lock); in qcn_wput()
629 mutex_exit(&qcn_state->qcn_lock); in qcn_wput()
631 mutex_enter(&qcn_state->qcn_lock); in qcn_wput()
683 mutex_exit(&qcn_state->qcn_lock); in qcn_wput()
706 tty = &(qcn_state->qcn_tty); in qcn_ioctl()
725 &qcn_state->qcn_polledio; in qcn_ioctl()
739 if (qcn_state->qcn_wbufcid) in qcn_ioctl()
740 unbufcall(qcn_state->qcn_wbufcid); in qcn_ioctl()
742 qcn_state->qcn_wbufcid = in qcn_ioctl()
743 bufcall(data_size, BPRI_HI, qcn_reioctl, qcn_state); in qcn_ioctl()
748 mutex_enter(&qcn_state->qcn_lock); in qcn_ioctl()
794 mutex_exit(&qcn_state->qcn_lock); in qcn_ioctl()
845 ASSERT(MUTEX_HELD(&qcn_state->qcn_lock)); in qcn_start()
851 q = qcn_state->qcn_writeq; in qcn_start()
859 mutex_exit(&qcn_state->qcn_lock); in qcn_start()
861 mutex_enter(&qcn_state->qcn_lock); in qcn_start()
867 rv = qcn_state->cons_transmit(q, mp); in qcn_start()
893 bcopy(bp->b_rptr, qcn_state->cons_write_buffer, i); in qcn_transmit_write()
894 retval = hv_cnwrite(qcn_state->cons_write_buf_ra, i, &i); in qcn_transmit_write()
969 ASSERT(MUTEX_HELD(&qcn_state->qcn_lock)); in qcn_flush()
971 q = qcn_state->qcn_writeq; in qcn_flush()
986 if (atomic_swap_uint(&qcn_state->qcn_soft_pend, QCN_SP_DO) == in qcn_trigger_softint()
989 qcn_state->qcn_softint_hdl, NULL); in qcn_trigger_softint()
1002 (void) atomic_swap_uint(&qcn_state->qcn_soft_pend, QCN_SP_IP); in qcn_soft_intr()
1003 mutex_enter(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1004 cc = RING_CNT(qcn_state); in qcn_soft_intr()
1005 mutex_exit(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1011 mutex_enter(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1013 mutex_exit(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1019 mutex_enter(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1022 *(char *)mp->b_wptr++ = RING_GET(qcn_state); in qcn_soft_intr()
1025 if ((overflow_check = qcn_state->qcn_rbuf_overflow) != 0) { in qcn_soft_intr()
1026 qcn_state->qcn_rbuf_overflow = 0; in qcn_soft_intr()
1028 mutex_exit(&qcn_state->qcn_hi_lock); in qcn_soft_intr()
1034 if (qcn_state->qcn_readq) { in qcn_soft_intr()
1035 putnext(qcn_state->qcn_readq, mp); in qcn_soft_intr()
1043 if (qcn_state->qcn_writeq != NULL) { in qcn_soft_intr()
1044 if (qcn_state->qcn_hangup) { in qcn_soft_intr()
1045 (void) putctl(qcn_state->qcn_readq, M_HANGUP); in qcn_soft_intr()
1046 flushq(qcn_state->qcn_writeq, FLUSHDATA); in qcn_soft_intr()
1047 qcn_state->qcn_hangup = 0; in qcn_soft_intr()
1049 mutex_enter(&qcn_state->qcn_lock); in qcn_soft_intr()
1051 mutex_exit(&qcn_state->qcn_lock); in qcn_soft_intr()
1058 } while (atomic_swap_uint(&qcn_state->qcn_soft_pend, QCN_SP_IDL) == in qcn_soft_intr()
1067 mutex_enter(&qcn_state->qcn_hi_lock); in qcn_hi_intr()
1069 qcn_state->cons_receive(); in qcn_hi_intr()
1071 mutex_exit(&qcn_state->qcn_hi_lock); in qcn_hi_intr()
1089 if (RING_CNT(qcn_state) <= 0) { in qcn_receive_read()
1090 RING_INIT(qcn_state); in qcn_receive_read()
1092 rv = hv_cnread(qcn_state->cons_read_buf_ra + in qcn_receive_read()
1093 RING_POFF(qcn_state), in qcn_receive_read()
1094 RING_LEFT(qcn_state), in qcn_receive_read()
1096 bufp = RING_ADDR(qcn_state); in qcn_receive_read()
1119 RING_UPD(qcn_state, retcount); in qcn_receive_read()
1141 qcn_state->qcn_hangup = 1; in qcn_receive_read()
1167 if (RING_POK(qcn_state, 1)) { in qcn_receive_getchr()
1168 RING_PUT(qcn_state, buf); in qcn_receive_getchr()
1170 qcn_state->qcn_rbuf_overflow++; in qcn_receive_getchr()
1179 qcn_state->qcn_hangup = 1; in qcn_receive_getchr()
1205 if (qcn_state->qcn_readq) { in qcn_poll_handler()
1206 (void) putctl(qcn_state->qcn_readq, M_HANGUP); in qcn_poll_handler()
1222 if (qcn_state->qcn_readq) { in qcn_poll_handler()
1230 putnext(qcn_state->qcn_readq, mp); in qcn_poll_handler()
1239 mutex_enter(&qcn_state->qcn_lock); in qcn_poll_handler()
1240 if (qcn_state->qcn_writeq != NULL) { in qcn_poll_handler()
1242 flushq(qcn_state->qcn_writeq, FLUSHDATA); in qcn_poll_handler()
1247 mutex_exit(&qcn_state->qcn_lock); in qcn_poll_handler()
1282 mutex_enter(&qcn_state->qcn_lock); in qcn_rsrv()
1291 mutex_exit(&qcn_state->qcn_lock); in qcn_rsrv()
1303 mutex_enter(&qcn_state->qcn_lock); in qcn_wsrv()
1305 if (qcn_state->qcn_writeq != NULL) in qcn_wsrv()
1308 mutex_exit(&qcn_state->qcn_lock); in qcn_wsrv()