[英]Adding Interrupt service routine in kernel
I am trying to add a switch/GPIO interrupt. 我正在尝试添加一个开关/ GPIO中断。 I want to write it as part of kernel source tree.
我想将其编写为内核源代码树的一部分。 After building the kernel image and deploying to my custom board it has to appear in proc/interrupts.
构建内核映像并部署到我的自定义板后,它必须以proc / interrupts的形式出现。 I have already written the module and it is working if do insmod.
我已经写了模块,如果执行insmod,它就可以正常工作。 Instead of compiling separately i want it to be a part of my kernel tree.
与其单独编译,我不希望它成为内核树的一部分。 What are the steps to add the irq to kernel source.
将irq添加到内核源代码的步骤是什么。
Actually if you have written the module inside the kernel tree, it is pretty straightforward: 实际上,如果您已在内核树中编写了模块,则非常简单:
Lets say you put the source code in drivers directory, so the hierarchy looks as follows: drivers/hello Kconfig Makefile hello.c 可以说您将源代码放置在drivers目录中,因此层次结构如下所示:drivers / hello Kconfig Makefile hello.c
In drivers/Makefile you should add the following: 在驱动程序/ Makefile中,应添加以下内容:
obj-$(CONFIG-HELLO) += hello/
In drivers/Kconfig you should add the following: 在drivers / Kconfig中,应添加以下内容:
source "drivers/hello/Kconfig"
Sample code for drivers/hello/Kconfig: 驱动程序/ hello / Kconfig的示例代码:
config HELLO
tristate "Hello world module"
default n
help
Enable Hello world module support
Sample code for drivers/hello/Makefile: 驱动程序/ hello / Makefile的示例代码:
obj-$(CONFIG_HELLO) += hello.o
Sample code for drivers/hello.c: drivers / hello.c的示例代码:
#include <linux/module.h>
#include <linux/moduleparam.h>
...
...
static int __init hello_init(void)
{
...
}
static void __exit hello_exit(void)
{
...
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("Obi One Kenoby");
MODULE_DESCRIPTION("Hello Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
Now you should be able to see the hello module in make menuconfig - select 'm' for module and '*' for built in. the module_init/module_exit macros works with both options. 现在,您应该可以在make menuconfig中看到hello模块-为模块选择“ m”,为内置选择“ *”。module_init / module_exit宏可同时使用这两个选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.