https://git.reactos.org/?p=reactos.git;a=commitdiff;h=28f30ba85404b33cb9e47…
commit 28f30ba85404b33cb9e475d9c78ea56f5bec840a
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Fri Oct 13 21:52:38 2017 +0200
[STORAHCI] Make the storahci driver build on gcc and add it to the build.
---
drivers/storage/CMakeLists.txt | 2 +-
drivers/storage/storahci/storahci.c | 86 ++++++++++++++++++++++++++----------
drivers/storage/storahci/storahci.h | 8 +++-
drivers/storage/storahci/storahci.rc | 17 ++-----
4 files changed, 73 insertions(+), 40 deletions(-)
diff --git a/drivers/storage/CMakeLists.txt b/drivers/storage/CMakeLists.txt
index 44cd86852b..610df522d2 100644
--- a/drivers/storage/CMakeLists.txt
+++ b/drivers/storage/CMakeLists.txt
@@ -6,4 +6,4 @@ add_subdirectory(floppy)
add_subdirectory(ide)
add_subdirectory(port)
add_subdirectory(scsiport)
-#add_subdirectory(storahci)
+add_subdirectory(storahci)
diff --git a/drivers/storage/storahci/storahci.c b/drivers/storage/storahci/storahci.c
index 97138a6a0a..54931ac6ff 100644
--- a/drivers/storage/storahci/storahci.c
+++ b/drivers/storage/storahci/storahci.c
@@ -19,10 +19,12 @@
* Return true if intialization was successful
*/
BOOLEAN
+NTAPI
AhciPortInitialize (
- __in PAHCI_PORT_EXTENSION PortExtension
+ __in PVOID DeviceExtension
)
{
+ PAHCI_PORT_EXTENSION PortExtension;
AHCI_PORT_CMD cmd;
PAHCI_MEMORY_REGISTERS abar;
ULONG mappedLength, portNumber, ticks;
@@ -31,6 +33,7 @@ AhciPortInitialize (
AhciDebugPrint("AhciPortInitialize()\n");
+ PortExtension = (PAHCI_PORT_EXTENSION)DeviceExtension;
adapterExtension = PortExtension->AdapterExtension;
abar = adapterExtension->ABAR_Address;
portNumber = PortExtension->PortNumber;
@@ -95,8 +98,8 @@ AhciPortInitialize (
}
// 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’)
- // PxFB and PxFBU (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’)
// Note: Assuming 32bit support only
StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLB,
commandListPhysical.LowPart);
if (IsAdapterCAPS64(adapterExtension->CAP))
@@ -417,8 +420,8 @@ AhciStartPort (
VOID
AhciCommandCompletionDpcRoutine (
__in PSTOR_DPC Dpc,
- __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
- __in PAHCI_PORT_EXTENSION PortExtension,
+ __in PVOID HwDeviceExtension,
+ __in PVOID SystemArgument1,
__in PVOID SystemArgument2
)
{
@@ -426,12 +429,17 @@ AhciCommandCompletionDpcRoutine (
PAHCI_SRB_EXTENSION SrbExtension;
STOR_LOCK_HANDLE lockhandle = {0};
PAHCI_COMPLETION_ROUTINE CompletionRoutine;
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
+ PAHCI_PORT_EXTENSION PortExtension;
UNREFERENCED_PARAMETER(Dpc);
UNREFERENCED_PARAMETER(SystemArgument2);
AhciDebugPrint("AhciCommandCompletionDpcRoutine()\n");
+ AdapterExtension = (PAHCI_ADAPTER_EXTENSION)HwDeviceExtension;
+ PortExtension = (PAHCI_PORT_EXTENSION)SystemArgument1;
+
StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle);
Srb = RemoveQueue(&PortExtension->CompletionQueue);
StorPortReleaseSpinLock(AdapterExtension, &lockhandle);
@@ -473,14 +481,17 @@ AhciCommandCompletionDpcRoutine (
*/
BOOLEAN
AhciHwPassiveInitialize (
- __in PAHCI_ADAPTER_EXTENSION AdapterExtension
+ __in PVOID DeviceExtension
)
{
ULONG index;
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
PAHCI_PORT_EXTENSION PortExtension;
AhciDebugPrint("AhciHwPassiveInitialize()\n");
+ AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
+
for (index = 0; index < AdapterExtension->PortCount; index++)
{
if ((AdapterExtension->PortImplemented & (0x1 << index)) != 0)
@@ -506,14 +517,17 @@ AhciHwPassiveInitialize (
* return TRUE if intialization was successful
*/
BOOLEAN
+NTAPI
AhciHwInitialize (
- __in PAHCI_ADAPTER_EXTENSION AdapterExtension
+ __in PVOID DeviceExtension
)
{
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
AHCI_GHC ghc;
AhciDebugPrint("AhciHwInitialize()\n");
+ AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
AdapterExtension->StateFlags.MessagePerPort = FALSE;
// First check what type of interrupt/synchronization device is using
@@ -701,12 +715,16 @@ AhciInterruptHandler (
* return FALSE Indicates the interrupt was not ours.
*/
BOOLEAN
+NTAPI
AhciHwInterrupt (
- __in PAHCI_ADAPTER_EXTENSION AdapterExtension
+ __in PVOID DeviceExtension
)
{
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
ULONG portPending, nextPort, i, portCount;
+ AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
+
if (AdapterExtension->StateFlags.Removed)
{
return FALSE;
@@ -765,13 +783,18 @@ AhciHwInterrupt (
* return FALSE if the request must be submitted later
*/
BOOLEAN
+NTAPI
AhciHwStartIo (
- __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
+ __in PVOID DeviceExtension,
__in PSCSI_REQUEST_BLOCK Srb
)
{
+ PAHCI_ADAPTER_EXTENSION AdapterExtension;
+
AhciDebugPrint("AhciHwStartIo()\n");
+ AdapterExtension = (PAHCI_ADAPTER_EXTENSION)DeviceExtension;
+
if (!IsPortValid(AdapterExtension, Srb->PathId))
{
Srb->SrbStatus = SRB_STATUS_NO_DEVICE;
@@ -903,17 +926,18 @@ AhciHwStartIo (
* return TRUE if bus was successfully reset
*/
BOOLEAN
+NTAPI
AhciHwResetBus (
__in PVOID AdapterExtension,
__in ULONG PathId
)
{
STOR_LOCK_HANDLE lockhandle = {0};
- PAHCI_ADAPTER_EXTENSION adapterExtension;
+// PAHCI_ADAPTER_EXTENSION adapterExtension;
AhciDebugPrint("AhciHwResetBus()\n");
- adapterExtension = AdapterExtension;
+// adapterExtension = AdapterExtension;
if (IsPortValid(AdapterExtension, PathId))
{
@@ -962,11 +986,12 @@ AhciHwResetBus (
* @remarks Called by Storport.
*/
ULONG
+NTAPI
AhciHwFindAdapter (
- __in PVOID AdapterExtension,
+ __in PVOID DeviceExtension,
__in PVOID HwContext,
__in PVOID BusInformation,
- __in PVOID ArgumentString,
+ __in PCHAR ArgumentString,
__inout PPORT_CONFIGURATION_INFORMATION ConfigInfo,
__in PBOOLEAN Reserved3
)
@@ -987,7 +1012,7 @@ AhciHwFindAdapter (
UNREFERENCED_PARAMETER(ArgumentString);
UNREFERENCED_PARAMETER(Reserved3);
- adapterExtension = AdapterExtension;
+ adapterExtension = DeviceExtension;
adapterExtension->SlotNumber = ConfigInfo->SlotNumber;
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, it’s called ABAR (AHCI Base Memory Register).
adapterExtension->AhciBaseAddress = pciConfigData->u.type0.BaseAddresses[5]
& (0xFFFFFFF0);
- AhciDebugPrint("\tVendorID:%d DeviceID:%d RevisionID:%d\n",
adapterExtension->VendorID,
-
adapterExtension->DeviceID,
-
adapterExtension->RevisionID);
+ AhciDebugPrint("\tVendorID: %04x DeviceID: %04x RevisionID: %02x\n",
+ adapterExtension->VendorID,
+ adapterExtension->DeviceID,
+ adapterExtension->RevisionID);
// 2.1.11
abar = NULL;
@@ -1133,6 +1159,7 @@ AhciHwFindAdapter (
* NT_STATUS in case of driver loaded successfully.
*/
ULONG
+NTAPI
DriverEntry (
__in PVOID DriverObject,
__in PVOID RegistryPath
@@ -1599,15 +1626,20 @@ AhciProcessIO (
*/
VOID
AtapiInquiryCompletion (
- __in PAHCI_PORT_EXTENSION PortExtension,
- __in PSCSI_REQUEST_BLOCK Srb
+ __in PVOID _Extension,
+ __in PVOID _Srb
)
{
- BOOLEAN status;
+ PAHCI_PORT_EXTENSION PortExtension;
PAHCI_ADAPTER_EXTENSION AdapterExtension;
+ PSCSI_REQUEST_BLOCK Srb;
+ BOOLEAN status;
AhciDebugPrint("AtapiInquiryCompletion()\n");
+ PortExtension = (PAHCI_PORT_EXTENSION)_Extension;
+ Srb = (PSCSI_REQUEST_BLOCK)_Srb;
+
NT_ASSERT(Srb != NULL);
NT_ASSERT(PortExtension != NULL);
@@ -1637,11 +1669,14 @@ AtapiInquiryCompletion (
*/
VOID
InquiryCompletion (
- __in PAHCI_PORT_EXTENSION PortExtension,
- __in PSCSI_REQUEST_BLOCK Srb
+ __in PVOID _Extension,
+ __in PVOID _Srb
)
{
- PCDB cdb;
+ PAHCI_PORT_EXTENSION PortExtension;
+ PSCSI_REQUEST_BLOCK Srb;
+
+// PCDB cdb;
BOOLEAN status;
PINQUIRYDATA InquiryData;
PAHCI_SRB_EXTENSION SrbExtension;
@@ -1650,10 +1685,13 @@ InquiryCompletion (
AhciDebugPrint("InquiryCompletion()\n");
+ PortExtension = (PAHCI_PORT_EXTENSION)_Extension;
+ Srb = (PSCSI_REQUEST_BLOCK)_Srb;
+
NT_ASSERT(Srb != NULL);
NT_ASSERT(PortExtension != NULL);
- cdb = (PCDB)&Srb->Cdb;
+// cdb = (PCDB)&Srb->Cdb;
InquiryData = Srb->DataBuffer;
SrbExtension = GetSrbExtension(Srb);
AdapterExtension = PortExtension->AdapterExtension;
diff --git a/drivers/storage/storahci/storahci.h b/drivers/storage/storahci/storahci.h
index 6adcc50ace..8c5277d04c 100644
--- a/drivers/storage/storahci/storahci.h
+++ b/drivers/storage/storahci/storahci.h
@@ -9,9 +9,14 @@
#include <ata.h>
#include <storport.h>
+#define NDEBUG
+#include <debug.h>
+
#define DEBUG 1
+#if defined(_MSC_VER)
#pragma warning(disable:4214) // bit field types other than int
#pragma warning(disable:4201) // nameless struct/union
+#endif
#define MAXIMUM_AHCI_PORT_COUNT 32
#define MAXIMUM_AHCI_PRDT_ENTRIES 32
@@ -76,7 +81,8 @@
#define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8)
#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
VOID
diff --git a/drivers/storage/storahci/storahci.rc b/drivers/storage/storahci/storahci.rc
index 5950ce2d1f..b6f7645078 100644
--- a/drivers/storage/storahci/storahci.rc
+++ b/drivers/storage/storahci/storahci.rc
@@ -4,19 +4,8 @@
// PURPOSE: To Implement AHCI Miniport driver targeting storport NT 5.2
// PROGRAMMERS: Aman Priyadarshi (aman.eureka(a)gmail.com)
//
-
-#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_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "AHCI Storport Miniport Driver"
-#define REACTOS_STR_FILE_VERSION VERSION_STR
-#define REACTOS_STR_INTERNAL_NAME "storahci.sys"
+#define REACTOS_STR_INTERNAL_NAME "storahci"
#define REACTOS_STR_ORIGINAL_FILENAME "storahci.sys"
-#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright 2016 ReactOS Team"
-#define REACTOS_STR_PRODUCT_NAME "AHCI Driver for ReactOS"
-#define REACTOS_STR_PRODUCT_VERSION VERSION_STR
+#include <reactos/version.rc>