Author: apriyadarshi
Date: Mon Jul 4 20:20:25 2016
New Revision: 71810
URL:
http://svn.reactos.org/svn/reactos?rev=71810&view=rev
Log:
- Fixed Offset Issue (VendorId and Reversed space offset in Memory Registers)
- DET = 03h Device is Ready!
- Fixed some warnings
Modified:
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/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] Mon Jul 4
20:20:25 2016
@@ -130,7 +130,7 @@
)
{
PCHAR nonCachedExtension, tmp;
- ULONG status, index, NCS, AlignedNCS;
+ ULONG index, NCS, AlignedNCS;
ULONG portCount, portImplemented, nonCachedExtensionSize;
DebugPrint("AhciAllocateResourceForAdapter()\n");
@@ -179,7 +179,7 @@
AdapterExtension->PortExtension[index].PortNumber = index;
AdapterExtension->PortExtension[index].IsActive = TRUE;
AdapterExtension->PortExtension[index].AdapterExtension =
AdapterExtension;
- AdapterExtension->PortExtension[index].CommandList = nonCachedExtension;
+ AdapterExtension->PortExtension[index].CommandList =
(PAHCI_COMMAND_HEADER)nonCachedExtension;
tmp = (PCHAR)(nonCachedExtension + sizeof(AHCI_COMMAND_HEADER) *
AlignedNCS);
@@ -274,7 +274,7 @@
return FALSE;
}
- DebugPrint("\tDET: %d %x %x\n", ssts.DET, PortExtension->Port->CMD,
PortExtension->Port->SSTS);
+ DebugPrint("\tDET: %d %d\n", ssts.DET, cmd.ST);
return FALSE;
}// -- AhciStartPort();
@@ -294,10 +294,9 @@
__in PVOID AdapterExtension
)
{
- ULONG ghc, messageCount, status, cmd, index;
+ ULONG ghc, index;
PAHCI_PORT_EXTENSION PortExtension;
PAHCI_ADAPTER_EXTENSION adapterExtension;
- AHCI_SERIAL_ATA_STATUS ssts;
DebugPrint("AhciHwInitialize()\n");
@@ -750,10 +749,7 @@
__in PBOOLEAN Reserved3
)
{
- ULONG ghc;
- ULONG index;
- ULONG portCount, portImplemented;
- ULONG pci_cfg_len;
+ ULONG ghc, index, pci_cfg_len;
UCHAR pci_cfg_buf[sizeof(PCI_COMMON_CONFIG)];
PACCESS_RANGE accessRange;
@@ -762,6 +758,11 @@
PAHCI_ADAPTER_EXTENSION adapterExtension;
DebugPrint("AhciHwFindAdapter()\n");
+
+ UNREFERENCED_PARAMETER(HwContext);
+ UNREFERENCED_PARAMETER(BusInformation);
+ UNREFERENCED_PARAMETER(ArgumentString);
+ UNREFERENCED_PARAMETER(Reserved3);
adapterExtension = AdapterExtension;
adapterExtension->SlotNumber = ConfigInfo->SlotNumber;
@@ -797,9 +798,9 @@
abar = NULL;
if (ConfigInfo->NumberOfAccessRanges > 0)
{
+ accessRange = *(ConfigInfo->AccessRanges);
for (index = 0; index < ConfigInfo->NumberOfAccessRanges; index++)
{
- accessRange = *ConfigInfo->AccessRanges;
if (accessRange[index].RangeStart.QuadPart ==
adapterExtension->AhciBaseAddress)
{
abar = StorPortGetDeviceBase(adapterExtension,
@@ -902,8 +903,8 @@
__in PVOID RegistryPath
)
{
+ ULONG status;
HW_INITIALIZATION_DATA hwInitializationData;
- ULONG i, status;
DebugPrint("Storahci Loaded\n");
@@ -961,6 +962,8 @@
)
{
PAHCI_COMMAND_TABLE cmdTable;
+
+ UNREFERENCED_PARAMETER(PortExtension);
DebugPrint("AhciATA_CFIS()\n");
@@ -1005,8 +1008,12 @@
__in PAHCI_SRB_EXTENSION SrbExtension
)
{
+ UNREFERENCED_PARAMETER(PortExtension);
+ UNREFERENCED_PARAMETER(SrbExtension);
+
DebugPrint("AhciATAPI_CFIS()\n");
+ return;
}// -- AhciATAPI_CFIS();
/**
@@ -1377,7 +1384,7 @@
* @remark
*
http://www.seagate.com/staticfiles/support/disc/manuals/Interface%20manuals…
*/
-ULONG
+UCHAR
DeviceInquiryRequest (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension,
__in PSCSI_REQUEST_BLOCK Srb,
@@ -1547,10 +1554,10 @@
BOOLEAN
IsPortValid (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension,
- __in UCHAR pathId
- )
-{
- NT_ASSERT(pathId >= 0);
+ __in ULONG pathId
+ )
+{
+ NT_ASSERT(pathId < MAXIMUM_AHCI_PORT_COUNT);
if (pathId >= AdapterExtension->PortCount)
{
@@ -1645,7 +1652,7 @@
ULONG Offset;
ULONG_PTR SrbExtension;
- SrbExtension = Srb->SrbExtension;
+ SrbExtension = (ULONG_PTR)Srb->SrbExtension;
Offset = SrbExtension % 128;
// CommandTable should be 128 byte aligned
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] Mon Jul 4
20:20:25 2016
@@ -10,8 +10,10 @@
#include <storport.h>
#define DEBUG 1
-
-#define MAXIMUM_AHCI_PORT_COUNT 25
+#pragma warning(disable:4214) // bit field types other than int
+#pragma warning(disable:4201) // nameless struct/union
+
+#define MAXIMUM_AHCI_PORT_COUNT 32
#define MAXIMUM_AHCI_PRDT_ENTRIES 32
#define MAXIMUM_AHCI_PORT_NCS 30
#define MAXIMUM_QUEUE_BUFFER_SIZE 255
@@ -363,6 +365,28 @@
ULONG Vendor[4]; // 0x70 ~ 0x7F, vendor specific
} AHCI_PORT, *PAHCI_PORT;
+#ifdef DEBUG
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, CLB) == 0x00);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, CLBU) == 0x04);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, FB) == 0x08);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, FBU) == 0x0C);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, IS) == 0x10);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, IE) == 0x14);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, CMD) == 0x18);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, RSV0) == 0x1C);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, TFD) == 0x20);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SIG) == 0x24);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SSTS) == 0x28);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SCTL) == 0x2C);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SERR) == 0x30);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SACT) == 0x34);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, CI) == 0x38);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, SNTF) == 0x3C);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, FBS) == 0x40);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, RSV1) == 0x44);
+ C_ASSERT(FIELD_OFFSET(AHCI_PORT, Vendor) == 0x70);
+#endif
+
typedef struct _AHCI_MEMORY_REGISTERS
{
// 0x00 - 0x2B, Generic Host Control
@@ -377,11 +401,26 @@
ULONG EM_CTL; // 0x20, Enclosure management control
ULONG CAP2; // 0x24, Host capabilities extended
ULONG BOHC; // 0x28, BIOS/OS handoff control and
status
- ULONG Reserved[0xA0-0x2C]; // 0x2C - 0x9F, Reserved
- ULONG VendorSpecific[0x100-0xA0]; // 0xA0 - 0xFF, Vendor specific
registers
+ ULONG Reserved[0x1d]; // 0x2C - 0x9F, Reserved
+ ULONG VendorSpecific[0x18]; // 0xA0 - 0xFF, Vendor specific
registers
AHCI_PORT PortList[MAXIMUM_AHCI_PORT_COUNT];
-
} AHCI_MEMORY_REGISTERS, *PAHCI_MEMORY_REGISTERS;
+
+#ifdef DEBUG
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP) == 0x00);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, GHC) == 0x04);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, IS) == 0x08);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PI) == 0x0C);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VS) == 0x10);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_CTL) == 0x14);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_PTS) == 0x18);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_LOC) == 0x1C);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_CTL) == 0x20);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP2) == 0x24);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, BOHC) == 0x28);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, Reserved) == 0x2C);
+ C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VendorSpecific) == 0xA0);
+#endif
// Holds information for each attached attached port to a given adapter.
typedef struct _AHCI_PORT_EXTENSION
@@ -492,10 +531,10 @@
BOOLEAN
IsPortValid (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension,
- __in UCHAR pathId
- );
-
-ULONG
+ __in ULONG pathId
+ );
+
+UCHAR
DeviceInquiryRequest (
__in PAHCI_ADAPTER_EXTENSION AdapterExtension,
__in PSCSI_REQUEST_BLOCK Srb,