Skip to content

Commit dbadff8

Browse files
authored
Merged current inbox code except for DDKSPLIT (#474)
* Merged current inbox code except for DDKSPLIT * 19H1 inbox code except for DDKSPLIT and storport_p.h * Removed internal code
1 parent 9afd930 commit dbadff8

File tree

16 files changed

+4549
-1223
lines changed

16 files changed

+4549
-1223
lines changed

storage/miniports/storahci/src/ahci.h

Lines changed: 53 additions & 54 deletions
Large diffs are not rendered by default.

storage/miniports/storahci/src/common.c

Lines changed: 1404 additions & 229 deletions
Large diffs are not rendered by default.

storage/miniports/storahci/src/common.h

Lines changed: 119 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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
317339
BOOLEAN
@@ -601,7 +623,8 @@ __inline
601623
AhciAllocateDmaBuffer (
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
631655
AhciFreeDmaBuffer (
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

866921
UCHAR
867922
AtaMapError(
@@ -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-
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*++
2+
3+
Copyright (c) 2017 Microsoft Corporation
4+
5+
Module Name:
6+
7+
data.h
8+
9+
Abstract:
10+
11+
Definitions needed by storahci log/diagnostic function.
12+
13+
Author:
14+
15+
--*/
16+
17+
#pragma once
18+
19+
//
20+
// Diagnostic data definitions for STORAHCI
21+
//
22+
23+
#define MAX_EXECUTION_HISTORY_ENTRY_COUNT 200 // 200 entries take up 20KB
24+
25+
typedef struct _SLOT_MANAGER {
26+
27+
ULONG HighPriorityAttribute;
28+
29+
ULONG NCQueueSlice;
30+
ULONG NormalQueueSlice;
31+
ULONG SingleIoSlice;
32+
33+
ULONG CommandsIssued;
34+
ULONG CommandsToComplete;
35+
36+
//
37+
// These issued slices are used to determine the type of command
38+
// being programmed to adapter.
39+
// They are used instead of reading PxCI and PxSACT.
40+
//
41+
ULONG NCQueueSliceIssued;
42+
ULONG NormalQueueSliceIssued;
43+
ULONG SingleIoSliceIssued;
44+
45+
ULONG Reserved;
46+
47+
} SLOT_MANAGER, *PSLOT_MANAGER;
48+
49+
typedef struct _EXECUTION_HISTORY {
50+
51+
ULONG Function;
52+
ULONG IS;
53+
SLOT_MANAGER SlotManager; //SLOT_MANAGER from _AHCI_CHANNEL_EXTENSION
54+
ULONG Px[0x10]; //Px registers value, end to AHCI_SNOTIFICATION -- SNTF
55+
LARGE_INTEGER TimeStamp;
56+
57+
} EXECUTION_HISTORY, *PEXECUTION_HISTORY;
58+
59+
typedef struct _ATA_IO_RECORD {
60+
61+
ULONG SuccessCount;
62+
63+
ULONG CrcErrorCount;
64+
ULONG MediaErrorCount;
65+
ULONG EndofMediaCount;
66+
ULONG IllegalCommandCount;
67+
ULONG AbortedCommandCount;
68+
ULONG DeviceFaultCount;
69+
70+
ULONG OtherErrorCount;
71+
72+
ULONG NcqReadLogErrorCount; // used to record the READ LOG EXT command error count when used for NCQ Error Recovery.
73+
74+
ULONG PortDriverResetCount;
75+
ULONG TotalResetCount;
76+
77+
} ATA_IO_RECORD, *PATA_IO_RECORD;
78+
79+
typedef struct _STORAGE_DIAGNOSTIC_AHCI_EXECUTION_HISTORY {
80+
81+
ULONG ExecutionHistoryCount;
82+
ULONG ExecutionHistoryIndex;
83+
EXECUTION_HISTORY History[MAX_EXECUTION_HISTORY_ENTRY_COUNT];
84+
85+
} STORAGE_DIAGNOSTIC_AHCI_EXECUTION_HISTORY, *PSTORAGE_DIAGNOSTIC_AHCI_EXECUTION_HISTORY;
86+
87+
typedef struct _STORAGE_DIAGNOSTIC_AHCI_DATA {
88+
89+
ULONG Version;
90+
ULONG Count;
91+
STORAGE_DIAGNOSTIC_AHCI_EXECUTION_HISTORY ExecutionHistory;
92+
AHCI_PORT Registers;
93+
ATA_IO_RECORD IoRecord;
94+
95+
} STORAGE_DIAGNOSTIC_AHCI_DATA, *PSTORAGE_DIAGNOSTIC_AHCI_DATA;
96+

0 commit comments

Comments
 (0)