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.

200 lines
5.0 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, MinBlockSize) \
  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. if (MinBlockSize) { \
  62. BlockSize = 1 << count; \
  63. } else { \
  64. BlockSize = 1 << (count - 1); \
  65. } \
  66. } \
  67. } \
  68. }
  69. //
  70. // Tape class driver extension
  71. //
  72. typedef struct _TAPE_DATA {
  73. TAPE_INIT_DATA_EX TapeInitData;
  74. KSPIN_LOCK SplitRequestSpinLock;
  75. LARGE_INTEGER LastDriveCleanRequestTime;
  76. UNICODE_STRING TapeInterfaceString;
  77. ULONG SrbTimeoutDelta;
  78. BOOLEAN DosNameCreated;
  79. } TAPE_DATA, *PTAPE_DATA;
  80. //
  81. // WMI routines
  82. //
  83. NTSTATUS
  84. TapeQueryWmiRegInfo(
  85. IN PDEVICE_OBJECT DeviceObject,
  86. OUT ULONG *RegFlags,
  87. OUT PUNICODE_STRING InstanceName
  88. );
  89. NTSTATUS
  90. TapeQueryWmiDataBlock(
  91. IN PDEVICE_OBJECT DeviceObject,
  92. IN PIRP Irp,
  93. IN ULONG GuidIndex,
  94. IN ULONG BufferAvail,
  95. OUT PUCHAR Buffer
  96. );
  97. NTSTATUS
  98. TapeSetWmiDataBlock(
  99. IN PDEVICE_OBJECT DeviceObject,
  100. IN PIRP Irp,
  101. IN ULONG GuidIndex,
  102. IN ULONG BufferSize,
  103. IN PUCHAR Buffer
  104. );
  105. NTSTATUS
  106. TapeSetWmiDataItem(
  107. IN PDEVICE_OBJECT DeviceObject,
  108. IN PIRP Irp,
  109. IN ULONG GuidIndex,
  110. IN ULONG DataItemId,
  111. IN ULONG BufferSize,
  112. IN PUCHAR Buffer
  113. );
  114. NTSTATUS
  115. TapeExecuteWmiMethod(
  116. IN PDEVICE_OBJECT DeviceObject,
  117. IN PIRP Irp,
  118. IN ULONG GuidIndex,
  119. IN ULONG MethodId,
  120. IN ULONG InBufferSize,
  121. IN ULONG OutBufferSize,
  122. IN PUCHAR Buffer
  123. );
  124. NTSTATUS
  125. TapeWmiFunctionControl(
  126. IN PDEVICE_OBJECT DeviceObject,
  127. IN PIRP Irp,
  128. IN ULONG GuidIndex,
  129. IN CLASSENABLEDISABLEFUNCTION Function,
  130. IN BOOLEAN Enable
  131. );
  132. //
  133. // Internal routines
  134. //
  135. NTSTATUS
  136. TapeWMIControl(
  137. IN PDEVICE_OBJECT DeviceObject,
  138. IN TAPE_PROCESS_COMMAND_ROUTINE commandRoutine,
  139. IN PUCHAR Buffer
  140. );
  141. VOID
  142. ScsiTapeFreeSrbBuffer(
  143. IN OUT PSCSI_REQUEST_BLOCK Srb
  144. );
  145. BOOLEAN
  146. ScsiTapeTapeStatusToNtStatus(
  147. IN TAPE_STATUS TapeStatus,
  148. OUT PNTSTATUS NtStatus
  149. );
  150. BOOLEAN
  151. ScsiTapeNtStatusToTapeStatus(
  152. IN NTSTATUS NtStatus,
  153. OUT PTAPE_STATUS TapeStatus
  154. );
  155. NTSTATUS
  156. TapeEnableDisableDrivePolling(
  157. IN PFUNCTIONAL_DEVICE_EXTENSION fdoExtension,
  158. IN BOOLEAN Enable,
  159. IN ULONG PollingTimeInSeconds
  160. );
  161. ULONG
  162. GetTimeoutDeltaFromRegistry(
  163. IN PDEVICE_OBJECT LowerPdo
  164. );
  165. #endif // _TAPE_H_