ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

Linux Driver Weeder I/O Boards

Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

LINUX DRIVES WEEDER I/O BOARDS

Applications
by Jack Dennon

Start ý Create the Device Driver ý Create the Device ý The Order of Things ý Load the Device Driver ý Call the Test Program ý Remove the Device Driver ý Sources and PDF

CREATE THE DEVICE

In any UNIX-like system such as Linux, attached peripheral devices are usually accessed through the file system. A directory entry that represents a peripheral device is said to point to a special file, also called a device file. Such an entry can be placed in any directory, but it is conventional to place device entries in the well-known directory /dev where programs can find them.

For example, to access a line printer, there will be one or more device files in this directory starting with lp. The command ls -l /dev/lp* will display entries such as:

crw-rw---- 1 root daemon 6, 0 Apr 27 1995 /dev/lp0
crw-rw---- 1 root daemon 6, 1 Apr 27 1995 /dev/lp1
crw-rw---- 1 root daemon 6, 2 Apr 27 1995 /dev/lp2

The c in the string crw-rw---- means that the device named /dev/lp0, for example, is a character special device, and the rest of the string shows that root and members of the daemon group have read and write access to this device. The line printer driver in this system has been assigned major number 6 and is intended to handle up to three attached printers that are to be selected via minor numbers 0, 1, and 2.

The kernel cares only about the device type c and the major device number. The minor numbers are passed to and used only by the device driver. The major number is the index into a kernel table of pointers to device drivers.

To examine the current contents of your kernelýs device table, you can use the command cat /proc/devices. You should see a display such as shown in Table 1. Here, you see that there is a device driver named lp, which occupies location 6 in the device driver table.

Character devices

Block devices

1
2
3
4
5
6
7
30
127
mem
pty
ttyp
ttyp
cua
lp
vcs
socksys
pcmcia
1
2
3
9
22
ramdisk
fd
ide0
md
ide1

 

Table 1ýAll the device drivers currently registered with your kernel can be displayed with the command cat /proc/devices. The output produced will contain information such as what is seen in this table.

PREVIOUS NEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
 
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