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.

1281 lines
25 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. srb.h
  5. Abstract:
  6. This file defines the interface between SCSI mini-port drivers and the
  7. SCSI port driver. It is also used by SCSI class drivers to talk to the
  8. SCSI port driver.
  9. Author:
  10. Mike Glass
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef _NTSRB_
  15. #define _NTSRB_
  16. #if DBG
  17. #define DebugPrint(x) ScsiDebugPrint x
  18. #else
  19. #define DebugPrint(x)
  20. #endif
  21. //
  22. // Define SCSI maximum configuration parameters.
  23. //
  24. #define SCSI_MAXIMUM_LOGICAL_UNITS 8
  25. #define SCSI_MAXIMUM_TARGETS_PER_BUS 128
  26. #define SCSI_MAXIMUM_LUNS_PER_TARGET 255
  27. #define SCSI_MAXIMUM_BUSES 8
  28. #define SCSI_MINIMUM_PHYSICAL_BREAKS 16
  29. #define SCSI_MAXIMUM_PHYSICAL_BREAKS 255
  30. #define SCSI_COMBINE_BUS_TARGET( Bus, Target ) ( \
  31. ((((UCHAR) (Target)) & ~(0x20 - 1)) << 8) | \
  32. (((UCHAR) (Bus)) << 5) | \
  33. (((UCHAR) (Target)) & (0x20 - 1)))
  34. #define SCSI_DECODE_BUS_TARGET( Value, Bus, Target ) ( \
  35. Bus = (UCHAR) ((Value) >> 5), \
  36. Target = (UCHAR) ((((Value) >> 8) & ~(0x20 - 1)) | ((Value) & (0x20 - 1))))
  37. //
  38. // This constant is for backward compatibility.
  39. // This use to be the maximum number of targets supported.
  40. //
  41. #define SCSI_MAXIMUM_TARGETS 8
  42. typedef PHYSICAL_ADDRESS SCSI_PHYSICAL_ADDRESS, *PSCSI_PHYSICAL_ADDRESS;
  43. typedef struct _ACCESS_RANGE {
  44. SCSI_PHYSICAL_ADDRESS RangeStart;
  45. ULONG RangeLength;
  46. BOOLEAN RangeInMemory;
  47. }ACCESS_RANGE, *PACCESS_RANGE;
  48. //
  49. // Configuration information structure. Contains the information necessary
  50. // to initialize the adapter. NOTE: This structure's must be a multiple of
  51. // quadwords.
  52. //
  53. typedef struct _PORT_CONFIGURATION_INFORMATION {
  54. //
  55. // Length of port configuation information strucuture.
  56. //
  57. ULONG Length;
  58. //
  59. // IO bus number (0 for machines that have only 1 IO bus
  60. //
  61. ULONG SystemIoBusNumber;
  62. //
  63. // EISA, MCA or ISA
  64. //
  65. INTERFACE_TYPE AdapterInterfaceType;
  66. //
  67. // Interrupt request level for device
  68. //
  69. ULONG BusInterruptLevel;
  70. //
  71. // Bus interrupt vector used with hardware buses which use as vector as
  72. // well as level, such as internal buses.
  73. //
  74. ULONG BusInterruptVector;
  75. //
  76. // Interrupt mode (level-sensitive or edge-triggered)
  77. //
  78. KINTERRUPT_MODE InterruptMode;
  79. //
  80. // Maximum number of bytes that can be transferred in a single SRB
  81. //
  82. ULONG MaximumTransferLength;
  83. //
  84. // Number of contiguous blocks of physical memory
  85. //
  86. ULONG NumberOfPhysicalBreaks;
  87. //
  88. // DMA channel for devices using system DMA
  89. //
  90. ULONG DmaChannel;
  91. ULONG DmaPort;
  92. DMA_WIDTH DmaWidth;
  93. DMA_SPEED DmaSpeed;
  94. //
  95. // Alignment masked required by the adapter for data transfers.
  96. //
  97. ULONG AlignmentMask;
  98. //
  99. // Number of access range elements which have been allocated.
  100. //
  101. ULONG NumberOfAccessRanges;
  102. //
  103. // Pointer to array of access range elements.
  104. //
  105. ACCESS_RANGE (*AccessRanges)[];
  106. //
  107. // Reserved field.
  108. //
  109. PVOID Reserved;
  110. //
  111. // Number of SCSI buses attached to the adapter.
  112. //
  113. UCHAR NumberOfBuses;
  114. //
  115. // SCSI bus ID for adapter
  116. //
  117. UCHAR InitiatorBusId[8];
  118. //
  119. // Indicates that the adapter does scatter/gather
  120. //
  121. BOOLEAN ScatterGather;
  122. //
  123. // Indicates that the adapter is a bus master
  124. //
  125. BOOLEAN Master;
  126. //
  127. // Host caches data or state.
  128. //
  129. BOOLEAN CachesData;
  130. //
  131. // Host adapter scans down for bios devices.
  132. //
  133. BOOLEAN AdapterScansDown;
  134. //
  135. // Primary at disk address (0x1F0) claimed.
  136. //
  137. BOOLEAN AtdiskPrimaryClaimed;
  138. //
  139. // Secondary at disk address (0x170) claimed.
  140. //
  141. BOOLEAN AtdiskSecondaryClaimed;
  142. //
  143. // The master uses 32-bit DMA addresses.
  144. //
  145. BOOLEAN Dma32BitAddresses;
  146. //
  147. // Use Demand Mode DMA rather than Single Request.
  148. //
  149. BOOLEAN DemandMode;
  150. //
  151. // Data buffers must be mapped into virtual address space.
  152. //
  153. BOOLEAN MapBuffers;
  154. //
  155. // The driver will need to tranlate virtual to physical addresses.
  156. //
  157. BOOLEAN NeedPhysicalAddresses;
  158. //
  159. // Supports tagged queuing
  160. //
  161. BOOLEAN TaggedQueuing;
  162. //
  163. // Supports auto request sense.
  164. //
  165. BOOLEAN AutoRequestSense;
  166. //
  167. // Supports multiple requests per logical unit.
  168. //
  169. BOOLEAN MultipleRequestPerLu;
  170. //
  171. // Support receive event function.
  172. //
  173. BOOLEAN ReceiveEvent;
  174. //
  175. // Indicates the real-mode driver has initialized the card.
  176. //
  177. BOOLEAN RealModeInitialized;
  178. //
  179. // Indicate that the miniport will not touch the data buffers directly.
  180. //
  181. BOOLEAN BufferAccessScsiPortControlled;
  182. //
  183. // Indicator for wide scsi.
  184. //
  185. UCHAR MaximumNumberOfTargets;
  186. //
  187. // Ensure quadword alignment.
  188. //
  189. UCHAR ReservedUchars[2];
  190. //
  191. // Adapter slot number
  192. //
  193. ULONG SlotNumber;
  194. //
  195. // Interrupt information for a second IRQ.
  196. //
  197. ULONG BusInterruptLevel2;
  198. ULONG BusInterruptVector2;
  199. KINTERRUPT_MODE InterruptMode2;
  200. //
  201. // DMA information for a second channel.
  202. //
  203. ULONG DmaChannel2;
  204. ULONG DmaPort2;
  205. DMA_WIDTH DmaWidth2;
  206. DMA_SPEED DmaSpeed2;
  207. //
  208. // Fields added to allow for the miniport
  209. // to update these sizes based on requirements
  210. // for large transfers ( > 64K);
  211. //
  212. ULONG DeviceExtensionSize;
  213. ULONG SpecificLuExtensionSize;
  214. ULONG SrbExtensionSize;
  215. //
  216. // Used to determine whether the system and/or the miniport support
  217. // 64-bit physical addresses. See SCSI_DMA64_* flags below.
  218. //
  219. UCHAR Dma64BitAddresses; /* New */
  220. //
  221. // Indicates that the miniport can accept a SRB_FUNCTION_RESET_DEVICE
  222. // to clear all requests to a particular LUN.
  223. //
  224. BOOLEAN ResetTargetSupported; /* New */
  225. //
  226. // Indicates that the miniport can support more than 8 logical units per
  227. // target (maximum LUN number is one less than this field).
  228. //
  229. UCHAR MaximumNumberOfLogicalUnits; /* New */
  230. //
  231. // Supports WMI?
  232. //
  233. BOOLEAN WmiDataProvider;
  234. } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
  235. //
  236. // Version control for ConfigInfo structure.
  237. //
  238. #define CONFIG_INFO_VERSION_2 sizeof(PORT_CONFIGURATION_INFORMATION)
  239. //
  240. // Flags for controlling 64-bit DMA use (PORT_CONFIGURATION_INFORMATION field
  241. // Dma64BitAddresses)
  242. //
  243. //
  244. // Set by scsiport on entering HwFindAdapter if the system can support 64-bit
  245. // physical addresses. The miniport can use this information before calling
  246. // ScsiPortGetUncachedExtension to modify the DeviceExtensionSize,
  247. // SpecificLuExtensionSize & SrbExtensionSize fields to account for the extra
  248. // size of the scatter gather list.
  249. //
  250. #define SCSI_DMA64_SYSTEM_SUPPORTED 0x80
  251. //
  252. // Set by the miniport before calling ScsiPortGetUncachedExtension to indicate
  253. // that scsiport should provide it with 64-bit physical addresses. If the
  254. // system does not support 64-bit PA's then this bit will be ignored.
  255. //
  256. #define SCSI_DMA64_MINIPORT_SUPPORTED 0x01
  257. //
  258. // Command type (and parameter) definition(s) for AdapterControl requests.
  259. //
  260. typedef enum _SCSI_ADAPTER_CONTROL_TYPE {
  261. ScsiQuerySupportedControlTypes = 0,
  262. ScsiStopAdapter,
  263. ScsiRestartAdapter,
  264. ScsiSetBootConfig,
  265. ScsiSetRunningConfig,
  266. ScsiAdapterControlMax,
  267. MakeAdapterControlTypeSizeOfUlong = 0xffffffff
  268. } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
  269. //
  270. // Adapter control status values
  271. //
  272. typedef enum _SCSI_ADAPTER_CONTROL_STATUS {
  273. ScsiAdapterControlSuccess = 0,
  274. ScsiAdapterControlUnsuccessful
  275. } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
  276. //
  277. // Parameters for Adapter Control Functions:
  278. //
  279. //
  280. // ScsiQuerySupportedControlTypes:
  281. //
  282. #pragma warning(disable:4200)
  283. typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST {
  284. //
  285. // Specifies the number of entries in the adapter control type list.
  286. //
  287. IN ULONG MaxControlType;
  288. //
  289. // The miniport will set TRUE for each control type it supports.
  290. // The number of entries in this array is defined by MaxAdapterControlType
  291. // - the miniport must not attempt to set any AC types beyond the maximum
  292. // value specified.
  293. //
  294. OUT BOOLEAN SupportedTypeList[0];
  295. } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST;
  296. #pragma warning(default:4200)
  297. //
  298. // Uninitialized flag value.
  299. //
  300. #define SP_UNINITIALIZED_VALUE ((ULONG) ~0)
  301. #define SP_UNTAGGED ((UCHAR) ~0)
  302. //
  303. // Set asynchronous events.
  304. //
  305. #define SRBEV_BUS_RESET 0x0001
  306. #define SRBEV_SCSI_ASYNC_NOTIFICATION 0x0002
  307. // begin_ntminitape
  308. #define MAXIMUM_CDB_SIZE 12
  309. //
  310. // SCSI I/O Request Block
  311. //
  312. typedef struct _SCSI_REQUEST_BLOCK {
  313. USHORT Length; // offset 0
  314. UCHAR Function; // offset 2
  315. UCHAR SrbStatus; // offset 3
  316. UCHAR ScsiStatus; // offset 4
  317. UCHAR PathId; // offset 5
  318. UCHAR TargetId; // offset 6
  319. UCHAR Lun; // offset 7
  320. UCHAR QueueTag; // offset 8
  321. UCHAR QueueAction; // offset 9
  322. UCHAR CdbLength; // offset a
  323. UCHAR SenseInfoBufferLength; // offset b
  324. ULONG SrbFlags; // offset c
  325. ULONG DataTransferLength; // offset 10
  326. ULONG TimeOutValue; // offset 14
  327. PVOID DataBuffer; // offset 18
  328. PVOID SenseInfoBuffer; // offset 1c
  329. struct _SCSI_REQUEST_BLOCK *NextSrb; // offset 20
  330. PVOID OriginalRequest; // offset 24
  331. PVOID SrbExtension; // offset 28
  332. union {
  333. ULONG InternalStatus; // offset 2c
  334. ULONG QueueSortKey; // offset 2c
  335. };
  336. #if defined(_WIN64)
  337. //
  338. // Force PVOID alignment of Cdb
  339. //
  340. ULONG Reserved;
  341. #endif
  342. UCHAR Cdb[16]; // offset 30
  343. } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
  344. #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
  345. //
  346. // SCSI I/O Request Block for WMI Requests
  347. //
  348. typedef struct _SCSI_WMI_REQUEST_BLOCK {
  349. USHORT Length;
  350. UCHAR Function; // SRB_FUNCTION_WMI
  351. UCHAR SrbStatus;
  352. UCHAR WMISubFunction;
  353. UCHAR PathId; // If SRB_WMI_FLAGS_ADAPTER_REQUEST is set in
  354. UCHAR TargetId; // WMIFlags then PathId, TargetId and Lun are
  355. UCHAR Lun; // reserved fields.
  356. UCHAR Reserved1;
  357. UCHAR WMIFlags;
  358. UCHAR Reserved2[2];
  359. ULONG SrbFlags;
  360. ULONG DataTransferLength;
  361. ULONG TimeOutValue;
  362. PVOID DataBuffer;
  363. PVOID DataPath;
  364. PVOID Reserved3;
  365. PVOID OriginalRequest;
  366. PVOID SrbExtension;
  367. ULONG Reserved4;
  368. UCHAR Reserved5[16];
  369. } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
  370. //
  371. // SRB Functions
  372. //
  373. #define SRB_FUNCTION_EXECUTE_SCSI 0x00
  374. #define SRB_FUNCTION_CLAIM_DEVICE 0x01
  375. #define SRB_FUNCTION_IO_CONTROL 0x02
  376. #define SRB_FUNCTION_RECEIVE_EVENT 0x03
  377. #define SRB_FUNCTION_RELEASE_QUEUE 0x04
  378. #define SRB_FUNCTION_ATTACH_DEVICE 0x05
  379. #define SRB_FUNCTION_RELEASE_DEVICE 0x06
  380. #define SRB_FUNCTION_SHUTDOWN 0x07
  381. #define SRB_FUNCTION_FLUSH 0x08
  382. #define SRB_FUNCTION_ABORT_COMMAND 0x10
  383. #define SRB_FUNCTION_RELEASE_RECOVERY 0x11
  384. #define SRB_FUNCTION_RESET_BUS 0x12
  385. #define SRB_FUNCTION_RESET_DEVICE 0x13
  386. #define SRB_FUNCTION_TERMINATE_IO 0x14
  387. #define SRB_FUNCTION_FLUSH_QUEUE 0x15
  388. #define SRB_FUNCTION_REMOVE_DEVICE 0x16
  389. #define SRB_FUNCTION_WMI 0x17
  390. #define SRB_FUNCTION_LOCK_QUEUE 0x18
  391. #define SRB_FUNCTION_UNLOCK_QUEUE 0x19
  392. #define SRB_FUNCTION_RESET_LOGICAL_UNIT 0x20
  393. //
  394. // SRB Status
  395. //
  396. #define SRB_STATUS_PENDING 0x00
  397. #define SRB_STATUS_SUCCESS 0x01
  398. #define SRB_STATUS_ABORTED 0x02
  399. #define SRB_STATUS_ABORT_FAILED 0x03
  400. #define SRB_STATUS_ERROR 0x04
  401. #define SRB_STATUS_BUSY 0x05
  402. #define SRB_STATUS_INVALID_REQUEST 0x06
  403. #define SRB_STATUS_INVALID_PATH_ID 0x07
  404. #define SRB_STATUS_NO_DEVICE 0x08
  405. #define SRB_STATUS_TIMEOUT 0x09
  406. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  407. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  408. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  409. #define SRB_STATUS_BUS_RESET 0x0E
  410. #define SRB_STATUS_PARITY_ERROR 0x0F
  411. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  412. #define SRB_STATUS_NO_HBA 0x11
  413. #define SRB_STATUS_DATA_OVERRUN 0x12
  414. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  415. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  416. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  417. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  418. #define SRB_STATUS_INVALID_LUN 0x20
  419. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  420. #define SRB_STATUS_BAD_FUNCTION 0x22
  421. #define SRB_STATUS_ERROR_RECOVERY 0x23
  422. #define SRB_STATUS_NOT_POWERED 0x24
  423. //
  424. // This value is used by the port driver to indicate that a non-scsi-related
  425. // error occured. Miniports must never return this status.
  426. //
  427. #define SRB_STATUS_INTERNAL_ERROR 0x30
  428. //
  429. // Srb status values 0x38 through 0x3f are reserved for internal port driver
  430. // use.
  431. //
  432. //
  433. // SRB Status Masks
  434. //
  435. #define SRB_STATUS_QUEUE_FROZEN 0x40
  436. #define SRB_STATUS_AUTOSENSE_VALID 0x80
  437. #define SRB_STATUS(Status) (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
  438. //
  439. // SRB Flag Bits
  440. //
  441. #define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002
  442. #define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004
  443. #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008
  444. #define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010
  445. #define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020
  446. #define SRB_FLAGS_DATA_IN 0x00000040
  447. #define SRB_FLAGS_DATA_OUT 0x00000080
  448. #define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
  449. #define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
  450. #define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100
  451. #define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200
  452. #define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400
  453. #define SRB_FLAGS_IS_ACTIVE 0x00010000
  454. #define SRB_FLAGS_ALLOCATED_FROM_ZONE 0x00020000
  455. #define SRB_FLAGS_SGLIST_FROM_POOL 0x00040000
  456. #define SRB_FLAGS_BYPASS_LOCKED_QUEUE 0x00080000
  457. #define SRB_FLAGS_NO_KEEP_AWAKE 0x00100000
  458. #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE 0x00200000
  459. #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT 0x00400000
  460. #define SRB_FLAGS_DONT_START_NEXT_PACKET 0x00800000
  461. #define SRB_FLAGS_PORT_DRIVER_RESERVED 0x0F000000
  462. #define SRB_FLAGS_CLASS_DRIVER_RESERVED 0xF0000000
  463. #if DBG==1
  464. //
  465. // A signature used to validate the scsi port number
  466. // at the end of a sense buffer.
  467. //
  468. #define SCSI_PORT_SIGNATURE 0x54524f50
  469. #endif
  470. //
  471. // Queue Action
  472. //
  473. #define SRB_SIMPLE_TAG_REQUEST 0x20
  474. #define SRB_HEAD_OF_QUEUE_TAG_REQUEST 0x21
  475. #define SRB_ORDERED_QUEUE_TAG_REQUEST 0x22
  476. #define SRB_WMI_FLAGS_ADAPTER_REQUEST 0x01
  477. // end_ntminitape
  478. //
  479. // SCSI Adapter Dependent Routines
  480. //
  481. typedef
  482. BOOLEAN
  483. (*PHW_INITIALIZE) (
  484. IN PVOID DeviceExtension
  485. );
  486. typedef
  487. BOOLEAN
  488. (*PHW_STARTIO) (
  489. IN PVOID DeviceExtension,
  490. IN PSCSI_REQUEST_BLOCK Srb
  491. );
  492. typedef
  493. BOOLEAN
  494. (*PHW_INTERRUPT) (
  495. IN PVOID DeviceExtension
  496. );
  497. typedef
  498. VOID
  499. (*PHW_TIMER) (
  500. IN PVOID DeviceExtension
  501. );
  502. typedef
  503. VOID
  504. (*PHW_DMA_STARTED) (
  505. IN PVOID DeviceExtension
  506. );
  507. typedef
  508. ULONG
  509. (*PHW_FIND_ADAPTER) (
  510. IN PVOID DeviceExtension,
  511. IN PVOID HwContext,
  512. IN PVOID BusInformation,
  513. IN PCHAR ArgumentString,
  514. IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
  515. OUT PBOOLEAN Again
  516. );
  517. typedef
  518. BOOLEAN
  519. (*PHW_RESET_BUS) (
  520. IN PVOID DeviceExtension,
  521. IN ULONG PathId
  522. );
  523. typedef
  524. BOOLEAN
  525. (*PHW_ADAPTER_STATE) (
  526. IN PVOID DeviceExtension,
  527. IN PVOID Context,
  528. IN BOOLEAN SaveState
  529. );
  530. typedef
  531. SCSI_ADAPTER_CONTROL_STATUS
  532. (*PHW_ADAPTER_CONTROL) (
  533. IN PVOID DeviceExtension,
  534. IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
  535. IN PVOID Parameters
  536. );
  537. //
  538. // Port driver error codes
  539. //
  540. #define SP_BUS_PARITY_ERROR 0x0001
  541. #define SP_UNEXPECTED_DISCONNECT 0x0002
  542. #define SP_INVALID_RESELECTION 0x0003
  543. #define SP_BUS_TIME_OUT 0x0004
  544. #define SP_PROTOCOL_ERROR 0x0005
  545. #define SP_INTERNAL_ADAPTER_ERROR 0x0006
  546. #define SP_REQUEST_TIMEOUT 0x0007
  547. #define SP_IRQ_NOT_RESPONDING 0x0008
  548. #define SP_BAD_FW_WARNING 0x0009
  549. #define SP_BAD_FW_ERROR 0x000a
  550. #define SP_LOST_WMI_MINIPORT_REQUEST 0x000b
  551. //
  552. // Return values for SCSI_HW_FIND_ADAPTER.
  553. //
  554. #define SP_RETURN_NOT_FOUND 0
  555. #define SP_RETURN_FOUND 1
  556. #define SP_RETURN_ERROR 2
  557. #define SP_RETURN_BAD_CONFIG 3
  558. //
  559. // Notification Event Types
  560. //
  561. typedef enum _SCSI_NOTIFICATION_TYPE {
  562. RequestComplete,
  563. NextRequest,
  564. NextLuRequest,
  565. ResetDetected,
  566. CallDisableInterrupts,
  567. CallEnableInterrupts,
  568. RequestTimerCall,
  569. BusChangeDetected, /* New */
  570. WMIEvent,
  571. WMIReregister
  572. } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
  573. //
  574. // Structure passed between miniport initialization
  575. // and SCSI port initialization
  576. //
  577. typedef struct _HW_INITIALIZATION_DATA {
  578. ULONG HwInitializationDataSize;
  579. //
  580. // Adapter interface type:
  581. //
  582. // Internal
  583. // Isa
  584. // Eisa
  585. // MicroChannel
  586. // TurboChannel
  587. // PCIBus
  588. // VMEBus
  589. // NuBus
  590. // PCMCIABus
  591. // CBus
  592. // MPIBus
  593. // MPSABus
  594. //
  595. INTERFACE_TYPE AdapterInterfaceType;
  596. //
  597. // Miniport driver routines
  598. //
  599. PHW_INITIALIZE HwInitialize;
  600. PHW_STARTIO HwStartIo;
  601. PHW_INTERRUPT HwInterrupt;
  602. PHW_FIND_ADAPTER HwFindAdapter;
  603. PHW_RESET_BUS HwResetBus;
  604. PHW_DMA_STARTED HwDmaStarted;
  605. PHW_ADAPTER_STATE HwAdapterState;
  606. //
  607. // Miniport driver resources
  608. //
  609. ULONG DeviceExtensionSize;
  610. ULONG SpecificLuExtensionSize;
  611. ULONG SrbExtensionSize;
  612. ULONG NumberOfAccessRanges;
  613. PVOID Reserved;
  614. //
  615. // Data buffers must be mapped into virtual address space.
  616. //
  617. BOOLEAN MapBuffers;
  618. //
  619. // The driver will need to tranlate virtual to physical addresses.
  620. //
  621. BOOLEAN NeedPhysicalAddresses;
  622. //
  623. // Supports tagged queuing
  624. //
  625. BOOLEAN TaggedQueuing;
  626. //
  627. // Supports auto request sense.
  628. //
  629. BOOLEAN AutoRequestSense;
  630. //
  631. // Supports multiple requests per logical unit.
  632. //
  633. BOOLEAN MultipleRequestPerLu;
  634. //
  635. // Support receive event function.
  636. //
  637. BOOLEAN ReceiveEvent;
  638. //
  639. // Vendor identification length
  640. //
  641. USHORT VendorIdLength;
  642. //
  643. // Vendor identification
  644. //
  645. PVOID VendorId;
  646. //
  647. // Pad for alignment and future use.
  648. //
  649. USHORT ReservedUshort;
  650. //
  651. // Device identification length
  652. //
  653. USHORT DeviceIdLength;
  654. //
  655. // Device identification
  656. //
  657. PVOID DeviceId;
  658. //
  659. // Stop adapter routine.
  660. //
  661. PHW_ADAPTER_CONTROL HwAdapterControl;
  662. } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
  663. // begin_ntminitape
  664. #ifndef _NTDDK_
  665. #define SCSIPORT_API DECLSPEC_IMPORT
  666. #else
  667. #define SCSIPORT_API
  668. #endif
  669. // end_ntminitape
  670. //
  671. // Port driver routines called by miniport driver
  672. //
  673. SCSIPORT_API
  674. ULONG
  675. ScsiPortInitialize(
  676. IN PVOID Argument1,
  677. IN PVOID Argument2,
  678. IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
  679. IN PVOID HwContext
  680. );
  681. SCSIPORT_API
  682. VOID
  683. ScsiPortFreeDeviceBase(
  684. IN PVOID HwDeviceExtension,
  685. IN PVOID MappedAddress
  686. );
  687. SCSIPORT_API
  688. ULONG
  689. ScsiPortGetBusData(
  690. IN PVOID DeviceExtension,
  691. IN ULONG BusDataType,
  692. IN ULONG SystemIoBusNumber,
  693. IN ULONG SlotNumber,
  694. IN PVOID Buffer,
  695. IN ULONG Length
  696. );
  697. SCSIPORT_API
  698. ULONG
  699. ScsiPortSetBusDataByOffset(
  700. IN PVOID DeviceExtension,
  701. IN ULONG BusDataType,
  702. IN ULONG SystemIoBusNumber,
  703. IN ULONG SlotNumber,
  704. IN PVOID Buffer,
  705. IN ULONG Offset,
  706. IN ULONG Length
  707. );
  708. SCSIPORT_API
  709. PVOID
  710. ScsiPortGetDeviceBase(
  711. IN PVOID HwDeviceExtension,
  712. IN INTERFACE_TYPE BusType,
  713. IN ULONG SystemIoBusNumber,
  714. IN SCSI_PHYSICAL_ADDRESS IoAddress,
  715. IN ULONG NumberOfBytes,
  716. IN BOOLEAN InIoSpace
  717. );
  718. SCSIPORT_API
  719. PVOID
  720. ScsiPortGetLogicalUnit(
  721. IN PVOID HwDeviceExtension,
  722. IN UCHAR PathId,
  723. IN UCHAR TargetId,
  724. IN UCHAR Lun
  725. );
  726. SCSIPORT_API
  727. PSCSI_REQUEST_BLOCK
  728. ScsiPortGetSrb(
  729. IN PVOID DeviceExtension,
  730. IN UCHAR PathId,
  731. IN UCHAR TargetId,
  732. IN UCHAR Lun,
  733. IN LONG QueueTag
  734. );
  735. SCSIPORT_API
  736. SCSI_PHYSICAL_ADDRESS
  737. ScsiPortGetPhysicalAddress(
  738. IN PVOID HwDeviceExtension,
  739. IN PSCSI_REQUEST_BLOCK Srb,
  740. IN PVOID VirtualAddress,
  741. OUT ULONG *Length
  742. );
  743. SCSIPORT_API
  744. PVOID
  745. ScsiPortGetVirtualAddress(
  746. IN PVOID HwDeviceExtension,
  747. IN SCSI_PHYSICAL_ADDRESS PhysicalAddress
  748. );
  749. SCSIPORT_API
  750. PVOID
  751. ScsiPortGetUncachedExtension(
  752. IN PVOID HwDeviceExtension,
  753. IN PPORT_CONFIGURATION_INFORMATION ConfigInfo,
  754. IN ULONG NumberOfBytes
  755. );
  756. SCSIPORT_API
  757. VOID
  758. ScsiPortFlushDma(
  759. IN PVOID DeviceExtension
  760. );
  761. SCSIPORT_API
  762. VOID
  763. ScsiPortIoMapTransfer(
  764. IN PVOID HwDeviceExtension,
  765. IN PSCSI_REQUEST_BLOCK Srb,
  766. IN PVOID LogicalAddress,
  767. IN ULONG Length
  768. );
  769. SCSIPORT_API
  770. VOID
  771. ScsiPortNotification(
  772. IN SCSI_NOTIFICATION_TYPE NotificationType,
  773. IN PVOID HwDeviceExtension,
  774. ...
  775. );
  776. SCSIPORT_API
  777. VOID
  778. ScsiPortLogError(
  779. IN PVOID HwDeviceExtension,
  780. IN PSCSI_REQUEST_BLOCK Srb OPTIONAL,
  781. IN UCHAR PathId,
  782. IN UCHAR TargetId,
  783. IN UCHAR Lun,
  784. IN ULONG ErrorCode,
  785. IN ULONG UniqueId
  786. );
  787. SCSIPORT_API
  788. VOID
  789. ScsiPortCompleteRequest(
  790. IN PVOID HwDeviceExtension,
  791. IN UCHAR PathId,
  792. IN UCHAR TargetId,
  793. IN UCHAR Lun,
  794. IN UCHAR SrbStatus
  795. );
  796. SCSIPORT_API
  797. VOID
  798. ScsiPortMoveMemory(
  799. IN PVOID WriteBuffer,
  800. IN PVOID ReadBuffer,
  801. IN ULONG Length
  802. );
  803. SCSIPORT_API
  804. UCHAR
  805. ScsiPortReadPortUchar(
  806. IN PUCHAR Port
  807. );
  808. SCSIPORT_API
  809. USHORT
  810. ScsiPortReadPortUshort(
  811. IN PUSHORT Port
  812. );
  813. SCSIPORT_API
  814. ULONG
  815. ScsiPortReadPortUlong(
  816. IN PULONG Port
  817. );
  818. SCSIPORT_API
  819. VOID
  820. ScsiPortReadPortBufferUchar(
  821. IN PUCHAR Port,
  822. IN PUCHAR Buffer,
  823. IN ULONG Count
  824. );
  825. SCSIPORT_API
  826. VOID
  827. ScsiPortReadPortBufferUshort(
  828. IN PUSHORT Port,
  829. IN PUSHORT Buffer,
  830. IN ULONG Count
  831. );
  832. SCSIPORT_API
  833. VOID
  834. ScsiPortReadPortBufferUlong(
  835. IN PULONG Port,
  836. IN PULONG Buffer,
  837. IN ULONG Count
  838. );
  839. SCSIPORT_API
  840. UCHAR
  841. ScsiPortReadRegisterUchar(
  842. IN PUCHAR Register
  843. );
  844. SCSIPORT_API
  845. USHORT
  846. ScsiPortReadRegisterUshort(
  847. IN PUSHORT Register
  848. );
  849. SCSIPORT_API
  850. ULONG
  851. ScsiPortReadRegisterUlong(
  852. IN PULONG Register
  853. );
  854. SCSIPORT_API
  855. VOID
  856. ScsiPortReadRegisterBufferUchar(
  857. IN PUCHAR Register,
  858. IN PUCHAR Buffer,
  859. IN ULONG Count
  860. );
  861. SCSIPORT_API
  862. VOID
  863. ScsiPortReadRegisterBufferUshort(
  864. IN PUSHORT Register,
  865. IN PUSHORT Buffer,
  866. IN ULONG Count
  867. );
  868. SCSIPORT_API
  869. VOID
  870. ScsiPortReadRegisterBufferUlong(
  871. IN PULONG Register,
  872. IN PULONG Buffer,
  873. IN ULONG Count
  874. );
  875. SCSIPORT_API
  876. VOID
  877. ScsiPortStallExecution(
  878. IN ULONG Delay
  879. );
  880. SCSIPORT_API
  881. VOID
  882. ScsiPortWritePortUchar(
  883. IN PUCHAR Port,
  884. IN UCHAR Value
  885. );
  886. SCSIPORT_API
  887. VOID
  888. ScsiPortWritePortUshort(
  889. IN PUSHORT Port,
  890. IN USHORT Value
  891. );
  892. SCSIPORT_API
  893. VOID
  894. ScsiPortWritePortUlong(
  895. IN PULONG Port,
  896. IN ULONG Value
  897. );
  898. SCSIPORT_API
  899. VOID
  900. ScsiPortWritePortBufferUchar(
  901. IN PUCHAR Port,
  902. IN PUCHAR Buffer,
  903. IN ULONG Count
  904. );
  905. SCSIPORT_API
  906. VOID
  907. ScsiPortWritePortBufferUshort(
  908. IN PUSHORT Port,
  909. IN PUSHORT Buffer,
  910. IN ULONG Count
  911. );
  912. SCSIPORT_API
  913. VOID
  914. ScsiPortWritePortBufferUlong(
  915. IN PULONG Port,
  916. IN PULONG Buffer,
  917. IN ULONG Count
  918. );
  919. SCSIPORT_API
  920. VOID
  921. ScsiPortWriteRegisterUchar(
  922. IN PUCHAR Register,
  923. IN UCHAR Value
  924. );
  925. SCSIPORT_API
  926. VOID
  927. ScsiPortWriteRegisterUshort(
  928. IN PUSHORT Register,
  929. IN USHORT Value
  930. );
  931. SCSIPORT_API
  932. VOID
  933. ScsiPortWriteRegisterUlong(
  934. IN PULONG Register,
  935. IN ULONG Value
  936. );
  937. SCSIPORT_API
  938. VOID
  939. ScsiPortWriteRegisterBufferUchar(
  940. IN PUCHAR Register,
  941. IN PUCHAR Buffer,
  942. IN ULONG Count
  943. );
  944. SCSIPORT_API
  945. VOID
  946. ScsiPortWriteRegisterBufferUshort(
  947. IN PUSHORT Register,
  948. IN PUSHORT Buffer,
  949. IN ULONG Count
  950. );
  951. SCSIPORT_API
  952. VOID
  953. ScsiPortWriteRegisterBufferUlong(
  954. IN PULONG Register,
  955. IN PULONG Buffer,
  956. IN ULONG Count
  957. );
  958. SCSIPORT_API
  959. SCSI_PHYSICAL_ADDRESS
  960. ScsiPortConvertUlongToPhysicalAddress(
  961. ULONG_PTR UlongAddress
  962. );
  963. SCSIPORT_API
  964. ULONG
  965. ScsiPortConvertPhysicalAddressToUlong(
  966. SCSI_PHYSICAL_ADDRESS Address
  967. );
  968. SCSIPORT_API
  969. VOID
  970. ScsiPortQuerySystemTime(
  971. OUT PLARGE_INTEGER CurrentTime
  972. );
  973. #define ScsiPortConvertPhysicalAddressToUlong(Address) ((Address).LowPart)
  974. //
  975. // Sundown Note:
  976. // For now, ScsiPortConvertPhysicalAddressToULongPtr() exists only as a macro.
  977. //
  978. #define ScsiPortConvertPhysicalAddressToULongPtr(Address) ((ULONG_PTR)((Address).QuadPart))
  979. SCSIPORT_API
  980. BOOLEAN
  981. ScsiPortValidateRange(
  982. IN PVOID HwDeviceExtension,
  983. IN INTERFACE_TYPE BusType,
  984. IN ULONG SystemIoBusNumber,
  985. IN SCSI_PHYSICAL_ADDRESS IoAddress,
  986. IN ULONG NumberOfBytes,
  987. IN BOOLEAN InIoSpace
  988. );
  989. // begin_ntminitape
  990. SCSIPORT_API
  991. VOID
  992. ScsiDebugPrint(
  993. ULONG DebugPrintLevel,
  994. PCCHAR DebugMessage,
  995. ...
  996. );
  997. // end_ntminitape
  998. #endif //