版权声明:This article is a blogger original article, only for study reference, reprint please indicate the source, thank you! https://blog.csdn.net/Rong_Toa/article/details/88046358
1. Character devices is the most common type of devices. Initially for devices implementing streams of bytes, it is now used for a wide range of devices: serial ports, framebuffers, video capture devices, sound devices, input devices, I2C and SPI gateways, etc.
2. Block devices for storage devices like hard disks, CD-ROM drives, USB keys, SD/MMC cards, etc.
3. Network devices for wired or wireless interfaces, PPP connections and others
- Network devices are accessed through network-specic APIs and tools (socket API of the standard C library, tools such as
- ifconfig, route, etc.)
- Block and character devices are represented for userspace applications as les than can be manipulated using the traditional le API (open(), read(), write(), close(), etc.)
- Special le types for block and character devices, associating a name with a couple (major, minor)
- The kernel only cares about the (type, major, minor), which is the unique identier of the device
- Special les traditionaly located in /dev, created by mknod, either manually or automatically by udev
Device drivers must register themselves to the core kernel and implement a set of operations specic to their type:
- Character drivers must instantiate and register a cdev structure and implement file_operations
- Block drivers must instantiate and register a gendisk structure and implement block_device_operations and a special make_request function
- Network drivers must instantiate and register a net_device structure and implement net_device_ops
In this presentation, we will rst focus on character devices as an example of device drivers.
Thomas Petazzoni
Free Electrons
[email protected]