ReactOS  0.4.14-dev-114-gc8cbd56
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

static NTSTATUS NTAPI ForwardIrpAndWaitCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
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)
 

Variables

static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
 

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 170 of file fdo.c.

182 {
183  PKEY_VALUE_FULL_INFORMATION ControllerFullDescriptor;
184  PCM_FULL_RESOURCE_DESCRIPTOR ControllerResourceDescriptor;
185  PKEY_VALUE_FULL_INFORMATION PeripheralFullDescriptor;
186  PCM_FULL_RESOURCE_DESCRIPTOR PeripheralResourceDescriptor;
187  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
188  PCM_FLOPPY_DEVICE_DATA FloppyDeviceData;
189  PFDO_DEVICE_EXTENSION DeviceExtension;
190  PDRIVE_INFO DriveInfo;
191  BOOLEAN ControllerFound = FALSE;
192  ULONG i;
193 
194  DPRINT("FdcFdoConfigCallback() called\n");
195 
196  DeviceExtension = (PFDO_DEVICE_EXTENSION)Context;
197 
198  /* Get the controller resources */
199  ControllerFullDescriptor = ControllerInformation[IoQueryDeviceConfigurationData];
200  ControllerResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)((PCHAR)ControllerFullDescriptor +
201  ControllerFullDescriptor->DataOffset);
202 
203  for(i = 0; i < ControllerResourceDescriptor->PartialResourceList.Count; i++)
204  {
205  PartialDescriptor = &ControllerResourceDescriptor->PartialResourceList.PartialDescriptors[i];
206 
207  if (PartialDescriptor->Type == CmResourceTypePort)
208  {
209  if ((PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart == DeviceExtension->ControllerInfo.BaseAddress)
210  ControllerFound = TRUE;
211  }
212  }
213 
214  /* Leave, if the enumerated controller is not the one represented by the FDO */
215  if (ControllerFound == FALSE)
216  return STATUS_SUCCESS;
217 
218  /* Get the peripheral resources */
219  PeripheralFullDescriptor = PeripheralInformation[IoQueryDeviceConfigurationData];
220  PeripheralResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)((PCHAR)PeripheralFullDescriptor +
221  PeripheralFullDescriptor->DataOffset);
222 
223  /* learn about drives attached to controller */
224  for(i = 0; i < PeripheralResourceDescriptor->PartialResourceList.Count; i++)
225  {
226  PartialDescriptor = &PeripheralResourceDescriptor->PartialResourceList.PartialDescriptors[i];
227 
228  if (PartialDescriptor->Type != CmResourceTypeDeviceSpecific)
229  continue;
230 
231  FloppyDeviceData = (PCM_FLOPPY_DEVICE_DATA)(PartialDescriptor + 1);
232 
233  DriveInfo = &DeviceExtension->ControllerInfo.DriveInfo[DeviceExtension->ControllerInfo.NumberOfDrives];
234 
235  DriveInfo->ControllerInfo = &DeviceExtension->ControllerInfo;
236  DriveInfo->UnitNumber = DeviceExtension->ControllerInfo.NumberOfDrives;
237  DriveInfo->PeripheralNumber = PeripheralNumber;
238 
239  DriveInfo->FloppyDeviceData.MaxDensity = FloppyDeviceData->MaxDensity;
240  DriveInfo->FloppyDeviceData.MountDensity = FloppyDeviceData->MountDensity;
241  DriveInfo->FloppyDeviceData.StepRateHeadUnloadTime = FloppyDeviceData->StepRateHeadUnloadTime;
242  DriveInfo->FloppyDeviceData.HeadLoadTime = FloppyDeviceData->HeadLoadTime;
243  DriveInfo->FloppyDeviceData.MotorOffTime = FloppyDeviceData->MotorOffTime;
244  DriveInfo->FloppyDeviceData.SectorLengthCode = FloppyDeviceData->SectorLengthCode;
245  DriveInfo->FloppyDeviceData.SectorPerTrack = FloppyDeviceData->SectorPerTrack;
246  DriveInfo->FloppyDeviceData.ReadWriteGapLength = FloppyDeviceData->ReadWriteGapLength;
247  DriveInfo->FloppyDeviceData.FormatGapLength = FloppyDeviceData->FormatGapLength;
248  DriveInfo->FloppyDeviceData.FormatFillCharacter = FloppyDeviceData->FormatFillCharacter;
249  DriveInfo->FloppyDeviceData.HeadSettleTime = FloppyDeviceData->HeadSettleTime;
250  DriveInfo->FloppyDeviceData.MotorSettleTime = FloppyDeviceData->MotorSettleTime;
251  DriveInfo->FloppyDeviceData.MaximumTrackValue = FloppyDeviceData->MaximumTrackValue;
252  DriveInfo->FloppyDeviceData.DataTransferLength = FloppyDeviceData->DataTransferLength;
253 
254  /* Once it's all set up, acknowledge its existence in the controller info object */
255  DeviceExtension->ControllerInfo.NumberOfDrives++;
256  }
257 
258  DeviceExtension->ControllerInfo.Populated = TRUE;
259 
260  DPRINT("Detected %lu floppy drives!\n",
261  DeviceExtension->ControllerInfo.NumberOfDrives);
262 
263  return STATUS_SUCCESS;
264 }
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
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
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
BOOLEAN Populated
Definition: fdc.h:39
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375 u
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375::@377 Port
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:487
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
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by FdcFdoQueryBusRelations().

