Presentation is loading. Please wait.

Presentation is loading. Please wait.

AHCI: ATAport Miniport Example. Outline AHCI Features Goals Basics AHCI ATA Miniport Design Philosophy Memory Structures and Resources Enumeration IO.

Similar presentations


Presentation on theme: "AHCI: ATAport Miniport Example. Outline AHCI Features Goals Basics AHCI ATA Miniport Design Philosophy Memory Structures and Resources Enumeration IO."— Presentation transcript:

1 AHCI: ATAport Miniport Example

2 Outline AHCI Features Goals Basics AHCI ATA Miniport Design Philosophy Memory Structures and Resources Enumeration IO Creation Error Handling

3 Role of AHCI Industry transitioning to SATA, AHCI provides a standard interface and is facilitating adoption Implementing AHCI interface in a controller doesn’t prevent the controller from implementing 8038i/PCIIDE AHCI follows advancements in PCI PCI 2.3, power management, MSI, etc. AHCI comprehends SATA features

4 Feature Basics 8038i/PCIIDE (PATA) Controller Resources IO Port 2 channel per controller 2 devices per channel Interrupt Capabilities Interrupt per channel No hot plug No power management No notification IO Capabilities PIO interrupt per DRQ Software queuing Tagged Command Queuing AHCI 1.0 (SATA) Controller Resources Memory Mapped 32 channels per controller 15 devices per channel Interrupt Capabilities Selective interrupt hierarchy Hot plug supported Link power management Asynchronous notification IO Capabilities PIO through DMA Hardware queuing Native Command Queueing

5 AHCI Design: Memory Structures and Resources Controller Extension ABAR AdapterControl w/ IdeStart receives ABAR as part of ControllerConfiguration->ControllerResources Channel Extension One per channel Uncached Extension One per channel Page aligned Contains Command List and FIS Receive Buffer IRB Extension Contains Command Table First IRB’s Extension is Page aligned, all other IRB Extensions are IRB Extension size aligned

6 AHCI Design: Synchronization Per channel, only one channel entry point will be running at a time AdapterControl The port driver ensures that there is no outstanding I/O on the adapter before invoking this routine. Interrupts are enabled just before the HwControl w/ IdeStart is called. If Interrupts are enabled, the Interrupt routine may be called after this.

7 AHCI Design: IRB Return Values If the IRB status is not IRB_STATUS_DEVICE_ERROR, the port assumes that the miniport has done the error translation already and so the Error register is ignored. IRB_STATUS_PENDING is used internally to signal ‘waiting on interrupt’. The miniport should not complete IRB if it is still waiting on an interrupt. IRB_STATUS_DATALENGTH_MISMATCH Return the actual byteCount Irb->DataTransferLength -= GetBytesLeft(ChannelExtension, Irb); Don’t set this on RequestSense IRBs, as the amount of data expected is unknown

8 AHCI Design: IRB Return Values (con’t) IRB_STATUS_BUSY should be used when device is busy and the miniport wants the ATAport driver to retry the command. Use BUSY with AtaPortCompleteAllActiveRequests Always pause ATAport queues with AtaPortDeviceBusy() when returning BUSY IRB_STATUS_SELECTION_TIMEOUT should be used when the controller is not capable of handling IO. The ATAport driver will not retry the command. IRB_STATUS_BUS_RESET IRB_STATUS_INVALID_REQUEST IRB_STATUS_SUCCESS

9 AHCI Design: Enumeration Port sends ID_DEVICE, then ID_PACKET_DEVICE (or vice versa) IRBs completed with IRB_STATUS_BUSY will be retried All other IRB status values will be interpreted as enumeration failure Status 0xFF, 0xFE will be interpreted as no device Enabling an AHCI channel (CMD.ST) may take milliseconds. Pausing ATAport queues can be an effective StallTimer if attempts to move the controller to P:Running are made from StartIo.

10 AHCI Design: Creating IO Miniport’s create IRBs only in uncommon circumstances Request Sense AtaPortBuildRequestSenseIrb (ChannelExtension, root IRB) Request Sense IrbExtension is the same as the Request Sense root IRB’s IrbExtension Don’t use SGList, use IRB Data Buffer Read Log Ext Used to determine NCQ failures Set Features HwInitialize AtaPortCompleteAllActiveRequests do not complete miniport created IRBs … however it will complete Request Sense root IRBs

11 AHCI Design: Crashdump Must be handled at any time The miniport driver is reloaded Only kernel, ATAport and miniport are running, therefore initialization is very fast The port driver will only enable the channel that contains the device with the page file The controller is very likely enabled (AE = 1) and handling IO, in which case it must be stopped and restarted

12 AHCI Design: Miscellaneous Hotplug Interrupt routine should use AtaPortDeviceArrived and AtaPortDeviceRemoved for hotplug events Causes ATAport to invalidate device relations appropriately Reset/Error Handling AtaPortCompleteAllActiveRequests is very handy. Complete everything with BUSY, restore stability, and let the ATAport driver handle retrying commands

13 Additional Resources ATA Miniport Interface Documented in the WDK List of Specifications ATA: http://www.t13.orghttp://www.t13.org SATA: http://www.serialata.orghttp://www.serialata.org SCSI: http://www.t10.orghttp://www.t10.org AHCI: http://developer.intel.com/technology/serialata/ahci.htm http://developer.intel.com/technology/serialata/ahci.htm WhitePapers ATA Miniport Design Guide MSI Guidance http://download.microsoft.com/download/5/7/7/577a568 4-8a83-43ae-9272-ff260a9c20e2/MSI.doc http://download.microsoft.com/download/5/7/7/577a568 4-8a83-43ae-9272-ff260a9c20e2/MSI.doc

14 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "AHCI: ATAport Miniport Example. Outline AHCI Features Goals Basics AHCI ATA Miniport Design Philosophy Memory Structures and Resources Enumeration IO."

Similar presentations


Ads by Google