Author: apriyadarshi
Date: Thu Jun 30 16:04:50 2016
New Revision: 71705
URL:
http://svn.reactos.org/svn/reactos?rev=71705&view=rev
Log:
- Completed Interrupt Handler Routine
- Added Inquiry Completion Routine
Check Notes.txt
Modified:
branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt
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/Notes.txt
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt [iso-8859-1] (original)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt [iso-8859-1] Thu Jun 30
16:04:50 2016
@@ -153,3 +153,16 @@
TESTED
Comment
NONE
+
+AhciCompleteIssuedSrb
+ Flags
+ IMPLEMENTED
+ FULLY_SUPPORTED
+ Comment
+ NONE
+
+InquiryCompletion
+ Flags
+ NOT_IMPLEMENTED
+ Comment
+ NONE
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] Thu Jun 30
16:04:50 2016
@@ -216,6 +216,67 @@
return TRUE;
}// -- AhciHwInitialize();
+
+/**
+ * @name AhciCompleteIssuedSrb
+ * @implemented
+ *
+ * Complete issued Srbs
+ *
+ * @param PortExtension
+ *
+ */
+VOID
+AhciCompleteIssuedSrb (
+ __in PAHCI_PORT_EXTENSION PortExtension,
+ __in ULONG CommandsToComplete
+ )
+{
+ ULONG NCS, i;
+ PSCSI_REQUEST_BLOCK Srb;
+ PAHCI_SRB_EXTENSION SrbExtension;
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
+ PAHCI_COMPLETION_ROUTINE CompletionRoutine;
+
+ DebugPrint("AhciCompleteIssuedSrb()\n");
+
+ NT_ASSERT(CommandsToComplete != 0);
+
+ DebugPrint("\tCompleted Commands: %d\n", CommandsToComplete);
+
+ AdapterExtension = PortExtension->AdapterExtension;
+ NCS = AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP);
+
+ for (i = 0; i < NCS; i++)
+ {
+ if (((1 << i) & CommandsToComplete) != 0)
+ {
+ Srb = &PortExtension->Slot[i];
+ NT_ASSERT(Srb != NULL);
+
+ if (Srb->SrbStatus == SRB_STATUS_PENDING)
+ {
+ Srb->SrbStatus = SRB_STATUS_SUCCESS;
+ }
+
+ SrbExtension = GetSrbExtension(Srb);
+ CompletionRoutine = SrbExtension->CompletionRoutine;
+
+ if (CompletionRoutine != NULL)
+ {
+ // now it's completion routine responsibility to set SrbStatus
+ CompletionRoutine(AdapterExtension, PortExtension, Srb);
+ }
+ else
+ {
+ Srb->SrbStatus = SRB_STATUS_SUCCESS;
+ StorPortNotification(RequestComplete, AdapterExtension, Srb);
+ }
+ }
+ }
+
+ return;
+}// -- AhciCompleteIssuedSrb();
/**
* @name AhciInterruptHandler
@@ -304,7 +365,7 @@
outstanding = ci | sact; // NOTE: Including both non-NCQ and NCQ based commands
if ((PortExtension->CommandIssuedSlots & (~outstanding)) != 0)
{
- DebugPrint("\tCompleted Commands: %d\n",
(PortExtension->CommandIssuedSlots & (~outstanding)));
+ AhciCompleteIssuedSrb(PortExtension, (PortExtension->CommandIssuedSlots &
(~outstanding)));
PortExtension->CommandIssuedSlots &= outstanding;
}
@@ -981,6 +1042,7 @@
}
// mark this slot
+ PortExtension->Slot[SlotIndex] = Srb;
PortExtension->QueueSlots |= SlotIndex;
return;
}// -- AhciProcessSrb();
@@ -1026,8 +1088,10 @@
slotToActivate = (QueueSlots & (~tmp));
// mark that bit off in QueueSlots
+ // so we can know we it is really needed to activate port or not
PortExtension->QueueSlots &= ~slotToActivate;
// mark this CommandIssuedSlots
+ // to validate in completeIssuedCommand
PortExtension->CommandIssuedSlots |= slotToActivate;
// tell the HBA to issue this Command Slot to the given port
@@ -1119,6 +1183,59 @@
}// -- AhciProcessIO();
/**
+ * @name InquiryCompletion
+ * @not_implemented
+ *
+ * InquiryCompletion routine should be called after device signals
+ * for device inquiry request is completed (through interrupt)
+ *
+ * @param PortExtension
+ * @param Srb
+ *
+ */
+VOID
+InquiryCompletion (
+ __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
+ __in PAHCI_PORT_EXTENSION PortExtension,
+ __in PSCSI_REQUEST_BLOCK Srb
+ )
+{
+ ULONG SrbStatus;
+ PAHCI_SRB_EXTENSION SrbExtension;
+
+ DebugPrint("InquiryCompletion()\n");
+
+ NT_ASSERT(PortExtension != NULL);
+ NT_ASSERT(Srb != NULL);
+
+ SrbStatus = Srb->SrbStatus;
+ SrbExtension = GetSrbExtension(Srb);
+
+ if (SrbStatus == SRB_STATUS_SUCCESS)
+ {
+ if (SrbExtension->CommandReg == IDE_COMMAND_IDENTIFY)
+ {
+ AdapterExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATA;
+ }
+ else
+ {
+ AdapterExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATAPI;
+ }
+ // TODO: Set Device Paramters
+ }
+ else if (SrbStatus == SRB_STATUS_NO_DEVICE)
+ {
+ AdapterExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_NODEVICE;
+ }
+ else
+ {
+ return;
+ }
+
+ return;
+}// -- InquiryCompletion();
+
+/**
* @name DeviceInquiryRequest
* @implemented
*
@@ -1162,8 +1279,10 @@
SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY;
SrbExtension->Flags |= ATA_FLAGS_DATA_IN;
+ SrbExtension->CompletionRoutine = InquiryCompletion;
SrbExtension->CommandReg = IDE_COMMAND_NOT_VALID;
+ // TODO: Should use AhciZeroMemory
SrbExtension->FeaturesLow = 0;
SrbExtension->LBA0 = 0;
SrbExtension->LBA1 = 0;
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] Thu Jun 30
16:04:50 2016
@@ -13,8 +13,14 @@
#define MAXIMUM_AHCI_PORT_COUNT 25
#define MAXIMUM_AHCI_PRDT_ENTRIES 32
+#define MAXIMUM_AHCI_PORT_NCS 30
#define MAXIMUM_QUEUE_BUFFER_SIZE 255
#define MAXIMUM_TRANSFER_LENGTH (128*1024) // 128 KB
+
+// device type (DeviceParams)
+#define AHCI_DEVICE_TYPE_ATA 1
+#define AHCI_DEVICE_TYPE_ATAPI 2
+#define AHCI_DEVICE_TYPE_NODEVICE 3
// section 3.1.2
#define AHCI_Global_HBA_CONTROL_HR (1 << 0)
@@ -61,6 +67,14 @@
#if DEBUG
#define DebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
#endif
+
+typedef
+VOID
+(*PAHCI_COMPLETION_ROUTINE) (
+ __in PVOID AdapterExtension,
+ __in PVOID PortExtension,
+ __in PVOID Srb
+ );
//////////////////////////////////////////////////////////////
// ---- Support Structures --- //
@@ -312,11 +326,12 @@
typedef struct _AHCI_PORT_EXTENSION
{
ULONG PortNumber;
- ULONG QueueSlots; // slots to which we have already
assigned task
- ULONG CommandIssuedSlots;
+ ULONG QueueSlots; // slots which we have already
assigned task (Slot)
+ ULONG CommandIssuedSlots; // slots which has been
programmed
BOOLEAN IsActive;
PAHCI_PORT Port; // AHCI Port Infomation
- AHCI_QUEUE SrbQueue;
+ AHCI_QUEUE SrbQueue; // pending Srbs
+ PSCSI_REQUEST_BLOCK Slot[MAXIMUM_AHCI_PORT_NCS]; // Srbs which has been alloted a
port
PAHCI_RECEIVED_FIS ReceivedFIS;
PAHCI_COMMAND_HEADER CommandList;
STOR_DEVICE_POWER_STATE DevicePowerState; // Device Power State
@@ -345,7 +360,12 @@
ULONG LastInterruptPort;
ULONG CurrentCommandSlot;
- PVOID NonCachedExtension;// holds virtual address to noncached buffer allocated for
Port Extension
+ PVOID NonCachedExtension; // holds virtual address to noncached buffer allocated for
Port Extension
+
+ struct
+ {
+ UCHAR DeviceType;
+ } DeviceParams;
struct
{
@@ -388,6 +408,7 @@
ULONG SlotIndex;
LOCAL_SCATTER_GATHER_LIST Sgl;
+ PAHCI_COMPLETION_ROUTINE CompletionRoutine;
} AHCI_SRB_EXTENSION, *PAHCI_SRB_EXTENSION;
//////////////////////////////////////////////////////////////