中断函数和printk()

yongyuan10cn 2007-01-04 07:57:16
1,中断处理函数的返回值和形参类型都必须是void吗?
2,printk()函数是内核的打印,可以在终端上打印出来吗?
谢谢!
...全文
710 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
joyself 2007-01-05
  • 打赏
  • 举报
回复
看看 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.


yongyuan10cn 2007-01-04
  • 打赏
  • 举报
回复
那关于中断函数的呢,继续请教
jiangyue009 2007-01-04
  • 打赏
  • 举报
回复
printk的信息可以在终端显示

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