linux-kernel – 编写基本键盘中断处理程序,抛出“Unknown key r
发布时间:2020-12-14 01:45:13 所属栏目:Linux 来源:网络整理
导读:我写了一个基本的键盘中断处理程序.它使用共享中断,用于打印到按下键的/ var / log / messages.但是当我尝试使用箭头键时,我得到以下错误,其余的键工作正常. 8月19日18:59:06 vim内核:[112.485102] atkbd serio0:释放未知密钥(翻译集2,代码0xe0在isa0060 /
我写了一个基本的键盘中断处理程序.它使用共享中断,用于打印到按下键的/ var / log / messages.但是当我尝试使用箭头键时,我得到以下错误,其余的键工作正常.
8月19日18:59:06 vim内核:[112.485102] atkbd serio0:释放未知密钥(翻译集2,代码0xe0在isa0060 / serio0上). 粘贴代码. #include <linux/kernel.h> #include <linux/module.h> #include <linux/interrupt.h> #include <asm/io.h> /* This function services keyboard interrupts */ irq_handler_t irq_handler (int irq,void *dev_id,struct pt_regs *regs) { static unsigned char scancode; /* Read keyboard status */ scancode = inb (0x60); if ((scancode == 0x01) || (scancode == 0x81)) { printk ("You pressed Esc !n"); } } return (irq_handler_t) IRQ_HANDLED; } /* Initialize the module and Register the IRQ handler */ static int __init keybrd_int_register(void) { int result; /* Request IRQ 1,the keyboard IRQ */ result = request_irq (1,(irq_handler_t) irq_handler,IRQF_SHARED,"keyboard_stats_irq",(void *)(irq_handler)); if (result) printk(KERN_INFO "can't get shared interrupt for keyboardn"); return result; } /* Remove the interrupt handler */ static void __exit keybrd_int_unregister(void) { free_irq(1,(void *)(irq_handler)); /* i can't pass NULL,this is a shared interrupt handler! */ } MODULE_LICENSE ("GPL"); module_init(keybrd_int_register); module_exit(keybrd_int_unregister); 任何人都可以给我一些线索,为什么这个箭头键停止工作当我插入我的模块并开始工作乳清我删除它们? 我正在虚拟机上运行我的代码. 解决方法
原因是由于某些VM搞砸了.它在基本Linux主机上运行良好.你可以看到完整的代码实现(天真)@
https://github.com/vigith/Linux-Device-Drivers/tree/master/keyboard
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |