02.07.2013 Views

kernel 里面的中断代码分析

kernel 里面的中断代码分析

kernel 里面的中断代码分析

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if (irq >= NR_IRQS)<br />

return -EINVAL;<br />

if (desc->chip == &no_irq_chip) //这里很很关键<br />

/*<br />

return -ENOSYS; //功能没有实现<br />

* Some drivers like serial.c use request_irq() heavily,<br />

* so we have to be careful not to interfere with a<br />

* running system.<br />

*/<br />

if (new->flags & IRQF_SAMPLE_RANDOM) {<br />

}<br />

/*<br />

/*<br />

* This function might sleep, we want to call it first,<br />

* outside of the atomic block.<br />

* Yes, this might clear the entropy pool if the wrong<br />

* driver is attempted to be loaded, without actually<br />

* installing a new handler, but is this really a problem,<br />

* only the sysadmin is able to do this.<br />

*/<br />

rand_initialize_irq(irq);<br />

* The following block of code has to be executed atomically<br />

*/<br />

spin_lock_irqsave(&desc->lock, flags);<br />

// ----------------------------------------------------------------------------------------------------<br />

p = &desc->action;<br />

old = *p;<br />

if (old) {<br />

/*<br />

* Can't share interrupts unless both agree to and are<br />

* the same type (level, edge, polarity). So both flag<br />

* fields must have IRQF_SHARED set and the bits which<br />

* set the trigger type must match.<br />

*/<br />

if (!((old->flags & new->flags) & IRQF_SHARED) ||<br />

((old->flags ^ new->flags) & IRQF_TRIGGER_MASK))<br />

goto mismatch;

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

Saved successfully!

Ooh no, something went wrong!