ReactOS 0.4.16-dev-117-g38f21f9
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 123 of file fdo.c.

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

Referenced by FdcFdoQueryBusRelations().

◆ FdcFdoPnp()

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

Definition at line 444 of file fdo.c.

447{
450 PDEVICE_RELATIONS DeviceRelations = NULL;
453
454 DPRINT("FdcFdoPnp()\n");
455
457
458 switch (IrpSp->MinorFunction)
459 {
461 DPRINT(" IRP_MN_START_DEVICE received\n");
462
463 /* Call lower driver */
465 FdoExtension = DeviceObject->DeviceExtension;
466
467 if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
468 {
469 Status = Irp->IoStatus.Status;
470 if (NT_SUCCESS(Status))
471 {
473 IrpSp->Parameters.StartDevice.AllocatedResources,
474 IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
475 }
476 }
477
478 break;
479
481 DPRINT(" IRP_MN_QUERY_REMOVE_DEVICE\n");
482 break;
483
485 DPRINT(" IRP_MN_REMOVE_DEVICE received\n");
486 break;
487
489 DPRINT(" IRP_MN_CANCEL_REMOVE_DEVICE\n");
490 break;
491
493 DPRINT(" IRP_MN_STOP_DEVICE received\n");
494 break;
495
497 DPRINT(" IRP_MN_QUERY_STOP_DEVICE received\n");
498 break;
499
501 DPRINT(" IRP_MN_CANCEL_STOP_DEVICE\n");
502 break;
503
505 DPRINT(" IRP_MN_QUERY_DEVICE_RELATIONS\n");
506
508 {
509 case BusRelations:
510 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
511 Status = FdcFdoQueryBusRelations(DeviceObject, &DeviceRelations);
512 Information = (ULONG_PTR)DeviceRelations;
513 break;
514
515 case RemovalRelations:
516 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
518
519 default:
520 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
523 }
524 break;
525
527 DPRINT(" IRP_MN_SURPRISE_REMOVAL received\n");
528 break;
529
530 default:
531 DPRINT(" Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
533 }
534
535 Irp->IoStatus.Information = Information;
536 Irp->IoStatus.Status = Status;
538
539 return Status;
540}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
@ FdoExtension
Definition: precomp.h:48
Status
Definition: gdiplustypes.h:25
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
static NTSTATUS FdcFdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
Definition: fdo.c:36
static NTSTATUS FdcFdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *DeviceRelations)
Definition: fdo.c:279
struct _IO_STACK_LOCATION::@3974::@4011 StartDevice
struct _IO_STACK_LOCATION::@3974::@3999 QueryDeviceRelations
union _IO_STACK_LOCATION::@1575 Parameters
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define IRP_MN_CANCEL_STOP_DEVICE
@ RemovalRelations
Definition: iotypes.h:2155
@ BusRelations
Definition: iotypes.h:2152
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by FdcPnp().

◆ FdcFdoQueryBusRelations()

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

Definition at line 279 of file fdo.c.

