首页 / LINUX / Linux驱动知识:中断
Linux驱动知识:中断
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux驱动知识:中断,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2629字,纯文字阅读大概需要4分钟。
内容图文
![Linux驱动知识:中断](/upload/InfoBanner/zyjiaocheng/970/df4597b361174d2dbbf7abce21985169.jpg)
These symbols related to interrupt management were introduced in this chapter:
#include <linux/interrupt.h>
int request_irq(unsigned int irq, irqreturn_t (*handler)( ), unsigned long flags, const char *dev_name, void *dev_id);
void free_irq(unsigned int irq, void *dev_id);
Calls that register and unregister an interrupt handler.
dev_name为显示在/proc/interrupts中的名字
dev_id为回调中断处理程序时所给的参数,通常为本地dev结构的地址指针。
#include <linux/irq.h.h> int can_request_irq(unsigned int irq, unsigned long flags);
This function, available on the i386 and x86_64 architectures, returns a nonzero value if an attempt to allocate the given interrupt line succeeds.
#include <asm/signal.h> SA_INTERRUPT SA_SHIRQ SA_SAMPLE_RANDOM
Flags for request_irq. SA_INTERRUPT requests installation of a fast handler (as opposed to a slow one). SA_SHIRQ installs a shared handler, and the third flag asserts that interrupt timestamps can be used to generate system entropy.
Modern hardware, of course, has been designed to allow the sharing of interrupts; the PCI bus requires it.
/proc/interrupts /proc/stat
Filesystem nodes that report information about hardware interrupts and installed handlers.
unsigned long probe_irq_on(void); int probe_irq_off(unsigned long);
Functions used by the driver when it has to probe to determine which interrupt line is being used by a device. The result of probe_irq_onmust be passed back to probe_irq_off after the interrupt has been generated. The return value of probe_irq_off is the detected interrupt number.
The programmer should be careful to enable interrupts on the device after the call to probe_irq_on and to disable them before callingprobe_irq_off
IRQ_NONE IRQ_HANDLED IRQ_RETVAL(int x)
The possible return values from an interrupt handler, indicating whether an actual interrupt from the device was present.
void disable_irq(int irq); //关中断且等待当前的中断处理程序完成 void disable_irq_nosync(int irq); //不等待,有风险 void enable_irq(int irq);
A driver can enable and disable interrupt reporting. If the hardware tries to generate an interrupt while interrupts are disabled, the interrupt is lost forever. A driver using a shared handler must not use these functions.
void local_irq_save(unsigned long flags); void local_irq_restore(unsigned long flags);
Use local_irq_save to disable interrupts on the local processor and remember their previous state. The flags can be passed to local_irq_restore to restore the previous interrupt state.
void local_irq_disable(void); void local_irq_enable(void);
Functions that unconditionally disable and enable interrupts on the current processor.
内容总结
以上是互联网集市为您收集整理的Linux驱动知识:中断全部内容,希望文章能够帮你解决Linux驱动知识:中断所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。