ieee1394_core.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 1,324 行 · 第 1/3 页
C
1,324 行
} else { hpsb_free_packet(packet); } break; }}#undef PREP_REPLY_PACKETvoid hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, int write_acked){ int tcode; if (host->in_bus_reset) { HPSB_INFO("received packet during reset; ignoring"); return; } dump_packet("received packet:", data, size); tcode = (data[0] >> 4) & 0xf; switch (tcode) { case TCODE_WRITE_RESPONSE: case TCODE_READQ_RESPONSE: case TCODE_READB_RESPONSE: case TCODE_LOCK_RESPONSE: handle_packet_response(host, tcode, data, size); break; case TCODE_WRITEQ: case TCODE_WRITEB: case TCODE_READQ: case TCODE_READB: case TCODE_LOCK_REQUEST: handle_incoming_packet(host, tcode, data, size, write_acked); break; case TCODE_ISO_DATA: highlevel_iso_receive(host, data, size); break; case TCODE_CYCLE_START: /* simply ignore this packet if it is passed on */ break; default: HPSB_NOTICE("received packet with bogus transaction code %d", tcode); break; }}void abort_requests(struct hpsb_host *host){ struct hpsb_packet *packet; struct sk_buff *skb; host->driver->devctl(host, CANCEL_REQUESTS, 0); while ((skb = skb_dequeue(&host->pending_packet_queue)) != NULL) { packet = (struct hpsb_packet *)skb->data; packet->state = hpsb_complete; packet->ack_code = ACKX_ABORTED; queue_packet_complete(packet); }}void abort_timedouts(unsigned long __opaque){ struct hpsb_host *host = (struct hpsb_host *)__opaque; unsigned long flags; struct hpsb_packet *packet; struct sk_buff *skb; unsigned long expire; spin_lock_irqsave(&host->csr.lock, flags); expire = host->csr.expire; spin_unlock_irqrestore(&host->csr.lock, flags); /* Hold the lock around this, since we aren't dequeuing all * packets, just ones we need. */ spin_lock_irqsave(&host->pending_packet_queue.lock, flags); while (!skb_queue_empty(&host->pending_packet_queue)) { skb = skb_peek(&host->pending_packet_queue); packet = (struct hpsb_packet *)skb->data; if (time_before(packet->sendtime + expire, jiffies)) { __skb_unlink(skb, skb->list); packet->state = hpsb_complete; packet->ack_code = ACKX_TIMEOUT; queue_packet_complete(packet); } else { /* Since packets are added to the tail, the oldest * ones are first, always. When we get to one that * isn't timed out, the rest aren't either. */ break; } } if (!skb_queue_empty(&host->pending_packet_queue)) mod_timer(&host->timeout, jiffies + host->timeout_interval); spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);}/* Kernel thread and vars, which handles packets that are completed. Only * packets that have a "complete" function are sent here. This way, the * completion is run out of kernel context, and doesn't block the rest of * the stack. */static int khpsbpkt_pid = -1, khpsbpkt_kill;static DECLARE_COMPLETION(khpsbpkt_complete);struct sk_buff_head hpsbpkt_queue;static DECLARE_MUTEX_LOCKED(khpsbpkt_sig);static void queue_packet_complete(struct hpsb_packet *packet){ if (packet->no_waiter) { hpsb_free_packet(packet); return; } if (packet->complete_routine != NULL) { skb_queue_tail(&hpsbpkt_queue, packet->skb); /* Signal the kernel thread to handle this */ up(&khpsbpkt_sig); } return;}static int hpsbpkt_thread(void *__hi){ struct sk_buff *skb; struct hpsb_packet *packet; void (*complete_routine)(void*); void *complete_data; daemonize("khpsbpkt"); while (!down_interruptible(&khpsbpkt_sig)) { if (khpsbpkt_kill) break; if (current->flags & PF_FREEZE) { refrigerator(0); continue; } while ((skb = skb_dequeue(&hpsbpkt_queue)) != NULL) { packet = (struct hpsb_packet *)skb->data; complete_routine = packet->complete_routine; complete_data = packet->complete_data; packet->complete_routine = packet->complete_data = NULL; complete_routine(complete_data); } } complete_and_exit(&khpsbpkt_complete, 0);}static int __init ieee1394_init(void){ int i, ret; skb_queue_head_init(&hpsbpkt_queue); /* non-fatal error */ if (hpsb_init_config_roms()) { HPSB_ERR("Failed to initialize some config rom entries.\n"); HPSB_ERR("Some features may not be available\n"); } khpsbpkt_pid = kernel_thread(hpsbpkt_thread, NULL, CLONE_KERNEL); if (khpsbpkt_pid < 0) { HPSB_ERR("Failed to start hpsbpkt thread!\n"); ret = -ENOMEM; goto exit_cleanup_config_roms; } if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) { HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR); ret = -ENODEV; goto exit_release_kernel_thread; } /* actually this is a non-fatal error */ ret = devfs_mk_dir("ieee1394"); if (ret < 0) { HPSB_ERR("unable to make devfs dir for device major %d!\n", IEEE1394_MAJOR); goto release_chrdev; } ret = bus_register(&ieee1394_bus_type); if (ret < 0) { HPSB_INFO("bus register failed"); goto release_devfs; } for (i = 0; fw_bus_attrs[i]; i++) { ret = bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]); if (ret < 0) { while (i >= 0) { bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i--]); } bus_unregister(&ieee1394_bus_type); goto release_devfs; } } ret = class_register(&hpsb_host_class); if (ret < 0) goto release_all_bus; ret = init_csr(); if (ret) { HPSB_INFO("init csr failed"); ret = -ENOMEM; goto release_class; } if (disable_nodemgr) { HPSB_INFO("nodemgr functionality disabled"); return 0; } ret = init_ieee1394_nodemgr(); if (ret < 0) { HPSB_INFO("init nodemgr failed"); goto cleanup_csr; } return 0;cleanup_csr: cleanup_csr();release_class: class_unregister(&hpsb_host_class);release_all_bus: for (i = 0; fw_bus_attrs[i]; i++) bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]); bus_unregister(&ieee1394_bus_type);release_devfs: devfs_remove("ieee1394");release_chrdev: unregister_chrdev_region(IEEE1394_CORE_DEV, 256);exit_release_kernel_thread: if (khpsbpkt_pid >= 0) { kill_proc(khpsbpkt_pid, SIGTERM, 1); wait_for_completion(&khpsbpkt_complete); }exit_cleanup_config_roms: hpsb_cleanup_config_roms(); return ret;}static void __exit ieee1394_cleanup(void){ int i; if (!disable_nodemgr) cleanup_ieee1394_nodemgr(); cleanup_csr(); class_unregister(&hpsb_host_class); for (i = 0; fw_bus_attrs[i]; i++) bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]); bus_unregister(&ieee1394_bus_type); if (khpsbpkt_pid >= 0) { khpsbpkt_kill = 1; mb(); up(&khpsbpkt_sig); wait_for_completion(&khpsbpkt_complete); } hpsb_cleanup_config_roms(); unregister_chrdev_region(IEEE1394_CORE_DEV, 256); devfs_remove("ieee1394");}module_init(ieee1394_init);module_exit(ieee1394_cleanup);/* Exported symbols *//** hosts.c **/EXPORT_SYMBOL(hpsb_alloc_host);EXPORT_SYMBOL(hpsb_add_host);EXPORT_SYMBOL(hpsb_remove_host);EXPORT_SYMBOL(hpsb_update_config_rom_image);/** ieee1394_core.c **/EXPORT_SYMBOL(hpsb_speedto_str);EXPORT_SYMBOL(hpsb_set_packet_complete_task);EXPORT_SYMBOL(hpsb_alloc_packet);EXPORT_SYMBOL(hpsb_free_packet);EXPORT_SYMBOL(hpsb_send_phy_config);EXPORT_SYMBOL(hpsb_send_packet);EXPORT_SYMBOL(hpsb_send_packet_and_wait);EXPORT_SYMBOL(hpsb_reset_bus);EXPORT_SYMBOL(hpsb_bus_reset);EXPORT_SYMBOL(hpsb_selfid_received);EXPORT_SYMBOL(hpsb_selfid_complete);EXPORT_SYMBOL(hpsb_packet_sent);EXPORT_SYMBOL(hpsb_packet_received);/** ieee1394_transactions.c **/EXPORT_SYMBOL(hpsb_get_tlabel);EXPORT_SYMBOL(hpsb_free_tlabel);EXPORT_SYMBOL(hpsb_make_readpacket);EXPORT_SYMBOL(hpsb_make_writepacket);EXPORT_SYMBOL(hpsb_make_streampacket);EXPORT_SYMBOL(hpsb_make_lockpacket);EXPORT_SYMBOL(hpsb_make_lock64packet);EXPORT_SYMBOL(hpsb_make_phypacket);EXPORT_SYMBOL(hpsb_make_isopacket);EXPORT_SYMBOL(hpsb_read);EXPORT_SYMBOL(hpsb_write);EXPORT_SYMBOL(hpsb_lock);EXPORT_SYMBOL(hpsb_lock64);EXPORT_SYMBOL(hpsb_send_gasp);EXPORT_SYMBOL(hpsb_packet_success);/** highlevel.c **/EXPORT_SYMBOL(hpsb_register_highlevel);EXPORT_SYMBOL(hpsb_unregister_highlevel);EXPORT_SYMBOL(hpsb_register_addrspace);EXPORT_SYMBOL(hpsb_unregister_addrspace);EXPORT_SYMBOL(hpsb_allocate_and_register_addrspace);EXPORT_SYMBOL(hpsb_listen_channel);EXPORT_SYMBOL(hpsb_unlisten_channel);EXPORT_SYMBOL(hpsb_get_hostinfo);EXPORT_SYMBOL(hpsb_get_host_bykey);EXPORT_SYMBOL(hpsb_create_hostinfo);EXPORT_SYMBOL(hpsb_destroy_hostinfo);EXPORT_SYMBOL(hpsb_set_hostinfo_key);EXPORT_SYMBOL(hpsb_get_hostinfo_key);EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);EXPORT_SYMBOL(hpsb_set_hostinfo);EXPORT_SYMBOL(highlevel_read);EXPORT_SYMBOL(highlevel_write);EXPORT_SYMBOL(highlevel_lock);EXPORT_SYMBOL(highlevel_lock64);EXPORT_SYMBOL(highlevel_add_host);EXPORT_SYMBOL(highlevel_remove_host);EXPORT_SYMBOL(highlevel_host_reset);/** nodemgr.c **/EXPORT_SYMBOL(hpsb_guid_get_entry);EXPORT_SYMBOL(hpsb_nodeid_get_entry);EXPORT_SYMBOL(hpsb_node_fill_packet);EXPORT_SYMBOL(hpsb_node_read);EXPORT_SYMBOL(hpsb_node_write);EXPORT_SYMBOL(hpsb_node_lock);EXPORT_SYMBOL(hpsb_register_protocol);EXPORT_SYMBOL(hpsb_unregister_protocol);EXPORT_SYMBOL(ieee1394_bus_type);EXPORT_SYMBOL(nodemgr_for_each_host);/** csr.c **/EXPORT_SYMBOL(hpsb_update_config_rom);/** dma.c **/EXPORT_SYMBOL(dma_prog_region_init);EXPORT_SYMBOL(dma_prog_region_alloc);EXPORT_SYMBOL(dma_prog_region_free);EXPORT_SYMBOL(dma_region_init);EXPORT_SYMBOL(dma_region_alloc);EXPORT_SYMBOL(dma_region_free);EXPORT_SYMBOL(dma_region_sync_for_cpu);EXPORT_SYMBOL(dma_region_sync_for_device);EXPORT_SYMBOL(dma_region_mmap);EXPORT_SYMBOL(dma_region_offset_to_bus);/** iso.c **/EXPORT_SYMBOL(hpsb_iso_xmit_init);EXPORT_SYMBOL(hpsb_iso_recv_init);EXPORT_SYMBOL(hpsb_iso_xmit_start);EXPORT_SYMBOL(hpsb_iso_recv_start);EXPORT_SYMBOL(hpsb_iso_recv_listen_channel);EXPORT_SYMBOL(hpsb_iso_recv_unlisten_channel);EXPORT_SYMBOL(hpsb_iso_recv_set_channel_mask);EXPORT_SYMBOL(hpsb_iso_stop);EXPORT_SYMBOL(hpsb_iso_shutdown);EXPORT_SYMBOL(hpsb_iso_xmit_queue_packet);EXPORT_SYMBOL(hpsb_iso_xmit_sync);EXPORT_SYMBOL(hpsb_iso_recv_release_packets);EXPORT_SYMBOL(hpsb_iso_n_ready);EXPORT_SYMBOL(hpsb_iso_packet_sent);EXPORT_SYMBOL(hpsb_iso_packet_received);EXPORT_SYMBOL(hpsb_iso_wake);EXPORT_SYMBOL(hpsb_iso_recv_flush);/** csr1212.c **/EXPORT_SYMBOL(csr1212_create_csr);EXPORT_SYMBOL(csr1212_init_local_csr);EXPORT_SYMBOL(csr1212_new_immediate);EXPORT_SYMBOL(csr1212_new_leaf);EXPORT_SYMBOL(csr1212_new_csr_offset);EXPORT_SYMBOL(csr1212_new_directory);EXPORT_SYMBOL(csr1212_associate_keyval);EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);EXPORT_SYMBOL(csr1212_new_extended_immediate);EXPORT_SYMBOL(csr1212_new_extended_leaf);EXPORT_SYMBOL(csr1212_new_descriptor_leaf);EXPORT_SYMBOL(csr1212_new_textual_descriptor_leaf);EXPORT_SYMBOL(csr1212_new_string_descriptor_leaf);EXPORT_SYMBOL(csr1212_new_icon_descriptor_leaf);EXPORT_SYMBOL(csr1212_new_modifiable_descriptor_leaf);EXPORT_SYMBOL(csr1212_new_keyword_leaf);EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);EXPORT_SYMBOL(csr1212_disassociate_keyval);EXPORT_SYMBOL(csr1212_release_keyval);EXPORT_SYMBOL(csr1212_destroy_csr);EXPORT_SYMBOL(csr1212_read);EXPORT_SYMBOL(csr1212_generate_positions);EXPORT_SYMBOL(csr1212_generate_layout_order);EXPORT_SYMBOL(csr1212_fill_cache);EXPORT_SYMBOL(csr1212_generate_csr_image);EXPORT_SYMBOL(csr1212_parse_keyval);EXPORT_SYMBOL(csr1212_parse_csr);EXPORT_SYMBOL(_csr1212_read_keyval);EXPORT_SYMBOL(_csr1212_destroy_keyval);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?