ReactOS  0.4.14-dev-583-g2a1ba2c
pnp.c File Reference
#include "usbport.h"
#include <debug.h>
#include "usbdebug.h"
Include dependency graph for pnp.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NDEBUG_USBPORT_CORE
 

Functions

NTSTATUS NTAPI USBPORT_FdoStartCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI USBPORT_RegisterDeviceInterface (IN PDEVICE_OBJECT PdoDevice, IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceClassGuid, IN BOOLEAN Enable)
 
BOOLEAN NTAPI USBPORT_IsSelectiveSuspendEnabled (IN PDEVICE_OBJECT FdoDevice)
 
NTSTATUS NTAPI USBPORT_GetConfigValue (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
NTSTATUS NTAPI USBPORT_GetDefaultBIOSx (IN PDEVICE_OBJECT FdoDevice, IN PULONG UsbBIOSx, IN PULONG DisableSelectiveSuspend, IN PULONG DisableCcDetect, IN PULONG IdleEpSupport, IN PULONG IdleEpSupportEx, IN PULONG SoftRetry)
 
NTSTATUS NTAPI USBPORT_IsCompanionController (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN *IsCompanion)
 
NTSTATUS NTAPI USBPORT_QueryPciBusInterface (IN PDEVICE_OBJECT FdoDevice)
 
NTSTATUS NTAPI USBPORT_QueryCapabilities (IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_CAPABILITIES Capabilities)
 
NTSTATUS NTAPI USBPORT_CreateLegacySymbolicLink (IN PDEVICE_OBJECT FdoDevice)
 
NTSTATUS NTAPI USBPORT_StopDevice (IN PDEVICE_OBJECT FdoDevice)
 
NTSTATUS NTAPI USBPORT_StartDevice (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_RESOURCES UsbPortResources)
 
NTSTATUS NTAPI USBPORT_ParseResources (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PUSBPORT_RESOURCES UsbPortResources)
 
NTSTATUS NTAPI USBPORT_CreatePdo (IN PDEVICE_OBJECT FdoDevice, OUT PDEVICE_OBJECT *RootHubPdo)
 
NTSTATUS NTAPI USBPORT_FdoPnP (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
PVOID NTAPI USBPORT_GetDeviceHwIds (IN PDEVICE_OBJECT FdoDevice, IN USHORT VendorID, IN USHORT DeviceID, IN USHORT RevisionID)
 
NTSTATUS NTAPI USBPORT_PdoPnP (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 

Variables

IO_COMPLETION_ROUTINE USBPORT_FdoStartCompletion
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file pnp.c.

◆ NDEBUG_USBPORT_CORE

#define NDEBUG_USBPORT_CORE

Definition at line 13 of file pnp.c.

Function Documentation

◆ USBPORT_CreateLegacySymbolicLink()

NTSTATUS NTAPI USBPORT_CreateLegacySymbolicLink ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 449 of file pnp.c.

450 {
452  WCHAR CharName[255] = {0};
453  WCHAR CharDosName[255] = {0};
456 
457  FdoExtension = FdoDevice->DeviceExtension;
458 
459  RtlStringCbPrintfW(CharName,
460  sizeof(CharName),
461  L"\\Device\\USBFDO-%d",
462  FdoExtension->FdoNameNumber);
463 
464  RtlInitUnicodeString(&DeviceName, CharName);
465 
466  RtlStringCbPrintfW(CharDosName,
467  sizeof(CharDosName),
468  L"\\DosDevices\\HCD%d",
469  FdoExtension->FdoNameNumber);
470 
471  RtlInitUnicodeString(&FdoExtension->DosDeviceSymbolicName, CharDosName);
472 
473  DPRINT("USBPORT_CreateLegacySymbolicLink: DeviceName - %wZ, DosSymbolicName - %wZ\n",
474  &DeviceName,
475  &FdoExtension->DosDeviceSymbolicName);
476 
477  Status = IoCreateSymbolicLink(&FdoExtension->DosDeviceSymbolicName,
478  &DeviceName);
479 
480  if (NT_SUCCESS(Status))
481  {
483  }
484 
485  return Status;
486 }
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
static const WCHAR L[]
Definition: oid.c:1250
#define USBPORT_FLAG_DOS_SYMBOLIC_NAME
Definition: usbport.h:73
Status
Definition: gdiplustypes.h:24
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by USBPORT_StartDevice().

◆ USBPORT_CreatePdo()

NTSTATUS NTAPI USBPORT_CreatePdo ( IN PDEVICE_OBJECT  FdoDevice,
OUT PDEVICE_OBJECT RootHubPdo 
)

Definition at line 1028 of file pnp.c.

1030 {
1034  ULONG DeviceNumber = 0;
1036  WCHAR CharDeviceName[64];
1038 
1039  DPRINT("USBPORT_CreatePdo: FdoDevice - %p, RootHubPdo - %p\n",
1040  FdoDevice,
1041  RootHubPdo);
1042 
1043  FdoExtension = FdoDevice->DeviceExtension;
1044 
1045  do
1046  {
1047  RtlStringCbPrintfW(CharDeviceName,
1048  sizeof(CharDeviceName),
1049  L"\\Device\\USBPDO-%d",
1050  DeviceNumber);
1051 
1052  RtlInitUnicodeString(&DeviceName, CharDeviceName);
1053 
1054  DPRINT("USBPORT_CreatePdo: DeviceName - %wZ\n", &DeviceName);
1055 
1056  Status = IoCreateDevice(FdoExtension->MiniPortInterface->DriverObject,
1058  &DeviceName,
1060  0,
1061  FALSE,
1062  &DeviceObject);
1063 
1064  ++DeviceNumber;
1065  }
1067 
1068  if (!NT_SUCCESS(Status))
1069  {
1070  *RootHubPdo = NULL;
1071  DPRINT1("USBPORT_CreatePdo: Filed create HubPdo!\n");
1072  return Status;
1073  }
1074 
1075  if (DeviceObject)
1076  {
1078 
1080 
1081  PdoExtension->CommonExtension.SelfDevice = DeviceObject;
1082  PdoExtension->CommonExtension.IsPDO = TRUE;
1083 
1084  PdoExtension->FdoDevice = FdoDevice;
1085  PdoExtension->PdoNameNumber = DeviceNumber;
1086 
1088 
1089  DeviceObject->StackSize = FdoDevice->StackSize;
1090 
1093  }
1094  else
1095  {
1097  }
1098 
1099  if (!NT_SUCCESS(Status))
1100  *RootHubPdo = NULL;
1101  else
1102  *RootHubPdo = DeviceObject;
1103 
1104  DPRINT("USBPORT_CreatePdo: HubPdo - %p\n", DeviceObject);
1105  return Status;
1106 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define DO_POWER_PAGABLE
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
VOID NTAPI USBPORT_AdjustDeviceCapabilities(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
Definition: power.c:668
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DPRINT1
Definition: precomp.h:8
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
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147

Referenced by USBPORT_FdoPnP().

◆ USBPORT_FdoPnP()

NTSTATUS NTAPI USBPORT_FdoPnP ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 1110 of file pnp.c.

1112 {
1114  PUSBPORT_COMMON_DEVICE_EXTENSION FdoCommonExtension;
1116  PUSBPORT_RESOURCES UsbPortResources;
1117  PIO_STACK_LOCATION IoStack;
1118  UCHAR Minor;
1119  KEVENT Event;
1120  NTSTATUS Status;
1121  DEVICE_RELATION_TYPE RelationType;
1122  PDEVICE_RELATIONS DeviceRelations;
1123  PDEVICE_OBJECT RootHubPdo;
1124 
1125  FdoExtension = FdoDevice->DeviceExtension;
1126  FdoCommonExtension = &FdoExtension->CommonExtension;
1127  UsbPortResources = &FdoExtension->UsbPortResources;
1128  Packet = &FdoExtension->MiniPortInterface->Packet;
1129 
1130  IoStack = IoGetCurrentIrpStackLocation(Irp);
1131  Minor = IoStack->MinorFunction;
1132 
1133  DPRINT("USBPORT_FdoPnP: FdoDevice - %p, Minor - %x\n", FdoDevice, Minor);
1134 
1135  RelationType = IoStack->Parameters.QueryDeviceRelations.Type;
1136 
1137  switch (Minor)
1138  {
1139  case IRP_MN_START_DEVICE:
1140  DPRINT("IRP_MN_START_DEVICE\n");
1141 
1143 
1145 
1148  &Event,
1149  TRUE,
1150  TRUE,
1151  TRUE);
1152 
1153  Status = IoCallDriver(FdoCommonExtension->LowerDevice,
1154  Irp);
1155 
1156  if (Status == STATUS_PENDING)
1157  {
1159  Suspended,
1160  KernelMode,
1161  FALSE,
1162  NULL);
1163 
1164  Status = Irp->IoStatus.Status;
1165  }
1166 
1167  if (!NT_SUCCESS(Status))
1168  {
1169  goto Exit;
1170  }
1171 
1172  Status = USBPORT_ParseResources(FdoDevice,
1173  Irp,
1174  UsbPortResources);
1175 
1176  if (!NT_SUCCESS(Status))
1177  {
1178  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STOPPED;
1179  goto Exit;
1180  }
1181 
1182  Status = USBPORT_StartDevice(FdoDevice, UsbPortResources);
1183 
1184  if (!NT_SUCCESS(Status))
1185  {
1186  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STOPPED;
1187  goto Exit;
1188  }
1189 
1190  FdoCommonExtension->PnpStateFlags &= ~USBPORT_PNP_STATE_NOT_INIT;
1191  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STARTED;
1192 
1193  FdoCommonExtension->DevicePowerState = PowerDeviceD0;
1194 
1195  if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1196  {
1197  USBPORT_AddUSB2Fdo(FdoDevice);
1198  }
1199  else
1200  {
1201  USBPORT_AddUSB1Fdo(FdoDevice);
1202  }
1203 
1204 Exit:
1205  Irp->IoStatus.Status = Status;
1207  return Status;
1208 
1210  DPRINT("IRP_MN_QUERY_REMOVE_DEVICE\n");
1211  if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1212  {
1213  DPRINT1("USBPORT_FdoPnP: Haction registry write FIXME\n");
1214  }
1215 
1216  Irp->IoStatus.Status = STATUS_SUCCESS;
1217  goto ForwardIrp;
1218 
1219  case IRP_MN_REMOVE_DEVICE:
1220  DPRINT("USBPORT_FdoPnP: IRP_MN_REMOVE_DEVICE\n");
1221  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_FAILED;
1222 
1223  if (FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_STARTED &&
1224  !(FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_NOT_INIT))
1225  {
1226  DPRINT1("USBPORT_FdoPnP: stop fdo FIXME\n");
1227  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_NOT_INIT;
1228  }
1229 
1230  Irp->IoStatus.Status = STATUS_SUCCESS;
1232  Status = IoCallDriver(FdoCommonExtension->LowerDevice, Irp);
1233 
1234  IoDetachDevice(FdoCommonExtension->LowerDevice);
1235 
1236  RootHubPdo = FdoExtension->RootHubPdo;
1237 
1238  IoDeleteDevice(FdoDevice);
1239 
1240  if (RootHubPdo)
1241  {
1242  IoDeleteDevice(RootHubPdo);
1243  }
1244 
1245  return Status;
1246 
1248  DPRINT("IRP_MN_CANCEL_REMOVE_DEVICE\n");
1249  Irp->IoStatus.Status = STATUS_SUCCESS;
1250  goto ForwardIrp;
1251 
1252  case IRP_MN_STOP_DEVICE:
1253  DPRINT("IRP_MN_STOP_DEVICE\n");
1254  if (FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_STARTED)
1255  {
1256  DPRINT1("USBPORT_FdoPnP: stop fdo FIXME\n");
1257 
1258  FdoCommonExtension->PnpStateFlags &= ~USBPORT_PNP_STATE_STARTED;
1259  FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_NOT_INIT;
1260  }
1261 
1262  Irp->IoStatus.Status = STATUS_SUCCESS;
1263  goto ForwardIrp;
1264 
1266  DPRINT("IRP_MN_QUERY_STOP_DEVICE\n");
1267  Irp->IoStatus.Status = STATUS_SUCCESS;
1268  goto ForwardIrp;
1269 
1271  DPRINT("IRP_MN_CANCEL_STOP_DEVICE\n");
1272  Irp->IoStatus.Status = STATUS_SUCCESS;
1273  goto ForwardIrp;
1274 
1276  DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n");
1277  if (RelationType == BusRelations)
1278  {
1279  DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1280  sizeof(DEVICE_RELATIONS),
1281  USB_PORT_TAG);
1282 
1283  if (!DeviceRelations)
1284  {
1286  Irp->IoStatus.Status = Status;
1288  return Status;
1289  }
1290 
1291  DeviceRelations->Count = 0;
1292  DeviceRelations->Objects[0] = NULL;
1293 
1294  if (!FdoExtension->RootHubPdo)
1295  {
1296  Status = USBPORT_CreatePdo(FdoDevice,
1297  &FdoExtension->RootHubPdo);
1298 
1299  if (!NT_SUCCESS(Status))
1300  {
1301  ExFreePoolWithTag(DeviceRelations, USB_PORT_TAG);
1302  goto ForwardIrp;
1303  }
1304  }
1305  else
1306  {
1308  }
1309 
1310  DeviceRelations->Count = 1;
1311  DeviceRelations->Objects[0] = FdoExtension->RootHubPdo;
1312 
1313  ObReferenceObject(FdoExtension->RootHubPdo);
1314  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1315  }
1316  else
1317  {
1318  if (RelationType == RemovalRelations)
1319  {
1320  DPRINT1("USBPORT_FdoPnP: FIXME IRP_MN_QUERY_DEVICE_RELATIONS/RemovalRelations\n");
1321  }
1322 
1323  goto ForwardIrp;
1324  }
1325 
1326  Irp->IoStatus.Status = Status;
1327  goto ForwardIrp;
1328 
1330  DPRINT("IRP_MN_QUERY_INTERFACE\n");
1331  goto ForwardIrp;
1332 
1334  DPRINT("IRP_MN_QUERY_CAPABILITIES\n");
1335  goto ForwardIrp;
1336 
1338  DPRINT("IRP_MN_QUERY_RESOURCES\n");
1339  goto ForwardIrp;
1340 
1342  DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
1343  goto ForwardIrp;
1344 
1346  DPRINT("IRP_MN_QUERY_DEVICE_TEXT\n");
1347  goto ForwardIrp;
1348 
1350  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1351  goto ForwardIrp;
1352 
1353  case IRP_MN_READ_CONFIG:
1354  DPRINT("IRP_MN_READ_CONFIG\n");
1355  goto ForwardIrp;
1356 
1357  case IRP_MN_WRITE_CONFIG:
1358  DPRINT("IRP_MN_WRITE_CONFIG\n");
1359  goto ForwardIrp;
1360 
1361  case IRP_MN_EJECT:
1362  DPRINT("IRP_MN_EJECT\n");
1363  goto ForwardIrp;
1364 
1365  case IRP_MN_SET_LOCK:
1366  DPRINT("IRP_MN_SET_LOCK\n");
1367  goto ForwardIrp;
1368 
1369  case IRP_MN_QUERY_ID:
1370  DPRINT("IRP_MN_QUERY_ID\n");
1371  goto ForwardIrp;
1372 
1374  DPRINT("IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1375  goto ForwardIrp;
1376 
1378  DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
1379  goto ForwardIrp;
1380 
1382  DPRINT("IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1383  goto ForwardIrp;
1384 
1386  DPRINT1("IRP_MN_SURPRISE_REMOVAL\n");
1387  if (!(FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_FAILED))
1388  {
1391  }
1392  goto ForwardIrp;
1393 
1394  default:
1395  DPRINT("unknown IRP_MN_???\n");
1396 ForwardIrp:
1397  /* forward irp to next device object */
1399  break;
1400  }
1401 
1402  return IoCallDriver(FdoCommonExtension->LowerDevice, Irp);
1403 }
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define TRUE
Definition: types.h:120
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_WRITE_CONFIG
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
#define USBPORT_INVALIDATE_CONTROLLER_SURPRISE_REMOVE
Definition: usbmport.h:490
#define IRP_MN_EJECT
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
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define USB_PORT_TAG
Definition: usbport.h:44
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
VOID NTAPI USBPORT_InvalidateControllerHandler(IN PDEVICE_OBJECT FdoDevice, IN ULONG Type)
Definition: usbport.c:635
#define USBPORT_PNP_STATE_FAILED
Definition: usbport.h:88
#define IRP_MN_QUERY_REMOVE_DEVICE
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define USBPORT_PNP_STATE_STOPPED
Definition: usbport.h:89
NTSTATUS NTAPI USBPORT_CreatePdo(IN PDEVICE_OBJECT FdoDevice, OUT PDEVICE_OBJECT *RootHubPdo)
Definition: pnp.c:1028
#define IRP_MN_READ_CONFIG
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static void Exit(void)
Definition: sock.c:1331
#define IRP_MN_START_DEVICE
VOID NTAPI USBPORT_AddUSB2Fdo(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:82
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IRP_MN_QUERY_BUS_INFORMATION
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSTATUS NTAPI USBPORT_StartDevice(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_RESOURCES UsbPortResources)
Definition: pnp.c:499
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
IO_COMPLETION_ROUTINE USBPORT_FdoStartCompletion
Definition: pnp.c:16
DEVICE_POWER_STATE DevicePowerState
Definition: usbport.h:286
#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
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS NTAPI USBPORT_ParseResources(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PUSBPORT_RESOURCES UsbPortResources)
Definition: pnp.c:912
#define USBPORT_PNP_STATE_NOT_INIT
Definition: usbport.h:86
#define DPRINT1
Definition: precomp.h:8
#define ObReferenceObject
Definition: obfuncs.h:204
#define IRP_MN_SET_LOCK
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI USBPORT_AddUSB1Fdo(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:66
#define IRP_MN_CANCEL_STOP_DEVICE
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define USBPORT_PNP_STATE_STARTED
Definition: usbport.h:87
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES

Referenced by USBPORT_Dispatch().

◆ USBPORT_FdoStartCompletion()

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

Definition at line 20 of file pnp.c.

23 {
26 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define EVENT_INCREMENT
Definition: iotypes.h:565

◆ USBPORT_GetConfigValue()

NTSTATUS NTAPI USBPORT_GetConfigValue ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)

Definition at line 110 of file pnp.c.

116 {
118 
119  DPRINT("USBPORT_GetConfigValue \n");
120 
121  if (ValueType == REG_DWORD)
122  {
124  }
125  else
126  {
128  }
129 
130  return Status;
131 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
LONG NTSTATUS
Definition: precomp.h:26
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4004
void DPRINT(...)
Definition: polytest.cpp:61
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by USBPORT_GetDefaultBIOSx().

◆ USBPORT_GetDefaultBIOSx()

NTSTATUS NTAPI USBPORT_GetDefaultBIOSx ( IN PDEVICE_OBJECT  FdoDevice,
IN PULONG  UsbBIOSx,
IN PULONG  DisableSelectiveSuspend,
IN PULONG  DisableCcDetect,
IN PULONG  IdleEpSupport,
IN PULONG  IdleEpSupportEx,
IN PULONG  SoftRetry 
)

Definition at line 135 of file pnp.c.

142 {
144 
145  DPRINT("USBPORT_GetDefaultBIOS_X: ... \n");
146 
148 
149  *UsbBIOSx = 2;
150 
152  QueryTable[0].Flags = 0;
153  QueryTable[0].Name = L"UsbBIOSx";
154  QueryTable[0].EntryContext = UsbBIOSx;
156  QueryTable[0].DefaultData = UsbBIOSx;
157  QueryTable[0].DefaultLength = sizeof(ULONG);
158 
160  QueryTable[1].Flags = 0;
161  QueryTable[1].Name = L"DisableSelectiveSuspend";
162  QueryTable[1].EntryContext = DisableSelectiveSuspend;
164  QueryTable[1].DefaultData = DisableSelectiveSuspend;
165  QueryTable[1].DefaultLength = sizeof(ULONG);
166 
168  QueryTable[2].Flags = 0;
169  QueryTable[2].Name = L"DisableCcDetect";
170  QueryTable[2].EntryContext = DisableCcDetect;
172  QueryTable[2].DefaultData = DisableCcDetect;
173  QueryTable[2].DefaultLength = sizeof(ULONG);
174 
176  QueryTable[3].Flags = 0;
177  QueryTable[3].Name = L"EnIdleEndpointSupport";
178  QueryTable[3].EntryContext = IdleEpSupport;
180  QueryTable[3].DefaultData = IdleEpSupport;
181  QueryTable[3].DefaultLength = sizeof(ULONG);
182 
184  QueryTable[4].Flags = 0;
185  QueryTable[4].Name = L"EnIdleEndpointSupportEx";
186  QueryTable[4].EntryContext = IdleEpSupportEx;
188  QueryTable[4].DefaultData = IdleEpSupportEx;
189  QueryTable[4].DefaultLength = sizeof(ULONG);
190 
192  QueryTable[5].Flags = 0;
193  QueryTable[5].Name = L"EnSoftRetry";
194  QueryTable[5].EntryContext = SoftRetry;
196  QueryTable[5].DefaultData = SoftRetry;
197  QueryTable[5].DefaultLength = sizeof(ULONG);
198 
200  L"usb",
201  QueryTable,
202  NULL,
203  NULL);
204 }
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4004
#define RTL_REGISTRY_SERVICES
Definition: nt_native.h:162
NTSTATUS NTAPI USBPORT_GetConfigValue(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: pnp.c:110
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
static const WCHAR L[]
Definition: oid.c:1250
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by USBPORT_StartDevice().

◆ USBPORT_GetDeviceHwIds()

PVOID NTAPI USBPORT_GetDeviceHwIds ( IN PDEVICE_OBJECT  FdoDevice,
IN USHORT  VendorID,
IN USHORT  DeviceID,
IN USHORT  RevisionID 
)

Definition at line 1407 of file pnp.c.

1411 {
1414  PVOID Id;
1415  WCHAR Buffer[300] = {0};
1416  SIZE_T Length = 0;
1417  size_t Remaining = sizeof(Buffer);
1418  PWCHAR EndBuffer;
1419 
1420  FdoExtension = FdoDevice->DeviceExtension;
1421  Packet = &FdoExtension->MiniPortInterface->Packet;
1422 
1423  DPRINT("USBPORT_GetDeviceHwIds: FdoDevice - %p, Packet->MiniPortFlags - %p\n",
1424  FdoDevice,
1425  Packet->MiniPortFlags);
1426 
1427  if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1428  {
1430  Remaining,
1431  &EndBuffer,
1432  &Remaining,
1433  0,
1434  L"USB\\ROOT_HUB20&VID%04x&PID%04x&REV%04x",
1435  VendorID,
1436  DeviceID,
1437  RevisionID);
1438 
1439  EndBuffer++;
1440  Remaining -= sizeof(UNICODE_NULL);
1441 
1442  RtlStringCbPrintfExW(EndBuffer,
1443  Remaining,
1444  &EndBuffer,
1445  &Remaining,
1446  0,
1447  L"USB\\ROOT_HUB20&VID%04x&PID%04x",
1448  VendorID,
1449  DeviceID);
1450 
1451  EndBuffer++;
1452  Remaining -= sizeof(UNICODE_NULL);
1453 
1454  RtlStringCbPrintfExW(EndBuffer,
1455  Remaining,
1456  NULL,
1457  &Remaining,
1458  0,
1459  L"USB\\ROOT_HUB20");
1460  }
1461  else
1462  {
1464  Remaining,
1465  &EndBuffer,
1466  &Remaining,
1467  0,
1468  L"USB\\ROOT_HUB&VID%04x&PID%04x&REV%04x",
1469  VendorID,
1470  DeviceID,
1471  RevisionID);
1472 
1473  EndBuffer++;
1474  Remaining -= sizeof(UNICODE_NULL);
1475 
1476  RtlStringCbPrintfExW(EndBuffer,
1477  Remaining,
1478  &EndBuffer,
1479  &Remaining,
1480  0,
1481  L"USB\\ROOT_HUB&VID%04x&PID%04x",
1482  VendorID,
1483  DeviceID);
1484 
1485  EndBuffer++;
1486  Remaining -= sizeof(UNICODE_NULL);
1487 
1488  RtlStringCbPrintfExW(EndBuffer,
1489  Remaining,
1490  NULL,
1491  &Remaining,
1492  0,
1493  L"USB\\ROOT_HUB");
1494  }
1495 
1496  Length = (sizeof(Buffer) - Remaining + 2 * sizeof(UNICODE_NULL));
1497 
1498  /* for debug only */
1499  if (FALSE)
1500  {
1501  DPRINT("Hardware IDs:\n");
1503  }
1504 
1506 
1507  if (!Id)
1508  return NULL;
1509 
1511 
1512  return Id;
1513 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
_In_ USHORT DeviceID
Definition: iotypes.h:860
NTSTRSAFEVAPI RtlStringCbPrintfExW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _Outptr_opt_result_bytebuffer_(*pcbRemaining) NTSTRSAFE_PWSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1335
uint16_t * PWCHAR
Definition: typedefs.h:54
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
DWORD Id
#define USB_PORT_TAG
Definition: usbport.h:44
_In_ USHORT _In_ UCHAR RevisionID
Definition: iotypes.h:860
#define UNICODE_NULL
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI USBPORT_DumpingIDs(IN PVOID Buffer)
Definition: debug.c:258
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
ULONG_PTR SIZE_T
Definition: typedefs.h:78
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by USBPORT_PdoPnP().

◆ USBPORT_IsCompanionController()

NTSTATUS NTAPI USBPORT_IsCompanionController ( IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN IsCompanion 
)

Definition at line 208 of file pnp.c.

210 {
211  PDEVICE_OBJECT HighestDevice;
212  PIRP Irp;
213  KEVENT Event;
214  PIO_STACK_LOCATION IoStack;
215  PCI_DEVICE_PRESENT_INTERFACE PciInterface = {0};
219  BOOLEAN IsPresent;
220 
221  DPRINT("USBPORT_IsCompanionController: ... \n");
222 
223  *IsCompanion = FALSE;
224 
226 
228 
230  HighestDevice,
231  NULL,
232  0,
233  NULL,
234  &Event,
235  &IoStatusBlock);
236 
237  if (!Irp)
238  {
240  ObDereferenceObject(HighestDevice);
241  return Status;
242  }
243 
244  IoStack = IoGetNextIrpStackLocation(Irp);
245 
246  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
247  Irp->IoStatus.Information = 0;
248 
250 
251  IoStack->Parameters.QueryInterface.InterfaceType = &GUID_PCI_DEVICE_PRESENT_INTERFACE;
253  IoStack->Parameters.QueryInterface.Version = 1;
254  IoStack->Parameters.QueryInterface.Interface = (PINTERFACE)&PciInterface;
255  IoStack->Parameters.QueryInterface.InterfaceSpecificData = 0;
256 
257  Status = IoCallDriver(HighestDevice, Irp);
258 
259  if (Status == STATUS_PENDING)
260  {
263  }
264 
265  if (!NT_SUCCESS(Status))
266  {
267  DPRINT1("USBPORT_IsCompanionController: query interface failed\\n");
268  ObDereferenceObject(HighestDevice);
269  return Status;
270  }
271 
272  DPRINT("USBPORT_IsCompanionController: query interface succeeded\n");
273 
274  if (PciInterface.Size < sizeof(PCI_DEVICE_PRESENT_INTERFACE))
275  {
276  DPRINT1("USBPORT_IsCompanionController: old version\n");
277  ObDereferenceObject(HighestDevice);
278  return Status;
279  }
280 
282 
286 
291 
292  IsPresent = (PciInterface.IsDevicePresentEx)(PciInterface.Context,
293  &Parameters);
294 
295  if (IsPresent)
296  {
297  DPRINT("USBPORT_IsCompanionController: Present EHCI controller for FDO - %p\n",
298  DeviceObject);
299  }
300  else
301  {
302  DPRINT("USBPORT_IsCompanionController: No EHCI controller for FDO - %p\n",
303  DeviceObject);
304  }
305 
306  *IsCompanion = IsPresent;
307 
308  (PciInterface.InterfaceDereference)(PciInterface.Context);
309 
310  ObDereferenceObject(HighestDevice);
311 
312  return Status;
313 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_CLASS_SERIAL_BUS_CTLR
Definition: iotypes.h:3759
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
#define PCI_SUBCLASS_SB_USB
Definition: iotypes.h:3851
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
struct _PCI_DEVICE_PRESENT_INTERFACE PCI_DEVICE_PRESENT_INTERFACE
#define PCI_USE_PROGIF
Definition: iotypes.h:838
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
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _INTERFACE * PINTERFACE
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx
Definition: iotypes.h:894
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:892
#define PCI_USE_LOCAL_DEVICE
Definition: iotypes.h:840
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_QUERY_INTERFACE
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define PCI_INTERFACE_USB_ID_EHCI
Definition: usbport.h:25
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PCI_USE_LOCAL_BUS
Definition: iotypes.h:839
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define DPRINT1
Definition: precomp.h:8
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define PCI_USE_CLASS_SUBCLASS
Definition: iotypes.h:837

Referenced by USBPORT_StartDevice().

◆ USBPORT_IsSelectiveSuspendEnabled()

BOOLEAN NTAPI USBPORT_IsSelectiveSuspendEnabled ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 88 of file pnp.c.

89 {
91  ULONG Disabled = 0;
92 
93  DPRINT("USBPORT_IsSelectiveSuspendEnabled: ... \n");
94 
95  FdoExtension = FdoDevice->DeviceExtension;
96 
98  FdoExtension->CommonExtension.LowerPdoDevice,
99  TRUE,
100  L"HcDisableSelectiveSuspend",
101  sizeof(L"HcDisableSelectiveSuspend"),
102  &Disabled,
103  sizeof(Disabled));
104 
105  return (Disabled == 0);
106 }
#define TRUE
Definition: types.h:120
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI USBPORT_GetRegistryKeyValueFullInfo(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN BOOL UseDriverKey, IN PCWSTR SourceString, IN ULONG LengthStr, IN PVOID Buffer, IN ULONG BufferLength)
Definition: usbport.c:296
static const WCHAR L[]
Definition: oid.c:1250
unsigned int ULONG
Definition: retypes.h:1

Referenced by USBPORT_StartDevice().

◆ USBPORT_ParseResources()

NTSTATUS NTAPI USBPORT_ParseResources ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp,
IN PUSBPORT_RESOURCES  UsbPortResources 
)

Definition at line 912 of file pnp.c.

915 {
918  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
919  PCM_PARTIAL_RESOURCE_DESCRIPTOR PortDescriptor = NULL;
921  PCM_PARTIAL_RESOURCE_DESCRIPTOR InterruptDescriptor = NULL;
922  PIO_STACK_LOCATION IoStack;
923  ULONG ix;
925 
926  DPRINT("USBPORT_ParseResources: ... \n");
927 
929  AllocatedResourcesTranslated = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
930 
932  {
933  RtlZeroMemory(UsbPortResources, sizeof(USBPORT_RESOURCES));
934 
935  ResourceList = &AllocatedResourcesTranslated->List[0].PartialResourceList;
936 
937  PartialDescriptor = &ResourceList->PartialDescriptors[0];
938 
939  for (ix = 0; ix < ResourceList->Count; ++ix)
940  {
941  if (PartialDescriptor->Type == CmResourceTypePort)
942  {
943  if (!PortDescriptor)
944  PortDescriptor = PartialDescriptor;
945  }
946  else if (PartialDescriptor->Type == CmResourceTypeInterrupt)
947  {
948  if (!InterruptDescriptor)
949  InterruptDescriptor = PartialDescriptor;
950  }
951  else if (PartialDescriptor->Type == CmResourceTypeMemory)
952  {
953  if (!MemoryDescriptor)
954  MemoryDescriptor = PartialDescriptor;
955  }
956 
957  PartialDescriptor += 1;
958  }
959 
960  if (PortDescriptor)
961  {
962  if (PortDescriptor->Flags & CM_RESOURCE_PORT_IO)
963  {
964  UsbPortResources->ResourceBase = (PVOID)(ULONG_PTR)PortDescriptor->u.Port.Start.QuadPart;
965  }
966  else
967  {
968  UsbPortResources->ResourceBase = MmMapIoSpace(PortDescriptor->u.Port.Start,
969  PortDescriptor->u.Port.Length,
970  0);
971  }
972 
973  UsbPortResources->IoSpaceLength = PortDescriptor->u.Port.Length;
974 
975  if (UsbPortResources->ResourceBase)
976  {
977  UsbPortResources->ResourcesTypes |= USBPORT_RESOURCES_PORT;
978  }
979  else
980  {
982  }
983  }
984 
986  {
987  UsbPortResources->IoSpaceLength = MemoryDescriptor->u.Memory.Length;
988 
989  UsbPortResources->ResourceBase = MmMapIoSpace(MemoryDescriptor->u.Memory.Start,
990  MemoryDescriptor->u.Memory.Length,
991  0);
992 
993  if (UsbPortResources->ResourceBase)
994  {
995  UsbPortResources->ResourcesTypes |= USBPORT_RESOURCES_MEMORY;
996  }
997  else
998  {
1000  }
1001  }
1002 
1003  if (InterruptDescriptor && NT_SUCCESS(Status))
1004  {
1005  UsbPortResources->ResourcesTypes |= USBPORT_RESOURCES_INTERRUPT;
1006 
1007  UsbPortResources->InterruptVector = InterruptDescriptor->u.Interrupt.Vector;
1008  UsbPortResources->InterruptLevel = InterruptDescriptor->u.Interrupt.Level;
1009  UsbPortResources->InterruptAffinity = InterruptDescriptor->u.Interrupt.Affinity;
1010 
1011  UsbPortResources->ShareVector = InterruptDescriptor->ShareDisposition ==
1013 
1014  UsbPortResources->InterruptMode = InterruptDescriptor->Flags ==
1016  }
1017  }
1018  else
1019  {
1021  }
1022 
1023  return Status;
1024 }
_Out_ PNDIS_BUFFER _In_ NDIS_HANDLE _In_ PVOID MemoryDescriptor
Definition: ndis.h:3270
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define STATUS_NONE_MAPPED
Definition: ntstatus.h:337
uint32_t ULONG_PTR
Definition: typedefs.h:63
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
#define USBPORT_RESOURCES_MEMORY
Definition: usbmport.h:42
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResourcesTranslated
Definition: ndis.h:4640
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
#define USBPORT_RESOURCES_INTERRUPT
Definition: usbmport.h:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define USBPORT_RESOURCES_PORT
Definition: usbmport.h:40
Status
Definition: gdiplustypes.h:24
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@378 Port
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@379 Interrupt
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by USBPORT_FdoPnP().

◆ USBPORT_PdoPnP()

NTSTATUS NTAPI USBPORT_PdoPnP ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 1517 of file pnp.c.

1519 {
1521  PUSBPORT_COMMON_DEVICE_EXTENSION PdoCommonExtension;
1522  PDEVICE_OBJECT FdoDevice;
1524  PIO_STACK_LOCATION IoStack;
1525  UCHAR Minor;
1526  NTSTATUS Status;
1527  PPNP_BUS_INFORMATION BusInformation;
1529 
1530  PdoExtension = PdoDevice->DeviceExtension;
1531  PdoCommonExtension = &PdoExtension->CommonExtension;
1532 
1533  FdoDevice = PdoExtension->FdoDevice;
1534  FdoExtension = FdoDevice->DeviceExtension;
1535 
1536  IoStack = IoGetCurrentIrpStackLocation(Irp);
1537  Minor = IoStack->MinorFunction;
1538 
1539  Status = Irp->IoStatus.Status;
1540 
1541  DPRINT("USBPORT_PdoPnP: PdoDevice - %p, Minor - %x\n", PdoDevice, Minor);
1542 
1543  switch (Minor)
1544  {
1545  case IRP_MN_START_DEVICE:
1546  DPRINT("IRP_MN_START_DEVICE\n");
1547 
1548  Status = USBPORT_RootHubCreateDevice(FdoDevice, PdoDevice);
1549 
1550  if (NT_SUCCESS(Status))
1551  {
1553  PdoDevice,
1554  &GUID_DEVINTERFACE_USB_HUB,
1555  TRUE);
1556 
1557  if (NT_SUCCESS(Status))
1558  {
1559  PdoCommonExtension->DevicePowerState = PowerDeviceD0;
1560  PdoCommonExtension->PnpStateFlags = USBPORT_PNP_STATE_STARTED;
1561  }
1562  }
1563 
1564  break;
1565 
1567  DPRINT("USBPORT_PdoPnP: IRP_MN_QUERY_REMOVE_DEVICE\n");
1569  break;
1570 
1571  case IRP_MN_REMOVE_DEVICE:
1572  DPRINT1("USBPORT_PdoPnP: IRP_MN_REMOVE_DEVICE UNIMPLEMENTED. FIXME. \n");
1573  //USBPORT_StopRootHub();
1575  break;
1576 
1578  DPRINT("IRP_MN_CANCEL_REMOVE_DEVICE\n");
1580  break;
1581 
1582  case IRP_MN_STOP_DEVICE:
1583  DPRINT1("USBPORT_PdoPnP: IRP_MN_STOP_DEVICE UNIMPLEMENTED. FIXME. \n");
1584  //USBPORT_StopRootHub();
1586  break;
1587 
1589  DPRINT("IRP_MN_QUERY_STOP_DEVICE\n");
1591  break;
1592 
1594  DPRINT("IRP_MN_CANCEL_STOP_DEVICE\n");
1596  break;
1597 
1599  {
1600  PDEVICE_RELATIONS DeviceRelations;
1601 
1602  DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n");
1603  if (IoStack->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
1604  {
1605  break;
1606  }
1607 
1608  DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1609  sizeof(DEVICE_RELATIONS),
1610  USB_PORT_TAG);
1611 
1612  if (!DeviceRelations)
1613  {
1615  Irp->IoStatus.Information = 0;
1616  break;
1617  }
1618 
1619  DeviceRelations->Count = 1;
1620  DeviceRelations->Objects[0] = PdoDevice;
1621 
1622  ObReferenceObject(PdoDevice);
1623 
1625  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1626  break;
1627  }
1628 
1630  DPRINT("IRP_MN_QUERY_INTERFACE\n");
1631  Status = USBPORT_PdoQueryInterface(FdoDevice, PdoDevice, Irp);
1632  break;
1633 
1635  DPRINT("IRP_MN_QUERY_CAPABILITIES\n");
1636 
1637  DeviceCapabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
1638 
1640  &PdoExtension->Capabilities,
1641  sizeof(DEVICE_CAPABILITIES));
1642 
1644  break;
1645 
1647  DPRINT("USBPORT_PdoPnP: IRP_MN_QUERY_RESOURCES\n");
1648  break;
1649 
1651  DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
1652  break;
1653 
1655  DPRINT("IRP_MN_QUERY_DEVICE_TEXT\n");
1656  break;
1657 
1659  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1660  break;
1661 
1662  case IRP_MN_READ_CONFIG:
1663  DPRINT("IRP_MN_READ_CONFIG\n");
1664  ASSERT(FALSE);
1665  break;
1666 
1667  case IRP_MN_WRITE_CONFIG:
1668  DPRINT("IRP_MN_WRITE_CONFIG\n");
1669  ASSERT(FALSE);
1670  break;
1671 
1672  case IRP_MN_EJECT:
1673  DPRINT("IRP_MN_EJECT\n");
1674  ASSERT(FALSE);
1675  break;
1676 
1677  case IRP_MN_SET_LOCK:
1678  DPRINT("IRP_MN_SET_LOCK\n");
1679  ASSERT(FALSE);
1680  break;
1681 
1682  case IRP_MN_QUERY_ID:
1683  {
1684  ULONG IdType;
1685  LONG Length;
1686  WCHAR Buffer[64] = {0};
1687  PVOID Id;
1688 
1690  IdType = IoStack->Parameters.QueryId.IdType;
1691 
1692  DPRINT("IRP_MN_QUERY_ID/Type %x\n", IdType);
1693 
1694  if (IdType == BusQueryDeviceID)
1695  {
1697  Packet = &FdoExtension->MiniPortInterface->Packet;
1698 
1699  if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1700  {
1702  sizeof(Buffer),
1703  L"USB\\ROOT_HUB20");
1704  }
1705  else
1706  {
1708  sizeof(Buffer),
1709  L"USB\\ROOT_HUB");
1710  }
1711 
1712  Length = (LONG)(wcslen(Buffer) + 1);
1713 
1715  Length * sizeof(WCHAR),
1716  USB_PORT_TAG);
1717 
1718  if (Id)
1719  {
1720  RtlZeroMemory(Id, Length * sizeof(WCHAR));
1721  RtlStringCbCopyW(Id, Length * sizeof(WCHAR), Buffer);
1722 
1723  DPRINT("BusQueryDeviceID - %S, TotalLength - %hu\n",
1724  Id,
1725  Length);
1726  }
1727 
1728  Irp->IoStatus.Information = (ULONG_PTR)Id;
1729  break;
1730  }
1731 
1732  if (IdType == BusQueryHardwareIDs)
1733  {
1734  Id = USBPORT_GetDeviceHwIds(FdoDevice,
1735  FdoExtension->VendorID,
1736  FdoExtension->DeviceID,
1737  FdoExtension->RevisionID);
1738 
1739  Irp->IoStatus.Information = (ULONG_PTR)Id;
1740  break;
1741  }
1742 
1743  if (IdType == BusQueryCompatibleIDs ||
1745  {
1746  Irp->IoStatus.Information = 0;
1747  break;
1748  }
1749 
1750  /* IdType == BusQueryDeviceSerialNumber */
1751  Status = Irp->IoStatus.Status;
1752  break;
1753  }
1754 
1756  DPRINT("IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1758  break;
1759 
1761  DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
1762 
1763  /* Allocate buffer for bus information */
1764  BusInformation = ExAllocatePoolWithTag(PagedPool,
1765  sizeof(PNP_BUS_INFORMATION),
1766  USB_PORT_TAG);
1767 
1768  if (!BusInformation)
1769  {
1770  /* No memory */
1772  break;
1773  }
1774 
1775  RtlZeroMemory(BusInformation, sizeof(PNP_BUS_INFORMATION));
1776 
1777  /* Copy BUS GUID */
1778  RtlMoveMemory(&BusInformation->BusTypeGuid,
1779  &GUID_BUS_TYPE_USB,
1780  sizeof(GUID));
1781 
1782  /* Set bus type */
1783  BusInformation->LegacyBusType = PNPBus;
1784  BusInformation->BusNumber = 0;
1785 
1787  Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
1788  break;
1789 
1791  DPRINT("IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1792  break;
1793 
1795  DPRINT("USBPORT_PdoPnP: IRP_MN_SURPRISE_REMOVAL\n");
1797  break;
1798 
1799  default:
1800  DPRINT("unknown IRP_MN_???\n");
1801  break;
1802  }
1803 
1804  Irp->IoStatus.Status = Status;
1806  return Status;
1807 }
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_WRITE_CONFIG
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
NTSTATUS NTAPI USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
Definition: roothub.c:747
LONG NTSTATUS
Definition: precomp.h:26
DEVICE_CAPABILITIES
Definition: iotypes.h:928
#define IRP_MN_EJECT
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
DWORD Id
#define USB_PORT_TAG
Definition: usbport.h:44
NTSTATUS NTAPI USBPORT_RegisterDeviceInterface(IN PDEVICE_OBJECT PdoDevice, IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceClassGuid, IN BOOLEAN Enable)
Definition: pnp.c:30
#define IRP_MN_QUERY_REMOVE_DEVICE
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
long LONG
Definition: pedump.c:60
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
#define DeviceCapabilities
Definition: wingdi.h:4448
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:357
#define IRP_MN_READ_CONFIG
PVOID NTAPI USBPORT_GetDeviceHwIds(IN PDEVICE_OBJECT FdoDevice, IN USHORT VendorID, IN USHORT DeviceID, IN USHORT RevisionID)
Definition: pnp.c:1407
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IRP_MN_QUERY_BUS_INFORMATION
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI USBPORT_PdoQueryInterface(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: iface.c:782
* PDEVICE_CAPABILITIES
Definition: iotypes.h:928
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
DEVICE_POWER_STATE DevicePowerState
Definition: usbport.h:286
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
#define ObReferenceObject
Definition: obfuncs.h:204
#define IRP_MN_SET_LOCK
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define USBPORT_PNP_STATE_STARTED
Definition: usbport.h:87
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:363
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES

Referenced by USBPORT_Dispatch().

◆ USBPORT_QueryCapabilities()

NTSTATUS NTAPI USBPORT_QueryCapabilities ( IN PDEVICE_OBJECT  FdoDevice,
IN PDEVICE_CAPABILITIES  Capabilities 
)

Definition at line 382 of file pnp.c.

384 {
385  PUSBPORT_DEVICE_EXTENSION FdoExtention;
386  PIRP Irp;
388  PIO_STACK_LOCATION IoStack;
389  KEVENT Event;
390 
391  DPRINT("USBPORT_QueryCapabilities: ... \n");
392 
393  FdoExtention = FdoDevice->DeviceExtension;
394 
396 
397  Capabilities->Size = sizeof(DEVICE_CAPABILITIES);
398  Capabilities->Version = 1;
399  Capabilities->Address = MAXULONG;
400  Capabilities->UINumber = MAXULONG;
401 
403  FALSE);
404 
405  if (!Irp)
406  {
407  DPRINT1("USBPORT_QueryCapabilities: No resources - IoAllocateIrp!\n");
409  }
410 
412  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
413 
414  IoStack = IoGetNextIrpStackLocation(Irp);
415  IoStack->MajorFunction = IRP_MJ_PNP;
417 
419 
422  &Event,
423  TRUE,
424  TRUE,
425  TRUE);
426 
427  IoStack->Parameters.DeviceCapabilities.Capabilities = Capabilities;
428 
430 
431  if (Status == STATUS_PENDING)
432  {
434  Status = Irp->IoStatus.Status;
435  }
436 
438  {
440  }
441 
442  IoFreeIrp(Irp);
443 
444  return Status;
445 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
DEVICE_CAPABILITIES
Definition: iotypes.h:928
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
USBPORT_COMMON_DEVICE_EXTENSION CommonExtension
Definition: usbport.h:291
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI USBPORT_DumpingCapabilities(IN PDEVICE_CAPABILITIES Capabilities)
Definition: debug.c:171
IO_COMPLETION_ROUTINE USBPORT_FdoStartCompletion
Definition: pnp.c:16
#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
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define IRP_MN_QUERY_CAPABILITIES

Referenced by USBPORT_StartDevice().

◆ USBPORT_QueryPciBusInterface()

NTSTATUS NTAPI USBPORT_QueryPciBusInterface ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 317 of file pnp.c.

318 {
320  PBUS_INTERFACE_STANDARD BusInterface;
321  PIO_STACK_LOCATION IoStack;
323  PDEVICE_OBJECT HighestDevice;
324  KEVENT Event;
325  PIRP Irp;
327 
328  DPRINT("USBPORT_QueryPciBusInterface: ... \n");
329 
330  FdoExtension = FdoDevice->DeviceExtension;
331  BusInterface = &FdoExtension->BusInterface;
332 
333  RtlZeroMemory(BusInterface, sizeof(BUS_INTERFACE_STANDARD));
335  HighestDevice = IoGetAttachedDeviceReference(FdoDevice);
336 
338  HighestDevice,
339  NULL,
340  0,
341  NULL,
342  &Event,
343  &IoStatusBlock);
344 
345  if (Irp)
346  {
347  IoStack = IoGetNextIrpStackLocation(Irp);
348 
349  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
350  Irp->IoStatus.Information = 0;
351 
353 
354  IoStack->Parameters.QueryInterface.InterfaceType = &GUID_BUS_INTERFACE_STANDARD;
355  IoStack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
356  IoStack->Parameters.QueryInterface.Version = 1;
357  IoStack->Parameters.QueryInterface.Interface = (PINTERFACE)BusInterface;
358  IoStack->Parameters.QueryInterface.InterfaceSpecificData = 0;
359 
360  Status = IoCallDriver(HighestDevice, Irp);
361 
362  if (Status == STATUS_PENDING)
363  {
366  }
367  }
368  else
369  {
371  }
372 
373  ObDereferenceObject(HighestDevice);
374 
375  DPRINT("USBPORT_QueryPciBusInterface: return Status - %x\n", Status);
376 
377  return Status;
378 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
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
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
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
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_QUERY_INTERFACE
__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
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

Referenced by USBPORT_StartDevice().

◆ USBPORT_RegisterDeviceInterface()

NTSTATUS NTAPI USBPORT_RegisterDeviceInterface ( IN PDEVICE_OBJECT  PdoDevice,
IN PDEVICE_OBJECT  DeviceObject,
IN CONST GUID InterfaceClassGuid,
IN BOOLEAN  Enable 
)

Definition at line 30 of file pnp.c.

34 {
35  PUSBPORT_RHDEVICE_EXTENSION DeviceExtension;
36  PUNICODE_STRING SymbolicLinkName;
38 
39  DPRINT("USBPORT_RegisterDeviceInterface: Enable - %x\n", Enable);
40 
41  DeviceExtension = DeviceObject->DeviceExtension;
42  SymbolicLinkName = &DeviceExtension->CommonExtension.SymbolicLinkName;
43 
44  if (Enable)
45  {
48  NULL,
49  SymbolicLinkName);
50 
51  if (NT_SUCCESS(Status))
52  {
53  DeviceExtension->CommonExtension.IsInterfaceEnabled = 1;
54 
56  FALSE,
57  REG_SZ,
58  L"SymbolicName",
59  SymbolicLinkName->Buffer,
60  SymbolicLinkName->Length);
61 
62  if (NT_SUCCESS(Status))
63  {
64  DPRINT("USBPORT_RegisterDeviceInterface: LinkName - %wZ\n",
65  &DeviceExtension->CommonExtension.SymbolicLinkName);
66 
67  Status = IoSetDeviceInterfaceState(SymbolicLinkName, TRUE);
68  }
69  }
70  }
71  else
72  {
73  /* Disable device interface */
74  Status = IoSetDeviceInterfaceState(SymbolicLinkName, FALSE);
75 
76  if (NT_SUCCESS(Status))
77  {
78  RtlFreeUnicodeString(SymbolicLinkName);
79  DeviceExtension->CommonExtension.IsInterfaceEnabled = 0; // Disabled interface
80  }
81  }
82 
83  return Status;
84 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
UNICODE_STRING SymbolicLinkName
Definition: usbport.h:284
_In_ CONST GUID * InterfaceClassGuid
Definition: iofuncs.h:1134
NTSTATUS NTAPI USBPORT_SetRegistryKeyValue(IN PDEVICE_OBJECT DeviceObject, IN BOOL UseDriverKey, IN ULONG Type, IN PCWSTR ValueNameString, IN PVOID Data, IN ULONG DataSize)
Definition: usbport.c:248
USBPORT_COMMON_DEVICE_EXTENSION CommonExtension
Definition: usbport.h:417
#define REG_SZ
Definition: layer.c:22

Referenced by USBPORT_PdoPnP(), and USBPORT_StartDevice().

◆ USBPORT_StartDevice()

NTSTATUS NTAPI USBPORT_StartDevice ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_RESOURCES  UsbPortResources 
)

