Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. pnp.c
  5. Abstract: This module contains code to handle PnP and Power IRPs.
  6. Environment:
  7. Kernel mode
  8. Author:
  9. Michael Tsang (MikeTs) 20-Nov-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, SmbLitePnp)
  15. #pragma alloc_text(PAGE, SmbLitePower)
  16. #endif
  17. /*++
  18. @doc EXTERNAL
  19. @func NTSTATUS | SmbLitePnp |
  20. Plug and Play dispatch routine for this driver.
  21. @parm IN PDEVICE_OBJECT | DevObj | Pointer to the device object.
  22. @parm IN PIRP | Irp | Pointer to an I/O request packet.
  23. @rvalue SUCCESS | returns STATUS_SUCCESS
  24. @rvalue FAILURE | returns NT status code
  25. --*/
  26. NTSTATUS EXTERNAL
  27. SmbLitePnp(
  28. IN PDEVICE_OBJECT DevObj,
  29. IN PIRP Irp
  30. )
  31. {
  32. PROCNAME("SmbLitePnp")
  33. NTSTATUS status;
  34. PIO_STACK_LOCATION irpsp;
  35. PSMBLITE_DEVEXT devext;
  36. PAGED_CODE();
  37. irpsp = IoGetCurrentIrpStackLocation(Irp);
  38. ENTER(1, ("(DevObj=%p,Irp=%p,IrpSp=%p,Minor=%s)\n",
  39. DevObj, Irp, irpsp,
  40. LookupName(irpsp->MinorFunction, PnPMinorFnNames)));
  41. devext = DevObj->DeviceExtension;
  42. status = IoAcquireRemoveLock(&devext->RemoveLock, Irp);
  43. if (NT_SUCCESS(status))
  44. {
  45. status = STATUS_NOT_SUPPORTED;
  46. switch (irpsp->MinorFunction)
  47. {
  48. case IRP_MN_QUERY_CAPABILITIES:
  49. {
  50. PDEVICE_CAPABILITIES DevCap;
  51. DevCap = irpsp->Parameters.DeviceCapabilities.Capabilities;
  52. //
  53. // Set size and version.
  54. //
  55. DevCap->Size = sizeof(DEVICE_CAPABILITIES);
  56. DevCap->Version = 1;
  57. //
  58. // Set capability bits.
  59. //
  60. DevCap->LockSupported = FALSE;
  61. DevCap->EjectSupported = FALSE;
  62. DevCap->Removable = FALSE;
  63. DevCap->DockDevice = FALSE;
  64. DevCap->UniqueID = TRUE;
  65. DevCap->SilentInstall = TRUE;
  66. DevCap->RawDeviceOK = FALSE;
  67. DevCap->Address = 0xffffffff;
  68. DevCap->UINumber = 0xffffffff;
  69. DevCap->SystemWake = PowerSystemUnspecified;
  70. DevCap->DeviceWake = PowerSystemUnspecified;
  71. DevCap->D1Latency = 0;
  72. DevCap->D2Latency = 0;
  73. DevCap->D3Latency = 0;
  74. status = STATUS_SUCCESS;
  75. break;
  76. }
  77. case IRP_MN_START_DEVICE:
  78. ASSERT(!(devext->dwfSmbLite & SMBLITEF_DEVICE_STARTED));
  79. devext->dwfSmbLite |= SMBLITEF_DEVICE_STARTED;
  80. status = STATUS_SUCCESS;
  81. break;
  82. case IRP_MN_STOP_DEVICE:
  83. if (devext->dwfSmbLite & SMBLITEF_DEVICE_STARTED)
  84. {
  85. devext->dwfSmbLite &= ~SMBLITEF_DEVICE_STARTED;
  86. }
  87. status = STATUS_SUCCESS;
  88. break;
  89. case IRP_MN_QUERY_REMOVE_DEVICE:
  90. case IRP_MN_CANCEL_REMOVE_DEVICE:
  91. status = STATUS_SUCCESS;
  92. break;
  93. case IRP_MN_SURPRISE_REMOVAL:
  94. //
  95. // This should never happen because the backlight is
  96. // non-removable.
  97. //
  98. ASSERT(FALSE);
  99. status = STATUS_SUCCESS;
  100. case IRP_MN_REMOVE_DEVICE:
  101. devext->dwfSmbLite &= ~SMBLITEF_DEVICE_STARTED;
  102. devext->dwfSmbLite |= SMBLITEF_DEVICE_REMOVED;
  103. IoReleaseRemoveLockAndWait(&devext->RemoveLock, Irp);
  104. RemoveDevice(devext);
  105. status = STATUS_SUCCESS;
  106. break;
  107. }
  108. if (irpsp->MinorFunction != IRP_MN_REMOVE_DEVICE)
  109. {
  110. IoReleaseRemoveLock(&devext->RemoveLock, Irp);
  111. }
  112. }
  113. if (status != STATUS_NOT_SUPPORTED)
  114. {
  115. //
  116. // Only set status if we have something to add.
  117. //
  118. Irp->IoStatus.Status = status;
  119. }
  120. if (NT_SUCCESS(status) || (status == STATUS_NOT_SUPPORTED))
  121. {
  122. //
  123. // Forward the request to lower drivers.
  124. //
  125. IoSkipCurrentIrpStackLocation(Irp);
  126. ENTER(2, (".IoCallDriver(DevObj=%p,Irp=%p)\n",
  127. devext->LowerDevice, Irp));
  128. status = IoCallDriver(devext->LowerDevice, Irp);
  129. EXIT(2, (".IoCallDriver=%x\n", status));
  130. }
  131. else
  132. {
  133. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  134. }
  135. EXIT(1, ("=%x\n", status));
  136. return status;
  137. } //SmbLitePnp
  138. /*++
  139. @doc EXTERNAL
  140. @func NTSTATUS | SmbLitePower |
  141. The power dispatch routine for this driver.
  142. @parm IN PDEVICE_OBJECT | DevObj | Points to the device object.
  143. @parm IN PIRP | Irp | Points to an I/O request packet.
  144. @rvalue SUCCESS | returns STATUS_SUCCESS
  145. @rvalue FAILURE | returns NT status code
  146. --*/
  147. NTSTATUS EXTERNAL
  148. SmbLitePower(
  149. IN PDEVICE_OBJECT DevObj,
  150. IN PIRP Irp
  151. )
  152. {
  153. PROCNAME("SmbLitePower")
  154. NTSTATUS status = STATUS_NOT_SUPPORTED;
  155. PSMBLITE_DEVEXT devext = DevObj->DeviceExtension;
  156. PAGED_CODE();
  157. ENTER(1, ("(DevObj=%p,Irp=%p,Minor=%s)\n",
  158. DevObj, Irp,
  159. LookupName(IoGetCurrentIrpStackLocation(Irp)->MinorFunction,
  160. PowerMinorFnNames)));
  161. PoStartNextPowerIrp(Irp);
  162. if (NT_SUCCESS(status) || (status == STATUS_NOT_SUPPORTED))
  163. {
  164. //
  165. // Forward the request to lower drivers.
  166. //
  167. IoSkipCurrentIrpStackLocation(Irp);
  168. ENTER(2, (".PoCallDriver(DevObj=%p,Irp=%p)\n",
  169. devext->LowerDevice, Irp));
  170. status = PoCallDriver(devext->LowerDevice, Irp);
  171. EXIT(2, (".PoCallDriver=%x\n", status));
  172. }
  173. else
  174. {
  175. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  176. }
  177. EXIT(1, ("=%x\n", status));
  178. return status;
  179. } //SmbLitePower