中断
2017-03-27 12:43:05 0 举报
中断,通常指的是在正在进行的活动中突然发生的、需要立即处理的事件。这种事件可能是外部的,如电话铃声、门铃声等,也可能是内部的,如身体的疼痛、思绪的混乱等。中断会打断原有的流程,使人们不得不暂时放下手头的工作,去处理这个突发事件。虽然中断可能会带来一定的困扰,但它也是生活中不可避免的一部分。通过妥善处理中断,我们可以更好地平衡工作和生活,提高效率和生活质量。
作者其他创作
大纲/内容
*next
data
中断触发后会调用到该函数,该函数会遍历action链表,然后执行我们注册的中断处理函数
操作硬件的
struct irq_data {\tu32\t\t\tmask;\tunsigned int\t\tirq;\tunsigned long\t\thwirq;\tunsigned int\t\tnode;\tunsigned int\t\tstate_use_accessors;\tstruct irq_chip\t\t*chip; 中断控制器硬件驱动\tstruct irq_domain\t*domain;\tvoid\t\t\t*handler_data;\tvoid\t\t\t*chip_data;\tstruct msi_desc\t\t*msi_desc;\tcpumask_var_t\t\taffinity;};
硬件驱动信息
irq_desc_tree
注册的中断号
request_irq()
中断函数-中断触发首先调用它
action是一个链表
内核维护所有中断
struct irq_desc {\tstruct irq_data\t\tirq_data;\tunsigned int __percpu\t*kstat_irqs;\tirq_flow_handler_t\thandle_irq;#ifdef CONFIG_IRQ_PREFLOW_FASTEOI\tirq_preflow_handler_t\tpreflow_handler;#endif /*我们注册的信息都放在该结构体中,是一个链表,*/\tstruct irqaction\t*action;\t/* IRQ action list */\tunsigned int\t\tstatus_use_accessors;\tunsigned int\t\tcore_internal_state__do_not_mess_with_it;\tunsigned int\t\tdepth;\t\t/* nested irq disables */\tunsigned int\t\twake_depth;\t/* nested wake enables */\tunsigned int\t\tirq_count;\t/* For detecting broken IRQs */\tunsigned long\t\tlast_unhandled;\t/* Aging timer for unhandled count */\tunsigned int\t\tirqs_unhandled;\traw_spinlock_t\t\tlock;\tstruct cpumask\t\t*percpu_enabled;#ifdef CONFIG_SMP\tconst struct cpumask\t*affinity_hint;\tstruct irq_affinity_notify *affinity_notify;#ifdef CONFIG_GENERIC_PENDING_IRQ\tcpumask_var_t\t\tpending_mask;#endif#endif\tunsigned long\t\tthreads_oneshot;\tatomic_t\t\tthreads_active;\twait_queue_head_t wait_for_threads;#ifdef CONFIG_PROC_FS\tstruct proc_dir_entry\t*dir;#endif\tint\t\t\tparent_irq;\tstruct module\t\t*owner;\tconst char\t\t*name;} ____cacheline_internodealigned_in_smp;
struct irqaction {\tirq_handler_t\t\thandler;\tvoid\t\t\t*dev_id;\tvoid __percpu\t\t*percpu_dev_id;\tstruct irqaction\t*next;\tirq_handler_t\t\tthread_fn;\tstruct task_struct\t*thread;\tunsigned int\t\tirq;\tunsigned int\t\tflags;\tunsigned long\t\tthread_flags;\tunsigned long\t\tthread_mask;\tconst char\t\t*name;\tstruct proc_dir_entry\t*dir;} ____cacheline_internodealigned_in_smp;
我们注册的信息都放在该结构体中,是一个链表
中断号对应一个下标
这是我们注册的中断处理函数
struct irqaction {\tirq_handler_t\t\thandler;\tvoid\t\t\t*dev_id;\tvoid __percpu\t\t*percpu_dev_id;\tstruct irqaction\t*next;\tirq_handler_t\t\tthread_fn;\tstruct task_struct\t*thread;\tunsigned int\t\tirq;\tunsigned int\t\tflags;} ____
struct irq_desc {\tstruct irq_data\t\tirq_data;\tunsigned int __percpu\t*kstat_irqs;\tirq_flow_handler_t\thandle_irq; struct irqaction *action; /* IRQ action list */}
struct irq_chip {\tconst char\t*name;\tunsigned int\t(*irq_startup)(struct irq_data *data);\tvoid\t\t(*irq_shutdown)(struct irq_data *data);\tvoid\t\t(*irq_enable)(struct irq_data *data);\tvoid\t\t(*irq_disable)(struct irq_data *data);
这是我们注册的共享中断
per irq and chip data passed down to chip functions
名字
硬件驱动
这里蓝色线条指示了函数遍历链表的过程
最后一个指向NULL
struct irq_chip\t\t*chip;
收藏
收藏
0 条评论
下一页