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.

194 lines
4.6 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. #if defined(_X86_) && ISOLATE_CARDS
  95. if (IsNEC_98) {
  96. ADDRESS_PORT=ADDRESS_PORT_NEC;
  97. COMMAND_PORT=COMMAND_PORT_NEC;
  98. }
  99. #endif
  100. PipDriverObject = DriverObject;
  101. //
  102. // Fill in the driver object
  103. //
  104. DriverObject->DriverUnload = PiUnload;
  105. DriverObject->MajorFunction[IRP_MJ_PNP] = PiDispatchPnp;
  106. DriverObject->MajorFunction[IRP_MJ_POWER] = PiDispatchPower;
  107. //
  108. // Device and system control IRPs can be handled in the same way
  109. // we basically don't touch them
  110. //
  111. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PiDispatchDevCtl;
  112. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = PiDispatchDevCtl;
  113. DriverObject->MajorFunction[IRP_MJ_CREATE] = PiDispatchCreate;
  114. DriverObject->MajorFunction[IRP_MJ_CLOSE] = PiDispatchClose;
  115. driverExtension = DriverObject->DriverExtension;
  116. driverExtension->AddDevice = PiAddDevice;
  117. //
  118. // Store our registry path globally so we can use it later
  119. //
  120. PipRegistryPath.Length = RegistryPath->Length;
  121. PipRegistryPath.MaximumLength = RegistryPath->MaximumLength;
  122. PipRegistryPath.Buffer = ExAllocatePool(PagedPool,
  123. RegistryPath->MaximumLength );
  124. if( PipRegistryPath.Buffer == NULL ){
  125. return STATUS_INSUFFICIENT_RESOURCES;
  126. }
  127. RtlCopyMemory( PipRegistryPath.Buffer,
  128. RegistryPath->Buffer,
  129. RegistryPath->MaximumLength );
  130. //
  131. // Initialize global varaibles
  132. //
  133. KeInitializeEvent (&PipDeviceTreeLock, SynchronizationEvent, TRUE);
  134. KeInitializeEvent (&IsaBusNumberLock, SynchronizationEvent, TRUE);
  135. BusNumBM=&BusNumBMHeader;
  136. RtlInitializeBitMap (BusNumBM,BusNumberBuffer,256/sizeof (ULONG));
  137. RtlClearAllBits (BusNumBM);
  138. #if ISOLATE_CARDS
  139. PipIsolationDisabled = PipIsIsolationDisabled();
  140. #endif
  141. return status;
  142. }