irq_desc ,irqaction, hw_interrupt_type
/*
* This is the "IRQ descriptor", which contains various information
* about the irq, including what kind of hardware handling it has,
* whether it is disabled etc etc.
*
* Pad this out to 32 bytes for cache and indexing reasons.
*/
typedef struct irq_desc {
hw_irq_controller *handler; 结构体指针
void *handler_data;
struct irqaction *action; /* IRQ action list */指向一个有irqaction结构体组成的一个单向链表的头的指针
unsigned int status; /* IRQ status */ irq是否被禁止
unsigned int depth; /* nested irq disables */当前用户个数
unsigned int irq_count; /* For detecting broken interrupts */
unsigned int irqs_unhandled;
spinlock_t lock;
#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
unsigned int move_irq; /* Flag need to re-target intr dest*/
#endif
} ____cacheline_aligned irq_desc_t;
-------------------------------------------------------------------------------------------
数组irq_desc[NR_IRQS]描述中断源。
数组中的每一项都对应着中断向量表中的一项,该数组的第一项就对应着中断向量表中的第32项,(0x20)。
----------------------------------------------------------------------------------------------
struct irqaction {
irqreturn_t (*handler)(int, void *, struct pt_regs *); //中断发生时,相应的hander指向的中断处理程序
unsigned long flags;
cpumask_t mask;
const char *name;
void *dev_id;
struct irqaction *next;
int irq;
struct proc_dir_entry *dir;
};
--------------------------------------------------------------------------------------------------
该结构体包含处理一种中断所需要的各种信息,代表了内核接收到的特定的IRQ之后应该采取的操作。
------------------------------------------------------------------------------------------------------------------------------
/*
* Interrupt controller descriptor. This is all we need
* to describe about the low-level hardware.
*/
struct hw_interrupt_type {
const char * typename;
unsigned int (*startup)(unsigned int irq);
void (*shutdown)(unsigned int irq);
void (*enable)(unsigned int irq);
void (*disable)(unsigned int irq);
void (*ack)(unsigned int irq);
void (*end)(unsigned int irq);
void (*set_affinity)(unsigned int irq, cpumask_t dest);
/* Currently used only by UML, might disappear one day.*/
#ifdef CONFIG_IRQ_RELEASE_METHOD
void (*release)(unsigned int irq, void *dev_id);
#endif
};
typedef struct hw_interrupt_type hw_irq_controller;
用来描述中断控制器,是一个抽象的。里面的成员是一系列指向函数的指针。
========================================================================
x86体系中,linux采用的中断控制器是8259A芯片,如下为控制器具体成员的定义:
static struct hw_interrupt_type i8259A_irq_type = {
.typename = "XT-PIC",
.startup = startup_8259A_irq,
.shutdown = shutdown_8259A_irq,
.enable = enable_8259A_irq,
.disable = disable_8259A_irq,
.ack = mask_and_ack_8259A,
.end = end_8259A_irq,
};
阅读(1858) | 评论(0) | 转发(0) |