libATA Developer s Guide(2).pdf

(1662 KB) Pobierz
libATA Developer’s Guide
Jeff Garzik
libATA Developer’s Guide
by Jeff Garzik
Copyright © 2003-2006 Jeff Garzik
The contents of this file are subject to the Open Software License version 1.1 that can be found at http://www.opensource.org/licenses/osl-1.1.txt
and is included herein by reference.
Alternatively, the contents of this file may be used under the terms of the GNU General Public License version 2 (the "GPL") as distributed in the
kernel source COPYING file, in which case the provisions of the GPL are applicable instead of the above. If you wish to allow the use of your
version of this file only under the terms of the GPL and not to allow others to use your version of this file under the OSL, indicate your decision by
deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions
above, a recipient may use your version of this file under either the OSL or the GPL.
Table of Contents
1. Introduction............................................................................................................................................1
2. libata Driver API ...................................................................................................................................2
2.1. struct ata_port_operations ...........................................................................................................2
2.1.1. Disable ATA port ............................................................................................................2
2.1.2. Post-IDENTIFY device configuration............................................................................2
2.1.3. Set PIO/DMA mode .......................................................................................................2
2.1.4. Taskfile read/write ..........................................................................................................3
2.1.5. PIO data read/write.........................................................................................................3
2.1.6. ATA command execute...................................................................................................3
2.1.7. Per-cmd ATAPI DMA capabilities filter.........................................................................4
2.1.8. Read specific ATA shadow registers...............................................................................4
2.1.9. Select ATA device on bus ...............................................................................................4
2.1.10. Private tuning method...................................................................................................4
2.1.11. Control PCI IDE BMDMA engine...............................................................................5
2.1.12. High-level taskfile hooks ..............................................................................................5
2.1.13. Exception and probe handling (EH) .............................................................................6
2.1.14. Hardware interrupt handling.........................................................................................7
2.1.15. SATA phy read/write ....................................................................................................7
2.1.16. Init and shutdown .........................................................................................................8
3. Error handling .......................................................................................................................................9
3.1. Origins of commands ..................................................................................................................9
3.2. How commands are issued..........................................................................................................9
3.3. How commands are processed ..................................................................................................10
3.4. How commands are completed .................................................................................................10
3.5. ata_scsi_error()..........................................................................................................................11
3.6. Problems with the current EH ...................................................................................................12
4. libata Library .......................................................................................................................................13
ata_link_next ....................................................................................................................................13
ata_dev_next.....................................................................................................................................13
atapi_cmd_type ................................................................................................................................14
ata_tf_to_fis......................................................................................................................................15
ata_tf_from_fis .................................................................................................................................16
ata_pack_xfermask...........................................................................................................................17
ata_unpack_xfermask.......................................................................................................................18
ata_xfer_mask2mode .......................................................................................................................19
ata_xfer_mode2mask .......................................................................................................................20
ata_xfer_mode2shift.........................................................................................................................21
ata_mode_string ...............................................................................................................................22
ata_dev_classify ...............................................................................................................................23
ata_id_string.....................................................................................................................................24
ata_id_c_string .................................................................................................................................25
ata_id_xfermask ...............................................................................................................................26
ata_pio_need_iordy ..........................................................................................................................28
ata_do_dev_read_id .........................................................................................................................28
ata_cable_40wire .............................................................................................................................29
iii
ata_cable_80wire .............................................................................................................................30
ata_cable_unknown..........................................................................................................................30
ata_cable_ignore ..............................................................................................................................31
ata_cable_sata ..................................................................................................................................32
ata_port_probe .................................................................................................................................33
ata_dev_pair .....................................................................................................................................33
ata_port_disable ...............................................................................................................................34
sata_set_spd .....................................................................................................................................35
ata_timing_cycle2mode ...................................................................................................................36
ata_do_set_mode..............................................................................................................................37
ata_wait_after_reset .........................................................................................................................38
sata_link_debounce ..........................................................................................................................39
sata_link_resume..............................................................................................................................40
ata_std_prereset................................................................................................................................41
sata_link_hardreset...........................................................................................................................42
sata_std_hardreset ............................................................................................................................43
ata_std_postreset ..............................................................................................................................45
ata_std_qc_defer ..............................................................................................................................45
ata_sg_init ........................................................................................................................................46
ata_qc_complete...............................................................................................................................47
ata_qc_complete_multiple ...............................................................................................................48
sata_scr_valid ...................................................................................................................................49
sata_scr_read ....................................................................................................................................50
sata_scr_write...................................................................................................................................51
sata_scr_write_flush.........................................................................................................................52
ata_link_online.................................................................................................................................53
ata_link_offline ................................................................................................................................54
ata_host_suspend .............................................................................................................................55
ata_host_resume...............................................................................................................................56
ata_port_start....................................................................................................................................57
ata_host_alloc...................................................................................................................................58
ata_host_alloc_pinfo ........................................................................................................................59
ata_slave_link_init ...........................................................................................................................60
ata_host_start ...................................................................................................................................62
ata_host_init .....................................................................................................................................63
ata_host_register ..............................................................................................................................64
ata_host_activate ..............................................................................................................................65
ata_host_detach ................................................................................................................................66
ata_pci_remove_one ........................................................................................................................67
ata_wait_register ..............................................................................................................................68
5. libata Core Internals............................................................................................................................70
ata_dev_phys_link............................................................................................................................70
ata_force_cbl ....................................................................................................................................70
ata_force_link_limits .......................................................................................................................71
ata_force_xfermask ..........................................................................................................................72
ata_force_horkage ............................................................................................................................73
ata_rwcmd_protocol.........................................................................................................................74
iv
ata_tf_read_block.............................................................................................................................75
ata_build_rw_tf ................................................................................................................................76
ata_dev_enable_pm..........................................................................................................................77
ata_dev_disable_pm .........................................................................................................................78
ata_read_native_max_address..........................................................................................................79
ata_set_max_sectors.........................................................................................................................80
ata_hpa_resize ..................................................................................................................................81
ata_dump_id.....................................................................................................................................82
ata_pio_queue_task ..........................................................................................................................83
ata_port_flush_task ..........................................................................................................................84
ata_exec_internal_sg ........................................................................................................................84
ata_exec_internal..............................................................................................................................86
ata_do_simple_cmd .........................................................................................................................87
ata_pio_mask_no_iordy ...................................................................................................................88
ata_dev_read_id ...............................................................................................................................89
ata_dev_configure ............................................................................................................................90
ata_bus_probe ..................................................................................................................................91
sata_print_link_status.......................................................................................................................92
sata_down_spd_limit........................................................................................................................93
sata_set_spd_needed ........................................................................................................................94
ata_down_xfermask_limit................................................................................................................95
ata_wait_ready .................................................................................................................................96
ata_dev_same_device.......................................................................................................................98
ata_dev_reread_id ............................................................................................................................99
ata_dev_revalidate..........................................................................................................................100
ata_is_40wire .................................................................................................................................101
cable_is_40wire .............................................................................................................................101
ata_dev_xfermask ..........................................................................................................................102
ata_dev_set_xfermode....................................................................................................................103
ata_dev_set_feature........................................................................................................................104
ata_dev_init_params ......................................................................................................................105
ata_sg_clean ...................................................................................................................................106
atapi_check_dma............................................................................................................................107
ata_sg_setup ...................................................................................................................................108
swap_buf_le16 ...............................................................................................................................109
ata_qc_new.....................................................................................................................................110
ata_qc_new_init .............................................................................................................................110
ata_qc_free .....................................................................................................................................111
ata_qc_issue ...................................................................................................................................112
ata_phys_link_online .....................................................................................................................113
ata_phys_link_offline .....................................................................................................................114
ata_dev_init ....................................................................................................................................115
ata_link_init ...................................................................................................................................116
sata_link_init_spd ..........................................................................................................................116
ata_port_alloc.................................................................................................................................117
ata_finalize_port_ops .....................................................................................................................118
ata_port_detach ..............................................................................................................................119
v
Zgłoś jeśli naruszono regulamin