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