资源简介
linux内核中断实例,可能通过模块参数插入指定的中断中
代码片段和文件信息
#include
#include
#include
#include
static int irq;
static char *devname;
static struct tasklet_struct mytasklet;
module_param(irq int 0644);
module_param(devname charp 0644);
struct myirq
{
int devid;
};
struct myirq mydev={1119};
static void mytasklet_handler(unsigned long data)
{
printk(“tasklet is working..\n“);
}
static irqreturn_t myirq_handler(int irq void *dev)
{
struct myirq mydev;
static int count =0;
mydev=*(struct myirq*)dev;
printk(“key:%d..\n“count+1);
printk(“devid:%d ISR is working..\n“mydev.devid);
printk(“Bottom half will be working..\n“);
tasklet_init(&mytasklet mytasklet_handler0);
tasklet_schedule(&mytasklet);
printk(“ISR is leaving“);
count++;
return IRQ_HANDLED;
}
static int __init myirq_init(void)
{
printk(“Module is working..\n“);
if(request_irq(irq myirq_handler IRQF_SHARED devname &mydev)!=0)
{
printk(“%s request IRQ:%d failed..\n“devnameirq);
return -1;
}
printk(“%s rquest IRQ:%d success..\n“devnameirq);
return 0;
}
static void __exit myirq_exit(void)
{
printk(“Module is leaving“);
free_irq(irq &mydev);
printk(“%s request IRQ :%d success...\n“devname irq);
}
module_init(myirq_init);
module_exit(myirq_exit);
MODULE_LICENSE(“GPL“);
- 上一篇:数据库系统课程设计——银行管理系统
- 下一篇:origin8.0 中文版 破解方法
评论
共有 条评论