设为首页 加入收藏

TOP

Linux 中断学习之小试牛刀篇(七)
2014-11-24 07:26:15 来源: 作者: 【 】 浏览:2
Tags:Linux 中断 习之 小试牛刀
void (*bus_lock)(unsigned int irq);
132 void (*bus_sync_unlock)(unsigned int irq);
133
134 /* Currently used only by UML, might disappear one day.*/
135#ifdef CONFIG_IRQ_RELEASE_METHOD
136 void (*release)(unsigned int irq, void *dev_id);
137#endif
138 /*
139 * For compatibility, ->typename is copied into ->name.
140 * Will disappear.
141 */
142 const char *typename;
143};
144



name:中断控制器的名字;
Startup:启动中断线;
Shutdown:关闭中断线;
Enable:允许中断;
Disable:禁止中断;


分析了struct irq_desc,struct irq_chip和irqaction的数据结构之后我们来看看他们之间的关系 。



现在深入分析request_irq()内部是如何实现的。


135request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
136 const char *name, void *dev)
137{
138 return request_threaded_irq(irq, handler, NULL, flags, name, dev);
139}
140
135request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
136 const char *name, void *dev)
137{
138 return request_threaded_irq(irq, handler, NULL, flags, name, dev);
139}
140


可以看到request_irq()函数里面有封装了request_threaded_irq(irq, handler, NULL, flags, name, dev)函数。


先看一下官方的解释


1006/**
1007 * request_threaded_irq - allocate an interrupt line
1008 * @irq: Interrupt line to allocate
1009 * @handler: Function to be called when the IRQ occurs.
1010 * Primary handler for threaded interrupts
1011 * If NULL and thread_fn != NULL the default
1012 * primary handler is installed
1013 * @thread_fn: Function called from the irq handler thread
1014 * If NULL, no irq thread is created
1015 * @irqflags: Interrupt type flags
1016 * @devname: An ascii name for the claiming device
1017 * @dev_id: A cookie passed back to the handler function
1018 *
1019 * This call allocates interrupt resources and enables the
1020 * interrupt line and IRQ handling. From the point this
1021 * call is made your handler function may be invoked. Since
1022 * your handler function must clear any interrupt the board
1023 * raises, you must take care both to initialise your hardware
1024 * and to set up the interrupt handler in the right order.
1025 *
1026 * If you want to set up a threaded irq handler for your device
1027 * then you need to supply @handler and @thread_fn. @handler ist
1028 * still called in hard interrupt context and has to check
1029 * whether the interrupt originates from the device. If yes it
1030 * needs to disable the interrupt on the device and return
1031 * IRQ_WAKE_THREAD which will wake up the handler thread and run
1032 * @thread_fn. This split handler design is necessary to support
1033 * shared interrupts.
1034 *
1035 * Dev_id must be globally unique. Normally the address of the
1036 * device data structure is used as the cookie. Since the handler
1037 * receives this value it makes sense to use it.
1038 *
1039 * If your interrupt is shared you must pass a non NULL dev_id
1040 * as this is required when freeing the interrupt.
1041 *
1042 * Flags:
1043 *
1044 * IRQF_SHARED Interrupt is shared
1045 * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy
1046 * IRQF_TRIGGER_* Specify active edge(s) or level
1047 *
1048 */
1006/**
1007 * request_thr

首页 上一页 4 5 6 7 8 9 10 下一页 尾页 7/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux 中断学习之前言篇 中断之原.. 下一篇Linux之Git工具的使用

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·数据库:推荐几款 Re (2025-12-25 12:17:11)
·如何最简单、通俗地 (2025-12-25 12:17:09)
·什么是Redis?为什么 (2025-12-25 12:17:06)
·对于一个想入坑Linux (2025-12-25 11:49:07)
·Linux 怎么读? (2025-12-25 11:49:04)