◆ FdcFdoPnp()

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

Definition at line 491 of file fdo.c.

494 {
496  PDEVICE_RELATIONS DeviceRelations = NULL;
499 
500  DPRINT("FdcFdoPnp()\n");
501 
503 
504  switch (IrpSp->MinorFunction)
505  {
506  case IRP_MN_START_DEVICE:
507  DPRINT(" IRP_MN_START_DEVICE received\n");
508  /* Call lower driver */
510  if (NT_SUCCESS(Status))
511  {
513  IrpSp->Parameters.StartDevice.AllocatedResources,
514  IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
515  }
516  break;
517 
519  DPRINT(" IRP_MN_QUERY_REMOVE_DEVICE\n");
520  break;
521 
523  DPRINT(" IRP_MN_REMOVE_DEVICE received\n");
524  break;
525 
527  DPRINT(" IRP_MN_CANCEL_REMOVE_DEVICE\n");
528  break;
529 
530  case IRP_MN_STOP_DEVICE:
531  DPRINT(" IRP_MN_STOP_DEVICE received\n");
532  break;
533 
535  DPRINT(" IRP_MN_QUERY_STOP_DEVICE received\n");
536  break;
537 
539  DPRINT(" IRP_MN_CANCEL_STOP_DEVICE\n");
540  break;
541 
543  DPRINT(" IRP_MN_QUERY_DEVICE_RELATIONS\n");
544 
545  switch (IrpSp->Parameters.QueryDeviceRelations.Type)
546  {
547  case BusRelations:
548  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
549  Status = FdcFdoQueryBusRelations(DeviceObject, &DeviceRelations);
550  Information = (ULONG_PTR)DeviceRelations;
551  break;
552 
553  case RemovalRelations:
554  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
556 
557  default:
558  DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
559  IrpSp->Parameters.QueryDeviceRelations.Type);
561  }
562  break;
563 
565  DPRINT(" IRP_MN_SURPRISE_REMOVAL received\n");
566  break;
567 
568  default:
569  DPRINT(" Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
571  }
572 
573  Irp->IoStatus.Information = Information;
574  Irp->IoStatus.Status = Status;
576 
577  return Status;
578 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS FdcFdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
Definition: fdo.c:83
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IRP_MN_QUERY_REMOVE_DEVICE
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IRP_MN_QUERY_STOP_DEVICE
static NTSTATUS FdcFdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *DeviceRelations)
Definition: fdo.c:326
#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
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:66
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
#define IRP_MN_CANCEL_STOP_DEVICE
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
Iosb Information
Definition: create.c:4377

Referenced by FdcPnp().

◆ FdcFdoQueryBusRelations()

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

Definition at line 326 of file fdo.c.

329 {
330  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
331  PPDO_DEVICE_EXTENSION PdoDeviceExtension;
332  INTERFACE_TYPE InterfaceType = Isa;
333  CONFIGURATION_TYPE ControllerType = DiskController;
334  CONFIGURATION_TYPE PeripheralType = FloppyDiskPeripheral;
335  PDEVICE_RELATIONS Relations;
336  PDRIVE_INFO DriveInfo;
338  WCHAR DeviceNameBuffer[80];
340  ULONG DeviceNumber = 0;
341  ULONG Size;
342  ULONG i;
344 
345  DPRINT("FdcFdoQueryBusRelations() called\n");
346 
347  FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
348 
349  Status = IoQueryDeviceDescription(&InterfaceType,
350  NULL,
351  &ControllerType,
352  NULL,
353  &PeripheralType,
354  NULL,
356  FdoDeviceExtension);
358  return Status;
359 
360  Size = sizeof(DEVICE_RELATIONS) +
361  sizeof(Relations->Objects) * (FdoDeviceExtension->ControllerInfo.NumberOfDrives - 1);
363  if (Relations == NULL)
364  {
366  }
367 
368  Relations->Count = FdoDeviceExtension->ControllerInfo.NumberOfDrives;
369 
370  for (i = 0; i < FdoDeviceExtension->ControllerInfo.NumberOfDrives; i++)
371  {
372  DriveInfo = &FdoDeviceExtension->ControllerInfo.DriveInfo[i];
373 
374  if (DriveInfo->DeviceObject == NULL)
375  {
376  do
377  {
378  swprintf(DeviceNameBuffer, L"\\Device\\FloppyPDO%lu", DeviceNumber++);
379  RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
380  DPRINT("Device name: %S\n", DeviceNameBuffer);
381 
382  /* Create physical device object */
383  Status = IoCreateDevice(FdoDeviceExtension->Common.DeviceObject->DriverObject,
384  sizeof(PDO_DEVICE_EXTENSION),
385  &DeviceName,
388  FALSE,
389  &Pdo);
390  }
392 
393  if (!NT_SUCCESS(Status))
394  {
395  DPRINT1("PDO creation failed (Status 0x%08lx)\n", Status);
396  goto done;
397  }
398 
399  DPRINT("PDO created: %S\n", DeviceNameBuffer);
400 
401  DriveInfo->DeviceObject = Pdo;
402 
403  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
404  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
405 
406  PdoDeviceExtension->Common.IsFDO = FALSE;
407  PdoDeviceExtension->Common.DeviceObject = Pdo;
408 
409  PdoDeviceExtension->Fdo = FdoDeviceExtension->Common.DeviceObject;
410  PdoDeviceExtension->DriveInfo = DriveInfo;
411 
412  Pdo->Flags |= DO_DIRECT_IO;
415 
416  /* Add Device ID string */
417  RtlCreateUnicodeString(&PdoDeviceExtension->DeviceId,
418  L"FDC\\GENERIC_FLOPPY_DRIVE");
419  DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceId.Buffer);
420 
421  /* Add Hardware IDs string */
422  Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIds);
423  if (!NT_SUCCESS(Status))
424  {
425 // ErrorStatus = Status;
426 // ErrorOccurred = TRUE;
427  break;
428  }
429 
430  /* Add Compatible IDs string */
431  Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIds);
432  if (!NT_SUCCESS(Status))
433  {
434 // ErrorStatus = Status;
435 // ErrorOccurred = TRUE;
436  break;
437  }
438 
439  /* Add Instance ID string */
440  Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceId,
441  DriveInfo->PeripheralNumber);
442  if (!NT_SUCCESS(Status))
443  {
444 // ErrorStatus = Status;
445 // ErrorOccurred = TRUE;
446  break;
447  }
448 
449 #if 0
450  /* Add device description string */
452  if (!NT_SUCCESS(Status))
453  {
454 // ErrorStatus = Status;
455 // ErrorOccurred = TRUE;
456  break;
457  }
458 
459  /* Add device location string */
461  if (!NT_SUCCESS(Status))
462  {
463 // ErrorStatus = Status;
464 // ErrorOccurred = TRUE;
465  break;
466  }
467 #endif
468  }
469 
470  ObReferenceObject(DriveInfo->DeviceObject);
471  Relations->Objects[i] = DriveInfo->DeviceObject;
472  }
473 
474 done:
475  if (NT_SUCCESS(Status))
476  {
477  *DeviceRelations = Relations;
478  }
479  else
480  {
481  if (Relations != NULL)
482  ExFreePool(Relations);
483  }
484 
485  return Status;
486 }
#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
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PDEVICE_OBJECT Fdo
Definition: pci.h:57
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:655
UNICODE_STRING HardwareIds
Definition: serenum.h:54
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:62
WCHAR DeviceName[]
Definition: adapter.cpp:21
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
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
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
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:170
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:55
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs)
Definition: fdo.c:291
static NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, ULONG PeripheralNumber)
Definition: fdo.c:313
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:1011
UNICODE_STRING DeviceLocation
Definition: pci.h:71
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSTATUS PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
Definition: pci.c:387
UNICODE_STRING DeviceId
Definition: serenum.h:52
UNICODE_STRING DeviceDescription
Definition: pci.h:69
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
CONFIGURATION_TYPE
Definition: iotypes.h:4037
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:80
Status
Definition: gdiplustypes.h:24
static NTSTATUS PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs)
Definition: fdo.c:269
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _DEVICE_RELATIONS DEVICE_RELATIONS
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:261
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:1036
UNICODE_STRING InstanceId
Definition: serenum.h:53
#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 83 of file fdo.c.

