public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdlab.org>
To: Sarada prasanna <csaradap@mihy.mot.com>
Cc: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: Re: _IOR('t',90,int)
Date: Thu, 16 Aug 2001 14:40:20 -0700	[thread overview]
Message-ID: <3B7C3DC4.1DE74EF8@osdlab.org> (raw)
In-Reply-To: <C1590740235CD211BA5600A0C9E1F6FF02602296@hydmail.mihy.mot.com>

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

      reply	other threads:[~2001-08-16 21:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-16  2:27 _IOR('t',90,int) Sarada prasanna
2001-08-16 21:40 ` Randy.Dunlap [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B7C3DC4.1DE74EF8@osdlab.org \
    --to=rddunlap@osdlab.org \
    --cc=csaradap@mihy.mot.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox