⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libata.tmpl

📁 linux 内核源代码
💻 TMPL
📖 第 1 页 / 共 4 页
字号:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"	"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []><book id="libataDevGuide"> <bookinfo>  <title>libATA Developer's Guide</title>    <authorgroup>   <author>    <firstname>Jeff</firstname>    <surname>Garzik</surname>   </author>  </authorgroup>  <copyright>   <year>2003-2006</year>   <holder>Jeff Garzik</holder>  </copyright>  <legalnotice>   <para>   The contents of this file are subject to the Open   Software License version 1.1 that can be found at   <ulink url="http://www.opensource.org/licenses/osl-1.1.txt">http://www.opensource.org/licenses/osl-1.1.txt</ulink> and is included herein   by reference.   </para>   <para>   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.   </para>  </legalnotice> </bookinfo><toc></toc>  <chapter id="libataIntroduction">     <title>Introduction</title>  <para>  libATA is a library used inside the Linux kernel to support ATA host  controllers and devices.  libATA provides an ATA driver API, class  transports for ATA and ATAPI devices, and SCSI&lt;-&gt;ATA translation  for ATA devices according to the T10 SAT specification.  </para>  <para>  This Guide documents the libATA driver API, library functions, library  internals, and a couple sample ATA low-level drivers.  </para>  </chapter>  <chapter id="libataDriverApi">     <title>libata Driver API</title>     <para>     struct ata_port_operations is defined for every low-level libata     hardware driver, and it controls how the low-level driver     interfaces with the ATA and SCSI layers.     </para>     <para>     FIS-based drivers will hook into the system with ->qc_prep() and     ->qc_issue() high-level hooks.  Hardware which behaves in a manner     similar to PCI IDE hardware may utilize several generic helpers,     defining at a bare minimum the bus I/O addresses of the ATA shadow     register blocks.     </para>     <sect1>        <title>struct ata_port_operations</title>	<sect2><title>Disable ATA port</title>	<programlisting>void (*port_disable) (struct ata_port *);	</programlisting>	<para>	Called from ata_bus_probe() and ata_bus_reset() error paths,	as well as when unregistering from the SCSI module (rmmod, hot	unplug).	This function should do whatever needs to be done to take the	port out of use.  In most cases, ata_port_disable() can be used	as this hook.	</para>	<para>	Called from ata_bus_probe() on a failed probe.	Called from ata_bus_reset() on a failed bus reset.	Called from ata_scsi_release().	</para>	</sect2>	<sect2><title>Post-IDENTIFY device configuration</title>	<programlisting>void (*dev_config) (struct ata_port *, struct ata_device *);	</programlisting>	<para>	Called after IDENTIFY [PACKET] DEVICE is issued to each device	found.  Typically used to apply device-specific fixups prior to	issue of SET FEATURES - XFER MODE, and prior to operation.	</para>	<para>	Called by ata_device_add() after ata_dev_identify() determines	a device is present.	</para>	<para>	This entry may be specified as NULL in ata_port_operations.	</para>	</sect2>	<sect2><title>Set PIO/DMA mode</title>	<programlisting>void (*set_piomode) (struct ata_port *, struct ata_device *);void (*set_dmamode) (struct ata_port *, struct ata_device *);void (*post_set_mode) (struct ata_port *);unsigned int (*mode_filter) (struct ata_port *, struct ata_device *, unsigned int);	</programlisting>	<para>	Hooks called prior to the issue of SET FEATURES - XFER MODE	command.  The optional ->mode_filter() hook is called when libata	has built a mask of the possible modes. This is passed to the 	->mode_filter() function which should return a mask of valid modes	after filtering those unsuitable due to hardware limits. It is not	valid to use this interface to add modes.	</para>	<para>	dev->pio_mode and dev->dma_mode are guaranteed to be valid when	->set_piomode() and when ->set_dmamode() is called. The timings for	any other drive sharing the cable will also be valid at this point.	That is the library records the decisions for the modes of each	drive on a channel before it attempts to set any of them.	</para>	<para>	->post_set_mode() is	called unconditionally, after the SET FEATURES - XFER MODE	command completes successfully.	</para>	<para>	->set_piomode() is always called (if present), but	->set_dma_mode() is only called if DMA is possible.	</para>	</sect2>	<sect2><title>Taskfile read/write</title>	<programlisting>void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);	</programlisting>	<para>	->tf_load() is called to load the given taskfile into hardware	registers / DMA buffers.  ->tf_read() is called to read the	hardware registers / DMA buffers, to obtain the current set of	taskfile register values.	Most drivers for taskfile-based hardware (PIO or MMIO) use	ata_tf_load() and ata_tf_read() for these hooks.	</para>	</sect2>	<sect2><title>PIO data read/write</title>	<programlisting>void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int);	</programlisting>	<para>All bmdma-style drivers must implement this hook.  This is the low-leveloperation that actually copies the data bytes during a PIO datatransfer.Typically the driverwill choose one of ata_pio_data_xfer_noirq(), ata_pio_data_xfer(), orata_mmio_data_xfer().	</para>	</sect2>	<sect2><title>ATA command execute</title>	<programlisting>void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);	</programlisting>	<para>	causes an ATA command, previously loaded with	->tf_load(), to be initiated in hardware.	Most drivers for taskfile-based hardware use ata_exec_command()	for this hook.	</para>	</sect2>	<sect2><title>Per-cmd ATAPI DMA capabilities filter</title>	<programlisting>int (*check_atapi_dma) (struct ata_queued_cmd *qc);	</programlisting>	<para>Allow low-level driver to filter ATA PACKET commands, returning a statusindicating whether or not it is OK to use DMA for the supplied PACKETcommand.	</para>	<para>	This hook may be specified as NULL, in which case libata will	assume that atapi dma can be supported.	</para>	</sect2>	<sect2><title>Read specific ATA shadow registers</title>	<programlisting>u8   (*check_status)(struct ata_port *ap);u8   (*check_altstatus)(struct ata_port *ap);	</programlisting>	<para>	Reads the Status/AltStatus ATA shadow register from	hardware.  On some hardware, reading the Status register has	the side effect of clearing the interrupt condition.	Most drivers for taskfile-based hardware use	ata_check_status() for this hook.	</para>	<para>	Note that because this is called from ata_device_add(), at	least a dummy function that clears device interrupts must be	provided for all drivers, even if the controller doesn't	actually have a taskfile status register.	</para>	</sect2>	<sect2><title>Select ATA device on bus</title>	<programlisting>void (*dev_select)(struct ata_port *ap, unsigned int device);	</programlisting>	<para>	Issues the low-level hardware command(s) that causes one of N	hardware devices to be considered 'selected' (active and	available for use) on the ATA bus.  This generally has no	meaning on FIS-based devices.	</para>	<para>	Most drivers for taskfile-based hardware use	ata_std_dev_select() for this hook.  Controllers which do not	support second drives on a port (such as SATA contollers) will	use ata_noop_dev_select().	</para>	</sect2>	<sect2><title>Private tuning method</title>	<programlisting>void (*set_mode) (struct ata_port *ap);	</programlisting>	<para>	By default libata performs drive and controller tuning in	accordance with the ATA timing rules and also applies blacklists	and cable limits. Some controllers need special handling and have	custom tuning rules, typically raid controllers that use ATA	commands but do not actually do drive timing.	</para>	<warning>	<para>	This hook should not be used to replace the standard controller	tuning logic when a controller has quirks. Replacing the default	tuning logic in that case would bypass handling for drive and	bridge quirks that may be important to data reliability. If a	controller needs to filter the mode selection it should use the	mode_filter hook instead.	</para>	</warning>	</sect2>	<sect2><title>Control PCI IDE BMDMA engine</title>	<programlisting>void (*bmdma_setup) (struct ata_queued_cmd *qc);void (*bmdma_start) (struct ata_queued_cmd *qc);void (*bmdma_stop) (struct ata_port *ap);u8   (*bmdma_status) (struct ata_port *ap);	</programlisting>	<para>When setting up an IDE BMDMA transaction, these hooks arm(->bmdma_setup), fire (->bmdma_start), and halt (->bmdma_stop)the hardware's DMA engine.  ->bmdma_status is used to read the standardPCI IDE DMA Status register.	</para>	<para>These hooks are typically either no-ops, or simply not implemented, inFIS-based drivers.	</para>	<para>Most legacy IDE drivers use ata_bmdma_setup() for the bmdma_setup()hook.  ata_bmdma_setup() will write the pointer to the PRD table tothe IDE PRD Table Address register, enable DMA in the DMA Commandregister, and call exec_command() to begin the transfer.	</para>	<para>Most legacy IDE drivers use ata_bmdma_start() for the bmdma_start()hook.  ata_bmdma_start() will write the ATA_DMA_START flag to the DMACommand register.	</para>	<para>Many legacy IDE drivers use ata_bmdma_stop() for the bmdma_stop()hook.  ata_bmdma_stop() clears the ATA_DMA_START flag in the DMAcommand register.	</para>	<para>Many legacy IDE drivers use ata_bmdma_status() as the bmdma_status() hook.	</para>	</sect2>	<sect2><title>High-level taskfile hooks</title>	<programlisting>void (*qc_prep) (struct ata_queued_cmd *qc);int (*qc_issue) (struct ata_queued_cmd *qc);	</programlisting>	<para>	Higher-level hooks, these two hooks can potentially supercede	several of the above taskfile/DMA engine hooks.  ->qc_prep is	called after the buffers have been DMA-mapped, and is typically	used to populate the hardware's DMA scatter-gather table.	Most drivers use the standard ata_qc_prep() helper function, but	more advanced drivers roll their own.	</para>	<para>	->qc_issue is used to make a command active, once the hardware	and S/G tables have been prepared.  IDE BMDMA drivers use the	helper function ata_qc_issue_prot() for taskfile protocol-based	dispatch.  More advanced drivers implement their own ->qc_issue.	</para>	<para>	ata_qc_issue_prot() calls ->tf_load(), ->bmdma_setup(), and	->bmdma_start() as necessary to initiate a transfer.	</para>	</sect2>	<sect2><title>Exception and probe handling (EH)</title>	<programlisting>void (*eng_timeout) (struct ata_port *ap);void (*phy_reset) (struct ata_port *ap);	</programlisting>	<para>Deprecated.  Use ->error_handler() instead.	</para>	<programlisting>void (*freeze) (struct ata_port *ap);void (*thaw) (struct ata_port *ap);	</programlisting>	<para>ata_port_freeze() is called when HSM violations or some othercondition disrupts normal operation of the port.  A frozen portis not allowed to perform any operation until the port isthawed, which usually follows a successful reset.	</para>	<para>The optional ->freeze() callback can be used for freezing the porthardware-wise (e.g. mask interrupt and stop DMA engine).  If aport cannot be frozen hardware-wise, the interrupt handlermust ack and clear interrupts unconditionally while the portis frozen.	</para>	<para>The optional ->thaw() callback is called to perform the opposite of ->freeze():prepare the port for normal operation once again.  Unmask interrupts,start DMA engine, etc.	</para>	<programlisting>void (*error_handler) (struct ata_port *ap);	</programlisting>	<para>->error_handler() is a driver's hook into probe, hotplug, and recoveryand other exceptional conditions.  The primary responsibility of animplementation is to call ata_do_eh() or ata_bmdma_drive_eh() with a setof EH hooks as arguments:	</para>	<para>'prereset' hook (may be NULL) is called during an EH reset, before any other actionsare taken.	</para>	<para>'postreset' hook (may be NULL) is called after the EH reset is performed.  Based onexisting conditions, severity of the problem, and hardware capabilities,	</para>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -