Basics Of Device Driver Types Flashcards
The directory on a Linux machine where all the device files for the system are located.
/dev
/dev is a very interesting directory that highlights one important aspect of the Linux filesystem
Everything in Linux is a file
An example of the Printer driver in your Linux System. The device file of printer is /dev/lp0.
Any data written to this file by your application will be re-directed to your computer.
Data read/written to /dev/ttys0 will
allow you to communicate with a device like a serial terminal or a modem device.
In Linux we have following device types:
- Character Devices
- Block Devices
- Network Devices
Character Devices Driver
A character device typically transfers data to and from a user application- they behave like pipes or serial ports, instantly reading or writing the byte data in a character-by-character stream.
Character Device Drivers Framework
They provide the framework for many typical drivers, such as those that are required for interfacing to serial communications, video capture, and audio devices.
Block Device
Block devices behave in a similar fashion to regular files, allowing a buffered array of cached data to be viewed or manipulated with operations such as reads, writes, and seeks.
LKM
Linux Kernal Space
Major and Minor Numbers
Device drives have an associated major and minor number. For example /dev/ram0 and /dev/null are associated with a drive with a major number 1, and /dev/tty0 and /dev/ttys0 are associated with a driver with major number 4. The Major number is used by the kernel to identify the correct device driver when the device is accessed. The role of the minor number is device dependent and is handled internally within the driver.
molloyd@beaglebone:/dev$ ls -l
crw-rw—T 1 root i2c 89, 0 Jan 1 2000 i2c-0
brw-rw—T 1 root disk 1, 0 Mar 1 20:46 ram0
brw-rw—T 1 root floppy 179, 0 Mar 1 20:46 mmcblk0
crw-rw-rw- 1 root root 1, 3 Mar 1 20:46 null
crw——- 1 root root 4, 0 Mar 1 20:46 tty0
crw-rw—T 1 root dialout 4, 64 Mar 1 20:46 ttyS0
molloyd@beaglebone:/dev$ ls -l
crw-rw—T 1 root i2c 89, 0 Jan 1 2000 i2c-0
brw-rw—T 1 root disk 1, 0 Mar 1 20:46 ram0
brw-rw—T 1 root floppy 179, 0 Mar 1 20:46 mmcblk0
crw-rw-rw- 1 root root 1, 3 Mar 1 20:46 null
crw——- 1 root root 4, 0 Mar 1 20:46 tty0
crw-rw—T 1 root dialout 4, 64 Mar 1 20:46 ttyS0
Character devices are identified by a ‘c’ in the first column of a listing, and block devices are identified by a ‘b’. The access permissions, owner, and the group of the device is provided for each device.
Examples of character device drivers are
- Serial port ( /dev/ttyS0 )
- Text console ( /dev/console )
- Mice
- Parallel printer ports
Examples of Block device
- Hard Drive
- Cd-Rom
In what way do Block and Character devices differ?
Block and Character devices differ only in the way the data is managed internally by the kernal.
Block devices in short are
Block devices in short are devices that store or hold data.