/* INCLUDES *****************************************************************/
+#include "precomp.h"
+
#include <ntddk.h>
-#include <srb.h>
+#include <stdio.h>
#include <scsi.h>
#include <ntddscsi.h>
-#include <ntddstor.h>
#include <ntdddisk.h>
-#include <stdio.h>
-#include <stdarg.h>
-#ifndef NDEBUG
#define NDEBUG
-#endif
#include <debug.h>
#include "scsiport_int.h"
#undef ScsiPortMoveMemory
-/* TYPES *********************************************************************/
-
/* GLOBALS *******************************************************************/
static BOOLEAN
IN UCHAR TargetId,
IN UCHAR Lun)
{
- UNIMPLEMENTED;
-#if 0
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
- PSCSI_PORT_LUN_EXTENSION LunExtension;
- PLIST_ENTRY Entry;
+ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ PSCSI_PORT_LUN_EXTENSION LunExtension;
- DPRINT("ScsiPortGetLogicalUnit() called\n");
+ DPRINT("ScsiPortGetLogicalUnit() called\n");
- DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
- SCSI_PORT_DEVICE_EXTENSION,
- MiniPortDeviceExtension);
- if (IsListEmpty(&DeviceExtension->LunExtensionListHead))
- return NULL;
+ DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
+ SCSI_PORT_DEVICE_EXTENSION,
+ MiniPortDeviceExtension);
- Entry = DeviceExtension->LunExtensionListHead.Flink;
- while (Entry != &DeviceExtension->LunExtensionListHead)
+ /* Check the extension size */
+ if (!DeviceExtension->LunExtensionSize)
{
- LunExtension = CONTAINING_RECORD(Entry,
- SCSI_PORT_LUN_EXTENSION,
- List);
- if (LunExtension->PathId == PathId &&
- LunExtension->TargetId == TargetId &&
- LunExtension->Lun == Lun)
- {
- return (PVOID)&LunExtension->MiniportLunExtension;
- }
+ /* They didn't want one */
+ return NULL;
+ }
- Entry = Entry->Flink;
+ LunExtension = SpiGetLunExtension(DeviceExtension,
+ PathId,
+ TargetId,
+ Lun);
+ /* Check that the logical unit exists */
+ if (!LunExtension)
+ {
+ /* Nope, return NULL */
+ return NULL;
}
-#endif
- return NULL;
+
+ /* Return the logical unit miniport extension */
+ return (LunExtension + 1);
}
{
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
SCSI_PHYSICAL_ADDRESS PhysicalAddress;
- ULONG BufferLength = 0;
- ULONG Offset;
+ SIZE_T BufferLength = 0;
+ ULONG_PTR Offset;
PSCSI_SG_ADDRESS SGList;
PSCSI_REQUEST_BLOCK_INFO SrbInfo;
PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE);
}
- *Length = BufferLength;
+ *Length = (ULONG)BufferLength;
return PhysicalAddress;
}
KIRQL OldIrql;
PCM_RESOURCE_LIST ResourceList;
BOOLEAN Conflict;
+ SIZE_T BusConfigSize;
DPRINT ("ScsiPortInitialize() called!\n");
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
- DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ScsiPortDeviceControl;
DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
/* Obtain configuration information */
&Dirql[i],
&Affinity[i]);
}
-
+
if (DeviceExtension->InterruptCount == 1 || Dirql[0] > Dirql[1])
MaxDirql = Dirql[0];
else
MaxDirql = Dirql[1];
-
+
for (i = 0; i < DeviceExtension->InterruptCount; i++)
{
/* Determing IRQ sharability as usual */
break;
}
}
-
+
if (!NT_SUCCESS(Status))
break;
}
IoStartTimer(PortDeviceObject);
/* Initialize bus scanning information */
+ BusConfigSize = FIELD_OFFSET(BUSES_CONFIGURATION_INFORMATION,
+ BusScanInfo[DeviceExtension->PortConfig->NumberOfBuses]);
DeviceExtension->BusesConfig = ExAllocatePoolWithTag(PagedPool,
- sizeof(PSCSI_BUS_SCAN_INFO) * DeviceExtension->PortConfig->NumberOfBuses
- + sizeof(ULONG), TAG_SCSIPORT);
-
+ BusConfigSize,
+ TAG_SCSIPORT);
if (!DeviceExtension->BusesConfig)
{
DPRINT1("Out of resources!\n");
}
/* Zero it */
- RtlZeroMemory(DeviceExtension->BusesConfig,
- sizeof(PSCSI_BUS_SCAN_INFO) * DeviceExtension->PortConfig->NumberOfBuses
- + sizeof(ULONG));
+ RtlZeroMemory(DeviceExtension->BusesConfig, BusConfigSize);
/* Store number of buses there */
DeviceExtension->BusesConfig->NumberOfBuses = (UCHAR)DeviceExtension->BusNum;
IN ULONG ErrorCode,
IN ULONG UniqueId)
{
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ //PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
DPRINT1("ScsiPortLogError() called\n");
+ DPRINT1("PathId: 0x%02x TargetId: 0x%02x Lun: 0x%02x ErrorCode: 0x%08lx UniqueId: 0x%08lx\n",
+ PathId, TargetId, Lun, ErrorCode, UniqueId);
- DeviceExtension = CONTAINING_RECORD(HwDeviceExtension,
- SCSI_PORT_DEVICE_EXTENSION,
- MiniPortDeviceExtension);
+ //DeviceExtension = CONTAINING_RECORD(HwDeviceExtension, SCSI_PORT_DEVICE_EXTENSION, MiniPortDeviceExtension);
DPRINT("ScsiPortLogError() done\n");
case BusChangeDetected:
DPRINT1("UNIMPLEMENTED SCSI Notification called: BusChangeDetected!\n");
break;
-
+
default:
DPRINT1 ("Unsupported notification from WMI: %lu\n", NotificationType);
break;
PortConfig->DmaPort != SP_UNINITIALIZED_VALUE)
{
Dma = 1;
-
+
if (PortConfig->DmaChannel2 != SP_UNINITIALIZED_VALUE ||
PortConfig->DmaPort2 != SP_UNINITIALIZED_VALUE)
Dma++;
ResourceDescriptor->u.Dma.Channel = (Dma == 2) ? PortConfig->DmaChannel2 : PortConfig->DmaChannel;
ResourceDescriptor->u.Dma.Port = (Dma == 2) ? PortConfig->DmaPort2 : PortConfig->DmaPort;
ResourceDescriptor->Flags = 0;
-
+
if (((Dma == 2) ? PortConfig->DmaWidth2 : PortConfig->DmaWidth) == Width8Bits)
ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8;
else if (((Dma == 2) ? PortConfig->DmaWidth2 : PortConfig->DmaWidth) == Width16Bits)
if (((Dma == 2) ? PortConfig->DmaPort2 : PortConfig->DmaPort) == SP_UNINITIALIZED_VALUE)
ResourceDescriptor->u.Dma.Port = 0;
-
+
ResourceDescriptor++;
Dma--;
}
CHAR VendorIdString[8];
CHAR DeviceIdString[8];
UNICODE_STRING UnicodeStr;
- PCM_RESOURCE_LIST ResourceList;
+ PCM_RESOURCE_LIST ResourceList = NULL;
NTSTATUS Status;
DPRINT ("SpiGetPciConfiguration() called\n");
- RtlZeroMemory(&ResourceList, sizeof(PCM_RESOURCE_LIST));
SlotNumber.u.AsULONG = 0;
/* Loop through all devices */
if (DataSize == 0)
return FALSE;
- /* If result is PCI_INVALID_VENDORID, then this device has no more
- "Functions" */
- if (PciConfig.VendorID == PCI_INVALID_VENDORID)
- break;
+ /* Check if result is PCI_INVALID_VENDORID or too small */
+ if ((DataSize < sizeof(ULONG)) ||
+ (PciConfig.VendorID == PCI_INVALID_VENDORID))
+ {
+ /* Continue to try the next function */
+ continue;
+ }
sprintf (VendorIdString, "%04hx", PciConfig.VendorID);
sprintf (DeviceIdString, "%04hx", PciConfig.DeviceID);
case SRB_FUNCTION_EXECUTE_SCSI:
case SRB_FUNCTION_IO_CONTROL:
+ DPRINT(" SRB_FUNCTION_EXECUTE_SCSI or SRB_FUNCTION_IO_CONTROL\n");
/* Mark IRP as pending in all cases */
IoMarkIrpPending(Irp);
break;
default:
- DPRINT1(" unknown ioctl code: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
+ if ('M' == (Stack->Parameters.DeviceIoControl.IoControlCode >> 16)) {
+ DPRINT1(" got ioctl intended for the mount manager: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
+ } else {
+ DPRINT1(" unknown ioctl code: 0x%lX\n", Stack->Parameters.DeviceIoControl.IoControlCode);
+ }
Status = STATUS_NOT_IMPLEMENTED;
break;
}
break;
ScatterGatherList->Length = Srb->DataTransferLength - TotalLength;
- ScatterGatherList->PhysicalAddress = IoMapTransfer(NULL,
+ ScatterGatherList->PhysicalAddress = IoMapTransfer(DeviceExtension->AdapterObject,
Irp->MdlAddress,
MapRegisterBase,
DataVA + TotalLength,
BusData = &AdapterBusInfo->BusData[Bus];
/* Calculate and save an offset of the inquiry data */
- BusData->InquiryDataOffset = (PUCHAR)InquiryData - Buffer;
+ BusData->InquiryDataOffset = (ULONG)((PUCHAR)InquiryData - Buffer);
/* Get a pointer to the LUN information structure */
LunInfo = DeviceExtension->BusesConfig->BusScanInfo[Bus]->LunInfo;
InquiryData->InquiryDataLength = INQUIRYDATABUFFERSIZE;
InquiryData->DeviceClaimed = LunInfo->DeviceClaimed;
InquiryData->NextInquiryDataOffset =
- (PUCHAR)InquiryData + InquiryDataSize - Buffer;
+ (ULONG)((PUCHAR)InquiryData + InquiryDataSize - Buffer);
/* Copy data in it */
RtlCopyMemory(InquiryData->InquiryData,
PSCSI_PORT_LUN_EXTENSION LunExtension;
LONG Result;
PIRP Irp;
- ULONG SequenceNumber;
+ //ULONG SequenceNumber;
Srb = SrbInfo->Srb;
Irp = Srb->OriginalRequest;
/* Save transfer length in the IRP */
Irp->IoStatus.Information = Srb->DataTransferLength;
- SequenceNumber = SrbInfo->SequenceNumber;
+ //SequenceNumber = SrbInfo->SequenceNumber;
SrbInfo->SequenceNumber = 0;
/* Decrement the queue count */
IN PVOID ServiceContext)
{
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
- BOOLEAN Result;
DPRINT("ScsiPortIsr() called!\n");
return FALSE;
/* Call miniport's HwInterrupt routine */
- Result = DeviceExtension->HwInterrupt(&DeviceExtension->MiniPortDeviceExtension);
+ if (DeviceExtension->HwInterrupt(&DeviceExtension->MiniPortDeviceExtension) == FALSE)
+ {
+ /* This interrupt doesn't belong to us */
+ return FALSE;
+ }
/* If flag of notification is set - queue a DPC */
if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED)
0,
REG_SZ,
DriverName,
- (wcslen(DriverName) + 1) * sizeof(WCHAR));
+ (ULONG)((wcslen(DriverName) + 1) * sizeof(WCHAR)));
if (!NT_SUCCESS(Status))
{
DPRINT("ZwSetValueKey('Driver') failed (Status %lx)\n", Status);
0,
REG_SZ,
NameBuffer,
- (wcslen(NameBuffer) + 1) * sizeof(WCHAR));
+ (ULONG)((wcslen(NameBuffer) + 1) * sizeof(WCHAR)));
if (!NT_SUCCESS(Status))
{
DPRINT("ZwSetValueKey('Identifier') failed (Status %lx)\n", Status);
0,
REG_SZ,
TypeName,
- (wcslen(TypeName) + 1) * sizeof(WCHAR));
+ (ULONG)((wcslen(TypeName) + 1) * sizeof(WCHAR)));
if (!NT_SUCCESS(Status))
{
DPRINT("ZwSetValueKey('Type') failed (Status %lx)\n", Status);
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
NTSTATUS Status = STATUS_SUCCESS;
-
+
KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION) Buffer;
break;
case CmResourceTypeInterrupt:
-
+
if (Interrupt == 0)
{
ConfigInfo->BusInterruptLevel =
ConfigInfo->InterruptMode2 = (PartialDescriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED) ? Latched : LevelSensitive;
}
-
+
Interrupt++;
break;
{
ConfigInfo->DmaChannel = PartialDescriptor->u.Dma.Channel;
ConfigInfo->DmaPort = PartialDescriptor->u.Dma.Port;
-
+
if (PartialDescriptor->Flags & CM_RESOURCE_DMA_8)
ConfigInfo->DmaWidth = Width8Bits;
else if ((PartialDescriptor->Flags & CM_RESOURCE_DMA_16) ||
{
ConfigInfo->DmaChannel2 = PartialDescriptor->u.Dma.Channel;
ConfigInfo->DmaPort2 = PartialDescriptor->u.Dma.Port;
-
+
if (PartialDescriptor->Flags & CM_RESOURCE_DMA_8)
ConfigInfo->DmaWidth2 = Width8Bits;
else if ((PartialDescriptor->Flags & CM_RESOURCE_DMA_16) ||
else if (PartialDescriptor->Flags & CM_RESOURCE_DMA_32)
ConfigInfo->DmaWidth2 = Width32Bits;
}
-
+
Dma++;
break;
return(Address.u.LowPart);
}
-
/* EOF */