Lines Matching refs:qcn_state

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