您的位置:程序门 -> linux/unix社区 -> 内核及驱动程序研究区



中断函数和printk()


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


中断函数和printk()
发表于:2007-01-04 19:57:16 楼主
1,中断处理函数的返回值和形参类型都必须是void吗?
2,printk()函数是内核的打印,可以在终端上打印出来吗?
谢谢!
发表于:2007-01-04 21:43:081楼 得分:0
printk的信息可以在终端显示
发表于:2007-01-04 21:57:432楼 得分:0
那关于中断函数的呢,继续请教
发表于:2007-01-05 09:53:023楼 得分:0
看看   2.4和   2.6的内核的request_irq原型就知道了。

2.4:
int   request_irq(unsigned   int   irq,
                                void   (*handler)(int,   void   *,   struct   pt_regs   *),
                                unsigned   long   flags,
                                const   char   *dev_name,
                                void   *dev_id);

2.6:
int   request_irq(unsigned   int   irq,
                                irqreturn_t   (*handler)(int,   void   *,   struct   pt_regs   *),
                                unsigned   long   flags,  
                                const   char   *dev_name,
                                void   *dev_id);

下面是ldd3(2.6kernel)上摘录下来的:

interrupt   handlers   should   return   a   value   indicating   whether   there   was   actually   an   interrupt   to   handle.   if   the   handler   found   that   its   device   did,   indeed,   need   attention,   it   should   return   irq_handled;   otherwise   the   return   value   should   be   irq_none.   you   can   also   generate   the   return   value   with   this   macro:

irq_retval(handled)
where   handled   is   nonzero   if   you   were   able   to   handle   the   interrupt.   the   return   value   is   used   by   the   kernel   to   detect   and   suppress   spurious   interrupts.   if   your   device   gives   you   no   way   to   tell   whether   it   really   interrupted,   you   should   return   irq_handled.




快速检索

最新资讯
热门点击