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.

185 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1991-2000 Microsoft Corporation
  3. Module Name:
  4. init.c
  5. Abstract:
  6. DriverEntry initialization code for pnp isa bus driver
  7. Author:
  8. Shie-Lin Tzong (shielint) 3-Jan-1997
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "busp.h"
  14. #include "pnpisa.h"
  15. BOOLEAN
  16. PipIsIsolationDisabled(
  17. VOID
  18. );
  19. #ifdef ALLOC_PRAGMA
  20. #pragma alloc_text(INIT,DriverEntry)
  21. #pragma alloc_text(INIT,PipIsIsolationDisabled)
  22. #endif
  23. #if ISOLATE_CARDS
  24. BOOLEAN
  25. PipIsIsolationDisabled(
  26. )
  27. /*++
  28. Description:
  29. Look in the registry for flag indicating that isolation has been
  30. disabled. This is a last resort hook for platforms that can't
  31. deal with the RDP and it's boot config.
  32. Return Value:
  33. BOOLEAN indicating whether isolation is disabled or not.
  34. --*/
  35. {
  36. HANDLE serviceHandle, paramHandle;
  37. UNICODE_STRING paramString;
  38. PKEY_VALUE_FULL_INFORMATION keyInfo;
  39. NTSTATUS status;
  40. BOOLEAN result = FALSE;
  41. status = PipOpenRegistryKey(&serviceHandle,
  42. NULL,
  43. &PipRegistryPath,
  44. KEY_READ,
  45. FALSE);
  46. if (!NT_SUCCESS(status)) {
  47. return result;
  48. }
  49. RtlInitUnicodeString(&paramString, L"Parameters");
  50. status = PipOpenRegistryKey(&paramHandle,
  51. serviceHandle,
  52. &paramString,
  53. KEY_READ,
  54. FALSE);
  55. ZwClose(serviceHandle);
  56. if (!NT_SUCCESS(status)) {
  57. return result;
  58. }
  59. status = PipGetRegistryValue(paramHandle,
  60. L"IsolationDisabled",
  61. &keyInfo);
  62. ZwClose(paramHandle);
  63. if (NT_SUCCESS(status)) {
  64. if((keyInfo->Type == REG_DWORD) &&
  65. (keyInfo->DataLength >= sizeof(ULONG))) {
  66. result = *(PULONG)KEY_VALUE_DATA(keyInfo) != 0;
  67. }
  68. ExFreePool(keyInfo);
  69. }
  70. return result;
  71. }
  72. #endif
  73. NTSTATUS
  74. DriverEntry(
  75. IN PDRIVER_OBJECT DriverObject,
  76. IN PUNICODE_STRING RegistryPath
  77. )
  78. /*++
  79. Routine Description:
  80. This routine initializes driver object major function table to handle Pnp IRPs
  81. and AddDevice entry point. If detection is allowed, it reports a detected device
  82. for the pseudo isapnp bus and performs enumeration.
  83. Arguments:
  84. DriverObject - specifies the driver object for the bus extender.
  85. RegistryPath - supplies a pointer to a unicode string of the service key name in
  86. the CurrentControlSet\Services key for the bus extender.
  87. Return Value:
  88. Always return STATUS_UNSUCCESSFUL.
  89. --*/
  90. {
  91. PDRIVER_EXTENSION driverExtension;
  92. NTSTATUS status = STATUS_SUCCESS;
  93. PDEVICE_OBJECT detectedDeviceObject = NULL;
  94. PipDriverObject = DriverObject;
  95. //
  96. // Fill in the driver object
  97. //
  98. DriverObject->DriverUnload = PiUnload;
  99. DriverObject->MajorFunction[IRP_MJ_PNP] = PiDispatchPnp;
  100. DriverObject->MajorFunction[IRP_MJ_POWER] = PiDispatchPower;
  101. //
  102. // Device and system control IRPs can be handled in the same way
  103. // we basically don't touch them
  104. //
  105. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PiDispatchDevCtl;
  106. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = PiDispatchDevCtl;
  107. driverExtension = DriverObject->DriverExtension;
  108. driverExtension->AddDevice = PiAddDevice;
  109. //
  110. // Store our registry path globally so we can use it later
  111. //
  112. PipRegistryPath.Length = RegistryPath->Length;
  113. PipRegistryPath.MaximumLength = RegistryPath->MaximumLength;
  114. PipRegistryPath.Buffer = ExAllocatePool(PagedPool,
  115. RegistryPath->MaximumLength );
  116. if( PipRegistryPath.Buffer == NULL ){
  117. return STATUS_INSUFFICIENT_RESOURCES;
  118. }
  119. RtlCopyMemory( PipRegistryPath.Buffer,
  120. RegistryPath->Buffer,
  121. RegistryPath->MaximumLength );
  122. //
  123. // Initialize global varaibles
  124. //
  125. KeInitializeEvent (&PipDeviceTreeLock, SynchronizationEvent, TRUE);
  126. KeInitializeEvent (&IsaBusNumberLock, SynchronizationEvent, TRUE);
  127. BusNumBM=&BusNumBMHeader;
  128. RtlInitializeBitMap (BusNumBM,BusNumberBuffer,256/sizeof (ULONG));
  129. RtlClearAllBits (BusNumBM);
  130. #if ISOLATE_CARDS
  131. PipIsolationDisabled = PipIsIsolationDisabled();
  132. #endif
  133. return status;
  134. }