Lines Matching refs:global
403 static void i8042_send(struct i8042 *global, int reg, unsigned char cmd);
409 i8042_discard_junk_data(struct i8042 *global) in i8042_discard_junk_data() argument
415 stat = ddi_get8(global->io_handle, in i8042_discard_junk_data()
416 global->io_addr + I8042_STAT); in i8042_discard_junk_data()
419 (void) ddi_get8(global->io_handle, in i8042_discard_junk_data()
420 global->io_addr + I8042_DATA); in i8042_discard_junk_data()
426 i8042_cleanup(struct i8042 *global) in i8042_cleanup() argument
431 ASSERT(global != NULL); in i8042_cleanup()
433 if (global->initialized == B_TRUE) { in i8042_cleanup()
438 mutex_enter(&global->i8042_mutex); in i8042_cleanup()
441 port = &global->i8042_ports[which_port]; in i8042_cleanup()
444 mutex_exit(&global->i8042_mutex); in i8042_cleanup()
449 mutex_exit(&global->i8042_mutex); in i8042_cleanup()
456 mutex_exit(&global->i8042_mutex); in i8042_cleanup()
462 global->initialized = B_FALSE; in i8042_cleanup()
464 mutex_exit(&global->i8042_mutex); in i8042_cleanup()
469 if (global->timeout_id != 0) { in i8042_cleanup()
470 (void) untimeout(global->timeout_id); in i8042_cleanup()
475 if (global->init_state & I8042_INIT_INTRS_ENABLED) in i8042_cleanup()
476 i8042_write_command_byte(global, I8042_CMD_DISABLE_ALL); in i8042_cleanup()
478 if (global->intrs_added) { in i8042_cleanup()
483 for (i = global->nintrs - 1; i >= 0; i--) { in i8042_cleanup()
484 if (global->intrs_added & (1 << i)) in i8042_cleanup()
485 ddi_remove_intr(global->dip, i, in i8042_cleanup()
486 global->iblock_cookies[i]); in i8042_cleanup()
491 if (global->init_state & I8042_INIT_MUTEXES) { in i8042_cleanup()
494 port = &global->i8042_ports[which_port]; in i8042_cleanup()
498 cv_destroy(&global->glock_cv); in i8042_cleanup()
499 mutex_destroy(&global->i8042_out_mutex); in i8042_cleanup()
500 mutex_destroy(&global->i8042_mutex); in i8042_cleanup()
503 if (global->init_state & I8042_INIT_REGS_MAPPED) in i8042_cleanup()
504 ddi_regs_map_free(&global->io_handle); in i8042_cleanup()
506 if (global->init_state & I8042_INIT_BASIC) { in i8042_cleanup()
507 ddi_set_driver_private(global->dip, (caddr_t)NULL); in i8042_cleanup()
508 if (global->nintrs > 0) { in i8042_cleanup()
509 kmem_free(global->iblock_cookies, global->nintrs * in i8042_cleanup()
512 kmem_free(global, sizeof (struct i8042)); in i8042_cleanup()
527 i8042_wait_obf(struct i8042 *global) in i8042_wait_obf() argument
531 while (!(ddi_get8(global->io_handle, global->io_addr + I8042_STAT) & in i8042_wait_obf()
546 i8042_purge_outbuf(struct i8042 *global) in i8042_purge_outbuf() argument
551 if (i8042_wait_obf(global)) in i8042_purge_outbuf()
553 (void) ddi_get8(global->io_handle, in i8042_purge_outbuf()
554 global->io_addr + I8042_DATA); in i8042_purge_outbuf()
579 struct i8042 *global; in i8042_attach() local
586 global = (struct i8042 *)ddi_get_driver_private(dip); in i8042_attach()
587 i8042_discard_junk_data(global); in i8042_attach()
588 i8042_write_command_byte(global, I8042_CMD_ENABLE_ALL); in i8042_attach()
603 global = (struct i8042 *)kmem_zalloc(sizeof (struct i8042), KM_SLEEP); in i8042_attach()
604 ddi_set_driver_private(dip, (caddr_t)global); in i8042_attach()
605 global->dip = dip; in i8042_attach()
606 global->initialized = B_FALSE; in i8042_attach()
608 global->init_state |= I8042_INIT_BASIC; in i8042_attach()
610 if (ddi_regs_map_setup(dip, 0, (caddr_t *)&global->io_addr, in i8042_attach()
611 (offset_t)0, (offset_t)0, &attr, &global->io_handle) in i8042_attach()
615 global->init_state |= I8042_INIT_REGS_MAPPED; in i8042_attach()
620 if (ddi_dev_nintrs(dip, &global->nintrs) == DDI_FAILURE) in i8042_attach()
632 global->nintrs = 0; in i8042_attach()
633 } else if (global->nintrs == 0) { in i8042_attach()
645 ddi_dev_nintrs(dip, &global->nintrs) == DDI_FAILURE || in i8042_attach()
646 global->nintrs == 0) { in i8042_attach()
648 ddi_get_instance(global->dip)); in i8042_attach()
653 if (global->nintrs == 0) { in i8042_attach()
655 ddi_get_instance(global->dip)); in i8042_attach()
660 if (global->nintrs > MAX_INTERRUPTS) in i8042_attach()
661 global->nintrs = MAX_INTERRUPTS; in i8042_attach()
663 if (global->nintrs > 0) { in i8042_attach()
664 global->iblock_cookies = kmem_zalloc(global->nintrs * in i8042_attach()
667 for (i = 0; i < global->nintrs; i++) { in i8042_attach()
669 &global->iblock_cookies[i]) != DDI_SUCCESS) in i8042_attach()
673 global->iblock_cookies = NULL; in i8042_attach()
675 mutex_init(&global->i8042_mutex, NULL, MUTEX_DRIVER, in i8042_attach()
676 (global->nintrs > 0) ? global->iblock_cookies[0] : NULL); in i8042_attach()
678 mutex_init(&global->i8042_out_mutex, NULL, MUTEX_DRIVER, NULL); in i8042_attach()
680 cv_init(&global->glock_cv, NULL, CV_DRIVER, NULL); in i8042_attach()
683 port = &global->i8042_ports[which_port]; in i8042_attach()
685 port->i8042_global = global; in i8042_attach()
697 if (global->nintrs > 0) { in i8042_attach()
698 cookie = global->iblock_cookies[ in i8042_attach()
699 (which_port < global->nintrs) ? which_port : 0]; in i8042_attach()
711 global->init_state |= I8042_INIT_MUTEXES; in i8042_attach()
727 i8042_write_command_byte(global, I8042_CMD_DISABLE_ALL); in i8042_attach()
729 global->init_state &= ~I8042_INIT_INTRS_ENABLED; in i8042_attach()
732 if (i8042_purge_outbuf(global) != 0) in i8042_attach()
741 ASSERT(global->nintrs <= (sizeof (global->intrs_added) * NBBY)); in i8042_attach()
743 for (i = 0; i < global->nintrs; i++) { in i8042_attach()
751 i8042_intr, (caddr_t)global) != DDI_SUCCESS) in i8042_attach()
754 global->intrs_added |= (1 << i); in i8042_attach()
757 global->initialized = B_TRUE; in i8042_attach()
762 i8042_write_command_byte(global, I8042_CMD_ENABLE_ALL); in i8042_attach()
763 global->init_state |= I8042_INIT_INTRS_ENABLED; in i8042_attach()
778 global->timeout_id = timeout(i8042_timeout, global, in i8042_attach()
787 (void) i8042_cleanup(global); in i8042_attach()
795 struct i8042 *global = (struct i8042 *)ddi_get_driver_private(dip); in i8042_detach() local
797 ASSERT(global != NULL); in i8042_detach()
808 i8042_write_command_byte(global, I8042_CMD_DISABLE_ALL); in i8042_detach()
814 return (i8042_cleanup(global)); in i8042_detach()
836 struct i8042 *global; in i8042_map() local
844 global = ddi_get_driver_private(dip); in i8042_map()
910 port = &global->i8042_ports[which_port]; in i8042_map()
1009 struct i8042 *global = (struct i8042 *)arg; in i8042_intr() local
1016 mutex_enter(&global->i8042_mutex); in i8042_intr()
1018 stat = ddi_get8(global->io_handle, global->io_addr + I8042_STAT); in i8042_intr()
1022 mutex_exit(&global->i8042_mutex); in i8042_intr()
1026 byte = ddi_get8(global->io_handle, global->io_addr + I8042_DATA); in i8042_intr()
1030 port = &global->i8042_ports[which_port]; in i8042_intr()
1033 mutex_exit(&global->i8042_mutex); in i8042_intr()
1047 mutex_exit(&global->i8042_mutex); in i8042_intr()
1060 mutex_exit(&global->i8042_mutex); in i8042_intr()
1073 i8042_write_command_byte(struct i8042 *global, unsigned char cb) in i8042_write_command_byte() argument
1075 mutex_enter(&global->i8042_out_mutex); in i8042_write_command_byte()
1076 i8042_send(global, I8042_CMD, I8042_CMD_WCB); in i8042_write_command_byte()
1077 i8042_send(global, I8042_DATA, cb); in i8042_write_command_byte()
1078 mutex_exit(&global->i8042_out_mutex); in i8042_write_command_byte()
1086 i8042_send(struct i8042 *global, int reg, unsigned char val) in i8042_send() argument
1096 stat = ddi_get8(global->io_handle, in i8042_send()
1097 global->io_addr + I8042_STAT); in i8042_send()
1100 ddi_put8(global->io_handle, global->io_addr+reg, val); in i8042_send()
1145 struct i8042 *global; in i8042_get8() local
1153 global = port->i8042_global; in i8042_get8()
1158 mutex_enter(&global->i8042_out_mutex); in i8042_get8()
1163 while (global->glock) { in i8042_get8()
1164 cv_wait(&global->glock_cv, &global->i8042_out_mutex); in i8042_get8()
1167 global->glock = 1; in i8042_get8()
1168 mutex_exit(&global->i8042_out_mutex); in i8042_get8()
1173 mutex_enter(&global->i8042_out_mutex); in i8042_get8()
1174 ASSERT(global->glock != 0); in i8042_get8()
1177 global->glock = 0; in i8042_get8()
1182 cv_signal(&global->glock_cv); in i8042_get8()
1183 mutex_exit(&global->i8042_out_mutex); in i8042_get8()
1188 mutex_enter(&global->i8042_mutex); in i8042_get8()
1190 mutex_exit(&global->i8042_mutex); in i8042_get8()
1194 mutex_enter(&global->i8042_mutex); in i8042_get8()
1208 mutex_exit(&global->i8042_mutex); in i8042_get8()
1225 stat = ddi_get8(global->io_handle, in i8042_get8()
1226 global->io_addr + I8042_STAT); in i8042_get8()
1245 (void) ddi_get8(global->io_handle, in i8042_get8()
1246 global->io_addr + I8042_DATA); in i8042_get8()
1258 stat = ddi_get8(global->io_handle, in i8042_get8()
1259 global->io_addr + I8042_STAT); in i8042_get8()
1266 ret = ddi_get8(global->io_handle, in i8042_get8()
1267 global->io_addr + I8042_DATA); in i8042_get8()
1297 struct i8042 *global; in i8042_put8() local
1303 global = port->i8042_global; in i8042_put8()
1310 mutex_enter(&global->i8042_out_mutex); in i8042_put8()
1320 while (global->glock && !port->has_glock) { in i8042_put8()
1321 cv_wait(&global->glock_cv, in i8042_put8()
1322 &global->i8042_out_mutex); in i8042_put8()
1327 i8042_send(global, I8042_CMD, I8042_CMD_WRITE_AUX); in i8042_put8()
1329 i8042_send(global, I8042_DATA, value); in i8042_put8()
1332 mutex_exit(&global->i8042_out_mutex); in i8042_put8()
1361 struct i8042 *global; in i8042_intr_ops() local
1391 global = port->i8042_global; in i8042_intr_ops()
1417 global = port->i8042_global; in i8042_intr_ops()
1418 mutex_enter(&global->i8042_mutex); in i8042_intr_ops()
1420 mutex_exit(&global->i8042_mutex); in i8042_intr_ops()
1430 global = port->i8042_global; in i8042_intr_ops()
1431 mutex_enter(&global->i8042_mutex); in i8042_intr_ops()
1436 mutex_exit(&global->i8042_mutex); in i8042_intr_ops()
1447 global = port->i8042_global; in i8042_intr_ops()
1448 mutex_enter(&global->i8042_mutex); in i8042_intr_ops()
1451 mutex_exit(&global->i8042_mutex); in i8042_intr_ops()
1469 struct i8042 *global; in i8042_ctlops() local
1472 global = ddi_get_driver_private(dip); in i8042_ctlops()
1493 (caddr_t)&global->i8042_ports[which_port]); in i8042_ctlops()