282{
283 PFDO_DEVICE_EXTENSION FdoDeviceExtension;
284 PPDO_DEVICE_EXTENSION PdoDeviceExtension;
286 CONFIGURATION_TYPE ControllerType = DiskController;
288 PDEVICE_RELATIONS Relations;
289 PDRIVE_INFO DriveInfo;
291 WCHAR DeviceNameBuffer[80];
294 ULONG Size;
295 ULONG i;
297
298 DPRINT("FdcFdoQueryBusRelations() called\n");
299
300 FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
301
303 NULL,
304 &ControllerType,
305 NULL,
306 &PeripheralType,
307 NULL,
309 FdoDeviceExtension);
311 return Status;
312
313 Size = sizeof(DEVICE_RELATIONS) +
314 sizeof(Relations->Objects) * (FdoDeviceExtension->ControllerInfo.NumberOfDrives - 1);
316 if (Relations == NULL)
317 {
319 }
320
321 Relations->Count = FdoDeviceExtension->ControllerInfo.NumberOfDrives;
322
323 for (i = 0; i < FdoDeviceExtension->ControllerInfo.NumberOfDrives; i++)
324 {
325 DriveInfo = &FdoDeviceExtension->ControllerInfo.DriveInfo[i];
326
327 if (DriveInfo->DeviceObject == NULL)
328 {
329 do
330 {
331 swprintf(DeviceNameBuffer, L"\\Device\\FloppyPDO%lu", DeviceNumber++);
332 RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
333 DPRINT("Device name: %S\n", DeviceNameBuffer);
334
335 /* Create physical device object */
336 Status = IoCreateDevice(FdoDeviceExtension->Common.DeviceObject->DriverObject,
337 sizeof(PDO_DEVICE_EXTENSION),
338 &DeviceName,
341 FALSE,
342 &Pdo);
343 }
345
346 if (!NT_SUCCESS(Status))
347 {
348 DPRINT1("PDO creation failed (Status 0x%08lx)\n", Status);
349 goto done;
350 }
351
352 DPRINT("PDO created: %S\n", DeviceNameBuffer);
353
354 DriveInfo->DeviceObject = Pdo;
355
356 PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
357 RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
358
359 PdoDeviceExtension->Common.IsFDO = FALSE;
360 PdoDeviceExtension->Common.DeviceObject = Pdo;
361
362 PdoDeviceExtension->Fdo = FdoDeviceExtension->Common.DeviceObject;
363 PdoDeviceExtension->DriveInfo = DriveInfo;
364
365 Pdo->Flags |= DO_DIRECT_IO;
366 Pdo->Flags |= DO_POWER_PAGABLE;
367 Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
368
369 /* Add Device ID string */
370 RtlCreateUnicodeString(&PdoDeviceExtension->DeviceId,
371 L"FDC\\GENERIC_FLOPPY_DRIVE");
372 DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceId.Buffer);
373
374 /* Add Hardware IDs string */
375 Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIds);
376 if (!NT_SUCCESS(Status))
377 {
378// ErrorStatus = Status;
379// ErrorOccurred = TRUE;
380 break;
381 }
382
383 /* Add Compatible IDs string */
384 Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIds);
385 if (!NT_SUCCESS(Status))
386 {
387// ErrorStatus = Status;
388// ErrorOccurred = TRUE;
389 break;
390 }
391
392 /* Add Instance ID string */
393 Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceId,
394 DriveInfo->PeripheralNumber);
395 if (!NT_SUCCESS(Status))
396 {
397// ErrorStatus = Status;
398// ErrorOccurred = TRUE;
399 break;
400 }
401
402#if 0
403 /* Add device description string */
405 if (!NT_SUCCESS(Status))
406 {
407// ErrorStatus = Status;
408// ErrorOccurred = TRUE;
409 break;
410 }
411
412 /* Add device location string */
414 if (!NT_SUCCESS(Status))
415 {
416// ErrorStatus = Status;
417// ErrorOccurred = TRUE;
418 break;
419 }
420#endif
421 }
422
424 Relations->Objects[i] = DriveInfo->DeviceObject;
425 }
426
427done:
428 if (NT_SUCCESS(Status))
429 {
430 *DeviceRelations = Relations;
431 }
432 else
433 {
434 if (Relations != NULL)
435 ExFreePool(Relations);
436 }
437
438 return Status;
439}
#define DPRINT1
Definition: precomp.h:8
@ DiskController
Definition: arcname.c:68
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define swprintf
Definition: precomp.h:40
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
@ Isa
Definition: hwresource.cpp:138
enum _INTERFACE_TYPE INTERFACE_TYPE
NTSTATUS NTAPI IoQueryDeviceDescription(_In_opt_ PINTERFACE_TYPE BusType, _In_opt_ PULONG BusNumber, _In_opt_ PCONFIGURATION_TYPE ControllerType, _In_opt_ PULONG ControllerNumber, _In_opt_ PCONFIGURATION_TYPE PeripheralType, _In_opt_ PULONG PeripheralNumber, _In_ PIO_QUERY_DEVICE_ROUTINE CalloutRoutine, _In_opt_ PVOID Context)
Reads and returns Hardware information from the appropriate hardware registry key.
Definition: iorsrce.c:1213
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:60
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define L(x)
Definition: ntvdm.h:50
NTSTATUS PciCreateInstanceIDString(PUNICODE_STRING InstanceID, PPCI_DEVICE Device)
Definition: pci.c:302
NTSTATUS PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription, PPCI_DEVICE Device)
Definition: pci.c:430
NTSTATUS PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs, PPCI_DEVICE Device)
Definition: pci.c:366
NTSTATUS PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs, PPCI_DEVICE Device)
Definition: pci.c:314
NTSTATUS PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation, PPCI_DEVICE Device)
Definition: pci.c:698
@ FloppyDiskPeripheral
Definition: arc.h:130
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
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:123
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
PDEVICE_OBJECT DeviceObject
Definition: fdc.h:26
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84
PDEVICE_OBJECT Fdo
Definition: pci.h:61
UNICODE_STRING InstanceId
Definition: serenum.h:53
UNICODE_STRING DeviceDescription
Definition: pci.h:73
UNICODE_STRING HardwareIds
Definition: serenum.h:54
UNICODE_STRING DeviceLocation
Definition: pci.h:75
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:59
UNICODE_STRING CompatibleIds
Definition: serenum.h:55
PDRIVE_INFO DriveInfo
Definition: fdc.h:93
UNICODE_STRING DeviceId
Definition: serenum.h:52
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
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:72
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define DO_POWER_PAGABLE
struct _DEVICE_RELATIONS DEVICE_RELATIONS
#define ObReferenceObject
Definition: obfuncs.h:204
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

