mirror of
https://github.com/reactos/reactos.git
synced 2025-06-09 03:10:18 +00:00
[SCSIPORT][FORMATTING] Fix formatting and PCH generation
This commit is contained in:
parent
3da04a9b68
commit
fdc47e7ea7
4 changed files with 677 additions and 746 deletions
|
@ -3,15 +3,14 @@ spec2def(scsiport.sys scsiport.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
scsiport.c
|
scsiport.c
|
||||||
stubs.c
|
stubs.c)
|
||||||
precomp.h)
|
|
||||||
|
|
||||||
add_library(scsiport MODULE
|
add_library(scsiport MODULE
|
||||||
${SOURCE}
|
${SOURCE}
|
||||||
scsiport.rc
|
scsiport.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/scsiport.def)
|
${CMAKE_CURRENT_BINARY_DIR}/scsiport.def)
|
||||||
|
|
||||||
add_pch(scsiport precomp.h SOURCE)
|
add_pch(scsiport scsiport.h "")
|
||||||
set_module_type(scsiport kernelmodedriver)
|
set_module_type(scsiport kernelmodedriver)
|
||||||
add_importlibs(scsiport ntoskrnl hal)
|
add_importlibs(scsiport ntoskrnl hal)
|
||||||
add_cd_file(TARGET scsiport DESTINATION reactos/system32/drivers NO_CAB FOR all)
|
add_cd_file(TARGET scsiport DESTINATION reactos/system32/drivers NO_CAB FOR all)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#ifndef _SCSIPORT_PCH_
|
|
||||||
#define _SCSIPORT_PCH_
|
|
||||||
|
|
||||||
#include <wdm.h>
|
|
||||||
|
|
||||||
#endif /* _SCSIPORT_PCH_ */
|
|
|
@ -1,46 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS kernel
|
|
||||||
* Copyright (C) 2001, 2002 ReactOS Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS Storage Stack
|
* PROJECT: ReactOS Storage Stack
|
||||||
* FILE: drivers/storage/scsiport/scsiport.c
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: SCSI port driver
|
* PURPOSE: SCSI Port driver SCSI requests handling
|
||||||
* PROGRAMMER: Eric Kohl
|
* COPYRIGHT: Eric Kohl (eric.kohl@reactos.org)
|
||||||
* Aleksey Bragin (aleksey reactos org)
|
* Aleksey Bragin (aleksey@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "scsiport.h"
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <scsi.h>
|
|
||||||
#include <ntddscsi.h>
|
|
||||||
#include <ntdddisk.h>
|
|
||||||
#include <mountdev.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include "scsiport_int.h"
|
|
||||||
|
|
||||||
ULONG InternalDebugLevel = 0x00;
|
ULONG InternalDebugLevel = 0x00;
|
||||||
|
|
||||||
#undef ScsiPortMoveMemory
|
#undef ScsiPortMoveMemory
|
||||||
|
@ -1005,7 +977,8 @@ SpiInitOpenKeys(PCONFIGURATION_INFO ConfigInfo, PUNICODE_STRING RegistryPath)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ULONG NTAPI
|
ULONG NTAPI
|
||||||
ScsiPortInitialize(IN PVOID Argument1,
|
ScsiPortInitialize(
|
||||||
|
IN PVOID Argument1,
|
||||||
IN PVOID Argument2,
|
IN PVOID Argument2,
|
||||||
IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
|
IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
|
||||||
IN PVOID HwContext)
|
IN PVOID HwContext)
|
||||||
|
@ -1231,25 +1204,19 @@ CreatePortConfig:
|
||||||
if ((HwInitializationData->AdapterInterfaceType == PCIBus) &&
|
if ((HwInitializationData->AdapterInterfaceType == PCIBus) &&
|
||||||
(HwInitializationData->VendorIdLength > 0) &&
|
(HwInitializationData->VendorIdLength > 0) &&
|
||||||
(HwInitializationData->VendorId != NULL) &&
|
(HwInitializationData->VendorId != NULL) &&
|
||||||
(HwInitializationData->DeviceIdLength > 0) &&
|
(HwInitializationData->DeviceIdLength > 0) && (HwInitializationData->DeviceId != NULL))
|
||||||
(HwInitializationData->DeviceId != NULL))
|
|
||||||
{
|
{
|
||||||
PortConfig->BusInterruptLevel = 0;
|
PortConfig->BusInterruptLevel = 0;
|
||||||
|
|
||||||
/* Get PCI device data */
|
/* Get PCI device data */
|
||||||
DPRINT("VendorId '%.*s' DeviceId '%.*s'\n",
|
DPRINT(
|
||||||
HwInitializationData->VendorIdLength,
|
"VendorId '%.*s' DeviceId '%.*s'\n", HwInitializationData->VendorIdLength,
|
||||||
HwInitializationData->VendorId,
|
HwInitializationData->VendorId, HwInitializationData->DeviceIdLength,
|
||||||
HwInitializationData->DeviceIdLength,
|
|
||||||
HwInitializationData->DeviceId);
|
HwInitializationData->DeviceId);
|
||||||
|
|
||||||
if (!SpiGetPciConfigData(DriverObject,
|
if (!SpiGetPciConfigData(
|
||||||
PortDeviceObject,
|
DriverObject, PortDeviceObject, HwInitializationData, PortConfig, RegistryPath,
|
||||||
HwInitializationData,
|
ConfigInfo.BusNumber, &SlotNumber))
|
||||||
PortConfig,
|
|
||||||
RegistryPath,
|
|
||||||
ConfigInfo.BusNumber,
|
|
||||||
&SlotNumber))
|
|
||||||
{
|
{
|
||||||
/* Continue to the next bus, nothing here */
|
/* Continue to the next bus, nothing here */
|
||||||
ConfigInfo.BusNumber++;
|
ConfigInfo.BusNumber++;
|
||||||
|
@ -1275,15 +1242,12 @@ CreatePortConfig:
|
||||||
/* Note: HwFindAdapter is called once for each bus */
|
/* Note: HwFindAdapter is called once for each bus */
|
||||||
Again = FALSE;
|
Again = FALSE;
|
||||||
DPRINT("Calling HwFindAdapter() for Bus %lu\n", PortConfig->SystemIoBusNumber);
|
DPRINT("Calling HwFindAdapter() for Bus %lu\n", PortConfig->SystemIoBusNumber);
|
||||||
Result = (HwInitializationData->HwFindAdapter)(&DeviceExtension->MiniPortDeviceExtension,
|
Result = (HwInitializationData->HwFindAdapter)(
|
||||||
HwContext,
|
&DeviceExtension->MiniPortDeviceExtension, HwContext, 0, /* BusInformation */
|
||||||
0, /* BusInformation */
|
|
||||||
ConfigInfo.Parameter, /* ArgumentString */
|
ConfigInfo.Parameter, /* ArgumentString */
|
||||||
PortConfig,
|
PortConfig, &Again);
|
||||||
&Again);
|
|
||||||
|
|
||||||
DPRINT("HwFindAdapter() Result: %lu Again: %s\n",
|
DPRINT("HwFindAdapter() Result: %lu Again: %s\n", Result, (Again) ? "True" : "False");
|
||||||
Result, (Again) ? "True" : "False");
|
|
||||||
|
|
||||||
/* Free MapRegisterBase, it's not needed anymore */
|
/* Free MapRegisterBase, it's not needed anymore */
|
||||||
if (DeviceExtension->MapRegisterBase != NULL)
|
if (DeviceExtension->MapRegisterBase != NULL)
|
||||||
|
@ -1313,7 +1277,8 @@ CreatePortConfig:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("ScsiPortInitialize(): Found HBA! (%x), adapter Id %d\n",
|
DPRINT(
|
||||||
|
"ScsiPortInitialize(): Found HBA! (%x), adapter Id %d\n",
|
||||||
PortConfig->BusInterruptVector, PortConfig->InitiatorBusId[0]);
|
PortConfig->BusInterruptVector, PortConfig->InitiatorBusId[0]);
|
||||||
|
|
||||||
/* If the SRB extension size was updated */
|
/* If the SRB extension size was updated */
|
||||||
|
@ -1322,15 +1287,13 @@ CreatePortConfig:
|
||||||
{
|
{
|
||||||
/* Set it (rounding to LONGLONG again) */
|
/* Set it (rounding to LONGLONG again) */
|
||||||
DeviceExtension->SrbExtensionSize =
|
DeviceExtension->SrbExtensionSize =
|
||||||
(PortConfig->SrbExtensionSize +
|
(PortConfig->SrbExtensionSize + sizeof(LONGLONG)) & ~(sizeof(LONGLONG) - 1);
|
||||||
sizeof(LONGLONG)) & ~(sizeof(LONGLONG) - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The same with LUN extension size */
|
/* The same with LUN extension size */
|
||||||
if (PortConfig->SpecificLuExtensionSize != DeviceExtension->LunExtensionSize)
|
if (PortConfig->SpecificLuExtensionSize != DeviceExtension->LunExtensionSize)
|
||||||
DeviceExtension->LunExtensionSize = PortConfig->SpecificLuExtensionSize;
|
DeviceExtension->LunExtensionSize = PortConfig->SpecificLuExtensionSize;
|
||||||
|
|
||||||
|
|
||||||
if (!((HwInitializationData->AdapterInterfaceType == PCIBus) &&
|
if (!((HwInitializationData->AdapterInterfaceType == PCIBus) &&
|
||||||
(HwInitializationData->VendorIdLength > 0) &&
|
(HwInitializationData->VendorIdLength > 0) &&
|
||||||
(HwInitializationData->VendorId != NULL) &&
|
(HwInitializationData->VendorId != NULL) &&
|
||||||
|
@ -1338,8 +1301,7 @@ CreatePortConfig:
|
||||||
(HwInitializationData->DeviceId != NULL)))
|
(HwInitializationData->DeviceId != NULL)))
|
||||||
{
|
{
|
||||||
/* Construct a resource list */
|
/* Construct a resource list */
|
||||||
ResourceList = SpiConfigToResource(DeviceExtension,
|
ResourceList = SpiConfigToResource(DeviceExtension, PortConfig);
|
||||||
PortConfig);
|
|
||||||
|
|
||||||
if (ResourceList)
|
if (ResourceList)
|
||||||
{
|
{
|
||||||
|
@ -1354,8 +1316,8 @@ CreatePortConfig:
|
||||||
ResourceList,
|
ResourceList,
|
||||||
FIELD_OFFSET(CM_RESOURCE_LIST,
|
FIELD_OFFSET(CM_RESOURCE_LIST,
|
||||||
List[0].PartialResourceList.PartialDescriptors) +
|
List[0].PartialResourceList.PartialDescriptors) +
|
||||||
ResourceList->List[0].PartialResourceList.Count
|
ResourceList->List[0].PartialResourceList.Count *
|
||||||
* sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR),
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR),
|
||||||
FALSE,
|
FALSE,
|
||||||
&Conflict);
|
&Conflict);
|
||||||
ExFreePool(ResourceList);
|
ExFreePool(ResourceList);
|
||||||
|
@ -1393,8 +1355,7 @@ CreatePortConfig:
|
||||||
DeviceExtension->SupportsTaggedQueuing = PortConfig->MultipleRequestPerLu = FALSE;
|
DeviceExtension->SupportsTaggedQueuing = PortConfig->MultipleRequestPerLu = FALSE;
|
||||||
|
|
||||||
/* Check if we need to alloc SRB data */
|
/* Check if we need to alloc SRB data */
|
||||||
if (DeviceExtension->SupportsTaggedQueuing ||
|
if (DeviceExtension->SupportsTaggedQueuing || DeviceExtension->MultipleReqsPerLun)
|
||||||
DeviceExtension->MultipleReqsPerLun)
|
|
||||||
{
|
{
|
||||||
DeviceExtension->NeedSrbDataAlloc = TRUE;
|
DeviceExtension->NeedSrbDataAlloc = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1418,8 +1379,7 @@ CreatePortConfig:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->SrbExtensionBuffer == NULL &&
|
if (DeviceExtension->SrbExtensionBuffer == NULL &&
|
||||||
(DeviceExtension->SrbExtensionSize != 0 ||
|
(DeviceExtension->SrbExtensionSize != 0 || PortConfig->AutoRequestSense))
|
||||||
PortConfig->AutoRequestSense))
|
|
||||||
{
|
{
|
||||||
DeviceExtension->SupportsAutoSense = PortConfig->AutoRequestSense;
|
DeviceExtension->SupportsAutoSense = PortConfig->AutoRequestSense;
|
||||||
DeviceExtension->NeedSrbExtensionAlloc = TRUE;
|
DeviceExtension->NeedSrbExtensionAlloc = TRUE;
|
||||||
|
@ -1444,7 +1404,8 @@ CreatePortConfig:
|
||||||
Count = DeviceExtension->RequestsNumber * 2;
|
Count = DeviceExtension->RequestsNumber * 2;
|
||||||
|
|
||||||
/* Allocate the data */
|
/* Allocate the data */
|
||||||
SrbData = ExAllocatePoolWithTag(NonPagedPool, Count * sizeof(SCSI_REQUEST_BLOCK_INFO), TAG_SCSIPORT);
|
SrbData = ExAllocatePoolWithTag(
|
||||||
|
NonPagedPool, Count * sizeof(SCSI_REQUEST_BLOCK_INFO), TAG_SCSIPORT);
|
||||||
if (SrbData == NULL)
|
if (SrbData == NULL)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
@ -1526,16 +1487,16 @@ CreatePortConfig:
|
||||||
InterruptMode[0] = PortConfig->InterruptMode;
|
InterruptMode[0] = PortConfig->InterruptMode;
|
||||||
InterruptMode[1] = PortConfig->InterruptMode2;
|
InterruptMode[1] = PortConfig->InterruptMode2;
|
||||||
|
|
||||||
DeviceExtension->InterruptCount = (PortConfig->BusInterruptLevel2 != 0 || PortConfig->BusInterruptVector2 != 0) ? 2 : 1;
|
DeviceExtension->InterruptCount =
|
||||||
|
(PortConfig->BusInterruptLevel2 != 0 ||
|
||||||
|
PortConfig->BusInterruptVector2 != 0) ? 2 : 1;
|
||||||
|
|
||||||
for (i = 0; i < DeviceExtension->InterruptCount; i++)
|
for (i = 0; i < DeviceExtension->InterruptCount; i++)
|
||||||
{
|
{
|
||||||
/* Register an interrupt handler for this device */
|
/* Register an interrupt handler for this device */
|
||||||
MappedIrq[i] = HalGetInterruptVector(PortConfig->AdapterInterfaceType,
|
MappedIrq[i] = HalGetInterruptVector(
|
||||||
PortConfig->SystemIoBusNumber,
|
PortConfig->AdapterInterfaceType, PortConfig->SystemIoBusNumber,
|
||||||
DeviceExtension->InterruptLevel[i],
|
DeviceExtension->InterruptLevel[i], InterruptVector[i], &Dirql[i],
|
||||||
InterruptVector[i],
|
|
||||||
&Dirql[i],
|
|
||||||
&Affinity[i]);
|
&Affinity[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,22 +1518,14 @@ CreatePortConfig:
|
||||||
InterruptShareable = FALSE;
|
InterruptShareable = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IoConnectInterrupt(&DeviceExtension->Interrupt[i],
|
Status = IoConnectInterrupt(
|
||||||
(PKSERVICE_ROUTINE)ScsiPortIsr,
|
&DeviceExtension->Interrupt[i], (PKSERVICE_ROUTINE)ScsiPortIsr, DeviceExtension,
|
||||||
DeviceExtension,
|
&DeviceExtension->IrqLock, MappedIrq[i], Dirql[i], MaxDirql, InterruptMode[i],
|
||||||
&DeviceExtension->IrqLock,
|
InterruptShareable, Affinity[i], FALSE);
|
||||||
MappedIrq[i],
|
|
||||||
Dirql[i],
|
|
||||||
MaxDirql,
|
|
||||||
InterruptMode[i],
|
|
||||||
InterruptShareable,
|
|
||||||
Affinity[i],
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
if (!(NT_SUCCESS(Status)))
|
if (!(NT_SUCCESS(Status)))
|
||||||
{
|
{
|
||||||
DPRINT1("Could not connect interrupt %d\n",
|
DPRINT1("Could not connect interrupt %d\n", InterruptVector[i]);
|
||||||
InterruptVector[i]);
|
|
||||||
DeviceExtension->Interrupt[i] = NULL;
|
DeviceExtension->Interrupt[i] = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1585,8 +1538,7 @@ CreatePortConfig:
|
||||||
/* Save IoAddress (from access ranges) */
|
/* Save IoAddress (from access ranges) */
|
||||||
if (HwInitializationData->NumberOfAccessRanges != 0)
|
if (HwInitializationData->NumberOfAccessRanges != 0)
|
||||||
{
|
{
|
||||||
DeviceExtension->IoAddress =
|
DeviceExtension->IoAddress = ((*(PortConfig->AccessRanges))[0]).RangeStart.LowPart;
|
||||||
((*(PortConfig->AccessRanges))[0]).RangeStart.LowPart;
|
|
||||||
|
|
||||||
DPRINT("Io Address %x\n", DeviceExtension->IoAddress);
|
DPRINT("Io Address %x\n", DeviceExtension->IoAddress);
|
||||||
}
|
}
|
||||||
|
@ -1598,8 +1550,7 @@ CreatePortConfig:
|
||||||
DeviceExtension->ActiveRequestCounter = -1;
|
DeviceExtension->ActiveRequestCounter = -1;
|
||||||
|
|
||||||
/* Analyze what we have about DMA */
|
/* Analyze what we have about DMA */
|
||||||
if (DeviceExtension->AdapterObject != NULL &&
|
if (DeviceExtension->AdapterObject != NULL && PortConfig->Master &&
|
||||||
PortConfig->Master &&
|
|
||||||
PortConfig->NeedPhysicalAddresses)
|
PortConfig->NeedPhysicalAddresses)
|
||||||
{
|
{
|
||||||
DeviceExtension->MapRegisters = TRUE;
|
DeviceExtension->MapRegisters = TRUE;
|
||||||
|
@ -1612,8 +1563,8 @@ CreatePortConfig:
|
||||||
/* Call HwInitialize at DISPATCH_LEVEL */
|
/* Call HwInitialize at DISPATCH_LEVEL */
|
||||||
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
||||||
|
|
||||||
if (!KeSynchronizeExecution(DeviceExtension->Interrupt[0],
|
if (!KeSynchronizeExecution(
|
||||||
DeviceExtension->HwInitialize,
|
DeviceExtension->Interrupt[0], DeviceExtension->HwInitialize,
|
||||||
DeviceExtension->MiniPortDeviceExtension))
|
DeviceExtension->MiniPortDeviceExtension))
|
||||||
{
|
{
|
||||||
DPRINT1("HwInitialize() failed!\n");
|
DPRINT1("HwInitialize() failed!\n");
|
||||||
|
@ -1626,10 +1577,7 @@ CreatePortConfig:
|
||||||
if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED)
|
if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED)
|
||||||
{
|
{
|
||||||
/* Call DPC right away, because we're already at DISPATCH_LEVEL */
|
/* Call DPC right away, because we're already at DISPATCH_LEVEL */
|
||||||
ScsiPortDpcForIsr(NULL,
|
ScsiPortDpcForIsr(NULL, DeviceExtension->DeviceObject, NULL, NULL);
|
||||||
DeviceExtension->DeviceObject,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lower irql back to what it was */
|
/* Lower irql back to what it was */
|
||||||
|
@ -1639,11 +1587,11 @@ CreatePortConfig:
|
||||||
IoStartTimer(PortDeviceObject);
|
IoStartTimer(PortDeviceObject);
|
||||||
|
|
||||||
/* Initialize bus scanning information */
|
/* Initialize bus scanning information */
|
||||||
BusConfigSize = FIELD_OFFSET(BUSES_CONFIGURATION_INFORMATION,
|
BusConfigSize = FIELD_OFFSET(
|
||||||
|
BUSES_CONFIGURATION_INFORMATION,
|
||||||
BusScanInfo[DeviceExtension->PortConfig->NumberOfBuses]);
|
BusScanInfo[DeviceExtension->PortConfig->NumberOfBuses]);
|
||||||
DeviceExtension->BusesConfig = ExAllocatePoolWithTag(PagedPool,
|
DeviceExtension->BusesConfig =
|
||||||
BusConfigSize,
|
ExAllocatePoolWithTag(PagedPool, BusConfigSize, TAG_SCSIPORT);
|
||||||
TAG_SCSIPORT);
|
|
||||||
if (!DeviceExtension->BusesConfig)
|
if (!DeviceExtension->BusesConfig)
|
||||||
{
|
{
|
||||||
DPRINT1("Out of resources!\n");
|
DPRINT1("Out of resources!\n");
|
||||||
|
@ -1661,13 +1609,10 @@ CreatePortConfig:
|
||||||
SpiScanAdapter(DeviceExtension);
|
SpiScanAdapter(DeviceExtension);
|
||||||
|
|
||||||
/* Build the registry device map */
|
/* Build the registry device map */
|
||||||
SpiBuildDeviceMap(DeviceExtension,
|
SpiBuildDeviceMap(DeviceExtension, (PUNICODE_STRING)Argument2);
|
||||||
(PUNICODE_STRING)Argument2);
|
|
||||||
|
|
||||||
/* Create the dos device link */
|
/* Create the dos device link */
|
||||||
swprintf(DosNameBuffer,
|
swprintf(DosNameBuffer, L"\\??\\Scsi%lu:", SystemConfig->ScsiPortCount);
|
||||||
L"\\??\\Scsi%lu:",
|
|
||||||
SystemConfig->ScsiPortCount);
|
|
||||||
RtlInitUnicodeString(&DosDeviceName, DosNameBuffer);
|
RtlInitUnicodeString(&DosDeviceName, DosNameBuffer);
|
||||||
IoCreateSymbolicLink(&DosDeviceName, &DeviceName);
|
IoCreateSymbolicLink(&DosDeviceName, &DeviceName);
|
||||||
|
|
||||||
|
@ -1866,18 +1811,15 @@ ScsiPortMoveMemory(OUT PVOID Destination,
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, ...)
|
||||||
IN PVOID HwDeviceExtension,
|
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
DPRINT("ScsiPortNotification() called\n");
|
DPRINT("ScsiPortNotification() called\n");
|
||||||
|
|
||||||
DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
|
DeviceExtension =
|
||||||
SCSI_PORT_DEVICE_EXTENSION,
|
CONTAINING_RECORD(HwDeviceExtension, SCSI_PORT_DEVICE_EXTENSION, MiniPortDeviceExtension);
|
||||||
MiniPortDeviceExtension);
|
|
||||||
|
|
||||||
DPRINT("DeviceExtension %p\n", DeviceExtension);
|
DPRINT("DeviceExtension %p\n", DeviceExtension);
|
||||||
|
|
||||||
|
@ -1896,7 +1838,9 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
||||||
|
|
||||||
/* Make sure Srb is alright */
|
/* Make sure Srb is alright */
|
||||||
ASSERT(Srb->SrbStatus != SRB_STATUS_PENDING);
|
ASSERT(Srb->SrbStatus != SRB_STATUS_PENDING);
|
||||||
ASSERT(Srb->Function != SRB_FUNCTION_EXECUTE_SCSI || Srb->SrbStatus != SRB_STATUS_SUCCESS || Srb->ScsiStatus == SCSISTAT_GOOD);
|
ASSERT(
|
||||||
|
Srb->Function != SRB_FUNCTION_EXECUTE_SCSI ||
|
||||||
|
Srb->SrbStatus != SRB_STATUS_SUCCESS || Srb->ScsiStatus == SCSISTAT_GOOD);
|
||||||
|
|
||||||
if (!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE))
|
if (!(Srb->SrbFlags & SRB_FLAGS_IS_ACTIVE))
|
||||||
{
|
{
|
||||||
|
@ -1916,11 +1860,8 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get the SRB data */
|
/* Get the SRB data */
|
||||||
SrbData = SpiGetSrbData(DeviceExtension,
|
SrbData = SpiGetSrbData(
|
||||||
Srb->PathId,
|
DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun, Srb->QueueTag);
|
||||||
Srb->TargetId,
|
|
||||||
Srb->Lun,
|
|
||||||
Srb->QueueTag);
|
|
||||||
|
|
||||||
/* Make sure there are no CompletedRequests and there is a Srb */
|
/* Make sure there are no CompletedRequests and there is a Srb */
|
||||||
ASSERT(SrbData->CompletedRequests == NULL && SrbData->Srb != NULL);
|
ASSERT(SrbData->CompletedRequests == NULL && SrbData->Srb != NULL);
|
||||||
|
@ -1954,24 +1895,21 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
||||||
TargetId = (UCHAR)va_arg(ap, int);
|
TargetId = (UCHAR)va_arg(ap, int);
|
||||||
Lun = (UCHAR)va_arg(ap, int);
|
Lun = (UCHAR)va_arg(ap, int);
|
||||||
|
|
||||||
DPRINT("Notify: NextLuRequest(PathId %u TargetId %u Lun %u)\n",
|
DPRINT(
|
||||||
PathId, TargetId, Lun);
|
"Notify: NextLuRequest(PathId %u TargetId %u Lun %u)\n", PathId, TargetId, Lun);
|
||||||
|
|
||||||
/* Mark it in the flags field */
|
/* Mark it in the flags field */
|
||||||
DeviceExtension->InterruptData.Flags |= SCSI_PORT_NEXT_REQUEST_READY;
|
DeviceExtension->InterruptData.Flags |= SCSI_PORT_NEXT_REQUEST_READY;
|
||||||
|
|
||||||
/* Get the LUN extension */
|
/* Get the LUN extension */
|
||||||
LunExtension = SpiGetLunExtension(DeviceExtension,
|
LunExtension = SpiGetLunExtension(DeviceExtension, PathId, TargetId, Lun);
|
||||||
PathId,
|
|
||||||
TargetId,
|
|
||||||
Lun);
|
|
||||||
|
|
||||||
/* If returned LunExtension is NULL, break out */
|
/* If returned LunExtension is NULL, break out */
|
||||||
if (!LunExtension) break;
|
if (!LunExtension)
|
||||||
|
break;
|
||||||
|
|
||||||
/* This request should not be processed if */
|
/* This request should not be processed if */
|
||||||
if ((LunExtension->ReadyLun) ||
|
if ((LunExtension->ReadyLun) || (LunExtension->SrbInfo.Srb))
|
||||||
(LunExtension->SrbInfo.Srb))
|
|
||||||
{
|
{
|
||||||
/* Nothing to do here */
|
/* Nothing to do here */
|
||||||
break;
|
break;
|
||||||
|
@ -1986,8 +1924,7 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
||||||
case ResetDetected:
|
case ResetDetected:
|
||||||
DPRINT("Notify: ResetDetected\n");
|
DPRINT("Notify: ResetDetected\n");
|
||||||
/* Add RESET flags */
|
/* Add RESET flags */
|
||||||
DeviceExtension->InterruptData.Flags |=
|
DeviceExtension->InterruptData.Flags |= SCSI_PORT_RESET | SCSI_PORT_RESET_REPORTED;
|
||||||
SCSI_PORT_RESET | SCSI_PORT_RESET_REPORTED;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CallDisableInterrupts:
|
case CallDisableInterrupts:
|
||||||
|
@ -2556,8 +2493,7 @@ SpiHandleAttachRelease(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS NTAPI
|
||||||
ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
{
|
||||||
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
PSCSI_PORT_LUN_EXTENSION LunExtension;
|
PSCSI_PORT_LUN_EXTENSION LunExtension;
|
||||||
|
@ -2568,8 +2504,7 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
PIRP NextIrp, IrpList;
|
PIRP NextIrp, IrpList;
|
||||||
PKDEVICE_QUEUE_ENTRY Entry;
|
PKDEVICE_QUEUE_ENTRY Entry;
|
||||||
|
|
||||||
DPRINT("ScsiPortDispatchScsi(DeviceObject %p Irp %p)\n",
|
DPRINT("ScsiPortDispatchScsi(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
|
||||||
DeviceObject, Irp);
|
|
||||||
|
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
@ -2592,10 +2527,7 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("Srb->Function: %lu\n", Srb->Function);
|
DPRINT("Srb->Function: %lu\n", Srb->Function);
|
||||||
DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun);
|
DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun);
|
||||||
|
|
||||||
LunExtension = SpiGetLunExtension(DeviceExtension,
|
LunExtension = SpiGetLunExtension(DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
|
||||||
Srb->PathId,
|
|
||||||
Srb->TargetId,
|
|
||||||
Srb->Lun);
|
|
||||||
if (LunExtension == NULL)
|
if (LunExtension == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("ScsiPortDispatchScsi() called with an invalid LUN\n");
|
DPRINT("ScsiPortDispatchScsi() called with an invalid LUN\n");
|
||||||
|
@ -2644,7 +2576,8 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
||||||
|
|
||||||
/* Insert IRP into the queue */
|
/* Insert IRP into the queue */
|
||||||
if (!KeInsertByKeyDeviceQueue(&LunExtension->DeviceQueue,
|
if (!KeInsertByKeyDeviceQueue(
|
||||||
|
&LunExtension->DeviceQueue,
|
||||||
&Irp->Tail.Overlay.DeviceQueueEntry,
|
&Irp->Tail.Overlay.DeviceQueueEntry,
|
||||||
Srb->QueueSortKey))
|
Srb->QueueSortKey))
|
||||||
{
|
{
|
||||||
|
@ -2686,7 +2619,6 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
Srb->SrbStatus = SRB_STATUS_SUCCESS;
|
Srb->SrbStatus = SRB_STATUS_SUCCESS;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unfreeze the queue */
|
/* Unfreeze the queue */
|
||||||
|
@ -2706,7 +2638,6 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
KeReleaseSpinLock(&DeviceExtension->SpinLock, Irql);
|
KeReleaseSpinLock(&DeviceExtension->SpinLock, Irql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Srb->SrbStatus = SRB_STATUS_SUCCESS;
|
Srb->SrbStatus = SRB_STATUS_SUCCESS;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
@ -2773,10 +2704,9 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <wdm.h>
|
||||||
|
#include <ntddk.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <scsi.h>
|
||||||
|
#include <ntddscsi.h>
|
||||||
|
#include <ntdddisk.h>
|
||||||
|
#include <mountdev.h>
|
||||||
|
|
||||||
#define VERSION "0.0.3"
|
#define VERSION "0.0.3"
|
||||||
|
|
||||||
#ifndef PAGE_ROUND_UP
|
#ifndef PAGE_ROUND_UP
|
Loading…
Reference in a new issue