hdio.txt 24 KB

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