40{
41 PFDO_DEVICE_EXTENSION DeviceExtension;
42 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
43// PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated;
44 ULONG i;
45
46 DPRINT("FdcFdoStartDevice called\n");
47
48 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
49
50 ASSERT(DeviceExtension);
51
52 if (ResourceList == NULL ||
53 ResourceListTranslated == NULL)
54 {
55 DPRINT1("No allocated resources sent to driver\n");
57 }
58
59 if (ResourceList->Count != 1)
60 {
61 DPRINT1("Wrong number of allocated resources sent to driver\n");
63 }
64
65 if (ResourceList->List[0].PartialResourceList.Version != 1 ||
66 ResourceList->List[0].PartialResourceList.Revision != 1 ||
67 ResourceListTranslated->List[0].PartialResourceList.Version != 1 ||
68 ResourceListTranslated->List[0].PartialResourceList.Revision != 1)
69 {
70 DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n",
71 ResourceList->List[0].PartialResourceList.Version,
72 ResourceList->List[0].PartialResourceList.Revision,
73 ResourceListTranslated->List[0].PartialResourceList.Version,
74 ResourceListTranslated->List[0].PartialResourceList.Revision);
76 }
77
78 for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
79 {
80 PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
81// PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i];
82
83 switch (PartialDescriptor->Type)
84 {
86 DPRINT("Port: 0x%lx (%lu)\n",
87 PartialDescriptor->u.Port.Start.u.LowPart,
88 PartialDescriptor->u.Port.Length);
89 if (PartialDescriptor->u.Port.Length >= 6)
90 DeviceExtension->ControllerInfo.BaseAddress = (PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart;
91 break;
92
94 DPRINT("Interrupt: Level %lu Vector %lu\n",
95 PartialDescriptor->u.Interrupt.Level,
96 PartialDescriptor->u.Interrupt.Vector);
97/*
98 Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level;
99 Vector = PartialDescriptorTranslated->u.Interrupt.Vector;
100 Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity;
101 if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
102 InterruptMode = Latched;
103 else
104 InterruptMode = LevelSensitive;
105 ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared);
106*/
107 break;
108
110 DPRINT("Dma: Channel %lu\n",
111 PartialDescriptor->u.Dma.Channel);
112 break;
113 }
114 }
115
116 return STATUS_SUCCESS;
117}
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@394 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@397 Dma
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

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}
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225

◆ PciCreateCompatibleIDsString()

static NTSTATUS PciCreateCompatibleIDsString ( PUNICODE_STRING  CompatibleIDs)
static

Definition at line 244 of file fdo.c.

245{
246 WCHAR Buffer[256];
247 UNICODE_STRING BufferU;
248 ULONG Index;
249
250 Index = 0;
252 L"GenFloppyDisk");
253 Index++;
254
256
257 BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
258 BufferU.Buffer = Buffer;
259
260 return DuplicateUnicodeString(0, &BufferU, CompatibleIDs);
261}
Definition: bufpool.h:45
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:31
#define UNICODE_NULL
unsigned short USHORT
Definition: pedump.c:61
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ WDFCOLLECTION _In_ ULONG Index

◆ PciCreateHardwareIDsString()

static NTSTATUS PciCreateHardwareIDsString ( PUNICODE_STRING  HardwareIDs)
static

Definition at line 222 of file fdo.c.

223{
224 WCHAR Buffer[256];
225 UNICODE_STRING BufferU;
226 ULONG Index;
227
228 Index = 0;
230 L"FDC\\GENERIC_FLOPPY_DRIVE");
231 Index++;
232
234
235 BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
236 BufferU.Buffer = Buffer;
237
238 return DuplicateUnicodeString(0, &BufferU, HardwareIDs);
239}

◆ PciCreateInstanceIDString()

static NTSTATUS PciCreateInstanceIDString ( PUNICODE_STRING  InstanceID,
ULONG  PeripheralNumber 
)
static

Definition at line 266 of file fdo.c.

268{
269 WCHAR Buffer[3];
270
271 swprintf(Buffer, L"%02X", PeripheralNumber & 0xff);
272
274}
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING InstanceID
Definition: wdfpdo.h:309