02.07.2013 Views

kernel 里面的中断代码分析

kernel 里面的中断代码分析

kernel 里面的中断代码分析

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#endif<br />

unsigned int move_irq; /* need to re-target IRQ dest */<br />

#ifdef CONFIG_PROC_FS<br />

#endif<br />

struct proc_dir_entry *dir;<br />

} ____cacheline_aligned;<br />

重点分析 request_irq() 函数和 setup_irq() 函数 跟移植有关系的部分 。<br />

Kernel/irq/manage.c =>request_irq()<br />

int request_irq(unsigned int irq,<br />

{<br />

irqreturn_t (*handler)(int, void *, struct pt_regs *),<br />

unsigned long irqflags, const char *devname, void *dev_id)<br />

struct irqaction *action;<br />

int retval;<br />

#ifdef CONFIG_LOCKDEP<br />

/*<br />

#endif<br />

* Lockdep wants atomic interrupt handlers:<br />

*/<br />

irqflags |= SA_INTERRUPT;<br />

/*<br />

* Sanity-check: shared interrupts must pass in a real dev-ID,<br />

* otherwise we'll have trouble later trying to figure out<br />

* which interrupt is which (messes up the interrupt freeing<br />

* logic etc).<br />

*/<br />

if ((irqflags & IRQF_SHARED) && !dev_id)<br />

return -EINVAL;<br />

if (irq >= NR_IRQS)<br />

return -EINVAL;<br />

if (irq_desc[irq].status & IRQ_NOREQUEST) //这个要初始化,否则无法 request_irq , 显然这里应该在 <strong>kernel</strong> 启动的<br />

过程调用 irq 相关的函数进行初始化<br />

return -EINVAL;<br />

if (!handler)<br />

return -EINVAL;<br />

action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!