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.

117 lines
3.3 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2000
  3. Module Name:
  4. init.c
  5. Abstract:
  6. This file contains the initialization code for iSCSI port driver.
  7. Environment:
  8. kernel mode only
  9. Revision History:
  10. --*/
  11. #include "port.h"
  12. NTSTATUS
  13. DriverEntry(
  14. IN PDRIVER_OBJECT DriverObject,
  15. IN PUNICODE_STRING RegistryPath
  16. );
  17. #ifdef ALLOC_PRAGMA
  18. #pragma alloc_text(INIT, DriverEntry)
  19. #endif
  20. PEPROCESS iScsiSystemProcess;
  21. NTSTATUS
  22. DriverEntry(
  23. IN PDRIVER_OBJECT DriverObject,
  24. IN PUNICODE_STRING RegistryPath
  25. )
  26. /*+++
  27. Routine Description:
  28. Entry point for the driver.
  29. Arguements:
  30. DriverObject - Pointer to the driver object created by the system.
  31. RegistryPath - Registry path for the driver
  32. Return Value :
  33. STATUS_SUCCESS if initialization was successful
  34. Appropriate NTStatus code on failure
  35. --*/
  36. {
  37. NTSTATUS status;
  38. PISCSIPORT_DRIVER_EXTENSION driverExtension = NULL;
  39. DebugPrint((3, "iSCSI Port DriverEntry\n"));
  40. status = IoAllocateDriverObjectExtension(DriverObject,
  41. (PVOID) ISCSI_TAG_DRIVER_EXTENSION,
  42. sizeof(ISCSIPORT_DRIVER_EXTENSION),
  43. &driverExtension);
  44. if (NT_SUCCESS(status)) {
  45. RtlZeroMemory(driverExtension,
  46. sizeof(ISCSIPORT_DRIVER_EXTENSION));
  47. driverExtension->DriverObject = DriverObject;
  48. driverExtension->RegistryPath.Length = RegistryPath->Length;
  49. driverExtension->RegistryPath.MaximumLength =
  50. RegistryPath->MaximumLength;
  51. driverExtension->RegistryPath.Buffer =
  52. ExAllocatePoolWithTag(PagedPool,
  53. RegistryPath->MaximumLength,
  54. ISCSI_TAG_REGPATH);
  55. if (driverExtension->RegistryPath.Buffer == NULL) {
  56. return STATUS_NO_MEMORY;
  57. }
  58. RtlCopyUnicodeString(&(driverExtension->RegistryPath),
  59. RegistryPath);
  60. } else if (status == STATUS_OBJECT_NAME_COLLISION) {
  61. //
  62. // Extension already exists. Get a pointer to it
  63. //
  64. driverExtension = IoGetDriverObjectExtension(
  65. DriverObject,
  66. (PVOID) ISCSI_TAG_DRIVER_EXTENSION);
  67. ASSERT(driverExtension != NULL);
  68. } else {
  69. DebugPrint((1, "iSCSI : Could not allocate driver extension %lx\n",
  70. status));
  71. return status;
  72. }
  73. //
  74. // Update the driver object with the entry points
  75. //
  76. DriverObject->MajorFunction[IRP_MJ_SCSI] = iScsiPortGlobalDispatch;
  77. DriverObject->MajorFunction[IRP_MJ_CREATE] = iScsiPortGlobalDispatch;
  78. DriverObject->MajorFunction[IRP_MJ_CLOSE] = iScsiPortGlobalDispatch;
  79. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = iScsiPortGlobalDispatch;
  80. DriverObject->MajorFunction[IRP_MJ_PNP] = iScsiPortGlobalDispatch;
  81. DriverObject->MajorFunction[IRP_MJ_POWER] = iScsiPortGlobalDispatch;
  82. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = iScsiPortGlobalDispatch;
  83. DriverObject->DriverUnload = iScsiPortUnload;
  84. DriverObject->DriverExtension->AddDevice = iScsiPortAddDevice;
  85. iScsiSystemProcess = IoGetCurrentProcess ();
  86. return STATUS_SUCCESS;
  87. }