hdio.txt 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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. notes:
  297. Execute a reset on the device as soon as the current IO
  298. operation has completed.
  299. Executes an ATAPI soft reset if applicable, otherwise
  300. executes an ATA soft reset on the controller.
  301. HDIO_DRIVE_TASKFILE execute raw taskfile
  302. Note: If you don't have a copy of the ANSI ATA specification
  303. handy, you should probably ignore this ioctl.
  304. Execute an ATA disk command directly by writing the "taskfile"
  305. registers of the drive. Requires ADMIN and RAWIO access
  306. privileges.
  307. usage:
  308. struct {
  309. ide_task_request_t req_task;
  310. u8 outbuf[OUTPUT_SIZE];
  311. u8 inbuf[INPUT_SIZE];
  312. } task;
  313. memset(&task.req_task, 0, sizeof(task.req_task));
  314. task.req_task.out_size = sizeof(task.outbuf);
  315. task.req_task.in_size = sizeof(task.inbuf);
  316. ...
  317. ioctl(fd, HDIO_DRIVE_TASKFILE, &task);
  318. ...
  319. inputs:
  320. (See below for details on memory area passed to ioctl.)
  321. io_ports[8] values to be written to taskfile registers
  322. hob_ports[8] high-order bytes, for extended commands.
  323. out_flags flags indicating which registers are valid
  324. in_flags flags indicating which registers should be returned
  325. data_phase see below
  326. req_cmd command type to be executed
  327. out_size size of output buffer
  328. outbuf buffer of data to be transmitted to disk
  329. inbuf buffer of data to be received from disk (see [1])
  330. outputs:
  331. io_ports[] values returned in the taskfile registers
  332. hob_ports[] high-order bytes, for extended commands.
  333. out_flags flags indicating which registers are valid (see [2])
  334. in_flags flags indicating which registers should be returned
  335. outbuf buffer of data to be transmitted to disk (see [1])
  336. inbuf buffer of data to be received from disk
  337. error returns:
  338. EACCES CAP_SYS_ADMIN or CAP_SYS_RAWIO privilege not set.
  339. ENOMSG Device is not a disk drive.
  340. ENOMEM Unable to allocate memory for task
  341. EFAULT req_cmd == TASKFILE_IN_OUT (not implemented as of 2.6.8)
  342. EPERM req_cmd == TASKFILE_MULTI_OUT and drive
  343. multi-count not yet set.
  344. EIO Drive failed the command.
  345. notes:
  346. [1] READ THE FOLLOWING NOTES *CAREFULLY*. THIS IOCTL IS
  347. FULL OF GOTCHAS. Extreme caution should be used with using
  348. this ioctl. A mistake can easily corrupt data or hang the
  349. system.
  350. [2] Both the input and output buffers are copied from the
  351. user and written back to the user, even when not used.
  352. [3] If one or more bits are set in out_flags and in_flags is
  353. zero, the following values are used for in_flags.all and
  354. written back into in_flags on completion.
  355. * IDE_TASKFILE_STD_IN_FLAGS | (IDE_HOB_STD_IN_FLAGS << 8)
  356. if LBA48 addressing is enabled for the drive
  357. * IDE_TASKFILE_STD_IN_FLAGS
  358. if CHS/LBA28
  359. The association between in_flags.all and each enable
  360. bitfield flips depending on endianess; fortunately, TASKFILE
  361. only uses inflags.b.data bit and ignores all other bits.
  362. The end result is that, on any endian machines, it has no
  363. effect other than modifying in_flags on completion.
  364. [4] The default value of SELECT is (0xa0|DEV_bit|LBA_bit)
  365. except for four drives per port chipsets. For four drives
  366. per port chipsets, it's (0xa0|DEV_bit|LBA_bit) for the first
  367. pair and (0x80|DEV_bit|LBA_bit) for the second pair.
  368. [5] The argument to the ioctl is a pointer to a region of
  369. memory containing a ide_task_request_t structure, followed
  370. by an optional buffer of data to be transmitted to the
  371. drive, followed by an optional buffer to receive data from
  372. the drive.
  373. Command is passed to the disk drive via the ide_task_request_t
  374. structure, which contains these fields:
  375. io_ports[8] values for the taskfile registers
  376. hob_ports[8] high-order bytes, for extended commands
  377. out_flags flags indicating which entries in the
  378. io_ports[] and hob_ports[] arrays
  379. contain valid values. Type ide_reg_valid_t.
  380. in_flags flags indicating which entries in the
  381. io_ports[] and hob_ports[] arrays
  382. are expected to contain valid values
  383. on return.
  384. data_phase See below
  385. req_cmd Command type, see below
  386. out_size output (user->drive) buffer size, bytes
  387. in_size input (drive->user) buffer size, bytes
  388. When out_flags is zero, the following registers are loaded.
  389. HOB_FEATURE If the drive supports LBA48
  390. HOB_NSECTOR If the drive supports LBA48
  391. HOB_SECTOR If the drive supports LBA48
  392. HOB_LCYL If the drive supports LBA48
  393. HOB_HCYL If the drive supports LBA48
  394. FEATURE
  395. NSECTOR
  396. SECTOR
  397. LCYL
  398. HCYL
  399. SELECT First, masked with 0xE0 if LBA48, 0xEF
  400. otherwise; then, or'ed with the default
  401. value of SELECT.
  402. If any bit in out_flags is set, the following registers are loaded.
  403. HOB_DATA If out_flags.b.data is set. HOB_DATA will
  404. travel on DD8-DD15 on little endian machines
  405. and on DD0-DD7 on big endian machines.
  406. DATA If out_flags.b.data is set. DATA will
  407. travel on DD0-DD7 on little endian machines
  408. and on DD8-DD15 on big endian machines.
  409. HOB_NSECTOR If out_flags.b.nsector_hob is set
  410. HOB_SECTOR If out_flags.b.sector_hob is set
  411. HOB_LCYL If out_flags.b.lcyl_hob is set
  412. HOB_HCYL If out_flags.b.hcyl_hob is set
  413. FEATURE If out_flags.b.feature is set
  414. NSECTOR If out_flags.b.nsector is set
  415. SECTOR If out_flags.b.sector is set
  416. LCYL If out_flags.b.lcyl is set
  417. HCYL If out_flags.b.hcyl is set
  418. SELECT Or'ed with the default value of SELECT and
  419. loaded regardless of out_flags.b.select.
  420. Taskfile registers are read back from the drive into
  421. {io|hob}_ports[] after the command completes iff one of the
  422. following conditions is met; otherwise, the original values
  423. will be written back, unchanged.
  424. 1. The drive fails the command (EIO).
  425. 2. One or more than one bits are set in out_flags.
  426. 3. The requested data_phase is TASKFILE_NO_DATA.
  427. HOB_DATA If in_flags.b.data is set. It will contain
  428. DD8-DD15 on little endian machines and
  429. DD0-DD7 on big endian machines.
  430. DATA If in_flags.b.data is set. It will contain
  431. DD0-DD7 on little endian machines and
  432. DD8-DD15 on big endian machines.
  433. HOB_FEATURE If the drive supports LBA48
  434. HOB_NSECTOR If the drive supports LBA48
  435. HOB_SECTOR If the drive supports LBA48
  436. HOB_LCYL If the drive supports LBA48
  437. HOB_HCYL If the drive supports LBA48
  438. NSECTOR
  439. SECTOR
  440. LCYL
  441. HCYL
  442. The data_phase field describes the data transfer to be
  443. performed. Value is one of:
  444. TASKFILE_IN
  445. TASKFILE_MULTI_IN
  446. TASKFILE_OUT
  447. TASKFILE_MULTI_OUT
  448. TASKFILE_IN_OUT
  449. TASKFILE_IN_DMA
  450. TASKFILE_IN_DMAQ == IN_DMA (queueing not supported)
  451. TASKFILE_OUT_DMA
  452. TASKFILE_OUT_DMAQ == OUT_DMA (queueing not supported)
  453. TASKFILE_P_IN unimplemented
  454. TASKFILE_P_IN_DMA unimplemented
  455. TASKFILE_P_IN_DMAQ unimplemented
  456. TASKFILE_P_OUT unimplemented
  457. TASKFILE_P_OUT_DMA unimplemented
  458. TASKFILE_P_OUT_DMAQ unimplemented
  459. The req_cmd field classifies the command type. It may be
  460. one of:
  461. IDE_DRIVE_TASK_NO_DATA
  462. IDE_DRIVE_TASK_SET_XFER unimplemented
  463. IDE_DRIVE_TASK_IN
  464. IDE_DRIVE_TASK_OUT unimplemented
  465. IDE_DRIVE_TASK_RAW_WRITE
  466. [6] Do not access {in|out}_flags->all except for resetting
  467. all the bits. Always access individual bit fields. ->all
  468. value will flip depending on endianess. For the same
  469. reason, do not use IDE_{TASKFILE|HOB}_STD_{OUT|IN}_FLAGS
  470. constants defined in hdreg.h.
  471. HDIO_DRIVE_CMD execute a special drive command
  472. Note: If you don't have a copy of the ANSI ATA specification
  473. handy, you should probably ignore this ioctl.
  474. usage:
  475. u8 args[4+XFER_SIZE];
  476. ...
  477. ioctl(fd, HDIO_DRIVE_CMD, args);
  478. inputs:
  479. Commands other than WIN_SMART
  480. args[0] COMMAND
  481. args[1] NSECTOR
  482. args[2] FEATURE
  483. args[3] NSECTOR
  484. WIN_SMART
  485. args[0] COMMAND
  486. args[1] SECTOR
  487. args[2] FEATURE
  488. args[3] NSECTOR
  489. outputs:
  490. args[] buffer is filled with register values followed by any
  491. data returned by the disk.
  492. args[0] status
  493. args[1] error
  494. args[2] NSECTOR
  495. args[3] undefined
  496. args[4+] NSECTOR * 512 bytes of data returned by the command.
  497. error returns:
  498. EACCES Access denied: requires CAP_SYS_RAWIO
  499. ENOMEM Unable to allocate memory for task
  500. EIO Drive reports error
  501. notes:
  502. [1] For commands other than WIN_SMART, args[1] should equal
  503. args[3]. SECTOR, LCYL and HCYL are undefined. For
  504. WIN_SMART, 0x4f and 0xc2 are loaded into LCYL and HCYL
  505. respectively. In both cases SELECT will contain the default
  506. value for the drive. Please refer to HDIO_DRIVE_TASKFILE
  507. notes for the default value of SELECT.
  508. [2] If NSECTOR value is greater than zero and the drive sets
  509. DRQ when interrupting for the command, NSECTOR * 512 bytes
  510. are read from the device into the area following NSECTOR.
  511. In the above example, the area would be
  512. args[4..4+XFER_SIZE]. 16bit PIO is used regardless of
  513. HDIO_SET_32BIT setting.
  514. [3] If COMMAND == WIN_SETFEATURES && FEATURE == SETFEATURES_XFER
  515. && NSECTOR >= XFER_SW_DMA_0 && the drive supports any DMA
  516. mode, IDE driver will try to tune the transfer mode of the
  517. drive accordingly.
  518. HDIO_DRIVE_TASK execute task and special drive command
  519. Note: If you don't have a copy of the ANSI ATA specification
  520. handy, you should probably ignore this ioctl.
  521. usage:
  522. u8 args[7];
  523. ...
  524. ioctl(fd, HDIO_DRIVE_TASK, args);
  525. inputs:
  526. Taskfile register values:
  527. args[0] COMMAND
  528. args[1] FEATURE
  529. args[2] NSECTOR
  530. args[3] SECTOR
  531. args[4] LCYL
  532. args[5] HCYL
  533. args[6] SELECT
  534. outputs:
  535. Taskfile register values:
  536. args[0] status
  537. args[1] error
  538. args[2] NSECTOR
  539. args[3] SECTOR
  540. args[4] LCYL
  541. args[5] HCYL
  542. args[6] SELECT
  543. error returns:
  544. EACCES Access denied: requires CAP_SYS_RAWIO
  545. ENOMEM Unable to allocate memory for task
  546. ENOMSG Device is not a disk drive.
  547. EIO Drive failed the command.
  548. notes:
  549. [1] DEV bit (0x10) of SELECT register is ignored and the
  550. appropriate value for the drive is used. All other bits
  551. are used unaltered.
  552. HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
  553. Not implemented, as of 2.6.8.1
  554. HDIO_SET_32BIT change io_32bit flags
  555. usage:
  556. int val;
  557. ioctl(fd, HDIO_SET_32BIT, val);
  558. inputs:
  559. New value for io_32bit flag
  560. outputs: none
  561. error return:
  562. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  563. EACCES Access denied: requires CAP_SYS_ADMIN
  564. EINVAL value out of range [0 3]
  565. EBUSY Controller busy
  566. HDIO_SET_NOWERR change ignore-write-error flag
  567. usage:
  568. int val;
  569. ioctl(fd, HDIO_SET_NOWERR, val);
  570. inputs:
  571. New value for ignore-write-error flag. Used for ignoring
  572. WRERR_STAT
  573. outputs: none
  574. error return:
  575. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  576. EACCES Access denied: requires CAP_SYS_ADMIN
  577. EINVAL value out of range [0 1]
  578. EBUSY Controller busy
  579. HDIO_SET_DMA change use-dma flag
  580. usage:
  581. long val;
  582. ioctl(fd, HDIO_SET_DMA, val);
  583. inputs:
  584. New value for use-dma flag
  585. outputs: none
  586. error return:
  587. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  588. EACCES Access denied: requires CAP_SYS_ADMIN
  589. EINVAL value out of range [0 1]
  590. EBUSY Controller busy
  591. HDIO_SET_PIO_MODE reconfig interface to new speed
  592. usage:
  593. long val;
  594. ioctl(fd, HDIO_SET_PIO_MODE, val);
  595. inputs:
  596. New interface speed.
  597. outputs: none
  598. error return:
  599. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  600. EACCES Access denied: requires CAP_SYS_ADMIN
  601. EINVAL value out of range [0 255]
  602. EBUSY Controller busy
  603. HDIO_SCAN_HWIF register and (re)scan interface
  604. usage:
  605. int args[3]
  606. ...
  607. ioctl(fd, HDIO_SCAN_HWIF, args);
  608. inputs:
  609. args[0] io address to probe
  610. args[1] control address to probe
  611. args[2] irq number
  612. outputs: none
  613. error returns:
  614. EACCES Access denied: requires CAP_SYS_RAWIO
  615. EIO Probe failed.
  616. notes:
  617. This ioctl initializes the addresses and irq for a disk
  618. controller, probes for drives, and creates /proc/ide
  619. interfaces as appropriate.
  620. HDIO_UNREGISTER_HWIF unregister interface
  621. usage:
  622. int index;
  623. ioctl(fd, HDIO_UNREGISTER_HWIF, index);
  624. inputs:
  625. index index of hardware interface to unregister
  626. outputs: none
  627. error returns:
  628. EACCES Access denied: requires CAP_SYS_RAWIO
  629. notes:
  630. This ioctl removes a hardware interface from the kernel.
  631. Currently (2.6.8) this ioctl silently fails if any drive on
  632. the interface is busy.
  633. HDIO_SET_WCACHE change write cache enable-disable
  634. usage:
  635. int val;
  636. ioctl(fd, HDIO_SET_WCACHE, val);
  637. inputs:
  638. New value for write cache enable
  639. outputs: none
  640. error return:
  641. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  642. EACCES Access denied: requires CAP_SYS_ADMIN
  643. EINVAL value out of range [0 1]
  644. EBUSY Controller busy
  645. HDIO_SET_ACOUSTIC change acoustic behavior
  646. usage:
  647. int val;
  648. ioctl(fd, HDIO_SET_ACOUSTIC, val);
  649. inputs:
  650. New value for drive acoustic settings
  651. outputs: none
  652. error return:
  653. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  654. EACCES Access denied: requires CAP_SYS_ADMIN
  655. EINVAL value out of range [0 254]
  656. EBUSY Controller busy
  657. HDIO_SET_QDMA change use-qdma flag
  658. Not implemented, as of 2.6.8.1
  659. HDIO_SET_ADDRESS change lba addressing modes
  660. usage:
  661. int val;
  662. ioctl(fd, HDIO_SET_ADDRESS, val);
  663. inputs:
  664. New value for addressing mode
  665. 0 = 28-bit
  666. 1 = 48-bit
  667. 2 = 48-bit doing 28-bit
  668. outputs: none
  669. error return:
  670. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  671. EACCES Access denied: requires CAP_SYS_ADMIN
  672. EINVAL value out of range [0 2]
  673. EBUSY Controller busy
  674. EIO Drive does not support lba48 mode.
  675. HDIO_SET_IDE_SCSI
  676. usage:
  677. long val;
  678. ioctl(fd, HDIO_SET_IDE_SCSI, val);
  679. inputs:
  680. New value for scsi emulation mode (?)
  681. outputs: none
  682. error return:
  683. EINVAL (bdev != bdev->bd_contains) (not sure what this means)
  684. EACCES Access denied: requires CAP_SYS_ADMIN
  685. EINVAL value out of range [0 1]
  686. EBUSY Controller busy
  687. HDIO_SET_SCSI_IDE
  688. Not implemented, as of 2.6.8.1