NTSTATUS STDCALL WvDiskPnpQueryDevText( IN PDEVICE_OBJECT dev_obj, IN PIRP irp, IN WVL_SP_DISK_T disk ) { IN WV_SP_DEV_T dev = WvDevFromDevObj(dev_obj); WCHAR (*str)[512]; PIO_STACK_LOCATION io_stack_loc = IoGetCurrentIrpStackLocation(irp); NTSTATUS status; UINT32 str_len; /* Allocate a string buffer. */ str = wv_mallocz(sizeof *str); if (str == NULL) { DBG("wv_malloc IRP_MN_QUERY_DEVICE_TEXT\n"); status = STATUS_INSUFFICIENT_RESOURCES; goto alloc_str; } /* Determine the query type. */ switch (io_stack_loc->Parameters.QueryDeviceText.DeviceTextType) { case DeviceTextDescription: str_len = swprintf(*str, WVL_M_WLIT L" Disk") + 1; irp->IoStatus.Information = (ULONG_PTR) wv_palloc(str_len * sizeof *str); if (irp->IoStatus.Information == 0) { DBG("wv_palloc DeviceTextDescription\n"); status = STATUS_INSUFFICIENT_RESOURCES; goto alloc_info; } RtlCopyMemory( (PWCHAR) irp->IoStatus.Information, str, str_len * sizeof *str ); status = STATUS_SUCCESS; goto alloc_info; case DeviceTextLocationInformation: if (disk->disk_ops.PnpQueryId) { io_stack_loc->MinorFunction = IRP_MN_QUERY_ID; io_stack_loc->Parameters.QueryId.IdType = BusQueryInstanceID; return disk->disk_ops.PnpQueryId(dev_obj, irp, disk); } /* Else, fall through... */ default: irp->IoStatus.Information = 0; status = STATUS_NOT_SUPPORTED; } /* irp->IoStatus.Information not freed. */ alloc_info: wv_free(str); alloc_str: return WvlIrpComplete(irp, irp->IoStatus.Information, status); }
/* Handle an IRP. */ static NTSTATUS WvDummyIrpDispatch( IN PDEVICE_OBJECT dev_obj, IN PIRP irp ) { PIO_STACK_LOCATION io_stack_loc; WV_SP_DEV_T dev; io_stack_loc = IoGetCurrentIrpStackLocation(irp); dev = WvDevFromDevObj(dev_obj); switch (io_stack_loc->MajorFunction) { case IRP_MJ_PNP: return WvDummyPnp( dev, irp, io_stack_loc->MinorFunction ); default: DBG("Unhandled IRP_MJ_*: %d\n", io_stack_loc->MajorFunction); } return WvlIrpComplete(irp, 0, STATUS_NOT_SUPPORTED); }
static VOID STDCALL Debug_DecodeIrp( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PCHAR DebugMessage ) { WV_SP_DEV_T dev_ptr = WvDevFromDevObj(DeviceObject); PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); PSCSI_REQUEST_BLOCK Srb; PCDB Cdb; UINT32 StartSector, SectorCount; PSTORAGE_PROPERTY_QUERY StoragePropertyQuery; sprintf( DebugMessage, "%s %s", (dev_ptr->IsBus ? "Bus" : "Disk"), Debug_MajorFunctionString(Stack->MajorFunction) ); switch (Stack->MajorFunction) { case IRP_MJ_SYSTEM_CONTROL: sprintf( DebugMessage, "%s %s", DebugMessage, Debug_SystemControlMinorFunctionString(Stack->MinorFunction) ); break; case IRP_MJ_PNP: sprintf( DebugMessage, "%s %s", DebugMessage, Debug_PnPMinorFunctionString(Stack->MinorFunction) ); switch (Stack->MinorFunction) { case IRP_MN_QUERY_ID: sprintf( DebugMessage, "%s %s", DebugMessage, Debug_QueryIdString(Stack->Parameters.QueryId.IdType) ); break; case IRP_MN_QUERY_DEVICE_TEXT: sprintf( DebugMessage, "%s %s", DebugMessage, Debug_DeviceTextTypeString( Stack->Parameters.QueryDeviceText.DeviceTextType ) ); break; case IRP_MN_QUERY_DEVICE_RELATIONS: sprintf( DebugMessage, "%s %s", DebugMessage, Debug_QueryDeviceRelationsString( Stack->Parameters.QueryDeviceRelations.Type ) ); break; } break; case IRP_MJ_DEVICE_CONTROL: sprintf( DebugMessage, "%s (0x%08x) %s", DebugMessage, (int)Stack->Parameters.DeviceIoControl.IoControlCode, Debug_DeviceIoControlString( Stack->Parameters.DeviceIoControl.IoControlCode ) ); if ( !dev_ptr->IsBus && Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_STORAGE_QUERY_PROPERTY ) { StoragePropertyQuery = Irp->AssociatedIrp.SystemBuffer; switch (StoragePropertyQuery->PropertyId) { case StorageDeviceProperty: sprintf( DebugMessage, "%s StorageDeviceProperty", DebugMessage ); break; case StorageAdapterProperty: sprintf( DebugMessage, "%s StorageAdapterProperty", DebugMessage ); break; default: sprintf( DebugMessage, "%s StorageUnknownProperty (%d)", DebugMessage, StoragePropertyQuery->PropertyId ); } switch (StoragePropertyQuery->QueryType) { case PropertyStandardQuery: sprintf( DebugMessage, "%s PropertyStandardQuery", DebugMessage ); break; case PropertyExistsQuery: sprintf( DebugMessage, "%s PropertyExistsQuery", DebugMessage ); break; default: sprintf( DebugMessage, "%s PropertyUnknownQuery (%d)", DebugMessage, StoragePropertyQuery->QueryType ); } } break; case IRP_MJ_SCSI: if (!dev_ptr->IsBus) { Srb = Stack->Parameters.Scsi.Srb; Cdb = (PCDB) Srb->Cdb; sprintf( DebugMessage, "%s %s", DebugMessage, Debug_SrbFunctionString(Srb->Function) ); if ( Srb->Lun == 0 && Srb->Function == SRB_FUNCTION_EXECUTE_SCSI ) { sprintf( DebugMessage, "%s %s", DebugMessage, Debug_SCSIOPString(Cdb->AsByte[0]) ); if ( Cdb->AsByte[0] == SCSIOP_READ || Cdb->AsByte[0] == SCSIOP_WRITE || Cdb->AsByte[0] == SCSIOP_VERIFY ) { StartSector = (Cdb->CDB10.LogicalBlockByte0 << 24) + (Cdb->CDB10.LogicalBlockByte1 << 16) + (Cdb->CDB10.LogicalBlockByte2 << 8) + Cdb->CDB10.LogicalBlockByte3; SectorCount = (Cdb->CDB10.TransferBlocksMsb << 8) + Cdb->CDB10.TransferBlocksLsb; sprintf( DebugMessage, "%s %d %d", DebugMessage, (int)StartSector, (int)SectorCount ); } if ( Cdb->AsByte[0] == SCSIOP_READ || Cdb->AsByte[0] == SCSIOP_WRITE ) { sprintf( DebugMessage, "%s (buffersize: %d)", DebugMessage, (int)Srb->DataTransferLength ); } } } break; } }
/** * Remove a dummy PDO node on the WinVBlock bus. * * @v Pdo The PDO to remove. * @ret NTSTATUS The status of the operation. * * It might actually be better to handle a PnP remove IOCTL. */ WVL_M_LIB NTSTATUS STDCALL WvDummyRemove(IN PDEVICE_OBJECT Pdo) { /* Sanity check. */ if (Pdo->DriverObject == WvDriverObj) return WvBusRemoveDev(WvDevFromDevObj(Pdo)); return STATUS_INVALID_PARAMETER; }