QUOTE: |
int request_irq(unsigned int irq,irqreturn_t (*handler)(int, void *, struct pt_regs *),?unsigned long flags, const char *dev_name,void *dev_id); void free_irq(unsigned int irq, void *dev_id); |
QUOTE: |
irqreturn_t short_interrupt(int irq, void *dev_id, struct pt_regs *regs) { static long mytime=0; static int i=0; struct net_device *dev=(struct net_device *)dev_id; if(i==0){ mytime=jiffies; }else if(i<20){ mytime =jiffies- mytime; printk("Request on IRQ %d time %d\n",irq , mytime); mytime=jiffies; printk("Interrupt on %s -----%d \n",dev->name,dev->irq); } i++; return IRQ_HANDLED; } |
QUOTE: |
/* irqreturn.h */ #ifndef _Linux_IRQRETURN_H #define _Linux_IRQRETURN_H typedef int irqreturn_t; /* * For 2.4.x compatibility, 2.4.x can use * * typedef void irqreturn_t; * #define IRQ_NONE * #define IRQ_HANDLED * #define IRQ_RETVAL(x) *……此處我刪去了部分關緊要的內容 * To mix old-style and new-style irq handler returns. * * IRQ_NONE means we didn't handle it. * 中斷程序接收到中斷信號后發現這並不是註冊時指定的中斷原發出的中斷信號. *此時返回次值 * IRQ_HANDLED means that we did have a valid interrupt and handled it. * 接收到了準確的中斷信號,並且作了相應正確的處理 * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled) */ #define IRQ_NONE (0) #define IRQ_HANDLED (1) #define IRQ_RETVAL(x) ((x) != 0) //這個宏只是返回0或非0 #endif |
[火星人 ] linux中斷的註冊與釋放已經有540次圍觀