Wednesday 24 August 2016

Device Driver

Device drivers are broadly classified into two basic categories:

character devices and block devices. Character devices can be thought of as serial streams of
sequential data. Examples of character devices include serial ports and keyboards.
Block devices are characterized by the capability to read and write blocks of data to and from random locations on an addressable medium. Examples of block devices include hard drives and floppy disk drives.

Module Parameters

Many device driver modules can accept parameters to modify their behavior. Examples include
enabling debug mode, setting verbose reporting, or specifying module-specific optionsMany device driver modules can accept parameters to modify their behavior.

modprobe

The ext3 module depends on the jbd module. The modprobe utility can discover this relationship and load the dependent modules in the proper order. The following command loads both the jbd.ko and ext3.ko driver modules:
$ modprobe ext3

The modprobe utility has several command line options that control its behavior. As we saw earlier,
modprobe can be used to remove modules, including the modules upon which a given module
depends. Here is an example of module removal that removes both jbd.ko and ext3.ko:
$ modprobe -r ext3

Device Nodes and mknod

A device node is a special file type in Linux that represents a device. Virtually all Linux distributions keep device nodes in a common location in a directory called /dev.
let's create the proper device node to
exercise it:
$ mknod /dev/hello1 c 234 0
After executing this command on our target embedded system, we end up with a new file called
/dev/hello1 that represents our device driver module. If we list this file to the console, it looks like
this:
$ ls -l /dev/hello1
crw-r--r-- 1 root root 234, 0 Jul 14 2005 /dev/hello1

The major number is 234, the number we chose for this example, and the minor number is 0.


No comments:

Post a Comment