Operating System - HP-UX
1836582 Members
1659 Online
110102 Solutions
New Discussion

Re: Help with Peripheral devices ..

 
SOLVED
Go to solution
someone_4
Honored Contributor

Help with Peripheral devices ..

Hello everyone,
I am readying HP Certified and I just got done with the chapter on Peripheral devices this is the first time I have ever read information on this issue. Can someone please point me to more docs or help me understand what all this is about?

Richard
5 REPLIES 5
someone_4
Honored Contributor

Re: Help with Peripheral devices ..

I am looking to clear up the concepts and logic if any about Peripheral devices.
Sanjay_6
Honored Contributor

Re: Help with Peripheral devices ..

Hi Richard,

Can you be a little more clear about what sort of concepts you are lookingto clear ?.

thanks
someone_4
Honored Contributor

Re: Help with Peripheral devices ..

Well the whole chapter on Peripheral devices lost me. So any kind of information to clear it up would be most helpfull.

Richard
Sanjay_6
Honored Contributor

Re: Help with Peripheral devices ..

Hi,

Don't have the bok myself, so don't know what is there. Was thinking if you have any question, can help. Otherwise when we talk about peripherals, a lot of things come into mind, and it is very difficult to start with one particular peripheral and move into another without making any sense.

That was the reason i said, you have to ask pointed questions to get pointed answers. Very difficult to answer general questions.

Hope this helps and i'm making sense.

thanks
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Help with Peripheral devices ..

Hi Richard,

I'll just do this off the top of my head. Consider the problem of echoeing "Mary Had a Little Lamb" to a file. Is this somehow different than writing it to a terminal or sending those characters to a printer? To another process via a pipe? The whole concept behind UNIX I/O is that all of these are really the same to the application. They may, in fact, be very different to the kernel or to the peripheral device itself but to the application writing is writing.

Obviously there must be some layer between the application and the device and that is where device drivers which are actually part of the kernel come in.

Each I/O device has a only a few basic operations that it can perform - Open, Close,
Read, Write, Seek (possibly), and a general purpose thing called ioctl (I/O Control). How these operation are actually done may vary greatly between a disk drive and a printer but still the idea is that application merely tells the device to write. If you do an ls -l on any device (e.g. /dev/rdsk/c0t6d0) you will see two numbers - one generally a small decimal value followed by a hexadecimal value.
These are the major and minor device numbers.
You can also do an lsdev to display all the device drivers and their major device numbers.

Now here is the key to UNIX I/O - those major and minor device numbers. UNIX has no idea (nor does it care) what /dev/rdsk/c0t6d0 is; we could just as well call that device '/tmp/RogerRabbit' and it would work just as well. Those names are for the benefit of us dumb humans; the system only cares about those major and minor device numbers associated with that name.

I want you to think about an array that has as its index that major device number. Each element in that array has an entry for each of the basic I/O operations (open,close,etc.) that is defined for that device. This is called the device switch table and when the kernel wants to write to a disk, it determines the major device number and looks in the table for the write function (actually its address) and it now has most of what it needs to write "Mary Had a Little Lamb". The other part is the minor device number. This number means different things to different device drivers.
(e.g. Controller Number, SCSI target, LUN, tape density, rewind or norewind, compression enabled, etc.) You cam man scsi_tape, scsi_disk, and scsi_ctl fdor examples of what these minor device numbers do for those particular devices.

The only other complication to this is "Block" (sometimes called 'cooked') devices and "Character" (sometimes called 'raw') devices. The major difference is that "Block" devices read/write through the buffer cache while raw devices do not. There are actually two device switch tables - one for "Block" and one for "Character" but the concept is the same. If you man mknod you will see that there are arguments for creating both block and character devices and for specifying the major and minor device numbers.

Hope this gets you started, Clay.
If it ain't broke, I can fix that.