Author: apriyadarshi
Date: Wed Jun 15 17:07:26 2016
New Revision: 71641
URL:
http://svn.reactos.org/svn/reactos?rev=71641&view=rev
Log:
Added AHCI_Global_HBA_CAP_S64A support
Added AhciProcessIO
Added RC file
Added CMAKE file
And Some fixes
Added:
branches/GSoC_2016/AHCI/drivers/storage/storahci/CMakeLists.txt (with props)
branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.rc (with props)
Modified:
branches/GSoC_2016/AHCI/drivers/storage/storahci/sources
branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c
branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h
Added: branches/GSoC_2016/AHCI/drivers/storage/storahci/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/CMakeLists.txt (added)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/CMakeLists.txt [iso-8859-1] Wed Jun
15 17:07:26 2016
@@ -0,0 +1,28 @@
+
+set_cpp()
+
+include_directories(
+ BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
+ inc)
+
+#add_definitions(-DDEBUG)
+
+list(APPEND SOURCE
+ storahci.cpp
+ ros_glue/ros_glue.cpp
+ stdafx.h)
+
+add_library(storahci SHARED ${SOURCE} storahci.rc)
+
+if(NOT MSVC)
+ add_target_compile_flags(storahci "-Wno-narrowing")
+ if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ add_target_compile_flags(storahci "-Wno-unused-but-set-variable")
+ endif()
+endif()
+
+add_pch(storahci stdafx.h SOURCE)
+set_module_type(storahci kernelmodedriver)
+add_importlibs(storahci storport ntoskrnl hal)
+add_cd_file(TARGET storahci DESTINATION reactos/system32/drivers NO_CAB FOR all)
+add_registry_inf(storahci.inf)
Propchange: branches/GSoC_2016/AHCI/drivers/storage/storahci/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/sources
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/sources [iso-8859-1] (original)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/sources [iso-8859-1] Wed Jun 15
17:07:26 2016
@@ -6,4 +6,5 @@
INCLUDES = %BUILD%\inc
LIBS = %BUILD%\lib
-SOURCES = storahci.c
+SOURCES = storahci.c \
+ storahci.rc
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] Wed Jun 15
17:07:26 2016
@@ -61,18 +61,21 @@
return FALSE;
}
- if ((adapterExtension->CAP & AHCI_Global_HBA_CAP_S64A) != 0)
- {
- DebugPrint("\tCAP.S64A not supported\n");
- return FALSE;
- }
-
// 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â)
// Note: Assuming 32bit support only
StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLB,
commandListPhysical.LowPart);
+ if ((adapterExtension->CAP & AHCI_Global_HBA_CAP_S64A) != 0)
+ {
+ StorPortWriteRegisterUlong(adapterExtension,
&PortExtension->Port->CLBU, commandListPhysical.HighPart);
+ }
+
StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->FB,
receivedFISPhysical.LowPart);
+ if ((adapterExtension->CAP & AHCI_Global_HBA_CAP_S64A) != 0)
+ {
+ StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->FBU,
receivedFISPhysical.HighPart);
+ }
// set device power state flag to D0
PortExtension->DevicePowerState = StorPowerDeviceD0;
@@ -207,14 +210,17 @@
/**
* @name AhciInterruptHandler
- * @implemented
+ * @not_implemented
*
* Interrupt Handler for PortExtension
*
* @param PortExtension
*
- */
-VOID
+ * @return
+ * return TRUE Indicates the interrupt was handled correctly
+ * return FALSE Indicates something went wrong
+ */
+BOOLEAN
AhciInterruptHandler (
__in PAHCI_PORT_EXTENSION PortExtension
)
@@ -222,6 +228,7 @@
DebugPrint("AhciInterruptHandler()\n");
DebugPrint("\tPort Number: %d\n", PortExtension->PortNumber);
+ return FALSE;
}// -- AhciInterruptHandler();
/**
@@ -277,11 +284,10 @@
// we can assign this interrupt to this port
adapterExtension->LastInterruptPort = nextPort;
- AhciInterruptHandler(&adapterExtension->PortExtension[nextPort]);
- return TRUE;
- }
-
- DebugPrint("\tSomething wrong");
+ return AhciInterruptHandler(&adapterExtension->PortExtension[nextPort]);
+ }
+
+ DebugPrint("\tSomething went wrong");
return FALSE;
}// -- AhciHwInterrupt();
@@ -376,7 +382,6 @@
{
Srb->SrbStatus = DeviceInquiryRequest(adapterExtension, Srb, cdb);
StorPortNotification(RequestComplete, adapterExtension, Srb);
-
return TRUE;
}
}
@@ -417,6 +422,11 @@
DebugPrint("AhciHwResetBus()\n");
adapterExtension = AdapterExtension;
+
+ if (IsPortValid(AdapterExtension, PathId))
+ {
+ // TODO: Reset Port
+ }
return FALSE;
}// -- AhciHwResetBus();
@@ -515,13 +525,12 @@
accessRange = *ConfigInfo->AccessRanges;
if (accessRange[index].RangeStart.QuadPart ==
adapterExtension->AhciBaseAddress)
{
- abar = StorPortGetDeviceBase(
- adapterExtension,
- ConfigInfo->AdapterInterfaceType,
- ConfigInfo->SystemIoBusNumber,
- accessRange[index].RangeStart,
- accessRange[index].RangeLength,
- !accessRange[index].RangeInMemory);
+ abar = StorPortGetDeviceBase(adapterExtension,
+ ConfigInfo->AdapterInterfaceType,
+ ConfigInfo->SystemIoBusNumber,
+ accessRange[index].RangeStart,
+ accessRange[index].RangeLength,
+ !accessRange[index].RangeInMemory);
break;
}
}
@@ -647,11 +656,10 @@
hwInitializationData.DeviceExtensionSize = sizeof(AHCI_ADAPTER_EXTENSION);
// register our hw init data
- status = StorPortInitialize(
- DriverObject,
- RegistryPath,
- &hwInitializationData,
- NULL);
+ status = StorPortInitialize(DriverObject,
+ RegistryPath,
+ &hwInitializationData,
+ NULL);
DebugPrint("\tstatus:%x\n", status);
return status;
@@ -768,6 +776,63 @@
}// -- IsPortValid()
/**
+ * @name AhciProcessIO
+ * @not_implemented
+ *
+ * Acquire Exclusive lock to port, populate pending commands to command List
+ * program controller's port to process new commands in command list.
+ *
+ * @param AdapterExtension
+ * @param pathId
+ * @param Srb
+ *
+ */
+VOID
+AhciProcessIO (
+ __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
+ __in UCHAR pathId
+ )
+{
+ STOR_LOCK_HANDLE lockhandle;
+ PAHCI_PORT_EXTENSION PortExtension;
+ ULONG commandSlotMask, occupiedSlots, slotIndex;
+
+ DebugPrint("AhciProcessIO()\n");
+ DebugPrint("\tPathId: %d\n", pathId);
+
+ PortExtension = &AdapterExtension->PortExtension[pathId];
+
+ NT_ASSERT(pathId < MAXIMUM_AHCI_PORT_COUNT);
+
+ if (PortExtension->IsActive == FALSE)
+ return; // we should wait for device to get active
+
+ AhciZeroMemory(&lockhandle, sizeof(lockhandle));
+
+ // Acquire Lock
+ StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle);
+
+ occupiedSlots = PortExtension->OccupiedSlots; // Busy command slots for given
port
+ commandSlotMask = (1 << AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP)) -
1; // available slots mask
+
+ commandSlotMask = (commandSlotMask & ~occupiedSlots);
+ if(commandSlotMask != 0)
+ {
+ for (slotIndex = 0; slotIndex <=
AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP); slotIndex++)
+ {
+ // find first free slot
+ if ((commandSlotMask & (1 << slotIndex)) != 0)
+ {
+ // TODO: remove from queue and process it
+ }
+ }
+ }
+
+ // Release Lock
+ StorPortReleaseSpinLock(AdapterExtension, &lockhandle);
+}// -- AhciProcessIO();
+
+/**
* @name DeviceInquiryRequest
* @implemented
*
@@ -816,5 +881,6 @@
AhciZeroMemory(DataBuffer, DataBufferLength);
}
- return SRB_STATUS_BAD_FUNCTION;
+ AhciProcessIO(AdapterExtension, Srb->PathId, Srb);
+ return SRB_STATUS_SUCCESS;
}// -- DeviceInquiryRequest();
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] Wed Jun 15
17:07:26 2016
@@ -199,6 +199,7 @@
typedef struct _AHCI_PORT_EXTENSION
{
ULONG PortNumber;
+ ULONG OccupiedSlots; // slots to which we have already
assigned task
BOOLEAN IsActive;
PAHCI_PORT Port; // AHCI Port Infomation
PAHCI_RECEIVED_FIS ReceivedFIS;
Added: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
==============================================================================
--- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.rc (added)
+++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.rc [iso-8859-1] Wed Jun 15
17:07:26 2016
@@ -0,0 +1,22 @@
+//
+// PROJECT: ReactOS Kernel
+// LICENSE: GNU GPLv2 only as published by the Free Software Foundation
+// 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_STR_FILE_DESCRIPTION "AHCI Storport Miniport Driver"
+#define REACTOS_STR_FILE_VERSION VERSION_STR
+#define REACTOS_STR_INTERNAL_NAME "storahci.sys"
+#define REACTOS_STR_ORIGINAL_FILENAME "storahci.sys"
+#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright 2010 ReactOS Team"
+#define REACTOS_STR_PRODUCT_NAME "AHCI Driver for ReactOS"
+#define REACTOS_STR_PRODUCT_VERSION VERSION_STR
Propchange: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.rc
------------------------------------------------------------------------------
svn:eol-style = native