ReactOS  0.4.15-dev-4914-g2220e56
fdo.c File Reference
#include "fdc.h"
#include <stdio.h>
#include <debug.h>
Include dependency graph for fdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS FdcFdoStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
 
static NTSTATUS NTAPI FdcFdoConfigCallback (PVOID Context, PUNICODE_STRING PathName, INTERFACE_TYPE BusType, ULONG BusNumber, PKEY_VALUE_FULL_INFORMATION *BusInformation, CONFIGURATION_TYPE ControllerType, ULONG ControllerNumber, PKEY_VALUE_FULL_INFORMATION *ControllerInformation, CONFIGURATION_TYPE PeripheralType, ULONG PeripheralNumber, PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
 
static NTSTATUS PciCreateHardwareIDsString (PUNICODE_STRING HardwareIDs)
 
static NTSTATUS PciCreateCompatibleIDsString (PUNICODE_STRING CompatibleIDs)
 
static NTSTATUS PciCreateInstanceIDString (PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
 
static NTSTATUS FdcFdoQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *DeviceRelations)
 
NTSTATUS NTAPI FdcFdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file fdo.c.

Function Documentation

◆ FdcFdoConfigCallback()

static NTSTATUS NTAPI FdcFdoConfigCallback ( PVOID  Context,
PUNICODE_STRING  PathName,
INTERFACE_TYPE  BusType,
ULONG  BusNumber,
PKEY_VALUE_FULL_INFORMATION BusInformation,
CONFIGURATION_TYPE  ControllerType,
ULONG  ControllerNumber,
PKEY_VALUE_FULL_INFORMATION ControllerInformation,
CONFIGURATION_TYPE  PeripheralType,
ULONG  PeripheralNumber,
PKEY_VALUE_FULL_INFORMATION PeripheralInformation 
)
static

Definition at line 125 of file fdo.c.

137 {
138  PKEY_VALUE_FULL_INFORMATION ControllerFullDescriptor;
139  PCM_FULL_RESOURCE_DESCRIPTOR ControllerResourceDescriptor;
140  PKEY_VALUE_FULL_INFORMATION PeripheralFullDescriptor;
141  PCM_FULL_RESOURCE_DESCRIPTOR PeripheralResourceDescriptor;
142  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
143  PCM_FLOPPY_DEVICE_DATA FloppyDeviceData;
144  PFDO_DEVICE_EXTENSION DeviceExtension;
145  PDRIVE_INFO DriveInfo;
146  BOOLEAN ControllerFound = FALSE;
147  ULONG i;
148 
149  DPRINT("FdcFdoConfigCallback() called\n");
150 
151  DeviceExtension = (PFDO_DEVICE_EXTENSION)Context;
152 
153  /* Get the controller resources */
154  ControllerFullDescriptor = ControllerInformation[IoQueryDeviceConfigurationData];
155  ControllerResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)((PCHAR)ControllerFullDescriptor +
156  ControllerFullDescriptor->DataOffset);
157 
158  for(i = 0; i < ControllerResourceDescriptor->PartialResourceList.Count; i++)
159  {
160  PartialDescriptor = &ControllerResourceDescriptor->PartialResourceList.PartialDescriptors[i];
161 
162  if (PartialDescriptor->Type == CmResourceTypePort)
163  {
164  if ((PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart == DeviceExtension->ControllerInfo.BaseAddress)
165  ControllerFound = TRUE;
166  }
167  }
168 
169  /* Leave, if the enumerated controller is not the one represented by the FDO */
170  if (ControllerFound == FALSE)
171  return STATUS_SUCCESS;
172 
173  /* Get the peripheral resources */
174  PeripheralFullDescriptor = PeripheralInformation[IoQueryDeviceConfigurationData];
175  PeripheralResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)((PCHAR)PeripheralFullDescriptor +
176  PeripheralFullDescriptor->DataOffset);
177 
178  /* learn about drives attached to controller */
179  for(i = 0; i < PeripheralResourceDescriptor->PartialResourceList.Count; i++)
180  {
181  PartialDescriptor = &PeripheralResourceDescriptor->PartialResourceList.PartialDescriptors[i];
182 
183  if (PartialDescriptor->Type != CmResourceTypeDeviceSpecific)
184  continue;
185 
186  FloppyDeviceData = (PCM_FLOPPY_DEVICE_DATA)(PartialDescriptor + 1);
187 
188  DriveInfo = &DeviceExtension->ControllerInfo.DriveInfo[DeviceExtension->ControllerInfo.NumberOfDrives];
189 
190  DriveInfo->ControllerInfo = &DeviceExtension->ControllerInfo;
191  DriveInfo->UnitNumber = DeviceExtension->ControllerInfo.NumberOfDrives;
192  DriveInfo->PeripheralNumber = PeripheralNumber;
193 
194  DriveInfo->FloppyDeviceData.MaxDensity = FloppyDeviceData->MaxDensity;
195  DriveInfo->FloppyDeviceData.MountDensity = FloppyDeviceData->MountDensity;
196  DriveInfo->FloppyDeviceData.StepRateHeadUnloadTime = FloppyDeviceData->StepRateHeadUnloadTime;
197  DriveInfo->FloppyDeviceData.HeadLoadTime = FloppyDeviceData->HeadLoadTime;
198  DriveInfo->FloppyDeviceData.MotorOffTime = FloppyDeviceData->MotorOffTime;
199  DriveInfo->FloppyDeviceData.SectorLengthCode = FloppyDeviceData->SectorLengthCode;
200  DriveInfo->FloppyDeviceData.SectorPerTrack = FloppyDeviceData->SectorPerTrack;
201  DriveInfo->FloppyDeviceData.ReadWriteGapLength = FloppyDeviceData->ReadWriteGapLength;
202  DriveInfo->FloppyDeviceData.FormatGapLength = FloppyDeviceData->FormatGapLength;
203  DriveInfo->FloppyDeviceData.FormatFillCharacter = FloppyDeviceData->FormatFillCharacter;
204  DriveInfo->FloppyDeviceData.HeadSettleTime = FloppyDeviceData->HeadSettleTime;
205  DriveInfo->FloppyDeviceData.MotorSettleTime = FloppyDeviceData->MotorSettleTime;
206  DriveInfo->FloppyDeviceData.MaximumTrackValue = FloppyDeviceData->MaximumTrackValue;
207  DriveInfo->FloppyDeviceData.DataTransferLength = FloppyDeviceData->DataTransferLength;
208 
209  /* Once it's all set up, acknowledge its existence in the controller info object */
210  DeviceExtension->ControllerInfo.NumberOfDrives++;
211  }
212 
213  DeviceExtension->ControllerInfo.Populated = TRUE;
214 
215  DPRINT("Detected %lu floppy drives!\n",
216  DeviceExtension->ControllerInfo.NumberOfDrives);
217 
218  return STATUS_SUCCESS;
219 }
signed char * PCHAR
Definition: retypes.h:7
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378 u
struct _CONTROLLER_INFO * ControllerInfo
Definition: fdc.h:23
UCHAR NumberOfDrives
Definition: fdc.h:58
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
#define FALSE
Definition: types.h:117
BOOLEAN Populated
Definition: fdc.h:39
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@380 Port
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
unsigned char BOOLEAN
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
CM_FLOPPY_DEVICE_DATA FloppyDeviceData
Definition: fdc.h:27
UCHAR UnitNumber
Definition: fdc.h:24
UCHAR StepRateHeadUnloadTime
Definition: cmtypes.h:489
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CONTROLLER_INFO ControllerInfo
Definition: fdc.h:83
DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER]
Definition: fdc.h:60
struct _CM_FLOPPY_DEVICE_DATA * PCM_FLOPPY_DEVICE_DATA
PUCHAR BaseAddress
Definition: fdc.h:49
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
ULONG PeripheralNumber
Definition: fdc.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

