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.

196 lines
4.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999
  3. Module Name:
  4. tape.h
  5. Abstract:
  6. SCSI tape class driver
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef _TAPE_H_
  13. #define _TAPE_H_
  14. #include "ntddk.h"
  15. #include "newtape.h"
  16. #include "classpnp.h"
  17. #include <wmidata.h>
  18. #include <wmistr.h>
  19. #include "initguid.h"
  20. #include "ntddstor.h"
  21. #include "ioevent.h"
  22. #include <stdarg.h>
  23. #include <string.h>
  24. //
  25. // WMI guid list for tape.
  26. //
  27. extern GUIDREGINFO TapeWmiGuidList[];
  28. //
  29. // NT uses a system time measured in 100 nanosecond intervals.
  30. // Define convenient constant for the timer routines.
  31. //
  32. #define ONE_SECOND (10 * 1000 * 1000)
  33. //
  34. // Time interval between two drive clean notification - 1 Hour
  35. //
  36. #define TAPE_DRIVE_CLEAN_NOTIFICATION_INTERVAL 60 * 60
  37. //
  38. // Poll the tape drive every one hour
  39. //
  40. #define TAPE_DRIVE_POLLING_PERIOD 60 * 60
  41. //
  42. // Macro to update block size.
  43. // If the given blocksize is not a power of 2, this macro
  44. // sets the blocksize to the next lower power of 2
  45. //
  46. #define UPDATE_BLOCK_SIZE(BlockSize) \
  47. { \
  48. ULONG newBlockSize; \
  49. ULONG count; \
  50. \
  51. newBlockSize = BlockSize; \
  52. if ((newBlockSize & (newBlockSize - 1)) != 0) { \
  53. \
  54. count = 0; \
  55. while (newBlockSize > 0) { \
  56. newBlockSize >>= 1; \
  57. count++; \
  58. } \
  59. \
  60. if (count > 0) { \
  61. BlockSize = 1 << (count - 1); \
  62. } \
  63. } \
  64. }
  65. //
  66. // Tape class driver extension
  67. //
  68. typedef struct _TAPE_DATA {
  69. TAPE_INIT_DATA_EX TapeInitData;
  70. KSPIN_LOCK SplitRequestSpinLock;
  71. LARGE_INTEGER LastDriveCleanRequestTime;
  72. UNICODE_STRING TapeInterfaceString;
  73. ULONG SrbTimeoutDelta;
  74. BOOLEAN DosNameCreated;
  75. } TAPE_DATA, *PTAPE_DATA;
  76. //
  77. // WMI routines
  78. //
  79. NTSTATUS
  80. TapeQueryWmiRegInfo(
  81. IN PDEVICE_OBJECT DeviceObject,
  82. OUT ULONG *RegFlags,
  83. OUT PUNICODE_STRING InstanceName
  84. );
  85. NTSTATUS
  86. TapeQueryWmiDataBlock(
  87. IN PDEVICE_OBJECT DeviceObject,
  88. IN PIRP Irp,
  89. IN ULONG GuidIndex,
  90. IN ULONG BufferAvail,
  91. OUT PUCHAR Buffer
  92. );
  93. NTSTATUS
  94. TapeSetWmiDataBlock(
  95. IN PDEVICE_OBJECT DeviceObject,
  96. IN PIRP Irp,
  97. IN ULONG GuidIndex,
  98. IN ULONG BufferSize,
  99. IN PUCHAR Buffer
  100. );
  101. NTSTATUS
  102. TapeSetWmiDataItem(
  103. IN PDEVICE_OBJECT DeviceObject,
  104. IN PIRP Irp,
  105. IN ULONG GuidIndex,
  106. IN ULONG DataItemId,
  107. IN ULONG BufferSize,
  108. IN PUCHAR Buffer
  109. );
  110. NTSTATUS
  111. TapeExecuteWmiMethod(
  112. IN PDEVICE_OBJECT DeviceObject,
  113. IN PIRP Irp,
  114. IN ULONG GuidIndex,
  115. IN ULONG MethodId,
  116. IN ULONG InBufferSize,
  117. IN ULONG OutBufferSize,
  118. IN PUCHAR Buffer
  119. );
  120. NTSTATUS
  121. TapeWmiFunctionControl(
  122. IN PDEVICE_OBJECT DeviceObject,
  123. IN PIRP Irp,
  124. IN ULONG GuidIndex,
  125. IN CLASSENABLEDISABLEFUNCTION Function,
  126. IN BOOLEAN Enable
  127. );
  128. //
  129. // Internal routines
  130. //
  131. NTSTATUS
  132. TapeWMIControl(
  133. IN PDEVICE_OBJECT DeviceObject,
  134. IN TAPE_PROCESS_COMMAND_ROUTINE commandRoutine,
  135. IN PUCHAR Buffer
  136. );
  137. VOID
  138. ScsiTapeFreeSrbBuffer(
  139. IN OUT PSCSI_REQUEST_BLOCK Srb
  140. );
  141. BOOLEAN
  142. ScsiTapeTapeStatusToNtStatus(
  143. IN TAPE_STATUS TapeStatus,
  144. OUT PNTSTATUS NtStatus
  145. );
  146. BOOLEAN
  147. ScsiTapeNtStatusToTapeStatus(
  148. IN NTSTATUS NtStatus,
  149. OUT PTAPE_STATUS TapeStatus
  150. );
  151. NTSTATUS
  152. TapeEnableDisableDrivePolling(
  153. IN PFUNCTIONAL_DEVICE_EXTENSION fdoExtension,
  154. IN BOOLEAN Enable,
  155. IN ULONG PollingTimeInSeconds
  156. );
  157. ULONG
  158. GetTimeoutDeltaFromRegistry(
  159. IN PDEVICE_OBJECT LowerPdo
  160. );
  161. #endif // _TAPE_H_