@@ -44,6 +44,7 @@ Revision History:
4444
4545#define IDE_FEATURE_INVALID 0xFF
4646
47+ #define SCSI_VENDOR_ID_LENGTH (8)
4748
4849//
4950// ATA function code
@@ -84,7 +85,6 @@ Revision History:
8485#define ATA_FLAGS_ACTIVE_REFERENCE (1 << 10) // indicates Active Reference needs to be acquired before processing the Srb and released after processing the Srb
8586#define ATA_FLAGS_SENSEDATA_SET (1 << 11) // indicates sense data has been set to the Srb
8687
87-
8888//
8989// helper macros
9090//
@@ -114,9 +114,23 @@ typedef enum _AHCI_ETW_EVENT_IDS {
114114 AhciEtwEventUnitHybridEvict = 11 ,
115115 AhciEtwEventUnitHybridSetDirtyThreshold = 12 ,
116116 AhciEtwEventUnitHybridWriteThrough = 13 ,
117+ AhciEtwEventUnitFirmwareIoctl = 14 ,
118+ AhciEtwEventUnitFirmwareInfo = 15 ,
119+ AhciEtwEventUnitFirmwareDownload = 16 ,
120+ AhciEtwEventUnitFirmwareDownloadComplete = 17 ,
121+ AhciEtwEventUnitFirmwareActivate = 18 ,
122+ AhciEtwEventUnitFirmwareActivateComplete = 19 ,
123+ AhciEtwEventUnitGetPhysicalElementStatusComplete = 20 ,
124+ AhciEtwEventUnitRemoveElementAndTruncateComplete = 21 ,
125+ AhciEtwEventUnitGetInternalStatusDataHeaderComplete = 22 ,
126+ AhciEtwEventUnitGetInternalStatusDataComplete = 23 ,
127+ AhciEtwEventBuildIO = 24 ,
128+ AhciEtwEventStartIO = 25 ,
129+ AhciEtwEventHandleInterrupt = 26 ,
130+ AhciEtwEventPortReset = 27 ,
131+ AhciEtwEventIOCompletion = 28
117132} AHCI_ETW_EVENT_IDS , * PAHCI_ETW_EVENT_IDS ;
118133
119-
120134//
121135// task file register contents
122136//
@@ -312,6 +326,14 @@ typedef struct _HYBRID_EVICT_CONTEXT {
312326
313327} HYBRID_EVICT_CONTEXT , * PHYBRID_EVICT_CONTEXT ;
314328
329+ __inline
330+ BOOLEAN
331+ IsUnknownDevice (
332+ _In_ PATA_DEVICE_PARAMETERS DeviceParameters
333+ )
334+ {
335+ return (DeviceParameters -> AtaDeviceType == DeviceUnknown );
336+ }
315337
316338__inline
317339BOOLEAN
@@ -601,7 +623,8 @@ __inline
601623AhciAllocateDmaBuffer (
602624 _In_ PVOID AdapterExtension ,
603625 _In_ ULONG BufferLength ,
604- _Post_writable_byte_size_ (BufferLength ) PVOID * Buffer
626+ _Post_writable_byte_size_ (BufferLength ) PVOID * Buffer ,
627+ _Out_ PSTOR_PHYSICAL_ADDRESS PhysicalAddress
605628 )
606629{
607630 ULONG status ;
@@ -613,15 +636,16 @@ AhciAllocateDmaBuffer (
613636 maxPhysicalAddress .QuadPart = 0x7FFFFFFF ; // (2GB - 1)
614637 boundaryPhysicalAddress .QuadPart = 0 ;
615638
639+ status = StorPortAllocateDmaMemory (AdapterExtension ,
640+ BufferLength ,
641+ minPhysicalAddress ,
642+ maxPhysicalAddress ,
643+ boundaryPhysicalAddress ,
644+ MmCached ,
645+ MM_ANY_NODE_OK ,
646+ Buffer ,
647+ PhysicalAddress );
616648
617- status = StorPortAllocateContiguousMemorySpecifyCacheNode (AdapterExtension ,
618- BufferLength ,
619- minPhysicalAddress ,
620- maxPhysicalAddress ,
621- boundaryPhysicalAddress ,
622- MmCached ,
623- MM_ANY_NODE_OK ,
624- Buffer );
625649 return status ;
626650}
627651
@@ -631,14 +655,18 @@ __inline
631655AhciFreeDmaBuffer (
632656 _In_ PVOID AdapterExtension ,
633657 _In_ ULONG_PTR BufferLength ,
634- _In_reads_bytes_ (BufferLength ) _Post_invalid_ PVOID Buffer
658+ _In_reads_bytes_ (BufferLength ) _Post_invalid_ PVOID Buffer ,
659+ _In_opt_ STOR_PHYSICAL_ADDRESS PhysicalAddress
635660 )
636661{
637- ULONG status ;
638- status = StorPortFreeContiguousMemorySpecifyCache (AdapterExtension ,
639- Buffer ,
640- BufferLength ,
641- MmCached );
662+ ULONG status ;
663+
664+ status = StorPortFreeDmaMemory (AdapterExtension ,
665+ Buffer ,
666+ BufferLength ,
667+ MmCached ,
668+ PhysicalAddress );
669+
642670 return status ;
643671}
644672
@@ -862,6 +890,33 @@ AtaReportLunsCommand(
862890 _In_ PVOID Context
863891 );
864892
893+ ULONG
894+ AtaGetPhysicalElementStatusRequest (
895+ _In_ PAHCI_CHANNEL_EXTENSION ChannelExtension ,
896+ _In_ PSTORAGE_REQUEST_BLOCK Srb ,
897+ _In_ PCDB Cdb
898+ );
899+
900+ ULONG
901+ AtaRemoveElementAndTruncateRequest (
902+ _In_ PAHCI_CHANNEL_EXTENSION ChannelExtension ,
903+ _In_ PSTORAGE_REQUEST_BLOCK Srb ,
904+ _In_ PCDB Cdb
905+ );
906+
907+ ULONG
908+ AtaGetDeviceCurrentInternalStatusData (
909+ _In_ PAHCI_CHANNEL_EXTENSION ChannelExtension ,
910+ _In_ PSTORAGE_REQUEST_BLOCK Srb ,
911+ _In_ PCDB Cdb
912+ );
913+
914+ ULONG
915+ AtaGetDeviceCurrentInternalStatusDataHeader (
916+ _In_ PAHCI_CHANNEL_EXTENSION ChannelExtension ,
917+ _In_ PSTORAGE_REQUEST_BLOCK Srb ,
918+ _In_ PCDB Cdb
919+ );
865920
866921UCHAR
867922AtaMapError (
@@ -965,11 +1020,57 @@ FirmwareIoctlProcess(
9651020 );
9661021
9671022
1023+ //
1024+ // AHCI Telemetry event related.
1025+ //
1026+ #define AHCI_TELEMETRY_EVENT_VERSION 0x1
1027+ #define AHCI_TELEMETRY_DRIVER_VERSION 0x1
1028+
1029+ #define AHCI_TELEMETRY_FLAG_NOT_SUPPRESS_LOGGING 0x1
1030+
1031+ typedef enum _AHCI_TELEMETRY_EVENT_ID {
1032+ AhciTelemetryEventIdGeneral = 0 ,
1033+ AhciTelemetryEventIdPortReset = 1 ,
1034+ AhciTelemetryEventIdPortRunningStartFail = 2 ,
1035+ AhciTelemetryEventIdPortErrorRecovery = 3 ,
1036+ AhciTelemetryEventIdNonqueuedErrorRecovery = 4 ,
1037+ AhciTelemetryEventIdNCQErrorRecovery = 5 ,
1038+ AhciTelemetryEventIdNCQErrorRecoveryComplete = 6 ,
1039+ AhciTelemetryEventIdResetBus = 7 ,
1040+ AhciTelemetryEventIdResetDeviceRequest = 8 ,
1041+ AhciTelemetryEventIdSurpriseRemove = 9 ,
1042+ AhciTelemetryEventIdLpmAdaptiveSetting = 10 ,
1043+ AhciTelemetryEventIdLpmSettingsModes = 11 ,
1044+ AhciTelemetryEventIdPortStartSuccess = 12 ,
1045+ AhciTelemetryEventIdReservedSlotStuck = 13 ,
1046+ AhciTelemetryEventIdMax = 256
1047+ } AHCI_TELEMETRY_EVENT_ID , * PAHCI_TELEMETRY_EVENT_ID ;
1048+
1049+ //
1050+ // AHCI mark device failure related.
1051+ //
1052+ #define AHCI_BUS_CHANGE_WARNING_THROTTLE_MASK (0x1 << 0)
1053+ #define AHCI_BUS_CHANGE_COUNT_WARNING_THRESHOLD (20)
1054+
1055+ #define AHCI_NCQ_ERROR_WARNING_THROTTLE_MASK (0x1 << 1)
1056+ #define AHCI_NCQ_ERROR_COUNT_WARNING_THRESHOLD (100)
1057+
1058+ #define AHCI_NON_QUEUED_ERROR_WARNING_THROTTLE_MASK (0x1 << 2)
1059+ #define AHCI_NON_QUEUED_ERROR_COUNT_WARNING_THRESHOLD (100)
1060+
1061+ #define AHCI_DEVICE_STUCK_WARNING_THROTTLE_MASK (0x1 << 3)
1062+
1063+ typedef enum _AHCI_DEVICE_FAILURE_REASON {
1064+ AhciDeviceFailureUnspecific = 0 ,
1065+ AhciDeviceFailureTooManyBusChange = 1 ,
1066+ AhciDeviceFailureTooManyNCQError = 2 ,
1067+ AhciDeviceFailureTooManyNonQueuedError = 3 ,
1068+ AhciDeviceFailureDeviceStuck = 4
1069+ } AHCI_DEVICE_FAILURE_REASON , * PAHCI_DEVICE_FAILURE_REASON ;
9681070
9691071#if _MSC_VER >= 1200
9701072#pragma warning(pop)
9711073#else
9721074#pragma warning(default:4214)
9731075#pragma warning(default:4201)
9741076#endif
975-
0 commit comments