Referenced by FdcFdoQueryBusRelations().

◆ FdcFdoPnp()

NTSTATUS NTAPI FdcFdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 446 of file fdo.c.

449 {
452  PDEVICE_RELATIONS DeviceRelations = NULL;
455 
456  DPRINT("FdcFdoPnp()\n");
457 
459 
460  switch (IrpSp->MinorFunction)
461  {
462  case IRP_MN_START_DEVICE:
463  DPRINT(" IRP_MN_START_DEVICE received\n");
464 
465  /* Call lower driver */
467  FdoExtension = DeviceObject->DeviceExtension;
468 
469  if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
470  {
471  Status = Irp->IoStatus.Status;
472  if (NT_SUCCESS(Status))
473  {
475  IrpSp->Parameters.StartDevice.AllocatedResources,
476  IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
477  }
478  }
479 
480  break;
481 
483  DPRINT(" IRP_MN_QUERY_REMOVE_DEVICE\n");
484  break;
485 
487  DPRINT(" IRP_MN_REMOVE_DEVICE received\n");
488  break;
489 
491  DPRINT(" IRP_MN_CANCEL_REMOVE_DEVICE\n");
492  break;
493 
494  case IRP_MN_STOP_DEVICE:
495  DPRINT(" IRP_MN_STOP_DEVICE received\n");
496  break;
497 
499  DPRINT(" IRP_MN_QUERY_STOP_DEVICE received\n");
500  break;
501 
503  DPRINT(" IRP_MN_CANCEL_STOP_DEVICE\n");
504  break;
505 
507  DPRINT(" IRP_MN_QUERY_DEVICE_RELATIONS\n");
508 
509  switch (IrpSp->Parameters.QueryDeviceRelations.Type)
510  {
511  case BusRelations:
512  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
513  Status = FdcFdoQueryBusRelations(DeviceObject, &DeviceRelations);
514  Information = (ULONG_PTR)DeviceRelations;
515  break;
516 
517  case RemovalRelations:
518  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
520 
521  default:
522  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
523  IrpSp->Parameters.QueryDeviceRelations.Type);
525  }
526  break;
527 
529  DPRINT(" IRP_MN_SURPRISE_REMOVAL received\n");
530  break;
531 
532  default:
533  DPRINT(" Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
535  }
536 
537  Irp->IoStatus.Information = Information;
538  Irp->IoStatus.Status = Status;
540 
541  return Status;
542 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
return STATUS_NOT_SUPPORTED
#define IRP_MN_REMOVE_DEVICE
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:21
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS FdcFdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *DeviceRelations)
Definition: fdo.c:281
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_QUERY_STOP_DEVICE
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static NTSTATUS FdcFdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
Definition: fdo.c:38
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ULONG_PTR
Definition: config.h:101
#define IRP_MN_CANCEL_STOP_DEVICE
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

