Lines Matching refs:state
261 struct mouse_state *state; in mouse8042_attach() local
273 state = (struct mouse_state *)ddi_get_driver_private(dip); in mouse8042_attach()
276 state->ready = 1; in mouse8042_attach()
282 if (state->ms_rqp != NULL) { in mouse8042_attach()
285 putnext(state->ms_rqp, mp); in mouse8042_attach()
289 putnext(state->ms_rqp, mp); in mouse8042_attach()
302 state = kmem_zalloc(sizeof (struct mouse_state), KM_SLEEP); in mouse8042_attach()
303 state->ms_opened = B_FALSE; in mouse8042_attach()
304 state->reset_state = MSE_RESET_IDLE; in mouse8042_attach()
305 state->reset_tid = 0; in mouse8042_attach()
306 state->bc_id = 0; in mouse8042_attach()
307 ddi_set_driver_private(dip, state); in mouse8042_attach()
336 rc = ddi_regs_map_setup(dip, 0, (caddr_t *)&state->ms_addr, in mouse8042_attach()
337 (offset_t)0, (offset_t)0, &attr, &state->ms_handle); in mouse8042_attach()
342 rc = ddi_get_iblock_cookie(dip, 0, &state->ms_iblock_cookie); in mouse8042_attach()
347 mutex_init(&state->ms_mutex, NULL, MUTEX_DRIVER, in mouse8042_attach()
348 state->ms_iblock_cookie); in mouse8042_attach()
349 mutex_init(&state->reset_mutex, NULL, MUTEX_DRIVER, in mouse8042_attach()
350 state->ms_iblock_cookie); in mouse8042_attach()
351 cv_init(&state->reset_cv, NULL, CV_DRIVER, NULL); in mouse8042_attach()
355 mouse8042_intr, (caddr_t)state); in mouse8042_attach()
363 state->ready = 1; in mouse8042_attach()
370 ddi_regs_map_free(&state->ms_handle); in mouse8042_attach()
376 kmem_free(state, sizeof (struct mouse_state)); in mouse8042_attach()
384 struct mouse_state *state; in mouse8042_detach() local
386 state = ddi_get_driver_private(dip); in mouse8042_detach()
391 state->ready = 0; in mouse8042_detach()
395 ddi_remove_intr(dip, 0, state->ms_iblock_cookie); in mouse8042_detach()
397 cv_destroy(&state->reset_cv); in mouse8042_detach()
398 mutex_destroy(&state->reset_mutex); in mouse8042_detach()
399 mutex_destroy(&state->ms_mutex); in mouse8042_detach()
401 ddi_regs_map_free(&state->ms_handle); in mouse8042_detach()
403 kmem_free(state, sizeof (struct mouse_state)); in mouse8042_detach()
449 struct mouse_state *state; in mouse8042_open() local
456 state = ddi_get_driver_private(mouse8042_dip); in mouse8042_open()
458 mutex_enter(&state->ms_mutex); in mouse8042_open()
460 if (state->ms_opened) { in mouse8042_open()
464 if (state->ms_minor == minor) { in mouse8042_open()
465 mutex_exit(&state->ms_mutex); in mouse8042_open()
480 mutex_exit(&state->ms_mutex); in mouse8042_open()
502 mutex_exit(&state->ms_mutex); in mouse8042_open()
512 mutex_enter(&state->ms_mutex); in mouse8042_open()
516 q->q_ptr = (caddr_t)state; in mouse8042_open()
517 WR(q)->q_ptr = (caddr_t)state; in mouse8042_open()
518 state->ms_rqp = q; in mouse8042_open()
519 state->ms_wqp = WR(q); in mouse8042_open()
523 state->ms_minor = minor; in mouse8042_open()
524 state->ms_opened = B_TRUE; in mouse8042_open()
526 mutex_exit(&state->ms_mutex); in mouse8042_open()
536 struct mouse_state *state; in mouse8042_close() local
539 state = (struct mouse_state *)q->q_ptr; in mouse8042_close()
547 mutex_enter(&state->reset_mutex); in mouse8042_close()
548 while (state->reset_state != MSE_RESET_IDLE) { in mouse8042_close()
556 cv_wait(&state->reset_cv, &state->reset_mutex); in mouse8042_close()
559 if (state->reset_tid != 0) { in mouse8042_close()
560 (void) quntimeout(q, state->reset_tid); in mouse8042_close()
561 state->reset_tid = 0; in mouse8042_close()
564 if (state->reply_mp != NULL) { in mouse8042_close()
565 freemsg(state->reply_mp); in mouse8042_close()
566 state->reply_mp = NULL; in mouse8042_close()
569 if (state->reset_ack_mp != NULL) { in mouse8042_close()
570 freemsg(state->reset_ack_mp); in mouse8042_close()
571 state->reset_ack_mp = NULL; in mouse8042_close()
574 mutex_exit(&state->reset_mutex); in mouse8042_close()
576 mutex_enter(&state->ms_mutex); in mouse8042_close()
578 if (state->bc_id != 0) { in mouse8042_close()
579 (void) qunbufcall(q, state->bc_id); in mouse8042_close()
580 state->bc_id = 0; in mouse8042_close()
585 state->ms_rqp = NULL; in mouse8042_close()
586 state->ms_wqp = NULL; in mouse8042_close()
588 state->ms_opened = B_FALSE; in mouse8042_close()
590 minor = state->ms_minor; in mouse8042_close()
592 mutex_exit(&state->ms_mutex); in mouse8042_close()
632 struct mouse_state *state = (struct mouse_state *)argp; in mouse8042_reset_timeout() local
635 mutex_enter(&state->reset_mutex); in mouse8042_reset_timeout()
643 if (state->reset_state != MSE_RESET_IDLE && in mouse8042_reset_timeout()
644 state->reset_state != MSE_RESET_FAILED) { in mouse8042_reset_timeout()
646 state->reset_tid = 0; in mouse8042_reset_timeout()
647 state->reset_state = MSE_RESET_IDLE; in mouse8042_reset_timeout()
648 cv_signal(&state->reset_cv); in mouse8042_reset_timeout()
650 (void) ddi_get8(state->ms_handle, state->ms_addr + in mouse8042_reset_timeout()
653 mp = state->reply_mp; in mouse8042_reset_timeout()
655 state->reply_mp = NULL; in mouse8042_reset_timeout()
657 if (state->ms_rqp != NULL) in mouse8042_reset_timeout()
658 putnext(state->ms_rqp, mp); in mouse8042_reset_timeout()
662 ASSERT(state->ms_wqp != NULL); in mouse8042_reset_timeout()
664 enableok(state->ms_wqp); in mouse8042_reset_timeout()
665 qenable(state->ms_wqp); in mouse8042_reset_timeout()
668 mutex_exit(&state->reset_mutex); in mouse8042_reset_timeout()
675 mouse8042_initiate_reset(queue_t *q, mblk_t *mp, struct mouse_state *state) in mouse8042_initiate_reset() argument
677 mutex_enter(&state->reset_mutex); in mouse8042_initiate_reset()
682 if (state->reset_state != MSE_RESET_IDLE) { in mouse8042_initiate_reset()
689 mutex_exit(&state->reset_mutex); in mouse8042_initiate_reset()
698 mutex_exit(&state->reset_mutex); in mouse8042_initiate_reset()
700 if (state->reply_mp == NULL) in mouse8042_initiate_reset()
701 state->reply_mp = allocb(2, BPRI_MED); in mouse8042_initiate_reset()
702 if (state->reset_ack_mp == NULL) in mouse8042_initiate_reset()
703 state->reset_ack_mp = allocb(1, BPRI_MED); in mouse8042_initiate_reset()
705 if (state->reply_mp == NULL || state->reset_ack_mp == NULL) { in mouse8042_initiate_reset()
711 state->bc_id = qbufcall(q, (state->reply_mp == NULL) ? 2 : 1, in mouse8042_initiate_reset()
714 if (state->bc_id == 0) { in mouse8042_initiate_reset()
728 state->bc_id = 0; in mouse8042_initiate_reset()
736 (void) ddi_get8(state->ms_handle, in mouse8042_initiate_reset()
737 state->ms_addr + I8042_LOCK); in mouse8042_initiate_reset()
739 mutex_enter(&state->reset_mutex); in mouse8042_initiate_reset()
741 state->reset_state = MSE_RESET_PRE; in mouse8042_initiate_reset()
744 state->reset_tid = qtimeout(q, in mouse8042_initiate_reset()
746 state, in mouse8042_initiate_reset()
750 ddi_put8(state->ms_handle, in mouse8042_initiate_reset()
751 state->ms_addr + in mouse8042_initiate_reset()
756 mutex_exit(&state->reset_mutex); in mouse8042_initiate_reset()
764 mouse8042_process_data_msg(queue_t *q, mblk_t *mp, struct mouse_state *state) in mouse8042_process_data_msg() argument
787 if (mouse8042_initiate_reset(q, bp, state) == 0) in mouse8042_process_data_msg()
810 ddi_put8(state->ms_handle, in mouse8042_process_data_msg()
811 state->ms_addr + I8042_INT_OUTPUT_DATA, in mouse8042_process_data_msg()
822 mouse8042_process_msg(queue_t *q, mblk_t *mp, struct mouse_state *state) in mouse8042_process_msg() argument
847 rv = mouse8042_process_data_msg(q, mp, state); in mouse8042_process_msg()
866 struct mouse_state *state; in mouse8042_wput() local
867 state = (struct mouse_state *)q->q_ptr; in mouse8042_wput()
874 if (state->reset_state != MSE_RESET_IDLE) in mouse8042_wput()
886 (void) mouse8042_process_msg(q, mp, state); in mouse8042_wput()
895 struct mouse_state *state; in mouse8042_wsrv() local
896 state = (struct mouse_state *)qp->q_ptr; in mouse8042_wsrv()
899 if (mouse8042_process_msg(qp, mp, state) != 0) in mouse8042_wsrv()
939 struct mouse_state *state = (struct mouse_state *)arg; in mouse8042_intr() local
942 mutex_enter(&state->ms_mutex); in mouse8042_intr()
948 if (ddi_get8(state->ms_handle, in mouse8042_intr()
949 state->ms_addr + I8042_INT_INPUT_AVAIL) == 0) { in mouse8042_intr()
953 mdata = ddi_get8(state->ms_handle, in mouse8042_intr()
954 state->ms_addr + I8042_INT_INPUT_DATA); in mouse8042_intr()
961 if (!state->ready) in mouse8042_intr()
964 mutex_enter(&state->reset_mutex); in mouse8042_intr()
965 if (state->reset_state != MSE_RESET_IDLE) { in mouse8042_intr()
968 state->reset_state = MSE_RESET_FAILED; in mouse8042_intr()
970 state->reset_state = in mouse8042_intr()
971 mouse8042_reset_fsm(state->reset_state, in mouse8042_intr()
975 if (state->reset_state == MSE_RESET_ACK) { in mouse8042_intr()
983 if (state->reset_ack_mp != NULL) { in mouse8042_intr()
985 mp = state->reset_ack_mp; in mouse8042_intr()
987 state->reset_ack_mp = NULL; in mouse8042_intr()
989 if (state->ms_rqp != NULL) { in mouse8042_intr()
991 putnext(state->ms_rqp, mp); in mouse8042_intr()
996 if (state->ms_wqp != NULL) { in mouse8042_intr()
997 enableok(state->ms_wqp); in mouse8042_intr()
998 qenable(state->ms_wqp); in mouse8042_intr()
1001 } else if (state->reset_state == MSE_RESET_IDLE || in mouse8042_intr()
1002 state->reset_state == MSE_RESET_FAILED) { in mouse8042_intr()
1017 mutex_exit(&state->reset_mutex); in mouse8042_intr()
1018 (void) quntimeout(state->ms_wqp, in mouse8042_intr()
1019 state->reset_tid); in mouse8042_intr()
1020 mutex_enter(&state->reset_mutex); in mouse8042_intr()
1022 (void) ddi_get8(state->ms_handle, in mouse8042_intr()
1023 state->ms_addr + I8042_UNLOCK); in mouse8042_intr()
1025 state->reset_tid = 0; in mouse8042_intr()
1026 if (state->reply_mp != NULL) { in mouse8042_intr()
1027 mp = state->reply_mp; in mouse8042_intr()
1028 if (state->reset_state == in mouse8042_intr()
1035 state->reply_mp = NULL; in mouse8042_intr()
1040 state->reset_state = MSE_RESET_IDLE; in mouse8042_intr()
1041 cv_signal(&state->reset_cv); in mouse8042_intr()
1044 if (state->ms_rqp != NULL) in mouse8042_intr()
1045 putnext(state->ms_rqp, mp); in mouse8042_intr()
1050 if (state->ms_wqp != NULL) { in mouse8042_intr()
1051 enableok(state->ms_wqp); in mouse8042_intr()
1052 qenable(state->ms_wqp); in mouse8042_intr()
1056 mutex_exit(&state->reset_mutex); in mouse8042_intr()
1057 mutex_exit(&state->ms_mutex); in mouse8042_intr()
1060 mutex_exit(&state->reset_mutex); in mouse8042_intr()
1062 if (state->ms_rqp != NULL && (mp = allocb(1, BPRI_MED))) { in mouse8042_intr()
1064 putnext(state->ms_rqp, mp); in mouse8042_intr()
1067 mutex_exit(&state->ms_mutex); in mouse8042_intr()