相关数据结构介绍
先来看跟中断处理体系相关的三个数据结构(我们抽取出主要的部分,实际上不止这些成员,详细看include/linux/irq.h):
1
struct irq_desc {
irq_flow_handler_t handle_irq; /*当前中断的处理函数入口*/
struct irq_chip *chip; /*低层的硬件访问*/
struct irqaction *action; /* IRQ action list 用户提供的中断处理*/
unsigned int status; /* IRQ status IRQ状态 */
const char *name; /*中断名称*/
} ____cacheline_internodealigned_in_smp;
2
struct irqaction {
irq_handler_t handler; /*用户注册的中断处理函数*/
unsigned long flags; /*中断标志,比如是否共享中断,电平触发还是边沿触发*/
cpumask_t mask; /*用于对称处理器系统*/
const char *name; /*用户注册的中断名字,cat/proc/interrupts可看到*/
void *dev_id; /*用户传给上面的handler参数,还可以用来区分共享中断*/
struct irqaction *next;
int irq; /*中断号*/
struct proc_dir_entry *dir;
};
3
struct irq_chip {
const char *name; /*名字*/
unsigned int (*startup)(unsigned int irq); /*启动中断,如果不设置,缺省为"enable"*/
void (*shutdown)(unsigned int irq); /*关闭中断,如果不设置,缺省为"disable"*/
void (*enable)(unsigned int irq); /*使能中断,如果不设置,缺省为"