hdio.txt 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. Summary of HDIO_ ioctl calls.
  2. ============================
  3. Edward A. Falk <efalk@google.com>
  4. November, 2004
  5. This document attempts to describe the ioctl(2) calls supported by
  6. the HD/IDE layer. These are by-and-large implemented (as of Linux 2.6)
  7. in drivers/ide/ide.c and drivers/block/scsi_ioctl.c
  8. ioctl values are listed in <linux/hdreg.h>. As of this writing, they
  9. are as follows:
  10. ioctls that pass argument pointers to user space:
  11. HDIO_GETGEO get device geometry
  12. HDIO_GET_UNMASKINTR get current unmask setting
  13. HDIO_GET_MULTCOUNT get current IDE blockmode setting
  14. HDIO_GET_QDMA get use-qdma flag
  15. HDIO_SET_XFER set transfer rate via proc
  16. HDIO_OBSOLETE_IDENTITY OBSOLETE, DO NOT USE
  17. HDIO_GET_KEEPSETTINGS get keep-settings-on-reset flag
  18. HDIO_GET_32BIT get current io_32bit setting
  19. HDIO_GET_NOWERR get ignore-write-error flag
  20. HDIO_GET_DMA get use-dma flag
  21. HDIO_GET_NICE get nice flags
  22. HDIO_GET_IDENTITY get IDE identification info
  23. HDIO_GET_WCACHE get write cache mode on|off
  24. HDIO_GET_ACOUSTIC get acoustic value
  25. HDIO_GET_ADDRESS get sector addressing mode
  26. HDIO_GET_BUSSTATE get the bus state of the hwif
  27. HDIO_TRISTATE_HWIF execute a channel tristate
  28. HDIO_DRIVE_RESET execute a device reset
  29. HDIO_DRIVE_TASKFILE execute raw taskfile
  30. HDIO_DRIVE_TASK execute task and special drive command
  31. HDIO_DRIVE_CMD execute a special drive command
  32. HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
  33. ioctls that pass non-pointer values:
  34. HDIO_SET_MULTCOUNT change IDE blockmode
  35. HDIO_SET_UNMASKINTR permit other irqs during I/O
  36. HDIO_SET_KEEPSETTINGS keep ioctl settings on reset
  37. HDIO_SET_32BIT change io_32bit flags
  38. HDIO_SET_NOWERR change ignore-write-error flag
  39. HDIO_SET_DMA change use-dma flag
  40. HDIO_SET_PIO_MODE reconfig interface to new speed
  41. HDIO_SCAN_HWIF register and (re)scan interface
  42. HDIO_SET_NICE set nice flags
  43. HDIO_UNREGISTER_HWIF unregister interface
  44. HDIO_SET_WCACHE change write cache enable-disable
  45. HDIO_SET_ACOUSTIC change acoustic behavior
  46. HDIO_SET_BUSSTATE set the bus state of the hwif
  47. HDIO_SET_QDMA change use-qdma flag
  48. HDIO_SET_ADDRESS change lba addressing modes
  49. HDIO_SET_IDE_SCSI Set scsi emulation mode on/off
  50. HDIO_SET_SCSI_IDE not implemented yet
  51. The information that follows was determined from reading kernel source
  52. code. It is likely that some corrections will be made over time.
  53. General:
  54. Unless otherwise specified, all ioctl calls return 0 on success
  55. and -1 with errno set to an appropriate value on error.
  56. Unless otherwise specified, all ioctl calls return -1 and set
  57. errno to EFAULT on a failed attempt to copy data to or from user
  58. address space.
  59. Unless otherwise specified, all data structures and constants
  60. are defined in <linux/hdreg.h>
  61. HDIO_GETGEO get device geometry
  62. usage:
  63. struct hd_geometry geom;
  64. ioctl(fd, HDIO_GETGEO, &geom);
  65. inputs: none
  66. outputs:
  67. hd_geometry structure containing:
  68. heads number of heads
  69. sectors number of sectors/track
  70. cylinders number of cylinders, mod 65536
  71. start starting sector of this partition.
  72. error returns:
  73. EINVAL if the device is not a disk drive or floppy drive,
  74. or if the user passes a null pointer
  75. notes:
  76. Not particularly useful with modern disk drives, whose geometry
  77. is a polite fiction anyway. Modern drives are addressed
  78. purely by sector number nowadays (lba addressing), and the
  79. drive geometry is an abstraction which is actually subject
  80. to change. Currently (as of Nov 2004), the geometry values
  81. are the "bios" values -- presumably the values the drive had
  82. when Linux first booted.
  83. In addition, the cylinders field of the hd_geometry is an
  84. unsigned short, meaning that on most architectures, this
  85. ioctl will not return a meaningful value on drives with more
  86. than 65535 tracks.
  87. The start field is unsigned long, meaning that it will not
  88. contain a meaningful value for disks over 219 Gb in size.
  89. HDIO_GET_UNMASKINTR get current unmask setting
  90. usage:
  91. long val;
  92. ioctl(fd, HDIO_GET_UNMASKINTR, &val);
  93. inputs: none
  94. outputs:
  95. The value of the drive's current unmask setting
  96. HDIO_SET_UNMASKINTR permit other irqs during I/O
  97. usage:
  98. unsigned long val;
  99. ioctl(fd, HDIO_SET_UNMASKINTR, val);
  100. inputs:
  101. New value for unmask flag
  102. outputs: none
  103. error return:
  104. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  105. EACCES Access denied: requires CAP_SYS_ADMIN
  106. EINVAL value out of range [0 1]
  107. EBUSY Controller busy
  108. HDIO_GET_MULTCOUNT get current IDE blockmode setting
  109. usage:
  110. long val;
  111. ioctl(fd, HDIO_GET_MULTCOUNT, &val);
  112. inputs: none
  113. outputs:
  114. The value of the current IDE block mode setting. This
  115. controls how many sectors the drive will transfer per
  116. interrupt.
  117. HDIO_SET_MULTCOUNT change IDE blockmode
  118. usage:
  119. int val;
  120. ioctl(fd, HDIO_SET_MULTCOUNT, val);
  121. inputs:
  122. New value for IDE block mode setting. This controls how many
  123. sectors the drive will transfer per interrupt.
  124. outputs: none
  125. error return:
  126. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  127. EACCES Access denied: requires CAP_SYS_ADMIN
  128. EINVAL value out of range supported by disk.
  129. EBUSY Controller busy or blockmode already set.
  130. EIO Drive did not accept new block mode.
  131. notes:
  132. Source code comments read:
  133. This is tightly woven into the driver->do_special cannot
  134. touch. DON'T do it again until a total personality rewrite
  135. is committed.
  136. If blockmode has already been set, this ioctl will fail with
  137. EBUSY
  138. HDIO_GET_QDMA get use-qdma flag
  139. Not implemented, as of 2.6.8.1
  140. HDIO_SET_XFER set transfer rate via proc
  141. Not implemented, as of 2.6.8.1
  142. HDIO_OBSOLETE_IDENTITY OBSOLETE, DO NOT USE
  143. Same as HDIO_GET_IDENTITY (see below), except that it only
  144. returns the first 142 bytes of drive identity information.
  145. HDIO_GET_IDENTITY get IDE identification info
  146. usage:
  147. unsigned char identity[512];
  148. ioctl(fd, HDIO_GET_IDENTITY, identity);
  149. inputs: none
  150. outputs:
  151. ATA drive identity information. For full description, see
  152. the IDENTIFY DEVICE and IDENTIFY PACKET DEVICE commands in
  153. the ATA specification.
  154. error returns:
  155. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  156. ENOMSG IDENTIFY DEVICE information not available
  157. notes:
  158. Returns information that was obtained when the drive was
  159. probed. Some of this information is subject to change, and
  160. this ioctl does not re-probe the drive to update the
  161. information.
  162. This information is also available from /proc/ide/hdX/identify
  163. HDIO_GET_KEEPSETTINGS get keep-settings-on-reset flag
  164. usage:
  165. long val;
  166. ioctl(fd, HDIO_GET_KEEPSETTINGS, &val);
  167. inputs: none
  168. outputs:
  169. The value of the current "keep settings" flag
  170. notes:
  171. When set, indicates that kernel should restore settings
  172. after a drive reset.
  173. HDIO_SET_KEEPSETTINGS keep ioctl settings on reset
  174. usage:
  175. long val;
  176. ioctl(fd, HDIO_SET_KEEPSETTINGS, val);
  177. inputs:
  178. New value for keep_settings flag
  179. outputs: none
  180. error return:
  181. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  182. EACCES Access denied: requires CAP_SYS_ADMIN
  183. EINVAL value out of range [0 1]
  184. EBUSY Controller busy
  185. HDIO_GET_32BIT get current io_32bit setting
  186. usage:
  187. long val;
  188. ioctl(fd, HDIO_GET_32BIT, &val);
  189. inputs: none
  190. outputs:
  191. The value of the current io_32bit setting
  192. notes:
  193. 0=16-bit, 1=32-bit, 2,3 = 32bit+sync
  194. HDIO_GET_NOWERR get ignore-write-error flag
  195. usage:
  196. long val;
  197. ioctl(fd, HDIO_GET_NOWERR, &val);
  198. inputs: none
  199. outputs:
  200. The value of the current ignore-write-error flag
  201. HDIO_GET_DMA get use-dma flag
  202. usage:
  203. long val;
  204. ioctl(fd, HDIO_GET_DMA, &val);
  205. inputs: none
  206. outputs:
  207. The value of the current use-dma flag
  208. HDIO_GET_NICE get nice flags
  209. usage:
  210. long nice;
  211. ioctl(fd, HDIO_GET_NICE, &nice);
  212. inputs: none
  213. outputs:
  214. The drive's "nice" values.
  215. notes:
  216. Per-drive flags which determine when the system will give more
  217. bandwidth to other devices sharing the same IDE bus.
  218. See <linux/hdreg.h>, near symbol IDE_NICE_DSC_OVERLAP.
  219. HDIO_SET_NICE set nice flags
  220. usage:
  221. unsigned long nice;
  222. ...
  223. ioctl(fd, HDIO_SET_NICE, nice);
  224. inputs:
  225. bitmask of nice flags.
  226. outputs: none
  227. error returns:
  228. EACCES Access denied: requires CAP_SYS_ADMIN
  229. EPERM Flags other than DSC_OVERLAP and NICE_1 set.
  230. EPERM DSC_OVERLAP specified but not supported by drive
  231. notes:
  232. This ioctl sets the DSC_OVERLAP and NICE_1 flags from values
  233. provided by the user.
  234. Nice flags are listed in <linux/hdreg.h>, starting with
  235. IDE_NICE_DSC_OVERLAP. These values represent shifts.
  236. HDIO_GET_WCACHE get write cache mode on|off
  237. usage:
  238. long val;
  239. ioctl(fd, HDIO_GET_WCACHE, &val);
  240. inputs: none
  241. outputs:
  242. The value of the current write cache mode
  243. HDIO_GET_ACOUSTIC get acoustic value
  244. usage:
  245. long val;
  246. ioctl(fd, HDIO_GET_ACOUSTIC, &val);
  247. inputs: none
  248. outputs:
  249. The value of the current acoustic settings
  250. notes:
  251. See HDIO_SET_ACOUSTIC
  252. HDIO_GET_ADDRESS
  253. usage:
  254. long val;
  255. ioctl(fd, HDIO_GET_ADDRESS, &val);
  256. inputs: none
  257. outputs:
  258. The value of the current addressing mode:
  259. 0 = 28-bit
  260. 1 = 48-bit
  261. 2 = 48-bit doing 28-bit
  262. 3 = 64-bit
  263. HDIO_GET_BUSSTATE get the bus state of the hwif
  264. usage:
  265. long state;
  266. ioctl(fd, HDIO_SCAN_HWIF, &state);
  267. inputs: none
  268. outputs:
  269. Current power state of the IDE bus. One of BUSSTATE_OFF,
  270. BUSSTATE_ON, or BUSSTATE_TRISTATE
  271. error returns:
  272. EACCES Access denied: requires CAP_SYS_ADMIN
  273. HDIO_SET_BUSSTATE set the bus state of the hwif
  274. usage:
  275. int state;
  276. ...
  277. ioctl(fd, HDIO_SCAN_HWIF, state);
  278. inputs:
  279. Desired IDE power state. One of BUSSTATE_OFF, BUSSTATE_ON,
  280. or BUSSTATE_TRISTATE
  281. outputs: none
  282. error returns:
  283. EACCES Access denied: requires CAP_SYS_RAWIO
  284. EOPNOTSUPP Hardware interface does not support bus power control
  285. HDIO_TRISTATE_HWIF execute a channel tristate
  286. Not implemented, as of 2.6.8.1. See HDIO_SET_BUSSTATE
  287. HDIO_DRIVE_RESET execute a device reset
  288. usage:
  289. int args[3]
  290. ...
  291. ioctl(fd, HDIO_DRIVE_RESET, args);
  292. inputs: none
  293. outputs: none
  294. error returns:
  295. EACCES Access denied: requires CAP_SYS_ADMIN
  296. ENXIO No such device: phy dead or ctl_addr == 0
  297. EIO I/O error: reset timed out or hardware error
  298. notes:
  299. Execute a reset on the device as soon as the current IO
  300. operation has completed.
  301. Executes an ATAPI soft reset if applicable, otherwise
  302. executes an ATA soft reset on the controller.
  303. HDIO_DRIVE_TASKFILE execute raw taskfile
  304. Note: If you don't have a copy of the ANSI ATA specification
  305. handy, you should probably ignore this ioctl.
  306. Execute an ATA disk command directly by writing the "taskfile"
  307. registers of the drive. Requires ADMIN and RAWIO access
  308. privileges.
  309. usage:
  310. struct {
  311. ide_task_request_t req_task;
  312. u8 outbuf[OUTPUT_SIZE];
  313. u8 inbuf[INPUT_SIZE];
  314. } task;
  315. memset(&task.req_task, 0, sizeof(task.req_task));
  316. task.req_task.out_size = sizeof(task.outbuf);
  317. task.req_task.in_size = sizeof(task.inbuf);
  318. ...
  319. ioctl(fd, HDIO_DRIVE_TASKFILE, &task);
  320. ...
  321. inputs:
  322. (See below for details on memory area passed to ioctl.)
  323. io_ports[8] values to be written to taskfile registers
  324. hob_ports[8] high-order bytes, for extended commands.
  325. out_flags flags indicating which registers are valid
  326. in_flags flags indicating which registers should be returned
  327. data_phase see below
  328. req_cmd command type to be executed
  329. out_size size of output buffer
  330. outbuf buffer of data to be transmitted to disk
  331. inbuf buffer of data to be received from disk (see [1])
  332. outputs:
  333. io_ports[] values returned in the taskfile registers
  334. hob_ports[] high-order bytes, for extended commands.
  335. out_flags flags indicating which registers are valid (see [2])
  336. in_flags flags indicating which registers should be returned
  337. outbuf buffer of data to be transmitted to disk (see [1])
  338. inbuf buffer of data to be received from disk
  339. error returns:
  340. EACCES CAP_SYS_ADMIN or CAP_SYS_RAWIO privilege not set.
  341. ENOMSG Device is not a disk drive.
  342. ENOMEM Unable to allocate memory for task
  343. EFAULT req_cmd == TASKFILE_IN_OUT (not implemented as of 2.6.8)
  344. EPERM req_cmd == TASKFILE_MULTI_OUT and drive
  345. multi-count not yet set.
  346. EIO Drive failed the command.
  347. notes:
  348. [1] READ THE FOLLOWING NOTES *CAREFULLY*. THIS IOCTL IS
  349. FULL OF GOTCHAS. Extreme caution should be used with using
  350. this ioctl. A mistake can easily corrupt data or hang the
  351. system.
  352. [2] Both the input and output buffers are copied from the
  353. user and written back to the user, even when not used.
  354. [3] If one or more bits are set in out_flags and in_flags is
  355. zero, the following values are used for in_flags.all and
  356. written back into in_flags on completion.
  357. * IDE_TASKFILE_STD_IN_FLAGS | (IDE_HOB_STD_IN_FLAGS << 8)
  358. if LBA48 addressing is enabled for the drive
  359. * IDE_TASKFILE_STD_IN_FLAGS
  360. if CHS/LBA28
  361. The association between in_flags.all and each enable
  362. bitfield flips depending on endianness; fortunately, TASKFILE
  363. only uses inflags.b.data bit and ignores all other bits.
  364. The end result is that, on any endian machines, it has no
  365. effect other than modifying in_flags on completion.
  366. [4] The default value of SELECT is (0xa0|DEV_bit|LBA_bit)
  367. except for four drives per port chipsets. For four drives
  368. per port chipsets, it's (0xa0|DEV_bit|LBA_bit) for the first
  369. pair and (0x80|DEV_bit|LBA_bit) for the second pair.
  370. [5] The argument to the ioctl is a pointer to a region of
  371. memory containing a ide_task_request_t structure, followed
  372. by an optional buffer of data to be transmitted to the
  373. drive, followed by an optional buffer to receive data from
  374. the drive.
  375. Command is passed to the disk drive via the ide_task_request_t
  376. structure, which contains these fields:
  377. io_ports[8] values for the taskfile registers
  378. hob_ports[8] high-order bytes, for extended commands
  379. out_flags flags indicating which entries in the
  380. io_ports[] and hob_ports[] arrays
  381. contain valid values. Type ide_reg_valid_t.
  382. in_flags flags indicating which entries in the
  383. io_ports[] and hob_ports[] arrays
  384. are expected to contain valid values
  385. on return.
  386. data_phase See below
  387. req_cmd Command type, see below
  388. out_size output (user->drive) buffer size, bytes
  389. in_size input (drive->user) buffer size, bytes
  390. When out_flags is zero, the following registers are loaded.
  391. HOB_FEATURE If the drive supports LBA48
  392. HOB_NSECTOR If the drive supports LBA48
  393. HOB_SECTOR If the drive supports LBA48
  394. HOB_LCYL If the drive supports LBA48
  395. HOB_HCYL If the drive supports LBA48
  396. FEATURE
  397. NSECTOR
  398. SECTOR
  399. LCYL
  400. HCYL
  401. SELECT First, masked with 0xE0 if LBA48, 0xEF
  402. otherwise; then, or'ed with the default
  403. value of SELECT.
  404. If any bit in out_flags is set, the following registers are loaded.
  405. HOB_DATA If out_flags.b.data is set. HOB_DATA will
  406. travel on DD8-DD15 on little endian machines
  407. and on DD0-DD7 on big endian machines.
  408. DATA If out_flags.b.data is set. DATA will
  409. travel on DD0-DD7 on little endian machines
  410. and on DD8-DD15 on big endian machines.
  411. HOB_NSECTOR If out_flags.b.nsector_hob is set
  412. HOB_SECTOR If out_flags.b.sector_hob is set
  413. HOB_LCYL If out_flags.b.lcyl_hob is set
  414. HOB_HCYL If out_flags.b.hcyl_hob is set
  415. FEATURE If out_flags.b.feature is set
  416. NSECTOR If out_flags.b.nsector is set
  417. SECTOR If out_flags.b.sector is set
  418. LCYL If out_flags.b.lcyl is set
  419. HCYL If out_flags.b.hcyl is set
  420. SELECT Or'ed with the default value of SELECT and
  421. loaded regardless of out_flags.b.select.
  422. Taskfile registers are read back from the drive into
  423. {io|hob}_ports[] after the command completes iff one of the
  424. following conditions is met; otherwise, the original values
  425. will be written back, unchanged.
  426. 1. The drive fails the command (EIO).
  427. 2. One or more than one bits are set in out_flags.
  428. 3. The requested data_phase is TASKFILE_NO_DATA.
  429. HOB_DATA If in_flags.b.data is set. It will contain
  430. DD8-DD15 on little endian machines and
  431. DD0-DD7 on big endian machines.
  432. DATA If in_flags.b.data is set. It will contain
  433. DD0-DD7 on little endian machines and
  434. DD8-DD15 on big endian machines.
  435. HOB_FEATURE If the drive supports LBA48
  436. HOB_NSECTOR If the drive supports LBA48
  437. HOB_SECTOR If the drive supports LBA48
  438. HOB_LCYL If the drive supports LBA48
  439. HOB_HCYL If the drive supports LBA48
  440. NSECTOR
  441. SECTOR
  442. LCYL
  443. HCYL
  444. The data_phase field describes the data transfer to be
  445. performed. Value is one of:
  446. TASKFILE_IN
  447. TASKFILE_MULTI_IN
  448. TASKFILE_OUT
  449. TASKFILE_MULTI_OUT
  450. TASKFILE_IN_OUT
  451. TASKFILE_IN_DMA
  452. TASKFILE_IN_DMAQ == IN_DMA (queueing not supported)
  453. TASKFILE_OUT_DMA
  454. TASKFILE_OUT_DMAQ == OUT_DMA (queueing not supported)
  455. TASKFILE_P_IN unimplemented
  456. TASKFILE_P_IN_DMA unimplemented
  457. TASKFILE_P_IN_DMAQ unimplemented
  458. TASKFILE_P_OUT unimplemented
  459. TASKFILE_P_OUT_DMA unimplemented
  460. TASKFILE_P_OUT_DMAQ unimplemented
  461. The req_cmd field classifies the command type. It may be
  462. one of:
  463. IDE_DRIVE_TASK_NO_DATA
  464. IDE_DRIVE_TASK_SET_XFER unimplemented
  465. IDE_DRIVE_TASK_IN
  466. IDE_DRIVE_TASK_OUT unimplemented
  467. IDE_DRIVE_TASK_RAW_WRITE
  468. [6] Do not access {in|out}_flags->all except for resetting
  469. all the bits. Always access individual bit fields. ->all
  470. value will flip depending on endianness. For the same
  471. reason, do not use IDE_{TASKFILE|HOB}_STD_{OUT|IN}_FLAGS
  472. constants defined in hdreg.h.
  473. HDIO_DRIVE_CMD execute a special drive command
  474. Note: If you don't have a copy of the ANSI ATA specification
  475. handy, you should probably ignore this ioctl.
  476. usage:
  477. u8 args[4+XFER_SIZE];
  478. ...
  479. ioctl(fd, HDIO_DRIVE_CMD, args);
  480. inputs:
  481. Commands other than WIN_SMART
  482. args[0] COMMAND
  483. args[1] NSECTOR
  484. args[2] FEATURE
  485. args[3] NSECTOR
  486. WIN_SMART
  487. args[0] COMMAND
  488. args[1] SECTOR
  489. args[2] FEATURE
  490. args[3] NSECTOR
  491. outputs:
  492. args[] buffer is filled with register values followed by any
  493. data returned by the disk.
  494. args[0] status
  495. args[1] error
  496. args[2] NSECTOR
  497. args[3] undefined
  498. args[4+] NSECTOR * 512 bytes of data returned by the command.
  499. error returns:
  500. EACCES Access denied: requires CAP_SYS_RAWIO
  501. ENOMEM Unable to allocate memory for task
  502. EIO Drive reports error
  503. notes:
  504. [1] For commands other than WIN_SMART, args[1] should equal
  505. args[3]. SECTOR, LCYL and HCYL are undefined. For
  506. WIN_SMART, 0x4f and 0xc2 are loaded into LCYL and HCYL
  507. respectively. In both cases SELECT will contain the default
  508. value for the drive. Please refer to HDIO_DRIVE_TASKFILE
  509. notes for the default value of SELECT.
  510. [2] If NSECTOR value is greater than zero and the drive sets
  511. DRQ when interrupting for the command, NSECTOR * 512 bytes
  512. are read from the device into the area following NSECTOR.
  513. In the above example, the area would be
  514. args[4..4+XFER_SIZE]. 16bit PIO is used regardless of
  515. HDIO_SET_32BIT setting.
  516. [3] If COMMAND == WIN_SETFEATURES && FEATURE == SETFEATURES_XFER
  517. && NSECTOR >= XFER_SW_DMA_0 && the drive supports any DMA
  518. mode, IDE driver will try to tune the transfer mode of the
  519. drive accordingly.
  520. HDIO_DRIVE_TASK execute task and special drive command
  521. Note: If you don't have a copy of the ANSI ATA specification
  522. handy, you should probably ignore this ioctl.
  523. usage:
  524. u8 args[7];
  525. ...
  526. ioctl(fd, HDIO_DRIVE_TASK, args);
  527. inputs:
  528. Taskfile register values:
  529. args[0] COMMAND
  530. args[1] FEATURE
  531. args[2] NSECTOR
  532. args[3] SECTOR
  533. args[4] LCYL
  534. args[5] HCYL
  535. args[6] SELECT
  536. outputs:
  537. Taskfile register values:
  538. args[0] status
  539. args[1] error
  540. args[2] NSECTOR
  541. args[3] SECTOR
  542. args[4] LCYL
  543. args[5] HCYL
  544. args[6] SELECT
  545. error returns:
  546. EACCES Access denied: requires CAP_SYS_RAWIO
  547. ENOMEM Unable to allocate memory for task
  548. ENOMSG Device is not a disk drive.
  549. EIO Drive failed the command.
  550. notes:
  551. [1] DEV bit (0x10) of SELECT register is ignored and the
  552. appropriate value for the drive is used. All other bits
  553. are used unaltered.
  554. HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
  555. Not implemented, as of 2.6.8.1
  556. HDIO_SET_32BIT change io_32bit flags
  557. usage:
  558. int val;
  559. ioctl(fd, HDIO_SET_32BIT, val);
  560. inputs:
  561. New value for io_32bit flag
  562. outputs: none
  563. error return:
  564. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  565. EACCES Access denied: requires CAP_SYS_ADMIN
  566. EINVAL value out of range [0 3]
  567. EBUSY Controller busy
  568. HDIO_SET_NOWERR change ignore-write-error flag
  569. usage:
  570. int val;
  571. ioctl(fd, HDIO_SET_NOWERR, val);
  572. inputs:
  573. New value for ignore-write-error flag. Used for ignoring
  574. WRERR_STAT
  575. outputs: none
  576. error return:
  577. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  578. EACCES Access denied: requires CAP_SYS_ADMIN
  579. EINVAL value out of range [0 1]
  580. EBUSY Controller busy
  581. HDIO_SET_DMA change use-dma flag
  582. usage:
  583. long val;
  584. ioctl(fd, HDIO_SET_DMA, val);
  585. inputs:
  586. New value for use-dma flag
  587. outputs: none
  588. error return:
  589. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  590. EACCES Access denied: requires CAP_SYS_ADMIN
  591. EINVAL value out of range [0 1]
  592. EBUSY Controller busy
  593. HDIO_SET_PIO_MODE reconfig interface to new speed
  594. usage:
  595. long val;
  596. ioctl(fd, HDIO_SET_PIO_MODE, val);
  597. inputs:
  598. New interface speed.
  599. outputs: none
  600. error return:
  601. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  602. EACCES Access denied: requires CAP_SYS_ADMIN
  603. EINVAL value out of range [0 255]
  604. EBUSY Controller busy
  605. HDIO_SCAN_HWIF register and (re)scan interface
  606. usage:
  607. int args[3]
  608. ...
  609. ioctl(fd, HDIO_SCAN_HWIF, args);
  610. inputs:
  611. args[0] io address to probe
  612. args[1] control address to probe
  613. args[2] irq number
  614. outputs: none
  615. error returns:
  616. EACCES Access denied: requires CAP_SYS_RAWIO
  617. EIO Probe failed.
  618. notes:
  619. This ioctl initializes the addresses and irq for a disk
  620. controller, probes for drives, and creates /proc/ide
  621. interfaces as appropriate.
  622. HDIO_UNREGISTER_HWIF unregister interface
  623. usage:
  624. int index;
  625. ioctl(fd, HDIO_UNREGISTER_HWIF, index);
  626. inputs:
  627. index index of hardware interface to unregister
  628. outputs: none
  629. error returns:
  630. EACCES Access denied: requires CAP_SYS_RAWIO
  631. notes:
  632. This ioctl removes a hardware interface from the kernel.
  633. Currently (2.6.8) this ioctl silently fails if any drive on
  634. the interface is busy.
  635. HDIO_SET_WCACHE change write cache enable-disable
  636. usage:
  637. int val;
  638. ioctl(fd, HDIO_SET_WCACHE, val);
  639. inputs:
  640. New value for write cache enable
  641. outputs: none
  642. error return:
  643. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  644. EACCES Access denied: requires CAP_SYS_ADMIN
  645. EINVAL value out of range [0 1]
  646. EBUSY Controller busy
  647. HDIO_SET_ACOUSTIC change acoustic behavior
  648. usage:
  649. int val;
  650. ioctl(fd, HDIO_SET_ACOUSTIC, val);
  651. inputs:
  652. New value for drive acoustic settings
  653. outputs: none
  654. error return:
  655. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  656. EACCES Access denied: requires CAP_SYS_ADMIN
  657. EINVAL value out of range [0 254]
  658. EBUSY Controller busy
  659. HDIO_SET_QDMA change use-qdma flag
  660. Not implemented, as of 2.6.8.1
  661. HDIO_SET_ADDRESS change lba addressing modes
  662. usage:
  663. int val;
  664. ioctl(fd, HDIO_SET_ADDRESS, val);
  665. inputs:
  666. New value for addressing mode
  667. 0 = 28-bit
  668. 1 = 48-bit
  669. 2 = 48-bit doing 28-bit
  670. outputs: none
  671. error return:
  672. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  673. EACCES Access denied: requires CAP_SYS_ADMIN
  674. EINVAL value out of range [0 2]
  675. EBUSY Controller busy
  676. EIO Drive does not support lba48 mode.
  677. HDIO_SET_IDE_SCSI
  678. usage:
  679. long val;
  680. ioctl(fd, HDIO_SET_IDE_SCSI, val);
  681. inputs:
  682. New value for scsi emulation mode (?)
  683. outputs: none
  684. error return:
  685. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  686. EACCES Access denied: requires CAP_SYS_ADMIN
  687. EINVAL value out of range [0 1]
  688. EBUSY Controller busy
  689. HDIO_SET_SCSI_IDE
  690. Not implemented, as of 2.6.8.1