Being an electrical engineering student at my undergraduate level, my exposure to Linux started rather late and was limited to C programming on Linux PC. My true interaction with Linux started during my post graduation at IIT DELHI, wherein I started learning Linux shell commands, Vi editor etc. Still my experience remained limited to user space work like programming, networking and basic system administration. My first encounter with kernel programming happened when I was given an assignment to write a device driver for mouse. Although I could succeed in getting mouse events, I could not complete the assignment. But it left an interesting area open to me which I continued to explore till date. The idea of sharing the experience started when I finished a self assignment to write a network device driver on 2.4 kernel. I wrote an article and published it on Linux Malta group. The article turned out to be an immensely popular which increased my faith in sharing my experience. Later, the same article was re-published in Linux Gazette magazine because Linux Malta group website went down. Based on the responses from the readers I realized that while many good, in-fact very good, reference books are available about Linux device driver programming, still there is a void in teaching an end to end driver development. Specifically a sample and real hardware made users to do the real development from scratch. Encouraged from this article’s success, I decided to write similar articles for block, USB, char, UART drivers as well and put them together along with kernel programming articles so that a reader finds all of them in one place. That’s how this book has originated. All the code samples in this book are written or re-written for 2.6.21 kernel, however wherever needed, reference to older kernel are also been given so that readers may know the difference if they have to work on older kernels. The examples sited throughout this book are trimmed versions of the self assignments done at home on Linux running on AMD AthlonTM processor. Specifically the error handling part is either removed or is minimal for the sake of brevity. Also the driver design is kept very simple and minimal basic functions are implemented for easy understanding. This will help readers to quickly understand and then modify them to add more features, error handling and bug fixing to grasp better understanding.
Additional Info
  • Publisher: Laxmi Publications
  • Language: English
  • ISBN : 978-93-80298-93-1
  • Chapter 1

    Beginning Kernel Programming Price 2.99  |  2.99 Rewards Points

    Linux being an open source operating system gives flexibility to customize the kernel based on user needs. This means, that a user is free to include whatever needed and exclude everything else to keep the kernel size small. In this chapter, we begin with kernel compilation and then develop first kernel module.
  • Chapter 2

    Application and Kernel Space Communication Price 2.99  |  2.99 Rewards Points

    Linux separates the execution space between application (user) space and kernel space. It is not possible to invoke direct function call between application source code and kernel source code for security reasons. However, Linux provides some controlled methods to perform communication between the two spaces.
  • Chapter 3

    Linux Kernel Debugging Price 2.99  |  2.99 Rewards Points

    Kernel debugging is an interesting and challenging task for every kernel programmer. It requires additional knowledge, information and sometimes additional resources for kernel debugging. In this chapter we discuss different methods for kernel debugging. Depending upon the problem, situation and resources, all or some of them can be used. This chapter discusses following methods of kernel debugging
  • Chapter 4

    Delayed Execution Price 2.99  |  2.99 Rewards Points

    Linux kernel programming or device driver programming very often requires delaying the code execution. For example, deferring IO based work for later time as it is very slow process or retransmitting a message after certain timeout. Linux kernel provides several mechanisms to delay the execution. This chapter discusses following such mechanisms and illustrates them with examples.
  • Chapter 5

    KernelLocking and Synchronization Price 2.99  |  2.99 Rewards Points

    One of the basic objectives of any operation system is to provide uniform and distributed access of system resources to the applications. Since the resources are limited and users are more, contention is likely to occur. Similarly data structures can be accessed by many users and therefore data structure may be corrupted if not accessed in well defined manner. To solve such problems, Linux kernel defines many primitives which can be used by different processes to wok in co-operative manner. In this chapter we discuss such primitives and learn how to use them.
  • Chapter 6

    Linux Networking Subsystem Price 2.99  |  2.99 Rewards Points

    63 Linux provides a layered, flexible and versatile networking subsystem. It’s up to date including all network technologies like IP, IPv6, ATM, IPX etc. The networking subsystems are often referred as stack owing to their layered design. There are some core data structures operating under all such subsystems. This chapter addresses a few such important data structures and then explains mechanism to install new protocol handlers.
  • Chapter 7

    Developing UART Serial Port Device Driver Price 2.99  |  2.99 Rewards Points

    This chapter shall describe a step by step and incremental method to develop device driver for UART chip which controls serial port on Linux box or Linux boards.
  • Chapter 8

    Developing USB Mass Storage Block Device Driver Price 2.99  |  2.99 Rewards Points

    In this chapter we learn to develop a USB mass storage block device driver in incremental order.
  • Chapter 9

    PCI Based Network Device Driver Price 2.99  |  2.99 Rewards Points

    In this chapter, we develop a PCI based network device driver. The PCI part of this driver can be used for any PCI based device, while the network part of this driver can be used for any other network card (NIC). This chapter assumes reader’s familiarity with chapter “LINUX NETWORKING SUBSYSTEM”. Unlike USB and UART, the NICs do not have a well defined interface or protocol. Every NIC has its own register set; therefore it is essential to have NIC specification (also referred as datasheet) available for driver development.
  • Chapter 10

    Memory Allocation and Miscellaneous Topics Price 2.99  |  2.99 Rewards Points

    Memory allocation and management is a very crucial part of kernel programming or device driver development. Memory allocation is more involved in kernel space than user space. This chapter explains various methods of memory allocation in kernel space, and explains their suitability to different scenarios.

About the Author