Lines Matching refs:hal
54 extern int nx1394_define_events(s1394_hal_t *hal);
55 extern void nx1394_undefine_events(s1394_hal_t *hal);
117 s1394_hal_t *hal; in h1394_attach() local
126 hal = (s1394_hal_t *)(*sl_private); in h1394_attach()
128 if (hal->halinfo.phy == H1394_PHY_1394A) in h1394_attach()
129 (void) HAL_CALL(hal).set_contender_bit( in h1394_attach()
130 hal->halinfo.hal_private); in h1394_attach()
137 hal = kmem_zalloc(sizeof (s1394_hal_t), KM_SLEEP); in h1394_attach()
140 hal->hal_state = S1394_HAL_INIT; in h1394_attach()
143 hal->halinfo = *halinfo; in h1394_attach()
146 mutex_init(&hal->topology_tree_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
147 hal->halinfo.hw_interrupt); in h1394_attach()
150 mutex_init(&hal->cm_timer_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
151 hal->halinfo.hw_interrupt); in h1394_attach()
154 hal->isoch_cec_list_head = NULL; in h1394_attach()
155 hal->isoch_cec_list_tail = NULL; in h1394_attach()
156 mutex_init(&hal->isoch_cec_list_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
157 hal->halinfo.hw_interrupt); in h1394_attach()
160 mutex_init(&hal->bus_mgr_node_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
161 hal->halinfo.hw_interrupt); in h1394_attach()
162 cv_init(&hal->bus_mgr_node_cv, NULL, CV_DRIVER, in h1394_attach()
163 hal->halinfo.hw_interrupt); in h1394_attach()
166 hal->bus_mgr_node = -1; in h1394_attach()
167 hal->incumbent_bus_mgr = B_FALSE; in h1394_attach()
170 hal->target_head = NULL; in h1394_attach()
171 hal->target_tail = NULL; in h1394_attach()
172 rw_init(&hal->target_list_rwlock, NULL, RW_DRIVER, in h1394_attach()
173 hal->halinfo.hw_interrupt); in h1394_attach()
176 hal->outstanding_q_head = NULL; in h1394_attach()
177 hal->outstanding_q_tail = NULL; in h1394_attach()
178 mutex_init(&hal->outstanding_q_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
179 hal->halinfo.hw_interrupt); in h1394_attach()
180 hal->pending_q_head = NULL; in h1394_attach()
181 hal->pending_q_tail = NULL; in h1394_attach()
182 mutex_init(&hal->pending_q_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
183 hal->halinfo.hw_interrupt); in h1394_attach()
186 (void) sprintf(buf, "hal%d_cache", ddi_get_instance(hal->halinfo.dip)); in h1394_attach()
188 hal->halinfo.hal_overhead; in h1394_attach()
190 hal->hal_kmem_cachep = kmem_cache_create(buf, cmd_size, 8, NULL, NULL, in h1394_attach()
194 ret = nx1394_define_events(hal); in h1394_attach()
197 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL0); in h1394_attach()
203 mutex_init(&hal->br_thread_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
204 hal->halinfo.hw_interrupt); in h1394_attach()
205 cv_init(&hal->br_thread_cv, NULL, CV_DRIVER, hal->halinfo.hw_interrupt); in h1394_attach()
206 mutex_init(&hal->br_cmplq_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
207 hal->halinfo.hw_interrupt); in h1394_attach()
208 cv_init(&hal->br_cmplq_cv, NULL, CV_DRIVER, hal->halinfo.hw_interrupt); in h1394_attach()
219 hal->br_thread = thread_create((caddr_t)NULL, 0, s1394_br_thread, in h1394_attach()
220 hal, 0, &p0, TS_RUN, minclsyspri); in h1394_attach()
223 hal->number_of_nodes = 0; in h1394_attach()
224 hal->num_bus_reset_till_fail = NUM_BR_FAIL; in h1394_attach()
227 hal->current_buffer = 0; in h1394_attach()
228 hal->selfid_buf0 = kmem_zalloc(S1394_SELFID_BUF_SIZE, KM_SLEEP); in h1394_attach()
229 hal->selfid_buf1 = kmem_zalloc(S1394_SELFID_BUF_SIZE, KM_SLEEP); in h1394_attach()
232 ret = s1394_kstat_init(hal); in h1394_attach()
235 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL3); in h1394_attach()
239 hal->hal_kstats->guid = hal->halinfo.guid; in h1394_attach()
242 hal->old_tree = &hal->last_valid_tree[0]; in h1394_attach()
243 hal->topology_tree = &hal->current_tree[0]; in h1394_attach()
246 ret = s1394_init_local_config_rom(hal); in h1394_attach()
249 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL4); in h1394_attach()
255 ret = s1394_init_addr_space(hal); in h1394_attach()
258 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL5); in h1394_attach()
264 ret = s1394_fcp_hal_init(hal); in h1394_attach()
267 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL6); in h1394_attach()
273 hal->IRM_node = -1; in h1394_attach()
276 if (hal->halinfo.phy == H1394_PHY_1394A) in h1394_attach()
277 (void) HAL_CALL(hal).set_contender_bit( in h1394_attach()
278 hal->halinfo.hal_private); in h1394_attach()
284 s1394_statep->hal_head = hal; in h1394_attach()
285 s1394_statep->hal_tail = hal; in h1394_attach()
287 s1394_statep->hal_tail->hal_next = hal; in h1394_attach()
288 hal->hal_prev = s1394_statep->hal_tail; in h1394_attach()
289 s1394_statep->hal_tail = hal; in h1394_attach()
294 *sl_private = (void *)hal; in h1394_attach()
317 s1394_hal_t *hal; in h1394_detach() local
319 hal = (s1394_hal_t *)(*sl_private); in h1394_detach()
324 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL7); in h1394_detach()
331 s1394_destroy_timers(hal); in h1394_detach()
333 hal->hal_was_suspended = B_TRUE; in h1394_detach()
365 s1394_hal_t *hal; in h1394_alloc_cmd() local
368 hal = (s1394_hal_t *)sl_private; in h1394_alloc_cmd()
370 if (s1394_alloc_cmd(hal, flags, cmdp) != DDI_SUCCESS) { in h1394_alloc_cmd()
399 s1394_hal_t *hal; in h1394_free_cmd() local
402 hal = (s1394_hal_t *)sl_private; in h1394_free_cmd()
413 kmem_cache_free(hal->hal_kmem_cachep, *cmdp); in h1394_free_cmd()
419 hal->hal_kstats->cmd_free++; in h1394_free_cmd()
446 s1394_hal_t *hal; in h1394_cmd_is_complete() local
449 hal = (s1394_hal_t *)sl_private; in h1394_cmd_is_complete()
454 s1394_atreq_cmd_complete(hal, command_id, status); in h1394_cmd_is_complete()
458 s1394_atresp_cmd_complete(hal, command_id, status); in h1394_cmd_is_complete()
462 dip = hal->halinfo.dip; in h1394_cmd_is_complete()
469 s1394_hal_shutdown(hal, B_TRUE); in h1394_cmd_is_complete()
490 s1394_hal_t *hal; in h1394_bus_reset() local
492 hal = (s1394_hal_t *)sl_private; in h1394_bus_reset()
494 mutex_enter(&hal->topology_tree_mutex); in h1394_bus_reset()
497 if (hal->hal_state != S1394_HAL_SHUTDOWN) { in h1394_bus_reset()
498 hal->hal_state = S1394_HAL_RESET; in h1394_bus_reset()
500 mutex_exit(&hal->topology_tree_mutex); in h1394_bus_reset()
504 if (hal->initiated_bus_reset == B_TRUE) { in h1394_bus_reset()
505 hal->initiated_bus_reset = B_FALSE; in h1394_bus_reset()
506 if (hal->num_bus_reset_till_fail > 0) { in h1394_bus_reset()
507 hal->num_bus_reset_till_fail--; in h1394_bus_reset()
510 hal->num_bus_reset_till_fail = NUM_BR_FAIL; in h1394_bus_reset()
514 hal->IRM_node = -1; in h1394_bus_reset()
517 hal->slowest_node_speed = IEEE1394_S400; in h1394_bus_reset()
520 if (hal->current_buffer == 0) { in h1394_bus_reset()
521 *selfid_buf_addr = (void *)hal->selfid_buf1; in h1394_bus_reset()
522 hal->current_buffer = 1; in h1394_bus_reset()
524 *selfid_buf_addr = (void *)hal->selfid_buf0; in h1394_bus_reset()
525 hal->current_buffer = 0; in h1394_bus_reset()
529 s1394_CSR_topology_map_disable(hal); in h1394_bus_reset()
531 mutex_exit(&hal->topology_tree_mutex); in h1394_bus_reset()
534 mutex_enter(&hal->bus_mgr_node_mutex); in h1394_bus_reset()
535 hal->bus_mgr_node = -1; in h1394_bus_reset()
536 mutex_exit(&hal->bus_mgr_node_mutex); in h1394_bus_reset()
562 s1394_hal_t *hal; in h1394_self_ids() local
575 hal = (s1394_hal_t *)sl_private; in h1394_self_ids()
578 mutex_enter(&hal->topology_tree_mutex); in h1394_self_ids()
579 if (hal->hal_state == S1394_HAL_SHUTDOWN) { in h1394_self_ids()
580 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
585 hal->hal_kstats->selfid_complete++; in h1394_self_ids()
587 if (generation_count > hal->generation_count) { in h1394_self_ids()
588 gen_diff = generation_count - hal->generation_count; in h1394_self_ids()
589 hal->hal_kstats->bus_reset += gen_diff; in h1394_self_ids()
591 gen_diff = hal->generation_count - generation_count; in h1394_self_ids()
593 hal->hal_kstats->bus_reset += in h1394_self_ids()
594 (hal->halinfo.max_generation - gen_diff); in h1394_self_ids()
602 if ((hal->topology_tree_valid == B_TRUE) && in h1394_self_ids()
603 (hal->topology_tree_processed == B_TRUE)) { in h1394_self_ids()
605 s1394_copy_old_tree(hal); in h1394_self_ids()
610 hal->node_id = node_id; in h1394_self_ids()
611 hal->generation_count = generation_count; in h1394_self_ids()
614 hal->topology_tree_valid = B_FALSE; in h1394_self_ids()
615 hal->topology_tree_processed = B_FALSE; in h1394_self_ids()
616 hal->cfgroms_being_read = 0; in h1394_self_ids()
623 saved_number_of_nodes = hal->number_of_nodes; in h1394_self_ids()
626 if (s1394_parse_selfid_buffer(hal, selfid_buf_addr, selfid_size) != in h1394_self_ids()
629 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
632 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
637 if (hal->halinfo.phy == H1394_PHY_1995) { in h1394_self_ids()
638 s1394_sort_selfids(hal); in h1394_self_ids()
645 mutex_enter(&hal->cm_timer_mutex); in h1394_self_ids()
646 if ((hal->cm_timer_set == B_TRUE) && in h1394_self_ids()
647 ((hal->old_number_of_nodes - 1) == in h1394_self_ids()
648 IEEE1394_NODE_NUM(hal->old_node_id)) && in h1394_self_ids()
649 ((hal->number_of_nodes - 1) != in h1394_self_ids()
650 IEEE1394_NODE_NUM(hal->node_id))) { in h1394_self_ids()
651 mutex_exit(&hal->cm_timer_mutex); in h1394_self_ids()
652 (void) untimeout(hal->cm_timer); in h1394_self_ids()
654 mutex_exit(&hal->cm_timer_mutex); in h1394_self_ids()
657 s1394_init_topology_tree(hal, tree_copied, saved_number_of_nodes); in h1394_self_ids()
660 hal->gap_count = s1394_get_current_gap_count(hal); in h1394_self_ids()
662 if (hal->gap_count == -1) { in h1394_self_ids()
664 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
667 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
671 mutex_enter(&hal->topology_tree_mutex); in h1394_self_ids()
672 hal->gap_count = 0x3F; in h1394_self_ids()
679 hal->IRM_node = s1394_get_isoch_rsrc_mgr(hal); in h1394_self_ids()
682 if (s1394_topology_tree_build(hal) != DDI_SUCCESS) { in h1394_self_ids()
684 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
687 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
692 s1394_CSR_topology_map_update(hal); in h1394_self_ids()
695 diameter = s1394_topology_tree_calculate_diameter(hal); in h1394_self_ids()
698 hal->optimum_gap_count = s1394_gap_count_optimize(diameter); in h1394_self_ids()
701 s1394_speed_map_fill(hal); in h1394_self_ids()
704 s1394_topology_tree_mark_all_unvisited(hal); in h1394_self_ids()
705 s1394_old_tree_mark_all_unvisited(hal); in h1394_self_ids()
706 s1394_old_tree_mark_all_unmatched(hal); in h1394_self_ids()
709 if ((hal->old_tree_valid == B_TRUE) && in h1394_self_ids()
710 (hal->topology_tree_valid == B_TRUE)) { in h1394_self_ids()
712 if (hal->hal_was_suspended == B_TRUE) { in h1394_self_ids()
713 hal->hal_was_suspended = B_FALSE; in h1394_self_ids()
715 gen_rollover = hal->halinfo.max_generation + 1; in h1394_self_ids()
717 if (((hal->old_generation_count + 1) % gen_rollover) == in h1394_self_ids()
719 s1394_match_tree_nodes(hal); in h1394_self_ids()
725 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
728 s1394_tickle_bus_reset_thread(hal); in h1394_self_ids()
748 s1394_hal_t *hal; in h1394_read_request() local
761 hal = (s1394_hal_t *)sl_private; in h1394_read_request()
771 hal->hal_kstats->arreq_quad_rd++; in h1394_read_request()
776 hal->hal_kstats->arreq_blk_rd++; in h1394_read_request()
780 dip = hal->halinfo.dip; in h1394_read_request()
787 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
793 mutex_enter(&hal->addr_space_used_mutex); in h1394_read_request()
796 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_read_request()
801 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
803 (void) s1394_send_response(hal, req); in h1394_read_request()
811 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
813 (void) s1394_send_response(hal, req); in h1394_read_request()
820 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
822 (void) s1394_send_response(hal, req); in h1394_read_request()
831 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
833 (void) s1394_send_response(hal, req); in h1394_read_request()
858 dip = hal->halinfo.dip; in h1394_read_request()
865 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
868 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
875 dip = hal->halinfo.dip; in h1394_read_request()
882 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
885 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
897 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
908 (void) s1394_send_response(hal, req); in h1394_read_request()
930 s1394_hal_t *hal; in h1394_write_request() local
946 hal = (s1394_hal_t *)sl_private; in h1394_write_request()
956 hal->hal_kstats->arreq_quad_wr++; in h1394_write_request()
961 hal->hal_kstats->arreq_blk_wr++; in h1394_write_request()
962 hal->hal_kstats->arreq_blk_wr_size += cmd_length; in h1394_write_request()
966 dip = hal->halinfo.dip; in h1394_write_request()
973 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
979 mutex_enter(&hal->addr_space_used_mutex); in h1394_write_request()
982 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_write_request()
985 posted_write = s1394_is_posted_write(hal, req->cmd_addr); in h1394_write_request()
1022 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1027 hal->hal_kstats->arreq_posted_write_error++; in h1394_write_request()
1029 HAL_CALL(hal).response_complete( in h1394_write_request()
1030 hal->halinfo.hal_private, req, h_priv); in h1394_write_request()
1033 (void) s1394_send_response(hal, req); in h1394_write_request()
1056 dip = hal->halinfo.dip; in h1394_write_request()
1063 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1066 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
1073 dip = hal->halinfo.dip; in h1394_write_request()
1080 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1083 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
1098 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1109 (void) s1394_send_response(hal, req); in h1394_write_request()
1131 s1394_hal_t *hal; in h1394_lock_request() local
1141 hal = (s1394_hal_t *)sl_private; in h1394_lock_request()
1149 mutex_enter(&hal->addr_space_used_mutex); in h1394_lock_request()
1152 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_lock_request()
1157 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1159 (void) s1394_send_response(hal, req); in h1394_lock_request()
1168 hal->hal_kstats->arreq_lock32++; in h1394_lock_request()
1174 hal->hal_kstats->arreq_lock64++; in h1394_lock_request()
1179 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1181 dip = hal->halinfo.dip; in h1394_lock_request()
1188 s1394_hal_shutdown(hal, B_TRUE); in h1394_lock_request()
1195 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1197 (void) s1394_send_response(hal, req); in h1394_lock_request()
1204 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1206 (void) s1394_send_response(hal, req); in h1394_lock_request()
1303 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1305 (void) s1394_send_response(hal, req); in h1394_lock_request()
1397 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1399 (void) s1394_send_response(hal, req); in h1394_lock_request()
1411 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1422 (void) s1394_send_response(hal, req); in h1394_lock_request()
1497 s1394_hal_t *hal; in h1394_error_detected() local
1501 hal = (s1394_hal_t *)sl_private; in h1394_error_detected()
1506 mutex_enter(&hal->topology_tree_mutex); in h1394_error_detected()
1507 hal_node_num = IEEE1394_NODE_NUM(hal->node_id); in h1394_error_detected()
1508 IRM_node_num = hal->IRM_node; in h1394_error_detected()
1509 mutex_exit(&hal->topology_tree_mutex); in h1394_error_detected()
1511 s1394_initiate_hal_reset(hal, NON_CRITICAL); in h1394_error_detected()
1518 s1394_hal_shutdown(hal, B_FALSE); in h1394_error_detected()
1523 mutex_enter(&hal->cm_timer_mutex); in h1394_error_detected()
1524 hal->cm_timer_set = B_TRUE; in h1394_error_detected()
1525 mutex_exit(&hal->cm_timer_mutex); in h1394_error_detected()
1526 hal->cm_timer = timeout(s1394_cycle_too_long_callback, hal, in h1394_error_detected()