Referenced by FdcPnp().

◆ FdcFdoQueryBusRelations()

static NTSTATUS FdcFdoQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_RELATIONS DeviceRelations 
)
static

Definition at line 281 of file fdo.c.

284 {
285  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
286  PPDO_DEVICE_EXTENSION PdoDeviceExtension;
288  CONFIGURATION_TYPE ControllerType = DiskController;
289  CONFIGURATION_TYPE PeripheralType = FloppyDiskPeripheral;
290  PDEVICE_RELATIONS Relations;
291  PDRIVE_INFO DriveInfo;
293  WCHAR DeviceNameBuffer[80];
295  ULONG DeviceNumber = 0;
296  ULONG Size;
297  ULONG i;
299 
300  DPRINT("FdcFdoQueryBusRelations() called\n");
301 
302  FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
303 
305  NULL,
306  &ControllerType,
307  NULL,
308  &PeripheralType,
309  NULL,
311  FdoDeviceExtension);
313  return Status;
314 
315  Size = sizeof(DEVICE_RELATIONS) +
316  sizeof(Relations->Objects) * (FdoDeviceExtension->ControllerInfo.NumberOfDrives - 1);
318  if (Relations == NULL)
319  {
321  }
322 
323  Relations->Count = FdoDeviceExtension->ControllerInfo.NumberOfDrives;
324 
325  for (i = 0; i < FdoDeviceExtension->ControllerInfo.NumberOfDrives; i++)
326  {
327  DriveInfo = &FdoDeviceExtension->ControllerInfo.DriveInfo[i];
328 
329  if (DriveInfo->DeviceObject == NULL)
330  {
331  do
332  {
333  swprintf(DeviceNameBuffer, L"\\Device\\FloppyPDO%lu", DeviceNumber++);
334  RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
335  DPRINT("Device name: %S\n", DeviceNameBuffer);
336 
337  /* Create physical device object */
338  Status = IoCreateDevice(FdoDeviceExtension->Common.DeviceObject->DriverObject,
339  sizeof(PDO_DEVICE_EXTENSION),
340  &DeviceName,
343  FALSE,
344  &Pdo);
345  }
347 
348  if (!NT_SUCCESS(Status))
349  {
350  DPRINT1("PDO creation failed (Status 0x%08lx)\n", Status);
351  goto done;
352  }
353 
354  DPRINT("PDO created: %S\n", DeviceNameBuffer);
355 
356  DriveInfo->DeviceObject = Pdo;
357 
358  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
359  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
360 
361  PdoDeviceExtension->Common.IsFDO = FALSE;
362  PdoDeviceExtension->Common.DeviceObject = Pdo;
363 
364  PdoDeviceExtension->Fdo = FdoDeviceExtension->Common.DeviceObject;
365  PdoDeviceExtension->DriveInfo = DriveInfo;
366 
367  Pdo->Flags |= DO_DIRECT_IO;
368  Pdo->Flags |= DO_POWER_PAGABLE;
369  Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
370 
371  /* Add Device ID string */
372  RtlCreateUnicodeString(&PdoDeviceExtension->DeviceId,
373  L"FDC\\GENERIC_FLOPPY_DRIVE");
374  DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceId.Buffer);
375 
376  /* Add Hardware IDs string */
377  Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIds);
378  if (!NT_SUCCESS(Status))
379  {
380 // ErrorStatus = Status;
381 // ErrorOccurred = TRUE;
382  break;
383  }
384 
385  /* Add Compatible IDs string */
386  Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIds);
387  if (!NT_SUCCESS(Status))
388  {
389 // ErrorStatus = Status;
390 // ErrorOccurred = TRUE;
391  break;
392  }
393 
394  /* Add Instance ID string */
395  Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceId,
396  DriveInfo->PeripheralNumber);
397  if (!NT_SUCCESS(Status))
398  {
399 // ErrorStatus = Status;
400 // ErrorOccurred = TRUE;
401  break;
402  }
403 
404 #if 0
405  /* Add device description string */
407  if (!NT_SUCCESS(Status))
408  {
409 // ErrorStatus = Status;
410 // ErrorOccurred = TRUE;
411  break;
412  }
413 
414  /* Add device location string */
416  if (!NT_SUCCESS(Status))
417  {
418 // ErrorStatus = Status;
419 // ErrorOccurred = TRUE;
420  break;
421  }
422 #endif
423  }
424 
425  ObReferenceObject(DriveInfo->DeviceObject);
426  Relations->Objects[i] = DriveInfo->DeviceObject;
427  }
428 
429 done:
430  if (NT_SUCCESS(Status))
431  {
432  *DeviceRelations = Relations;
433  }
434  else
435  {
436  if (Relations != NULL)
437  ExFreePool(Relations);
438  }
439 
440  return Status;
441 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define DO_POWER_PAGABLE
PDRIVE_INFO DriveInfo
Definition: fdc.h:93
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
enum _INTERFACE_TYPE INTERFACE_TYPE
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
NTSTATUS PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
Definition: pci.c:430
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PDEVICE_OBJECT Fdo
Definition: pci.h:61
UNICODE_STRING HardwareIds
Definition: serenum.h:54
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
static NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs)
Definition: fdo.c:246
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:62
UCHAR NumberOfDrives
Definition: fdc.h:58
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
PDEVICE_OBJECT DeviceObject
Definition: fdc.h:26
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:64
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:59
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI IoQueryDeviceDescription(PINTERFACE_TYPE BusType OPTIONAL, PULONG BusNumber OPTIONAL, PCONFIGURATION_TYPE ControllerType OPTIONAL, PULONG ControllerNumber OPTIONAL, PCONFIGURATION_TYPE PeripheralType OPTIONAL, PULONG PeripheralNumber OPTIONAL, PIO_QUERY_DEVICE_ROUTINE CalloutRoutine, PVOID Context)
Definition: iorsrce.c:1020
UNICODE_STRING DeviceLocation
Definition: pci.h:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING DeviceId
Definition: serenum.h:52
UNICODE_STRING DeviceDescription
Definition: pci.h:73
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
CONFIGURATION_TYPE
Definition: iotypes.h:4393
static NTSTATUS NTAPI FdcFdoConfigCallback(PVOID Context, PUNICODE_STRING PathName, INTERFACE_TYPE BusType, ULONG BusNumber, PKEY_VALUE_FULL_INFORMATION *BusInformation, CONFIGURATION_TYPE ControllerType, ULONG ControllerNumber, PKEY_VALUE_FULL_INFORMATION *ControllerInformation, CONFIGURATION_TYPE PeripheralType, ULONG PeripheralNumber, PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
Definition: fdo.c:125
int _cdecl swprintf(const WCHAR *,...)
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84
struct _DEVICE_RELATIONS DEVICE_RELATIONS
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static NTSTATUS PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs)
Definition: fdo.c:224
static NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
Definition: fdo.c:268
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:698
#define NULL
Definition: types.h:112
CONTROLLER_INFO ControllerInfo
Definition: fdc.h:83
DRIVE_INFO DriveInfo[MAX_DRIVES_PER_CONTROLLER]
Definition: fdc.h:60
#define DPRINT1
Definition: precomp.h:8
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG PeripheralNumber
Definition: fdc.h:25
UNICODE_STRING CompatibleIds
Definition: serenum.h:55
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING InstanceId
Definition: serenum.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FdcFdoPnp().

