Leaked source code of windows server 2003
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.

148 lines
4.4 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  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. PAGED_CODE();
  76. UNREFERENCED_PARAMETER(RegistryPath);
  77. UNREFERENCED_PARAMETER(DriverClassName);
  78. if (DeviceObject) {
  79. deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode;
  80. if ( deviceNode &&
  81. !(deviceNode->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) {
  82. PP_SAVE_DRIVEROBJECT_TO_TRIAGE_DUMP(DriverObject);
  83. PP_SAVE_DEVICEOBJECT_TO_TRIAGE_DUMP(DeviceObject);
  84. KeBugCheckEx(
  85. PNP_DETECTED_FATAL_ERROR,
  86. PNP_ERR_INVALID_PDO,
  87. (ULONG_PTR)DeviceObject,
  88. (ULONG_PTR)DriverObject,
  89. 0);
  90. }
  91. }
  92. if (RequestedResources) {
  93. if ( RequestedResources->AlternativeLists == 0 ||
  94. RequestedResources->List[0].Count == 0) {
  95. RequestedResources = NULL;
  96. }
  97. }
  98. if (pAllocatedResources) {
  99. *pAllocatedResources = NULL;
  100. }
  101. return IopLegacyResourceAllocation (
  102. ArbiterRequestLegacyAssigned,
  103. DriverObject,
  104. DeviceObject,
  105. RequestedResources,
  106. pAllocatedResources);
  107. }