将驱动程序编译为内核的一部分,而不是模块 [英] Compiling a driver as a part of a kernel, not as a module

查看:271
本文介绍了将驱动程序编译为内核的一部分,而不是模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为嵌入式设备创建一个简约的Linux。这意味着编译内核和驱动程序的必要性。一个驱动程序由它的创建者直接写入设备的板,因此它不是存储库。它可以编译为内核模块。



然而,由于Linux的不可变性和对内存使用极小的要求,我不想使用模块。我想要所有的驱动程序内置在内核中。所以我的问题是如何编译一个特殊的驱动程序到内核?



所有搜索都没有为我提供解决方案 - 所有的都只是作为模块编译。



感谢您的帮助。

解决方案

必须将驱动程序源放在内核源代码树中,并更新makefile以包含它。您可以在此处的步骤1.1到1.3中查看此功能的工作原理。 p>

如果用户级软件与设备驱动程序进行任何交谈,它可能通过系统调用。搜索通过驱动程序寻找 asmlinkage 如果你发现任何这些,那么你正在看到添加一些系统调用的源。上述文档的其余部分将解释如何设置它们。您必须至少修改两个文件(根据您的内核版本,它们可能略有不同)。



如果设备驱动程序直接与内核交谈,我们正在处理中断,内存映射I / O或DMA。老实说,我不知道他们是否可以在你的驱动程序的源文件中处理(在这种情况下你是好去做),或者他们是否还需要修改源树中的其他文件。 是一个很好的资源。



好运


I am trying to create a minimalistic Linux for an embedded device. That means the necessity of compiling kernel and drivers. One driver is written directly for the device's board by it's creator, so it is not a repository one. It can be compiled as a kernel module.

However because of immutable nature of the Linux and requirement of extremely small use of memory I do not want to use modules. I want all drivers built-in in the kernel. And all drivers provided with kernel I have set this way.

So my problem is how to compile that one special driver to the kernel?

All searching have not provided me with a solution - all are only about compiling as modules.

Thanks for any help.

解决方案

You're definitely going to have to put the driver source in the kernel source tree and update the makefile to include it. You can see how this works in steps 1.1 through 1.3 here.

If user-level software does any talking with the device driver it probably does it via system calls. Search through the source of the driver looking for asmlinkage if you find any of these then you're looking at adding some system calls. The remainder of the above document will explain how to set them up. You'll have to modify at least two files (and they might vary slightly depending on your kernel version).

If the device driver does any talking with the kernel directly, we're dealing with Interrupts, Memory Mapped I/O, or DMA. To be honest with you I do not know whether they can be handled within the source file for your driver (in which case you're good do go), or whether they also require modifying other files in the source tree. This is a good resource for such things.

Good Luck

这篇关于将驱动程序编译为内核的一部分,而不是模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