From 5344a0ac1bc708502d47039cc0f17885d0110197 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 27 Sep 2007 12:34:53 +0000 Subject: [PATCH] - Slightly cleanup the code. - Enable allocation of the adapter channel in case of Start I/O. svn path=/trunk/; revision=29243 --- reactos/drivers/storage/scsiport/scsiport.c | 130 +++++++++++--------- 1 file changed, 71 insertions(+), 59 deletions(-) diff --git a/reactos/drivers/storage/scsiport/scsiport.c b/reactos/drivers/storage/scsiport/scsiport.c index 8c590f9ca7b..8e9393dd891 100644 --- a/reactos/drivers/storage/scsiport/scsiport.c +++ b/reactos/drivers/storage/scsiport/scsiport.c @@ -137,6 +137,13 @@ static VOID STDCALL ScsiPortIoTimer(PDEVICE_OBJECT DeviceObject, PVOID Context); +IO_ALLOCATION_ACTION +STDCALL +ScsiPortAllocateAdapterChannel(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID MapRegisterBase, + IN PVOID Context); + static NTSTATUS SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, PUNICODE_STRING RegistryPath); @@ -336,7 +343,6 @@ ScsiPortFreeDeviceBase(IN PVOID HwDeviceExtension, SCSI_PORT_DEVICE_EXTENSION, MiniPortDeviceExtension); - /* Initialize our pointers */ NextMa = DeviceExtension->MappedAddressList; LastMa = NextMa; @@ -384,22 +390,44 @@ ScsiPortGetBusData(IN PVOID DeviceExtension, IN PVOID Buffer, IN ULONG Length) { - if (Length) - { - /* If Length is non-zero, just forward the call to - HalGetBusData() function */ - return HalGetBusData(BusDataType, - SystemIoBusNumber, - SlotNumber, - Buffer, - Length); - } + DPRINT("ScsiPortGetBusData()\n"); - /* We have a more complex case here */ - UNIMPLEMENTED; - return 0; + if (Length) + { + /* If Length is non-zero, just forward the call to + HalGetBusData() function */ + return HalGetBusData(BusDataType, + SystemIoBusNumber, + SlotNumber, + Buffer, + Length); + } + + /* We have a more complex case here */ + UNIMPLEMENTED; + return 0; } +/* + * @implemented + */ +ULONG STDCALL +ScsiPortSetBusDataByOffset(IN PVOID DeviceExtension, + IN ULONG BusDataType, + IN ULONG SystemIoBusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + DPRINT("ScsiPortSetBusDataByOffset()\n"); + return HalSetBusDataByOffset(BusDataType, + SystemIoBusNumber, + SlotNumber, + Buffer, + Offset, + Length); +} /* * @implemented @@ -461,7 +489,7 @@ ScsiPortGetDeviceBase(IN PVOID HwDeviceExtension, } /* - * @implemented + * @unimplemented */ PVOID STDCALL ScsiPortGetLogicalUnit(IN PVOID HwDeviceExtension, @@ -504,7 +532,7 @@ ScsiPortGetLogicalUnit(IN PVOID HwDeviceExtension, /* - * @unimplemented + * @implemented */ SCSI_PHYSICAL_ADDRESS STDCALL ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension, @@ -1654,13 +1682,11 @@ SpiCleanupAfterInit(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension) } else { -#if 0 HalFreeCommonBuffer(DeviceExtension->AdapterObject, DeviceExtension->CommonBufferLength, - DeviceExtension->PhysicalCommonBuffer, + DeviceExtension->PhysicalAddress, DeviceExtension->SrbExtensionBuffer, FALSE); -#endif } } @@ -1685,8 +1711,6 @@ SpiCleanupAfterInit(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension) IoDeleteDevice(DeviceExtension->DeviceObject); } - - /* * @unimplemented */ @@ -1700,7 +1724,6 @@ ScsiPortIoMapTransfer(IN PVOID HwDeviceExtension, UNIMPLEMENTED; } - /* * @unimplemented */ @@ -1725,7 +1748,6 @@ ScsiPortLogError(IN PVOID HwDeviceExtension, DPRINT("ScsiPortLogError() done\n"); } - /* * @implemented */ @@ -1876,29 +1898,6 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType, DeviceExtension->InterruptData.Flags |= SCSI_PORT_NOTIFICATION_NEEDED; } - -/* - * @implemented - */ -ULONG STDCALL -ScsiPortSetBusDataByOffset(IN PVOID DeviceExtension, - IN ULONG BusDataType, - IN ULONG SystemIoBusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length) -{ - DPRINT("ScsiPortSetBusDataByOffset()\n"); - return(HalSetBusDataByOffset(BusDataType, - SystemIoBusNumber, - SlotNumber, - Buffer, - Offset, - Length)); -} - - /* * @implemented */ @@ -2869,23 +2868,17 @@ ScsiPortStartIo(IN PDEVICE_OBJECT DeviceObject, DeviceExtension->AdapterObject != NULL && !DeviceExtension->MapRegisters) { -#if 0 IoAllocateAdapterChannel( DeviceExtension->AdapterObject, DeviceObject, DeviceExtension->PortCapabilities.MaximumPhysicalPages, - ScsiPortAllocationRoutine, + ScsiPortAllocateAdapterChannel, LunExtension ); return; -#else - /* TODO: DMA is not implemented yet */ - ASSERT(FALSE); -#endif } - KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock); if (!KeSynchronizeExecution(DeviceExtension->Interrupt, @@ -4081,7 +4074,6 @@ SpiProcessCompletedRequest(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, } } - /* Flush adapter if needed */ if (SrbInfo->BaseOfMapRegister) { @@ -4417,8 +4409,6 @@ SpiCompletionRoutine(PDEVICE_OBJECT DeviceObject, return STATUS_MORE_PROCESSING_REQUIRED; } - - static BOOLEAN STDCALL ScsiPortIsr(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext) @@ -5484,6 +5474,7 @@ SpiMiniportTimerDpc(IN struct _KDPC *Dpc, IN PVOID SystemArgument2) { DPRINT1("Miniport timer DPC\n"); + ASSERT(FALSE); } static NTSTATUS @@ -5616,7 +5607,6 @@ TryNextAd: } } - /* Look at device params */ Key = NULL; if (InternalConfigInfo->Parameter) @@ -5743,7 +5733,6 @@ SpiParseDeviceInfo(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, ANSI_STRING AnsiString; NTSTATUS Status = STATUS_SUCCESS; - KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION) Buffer; /* Loop through all values in the device node */ @@ -6064,7 +6053,6 @@ SpiParseDeviceInfo(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, } } - NTSTATUS STDCALL SpQueryDeviceCallout(IN PVOID Context, @@ -6086,7 +6074,31 @@ SpQueryDeviceCallout(IN PVOID Context, return STATUS_SUCCESS; } +IO_ALLOCATION_ACTION +STDCALL +ScsiPortAllocateAdapterChannel(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID MapRegisterBase, + IN PVOID Context) +{ + KIRQL Irql; + PSCSI_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + /* Guard access with the spinlock */ + KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql); + + /* Save MapRegisterBase we've got here */ + DeviceExtension->MapRegisterBase = MapRegisterBase; + + /* Start pending request */ + KeSynchronizeExecution(DeviceExtension->Interrupt, + ScsiPortStartPacket, DeviceObject); + + /* Release spinlock we took */ + KeReleaseSpinLock(&DeviceExtension->SpinLock, Irql); + + return KeepObject; +} static NTSTATUS