◆ FdcFdoStartDevice()

static NTSTATUS FdcFdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PCM_RESOURCE_LIST  ResourceList,
IN PCM_RESOURCE_LIST  ResourceListTranslated 
)
static

Definition at line 38 of file fdo.c.

42 {
43  PFDO_DEVICE_EXTENSION DeviceExtension;
44  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
45 // PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated;
46  ULONG i;
47 
48  DPRINT("FdcFdoStartDevice called\n");
49 
50  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
51 
52  ASSERT(DeviceExtension);
53 
54  if (ResourceList == NULL ||
55  ResourceListTranslated == NULL)
56  {
57  DPRINT1("No allocated resources sent to driver\n");
59  }
60 
61  if (ResourceList->Count != 1)
62  {
63  DPRINT1("Wrong number of allocated resources sent to driver\n");
65  }
66 
67  if (ResourceList->List[0].PartialResourceList.Version != 1 ||
68  ResourceList->List[0].PartialResourceList.Revision != 1 ||
69  ResourceListTranslated->List[0].PartialResourceList.Version != 1 ||
70  ResourceListTranslated->List[0].PartialResourceList.Revision != 1)
71  {
72  DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n",
73  ResourceList->List[0].PartialResourceList.Version,
74  ResourceList->List[0].PartialResourceList.Revision,
75  ResourceListTranslated->List[0].PartialResourceList.Version,
76  ResourceListTranslated->List[0].PartialResourceList.Revision);
78  }
79 
80  for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
81  {
82  PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
83 // PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i];
84 
85  switch (PartialDescriptor->Type)
86  {
87  case CmResourceTypePort:
88  DPRINT("Port: 0x%lx (%lu)\n",
89  PartialDescriptor->u.Port.Start.u.LowPart,
90  PartialDescriptor->u.Port.Length);
91  if (PartialDescriptor->u.Port.Length >= 6)
92  DeviceExtension->ControllerInfo.BaseAddress = (PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart;
93  break;
94 
96  DPRINT("Interrupt: Level %lu Vector %lu\n",
97  PartialDescriptor->u.Interrupt.Level,
98  PartialDescriptor->u.Interrupt.Vector);
99 /*
100  Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level;
101  Vector = PartialDescriptorTranslated->u.Interrupt.Vector;
102  Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity;
103  if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
104  InterruptMode = Latched;
105  else
106  InterruptMode = LevelSensitive;
107  ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared);
108 */
109  break;
110 
111  case CmResourceTypeDma:
112  DPRINT("Dma: Channel %lu\n",
113  PartialDescriptor->u.Dma.Channel);
114  break;
115  }
116  }
117 
118  return STATUS_SUCCESS;
119 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
unsigned char * PUCHAR
Definition: retypes.h:3
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378 u
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@380 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@384 Dma
#define ASSERT(a)
Definition: mode.c:44
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@381 Interrupt
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
CONTROLLER_INFO ControllerInfo
Definition: fdc.h:83
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
PUCHAR BaseAddress
Definition: fdc.h:49
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by FdcFdoPnp().

◆ ForwardIrpAndForget()

NTSTATUS NTAPI ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 21 of file fdo.c.

24 {
25  PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
26 
27  ASSERT(LowerDevice);
28 
30  return IoCallDriver(LowerDevice, Irp);
31 }
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by FdcFdoPnp(), FdoPnp(), PciIdeXFdoPnpDispatch(), PortFdoPnp(), SerenumFdoPnp(), and SermousePnp().

◆ PciCreateCompatibleIDsString()

static NTSTATUS PciCreateCompatibleIDsString ( PUNICODE_STRING  CompatibleIDs)
static

Definition at line 246 of file fdo.c.

247 {
248  WCHAR Buffer[256];
249  UNICODE_STRING BufferU;
250  ULONG Index;
251 
252  Index = 0;
253  Index += swprintf(&Buffer[Index],
254  L"GenFloppyDisk");
255  Index++;
256 
258 
259  BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
260  BufferU.Buffer = Buffer;
261 
262  return DuplicateUnicodeString(0, &BufferU, CompatibleIDs);
263 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:31
int _cdecl swprintf(const WCHAR *,...)
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateHardwareIDsString()

static NTSTATUS PciCreateHardwareIDsString ( PUNICODE_STRING  HardwareIDs)
static

Definition at line 224 of file fdo.c.

225 {
226  WCHAR Buffer[256];
227  UNICODE_STRING BufferU;
228  ULONG Index;
229 
230  Index = 0;
231  Index += swprintf(&Buffer[Index],
232  L"FDC\\GENERIC_FLOPPY_DRIVE");
233  Index++;
234 
236 
237  BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
238  BufferU.Buffer = Buffer;
239 
240  return DuplicateUnicodeString(0, &BufferU, HardwareIDs);
241 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:31
int _cdecl swprintf(const WCHAR *,...)
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateInstanceIDString()

static NTSTATUS PciCreateInstanceIDString ( PUNICODE_STRING  InstanceID,
ULONG  PeripheralNumber 
)
static

Definition at line 268 of file fdo.c.

270 {
271  WCHAR Buffer[3];
272 
273  swprintf(Buffer, L"%02X", PeripheralNumber & 0xff);
274 
276 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define L(x)
Definition: ntvdm.h:50
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING InstanceID
Definition: wdfpdo.h:306
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
int _cdecl swprintf(const WCHAR *,...)
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().