README.ioctl
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:13k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. Linux I2O User Space Interface
  2. rev 0.3 - 04/20/99
  3. =============================================================================
  4. Originally written by Deepak Saxena(deepak@plexity.net)
  5. Currently maintained by Deepak Saxena(deepak@plexity.net)
  6. =============================================================================
  7. I. Introduction
  8. The Linux I2O subsystem provides a set of ioctl() commands that can be
  9. utilized by user space applications to communicate with IOPs and devices
  10. on individual IOPs. This document defines the specific ioctl() commands
  11. that are available to the user and provides examples of their uses.
  12. This document assumes the reader is familiar with or has access to the 
  13. I2O specification as no I2O message parameters are outlined.  For information 
  14. on the specification, see http://www.i2osig.org
  15. This document and the I2O user space interface are currently maintained
  16. by Deepak Saxena.  Please send all comments, errata, and bug fixes to
  17. deepak@csociety.purdue.edu
  18. II. IOP Access
  19. Access to the I2O subsystem is provided through the device file named 
  20. /dev/i2o/ctl.  This file is a character file with major number 10 and minor
  21. number 166.  It can be created through the following command:
  22.    mknod /dev/i2o/ctl c 10 166
  23. III. Determining the IOP Count
  24.    SYNOPSIS 
  25.    ioctl(fd, I2OGETIOPS,  int *count);
  26.    u8 count[MAX_I2O_CONTROLLERS];
  27.    DESCRIPTION
  28.    This function returns the system's active IOP table.  count should
  29.    point to a buffer containing MAX_I2O_CONTROLLERS entries.  Upon 
  30.    returning, each entry will contain a non-zero value if the given
  31.    IOP unit is active, and NULL if it is inactive or non-existent.
  32.    RETURN VALUE.
  33.    Returns 0 if no errors occur, and -1 otherwise.  If an error occurs,
  34.    errno is set appropriately:
  35.      EFAULT   Invalid user space pointer was passed
  36. IV. Getting Hardware Resource Table
  37.    SYNOPSIS 
  38.  
  39.    ioctl(fd, I2OHRTGET, struct i2o_cmd_hrt *hrt);
  40.       struct i2o_cmd_hrtlct
  41.       {
  42.          u32   iop;      /* IOP unit number */
  43.          void  *resbuf;  /* Buffer for result */
  44.          u32   *reslen;  /* Buffer length in bytes */
  45.       };
  46.    DESCRIPTION
  47.    This function returns the Hardware Resource Table of the IOP specified 
  48.    by hrt->iop in the buffer pointed to by hrt->resbuf. The actual size of 
  49.    the data is written into *(hrt->reslen).
  50.    RETURNS
  51.    This function returns 0 if no errors occur. If an error occurs, -1 
  52.    is returned and errno is set appropriately:
  53.       EFAULT      Invalid user space pointer was passed
  54.       ENXIO       Invalid IOP number
  55.       ENOBUFS     Buffer not large enough.  If this occurs, the required
  56.                   buffer length is written into *(hrt->reslen)
  57.   
  58. V. Getting Logical Configuration Table
  59.    
  60.    SYNOPSIS 
  61.  
  62.    ioctl(fd, I2OLCTGET, struct i2o_cmd_lct *lct);
  63.       struct i2o_cmd_hrtlct
  64.       {
  65.          u32   iop;      /* IOP unit number */
  66.          void  *resbuf;  /* Buffer for result */
  67.          u32   *reslen;  /* Buffer length in bytes */
  68.       };
  69.    DESCRIPTION
  70.    This function returns the Logical Configuration Table of the IOP specified
  71.    by lct->iop in the buffer pointed to by lct->resbuf. The actual size of 
  72.    the data is written into *(lct->reslen).
  73.    RETURNS
  74.    This function returns 0 if no errors occur. If an error occurs, -1 
  75.    is returned and errno is set appropriately:
  76.       EFAULT      Invalid user space pointer was passed
  77.       ENXIO       Invalid IOP number
  78.       ENOBUFS     Buffer not large enough.  If this occurs, the required
  79.                   buffer length is written into *(lct->reslen)
  80. VI. Settting Parameters
  81.    
  82.    SYNOPSIS 
  83.  
  84.    ioctl(fd, I2OPARMSET, struct i2o_parm_setget *ops);
  85.       struct i2o_cmd_psetget
  86.       {
  87.          u32   iop;      /* IOP unit number */
  88.          u32   tid;      /* Target device TID */
  89.          void  *opbuf;   /* Operation List buffer */
  90.          u32   oplen;    /* Operation List buffer length in bytes */
  91.          void  *resbuf;  /* Result List buffer */
  92.          u32   *reslen;  /* Result List buffer length in bytes */
  93.       };
  94.    DESCRIPTION
  95.    This function posts a UtilParamsSet message to the device identified
  96.    by ops->iop and ops->tid.  The operation list for the message is 
  97.    sent through the ops->opbuf buffer, and the result list is written
  98.    into the buffer pointed to by ops->resbuf.  The number of bytes 
  99.    written is placed into *(ops->reslen). 
  100.    RETURNS
  101.    The return value is the size in bytes of the data written into
  102.    ops->resbuf if no errors occur.  If an error occurs, -1 is returned 
  103.    and errno is set appropriatly:
  104.       EFAULT      Invalid user space pointer was passed
  105.       ENXIO       Invalid IOP number
  106.       ENOBUFS     Buffer not large enough.  If this occurs, the required
  107.                   buffer length is written into *(ops->reslen)
  108.       ETIMEDOUT   Timeout waiting for reply message
  109.       ENOMEM      Kernel memory allocation error
  110.    A return value of 0 does not mean that the value was actually
  111.    changed properly on the IOP.  The user should check the result
  112.    list to determine the specific status of the transaction.
  113. VII. Getting Parameters
  114.    
  115.    SYNOPSIS 
  116.  
  117.    ioctl(fd, I2OPARMGET, struct i2o_parm_setget *ops);
  118.       struct i2o_parm_setget
  119.       {
  120.          u32   iop;      /* IOP unit number */
  121.          u32   tid;      /* Target device TID */
  122.          void  *opbuf;   /* Operation List buffer */
  123.          u32   oplen;    /* Operation List buffer length in bytes */
  124.          void  *resbuf;  /* Result List buffer */
  125.          u32   *reslen;  /* Result List buffer length in bytes */
  126.       };
  127.    DESCRIPTION
  128.    This function posts a UtilParamsGet message to the device identified
  129.    by ops->iop and ops->tid.  The operation list for the message is 
  130.    sent through the ops->opbuf buffer, and the result list is written
  131.    into the buffer pointed to by ops->resbuf.  The actual size of data
  132.    written is placed into *(ops->reslen).
  133.    RETURNS
  134.       EFAULT      Invalid user space pointer was passed
  135.       ENXIO       Invalid IOP number
  136.       ENOBUFS     Buffer not large enough.  If this occurs, the required
  137.                   buffer length is written into *(ops->reslen)
  138.       ETIMEDOUT   Timeout waiting for reply message
  139.       ENOMEM      Kernel memory allocation error
  140.    A return value of 0 does not mean that the value was actually
  141.    properly retreived.  The user should check the result list 
  142.    to determine the specific status of the transaction.
  143. VIII. Downloading Software
  144.    
  145.    SYNOPSIS 
  146.  
  147.    ioctl(fd, I2OSWDL, struct i2o_sw_xfer *sw);
  148.       struct i2o_sw_xfer
  149.       {
  150.          u32   iop;       /* IOP unit number */
  151.          u8    flags;     /* DownloadFlags field */
  152.          u8    sw_type;   /* Software type */
  153.          u32   sw_id;     /* Software ID */
  154.          void  *buf;      /* Pointer to software buffer */
  155.          u32   *swlen;    /* Length of software buffer */        
  156.          u32   *maxfrag;  /* Number of fragments */
  157.          u32   *curfrag;  /* Current fragment number */
  158.       };
  159.    DESCRIPTION
  160.    This function downloads a software fragment pointed by sw->buf
  161.    to the iop identified by sw->iop. The DownloadFlags, SwID, SwType
  162.    and SwSize fields of the ExecSwDownload message are filled in with
  163.    the values of sw->flags, sw->sw_id, sw->sw_type and *(sw->swlen).
  164.    The fragments _must_ be sent in order and be 8K in size. The last
  165.    fragment _may_ be shorter, however. The kernel will compute its
  166.    size based on information in the sw->swlen field.
  167.    Please note that SW transfers can take a long time.
  168.    RETURNS
  169.    This function returns 0 no errors occur. If an error occurs, -1 
  170.    is returned and errno is set appropriatly:
  171.       EFAULT      Invalid user space pointer was passed
  172.       ENXIO       Invalid IOP number
  173.       ETIMEDOUT   Timeout waiting for reply message
  174.       ENOMEM      Kernel memory allocation error
  175. IX. Uploading Software
  176.    
  177.    SYNOPSIS 
  178.    ioctl(fd, I2OSWUL, struct i2o_sw_xfer *sw);
  179.       struct i2o_sw_xfer
  180.       {
  181.          u32   iop;      /* IOP unit number */
  182.          u8    flags;   /* UploadFlags */
  183.          u8    sw_type;  /* Software type */
  184.          u32   sw_id;    /* Software ID */
  185.          void  *buf;     /* Pointer to software buffer */
  186.          u32   *swlen;   /* Length of software buffer */        
  187.          u32   *maxfrag; /* Number of fragments */
  188.          u32   *curfrag; /* Current fragment number */
  189.       };
  190.    DESCRIPTION
  191.    This function uploads a software fragment from the IOP identified
  192.    by sw->iop, sw->sw_type, sw->sw_id and optionally sw->swlen fields.
  193.    The UploadFlags, SwID, SwType and SwSize fields of the ExecSwUpload
  194.    message are filled in with the values of sw->flags, sw->sw_id,
  195.    sw->sw_type and *(sw->swlen).
  196.    The fragments _must_ be requested in order and be 8K in size. The
  197.    user is responsible for allocating memory pointed by sw->buf. The
  198.    last fragment _may_ be shorter.
  199.    Please note that SW transfers can take a long time.
  200.    RETURNS
  201.    This function returns 0 if no errors occur.  If an error occurs, -1
  202.    is returned and errno is set appropriatly:
  203.       EFAULT      Invalid user space pointer was passed
  204.       ENXIO       Invalid IOP number
  205.       ETIMEDOUT   Timeout waiting for reply message
  206.       ENOMEM      Kernel memory allocation error
  207.          
  208. X. Removing Software
  209.    
  210.    SYNOPSIS 
  211.  
  212.    ioctl(fd, I2OSWDEL, struct i2o_sw_xfer *sw);
  213.       struct i2o_sw_xfer
  214.       {
  215.          u32   iop;      /* IOP unit number */
  216.          u8    flags;   /* RemoveFlags */
  217.          u8    sw_type;  /* Software type */
  218.          u32   sw_id;    /* Software ID */
  219.          void  *buf;     /* Unused */
  220.          u32   *swlen;   /* Length of the software data */        
  221.          u32   *maxfrag; /* Unused */
  222.          u32   *curfrag; /* Unused */
  223.       };
  224.    DESCRIPTION
  225.    This function removes software from the IOP identified by sw->iop.
  226.    The RemoveFlags, SwID, SwType and SwSize fields of the ExecSwRemove message 
  227.    are filled in with the values of sw->flags, sw->sw_id, sw->sw_type and 
  228.    *(sw->swlen). Give zero in *(sw->len) if the value is unknown. IOP uses 
  229.    *(sw->swlen) value to verify correct identication of the module to remove. 
  230.    The actual size of the module is written into *(sw->swlen).
  231.    RETURNS
  232.    This function returns 0 if no errors occur.  If an error occurs, -1
  233.    is returned and errno is set appropriatly:
  234.       EFAULT      Invalid user space pointer was passed
  235.       ENXIO       Invalid IOP number
  236.       ETIMEDOUT   Timeout waiting for reply message
  237.       ENOMEM      Kernel memory allocation error
  238. X. Validating Configuration
  239.    SYNOPSIS
  240.    ioctl(fd, I2OVALIDATE, int *iop);
  241. u32 iop;
  242.    DESCRIPTION
  243.    This function posts an ExecConfigValidate message to the controller
  244.    identified by iop. This message indicates that the current
  245.    configuration is accepted. The iop changes the status of suspect drivers 
  246.    to valid and may delete old drivers from its store.
  247.    RETURNS
  248.    This function returns 0 if no erro occur.  If an error occurs, -1 is
  249.    returned and errno is set appropriatly:
  250.       ETIMEDOUT   Timeout waiting for reply message
  251.       ENXIO       Invalid IOP number
  252. XI. Configuration Dialog
  253.    
  254.    SYNOPSIS 
  255.  
  256.    ioctl(fd, I2OHTML, struct i2o_html *htquery);
  257.       struct i2o_html
  258.       {
  259.          u32   iop;      /* IOP unit number */
  260.          u32   tid;      /* Target device ID */
  261.          u32   page;     /* HTML page */
  262.          void  *resbuf;  /* Buffer for reply HTML page */
  263.          u32   *reslen;  /* Length in bytes of reply buffer */
  264.          void  *qbuf;    /* Pointer to HTTP query string */
  265.          u32   qlen;     /* Length in bytes of query string buffer */        
  266.       };
  267.    DESCRIPTION
  268.    This function posts an UtilConfigDialog message to the device identified
  269.    by htquery->iop and htquery->tid.  The requested HTML page number is 
  270.    provided by the htquery->page field, and the resultant data is stored 
  271.    in the buffer pointed to by htquery->resbuf.  If there is an HTTP query 
  272.    string that is to be sent to the device, it should be sent in the buffer
  273.    pointed to by htquery->qbuf.  If there is no query string, this field
  274.    should be set to NULL. The actual size of the reply received is written
  275.    into *(htquery->reslen).
  276.   
  277.    RETURNS
  278.    This function returns 0 if no error occur. If an error occurs, -1
  279.    is returned and errno is set appropriatly:
  280.       EFAULT      Invalid user space pointer was passed
  281.       ENXIO       Invalid IOP number
  282.       ENOBUFS     Buffer not large enough.  If this occurs, the required
  283.                   buffer length is written into *(ops->reslen)
  284.       ETIMEDOUT   Timeout waiting for reply message
  285.       ENOMEM      Kernel memory allocation error
  286. XII. Events
  287.     In the process of determining this.  Current idea is to have use
  288.     the select() interface to allow user apps to periodically poll
  289.     the /dev/i2o/ctl device for events.  When select() notifies the user
  290.     that an event is available, the user would call read() to retrieve
  291.     a list of all the events that are pending for the specific device.
  292. =============================================================================
  293. Revision History
  294. =============================================================================
  295. Rev 0.1 - 04/01/99
  296. - Initial revision
  297. Rev 0.2 - 04/06/99
  298. - Changed return values to match UNIX ioctl() standard.  Only return values
  299.   are 0 and -1.  All errors are reported through errno.
  300. - Added summary of proposed possible event interfaces
  301. Rev 0.3 - 04/20/99
  302. - Changed all ioctls() to use pointers to user data instead of actual data
  303. - Updated error values to match the code