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.

146 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. assign.c
  5. Abstract:
  6. IoAssignResources
  7. Author:
  8. Ken Reneris
  9. Environment:
  10. EDIT IN 110 COLUMN MODE
  11. Revision History:
  12. Add PnP support - shielint
  13. Cleanup - SantoshJ
  14. --*/
  15. #include "pnpmgrp.h"
  16. #ifdef ALLOC_PRAGMA
  17. #pragma alloc_text(PAGE,IoAssignResources)
  18. #endif // ALLOC_PRAGMA
  19. NTSTATUS
  20. IoAssignResources (
  21. IN PUNICODE_STRING RegistryPath,
  22. IN PUNICODE_STRING DriverClassName OPTIONAL,
  23. IN PDRIVER_OBJECT DriverObject,
  24. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  25. IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
  26. IN OUT PCM_RESOURCE_LIST *pAllocatedResources
  27. )
  28. /*++
  29. Routine Description:
  30. This routine takes an input request of RequestedResources, and returned
  31. allocated resources in pAllocatedResources. The allocated resources are
  32. automatically recorded in the registry under the ResourceMap for the
  33. DriverClassName/DriverObject/DeviceObject requestor.
  34. Arguments:
  35. RegistryPath
  36. For a simple driver, this would be the value passed to the drivers
  37. initialization function. For drivers call IoAssignResources with
  38. multiple DeviceObjects are responsible for passing in a unique
  39. RegistryPath for each object.
  40. The registry path is checked for:
  41. RegitryPath:
  42. AssignedSystemResources.
  43. AssignSystemResources is of type REG_RESOURCE_REQUIREMENTS_LIST
  44. If present, IoAssignResources will attempt to use these settings to
  45. satisify the requested resources. If the listed settings do
  46. not conform to the resource requirements, then IoAssignResources
  47. will fail.
  48. Note: IoAssignResources may store other internal binary information
  49. in the supplied RegisteryPath.
  50. DriverObject:
  51. The driver object of the caller.
  52. DeviceObject:
  53. If non-null, then requested resoruce list refers to this device.
  54. If null, the requested resource list refers to the driver.
  55. DriverClassName
  56. Used to partition allocated resources into different device classes.
  57. RequestedResources
  58. A list of resources to allocate.
  59. Allocated resources may be appended or freed by re-invoking
  60. IoAssignResources with the same RegistryPath, DriverObject and
  61. DeviceObject. (editing requirements on a resource list by using
  62. sucessive calls is not preferred driver behaviour).
  63. AllocatedResources
  64. Returns the allocated resources for the requested resource list.
  65. Note that the driver is responsible for passing in a pointer to
  66. an uninitialized pointer. IoAssignResources will initialize the
  67. pointer to point to the allocated CM_RESOURCE_LIST. The driver
  68. is responisble for returning the memory back to pool when it is
  69. done with them structure.
  70. Return Value:
  71. The status returned is the final completion status of the operation.
  72. --*/
  73. {
  74. PDEVICE_NODE deviceNode;
  75. UNREFERENCED_PARAMETER(RegistryPath);
  76. UNREFERENCED_PARAMETER(DriverClassName);
  77. if (DeviceObject) {
  78. deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode;
  79. if ( deviceNode &&
  80. !(deviceNode->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) {
  81. PP_SAVE_DRIVEROBJECT_TO_TRIAGE_DUMP(DriverObject);
  82. PP_SAVE_DEVICEOBJECT_TO_TRIAGE_DUMP(DeviceObject);
  83. KeBugCheckEx(
  84. PNP_DETECTED_FATAL_ERROR,
  85. PNP_ERR_INVALID_PDO,
  86. (ULONG_PTR)DeviceObject,
  87. 0,
  88. 0);
  89. }
  90. }
  91. if (RequestedResources) {
  92. if ( RequestedResources->AlternativeLists == 0 ||
  93. RequestedResources->List[0].Count == 0) {
  94. RequestedResources = NULL;
  95. }
  96. }
  97. if (pAllocatedResources) {
  98. *pAllocatedResources = NULL;
  99. }
  100. return IopLegacyResourceAllocation (
  101. ArbiterRequestLegacyAssigned,
  102. DriverObject,
  103. DeviceObject,
  104. RequestedResources,
  105. pAllocatedResources);
  106. }