Definition at line 499 of file pnp.c.

501 {
505  PCI_COMMON_CONFIG PciConfig;
508  PDMA_ADAPTER DmaAdapter = NULL;
509  ULONG MiniPortStatus;
510  PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
512  ULONG DisableSelectiveSuspend = 0;
513  ULONG DisableCcDetect = 0;
514  ULONG IdleEpSupport = 0;
515  ULONG IdleEpSupportEx = 0;
516  ULONG SoftRetry = 0;
517  ULONG Limit2GB = 0;
518  ULONG TotalBusBandwidth = 0;
519  BOOLEAN IsCompanion = FALSE;
520  ULONG LegacyBIOS;
521  ULONG MiniportFlags;
522  ULONG ix;
523 
524  DPRINT("USBPORT_StartDevice: FdoDevice - %p, UsbPortResources - %p\n",
525  FdoDevice,
526  UsbPortResources);
527 
528  FdoExtension = FdoDevice->DeviceExtension;
529  Packet = &FdoExtension->MiniPortInterface->Packet;
530 
532  if (!NT_SUCCESS(Status))
533  goto ExitWithError;
534 
535  BytesRead = (*FdoExtension->BusInterface.GetBusData)(FdoExtension->BusInterface.Context,
537  &PciConfig,
538  0,
540 
542  {
543  DPRINT1("USBPORT_StartDevice: Failed to get pci config information!\n");
544  goto ExitWithError;
545  }
546 
547  FdoExtension->VendorID = PciConfig.VendorID;
548  FdoExtension->DeviceID = PciConfig.DeviceID;
549  FdoExtension->RevisionID = PciConfig.RevisionID;
550  FdoExtension->ProgIf = PciConfig.ProgIf;
551  FdoExtension->SubClass = PciConfig.SubClass;
552  FdoExtension->BaseClass = PciConfig.BaseClass;
553 
555 
564 
565  DmaAdapter = IoGetDmaAdapter(FdoExtension->CommonExtension.LowerPdoDevice,
567  &FdoExtension->NumberMapRegs);
568 
569  FdoExtension->DmaAdapter = DmaAdapter;
570 
571  if (!DmaAdapter)
572  {
573  DPRINT1("USBPORT_StartDevice: Failed to get DmaAdapter!\n");
575  goto ExitWithError;
576  }
577 
578  Status = USBPORT_CreateWorkerThread(FdoDevice);
579  if (!NT_SUCCESS(Status))
580  goto ExitWithError;
581 
582  Status = USBPORT_QueryCapabilities(FdoDevice, &FdoExtension->Capabilities);
583  if (!NT_SUCCESS(Status))
584  goto ExitWithError;
585 
586  FdoExtension->PciDeviceNumber = FdoExtension->Capabilities.Address >> 16;
587  FdoExtension->PciFunctionNumber = FdoExtension->Capabilities.Address & 0xFFFF;
588 
589  Status = IoGetDeviceProperty(FdoExtension->CommonExtension.LowerPdoDevice,
591  sizeof(ULONG),
592  &FdoExtension->BusNumber,
593  &ResultLength);
594 
595  if (!NT_SUCCESS(Status))
596  goto ExitWithError;
597 
598  KeInitializeSpinLock(&FdoExtension->EndpointListSpinLock);
599  KeInitializeSpinLock(&FdoExtension->EpStateChangeSpinLock);
600  KeInitializeSpinLock(&FdoExtension->EndpointClosedSpinLock);
601  KeInitializeSpinLock(&FdoExtension->DeviceHandleSpinLock);
602  KeInitializeSpinLock(&FdoExtension->IdleIoCsqSpinLock);
603  KeInitializeSpinLock(&FdoExtension->BadRequestIoCsqSpinLock);
604  KeInitializeSpinLock(&FdoExtension->MapTransferSpinLock);
605  KeInitializeSpinLock(&FdoExtension->FlushTransferSpinLock);
606  KeInitializeSpinLock(&FdoExtension->FlushPendingTransferSpinLock);
607  KeInitializeSpinLock(&FdoExtension->DoneTransferSpinLock);
608  KeInitializeSpinLock(&FdoExtension->WorkerThreadEventSpinLock);
609  KeInitializeSpinLock(&FdoExtension->MiniportSpinLock);
610  KeInitializeSpinLock(&FdoExtension->TimerFlagsSpinLock);
611  KeInitializeSpinLock(&FdoExtension->PowerWakeSpinLock);
612  KeInitializeSpinLock(&FdoExtension->SetPowerD0SpinLock);
613  KeInitializeSpinLock(&FdoExtension->RootHubCallbackSpinLock);
614  KeInitializeSpinLock(&FdoExtension->TtSpinLock);
615 
616  KeInitializeDpc(&FdoExtension->IsrDpc, USBPORT_IsrDpc, FdoDevice);
617 
618  KeInitializeDpc(&FdoExtension->TransferFlushDpc,
620  FdoDevice);
621 
622  KeInitializeDpc(&FdoExtension->WorkerRequestDpc,
624  FdoDevice);
625 
626  KeInitializeDpc(&FdoExtension->HcWakeDpc,
628  FdoDevice);
629 
630  IoCsqInitialize(&FdoExtension->IdleIoCsq,
637 
638  IoCsqInitialize(&FdoExtension->BadRequestIoCsq,
645 
646  FdoExtension->IsrDpcCounter = -1;
647  FdoExtension->IsrDpcHandlerCounter = -1;
648  FdoExtension->IdleLockCounter = -1;
649  FdoExtension->BadRequestLockCounter = -1;
650  FdoExtension->ChirpRootPortLock = -1;
651 
652  FdoExtension->RHInitCallBackLock = 0;
653 
654  FdoExtension->UsbAddressBitMap[0] = 1;
655  FdoExtension->UsbAddressBitMap[1] = 0;
656  FdoExtension->UsbAddressBitMap[2] = 0;
657  FdoExtension->UsbAddressBitMap[3] = 0;
658 
659  USBPORT_GetDefaultBIOSx(FdoDevice,
660  &FdoExtension->UsbBIOSx,
661  &DisableSelectiveSuspend,
662  &DisableCcDetect,
663  &IdleEpSupport,
664  &IdleEpSupportEx,
665  &SoftRetry);
666 
667  if (DisableSelectiveSuspend)
669 
670  if (!DisableSelectiveSuspend &&
672  {
674  }
675 
676  MiniportFlags = Packet->MiniPortFlags;
677 
678  if (MiniportFlags & USB_MINIPORT_FLAGS_POLLING)
680 
681  if (MiniportFlags & USB_MINIPORT_FLAGS_WAKE_SUPPORT)
683 
684  if (MiniportFlags & USB_MINIPORT_FLAGS_DISABLE_SS)
687 
688  USBPORT_SetRegistryKeyValue(FdoExtension->CommonExtension.LowerPdoDevice,
689  TRUE,
690  REG_DWORD,
691  L"EnIdleEndpointSupport",
692  &IdleEpSupport,
693  sizeof(IdleEpSupport));
694 
695  USBPORT_SetRegistryKeyValue(FdoExtension->CommonExtension.LowerPdoDevice,
696  TRUE,
697  REG_DWORD,
698  L"EnIdleEndpointSupportEx",
699  &IdleEpSupportEx,
700  sizeof(IdleEpSupportEx));
701 
702  USBPORT_SetRegistryKeyValue(FdoExtension->CommonExtension.LowerPdoDevice,
703  TRUE,
704  REG_DWORD,
705  L"EnSoftRetry",
706  &SoftRetry,
707  sizeof(SoftRetry));
708 
710  FdoExtension->CommonExtension.LowerPdoDevice,
711  TRUE,
712  L"CommonBuffer2GBLimit",
713  sizeof(L"CommonBuffer2GBLimit"),
714  &Limit2GB,
715  sizeof(Limit2GB));
716 
717  FdoExtension->CommonBufferLimit = (Limit2GB != 0);
718 
719  if (FdoExtension->BaseClass == PCI_CLASS_SERIAL_BUS_CTLR &&
720  FdoExtension->SubClass == PCI_SUBCLASS_SB_USB &&
722  {
723  Status = USBPORT_IsCompanionController(FdoDevice, &IsCompanion);
724 
725  if (!NT_SUCCESS(Status))
726  {
727  if (IsCompanion)
728  {
730  }
731  else
732  {
734  }
735  }
736  }
737 
738  if (DisableCcDetect)
739  {
741  }
742 
743  TotalBusBandwidth = Packet->MiniPortBusBandwidth;
744  FdoExtension->TotalBusBandwidth = TotalBusBandwidth;
745 
747  FdoExtension->CommonExtension.LowerPdoDevice,
748  TRUE,
749  L"TotalBusBandwidth",
750  sizeof(L"TotalBusBandwidth"),
751  &TotalBusBandwidth,
752  sizeof(TotalBusBandwidth));
753 
754  if (TotalBusBandwidth != FdoExtension->TotalBusBandwidth)
755  {
756  FdoExtension->TotalBusBandwidth = TotalBusBandwidth;
757  }
758 
759  for (ix = 0; ix < USB2_FRAMES; ix++)
760  {
761  FdoExtension->Bandwidth[ix] = FdoExtension->TotalBusBandwidth -
762  FdoExtension->TotalBusBandwidth / 10;
763  }
764 
766  sizeof(USBPORT_IRP_TABLE),
767  USB_PORT_TAG);
768 
769  if (!FdoExtension->ActiveIrpTable)
770  {
771  DPRINT1("USBPORT_StartDevice: Allocate ActiveIrpTable failed!\n");
772  goto ExitWithError;
773  }
774 
775  RtlZeroMemory(FdoExtension->ActiveIrpTable, sizeof(USBPORT_IRP_TABLE));
776 
778  sizeof(USBPORT_IRP_TABLE),
779  USB_PORT_TAG);
780 
781  if (!FdoExtension->PendingIrpTable)
782  {
783  DPRINT1("USBPORT_StartDevice: Allocate PendingIrpTable failed!\n");
784  goto ExitWithError;
785  }
786 
787  RtlZeroMemory(FdoExtension->PendingIrpTable, sizeof(USBPORT_IRP_TABLE));
788 
789  Status = IoConnectInterrupt(&FdoExtension->InterruptObject,
791  (PVOID)FdoDevice,
792  0,
793  UsbPortResources->InterruptVector,
794  UsbPortResources->InterruptLevel,
795  UsbPortResources->InterruptLevel,
796  UsbPortResources->InterruptMode,
797  UsbPortResources->ShareVector,
798  UsbPortResources->InterruptAffinity,
799  0);
800 
801 
802  if (!NT_SUCCESS(Status))
803  {
804  DPRINT1("USBPORT_StartDevice: IoConnectInterrupt failed!\n");
805  goto ExitWithError;
806  }
807 
809 
810  if (Packet->MiniPortExtensionSize)
811  {
812  RtlZeroMemory(FdoExtension->MiniPortExt, Packet->MiniPortExtensionSize);
813  }
814 
815  if (Packet->MiniPortResourcesSize)
816  {
817  HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
818  Packet->MiniPortResourcesSize);
819 
820  if (!HeaderBuffer)
821  {
822  DPRINT1("USBPORT_StartDevice: Failed to AllocateCommonBuffer!\n");
824  goto ExitWithError;
825  }
826 
827  UsbPortResources->StartVA = HeaderBuffer->VirtualAddress;
828  UsbPortResources->StartPA = HeaderBuffer->PhysicalAddress;
829 
830  FdoExtension->MiniPortCommonBuffer = HeaderBuffer;
831  }
832  else
833  {
834  FdoExtension->MiniPortCommonBuffer = NULL;
835  }
836 
837  MiniPortStatus = Packet->StartController(FdoExtension->MiniPortExt,
838  UsbPortResources);
839 
840  if (UsbPortResources->LegacySupport)
841  {
843  LegacyBIOS = 1;
844  }
845  else
846  {
847  LegacyBIOS = 0;
848  }
849 
850  USBPORT_SetRegistryKeyValue(FdoExtension->CommonExtension.LowerPdoDevice,
851  FALSE,
852  REG_DWORD,
853  L"DetectedLegacyBIOS",
854  &LegacyBIOS,
855  sizeof(LegacyBIOS));
856 
857  if (MiniPortStatus)
858  {
859  DPRINT1("USBPORT_StartDevice: Failed to Start MiniPort. MiniPortStatus - %x\n",
860  MiniPortStatus);
861 
863  {
864  IoDisconnectInterrupt(FdoExtension->InterruptObject);
866  }
867 
868  if (FdoExtension->MiniPortCommonBuffer)
869  {
870  USBPORT_FreeCommonBuffer(FdoDevice, FdoExtension->MiniPortCommonBuffer);
871  FdoExtension->MiniPortCommonBuffer = NULL;
872  }
873 
874  goto ExitWithError;
875  }
876  else
877  {
879  USBPORT_MiniportInterrupts(FdoDevice, TRUE);
880  }
881 
882  FdoExtension->TimerValue = 500;
883  USBPORT_StartTimer((PVOID)FdoDevice, 500);
884 
885  Status = USBPORT_RegisterDeviceInterface(FdoExtension->CommonExtension.LowerPdoDevice,
886  FdoDevice,
887  &GUID_DEVINTERFACE_USB_HOST_CONTROLLER,
888  TRUE);
889 
890  if (!NT_SUCCESS(Status))
891  {
892  DPRINT1("USBPORT_StartDevice: RegisterDeviceInterface failed!\n");
893  goto ExitWithError;
894  }
895 
897 
899 
900  DPRINT("USBPORT_StartDevice: Exit Status - %p\n", Status);
901  return Status;
902 
903 ExitWithError:
904  USBPORT_StopDevice(FdoDevice);
905 
906  DPRINT1("USBPORT_StartDevice: ExitWithError Status - %lx\n", Status);
907  return Status;
908 }
VOID NTAPI USBPORT_FreeCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer)
Definition: usbport.c:1748
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
#define USB_MINIPORT_FLAGS_POLLING
Definition: usbmport.h:537
#define USBPORT_FLAG_INT_CONNECTED
Definition: usbport.h:66
VOID NTAPI USBPORT_RemoveIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:37
VOID NTAPI USBPORT_TransferFlushDpc(IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: usbport.c:825
NTSTATUS NTAPI USBPORT_CreateWorkerThread(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:1422
VOID NTAPI USBPORT_AcquireBadRequestLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
Definition: queue.c:214
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI USBPORT_IsCompanionController(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN *IsCompanion)
Definition: pnp.c:208
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_CLASS_SERIAL_BUS_CTLR
Definition: iotypes.h:3759
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
VOID NTAPI USBPORT_HcWakeDpc(IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: power.c:52
PDMA_ADAPTER NTAPI IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_DESCRIPTION DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
Definition: pnpdma.c:23
#define PCI_SUBCLASS_SB_USB
Definition: iotypes.h:3851
BOOLEAN NTAPI USBPORT_InterruptService(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
Definition: usbport.c:1077
LONG NTSTATUS
Definition: precomp.h:26
DMA_SPEED DmaSpeed
Definition: iotypes.h:2038
VOID NTAPI USBPORT_IsrDpc(IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: usbport.c:1031
#define USBPORT_FLAG_BIOS_DISABLE_SS
Definition: usbport.h:80
NTSTATUS NTAPI USBPORT_GetDefaultBIOSx(IN PDEVICE_OBJECT FdoDevice, IN PULONG UsbBIOSx, IN PULONG DisableSelectiveSuspend, IN PULONG DisableCcDetect, IN PULONG IdleEpSupport, IN PULONG IdleEpSupportEx, IN PULONG SoftRetry)
Definition: pnp.c:135
#define USBPORT_FLAG_HC_WAKE_SUPPORT
Definition: usbport.h:75
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2020
#define USB_PORT_TAG
Definition: usbport.h:44
PUSBPORT_COMMON_BUFFER_HEADER NTAPI USBPORT_AllocateCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN SIZE_T BufferLength)
Definition: usbport.c:1686
VOID NTAPI USBPORT_WorkerRequestDpc(IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: usbport.c:701
NTSTATUS NTAPI USBPORT_RegisterDeviceInterface(IN PDEVICE_OBJECT PdoDevice, IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceClassGuid, IN BOOLEAN Enable)
Definition: pnp.c:30
PIRP NTAPI USBPORT_PeekNextBadRequest(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
Definition: queue.c:169
VOID NTAPI USBPORT_CompleteCanceledBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:246
#define USB_MINIPORT_FLAGS_DISABLE_SS
Definition: usbmport.h:535
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
VOID NTAPI USBPORT_MiniportInterrupts(IN PDEVICE_OBJECT FdoDevice, IN BOOLEAN IsEnable)
Definition: usbport.c:555
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
VOID NTAPI USBPORT_ReleaseIdleLock(IN PIO_CSQ Csq, IN KIRQL Irql)
Definition: queue.c:107
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI USBPORT_QueryCapabilities(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_CAPABILITIES Capabilities)
Definition: pnp.c:382
#define USBPORT_FLAG_COMPANION_HC
Definition: usbport.h:77
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2030
BOOLEAN NTAPI USBPORT_StartTimer(IN PDEVICE_OBJECT FdoDevice, IN ULONG Time)
Definition: usbport.c:1653
VOID NTAPI USBPORT_RemoveBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:160
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
NTSTATUS NTAPI USBPORT_GetRegistryKeyValueFullInfo(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN BOOL UseDriverKey, IN PCWSTR SourceString, IN ULONG LengthStr, IN PVOID Buffer, IN ULONG BufferLength)
Definition: usbport.c:296
VOID NTAPI USBPORT_ReleaseBadRequestLock(IN PIO_CSQ Csq, IN KIRQL Irql)
Definition: queue.c:230
#define USBPORT_FLAG_HC_POLLING
Definition: usbport.h:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI USBPORT_CompleteCanceledIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:123
BOOLEAN ScatterGather
Definition: iotypes.h:2027
DMA_WIDTH DmaWidth
Definition: iotypes.h:2037
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3288
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI USBPORT_StopDevice(IN PDEVICE_OBJECT FdoDevice)
Definition: pnp.c:490
VOID NTAPI USBPORT_AcquireIdleLock(IN PIO_CSQ Csq, IN PKIRQL Irql)
Definition: queue.c:91
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
#define PCI_INTERFACE_USB_ID_EHCI
Definition: usbport.h:25
#define USBPORT_FLAG_LEGACY_SUPPORT
Definition: usbport.h:74
#define USBPORT_MPFLAG_INTERRUPTS_ENABLED
Definition: usbport.h:101
BOOLEAN NTAPI USBPORT_IsSelectiveSuspendEnabled(IN PDEVICE_OBJECT FdoDevice)
Definition: pnp.c:88
VOID NTAPI USBPORT_InsertBadRequest(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:143
#define DPRINT1
Definition: precomp.h:8
#define USB2_FRAMES
Definition: usbport.h:451
NTSTATUS NTAPI USBPORT_QueryPciBusInterface(IN PDEVICE_OBJECT FdoDevice)
Definition: pnp.c:317
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2036
NTSTATUS NTAPI USBPORT_SetRegistryKeyValue(IN PDEVICE_OBJECT DeviceObject, IN BOOL UseDriverKey, IN ULONG Type, IN PCWSTR ValueNameString, IN PVOID Data, IN ULONG DataSize)
Definition: usbport.c:248
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI USBPORT_InsertIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp)
Definition: queue.c:20
NTKERNELAPI NTSTATUS NTAPI IoCsqInitialize(_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp)
Set up a CSQ struct to initialize the queue.
Definition: csq.c:103
#define USBPORT_FLAG_SELECTIVE_SUSPEND
Definition: usbport.h:72
#define USB_MINIPORT_FLAGS_WAKE_SUPPORT
Definition: usbmport.h:539
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
#define REG_DWORD
Definition: sdbapi.c:596
NTSTATUS NTAPI USBPORT_CreateLegacySymbolicLink(IN PDEVICE_OBJECT FdoDevice)
Definition: pnp.c:449
PIRP NTAPI USBPORT_PeekNextIdleIrp(IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
Definition: queue.c:46
_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 USBPORT_FLAG_HC_STARTED
Definition: usbport.h:67
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3238

Referenced by USBPORT_FdoPnP().

◆ USBPORT_StopDevice()

NTSTATUS NTAPI USBPORT_StopDevice ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 490 of file pnp.c.

491 {
492  DPRINT1("USBPORT_StopDevice: UNIMPLEMENTED. FIXME\n");
493  DbgBreakPoint();
494  return STATUS_SUCCESS;
495 }
void DbgBreakPoint()
Definition: mach.c:553
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by USBPORT_StartDevice().

Variable Documentation

◆ USBPORT_FdoStartCompletion

IO_COMPLETION_ROUTINE USBPORT_FdoStartCompletion

Definition at line 16 of file pnp.c.

Referenced by USBPORT_FdoPnP(), and USBPORT_QueryCapabilities().