lkml.org 
[lkml]   [2001]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Sarada prasanna wrote:
>
> Hi friends,
> While reading a source code of pppd i came across a macro
> declaration like
>
> #define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags
> */
>
> I refered to the book called "Linux kernel internals by Beck and others" and
> on
> the page 219 (chap implementing a device driver) i found out the line
> telling
>
> _IOR(c,d,t) for commands which write back to the user address space a
> value of
> the C type t
>
> but still i am not being able to understand the macro declaration. Can
> someone kindly tell me about the _IOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A better reference would be "Linux Device Drivers", 2nd edition.
See http://www.xml.com/ldd/chapter/book/ch05.html#t1 for info
on I/O controls. (search for /_IOR/ or /_IOW/ for example)

In general, _IOR() and _IOW() take 3 parameters and make a
number out of them. That number is used in a driver's ioctl
function to decide what the request is, its direction (in or out),
its data type, and data size.

For example, on x86, _IOR and _IOW make a 32-bit number, used as:

|dd|ssssssssssssss|tttttttt|nnnnnnnn|
| \-size \-type \-number
\-direction

Size is limited to 14 bits; Direction is Read, Write, or None.
Type is usually (meant to be) a constant for any one driver,
such as 'T' for ttys, 'S' for SCSI, 'M' for MTRR driver,
'A' for APM, 'a' for ATM, 0x93 for autofs, 'C' for CAPI,
'B' for CCISS, 's' for cdk, 'c' for coda, 'd' for devfsd,
0x89 for DECNET, 'f' and 'v' for ext2/3, 'F' for frame buffer,
2 for floppy driver, 0x12 for block layer, 'H' for HID driver,

Is there a registry of IOCTL magic numbers? Yep, see
linux/Documentation/ioctl-number.txt for more info and numbers.

See linux/include/asm-i386/ioctl.h for macro specifics.

--
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:57    [W:0.030 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site