Linux内核设备驱动程序编程 [英] Linux kernel device driver programming

查看:96
本文介绍了Linux内核设备驱动程序编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习linux内核设备驱动程序编程.所以任何人都可以在这里发布良好的教程页面或链接.我是Linux内核环境的新手.我已经搜索过它,但是我不知道如何开始以及为了易于理解的基础而阅读哪一本书.提前致谢.

I want to learn linux kernel device driver programming. So can anyone please post good tutorials pages or links here. I am new to linux kernel environment. I have searched for it but I don't know how to start and which one to read for easy understanding basics. Thanks in advance.

推荐答案

取决于您当前的技能.如果您真的是Linux的新手,也许您应该从高级Linux编程开始进行用户空间系统编程. .使用此免费资源,您将对Unix系统调用和其他概念(例如信号,进程/线程等)有很好的了解.如果您在内核方面进行开发,这是必须的(理解用户空间API),因为内核的作用是以安全的方式向用户提供服务.

Depends on your current skills. If you're really new to Linux, perhaps you should start with user space system programming with Advanced Linux Programming. You'll get good knowledge of Unix system calls and other concepts such as signals, processes/threads and so on with this free resource. This is a must (understanding the user space API) if you're developing on the kernel side since the role of a kernel is providing services to users in a secure way.

否则,经常引用的一本书是 Linux设备驱动程序,第三版(LDD3).请记住,该版本是在Linux 2.6.10时编写的,此后发生了一些变化. 本文显示了2.6演变时的区别(直到2.6.31,所以不是很有用).我应该提到 martinezjavier/ldd3 ,其中包含了针对较新内核而更新的LDD3示例驱动程序(感谢 42n4 指出这一点.)

Otherwise one often cited book is Linux Device Drivers, Third Edition (LDD3). Keep in mind that this edition was written at the time of Linux 2.6.10 and some things changed since then. This article shows the differences as 2.6 evolved (until 2.6.31, that is, so not very useful). I should mention martinezjavier/ldd3, which contains example drivers of LDD3 updated for more recent kernels (thanks to 42n4 for pointing that out).

基本的Linux设备驱动程序是另一本不常被引用的有趣的书.您不会找到该版本的免费版本,但是它仍然具有一种有趣的方法.我喜欢它的原因是它涵盖了许多不同的设备类型,并且是2.6.24的最新版本,这比LDD更好.

Another interesting book that's not as often cited is Essential Linux Device Drivers. You won't find a free version of this one, but it still features an interesting approach. What I like about this one is it covers lots of different device types and is up-to-date as of 2.6.24, which is a bit better than LDD.

最后,关于内核本身(不是专门针对驱动程序)的一本很棒的书是了解Linux内核,第三版版.这涵盖了深入的内核功能和内部机制.它是2.6.11的最新版本.

Finally, one great book about the kernel itself (not specifically for drivers) is Understanding the Linux Kernel, 3rd Edition. This covers in-depth kernel facilities and internal mechanisms. It's up-to-date as of 2.6.11.

对于在线教程,我在Pete的Blog上找到了这篇文章是一个非常好的例子.它不仅显示了如何创建字符设备(最简单的内核驱动程序类型,即您应该从那里开始),而且还以易于理解的方式使用了现代Linux内核功能,包括:

As for online tutorials, I found this post on Pete's Blog is a really great example. Not only does it show how to create a character device (the most easy kernel driver type, i.e. the one you should start with), it uses modern Linux kernel features in an easy to understand fashion, including:

  • 使用udev
  • 使用内核数据结构(FIFO)
  • 使用内核同步(互斥体)
  • 使用具有自定义属性的Sysfs
  • insmod的模块选项
  • use of udev
  • use of a kernel data structure (FIFO)
  • use of kernel synchronization (mutex)
  • use of Sysfs with custom attributes
  • module options for insmod

Plus:它针对Linux 3.0,这意味着与其他资源相比,它是最新的.

Plus: it's aimed at Linux 3.0, which means it's more up-to-date compared to other resources.

您可能还喜欢这篇文章关于如何手动创建Sysfs条目,尽管如果不需要其他节点或属性,Linux设备模型将负责将设备注册为Sysfs条目.

You might also like this post about how to create Sysfs entries manually, although the Linux device model will take care of registering your device as a Sysfs entry if you don't need additional nodes or attributes.

编辑:我应该补充说,学习真正的Linux设备驱动程序编程的最好方法是查看实际的驱动程序. drivers 中有成千上万个驱动程序.开始阅读并理解诸如drivers/leds之类的简单概念的知识,您将看到它的好处.

Edit: I should add that the best way to learn real Linux device driver programming is to look at actual drivers. There are thousands of drivers in drivers. Start reading and understanding the concept of simple ones like drivers/leds and you will see how rewarding this is.

这篇关于Linux内核设备驱动程序编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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