#include "precomp.h"
-#ifndef NDEBUG
+#include <ntddk.h>
+#include <stdio.h>
+#include <scsi.h>
+#include <ntddscsi.h>
+#include <ntdddisk.h>
+
#define NDEBUG
-#endif
#include <debug.h>
+#include "scsiport_int.h"
+
ULONG InternalDebugLevel = 0x00;
#undef ScsiPortMoveMemory
-/* TYPES *********************************************************************/
-
/* GLOBALS *******************************************************************/
static BOOLEAN
{
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");
IoStartTimer(PortDeviceObject);
/* Initialize bus scanning information */
+ BusConfigSize = FIELD_OFFSET(BUSES_CONFIGURATION_INFORMATION,
+ BusScanInfo[DeviceExtension->PortConfig->NumberOfBuses]);
DeviceExtension->BusesConfig = ExAllocatePoolWithTag(PagedPool,
- sizeof(PVOID) * DeviceExtension->PortConfig->NumberOfBuses
- + sizeof(ULONG), TAG_SCSIPORT);
-
+ BusConfigSize,
+ TAG_SCSIPORT);
if (!DeviceExtension->BusesConfig)
{
DPRINT1("Out of resources!\n");
}
/* Zero it */
- RtlZeroMemory(DeviceExtension->BusesConfig,
- sizeof(PVOID) * DeviceExtension->PortConfig->NumberOfBuses
- + sizeof(ULONG));
+ RtlZeroMemory(DeviceExtension->BusesConfig, BusConfigSize);
/* Store number of buses there */
DeviceExtension->BusesConfig->NumberOfBuses = (UCHAR)DeviceExtension->BusNum;
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;
}
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,
return FALSE;
/* Call miniport's HwInterrupt routine */
- 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);
return(Address.u.LowPart);
}
-
/* EOF */