mirror of
https://github.com/reactos/reactos.git
synced 2025-04-28 01:11:35 +00:00
Added AHCI_Global_HBA_CAP_S64A support
Added AhciProcessIO Added RC file Added CMAKE file And Some fixes svn path=/branches/GSoC_2016/AHCI/; revision=71641
This commit is contained in:
parent
c9f49ee82b
commit
dcf485d6f3
5 changed files with 144 additions and 26 deletions
28
drivers/storage/storahci/CMakeLists.txt
Normal file
28
drivers/storage/storahci/CMakeLists.txt
Normal file
|
@ -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)
|
|
@ -6,4 +6,5 @@ TARGETLIBS=$(DDK_LIB_PATH)\storport.lib
|
|||
|
||||
INCLUDES = %BUILD%\inc
|
||||
LIBS = %BUILD%\lib
|
||||
SOURCES = storahci.c
|
||||
SOURCES = storahci.c \
|
||||
storahci.rc
|
||||
|
|
|
@ -61,18 +61,21 @@ AhciPortInitialize (
|
|||
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 @@ AhciHwInitialize (
|
|||
|
||||
/**
|
||||
* @name AhciInterruptHandler
|
||||
* @implemented
|
||||
* @not_implemented
|
||||
*
|
||||
* Interrupt Handler for PortExtension
|
||||
*
|
||||
* @param PortExtension
|
||||
*
|
||||
* @return
|
||||
* return TRUE Indicates the interrupt was handled correctly
|
||||
* return FALSE Indicates something went wrong
|
||||
*/
|
||||
VOID
|
||||
BOOLEAN
|
||||
AhciInterruptHandler (
|
||||
__in PAHCI_PORT_EXTENSION PortExtension
|
||||
)
|
||||
|
@ -222,6 +228,7 @@ AhciInterruptHandler (
|
|||
DebugPrint("AhciInterruptHandler()\n");
|
||||
DebugPrint("\tPort Number: %d\n", PortExtension->PortNumber);
|
||||
|
||||
return FALSE;
|
||||
}// -- AhciInterruptHandler();
|
||||
|
||||
/**
|
||||
|
@ -277,11 +284,10 @@ AhciHwInterrupt(
|
|||
|
||||
// we can assign this interrupt to this port
|
||||
adapterExtension->LastInterruptPort = nextPort;
|
||||
AhciInterruptHandler(&adapterExtension->PortExtension[nextPort]);
|
||||
return TRUE;
|
||||
return AhciInterruptHandler(&adapterExtension->PortExtension[nextPort]);
|
||||
}
|
||||
|
||||
DebugPrint("\tSomething wrong");
|
||||
DebugPrint("\tSomething went wrong");
|
||||
return FALSE;
|
||||
}// -- AhciHwInterrupt();
|
||||
|
||||
|
@ -376,7 +382,6 @@ AhciHwStartIo (
|
|||
{
|
||||
Srb->SrbStatus = DeviceInquiryRequest(adapterExtension, Srb, cdb);
|
||||
StorPortNotification(RequestComplete, adapterExtension, Srb);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -418,6 +423,11 @@ AhciHwResetBus (
|
|||
|
||||
adapterExtension = AdapterExtension;
|
||||
|
||||
if (IsPortValid(AdapterExtension, PathId))
|
||||
{
|
||||
// TODO: Reset Port
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}// -- AhciHwResetBus();
|
||||
|
||||
|
@ -515,13 +525,12 @@ AhciHwFindAdapter (
|
|||
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 @@ DriverEntry (
|
|||
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;
|
||||
|
@ -767,6 +775,63 @@ IsPortValid (
|
|||
return AdapterExtension->PortExtension[pathId].IsActive;
|
||||
}// -- 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 @@ DeviceInquiryRequest (
|
|||
AhciZeroMemory(DataBuffer, DataBufferLength);
|
||||
}
|
||||
|
||||
return SRB_STATUS_BAD_FUNCTION;
|
||||
AhciProcessIO(AdapterExtension, Srb->PathId, Srb);
|
||||
return SRB_STATUS_SUCCESS;
|
||||
}// -- DeviceInquiryRequest();
|
||||
|
|
|
@ -199,6 +199,7 @@ typedef struct _AHCI_MEMORY_REGISTERS
|
|||
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;
|
||||
|
|
22
drivers/storage/storahci/storahci.rc
Normal file
22
drivers/storage/storahci/storahci.rc
Normal file
|
@ -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@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
|
Loading…
Reference in a new issue