Presentation is loading. Please wait.

Presentation is loading. Please wait.

ATA Miniport Nuts and Bolts

Similar presentations


Presentation on theme: "ATA Miniport Nuts and Bolts"— Presentation transcript:

1

2 ATA Miniport Nuts and Bolts
Michael Xing SDE II Device and Storage Technologies

3 Agenda Why ATA Miniport? ATA Port / Miniport Model
ATA Port / Miniport Interfaces New Interfaces in Windows 7 Best Practices

4 Why ATA miniport? Do I need an miniport driver?
Controllers supported by inbox drivers Microsoft inbox ATA miniport drivers: atapi.sys – developed for legacy PATA controllers msahci.sys – developed for SATA controllers Consider options other than a driver Special requirements that are not covered by inbox drivers: Your hardware uses ATA protocol but has a different transfer layer or exposes special feature(s) Contact us about feature support before developing your own miniport driver

5 Why ATA miniport? Which port driver model should I use?
Windows versions support ATAport: Vista and later Storport: Server 2003 and later Command protocol selection ATAport / miniport command protocol: ATA Storport / miniport command protocol: SCSI Common ATA functionalities implemented in ATA port driver Such as set device attributes, set transfer mode, etc. Less code in miniport

6 ATA Port/Miniport Model – Driver Stack
Class Driver ATA Port DLLs - ATAport.sys - PCIIDEx.sys ATA Miniport Driver PCI Driver

7 ATA Port/Miniport Model – Loading Sequence
PCIIDEx.sys Create Channel FDO Create Device FDO Load ATA Miniport Load ATAport.sys Create Channel PDO Load Class Driver Create Controller PDO Enumerate Channels Create Device PDO PCI Driver Create Controller FDO Enumerate Devices ATA Controller

8 ATA Port/Miniport Model – Role of ATA Port Driver
I/O translation into ATA protocol I/O queuing with prioritization considered Sense Data generation for ATA devices PnP and power request handling Request to miniport driver in push mode

9 ATA Port/Miniport Model – Role of ATA Miniport Driver
Convert ATA command into final transfer layer package if necessary Send final command to device Monitor interrupt for command completion Negotiate for channel and device parameters Select queue depth Freeze/unfreeze queue according to device status

10 Port / Miniport Interfaces – General
ATAport Default Miniport ATA Port DLLs - ATAport.sys - PCIidex.sys Channel Interface ATA Controller I/O Controller Interface Vendor Miniport ATA Miniport Driver PCIidex

11 Port / Miniport Interfaces – Miniport Major Routines
Controller Interface Routines DriverEntry() AtaAdapterControl() – PnP, power operations AtaControllerChannelEnabled() – Channel is usable or not Channel Interface Routines AtaChannelInitRoutine() – Set routine pointers for channel IdeHwControl() – PnP, power operations IdeHwInitialize() – Device initialization IdeHwBuildIo() – I/O preparation IdeHwStartIo() – Execute the I/O IdeHwInterrupt() – Monitor hardware activities; process I/O completion

12 Port / Miniport Interfaces - Controller Interfaces
ATA Port Processes AtaControllerChannelEnabled() Create Channel PDO AtaAdapterControl() with IdeStart Enumerate Channels DriverEntry() (Set callback function pointers) Start Device (Controller) Add Device - Create Controller FDO Load PCIIDEx.sys Load ATA Miniport Load ATAport.sys AtaPortInitializeEx()

13 Port / Miniport Interfaces - Channel Interfaces
ATA Port Processes IdeHwInterrupt() I/O IdeHwStartIo() Create Device PDO IdeHwBuildIo() Configure Devices IdeHwInitialize() Enumerate Devices IdeHwControl() with IdeStart Start Channel AtaChannelInitRoutine() Add Device – Create Channel FDO

