Author: fireball
Date: Thu Sep 27 16:34:53 2007
New Revision: 29243
URL:
http://svn.reactos.org/svn/reactos?rev=29243&view=rev
Log:
- Slightly cleanup the code.
- Enable allocation of the adapter channel in case of Start I/O.
Modified:
trunk/reactos/drivers/storage/scsiport/scsiport.c
Modified: trunk/reactos/drivers/storage/scsiport/scsiport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport/s…
==============================================================================
--- trunk/reactos/drivers/storage/scsiport/scsiport.c (original)
+++ trunk/reactos/drivers/storage/scsiport/scsiport.c Thu Sep 27 16:34:53 2007
@@ -137,6 +137,13 @@
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 @@
SCSI_PORT_DEVICE_EXTENSION,
MiniPortDeviceExtension);
-
/* Initialize our pointers */
NextMa = DeviceExtension->MappedAddressList;
LastMa = NextMa;
@@ -384,22 +390,44 @@
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);
- }
-
- /* We have a more complex case here */
- UNIMPLEMENTED;
- return 0;
+ DPRINT("ScsiPortGetBusData()\n");
+
+ 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 @@
}
/*
- * @implemented
+ * @unimplemented
*/
PVOID STDCALL
ScsiPortGetLogicalUnit(IN PVOID HwDeviceExtension,
@@ -504,7 +532,7 @@
/*
- * @unimplemented
+ * @implemented
*/
SCSI_PHYSICAL_ADDRESS STDCALL
ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension,
@@ -1654,13 +1682,11 @@
}
else
{
-#if 0
HalFreeCommonBuffer(DeviceExtension->AdapterObject,
DeviceExtension->CommonBufferLength,
- DeviceExtension->PhysicalCommonBuffer,
+ DeviceExtension->PhysicalAddress,
DeviceExtension->SrbExtensionBuffer,
FALSE);
-#endif
}
}
@@ -1684,8 +1710,6 @@
DPRINT("Deleting device %p\n", DeviceExtension->DeviceObject);
IoDeleteDevice(DeviceExtension->DeviceObject);
}
-
-
/*
* @unimplemented
@@ -1699,7 +1723,6 @@
DPRINT1("ScsiPortIoMapTransfer()\n");
UNIMPLEMENTED;
}
-
/*
* @unimplemented
@@ -1725,7 +1748,6 @@
DPRINT("ScsiPortLogError() done\n");
}
-
/*
* @implemented
*/
@@ -1875,29 +1897,6 @@
/* Request a DPC after we're done with the interrupt */
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,22 +2868,16 @@
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);
@@ -4081,7 +4074,6 @@
}
}
-
/* Flush adapter if needed */
if (SrbInfo->BaseOfMapRegister)
{
@@ -4416,8 +4408,6 @@
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
-
-
static BOOLEAN STDCALL
ScsiPortIsr(IN PKINTERRUPT Interrupt,
@@ -5484,6 +5474,7 @@
IN PVOID SystemArgument2)
{
DPRINT1("Miniport timer DPC\n");
+ ASSERT(FALSE);
}
static NTSTATUS
@@ -5616,7 +5607,6 @@
}
}
-
/* Look at device params */
Key = NULL;
if (InternalConfigInfo->Parameter)
@@ -5742,7 +5732,6 @@
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
NTSTATUS Status = STATUS_SUCCESS;
-
KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION) Buffer;
@@ -6064,7 +6053,6 @@
}
}
-
NTSTATUS
STDCALL
SpQueryDeviceCallout(IN PVOID Context,
@@ -6086,7 +6074,31 @@
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