Author: apriyadarshi
Date: Sun Aug 14 12:54:10 2016
New Revision: 72219
URL:
http://svn.reactos.org/svn/reactos?rev=72219&view=rev
Log:
Added Port Reset for non Idle ports
FIXED missing VendorId, RevisionId and SerialNo
Modified:
branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c
branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h
Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Sun Aug 14
12:54:10 2016
@@ -24,8 +24,8 @@
)
{
AHCI_PORT_CMD cmd;
- ULONG mappedLength, portNumber;
PAHCI_MEMORY_REGISTERS abar;
+ ULONG mappedLength, portNumber, ticks;
PAHCI_ADAPTER_EXTENSION adapterExtension;
STOR_PHYSICAL_ADDRESS commandListPhysical, receivedFISPhysical;
@@ -76,7 +76,22 @@
cmd.Status = StorPortReadRegisterUlong(adapterExtension,
&PortExtension->Port->CMD);
if ((cmd.FR != 0) || (cmd.CR != 0) || (cmd.FRE != 0) || (cmd.ST != 0))
{
- AhciDebugPrint("\tPort is not idle: %x\n", cmd);
+ cmd.ST = 0;
+ cmd.FRE = 0;
+
+ ticks = 3;
+ do
+ {
+ StorPortStallExecution(50000);
+ cmd.Status = StorPortReadRegisterUlong(adapterExtension,
&PortExtension->Port->CMD);
+ if (ticks == 0)
+ {
+ AhciDebugPrint("\tAttempt to reset port failed: %x\n", cmd);
+ return FALSE;
+ }
+ ticks--;
+ }
+ while(cmd.CR != 0 || cmd.FR != 0);
}
// 10.1.2 For each implemented port, system software shall allocate memory for and
program:
@@ -1644,6 +1659,15 @@
PortExtension->DeviceParams.BytesPerPhysicalSector = DEVICE_ATA_BLOCK_SIZE;
+ // last byte should be NULL
+ StorPortCopyMemory(PortExtension->DeviceParams.VendorId,
IdentifyDeviceData->ModelNumber, sizeof(PortExtension->DeviceParams.VendorId) - 1);
+ StorPortCopyMemory(PortExtension->DeviceParams.RevisionID,
IdentifyDeviceData->FirmwareRevision, sizeof(PortExtension->DeviceParams.RevisionID)
- 1);
+ StorPortCopyMemory(PortExtension->DeviceParams.SerialNumber,
IdentifyDeviceData->SerialNumber, sizeof(PortExtension->DeviceParams.SerialNumber) -
1);
+
+
PortExtension->DeviceParams.VendorId[sizeof(PortExtension->DeviceParams.VendorId) -
1] = '\0';
+
PortExtension->DeviceParams.RevisionID[sizeof(PortExtension->DeviceParams.RevisionID)
- 1] = '\0';
+
PortExtension->DeviceParams.SerialNumber[sizeof(PortExtension->DeviceParams.SerialNumber)
- 1] = '\0';
+
// TODO: Add other device params
AhciDebugPrint("\tATA Device\n");
}
@@ -1658,6 +1682,7 @@
if (Srb->DataTransferLength < INQUIRYDATABUFFERSIZE)
{
AhciDebugPrint("\tDataBufferLength < sizeof(INQUIRYDATA), Could crash the
driver.\n");
+ NT_ASSERT(FALSE);
}
// update data transfer length
@@ -1674,10 +1699,14 @@
InquiryData->DeviceType = PortExtension->DeviceParams.AccessType;
InquiryData->RemovableMedia = PortExtension->DeviceParams.RemovableDevice;
- // TODO: Fill VendorID, Product Revision Level and other string fields
- InquiryData->VendorId[0] = '2';
- InquiryData->ProductId[0] = '3';
- InquiryData->ProductRevisionLevel[0] = '4';
+ // Fill VendorID, Product Revision Level and other string fields
+ StorPortCopyMemory(InquiryData->VendorId, PortExtension->DeviceParams.VendorId,
sizeof(InquiryData->VendorId) - 1);
+ StorPortCopyMemory(InquiryData->ProductId,
PortExtension->DeviceParams.RevisionID,
sizeof(PortExtension->DeviceParams.RevisionID));
+ StorPortCopyMemory(InquiryData->ProductRevisionLevel,
PortExtension->DeviceParams.SerialNumber, sizeof(InquiryData->ProductRevisionLevel)
- 1);
+
+ InquiryData->VendorId[sizeof(InquiryData->VendorId) - 1] = '\0';
+ InquiryData->ProductId[sizeof(InquiryData->ProductId) - 1] = '\0';
+ InquiryData->ProductRevisionLevel[sizeof(InquiryData->ProductRevisionLevel) -
1] = '\0';
// send queue depth
status = StorPortSetDeviceQueueDepth(PortExtension->AdapterExtension,
Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] (original)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] Sun Aug 14
12:54:10 2016
@@ -76,9 +76,7 @@
#define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8)
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
-#ifdef DBG
- #define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
-#endif
+#define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
typedef
VOID
@@ -472,9 +470,9 @@
LARGE_INTEGER MaxLba;
ULONG BytesPerLogicalSector;
ULONG BytesPerPhysicalSector;
- // UCHAR VendorId[41];
- // UCHAR RevisionID[9];
- // UCHAR SerialNumber[21];
+ UCHAR VendorId[41];
+ UCHAR RevisionID[9];
+ UCHAR SerialNumber[21];
} DeviceParams;
STOR_DPC CommandCompletion;