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.

119 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. NTSTATUS
  21. DriverEntry(
  22. IN PDRIVER_OBJECT DriverObject,
  23. IN PUNICODE_STRING RegistryPath
  24. )
  25. /*+++
  26. Routine Description:
  27. Entry point for the driver.
  28. Arguements:
  29. DriverObject - Pointer to the driver object created by the system.
  30. RegistryPath - Registry path for the driver
  31. Return Value :
  32. STATUS_SUCCESS if initialization was successful
  33. Appropriate NTStatus code on failure
  34. --*/
  35. {
  36. NTSTATUS status;
  37. PISCSIPORT_DRIVER_EXTENSION driverExtension = NULL;
  38. DebugPrint((3, "iSCSI Port DriverEntry\n"));
  39. status = IoAllocateDriverObjectExtension(DriverObject,
  40. (PVOID) ISCSI_TAG_DRIVER_EXTENSION,
  41. sizeof(ISCSIPORT_DRIVER_EXTENSION),
  42. &driverExtension);
  43. if (NT_SUCCESS(status)) {
  44. RtlZeroMemory(driverExtension,
  45. sizeof(ISCSIPORT_DRIVER_EXTENSION));
  46. driverExtension->DriverObject = DriverObject;
  47. driverExtension->RegistryPath.Length = RegistryPath->Length;
  48. driverExtension->RegistryPath.MaximumLength =
  49. RegistryPath->MaximumLength;
  50. driverExtension->RegistryPath.Buffer =
  51. ExAllocatePoolWithTag(PagedPool,
  52. RegistryPath->MaximumLength,
  53. ISCSI_TAG_REGPATH);
  54. if (driverExtension->RegistryPath.Buffer == NULL) {
  55. return STATUS_NO_MEMORY;
  56. }
  57. RtlCopyUnicodeString(&(driverExtension->RegistryPath),
  58. RegistryPath);
  59. //
  60. // Hard code bus type for now
  61. //
  62. driverExtension->BusType = BusTypeScsi;
  63. } else if (status == STATUS_OBJECT_NAME_COLLISION) {
  64. //
  65. // Extension already exists. Get a pointer to it
  66. //
  67. driverExtension = IoGetDriverObjectExtension(
  68. DriverObject,
  69. (PVOID) ISCSI_TAG_DRIVER_EXTENSION);
  70. ASSERT(driverExtension != NULL);
  71. } else {
  72. DebugPrint((1, "iSCSI : Could not allocate driver extension %lx\n",
  73. status));
  74. return status;
  75. }
  76. //
  77. // Update the driver object with the entry points
  78. //
  79. DriverObject->MajorFunction[IRP_MJ_SCSI] = iScsiPortGlobalDispatch;
  80. DriverObject->MajorFunction[IRP_MJ_CREATE] = iScsiPortGlobalDispatch;
  81. DriverObject->MajorFunction[IRP_MJ_CLOSE] = iScsiPortGlobalDispatch;
  82. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = iScsiPortGlobalDispatch;
  83. DriverObject->MajorFunction[IRP_MJ_PNP] = iScsiPortGlobalDispatch;
  84. DriverObject->MajorFunction[IRP_MJ_POWER] = iScsiPortGlobalDispatch;
  85. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = iScsiPortGlobalDispatch;
  86. DriverObject->DriverUnload = iScsiPortUnload;
  87. DriverObject->DriverExtension->AddDevice = iScsiPortAddDevice;
  88. return STATUS_SUCCESS;
  89. }