87 {
88  PFDO_DEVICE_EXTENSION DeviceExtension;
89  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
90 // PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated;
91  ULONG i;
92 
93  DPRINT("FdcFdoStartDevice called\n");
94 
96 
97  ASSERT(DeviceExtension);
98 
99  if (ResourceList == NULL ||
100  ResourceListTranslated == NULL)
101  {
102  DPRINT1("No allocated resources sent to driver\n");
104  }
105 
106  if (ResourceList->Count != 1)
107  {
108  DPRINT1("Wrong number of allocated resources sent to driver\n");
110  }
111 
112  if (ResourceList->List[0].PartialResourceList.Version != 1 ||
113  ResourceList->List[0].PartialResourceList.Revision != 1 ||
114  ResourceListTranslated->List[0].PartialResourceList.Version != 1 ||
115  ResourceListTranslated->List[0].PartialResourceList.Revision != 1)
116  {
117  DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n",
118  ResourceList->List[0].PartialResourceList.Version,
119  ResourceList->List[0].PartialResourceList.Revision,
120  ResourceListTranslated->List[0].PartialResourceList.Version,
121  ResourceListTranslated->List[0].PartialResourceList.Revision);
123  }
124 
125  for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
126  {
127  PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
128 // PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i];
129 
130  switch (PartialDescriptor->Type)
131  {
132  case CmResourceTypePort:
133  DPRINT("Port: 0x%lx (%lu)\n",
134  PartialDescriptor->u.Port.Start.u.LowPart,
135  PartialDescriptor->u.Port.Length);
136  if (PartialDescriptor->u.Port.Length >= 6)
137  DeviceExtension->ControllerInfo.BaseAddress = (PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart;
138  break;
139 
141  DPRINT("Interrupt: Level %lu Vector %lu\n",
142  PartialDescriptor->u.Interrupt.Level,
143  PartialDescriptor->u.Interrupt.Vector);
144 /*
145  Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level;
146  Vector = PartialDescriptorTranslated->u.Interrupt.Vector;
147  Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity;
148  if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
149  InterruptMode = Latched;
150  else
151  InterruptMode = LevelSensitive;
152  ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared);
153 */
154  break;
155 
156  case CmResourceTypeDma:
157  DPRINT("Dma: Channel %lu\n",
158  PartialDescriptor->u.Dma.Channel);
159  break;
160  }
161  }
162 
163  return STATUS_SUCCESS;
164 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:311
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
unsigned char * PUCHAR
Definition: retypes.h:3
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375::@381 Dma
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375::@378 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
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375 u
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@375::@377 Port
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
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
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by FdcFdoPnp().

◆ ForwardIrpAndForget()

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

Definition at line 66 of file fdo.c.

69 {
71 
72  ASSERT(LowerDevice);
73 
75  return IoCallDriver(LowerDevice, Irp);
76 }
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
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(), SermousePnp(), and USBHUB_FdoHandlePnp().

◆ ForwardIrpAndWait()

NTSTATUS ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 36 of file fdo.c.

39 {
41  KEVENT Event;
43 
44  ASSERT(LowerDevice);
45 
48 
49  DPRINT("Calling lower device %p\n", LowerDevice);
51 
52  Status = IoCallDriver(LowerDevice, Irp);
53  if (Status == STATUS_PENDING)
54  {
56  if (NT_SUCCESS(Status))
57  Status = Irp->IoStatus.Status;
58  }
59 
60  return Status;
61 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: fdo.c:19
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

◆ ForwardIrpAndWaitCompletion()

static NTSTATUS NTAPI ForwardIrpAndWaitCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)
static

Definition at line 24 of file fdo.c.

28 {
29  if (Irp->PendingReturned)
32 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define IO_NO_INCREMENT
Definition: iotypes.h:566

◆ PciCreateCompatibleIDsString()

static NTSTATUS PciCreateCompatibleIDsString ( PUNICODE_STRING  CompatibleIDs)
static

Definition at line 291 of file fdo.c.

292 {
293  WCHAR Buffer[256];
294  UNICODE_STRING BufferU;
295  ULONG Index;
296 
297  Index = 0;
298  Index += swprintf(&Buffer[Index],
299  L"GenFloppyDisk");
300  Index++;
301 
303 
304  BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
305  BufferU.Buffer = Buffer;
306 
307  return DuplicateUnicodeString(0, &BufferU, CompatibleIDs);
308 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:72
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateHardwareIDsString()

static NTSTATUS PciCreateHardwareIDsString ( PUNICODE_STRING  HardwareIDs)
static

Definition at line 269 of file fdo.c.

270 {
271  WCHAR Buffer[256];
272  UNICODE_STRING BufferU;
273  ULONG Index;
274 
275  Index = 0;
276  Index += swprintf(&Buffer[Index],
277  L"FDC\\GENERIC_FLOPPY_DRIVE");
278  Index++;
279 
281 
282  BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
283  BufferU.Buffer = Buffer;
284 
285  return DuplicateUnicodeString(0, &BufferU, HardwareIDs);
286 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define UNICODE_NULL
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:72
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

◆ PciCreateInstanceIDString()

static NTSTATUS PciCreateInstanceIDString ( PUNICODE_STRING  InstanceID,
ULONG  PeripheralNumber 
)
static

Definition at line 313 of file fdo.c.

315 {
316  WCHAR Buffer[3];
317 
318  swprintf(Buffer, L"%02X", PeripheralNumber & 0xff);
319 
321 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const WCHAR L[]
Definition: oid.c:1250
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by FdcFdoQueryBusRelations(), and FdoQueryBusRelations().

Variable Documentation

◆ ForwardIrpAndWaitCompletion

IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
static

Definition at line 19 of file fdo.c.

Referenced by ForwardIrpAndWait().