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.

388 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. diskdump.h
  5. Abstract:
  6. This file defines the necessary structures, defines, and functions for
  7. the common SCSI boot port driver.
  8. Author:
  9. Mike Glass (Ported from Jeff Havens and Mike Glass loader development.)
  10. Revision History:
  11. --*/
  12. #include "ntddscsi.h"
  13. #define INITIAL_MEMORY_BLOCK_SIZE 0x2000
  14. #define MAXIMUM_TRANSFER_SIZE 0x10000
  15. #define MINIMUM_TRANSFER_SIZE 0x8000
  16. //
  17. // SCSI Get Configuration Information
  18. //
  19. // LUN Information
  20. //
  21. typedef struct _LUNINFO {
  22. UCHAR PathId;
  23. UCHAR TargetId;
  24. UCHAR Lun;
  25. BOOLEAN DeviceClaimed;
  26. PVOID DeviceObject;
  27. struct _LUNINFO *NextLunInfo;
  28. UCHAR InquiryData[INQUIRYDATABUFFERSIZE];
  29. } LUNINFO, *PLUNINFO;
  30. typedef struct _SCSI_BUS_SCAN_DATA {
  31. USHORT Length;
  32. UCHAR InitiatorBusId;
  33. UCHAR NumberOfLogicalUnits;
  34. PLUNINFO LunInfoList;
  35. } SCSI_BUS_SCAN_DATA, *PSCSI_BUS_SCAN_DATA;
  36. typedef struct _SCSI_CONFIGURATION_INFO {
  37. UCHAR NumberOfBuses;
  38. PSCSI_BUS_SCAN_DATA BusScanData[1];
  39. } SCSI_CONFIGURATION_INFO, *PSCSI_CONFIGURATION_INFO;
  40. #define MAXIMUM_RETRIES 4
  41. //
  42. // System provided stall routine.
  43. //
  44. typedef
  45. VOID
  46. (*PSTALL_ROUTINE) (
  47. IN ULONG Delay
  48. );
  49. //
  50. // Define memory block header -- ensure always quad-aligned (code assumes that
  51. // it is always aligned)
  52. //
  53. typedef struct _MEMORY_HEADER {
  54. struct _MEMORY_HEADER *Next;
  55. PVOID Address;
  56. ULONG Length;
  57. ULONG Spare;
  58. } MEMORY_HEADER, *PMEMORY_HEADER;
  59. //
  60. // SCSI device timeout values in seconds
  61. //
  62. #define SCSI_DISK_TIMEOUT 10
  63. //
  64. // Adapter object transfer information.
  65. //
  66. typedef struct _ADAPTER_TRANSFER {
  67. PSCSI_REQUEST_BLOCK Srb;
  68. PVOID LogicalAddress;
  69. ULONG Length;
  70. } ADAPTER_TRANSFER, *PADAPTER_TRANSFER;
  71. typedef struct _DUMP_SCATTER_GATHER_LIST {
  72. ULONG NumberOfElements;
  73. ULONG_PTR Reserved;
  74. SCATTER_GATHER_ELEMENT Elements[17];
  75. } DUMP_SCATTER_GATHER_LIST, *PDUMP_SCATTER_GATHER_LIST;
  76. //
  77. // Check that this is the same as the DDK's definition.
  78. //
  79. C_ASSERT (FIELD_OFFSET (DUMP_SCATTER_GATHER_LIST, Elements) ==
  80. FIELD_OFFSET (SCATTER_GATHER_LIST, Elements));
  81. typedef enum _PORT_TYPE {
  82. ScsiPort = 1,
  83. StorPort = 2
  84. } PORT_TYPE;
  85. //
  86. // Device extension
  87. //
  88. typedef struct _DEVICE_EXTENSION {
  89. PDEVICE_OBJECT DeviceObject;
  90. PSTALL_ROUTINE StallRoutine;
  91. PPORT_CONFIGURATION_INFORMATION ConfigurationInformation;
  92. //
  93. // Port driver we are operating on: SCSIPORT or STORPORT.
  94. //
  95. PORT_TYPE PortType;
  96. //
  97. // Partition information
  98. //
  99. LARGE_INTEGER PartitionOffset;
  100. //
  101. // Memory management
  102. //
  103. //
  104. PMEMORY_HEADER FreeMemory;
  105. PVOID CommonBuffer[2];
  106. PHYSICAL_ADDRESS PhysicalAddress[2];
  107. PHYSICAL_ADDRESS LogicalAddress[2];
  108. //
  109. // SRBs
  110. //
  111. SCSI_REQUEST_BLOCK Srb;
  112. SCSI_REQUEST_BLOCK RequestSenseSrb;
  113. //
  114. // Current request
  115. //
  116. UCHAR PathId;
  117. UCHAR TargetId;
  118. UCHAR Lun;
  119. ULONG LuFlags;
  120. PMDL Mdl;
  121. PVOID SpecificLuExtension;
  122. LONG RequestTimeoutCounter;
  123. ULONG RetryCount;
  124. ULONG ByteCount;
  125. DUMP_SCATTER_GATHER_LIST ScatterGatherList;
  126. //
  127. // Noncached breakout.
  128. //
  129. PVOID NonCachedExtension;
  130. ULONG NonCachedExtensionSize;
  131. PSENSE_DATA RequestSenseBuffer;
  132. PVOID SrbExtension;
  133. ULONG SrbExtensionSize;
  134. //
  135. // Dma Adapter information.
  136. //
  137. PVOID MapRegisterBase[2];
  138. PADAPTER_OBJECT DmaAdapterObject;
  139. ADAPTER_TRANSFER FlushAdapterParameters;
  140. ULONG NumberOfMapRegisters;
  141. //
  142. // Number of SCSI buses
  143. //
  144. UCHAR NumberOfBuses;
  145. //
  146. // Maximum targets per bus
  147. //
  148. UCHAR MaximumTargetIds;
  149. //
  150. // Disk block size
  151. //
  152. ULONG BytesPerSector;
  153. //
  154. // Sector shift count
  155. //
  156. ULONG SectorShift;
  157. //
  158. // SCSI Capabilities structure
  159. //
  160. IO_SCSI_CAPABILITIES Capabilities;
  161. //
  162. // SCSI configuration information from inquiries.
  163. //
  164. LUNINFO LunInfo;
  165. //
  166. // SCSI port driver flags
  167. //
  168. ULONG Flags;
  169. //
  170. // SCSI port interrupt flags
  171. //
  172. ULONG InterruptFlags;
  173. //
  174. // Adapter object transfer parameters.
  175. //
  176. ADAPTER_TRANSFER MapTransferParameters;
  177. KSPIN_LOCK SpinLock;
  178. //
  179. // Mapped address list
  180. //
  181. PMAPPED_ADDRESS MappedAddressList;
  182. //
  183. // Miniport entry points
  184. //
  185. PHW_INITIALIZE HwInitialize;
  186. PHW_STARTIO HwStartIo;
  187. PHW_INTERRUPT HwInterrupt;
  188. PHW_RESET_BUS HwReset;
  189. PHW_DMA_STARTED HwDmaStarted;
  190. PHW_BUILDIO HwBuildIo;
  191. //
  192. // Buffers must be mapped into system space.
  193. //
  194. BOOLEAN MapBuffers;
  195. //
  196. // Is this device a bus master and does it require map registers.
  197. //
  198. BOOLEAN MasterWithAdapter;
  199. //
  200. // Indicates that adapter with boot device has been found.
  201. //
  202. BOOLEAN FoundBootDevice;
  203. //
  204. // Device extension for miniport routines.
  205. //
  206. PVOID HwDeviceExtension;
  207. //
  208. // Miniport request interrupt enabled/disable routine.
  209. //
  210. PHW_INTERRUPT HwRequestInterrupt;
  211. //
  212. // Miniport timer request routine.
  213. //
  214. PHW_INTERRUPT HwTimerRequest;
  215. //
  216. // Indicates request has been submitted to miniport and
  217. // has not yet been completed.
  218. //
  219. BOOLEAN RequestPending;
  220. //
  221. // Indicates that request has been completed.
  222. //
  223. BOOLEAN RequestComplete;
  224. //
  225. // Physical address of zone pool
  226. //
  227. ULONG PhysicalZoneBase;
  228. //
  229. // Logical Unit Extension
  230. //
  231. ULONG HwLogicalUnitExtensionSize;
  232. ULONG TimerValue;
  233. //
  234. // Value is set to true when the dump is done. We use this so that
  235. // we don't do a request sense incase one of the shutdown operations
  236. // fail.
  237. //
  238. BOOLEAN FinishingUp;
  239. //
  240. // The common buffer size is saved during initialization
  241. //
  242. ULONG CommonBufferSize;
  243. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  244. #define DEVICE_EXTENSION_SIZE sizeof(DEVICE_EXTENSION)
  245. //
  246. // Port driver extension flags.
  247. //
  248. #define PD_CURRENT_IRP_VALID 0X0001
  249. #define PD_RESET_DETECTED 0X0002
  250. #define PD_NOTIFICATION_IN_PROGRESS 0X0004
  251. #define PD_READY_FOR_NEXT_REQUEST 0X0008
  252. #define PD_FLUSH_ADAPTER_BUFFERS 0X0010
  253. #define PD_MAP_TRANSFER 0X0020
  254. #define PD_CALL_DMA_STARTED 0X01000
  255. #define PD_DISABLE_CALL_REQUEST 0X02000
  256. #define PD_DISABLE_INTERRUPTS 0X04000
  257. #define PD_ENABLE_CALL_REQUEST 0X08000
  258. #define PD_TIMER_CALL_REQUEST 0X10000
  259. //
  260. // Logical unit extension flags.
  261. //
  262. #define PD_QUEUE_FROZEN 0X0001
  263. #define PD_LOGICAL_UNIT_IS_ACTIVE 0X0002
  264. #define PD_CURRENT_REQUEST_COMPLETE 0X0004
  265. #define PD_LOGICAL_UNIT_IS_BUSY 0X0008
  266. //
  267. // The timer interval for the miniport timer routine specified in
  268. // units of 100 nanoseconds.
  269. //
  270. #define PD_TIMER_INTERVAL (250 * 1000 * 10) // 250 ms
  271. //
  272. // The define the interloop stall.
  273. //
  274. #define PD_INTERLOOP_STALL 5
  275. #define COMPLETION_DELAY 10
  276. //
  277. // Define global data structures
  278. //
  279. extern ULONG ScsiPortCount;
  280. //
  281. // Define HalFlushIoBuffers for i386 and AMD64.
  282. //
  283. #if defined(i386) || defined(_AMD64_)
  284. #define HalFlushIoBuffers
  285. #endif