hdio.rst 27 KB

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