[STORAHCI] Make the storahci driver build on gcc and add it to the build.

This commit is contained in:
Eric Kohl 2017-10-13 21:52:38 +02:00
parent 1128447196
commit 28f30ba854
4 changed files with 73 additions and 40 deletions

View file

@ -6,4 +6,4 @@ add_subdirectory(floppy)
add_subdirectory(ide) add_subdirectory(ide)
add_subdirectory(port) add_subdirectory(port)
add_subdirectory(scsiport) add_subdirectory(scsiport)
#add_subdirectory(storahci) add_subdirectory(storahci)

View file

@ -19,10 +19,12 @@
* Return true if intialization was successful * Return true if intialization was successful
*/ */
BOOLEAN BOOLEAN
NTAPI
AhciPortInitialize ( AhciPortInitialize (
__in PAHCI_PORT_EXTENSION PortExtension __in PVOID DeviceExtension
) )
{ {
PAHCI_PORT_EXTENSION PortExtension;
AHCI_PORT_CMD cmd; AHCI_PORT_CMD cmd;
PAHCI_MEMORY_REGISTERS abar; PAHCI_MEMORY_REGISTERS abar;
ULONG mappedLength, portNumber, ticks; ULONG mappedLength, portNumber, ticks;
@ -31,6 +33,7 @@ AhciPortInitialize (
AhciDebugPrint("AhciPortInitialize()\n"); AhciDebugPrint("AhciPortInitialize()\n");
PortExtension = (PAHCI_PORT_EXTENSION)DeviceExtension;
adapterExtension = PortExtension->AdapterExtension; adapterExtension = PortExtension->AdapterExtension;
abar = adapterExtension->ABAR_Address; abar = adapterExtension->ABAR_Address;
portNumber = PortExtension->PortNumber; portNumber = PortExtension->PortNumber;
@ -95,8 +98,8 @@ AhciPortInitialize (
} }
// 10.1.2 For each implemented port, system software shall allocate memory for and program: // 10.1.2 For each implemented port, system software shall allocate memory for and program:
// PxCLB and PxCLBU (if CAP.S64A is set to 1) // ? PxCLB and PxCLBU (if CAP.S64A is set to 1)
// PxFB and PxFBU (if CAP.S64A is set to 1) // ? PxFB and PxFBU (if CAP.S64A is set to 1)
// Note: Assuming 32bit support only // Note: Assuming 32bit support only
StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLB, commandListPhysical.LowPart); StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLB, commandListPhysical.LowPart);
if (IsAdapterCAPS64(adapterExtension->CAP)) if (IsAdapterCAPS64(adapterExtension->CAP))
@ -417,8 +420,8 @@ AhciStartPort (
VOID VOID
AhciCommandCompletionDpcRoutine ( AhciCommandCompletionDpcRoutine (
__in PSTOR_DPC Dpc, __in PSTOR_DPC Dpc,
__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PVOID HwDeviceExtension,
__in PAHCI_PORT_EXTENSION PortExtension, __in PVOID SystemArgument1,
__in PVOID SystemArgument2 __in PVOID SystemArgument2
) )
{ {
@ -426,12 +429,17 @@ AhciCommandCompletionDpcRoutine (
PAHCI_SRB_EXTENSION SrbExtension; PAHCI_SRB_EXTENSION SrbExtension;
STOR_LOCK_HANDLE lockhandle = {0}; STOR_LOCK_HANDLE lockhandle = {0};
PAHCI_COMPLETION_ROUTINE CompletionRoutine; PAHCI_COMPLETION_ROUTINE CompletionRoutine;
PAHCI_ADAPTER_EXTENSION AdapterExtension;
PAHCI_PORT_EXTENSION PortExtension;
UNREFERENCED_PARAMETER(Dpc); UNREFERENCED_PARAMETER(Dpc);
UNREFERENCED_PARAMETER(SystemArgument2); UNREFERENCED_PARAMETER(SystemArgument2);
AhciDebugPrint("AhciCommandCompletionDpcRoutine()\n"); AhciDebugPrint("AhciCommandCompletionDpcRoutine()\n");
AdapterExtension = (PAHCI_ADAPTER_EXTENSION)HwDeviceExtension;
PortExtension = (PAHCI_PORT_EXTENSION)SystemArgument1;
StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle);
Srb = RemoveQueue(&PortExtension->CompletionQueue); Srb = RemoveQueue(&PortExtension->CompletionQueue);
StorPortReleaseSpinLock(AdapterExtension, &lockhandle); StorPortReleaseSpinLock(AdapterExtension, &lockhandle);
@ -473,14 +481,17 @@ AhciCommandCompletionDpcRoutine (
*/ */
BOOLEAN BOOLEAN
AhciHwPassiveInitialize ( AhciHwPassiveInitialize (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension __in PVOID DeviceExtension
) )
{ {
ULONG index; ULONG index;
PAHCI_ADAPTER_EXTENSION AdapterExtension;
PAHCI_PORT_EXTENSION PortExtension; PAHCI_PORT_EXTENSION PortExtension;
AhciDebugPrint("AhciHwPassiveInitialize()\n"); AhciDebugPrint("AhciHwPassiveInitialize()\n");
AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
for (index = 0; index < AdapterExtension->PortCount; index++) for (index = 0; index < AdapterExtension->PortCount; index++)
{ {
if ((AdapterExtension->PortImplemented & (0x1 << index)) != 0) if ((AdapterExtension->PortImplemented & (0x1 << index)) != 0)
@ -506,14 +517,17 @@ AhciHwPassiveInitialize (
* return TRUE if intialization was successful * return TRUE if intialization was successful
*/ */
BOOLEAN BOOLEAN
NTAPI
AhciHwInitialize ( AhciHwInitialize (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension __in PVOID DeviceExtension
) )
{ {
PAHCI_ADAPTER_EXTENSION AdapterExtension;
AHCI_GHC ghc; AHCI_GHC ghc;
AhciDebugPrint("AhciHwInitialize()\n"); AhciDebugPrint("AhciHwInitialize()\n");
AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
AdapterExtension->StateFlags.MessagePerPort = FALSE; AdapterExtension->StateFlags.MessagePerPort = FALSE;
// First check what type of interrupt/synchronization device is using // First check what type of interrupt/synchronization device is using
@ -701,12 +715,16 @@ AhciInterruptHandler (
* return FALSE Indicates the interrupt was not ours. * return FALSE Indicates the interrupt was not ours.
*/ */
BOOLEAN BOOLEAN
NTAPI
AhciHwInterrupt ( AhciHwInterrupt (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension __in PVOID DeviceExtension
) )
{ {
PAHCI_ADAPTER_EXTENSION AdapterExtension;
ULONG portPending, nextPort, i, portCount; ULONG portPending, nextPort, i, portCount;
AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
if (AdapterExtension->StateFlags.Removed) if (AdapterExtension->StateFlags.Removed)
{ {
return FALSE; return FALSE;
@ -765,13 +783,18 @@ AhciHwInterrupt (
* return FALSE if the request must be submitted later * return FALSE if the request must be submitted later
*/ */
BOOLEAN BOOLEAN
NTAPI
AhciHwStartIo ( AhciHwStartIo (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PVOID DeviceExtension,
__in PSCSI_REQUEST_BLOCK Srb __in PSCSI_REQUEST_BLOCK Srb
) )
{ {
PAHCI_ADAPTER_EXTENSION AdapterExtension;
AhciDebugPrint("AhciHwStartIo()\n"); AhciDebugPrint("AhciHwStartIo()\n");
AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
if (!IsPortValid(AdapterExtension, Srb->PathId)) if (!IsPortValid(AdapterExtension, Srb->PathId))
{ {
Srb->SrbStatus = SRB_STATUS_NO_DEVICE; Srb->SrbStatus = SRB_STATUS_NO_DEVICE;
@ -903,17 +926,18 @@ AhciHwStartIo (
* return TRUE if bus was successfully reset * return TRUE if bus was successfully reset
*/ */
BOOLEAN BOOLEAN
NTAPI
AhciHwResetBus ( AhciHwResetBus (
__in PVOID AdapterExtension, __in PVOID AdapterExtension,
__in ULONG PathId __in ULONG PathId
) )
{ {
STOR_LOCK_HANDLE lockhandle = {0}; STOR_LOCK_HANDLE lockhandle = {0};
PAHCI_ADAPTER_EXTENSION adapterExtension; // PAHCI_ADAPTER_EXTENSION adapterExtension;
AhciDebugPrint("AhciHwResetBus()\n"); AhciDebugPrint("AhciHwResetBus()\n");
adapterExtension = AdapterExtension; // adapterExtension = AdapterExtension;
if (IsPortValid(AdapterExtension, PathId)) if (IsPortValid(AdapterExtension, PathId))
{ {
@ -962,11 +986,12 @@ AhciHwResetBus (
* @remarks Called by Storport. * @remarks Called by Storport.
*/ */
ULONG ULONG
NTAPI
AhciHwFindAdapter ( AhciHwFindAdapter (
__in PVOID AdapterExtension, __in PVOID DeviceExtension,
__in PVOID HwContext, __in PVOID HwContext,
__in PVOID BusInformation, __in PVOID BusInformation,
__in PVOID ArgumentString, __in PCHAR ArgumentString,
__inout PPORT_CONFIGURATION_INFORMATION ConfigInfo, __inout PPORT_CONFIGURATION_INFORMATION ConfigInfo,
__in PBOOLEAN Reserved3 __in PBOOLEAN Reserved3
) )
@ -987,7 +1012,7 @@ AhciHwFindAdapter (
UNREFERENCED_PARAMETER(ArgumentString); UNREFERENCED_PARAMETER(ArgumentString);
UNREFERENCED_PARAMETER(Reserved3); UNREFERENCED_PARAMETER(Reserved3);
adapterExtension = AdapterExtension; adapterExtension = DeviceExtension;
adapterExtension->SlotNumber = ConfigInfo->SlotNumber; adapterExtension->SlotNumber = ConfigInfo->SlotNumber;
adapterExtension->SystemIoBusNumber = ConfigInfo->SystemIoBusNumber; adapterExtension->SystemIoBusNumber = ConfigInfo->SystemIoBusNumber;
@ -1013,9 +1038,10 @@ AhciHwFindAdapter (
// The last PCI base address register (BAR[5], header offset 0x24) points to the AHCI base memory, its called ABAR (AHCI Base Memory Register). // The last PCI base address register (BAR[5], header offset 0x24) points to the AHCI base memory, its called ABAR (AHCI Base Memory Register).
adapterExtension->AhciBaseAddress = pciConfigData->u.type0.BaseAddresses[5] & (0xFFFFFFF0); adapterExtension->AhciBaseAddress = pciConfigData->u.type0.BaseAddresses[5] & (0xFFFFFFF0);
AhciDebugPrint("\tVendorID:%d DeviceID:%d RevisionID:%d\n", adapterExtension->VendorID, AhciDebugPrint("\tVendorID: %04x DeviceID: %04x RevisionID: %02x\n",
adapterExtension->DeviceID, adapterExtension->VendorID,
adapterExtension->RevisionID); adapterExtension->DeviceID,
adapterExtension->RevisionID);
// 2.1.11 // 2.1.11
abar = NULL; abar = NULL;
@ -1133,6 +1159,7 @@ AhciHwFindAdapter (
* NT_STATUS in case of driver loaded successfully. * NT_STATUS in case of driver loaded successfully.
*/ */
ULONG ULONG
NTAPI
DriverEntry ( DriverEntry (
__in PVOID DriverObject, __in PVOID DriverObject,
__in PVOID RegistryPath __in PVOID RegistryPath
@ -1599,15 +1626,20 @@ AhciProcessIO (
*/ */
VOID VOID
AtapiInquiryCompletion ( AtapiInquiryCompletion (
__in PAHCI_PORT_EXTENSION PortExtension, __in PVOID _Extension,
__in PSCSI_REQUEST_BLOCK Srb __in PVOID _Srb
) )
{ {
BOOLEAN status; PAHCI_PORT_EXTENSION PortExtension;
PAHCI_ADAPTER_EXTENSION AdapterExtension; PAHCI_ADAPTER_EXTENSION AdapterExtension;
PSCSI_REQUEST_BLOCK Srb;
BOOLEAN status;
AhciDebugPrint("AtapiInquiryCompletion()\n"); AhciDebugPrint("AtapiInquiryCompletion()\n");
PortExtension = (PAHCI_PORT_EXTENSION)_Extension;
Srb = (PSCSI_REQUEST_BLOCK)_Srb;
NT_ASSERT(Srb != NULL); NT_ASSERT(Srb != NULL);
NT_ASSERT(PortExtension != NULL); NT_ASSERT(PortExtension != NULL);
@ -1637,11 +1669,14 @@ AtapiInquiryCompletion (
*/ */
VOID VOID
InquiryCompletion ( InquiryCompletion (
__in PAHCI_PORT_EXTENSION PortExtension, __in PVOID _Extension,
__in PSCSI_REQUEST_BLOCK Srb __in PVOID _Srb
) )
{ {
PCDB cdb; PAHCI_PORT_EXTENSION PortExtension;
PSCSI_REQUEST_BLOCK Srb;
// PCDB cdb;
BOOLEAN status; BOOLEAN status;
PINQUIRYDATA InquiryData; PINQUIRYDATA InquiryData;
PAHCI_SRB_EXTENSION SrbExtension; PAHCI_SRB_EXTENSION SrbExtension;
@ -1650,10 +1685,13 @@ InquiryCompletion (
AhciDebugPrint("InquiryCompletion()\n"); AhciDebugPrint("InquiryCompletion()\n");
PortExtension = (PAHCI_PORT_EXTENSION)_Extension;
Srb = (PSCSI_REQUEST_BLOCK)_Srb;
NT_ASSERT(Srb != NULL); NT_ASSERT(Srb != NULL);
NT_ASSERT(PortExtension != NULL); NT_ASSERT(PortExtension != NULL);
cdb = (PCDB)&Srb->Cdb; // cdb = (PCDB)&Srb->Cdb;
InquiryData = Srb->DataBuffer; InquiryData = Srb->DataBuffer;
SrbExtension = GetSrbExtension(Srb); SrbExtension = GetSrbExtension(Srb);
AdapterExtension = PortExtension->AdapterExtension; AdapterExtension = PortExtension->AdapterExtension;

View file

@ -9,9 +9,14 @@
#include <ata.h> #include <ata.h>
#include <storport.h> #include <storport.h>
#define NDEBUG
#include <debug.h>
#define DEBUG 1 #define DEBUG 1
#if defined(_MSC_VER)
#pragma warning(disable:4214) // bit field types other than int #pragma warning(disable:4214) // bit field types other than int
#pragma warning(disable:4201) // nameless struct/union #pragma warning(disable:4201) // nameless struct/union
#endif
#define MAXIMUM_AHCI_PORT_COUNT 32 #define MAXIMUM_AHCI_PORT_COUNT 32
#define MAXIMUM_AHCI_PRDT_ENTRIES 32 #define MAXIMUM_AHCI_PRDT_ENTRIES 32
@ -76,7 +81,8 @@
#define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8) #define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8)
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S)) #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__) //#define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
#define AhciDebugPrint(format, ...) DbgPrint("(%s:%d) " format, __RELFILE__, __LINE__, ##__VA_ARGS__)
typedef typedef
VOID VOID

View file

@ -4,19 +4,8 @@
// PURPOSE: To Implement AHCI Miniport driver targeting storport NT 5.2 // PURPOSE: To Implement AHCI Miniport driver targeting storport NT 5.2
// PROGRAMMERS: Aman Priyadarshi (aman.eureka@gmail.com) // PROGRAMMERS: Aman Priyadarshi (aman.eureka@gmail.com)
// //
#define REACTOS_VERSION_DLL
#define VERSION 1
#define VERSION_STR "1.0"
#define REACTOS_FILETYPE VFT_DRV
#define REACTOS_FILESUBTYPE VFT2_DRV_SYSTEM
#define REACTOS_FILEVERSION VERSION
#define REACTOS_PRODUCTVERSION VERSION
#define REACTOS_STR_COMPANY_NAME "ReactOS Development Team"
#define REACTOS_STR_FILE_DESCRIPTION "AHCI Storport Miniport Driver" #define REACTOS_STR_FILE_DESCRIPTION "AHCI Storport Miniport Driver"
#define REACTOS_STR_FILE_VERSION VERSION_STR #define REACTOS_STR_INTERNAL_NAME "storahci"
#define REACTOS_STR_INTERNAL_NAME "storahci.sys"
#define REACTOS_STR_ORIGINAL_FILENAME "storahci.sys" #define REACTOS_STR_ORIGINAL_FILENAME "storahci.sys"
#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright 2016 ReactOS Team" #include <reactos/version.rc>
#define REACTOS_STR_PRODUCT_NAME "AHCI Driver for ReactOS"
#define REACTOS_STR_PRODUCT_VERSION VERSION_STR