14 Port / Miniport Interfaces – I/O Interface
IDE_REQUEST_BLOCK Contains Structure for ATA TaskFile I/O execute mode – PIO or DMA Data buffer for the I/O Other information needed by Miniport driver to execute the command Status and Error field Usage I/O request Miniport action, such as power down the device // 0x x1FF indicate ATA commands #define IRB_FUNCTION_ATA_COMMAND x100 #define IRB_FUNCTION_ATA_IDENTIFY x101 #define IRB_FUNCTION_ATA_READ x102 #define IRB_FUNCTION_ATA_WRITE x103 #define IRB_FUNCTION_ATA_FLUSH x104 #define IRB_FUNCTION_ATA_SMART x105 // 0x x2FF indicate ATAPI commands #define IRB_FUNCTION_ATAPI_COMMAND x200 #define IRB_FUNCTION_REQUEST_SENSE x201 // 0x400-0x4FF indicate miniport commands #define IRB_FUNCTION_MINIPORT_COMMAND 0x400 #define IRB_FUNCTION_ADAPTER_FLUSH x401 #define IRB_FUNCTION_SHUTDOWN x402 #define IRB_FUNCTION_POWER_CHANGE x403 #define IRB_FUNCTION_LUN_RESET x404 #define IRB_FUNCTION_MINIPORT_IOCTL 0x405 #define IRB_FUNCTION_POWER_REBOOT x406

15 New Interfaces in Windows 7
System Reboot Notification IRB_FUNCTION_POWER_REBOOT Vendor-Defined Power Management IDE_CONTROL_ACTION – IdeVendorDefined Device Parameter Flags Removable Device Flag – DFLAGS_REMOVABLE_DEVICE FUA Support Flag – DFLAGS_FUA_SUPPORT

16 Best Practices - Device Parameter Changes
Changing removable device flag in Microsoft Miniport driver for SATA controller BOOLEAN AhciHwInitialize ( IN PVOID ChannelExtension, IN OUT PIDE_DEVICE_PARAMETERS DeviceParameters, IN PIDENTIFY_DEVICE_DATA IdentifyData ) { // 3.1 Removable Device Detect if ((channelExtension->Px->CMD.HPCP) || ((channelExtension->CAP.SXS) && (channelExtension->Px->CMD.ESP))) { // Px->CMD.HPCP indicates that the port is hot-pluggable. (both signal and power cable) // CAP.SXS && Px->CMD.ESP indicates that it's an ESATA port. (only signal cable) DeviceParameters->DeviceCharacteristics |= DFLAGS_REMOVABLE_DEVICE; } return TRUE;

17 Best Practices – Pause Process
AtaPortStallExecution() Spin locks the CPU for x microseconds Less than one millisecond delays Should be used during hibernate or crash dump AtaPortRequestTimer() Causes the port driver to trigger a callback routine after x microseconds Greater than one millisecond delays Best when used with multiphase functions

18 Best Practices – I/O Error Reporting
IRB_STATUS_DEVICE_ERROR Most common I/O error code IRB_STATUS_BUSY Host is busy Make sure to pause the queues with AtaPortDeviceBusy() IRB_STATUS_SELECTION_TIMEOUT Not necessarily retried Port driver may reset the device IRB AtaStatus and Error fields Only valid on IRB_STATUS_DEVICE_ERROR or IRB_STATUS_SELECTION_TIMEOUT

19 Calls to Action Read “ATA Miniport Drivers” in MSDN
Refer to sample code Microsoft Miniport driver for AHCI controller in WDK at src\storage\msahci Ask questions at ATA Miniport Driver Development Forum Contact us about feature support:

20 Resources Related Specifications Related Sessions
ATA - SATA - AHCI - Related Sessions Session Day / Time Storport Drivers from the Ground Up Tues. 8:30-9:30 and Wed. 9:45-10:45 Storport Smorgasboard Tues. 4-5 and Wed

21 Questions ?


Download ppt "ATA Miniport Nuts and Bolts"

Similar presentations


Ads by Google