ReactOS  0.4.14-dev-554-g2f8d847
fdo.c File Reference
#include "pciidex.h"
#include <debug.h>
#include <initguid.h>
#include <wdmguid.h>
Include dependency graph for fdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS GetBusInterface (IN PFDO_DEVICE_EXTENSION DeviceExtension)
 
static NTSTATUS ReleaseBusInterface (IN PFDO_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciIdeXAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
static NTSTATUS NTAPI PciIdeXUdmaModesSupported (IN IDENTIFY_DATA IdentifyData, OUT PULONG BestXferMode, OUT PULONG CurrentXferMode)
 
static NTSTATUS PciIdeXFdoStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS PciIdeXFdoQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
 
NTSTATUS NTAPI PciIdeXFdoPnpDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file fdo.c.

Function Documentation

◆ GetBusInterface()

static NTSTATUS GetBusInterface ( IN PFDO_DEVICE_EXTENSION  DeviceExtension)
static

Definition at line 18 of file fdo.c.

20 {
21  PBUS_INTERFACE_STANDARD BusInterface = NULL;
22  KEVENT Event;
24  PIRP Irp;
25  PIO_STACK_LOCATION Stack;
27 
28  if (DeviceExtension->BusInterface)
29  {
30  DPRINT("We already have the bus interface\n");
31  goto cleanup;
32  }
33 
34  BusInterface = ExAllocatePool(PagedPool, sizeof(BUS_INTERFACE_STANDARD));
35  if (!BusInterface)
36  {
37  DPRINT("ExAllocatePool() failed\n");
39  goto cleanup;
40  }
41 
44  IRP_MJ_PNP,
45  DeviceExtension->LowerDevice,
46  NULL,
47  0,
48  NULL,
49  &Event,
50  &IoStatus);
51  if (!Irp)
52  {
53  DPRINT("IoBuildSynchronousFsdRequest() failed\n");
55  goto cleanup;
56  }
57 
58  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
59  Irp->IoStatus.Information = 0;
60 
62  Stack->MajorFunction = IRP_MJ_PNP;
64  Stack->Parameters.QueryInterface.InterfaceType = (LPGUID)&GUID_BUS_INTERFACE_STANDARD;
65  Stack->Parameters.QueryInterface.Version = 1;
66  Stack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
67  Stack->Parameters.QueryInterface.Interface = (PINTERFACE)BusInterface;
68  Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
69 
70  Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
71  if (Status == STATUS_PENDING)
72  {
74  Status = IoStatus.Status;
75  }
76  if (!NT_SUCCESS(Status))
77  goto cleanup;
78 
79  DeviceExtension->BusInterface = BusInterface;
80  BusInterface = NULL;
82 
83 cleanup:
84  if (BusInterface) ExFreePool(BusInterface);
85  return Status;
86 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
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
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _INTERFACE * PINTERFACE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_QUERY_INTERFACE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
struct _BUS_INTERFACE_STANDARD BUS_INTERFACE_STANDARD
#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
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
char * cleanup(char *str)
Definition: wpickclick.c:99
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
GUID * LPGUID
Definition: guiddef.h:81

Referenced by PciIdeXAddDevice(), and PortFdoStartMiniport().

◆ PciIdeXAddDevice()

NTSTATUS NTAPI PciIdeXAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 106 of file fdo.c.

109 {
111  PFDO_DEVICE_EXTENSION DeviceExtension;
112  PDEVICE_OBJECT Fdo;
114  PCI_COMMON_CONFIG PciConfig;
116 
117  DPRINT("PciIdeXAddDevice(%p %p)\n", DriverObject, Pdo);
118 
121 
123  DriverObject,
124  sizeof(FDO_DEVICE_EXTENSION) + DriverExtension->MiniControllerExtensionSize,
125  NULL,
128  TRUE,
129  &Fdo);
130  if (!NT_SUCCESS(Status))
131  {
132  DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status);
133  return Status;
134  }
135 
136  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
137  RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
138 
139  DeviceExtension->Common.IsFDO = TRUE;
140 
141  Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
142  if (!NT_SUCCESS(Status))
143  {
144  DPRINT("IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status);
145  return Status;
146  }
147 
148  Status = GetBusInterface(DeviceExtension);
149  if (!NT_SUCCESS(Status))
150  {
151  DPRINT("GetBusInterface() failed with status 0x%08lx\n", Status);
152  IoDetachDevice(DeviceExtension->LowerDevice);
153  return Status;
154  }
155 
156  BytesRead = (*DeviceExtension->BusInterface->GetBusData)(
157  DeviceExtension->BusInterface->Context,
159  &PciConfig,
160  0,
163  {
164  DPRINT("BusInterface->GetBusData() failed()\n");
165  ReleaseBusInterface(DeviceExtension);
166  IoDetachDevice(DeviceExtension->LowerDevice);
167  return STATUS_IO_DEVICE_ERROR;
168  }
169 
170  DeviceExtension->VendorId = PciConfig.VendorID;
171  DeviceExtension->DeviceId = PciConfig.DeviceID;
172 
173  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
174 
175  return STATUS_SUCCESS;
176 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define TRUE
Definition: types.h:120
PBUS_INTERFACE_STANDARD BusInterface
Definition: pciidex.h:23
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS GetBusInterface(IN PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:18
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:980
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:884
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3288
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:80
Status
Definition: gdiplustypes.h:24
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
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static NTSTATUS ReleaseBusInterface(IN PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:89
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3238

◆ PciIdeXFdoPnpDispatch()

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

Definition at line 402 of file fdo.c.

405 {
407  PIO_STACK_LOCATION Stack;
408  ULONG_PTR Information = Irp->IoStatus.Information;
410 
412  MinorFunction = Stack->MinorFunction;
413 
414  switch (MinorFunction)
415  {
416  case IRP_MN_START_DEVICE: /* 0x00 */
417  {
418  DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
419  /* Call lower driver */
421  if (NT_SUCCESS(Status))
423  break;
424  }
425  case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
426  {
427  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
429  break;
430  }
431  case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
432  {
433  switch (Stack->Parameters.QueryDeviceRelations.Type)
434  {
435  case BusRelations:
436  {
437  PDEVICE_RELATIONS DeviceRelations = NULL;
438  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
439  Status = PciIdeXFdoQueryBusRelations(DeviceObject, &DeviceRelations);
440  Information = (ULONG_PTR)DeviceRelations;
441  break;
442  }
443  default:
444  {
445  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
446  Stack->Parameters.QueryDeviceRelations.Type);
448  break;
449  }
450  }
451  break;
452  }
453  case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
454  {
455  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
458  break;
459  }
460  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: /* 0x0d */
461  {
462  DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
464  }
465  case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
466  {
467  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
469  }
470  default:
471  {
472  DPRINT1("IRP_MJ_PNP / Unknown minor function 0x%lx\n", MinorFunction);
474  }
475  }
476 
477  Irp->IoStatus.Information = Information;
478  Irp->IoStatus.Status = Status;
480  return Status;
481 }
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:66
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
static NTSTATUS PciIdeXFdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: fdo.c:315
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
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 NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:969
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
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
static NTSTATUS PciIdeXFdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:269
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define IRP_MN_QUERY_PNP_DEVICE_STATE
Iosb Information
Definition: create.c:4377
#define IRP_MN_QUERY_CAPABILITIES

Referenced by _Dispatch_type_().

◆ PciIdeXFdoQueryBusRelations()

static NTSTATUS PciIdeXFdoQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_RELATIONS pDeviceRelations 
)
static

Definition at line 315 of file fdo.c.

318 {
319  PFDO_DEVICE_EXTENSION DeviceExtension;
320  PDEVICE_RELATIONS DeviceRelations = NULL;
322  PPDO_DEVICE_EXTENSION PdoDeviceExtension;
323  ULONG i, j;
324  ULONG PDOs = 0;
325  IDE_CHANNEL_STATE ChannelState;
327 
329  ASSERT(DeviceExtension);
330  ASSERT(DeviceExtension->Common.IsFDO);
331 
332  for (i = 0; i < MAX_IDE_CHANNEL; i++)
333  {
334  if (DeviceExtension->Pdo[i])
335  {
336  PDOs++;
337  continue;
338  }
339  ChannelState = DeviceExtension->Properties.PciIdeChannelEnabled(
340  DeviceExtension->MiniControllerExtension, i);
341  if (ChannelState == ChannelDisabled)
342  {
343  DPRINT("Channel %lu is disabled\n", i);
344  continue;
345  }
346 
347  /* Need to create a PDO */
349  DeviceObject->DriverObject,
350  sizeof(PDO_DEVICE_EXTENSION),
351  NULL,
354  FALSE,
355  &Pdo);
356  if (!NT_SUCCESS(Status))
357  /* FIXME: handle error */
358  continue;
359 
360  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
361  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
362  PdoDeviceExtension->Common.IsFDO = FALSE;
363  PdoDeviceExtension->Channel = i;
364  PdoDeviceExtension->ControllerFdo = DeviceObject;
367 
368  DeviceExtension->Pdo[i] = Pdo;
369  PDOs++;
370  }
371 
372  if (PDOs == 0)
373  {
374  DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
375  PagedPool,
376  sizeof(DEVICE_RELATIONS));
377  }
378  else
379  {
380  DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(
381  PagedPool,
382  sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (PDOs - 1));
383  }
384  if (!DeviceRelations)
386 
387  DeviceRelations->Count = PDOs;
388  for (i = 0, j = 0; i < MAX_IDE_CHANNEL; i++)
389  {
390  if (DeviceExtension->Pdo[i])
391  {
392  ObReferenceObject(DeviceExtension->Pdo[i]);
393  DeviceRelations->Objects[j++] = DeviceExtension->Pdo[i];
394  }
395  }
396 
397  *pDeviceRelations = DeviceRelations;
398  return STATUS_SUCCESS;
399 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
PCIIDE_CHANNEL_ENABLED PciIdeChannelEnabled
Definition: ide.h:326
PDEVICE_OBJECT ControllerFdo
Definition: pciidex.h:38
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
IDE_CHANNEL_STATE
Definition: ide.h:259
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
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 FILE_DEVICE_CONTROLLER
Definition: winioctl.h:109
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define DO_BUS_ENUMERATED_DEVICE
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:55
void DPRINT(...)
Definition: polytest.cpp:61
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
#define MAX_IDE_CHANNEL
Definition: ide.h:26
PUCHAR MiniControllerExtension[0]
Definition: pciidex.h:30
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 GLint GLint j
Definition: glfuncs.h:250
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:80
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define ObReferenceObject
Definition: obfuncs.h:204
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
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
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
IDE_CONTROLLER_PROPERTIES Properties
Definition: pciidex.h:24

Referenced by PciIdeXFdoPnpDispatch().

◆ PciIdeXFdoStartDevice()

static NTSTATUS PciIdeXFdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 269 of file fdo.c.

272 {
274  PFDO_DEVICE_EXTENSION DeviceExtension;
277 
278  DPRINT("PciIdeXStartDevice(%p %p)\n", DeviceObject, Irp);
279 
283  ASSERT(DeviceExtension);
284  ASSERT(DeviceExtension->Common.IsFDO);
285 
286  DeviceExtension->Properties.Size = sizeof(IDE_CONTROLLER_PROPERTIES);
287  DeviceExtension->Properties.ExtensionSize = DriverExtension->MiniControllerExtensionSize;
288  Status = DriverExtension->HwGetControllerProperties(
289  DeviceExtension->MiniControllerExtension,
290  &DeviceExtension->Properties);
291  if (!NT_SUCCESS(Status))
292  return Status;
293 
294  DriverExtension->HwUdmaModesSupported = DeviceExtension->Properties.PciIdeUdmaModesSupported;
295  if (!DriverExtension->HwUdmaModesSupported)
296  /* This method is optional, so provide our own one */
297  DriverExtension->HwUdmaModesSupported = PciIdeXUdmaModesSupported;
298 
299  /* Get bus master port base, if any */
300  ResourceList = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
301  if (ResourceList
302  && ResourceList->Count == 1
303  && ResourceList->List[0].PartialResourceList.Count == 1
304  && ResourceList->List[0].PartialResourceList.Version == 1
305  && ResourceList->List[0].PartialResourceList.Revision == 1
306  && ResourceList->List[0].PartialResourceList.PartialDescriptors[0].Type == CmResourceTypePort
307  && ResourceList->List[0].PartialResourceList.PartialDescriptors[0].u.Port.Length == 16)
308  {
309  DeviceExtension->BusMasterPortBase = ResourceList->List[0].PartialResourceList.PartialDescriptors[0].u.Port.Start;
310  }
311  return STATUS_SUCCESS;
312 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
struct _IDE_CONTROLLER_PROPERTIES IDE_CONTROLLER_PROPERTIES
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
void DPRINT(...)
Definition: polytest.cpp:61
PUCHAR MiniControllerExtension[0]
Definition: pciidex.h:30
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
PHYSICAL_ADDRESS BusMasterPortBase
Definition: pciidex.h:25
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:80
Status
Definition: gdiplustypes.h:24
PCIIDE_UDMA_MODES_SUPPORTED PciIdeUdmaModesSupported
Definition: ide.h:369
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
static NTSTATUS NTAPI PciIdeXUdmaModesSupported(IN IDENTIFY_DATA IdentifyData, OUT PULONG BestXferMode, OUT PULONG CurrentXferMode)
Definition: fdo.c:179
IDE_CONTROLLER_PROPERTIES Properties
Definition: pciidex.h:24

Referenced by PciIdeXFdoPnpDispatch().

◆ PciIdeXUdmaModesSupported()

static NTSTATUS NTAPI PciIdeXUdmaModesSupported ( IN IDENTIFY_DATA  IdentifyData,
OUT PULONG  BestXferMode,
OUT PULONG  CurrentXferMode 
)
static

Definition at line 179 of file fdo.c.

183 {
184  ULONG Best = PIO_MODE0;
185  ULONG Current = PIO_MODE0;
186 
187  DPRINT("PciIdeXUdmaModesSupported(%lu, %p %p)\n",
188  IdentifyData, BestXferMode, CurrentXferMode);
189 
190  /* FIXME: if current mode is a PIO mode, how to get it?
191  * At the moment, PIO_MODE0 is always returned...
192  */
193 
194  if (IdentifyData.TranslationFieldsValid & 0x2)
195  {
196  /* PIO modes and some DMA modes are supported */
197  if (IdentifyData.AdvancedPIOModes & 0x10)
198  Best = PIO_MODE4;
199  else if (IdentifyData.AdvancedPIOModes & 0x8)
200  Best = PIO_MODE3;
201  else if (IdentifyData.AdvancedPIOModes & 0x4)
202  Best = PIO_MODE2;
203  else if (IdentifyData.AdvancedPIOModes & 0x2)
204  Best = PIO_MODE1;
205  else if (IdentifyData.AdvancedPIOModes & 0x1)
206  Best = PIO_MODE0;
207 
208  if (IdentifyData.SingleWordDMASupport & 0x4)
209  Best = SWDMA_MODE2;
210  else if (IdentifyData.SingleWordDMASupport & 0x2)
211  Best = SWDMA_MODE1;
212  else if (IdentifyData.SingleWordDMASupport & 0x1)
213  Best = SWDMA_MODE0;
214 
215  if (IdentifyData.SingleWordDMAActive & 0x4)
216  Current = SWDMA_MODE2;
217  else if (IdentifyData.SingleWordDMAActive & 0x2)
218  Current = SWDMA_MODE1;
219  else if (IdentifyData.SingleWordDMAActive & 0x1)
220  Current = SWDMA_MODE0;
221 
222  if (IdentifyData.MultiWordDMASupport & 0x4)
223  Best = MWDMA_MODE2;
224  else if (IdentifyData.MultiWordDMASupport & 0x2)
225  Best = MWDMA_MODE1;
226  else if (IdentifyData.MultiWordDMASupport & 0x1)
227  Best = MWDMA_MODE0;
228 
229  if (IdentifyData.MultiWordDMAActive & 0x4)
230  Current = MWDMA_MODE2;
231  else if (IdentifyData.MultiWordDMAActive & 0x2)
232  Current = MWDMA_MODE1;
233  else if (IdentifyData.MultiWordDMAActive & 0x1)
234  Current = MWDMA_MODE0;
235  }
236 
237  if (IdentifyData.TranslationFieldsValid & 0x4)
238  {
239  /* UDMA modes are supported */
240  if (IdentifyData.UltraDMAActive & 0x10)
241  Current = UDMA_MODE4;
242  else if (IdentifyData.UltraDMAActive & 0x8)
243  Current = UDMA_MODE3;
244  else if (IdentifyData.UltraDMAActive & 0x4)
245  Current = UDMA_MODE2;
246  else if (IdentifyData.UltraDMAActive & 0x2)
247  Current = UDMA_MODE1;
248  else if (IdentifyData.UltraDMAActive & 0x1)
249  Current = UDMA_MODE0;
250 
251  if (IdentifyData.UltraDMASupport & 0x10)
252  Best = UDMA_MODE4;
253  else if (IdentifyData.UltraDMASupport & 0x8)
254  Best = UDMA_MODE3;
255  else if (IdentifyData.UltraDMASupport & 0x4)
256  Best = UDMA_MODE2;
257  else if (IdentifyData.UltraDMASupport & 0x2)
258  Best = UDMA_MODE1;
259  else if (IdentifyData.UltraDMASupport & 0x1)
260  Best = UDMA_MODE0;
261  }
262 
263  *BestXferMode = Best;
264  *CurrentXferMode = Current;
265  return TRUE;
266 }
#define TRUE
Definition: types.h:120
#define MWDMA_MODE1
Definition: ideuser.h:33
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define PIO_MODE0
Definition: ideuser.h:22
#define UDMA_MODE3
Definition: ideuser.h:39
#define UDMA_MODE1
Definition: ideuser.h:37
#define SWDMA_MODE2
Definition: ideuser.h:30
void DPRINT(...)
Definition: polytest.cpp:61
#define PIO_MODE1
Definition: ideuser.h:23
#define SWDMA_MODE0
Definition: ideuser.h:28
#define UDMA_MODE0
Definition: ideuser.h:36
#define UDMA_MODE4
Definition: ideuser.h:40
#define PIO_MODE3
Definition: ideuser.h:25
#define MWDMA_MODE0
Definition: ideuser.h:32
#define PIO_MODE4
Definition: ideuser.h:26
#define MWDMA_MODE2
Definition: ideuser.h:34
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
#define PIO_MODE2
Definition: ideuser.h:24
unsigned int ULONG
Definition: retypes.h:1
#define UDMA_MODE2
Definition: ideuser.h:38
#define SWDMA_MODE1
Definition: ideuser.h:29

Referenced by PciIdeXFdoStartDevice().

◆ ReleaseBusInterface()

static NTSTATUS ReleaseBusInterface ( IN PFDO_DEVICE_EXTENSION  DeviceExtension)
static

Definition at line 89 of file fdo.c.

91 {
93 
94  if (DeviceExtension->BusInterface)
95  {
96  (*DeviceExtension->BusInterface->InterfaceDereference)(
97  DeviceExtension->BusInterface->Context);
98  DeviceExtension->BusInterface = NULL;
100  }
101 
102  return Status;
103 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by PciIdeXAddDevice().