tailieunhanh - Linux Device Drivers-Chapter 5 : Enhanced Char Driver Operations

Tham khảo tài liệu 'linux device drivers-chapter 5 : enhanced char driver operations', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 5 Enhanced Char Driver Operations In Chapter 3 Char Drivers we built a complete device driver that the user can write to and read from. But a real device usually offers more functionality than synchronous read and write. Now that we re equipped with debugging tools should something go awry we can safely go ahead and implement new operations. What is normally needed in addition to reading and writing the device is the ability to perform various types of hardware control via the device driver. Control operations are usually supported via the ioctl method. The alternative is to look at the data flow being written to the device and use special sequences as control commands. This latter technique should be avoided because it requires reserving some characters for controlling purposes thus the data flow can t contain those characters. Moreover this technique turns out to be more complex to handle than ioctl. Nonetheless sometimes it s a useful approach to device control and is used by tty s and other devices. We ll describe it later in this chapter in Device Control Without ioctl . As we suggested in the previous chapter the ioctl system call offers a device specific entry point for the driver to handle commands. ioctl is device specific in that unlike read and other methods it allows applications to access features unique to the hardware being driven such as configuring the device and entering or exiting operating modes. These control operations are usually not available through the read write file abstraction. For example everything you write to a serial port is used as communication data and you cannot change the baud rate by writing to the device. That is what ioctl is for controlling the I O channel. Another important feature of real devices unlike scull is that data being read or written is exchanged with other hardware and some synchronization is needed. The concepts of blocking I O and asynchronous notification fill the gap and are introduced in this .

TỪ KHÓA LIÊN QUAN