mirror of
https://github.com/reactos/reactos.git
synced 2025-04-29 10:39:07 +00:00
- Completed Interrupt Handler Routine
- Added Inquiry Completion Routine Check Notes.txt svn path=/branches/GSoC_2016/AHCI/; revision=71705
This commit is contained in:
parent
2cb1b3c60d
commit
68e6647b7f
3 changed files with 158 additions and 5 deletions
|
@ -153,3 +153,16 @@ RemoveQueue
|
||||||
TESTED
|
TESTED
|
||||||
Comment
|
Comment
|
||||||
NONE
|
NONE
|
||||||
|
|
||||||
|
AhciCompleteIssuedSrb
|
||||||
|
Flags
|
||||||
|
IMPLEMENTED
|
||||||
|
FULLY_SUPPORTED
|
||||||
|
Comment
|
||||||
|
NONE
|
||||||
|
|
||||||
|
InquiryCompletion
|
||||||
|
Flags
|
||||||
|
NOT_IMPLEMENTED
|
||||||
|
Comment
|
||||||
|
NONE
|
|
@ -217,6 +217,67 @@ AhciHwInitialize (
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}// -- AhciHwInitialize();
|
}// -- 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
|
* @name AhciInterruptHandler
|
||||||
* @not_implemented
|
* @not_implemented
|
||||||
|
@ -304,7 +365,7 @@ AhciInterruptHandler (
|
||||||
outstanding = ci | sact; // NOTE: Including both non-NCQ and NCQ based commands
|
outstanding = ci | sact; // NOTE: Including both non-NCQ and NCQ based commands
|
||||||
if ((PortExtension->CommandIssuedSlots & (~outstanding)) != 0)
|
if ((PortExtension->CommandIssuedSlots & (~outstanding)) != 0)
|
||||||
{
|
{
|
||||||
DebugPrint("\tCompleted Commands: %d\n", (PortExtension->CommandIssuedSlots & (~outstanding)));
|
AhciCompleteIssuedSrb(PortExtension, (PortExtension->CommandIssuedSlots & (~outstanding)));
|
||||||
PortExtension->CommandIssuedSlots &= outstanding;
|
PortExtension->CommandIssuedSlots &= outstanding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,6 +1042,7 @@ AhciProcessSrb (
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark this slot
|
// mark this slot
|
||||||
|
PortExtension->Slot[SlotIndex] = Srb;
|
||||||
PortExtension->QueueSlots |= SlotIndex;
|
PortExtension->QueueSlots |= SlotIndex;
|
||||||
return;
|
return;
|
||||||
}// -- AhciProcessSrb();
|
}// -- AhciProcessSrb();
|
||||||
|
@ -1026,8 +1088,10 @@ AhciActivatePort (
|
||||||
slotToActivate = (QueueSlots & (~tmp));
|
slotToActivate = (QueueSlots & (~tmp));
|
||||||
|
|
||||||
// mark that bit off in QueueSlots
|
// mark that bit off in QueueSlots
|
||||||
|
// so we can know we it is really needed to activate port or not
|
||||||
PortExtension->QueueSlots &= ~slotToActivate;
|
PortExtension->QueueSlots &= ~slotToActivate;
|
||||||
// mark this CommandIssuedSlots
|
// mark this CommandIssuedSlots
|
||||||
|
// to validate in completeIssuedCommand
|
||||||
PortExtension->CommandIssuedSlots |= slotToActivate;
|
PortExtension->CommandIssuedSlots |= slotToActivate;
|
||||||
|
|
||||||
// tell the HBA to issue this Command Slot to the given port
|
// tell the HBA to issue this Command Slot to the given port
|
||||||
|
@ -1118,6 +1182,59 @@ AhciProcessIO (
|
||||||
return;
|
return;
|
||||||
}// -- AhciProcessIO();
|
}// -- 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
|
* @name DeviceInquiryRequest
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -1162,8 +1279,10 @@ DeviceInquiryRequest (
|
||||||
|
|
||||||
SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY;
|
SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY;
|
||||||
SrbExtension->Flags |= ATA_FLAGS_DATA_IN;
|
SrbExtension->Flags |= ATA_FLAGS_DATA_IN;
|
||||||
|
SrbExtension->CompletionRoutine = InquiryCompletion;
|
||||||
SrbExtension->CommandReg = IDE_COMMAND_NOT_VALID;
|
SrbExtension->CommandReg = IDE_COMMAND_NOT_VALID;
|
||||||
|
|
||||||
|
// TODO: Should use AhciZeroMemory
|
||||||
SrbExtension->FeaturesLow = 0;
|
SrbExtension->FeaturesLow = 0;
|
||||||
SrbExtension->LBA0 = 0;
|
SrbExtension->LBA0 = 0;
|
||||||
SrbExtension->LBA1 = 0;
|
SrbExtension->LBA1 = 0;
|
||||||
|
|
|
@ -13,9 +13,15 @@
|
||||||
|
|
||||||
#define MAXIMUM_AHCI_PORT_COUNT 25
|
#define MAXIMUM_AHCI_PORT_COUNT 25
|
||||||
#define MAXIMUM_AHCI_PRDT_ENTRIES 32
|
#define MAXIMUM_AHCI_PRDT_ENTRIES 32
|
||||||
|
#define MAXIMUM_AHCI_PORT_NCS 30
|
||||||
#define MAXIMUM_QUEUE_BUFFER_SIZE 255
|
#define MAXIMUM_QUEUE_BUFFER_SIZE 255
|
||||||
#define MAXIMUM_TRANSFER_LENGTH (128*1024) // 128 KB
|
#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
|
// section 3.1.2
|
||||||
#define AHCI_Global_HBA_CONTROL_HR (1 << 0)
|
#define AHCI_Global_HBA_CONTROL_HR (1 << 0)
|
||||||
#define AHCI_Global_HBA_CONTROL_IE (1 << 1)
|
#define AHCI_Global_HBA_CONTROL_IE (1 << 1)
|
||||||
|
@ -62,6 +68,14 @@
|
||||||
#define DebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
|
#define DebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef
|
||||||
|
VOID
|
||||||
|
(*PAHCI_COMPLETION_ROUTINE) (
|
||||||
|
__in PVOID AdapterExtension,
|
||||||
|
__in PVOID PortExtension,
|
||||||
|
__in PVOID Srb
|
||||||
|
);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// ---- Support Structures --- //
|
// ---- Support Structures --- //
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
@ -312,11 +326,12 @@ typedef struct _AHCI_MEMORY_REGISTERS
|
||||||
typedef struct _AHCI_PORT_EXTENSION
|
typedef struct _AHCI_PORT_EXTENSION
|
||||||
{
|
{
|
||||||
ULONG PortNumber;
|
ULONG PortNumber;
|
||||||
ULONG QueueSlots; // slots to which we have already assigned task
|
ULONG QueueSlots; // slots which we have already assigned task (Slot)
|
||||||
ULONG CommandIssuedSlots;
|
ULONG CommandIssuedSlots; // slots which has been programmed
|
||||||
BOOLEAN IsActive;
|
BOOLEAN IsActive;
|
||||||
PAHCI_PORT Port; // AHCI Port Infomation
|
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_RECEIVED_FIS ReceivedFIS;
|
||||||
PAHCI_COMMAND_HEADER CommandList;
|
PAHCI_COMMAND_HEADER CommandList;
|
||||||
STOR_DEVICE_POWER_STATE DevicePowerState; // Device Power State
|
STOR_DEVICE_POWER_STATE DevicePowerState; // Device Power State
|
||||||
|
@ -345,7 +360,12 @@ typedef struct _AHCI_ADAPTER_EXTENSION
|
||||||
ULONG LastInterruptPort;
|
ULONG LastInterruptPort;
|
||||||
ULONG CurrentCommandSlot;
|
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
|
struct
|
||||||
{
|
{
|
||||||
|
@ -388,6 +408,7 @@ typedef struct _AHCI_SRB_EXTENSION
|
||||||
|
|
||||||
ULONG SlotIndex;
|
ULONG SlotIndex;
|
||||||
LOCAL_SCATTER_GATHER_LIST Sgl;
|
LOCAL_SCATTER_GATHER_LIST Sgl;
|
||||||
|
PAHCI_COMPLETION_ROUTINE CompletionRoutine;
|
||||||
} AHCI_SRB_EXTENSION, *PAHCI_SRB_EXTENSION;
|
} AHCI_SRB_EXTENSION, *PAHCI_SRB_EXTENSION;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue