实例介绍
Linux Device Driver (3edtion)原版 1. An Introduction to Device Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 The Role of the Device Driver 2 Splitting the Kernel 4 Classes of Devices and Modules 5 Security Issues 8 Version Numbering 10 License Terms 11 Joining the
③1)0mmm005M +4 Char Device registration open and release 58 sculls Memory usage read and write 63 Playing with the New devices Quick reference 70 4. Debugging Techniques 73 Debugging Support in the Kernel Debugging by Printing by querying g Debugging by Watching 91 Debugging System Faults 93 Debuggers and related tools 5. Concurrency and Race Conditions 106 Pitfalls in scull 107 Concurrency and its management 107 Semaphores and mutexes 109 Completions 114 Spinlocks 116 okiN T raps 121 Alternatives to locking 123 Quick reference 130 6. Advanced char driver Operations 135 ioctl 135 Blocking/O 147 poll and select 163 Asynchronous Notification 169 Seeking a device. 171 ccess control on a device file 173 Quick referer 179 7. Time, Delays, and Deferred Work ..183 Measuring Time Lapses 183 Knowing the Current Time 188 Delaying Execution 190 ernel timers 196 202 I Table of Contents ③1)0mmhm2290AM1 +4 Workqueues 205 Quick reference 208 8. Allocating Memory 213 The real story of kmalloc 213 Lookaside caches 217 get_free_page and Friend 221 vmalloc and friends 224 Per-CPU Variables 228 ning Large Buff 230 Quick reference 231 9. Communicating with Hardware 235 1/0 Ports and i/O Memory 235 Using 1/O ports 239 An I/O Port Example 245 Using 1/O memory 248 Quick reference 255 10. Interrupt Handling 258 Preparing the Parallel Port 259 Installing an Interrupt Handler 259 Implementing a handler 269 Top and Bottom Halves 275 Interrupt Sharing 278 Interrupt-Driven I/O 281 Quick ref 28 11. Data types in the Kernel 288 Use of Standard C Types 288 Assigning an Explicit size to data items 290 Interface-Specific T' yp 291 Other Portability Issues 292 Linked lists 295 ick reference 299 12. PCI Drivers 302 The Pci lnterfa 302 A look Back: Isa 319 PC/104 and PC/104 322 Table of contentsⅶi dr3ToC. fm. 4587 Page viii Thursday, January 20, 2005 9: 30 AM +4 her PC buses SBI 323 uBus 324 32 uick reference 325 13. USB Drivers 327 USB Device Basics 328 USB and sysfs 333 USB U USB D 346 USB Transfers Without Urbs Quick refe 360 14. The linux device mode 362 Objects, ksets, and Subsystems 364 ow-Level Systs Operations 371 hotplug Event Generation 375 Buses. Devices and drivers 377 387 Putting It All Together 391 otplu 397 Dealing with Firmware 405 Quick reference 407 15. Memory Mapping and Dma 412 memory Management in Linux 412 The mmap Device operation 422 Performing Direct I/O 435 mory Access 440 Quick reference 459 16. Block drivers 464 R 465 The Block Device Operations 471 Request processing 474 Some Other details 491 Quick reference 494 Table of contents ③1)0 fm.4587 Page ix Thursday, Januar 20059:30AM +4 17. Network Drivers 497 How snull Is Designed 498 Connecting to the kernel 502 The net device Structure in Detail 506 Opening and Closing 515 Packet transmission 516 Packet Reception 521 The Interrupt handler Receive Interrupt mitigation 525 Changes in Link statc 528 The Socket buff 528 MAC Address resolution 532 Custom ioctl commands 535 Statistical information 536 537 A Few Other details 540 Quick refere ence 542 18. TTY Drivers 546 A Small Tty driver 548 tty_driver Function Pointers 553 TTY Line setti 560 locCI ls 564 proc and sysfs Handling of TTY Devices 566 The tty_driver Structure in Detail b The tty_ operations Structure in Detail 569 The tty_struct Structure in Detail 571 Quick reference 573 Bibliography 575 Index 579 Table of Contents ③()0m2mm29mM +4 10011770 Page xi Thursday, January 27, 2005 12: 11 PM +4 Preface This is, on the surface, a book about writing device drivers for the Linux system That is a worthy goal, of course; the flow of new hardware products is not likely to slow down anytime soon, and somebody is going to have to make all those new gad gets work with Linux. But this book is also about how the Linux kernel works and how to adapt its workings to your needs or interests. Linux is an open system; with this book, we hope, it is more open and accessible to a larger community of developers This is the third edition of Linux Device Drivers. The kernel has changed greatly since this book was first published and we have tried to evolve the text to match This edition covers the 2.6.10 kernel as completely as we are able. We have, this time around, elected to omit the discussion of back ward compatibility with previous ker- nel versions. The changes from 2.4 are simply too large, and the 2. 4 interface remains well documented in the(freely available) second edition This edition contains quite a bit of new material relevant to the 2.6 kernel. The dis cussion of locking and concurrency has been expanded and moved into its own hapter. The Linux device model, which is new in 2.6, is covered in detail. There are new chapters on the usb bus and the serial driver subsystem; the chapter on Pci has lso been enhanced. While the organization of the rest of the book resembles that of the earlier editions, every chapter has been thoroughly updated We hope you enjoy reading this book as much as we have enjoyed writing it Jon s Introduction The publication of this edition coincides with my twelth year of working with Linux and, shocking y, my twenty-fifth year in the computing field. Computing seemed like a fast-moving field back in 1980, but things have sped up a lot since then. Keeping Linux device Drivers up lo date is increasingly a challenge; the linux kernel hackers continue to improve their code, and they have little patience for documentation that p up. 10011770 Page xii Thursday, January 27, 2005 12: 1 I PM Linux continues to succeed in the market and. more importantly in the hearts and minds of developers worldwide. The success of Linux is clearly a testament to its technical quality and to the numerous benefits of free software in general. But the true key to its success, in my opinion, lies in the fact that it has brought the fun back Lo computing. With Linux, any body can get their hands into the system and play in a sandbox where contributions from any direction are welcome, but where technical excellence is valued above all else. Linux not only provides us with a top-quality operating system; it gives us the opportunity to be part of its future development and to have fun while we re at it In my 25 years in the field, I have had many interesting opportunities, from program ming the first Cray computers (in Fortran, on punch cards) to seeing the minicom puter and Unix workstation waves, through to the current, microprocessor dominated era. Never, though, have I seen the field more full of life, opportunity and fun. Never have we had such control over our own tools and their evolution Linux, and free software in general, is clearly the driving force behind those changes ly hope is that this edition helps to bring that fun and opportunity to a new set of Linux developers. Whether your interests are in the kernel or in user space, I hope you find this book to be a useful and interesting guide to just how the kernel works with the hardware. I hope it helps and inspires you to fire up your editor and to make our shared, free operating system even better. Linux has come a long way, but it is also just beginning; it will be more than interesting to watch-and participate inwhat happens from here Alessandro's Introduction Ive always enjoyed computers because they can talk to external hardware. So, after soldering my devices for the Apple il and the ZX Spectrum, backed with the Unix and frce software expertise the university gave me, I could escape the dos trap by installing GNU/Linux on a fresh new 386 and by turning on the soldering iron once again. Back then, the community was a small one, and there wasn't much documentation about writing drivers around, so I started writing for Linux Journal. Thats how things started: when I later discovered I didn ' t like writing papers, I left the univer isty and found myself with an O'Reilly contract in my hands That was in 1996. Ages ago The computing world is different now: free software looks like a viable solution both technically and politically, but there's a lot of work to do in both realms. I hope this book furthers two aims: spreading technical knowledge and raising awareness about the need to spread knowledge. That's why, alter the first edition proved inter- esting to the public, the two authors of the second edition switched to a free license Preface 100 11770 Page xiii Thursday, January 27, 2005 12: 11 PM +4 supported by our editor and our publisher. I'm betting this is the right approach to Intormation, and it's great to team up with other people sharing this vision I' m excited by what I witness in the embedded arena, and I hope this text helps by doing more but ideas are moving fast these days, and it's already time to plan for the fourth edition, and look for a fourth author to help Greg s Introduction It seems like a long time ago that i picked up the first edition of this Linux device Drivers book in order to figure out how to write a real linux driver. That first edi tion was a great guide to helping me understand the internals of this operating sys tem that I had already been using for a number of years but whose kernel had never taken the time to look into with the knowledge gained from that book, and by read ing other programmers' code already present in the kernel, my first horribly buggy broken, and very SMP-unsate driver was accepted by the kernel community into the main kernel tree. Despite receiving my first bug report live minutes later, I was hooked on wanting to do as much as I could to make this operating system the best it could possibly be I am honored that I've had the ability to contribute to this book. I hope that it enables others to learn the details about the kernel discover that driver development is not a scary or forbidding place, and possibly encourage others to join in and help in the collective effort of making this operating system work on every computing latform with every type of device available. the development procedure is fun, the community is rewarding, and everyone benefits from the effort involved Now it's back to making this edition obsolete by fixing current bugs, changing APls to work better and be simpler to understand for everyone, and adding new features Come along; we can always use the help Audience for this book This book should be an interesting source of information both for people who want to experiment with their computer and for technical programmers who face the need to deal with the inner levels of a linux box note that "a linux box"is a wider con cept than "a PC running Linux, "as many platforms are supported by our operating system, and kernel programming is by no means bound to a specific platform. w hope this book is useful as a starting point for people who want to become kernel hackers but dont know where to start On the technical side, this text should offer a hands-on approach to understanding the kernel internals and some of the design choices made by the linux developers Although the main, official target of the book is teaching how to write device drivers the material should give an interesting overview of the kernel implementation as well Preface 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论