Linux 内核/驱动程序开发新手
最近,我开始开发运行Linux的嵌入式设备的驱动程序。
到目前为止,我只阅读有关 Linux 内部结构的内容。
由于没有驱动程序开发经验,我发现迈出第一步有点困难。
- 我已经下载了内核源代码(v2.6.32)。
- 我已阅读(略读)Linux 设备驱动程序 (3e)
- 我在 StackOverflow 上阅读了一些相关帖子。
- 我知道linux有一个“整体”方法。
- 我已经构建了内核(包括 menuconfig 等中的现有驱动程序)
- 我知道 kconfig 和 makefile 文件的基础知识,所以这应该不是问题。
有人可以描述一下结构(即内部链接)
内核源代码中的各个目录。换句话说,给定一个源代码文件,
相关代码会引用哪些其他文件(“#include”提供了部分想法)
有人可以帮助我获得更好的想法吗?
任何帮助将不胜感激,
谢谢。
Recently, i began developing a driver of an embedded device running linux.
Until now i have only read about linux internals.
Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step.
- I have downloaded the kernel source-code (v2.6.32).
- I have read (skimped) Linux Device Drivers (3e)
- I read a few related posts here on StackOverflow.
- I understand that linux has a "monolithic" approach.
- I have built kernel (included existing driver in menuconfig etc.)
- I know the basics of kconfig and makefile files so that should not be a problem.
Can someone describe the structure (i.e. the inter-links)
of the various directories in the kernel-source code.In other words, given a source-code file,
which other files would it refer to for related code(The "#include"-s provide a partial idea)
Could someone please help me in getting a better idea?
Any help will be greatly appreciated
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
给定一个 C 文件,您必须查看它调用的函数和它使用的数据结构,而不是担心特定的文件。
开发自己的设备驱动程序有两种基本途径:
当您完成此过程时,组成驱动程序的文件将更有意义。请务必考虑每个文件属于什么内容,但在某种程度上,在文件之间划分驱动程序更像是一门艺术,而不是一门科学。较小的驱动程序通常只适合一两个文件。
一点设计也可能是好的。考虑您的设备做什么,以及您的驱动程序需要做什么。基于此,您应该能够确定设备驱动程序需要具有哪些功能。
我还相信 Linux 设备驱动程序,第三版 可能会帮助您开始驱动程序开发。
Linux 文件本身包括基于其用途、所在层以及访问调用堆栈的哪一层的文件。大图真实地告诉了每个文件与下一个文件的关系。
Given a C file, you have to look at the functions it calls and data structures it uses, rather than worrying about particular files.
There are two basic routes to developing your own device driver:
The files that compose your driver will make more sense as you complete this process. Do consider what belongs in each file, but to some extent, dividing a driver among files is more an art than a science. Smaller drivers often fit into just one or two files.
A bit of design may also be good. Consider what you device does, and what your driver will need to do. Based on that, you should be able to map out what functions a device driver will need to have.
I also believe Linux Device Drivers, Third Edition may help you get on your way to driver development.
Linux files themselves include files based on what they do, what layer they are in, and what layer they access of the call stack. The Big Picture truly informs how each file is related to the next.
我必须修复一次内核驱动程序。我最大的技巧(如果你使用 vim)是使用 ctags 进行设置,这样每次你看到一个你不理解的函数时,你就可以使用 ctrl-] 跳转内核源代码。
I had to fix a kernel driver once. My biggest tip (if you use vim) is to set it up with ctags so you can jump around the kernel source with ctrl-] every time you see a function you don't understand.