Lines Matching refs:hal
58 extern int nx1394_define_events(s1394_hal_t *hal);
59 extern void nx1394_undefine_events(s1394_hal_t *hal);
128 s1394_hal_t *hal; in h1394_attach() local
139 hal = (s1394_hal_t *)(*sl_private); in h1394_attach()
141 if (hal->halinfo.phy == H1394_PHY_1394A) in h1394_attach()
142 (void) HAL_CALL(hal).set_contender_bit( in h1394_attach()
143 hal->halinfo.hal_private); in h1394_attach()
157 hal = kmem_zalloc(sizeof (s1394_hal_t), KM_SLEEP); in h1394_attach()
160 hal->hal_state = S1394_HAL_INIT; in h1394_attach()
163 hal->halinfo = *halinfo; in h1394_attach()
166 mutex_init(&hal->topology_tree_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
167 hal->halinfo.hw_interrupt); in h1394_attach()
170 mutex_init(&hal->cm_timer_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
171 hal->halinfo.hw_interrupt); in h1394_attach()
174 hal->isoch_cec_list_head = NULL; in h1394_attach()
175 hal->isoch_cec_list_tail = NULL; in h1394_attach()
176 mutex_init(&hal->isoch_cec_list_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
177 hal->halinfo.hw_interrupt); in h1394_attach()
180 mutex_init(&hal->bus_mgr_node_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
181 hal->halinfo.hw_interrupt); in h1394_attach()
182 cv_init(&hal->bus_mgr_node_cv, NULL, CV_DRIVER, in h1394_attach()
183 hal->halinfo.hw_interrupt); in h1394_attach()
186 hal->bus_mgr_node = -1; in h1394_attach()
187 hal->incumbent_bus_mgr = B_FALSE; in h1394_attach()
190 hal->target_head = NULL; in h1394_attach()
191 hal->target_tail = NULL; in h1394_attach()
192 rw_init(&hal->target_list_rwlock, NULL, RW_DRIVER, in h1394_attach()
193 hal->halinfo.hw_interrupt); in h1394_attach()
196 hal->outstanding_q_head = NULL; in h1394_attach()
197 hal->outstanding_q_tail = NULL; in h1394_attach()
198 mutex_init(&hal->outstanding_q_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
199 hal->halinfo.hw_interrupt); in h1394_attach()
200 hal->pending_q_head = NULL; in h1394_attach()
201 hal->pending_q_tail = NULL; in h1394_attach()
202 mutex_init(&hal->pending_q_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
203 hal->halinfo.hw_interrupt); in h1394_attach()
206 (void) sprintf(buf, "hal%d_cache", ddi_get_instance(hal->halinfo.dip)); in h1394_attach()
208 hal->halinfo.hal_overhead; in h1394_attach()
210 hal->hal_kmem_cachep = kmem_cache_create(buf, cmd_size, 8, NULL, NULL, in h1394_attach()
214 ret = nx1394_define_events(hal); in h1394_attach()
217 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL0); in h1394_attach()
227 mutex_init(&hal->br_thread_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
228 hal->halinfo.hw_interrupt); in h1394_attach()
229 cv_init(&hal->br_thread_cv, NULL, CV_DRIVER, hal->halinfo.hw_interrupt); in h1394_attach()
230 mutex_init(&hal->br_cmplq_mutex, NULL, MUTEX_DRIVER, in h1394_attach()
231 hal->halinfo.hw_interrupt); in h1394_attach()
232 cv_init(&hal->br_cmplq_cv, NULL, CV_DRIVER, hal->halinfo.hw_interrupt); in h1394_attach()
243 hal->br_thread = thread_create((caddr_t)NULL, 0, s1394_br_thread, in h1394_attach()
244 hal, 0, &p0, TS_RUN, minclsyspri); in h1394_attach()
247 hal->number_of_nodes = 0; in h1394_attach()
248 hal->num_bus_reset_till_fail = NUM_BR_FAIL; in h1394_attach()
251 hal->current_buffer = 0; in h1394_attach()
252 hal->selfid_buf0 = kmem_zalloc(S1394_SELFID_BUF_SIZE, KM_SLEEP); in h1394_attach()
253 hal->selfid_buf1 = kmem_zalloc(S1394_SELFID_BUF_SIZE, KM_SLEEP); in h1394_attach()
256 ret = s1394_kstat_init(hal); in h1394_attach()
259 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL3); in h1394_attach()
267 hal->hal_kstats->guid = hal->halinfo.guid; in h1394_attach()
270 hal->old_tree = &hal->last_valid_tree[0]; in h1394_attach()
271 hal->topology_tree = &hal->current_tree[0]; in h1394_attach()
274 ret = s1394_init_local_config_rom(hal); in h1394_attach()
277 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL4); in h1394_attach()
286 ret = s1394_init_addr_space(hal); in h1394_attach()
289 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL5); in h1394_attach()
299 ret = s1394_fcp_hal_init(hal); in h1394_attach()
302 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL6); in h1394_attach()
312 hal->IRM_node = -1; in h1394_attach()
315 if (hal->halinfo.phy == H1394_PHY_1394A) in h1394_attach()
316 (void) HAL_CALL(hal).set_contender_bit( in h1394_attach()
317 hal->halinfo.hal_private); in h1394_attach()
323 s1394_statep->hal_head = hal; in h1394_attach()
324 s1394_statep->hal_tail = hal; in h1394_attach()
326 s1394_statep->hal_tail->hal_next = hal; in h1394_attach()
327 hal->hal_prev = s1394_statep->hal_tail; in h1394_attach()
328 s1394_statep->hal_tail = hal; in h1394_attach()
333 *sl_private = (void *)hal; in h1394_attach()
357 s1394_hal_t *hal; in h1394_detach() local
361 hal = (s1394_hal_t *)(*sl_private); in h1394_detach()
366 s1394_cleanup_for_detach(hal, H1394_CLEANUP_LEVEL7); in h1394_detach()
373 s1394_destroy_timers(hal); in h1394_detach()
375 hal->hal_was_suspended = B_TRUE; in h1394_detach()
412 s1394_hal_t *hal; in h1394_alloc_cmd() local
418 hal = (s1394_hal_t *)sl_private; in h1394_alloc_cmd()
420 if (s1394_alloc_cmd(hal, flags, cmdp) != DDI_SUCCESS) { in h1394_alloc_cmd()
455 s1394_hal_t *hal; in h1394_free_cmd() local
461 hal = (s1394_hal_t *)sl_private; in h1394_free_cmd()
476 kmem_cache_free(hal->hal_kmem_cachep, *cmdp); in h1394_free_cmd()
482 hal->hal_kstats->cmd_free++; in h1394_free_cmd()
511 s1394_hal_t *hal; in h1394_cmd_is_complete() local
517 hal = (s1394_hal_t *)sl_private; in h1394_cmd_is_complete()
522 s1394_atreq_cmd_complete(hal, command_id, status); in h1394_cmd_is_complete()
526 s1394_atresp_cmd_complete(hal, command_id, status); in h1394_cmd_is_complete()
530 dip = hal->halinfo.dip; in h1394_cmd_is_complete()
537 s1394_hal_shutdown(hal, B_TRUE); in h1394_cmd_is_complete()
564 s1394_hal_t *hal; in h1394_bus_reset() local
568 hal = (s1394_hal_t *)sl_private; in h1394_bus_reset()
570 mutex_enter(&hal->topology_tree_mutex); in h1394_bus_reset()
573 if (hal->hal_state != S1394_HAL_SHUTDOWN) { in h1394_bus_reset()
574 hal->hal_state = S1394_HAL_RESET; in h1394_bus_reset()
576 mutex_exit(&hal->topology_tree_mutex); in h1394_bus_reset()
580 if (hal->initiated_bus_reset == B_TRUE) { in h1394_bus_reset()
581 hal->initiated_bus_reset = B_FALSE; in h1394_bus_reset()
582 if (hal->num_bus_reset_till_fail > 0) { in h1394_bus_reset()
583 hal->num_bus_reset_till_fail--; in h1394_bus_reset()
588 tnf_uint, br_type, hal->initiated_br_reason); in h1394_bus_reset()
591 hal->num_bus_reset_till_fail = NUM_BR_FAIL; in h1394_bus_reset()
595 hal->IRM_node = -1; in h1394_bus_reset()
598 hal->slowest_node_speed = IEEE1394_S400; in h1394_bus_reset()
601 if (hal->current_buffer == 0) { in h1394_bus_reset()
602 *selfid_buf_addr = (void *)hal->selfid_buf1; in h1394_bus_reset()
603 hal->current_buffer = 1; in h1394_bus_reset()
605 *selfid_buf_addr = (void *)hal->selfid_buf0; in h1394_bus_reset()
606 hal->current_buffer = 0; in h1394_bus_reset()
610 s1394_CSR_topology_map_disable(hal); in h1394_bus_reset()
612 mutex_exit(&hal->topology_tree_mutex); in h1394_bus_reset()
615 mutex_enter(&hal->bus_mgr_node_mutex); in h1394_bus_reset()
616 hal->bus_mgr_node = -1; in h1394_bus_reset()
617 mutex_exit(&hal->bus_mgr_node_mutex); in h1394_bus_reset()
645 s1394_hal_t *hal; in h1394_self_ids() local
661 hal = (s1394_hal_t *)sl_private; in h1394_self_ids()
664 mutex_enter(&hal->topology_tree_mutex); in h1394_self_ids()
665 if (hal->hal_state == S1394_HAL_SHUTDOWN) { in h1394_self_ids()
666 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
673 hal->hal_kstats->selfid_complete++; in h1394_self_ids()
675 if (generation_count > hal->generation_count) { in h1394_self_ids()
676 gen_diff = generation_count - hal->generation_count; in h1394_self_ids()
677 hal->hal_kstats->bus_reset += gen_diff; in h1394_self_ids()
679 gen_diff = hal->generation_count - generation_count; in h1394_self_ids()
681 hal->hal_kstats->bus_reset += in h1394_self_ids()
682 (hal->halinfo.max_generation - gen_diff); in h1394_self_ids()
690 if ((hal->topology_tree_valid == B_TRUE) && in h1394_self_ids()
691 (hal->topology_tree_processed == B_TRUE)) { in h1394_self_ids()
695 s1394_copy_old_tree(hal); in h1394_self_ids()
700 hal->node_id = node_id; in h1394_self_ids()
701 hal->generation_count = generation_count; in h1394_self_ids()
704 hal->topology_tree_valid = B_FALSE; in h1394_self_ids()
705 hal->topology_tree_processed = B_FALSE; in h1394_self_ids()
706 hal->cfgroms_being_read = 0; in h1394_self_ids()
716 saved_number_of_nodes = hal->number_of_nodes; in h1394_self_ids()
719 if (s1394_parse_selfid_buffer(hal, selfid_buf_addr, selfid_size) != in h1394_self_ids()
722 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
729 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
734 if (hal->halinfo.phy == H1394_PHY_1995) { in h1394_self_ids()
737 s1394_sort_selfids(hal); in h1394_self_ids()
744 mutex_enter(&hal->cm_timer_mutex); in h1394_self_ids()
745 if ((hal->cm_timer_set == B_TRUE) && in h1394_self_ids()
746 ((hal->old_number_of_nodes - 1) == in h1394_self_ids()
747 IEEE1394_NODE_NUM(hal->old_node_id)) && in h1394_self_ids()
748 ((hal->number_of_nodes - 1) != in h1394_self_ids()
749 IEEE1394_NODE_NUM(hal->node_id))) { in h1394_self_ids()
750 mutex_exit(&hal->cm_timer_mutex); in h1394_self_ids()
751 (void) untimeout(hal->cm_timer); in h1394_self_ids()
753 mutex_exit(&hal->cm_timer_mutex); in h1394_self_ids()
758 s1394_init_topology_tree(hal, tree_copied, saved_number_of_nodes); in h1394_self_ids()
761 hal->gap_count = s1394_get_current_gap_count(hal); in h1394_self_ids()
763 if (hal->gap_count == -1) { in h1394_self_ids()
765 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
772 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
776 mutex_enter(&hal->topology_tree_mutex); in h1394_self_ids()
777 hal->gap_count = 0x3F; in h1394_self_ids()
784 "", tnf_uint, gap_count, hal->gap_count); in h1394_self_ids()
787 hal->IRM_node = s1394_get_isoch_rsrc_mgr(hal); in h1394_self_ids()
790 tnf_int, IRM_node, hal->IRM_node); in h1394_self_ids()
796 if (s1394_topology_tree_build(hal) != DDI_SUCCESS) { in h1394_self_ids()
798 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
805 hal->hal_kstats->selfid_buffer_error++; in h1394_self_ids()
813 s1394_CSR_topology_map_update(hal); in h1394_self_ids()
816 diameter = s1394_topology_tree_calculate_diameter(hal); in h1394_self_ids()
819 hal->optimum_gap_count = s1394_gap_count_optimize(diameter); in h1394_self_ids()
823 tnf_uint, optimum_gap, hal->optimum_gap_count); in h1394_self_ids()
828 s1394_speed_map_fill(hal); in h1394_self_ids()
831 s1394_topology_tree_mark_all_unvisited(hal); in h1394_self_ids()
832 s1394_old_tree_mark_all_unvisited(hal); in h1394_self_ids()
833 s1394_old_tree_mark_all_unmatched(hal); in h1394_self_ids()
836 if ((hal->old_tree_valid == B_TRUE) && in h1394_self_ids()
837 (hal->topology_tree_valid == B_TRUE)) { in h1394_self_ids()
839 if (hal->hal_was_suspended == B_TRUE) { in h1394_self_ids()
840 hal->hal_was_suspended = B_FALSE; in h1394_self_ids()
842 gen_rollover = hal->halinfo.max_generation + 1; in h1394_self_ids()
844 if (((hal->old_generation_count + 1) % gen_rollover) == in h1394_self_ids()
848 s1394_match_tree_nodes(hal); in h1394_self_ids()
854 mutex_exit(&hal->topology_tree_mutex); in h1394_self_ids()
857 s1394_tickle_bus_reset_thread(hal); in h1394_self_ids()
880 s1394_hal_t *hal; in h1394_read_request() local
896 hal = (s1394_hal_t *)sl_private; in h1394_read_request()
906 hal->hal_kstats->arreq_quad_rd++; in h1394_read_request()
911 hal->hal_kstats->arreq_blk_rd++; in h1394_read_request()
915 dip = hal->halinfo.dip; in h1394_read_request()
922 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
933 mutex_enter(&hal->addr_space_used_mutex); in h1394_read_request()
936 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_read_request()
944 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
946 (void) s1394_send_response(hal, req); in h1394_read_request()
956 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
958 (void) s1394_send_response(hal, req); in h1394_read_request()
967 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
969 (void) s1394_send_response(hal, req); in h1394_read_request()
980 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
982 (void) s1394_send_response(hal, req); in h1394_read_request()
1009 dip = hal->halinfo.dip; in h1394_read_request()
1016 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
1019 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
1031 dip = hal->halinfo.dip; in h1394_read_request()
1038 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
1041 s1394_hal_shutdown(hal, B_TRUE); in h1394_read_request()
1058 mutex_exit(&hal->addr_space_used_mutex); in h1394_read_request()
1071 (void) s1394_send_response(hal, req); in h1394_read_request()
1098 s1394_hal_t *hal; in h1394_write_request() local
1117 hal = (s1394_hal_t *)sl_private; in h1394_write_request()
1127 hal->hal_kstats->arreq_quad_wr++; in h1394_write_request()
1132 hal->hal_kstats->arreq_blk_wr++; in h1394_write_request()
1133 hal->hal_kstats->arreq_blk_wr_size += cmd_length; in h1394_write_request()
1137 dip = hal->halinfo.dip; in h1394_write_request()
1144 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
1155 mutex_enter(&hal->addr_space_used_mutex); in h1394_write_request()
1158 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_write_request()
1164 posted_write = s1394_is_posted_write(hal, req->cmd_addr); in h1394_write_request()
1201 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1206 hal->hal_kstats->arreq_posted_write_error++; in h1394_write_request()
1208 HAL_CALL(hal).response_complete( in h1394_write_request()
1209 hal->halinfo.hal_private, req, h_priv); in h1394_write_request()
1214 (void) s1394_send_response(hal, req); in h1394_write_request()
1239 dip = hal->halinfo.dip; in h1394_write_request()
1246 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1249 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
1261 dip = hal->halinfo.dip; in h1394_write_request()
1268 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1271 s1394_hal_shutdown(hal, B_TRUE); in h1394_write_request()
1291 mutex_exit(&hal->addr_space_used_mutex); in h1394_write_request()
1304 (void) s1394_send_response(hal, req); in h1394_write_request()
1331 s1394_hal_t *hal; in h1394_lock_request() local
1344 hal = (s1394_hal_t *)sl_private; in h1394_lock_request()
1352 mutex_enter(&hal->addr_space_used_mutex); in h1394_lock_request()
1355 addr_blk = s1394_used_tree_search(hal, req->cmd_addr); in h1394_lock_request()
1360 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1362 (void) s1394_send_response(hal, req); in h1394_lock_request()
1373 hal->hal_kstats->arreq_lock32++; in h1394_lock_request()
1379 hal->hal_kstats->arreq_lock64++; in h1394_lock_request()
1384 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1386 dip = hal->halinfo.dip; in h1394_lock_request()
1393 s1394_hal_shutdown(hal, B_TRUE); in h1394_lock_request()
1405 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1407 (void) s1394_send_response(hal, req); in h1394_lock_request()
1416 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1418 (void) s1394_send_response(hal, req); in h1394_lock_request()
1517 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1519 (void) s1394_send_response(hal, req); in h1394_lock_request()
1616 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1618 (void) s1394_send_response(hal, req); in h1394_lock_request()
1635 mutex_exit(&hal->addr_space_used_mutex); in h1394_lock_request()
1648 (void) s1394_send_response(hal, req); in h1394_lock_request()
1738 s1394_hal_t *hal; in h1394_error_detected() local
1744 hal = (s1394_hal_t *)sl_private; in h1394_error_detected()
1751 mutex_enter(&hal->topology_tree_mutex); in h1394_error_detected()
1752 hal_node_num = IEEE1394_NODE_NUM(hal->node_id); in h1394_error_detected()
1753 IRM_node_num = hal->IRM_node; in h1394_error_detected()
1754 mutex_exit(&hal->topology_tree_mutex); in h1394_error_detected()
1756 s1394_initiate_hal_reset(hal, NON_CRITICAL); in h1394_error_detected()
1768 s1394_hal_shutdown(hal, B_FALSE); in h1394_error_detected()
1773 mutex_enter(&hal->cm_timer_mutex); in h1394_error_detected()
1774 hal->cm_timer_set = B_TRUE; in h1394_error_detected()
1775 mutex_exit(&hal->cm_timer_mutex); in h1394_error_detected()
1776 hal->cm_timer = timeout(s1394_cycle_too_long_callback, hal, in h1394_error_detected()