如何编写驱动程序代码?
我想在 Linux 操作系统中用 C 语言编写驱动程序,尽管我认为这非常困难。 我可以获得一些关于如何开始或要遵循的书籍的提示吗? 驱动程序可以从我的 USB 端口到显卡!
我知道在哪里可以查到书籍,我想知道我应该从哪些基础知识开始。 我需要具备硬件知识吗?哪些特定书籍适合像我这样的新手?
I want to code drivers in C in linux os, though I think its very tough. Can I get some hints as to how to start or books to follow? Drivers can be from my USB port to graphics card!!
I know as to where I can search for books, I would like to know as to what the basic knowledge I should start with. Do I need to have hardware knowledge and which specific books are good for novice like me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
从Linux 设备驱动程序(由 Rubini 和)科贝特,奥莱利出版。
它还可以免费 PDF 下载。
Start with Linux Device Drivers by Rubini and Corbet, published by O'Reilly.
It's also available as a free PDF download.
Rubini 和 Corbet 的 “Linux 设备驱动程序”(O'Reilley 书)是Linux 设备驱动程序的权威书籍。
凉爽的! 请参阅 Roddy 的回答中的免费 pdf 版本 克里斯蒂娜的评论!
"Linux Device Drivers" (the O'Reilley book) by Rubini and Corbet is the definitive book for Linux Device Drivers.
Cool! see the free pdf version in Roddy's answer & kristina's comment!
试试亚马逊!! 那里有很多给司机看的书。 有些有样品 2 !
try amazon !! there is many books there for drivers . some have samples 2 !!
几篇文章:
Several texts:
在开始设计驱动程序之前,您应该首先获得出色的 C 技能,可能还需要一些 Linux 内核知识。 设计驱动程序并非易事,如果您不习惯低级编程,可能会吓到您。
如果您不习惯 C,我可能会推荐 C 编程语言在我看来,如果您有一定的编程背景,这是 C 语言的入门读物。
Before you jump into designing drivers you should first get exceptional C skills and probably some Linux Kernel know-how. Desigining drivers is not trivial and might scare you off if you are not used to programming on a low-level.
I might recommend The C programming Language if you are not accustomed to C as it is, in my opinion, the primer on C if you have some programming background.
根据设备的不同,驱动程序的复杂性差异很大。 USB 驱动程序比较简单; GPU 驱动程序非常复杂,甚至这些驱动程序的作者通常也不知道它们所做的一切。 我的建议是关注您个人关心的硬件的驱动程序,而不是试图成为一个万能的硬件; 从长远来看,这会更容易。
其他人关于文档来源和各种需要阅读的内容的答案都是正确的,您应该真正接受其中之一。
许多更复杂的驱动程序社区也有自己的特定于域的信息。 如果您想编写 GPU 驱动程序,DRI/DRM 和 Mesa 社区有自己的 wiki 和邮件列表,它们还有自己的文档,可以为您提供很大帮助。 http://dri.freedesktop.org/ 是一个不错的起点,http://wiki.x.org/。
希望这可以帮助!
Drivers differ greatly in complexity depending on the device. USB drivers are on the simple side of the spectrum; GPU drivers are massively complex and even the authors of those drivers usually don't know everything that they do. My recommendation would be focusing on drivers for hardware you personally care about, rather than trying to be a jack-of-all-hardware; it'll be easier in the long run.
Everybody else's answers about documentation sources and various things to read are spot-on and you should really accept one of them.
Many of the more complex driver communities have their own domain-specific information as well. If you want to write a GPU driver, the DRI/DRM and Mesa communities have their own wikis and mailing lists which will help you out greatly, as well as their own documentation. http://dri.freedesktop.org/ is a decent starting place, as is http://wiki.x.org/.
Hope this helps!
你这里有一个非常好的例子
http://www.linuxjournal.com/article/7353
you have here a really good example
http://www.linuxjournal.com/article/7353
只需查看当前驱动程序的源代码即可。 我仅通过阅读代码上方的注释来编写我的 usb rndis 驱动程序。
获取内核源代码并查看 /drivers 目录。 USB 驱动程序位于 usb 目录中,但有关网络的 USB 驱动程序位于 /net/usb 中。
通过阅读评论你可以学到很多东西。
Just look at the source codes of current drivers. I wrote my usb rndis driver by only reading the comments put above the codes.
Get the kernel source and look at /drivers directory. Usb drivers are in usb directory, however usb drivers about networking are resided in /net/usb.
You can learn lots by reading the comments.