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.

1316 lines
38 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. STRMINI.H
  5. Abstract:
  6. This file defines streaming minidriver structures and class/minidriver
  7. interfaces.
  8. Author:
  9. billpa
  10. Environment:
  11. Kernel mode only
  12. Revision History:
  13. --*/
  14. #ifndef _STREAM_H
  15. #define _STREAM_H
  16. #include <wdm.h>
  17. #include <windef.h>
  18. #include <stdio.h>
  19. #include "ks.h"
  20. #define STREAMAPI __stdcall
  21. typedef unsigned __int64 STREAM_SYSTEM_TIME,
  22. *PSTREAM_SYSTEM_TIME;
  23. typedef unsigned __int64 STREAM_TIMESTAMP,
  24. *PSTREAM_TIMESTAMP;
  25. #define STREAM_SYSTEM_TIME_MASK ((STREAM_SYSTEM_TIME)0x00000001FFFFFFFF)
  26. //
  27. // debug print level values
  28. //
  29. typedef enum { // Use the given level to indicate:
  30. DebugLevelFatal = 0, // * imminent nonrecoverable system failure
  31. DebugLevelError, // * serious error, though recoverable
  32. DebugLevelWarning, // * warnings of unusual occurances
  33. DebugLevelInfo, // * status and other information - normal
  34. // though
  35. // perhaps unusual events. System MUST remain
  36. // responsive.
  37. DebugLevelTrace, // * trace information - normal events
  38. // system need not ramain responsive
  39. DebugLevelVerbose, // * verbose trace information
  40. // system need not remain responsive
  41. DebugLevelMaximum
  42. } STREAM_DEBUG_LEVEL;
  43. #define DebugLevelAlways DebugLevelFatal
  44. #if DBG
  45. //
  46. // macro for printing debug information
  47. //
  48. #define DebugPrint(x) StreamClassDebugPrint x
  49. //
  50. // macro for doing INT 3 (or non-x86 equivalent)
  51. //
  52. #if WIN95_BUILD
  53. #define DEBUG_BREAKPOINT() _asm int 3;
  54. #else
  55. #define DEBUG_BREAKPOINT() DbgBreakPoint()
  56. #endif
  57. //
  58. // macro for asserting (stops if not = TRUE)
  59. //
  60. #define DEBUG_ASSERT(exp) \
  61. if ( !(exp) ) { \
  62. StreamClassDebugAssert( __FILE__, __LINE__, #exp, exp); \
  63. }
  64. #else
  65. #define DebugPrint(x)
  66. #define DEBUG_BREAKPOINT()
  67. #define DEBUG_ASSERT(exp)
  68. #endif
  69. //
  70. // Uninitialized flag value.
  71. //
  72. #define MP_UNINITIALIZED_VALUE ((ULONG) ~0)
  73. //
  74. // define physical address formats
  75. //
  76. typedef PHYSICAL_ADDRESS STREAM_PHYSICAL_ADDRESS,
  77. *PSTREAM_PHYSICAL_ADDRESS;
  78. //
  79. // functions for the time context structure below
  80. //
  81. typedef enum {
  82. TIME_GET_STREAM_TIME,
  83. TIME_READ_ONBOARD_CLOCK,
  84. TIME_SET_ONBOARD_CLOCK
  85. } TIME_FUNCTION;
  86. //
  87. // define the time context structure
  88. //
  89. typedef struct _HW_TIME_CONTEXT {
  90. struct _HW_DEVICE_EXTENSION *HwDeviceExtension;
  91. struct _HW_STREAM_OBJECT *HwStreamObject;
  92. TIME_FUNCTION Function;
  93. ULONGLONG Time;
  94. ULONGLONG SystemTime;
  95. } HW_TIME_CONTEXT, *PHW_TIME_CONTEXT;
  96. //
  97. // define the event descriptor for enabling/disabling events.
  98. //
  99. typedef struct _HW_EVENT_DESCRIPTOR {
  100. BOOLEAN Enable; // TRUE means this is an enable, FALSE means disable
  101. PKSEVENT_ENTRY EventEntry; // event structure
  102. PKSEVENTDATA EventData; // data representing this event
  103. union {
  104. struct _HW_STREAM_OBJECT * StreamObject; // stream object for the event
  105. struct _HW_DEVICE_EXTENSION *DeviceExtension;
  106. };
  107. ULONG EnableEventSetIndex; // gives the index of the event set for ENABLE
  108. // field has no meaning for DISABLE
  109. PVOID HwInstanceExtension;
  110. ULONG Reserved;
  111. } HW_EVENT_DESCRIPTOR, *PHW_EVENT_DESCRIPTOR;
  112. //
  113. // function prototypes for stream object functions
  114. //
  115. typedef VOID
  116. (STREAMAPI * PHW_RECEIVE_STREAM_DATA_SRB) ( // HwReceiveDataPacket
  117. IN struct _HW_STREAM_REQUEST_BLOCK * SRB
  118. );
  119. typedef VOID
  120. (STREAMAPI * PHW_RECEIVE_STREAM_CONTROL_SRB) ( // HwReceiveControlPacket
  121. IN struct _HW_STREAM_REQUEST_BLOCK * SRB
  122. );
  123. typedef NTSTATUS
  124. (STREAMAPI * PHW_EVENT_ROUTINE) ( // HwEventRoutine
  125. IN PHW_EVENT_DESCRIPTOR EventDescriptor
  126. );
  127. typedef VOID
  128. (STREAMAPI * PHW_CLOCK_FUNCTION) ( // HwClockFunction
  129. IN PHW_TIME_CONTEXT HwTimeContext
  130. );
  131. //
  132. // define the clock object
  133. //
  134. typedef struct _HW_CLOCK_OBJECT {
  135. //
  136. // pointer to the minidriver's clock function
  137. //
  138. PHW_CLOCK_FUNCTION HwClockFunction;
  139. //
  140. // support flags as defined below
  141. //
  142. ULONG ClockSupportFlags;
  143. ULONG Reserved[2]; // Reserved for future use
  144. } HW_CLOCK_OBJECT, *PHW_CLOCK_OBJECT;
  145. //
  146. // clock object support flags defined as follows
  147. //
  148. //
  149. // indicates that the minidriver's clock for this stream is tunable
  150. // via TIME_SET_ONBOARD_CLOCK
  151. //
  152. #define CLOCK_SUPPORT_CAN_SET_ONBOARD_CLOCK 0x00000001
  153. //
  154. // indicates that the minidriver's clock for this stream is raw readable
  155. // via TIME_READ_ONBOARD_CLOCK
  156. //
  157. #define CLOCK_SUPPORT_CAN_READ_ONBOARD_CLOCK 0x00000002
  158. //
  159. // indicates that the minidriver can return the current stream time for this
  160. // stream via TIME_GET_STREAM_TIME
  161. //
  162. #define CLOCK_SUPPORT_CAN_RETURN_STREAM_TIME 0x00000004
  163. //
  164. // stream object definition
  165. //
  166. typedef struct _HW_STREAM_OBJECT {
  167. ULONG SizeOfThisPacket; // size of this structure
  168. ULONG StreamNumber; // number of this stream
  169. PVOID HwStreamExtension; // minidriver's stream extension
  170. PHW_RECEIVE_STREAM_DATA_SRB ReceiveDataPacket; // receive data packet routine
  171. PHW_RECEIVE_STREAM_CONTROL_SRB ReceiveControlPacket; // receive control packet routine
  172. HW_CLOCK_OBJECT HwClockObject; // clock object to be filled in by
  173. // minidriver
  174. BOOLEAN Dma; // device uses busmaster DMA
  175. // for this stream
  176. BOOLEAN Pio; // device uses PIO for this
  177. PVOID HwDeviceExtension; // minidriver's device ext.
  178. ULONG StreamHeaderMediaSpecific; // Size of media specific per
  179. // stream header expansion.
  180. ULONG StreamHeaderWorkspace; // Size of per-stream header workspace.
  181. BOOLEAN Allocator; // Set to TRUE if allocator is needed for this stream.
  182. //
  183. // the following routine receives ENABLE and DISABLE notification of
  184. // KS synchronization events for this stream.
  185. //
  186. PHW_EVENT_ROUTINE HwEventRoutine;
  187. ULONG Reserved[2]; // Reserved for future use
  188. } HW_STREAM_OBJECT, *PHW_STREAM_OBJECT;
  189. //
  190. // the following structures are used to report which stream types and properties
  191. // are supported by the minidriver. the HW_STREAM_HEADER structure is followed
  192. // in memory by one or more HW_STREAM_INFORMATION structures. See the
  193. // HW_STREAM_DESCRIPTOR structure below.
  194. //
  195. typedef struct _HW_STREAM_HEADER {
  196. //
  197. // indicates the number of HW_STREAM_INFORMATION structures follow this
  198. // structure.
  199. //
  200. ULONG NumberOfStreams;
  201. //
  202. // size of the HW_STREAM_INFORMATION structure below (filled in by the
  203. // minidriver)
  204. //
  205. ULONG SizeOfHwStreamInformation;
  206. //
  207. // indicates the number of property sets supported by the device itself.
  208. //
  209. ULONG NumDevPropArrayEntries;
  210. //
  211. // pointer to the array of device property sets.
  212. //
  213. PKSPROPERTY_SET DevicePropertiesArray;
  214. //
  215. // indicates the number of event sets supported by the device itself.
  216. //
  217. ULONG NumDevEventArrayEntries;
  218. //
  219. // pointer to the array of device property sets.
  220. //
  221. PKSEVENT_SET DeviceEventsArray;
  222. //
  223. // pointer to the topology structure
  224. //
  225. PKSTOPOLOGY Topology;
  226. //
  227. // event routine for processing device events, if any.
  228. //
  229. PHW_EVENT_ROUTINE DeviceEventRoutine;
  230. LONG NumDevMethodArrayEntries;
  231. PKSMETHOD_SET DeviceMethodsArray;
  232. } HW_STREAM_HEADER, *PHW_STREAM_HEADER;
  233. //
  234. // the HW_STREAM_INFORMATION structure(s) indicate what streams are supported
  235. //
  236. typedef struct _HW_STREAM_INFORMATION {
  237. //
  238. // number of possible instances of this stream that can be opened at once
  239. //
  240. ULONG NumberOfPossibleInstances;
  241. //
  242. // Indicates the direction of data flow of this stream
  243. //
  244. KSPIN_DATAFLOW DataFlow;
  245. //
  246. // Indicates whether the data is "seen" by the host processor. If the
  247. // data is not visible to the processor (such as an NTSC output port)
  248. // this boolean is set to false.
  249. //
  250. BOOLEAN DataAccessible;
  251. //
  252. // Number of formats supported by this stream. Indicates the number of
  253. // elements pointed to by StreamFormatsArray below.
  254. //
  255. ULONG NumberOfFormatArrayEntries;
  256. //
  257. // pointer to an array of elements indicating what types of data are
  258. // supported with this stream.
  259. //
  260. PKSDATAFORMAT* StreamFormatsArray;
  261. //
  262. // reserved for future use.
  263. //
  264. PVOID ClassReserved[4];
  265. //
  266. // number of property sets supported by this stream
  267. //
  268. ULONG NumStreamPropArrayEntries;
  269. //
  270. // pointer to an array of property set descriptors for this stream
  271. //
  272. PKSPROPERTY_SET StreamPropertiesArray;
  273. //
  274. // number of event sets supported by this stream
  275. //
  276. ULONG NumStreamEventArrayEntries;
  277. //
  278. // pointer to an array of event set descriptors for this stream
  279. //
  280. PKSEVENT_SET StreamEventsArray;
  281. //
  282. // pointer to guid representing catagory of stream. (optional)
  283. //
  284. GUID* Category;
  285. //
  286. // pointer to guid representing name of stream. (optional)
  287. //
  288. GUID* Name;
  289. //
  290. // count of media supported (optional)
  291. //
  292. ULONG MediumsCount;
  293. //
  294. // pointer to array of media (optional)
  295. //
  296. const KSPIN_MEDIUM* Mediums;
  297. //
  298. // indicates that this stream is a bridge stream (COMMUNICATIONS BRIDGE)
  299. // this field should be set to FALSE by most minidrivers.
  300. //
  301. BOOLEAN BridgeStream;
  302. ULONG Reserved[2]; // Reserved for future use
  303. } HW_STREAM_INFORMATION, *PHW_STREAM_INFORMATION;
  304. typedef struct _HW_STREAM_DESCRIPTOR {
  305. //
  306. // header as defined above
  307. //
  308. HW_STREAM_HEADER StreamHeader;
  309. //
  310. // one or more of the following, as indicated by NumberOfStreams in the
  311. // header.
  312. //
  313. HW_STREAM_INFORMATION StreamInfo;
  314. } HW_STREAM_DESCRIPTOR, *PHW_STREAM_DESCRIPTOR;
  315. //
  316. // STREAM Time Reference structure
  317. //
  318. typedef struct _STREAM_TIME_REFERENCE {
  319. STREAM_TIMESTAMP CurrentOnboardClockValue; // current value of adapter
  320. // clock
  321. LARGE_INTEGER OnboardClockFrequency; // frequency of adapter clock
  322. LARGE_INTEGER CurrentSystemTime; // KeQueryPeformanceCounter time
  323. ULONG Reserved[2]; // Reserved for future use
  324. } STREAM_TIME_REFERENCE, *PSTREAM_TIME_REFERENCE;
  325. //
  326. // data intersection structure. this structure is point to by the
  327. // Srb->CommandData.IntersectInfo field of the SRB on an
  328. // SRB_GET_DATA_INTERSECTION operation.
  329. //
  330. typedef struct _STREAM_DATA_INTERSECT_INFO {
  331. //
  332. // stream number to check
  333. //
  334. ULONG StreamNumber;
  335. //
  336. // pointer to the input data range to verify.
  337. //
  338. PKSDATARANGE DataRange;
  339. //
  340. // pointer to buffer which receives the format block if successful
  341. //
  342. PVOID DataFormatBuffer;
  343. //
  344. // size of the above buffer. set to sizeof(ULONG) if the caller just
  345. // wants to know what size is needed.
  346. //
  347. ULONG SizeOfDataFormatBuffer;
  348. } STREAM_DATA_INTERSECT_INFO, *PSTREAM_DATA_INTERSECT_INFO;
  349. //
  350. // stream property descriptor structure. this descriptor is referenced in
  351. // Srb->CommandData.PropertyInfo field of the SRB on an SRB_GET or
  352. // SRB_SET_PROPERTY operation.
  353. //
  354. typedef struct _STREAM_PROPERTY_DESCRIPTOR {
  355. //
  356. // pointer to the property GUID and ID
  357. //
  358. PKSPROPERTY Property;
  359. //
  360. // zero-based ID of the property, which is an index into the array of
  361. // property sets filled in by the minidriver.
  362. //
  363. ULONG PropertySetID;
  364. //
  365. // pointer to the information about the property (or the space to return
  366. // the information) passed in by the client
  367. //
  368. PVOID PropertyInfo;
  369. //
  370. // size of the client's input buffer
  371. //
  372. ULONG PropertyInputSize;
  373. //
  374. // size of the client's output buffer
  375. //
  376. ULONG PropertyOutputSize;
  377. } STREAM_PROPERTY_DESCRIPTOR, *PSTREAM_PROPERTY_DESCRIPTOR;
  378. typedef struct _STREAM_METHOD_DESCRIPTOR {
  379. ULONG MethodSetID;
  380. PKSMETHOD Method;
  381. PVOID MethodInfo;
  382. LONG MethodInputSize;
  383. LONG MethodOutputSize;
  384. } STREAM_METHOD_DESCRIPTOR, *PSTREAM_METHOD_DESCRIPTOR;
  385. //
  386. // STREAM I/O Request Block (SRB) structures and functions
  387. //
  388. #define STREAM_REQUEST_BLOCK_SIZE sizeof(STREAM_REQUEST_BLOCK)
  389. //
  390. // SRB command codes
  391. //
  392. typedef enum _SRB_COMMAND {
  393. //
  394. // stream specific codes follow
  395. //
  396. SRB_READ_DATA, // read data from hardware
  397. SRB_WRITE_DATA, // write data to the hardware
  398. SRB_GET_STREAM_STATE, // get the state of the stream
  399. SRB_SET_STREAM_STATE, // set the state of the stream
  400. SRB_SET_STREAM_PROPERTY, // set a property of the stream
  401. SRB_GET_STREAM_PROPERTY, // get a property value for the stream
  402. SRB_OPEN_MASTER_CLOCK, // indicates that the master clock is on this
  403. // stream
  404. SRB_INDICATE_MASTER_CLOCK, // supplies the handle to the master clock
  405. SRB_UNKNOWN_STREAM_COMMAND, // IRP function is unknown to class driver
  406. SRB_SET_STREAM_RATE, // set the rate at which the stream should run
  407. SRB_PROPOSE_DATA_FORMAT, // propose a new format, DOES NOT CHANGE IT!
  408. SRB_CLOSE_MASTER_CLOCK, // indicates that the master clock is closed
  409. SRB_PROPOSE_STREAM_RATE, // propose a new rate, DOES NOT CHANGE IT!
  410. SRB_SET_DATA_FORMAT, // sets a new data format
  411. SRB_GET_DATA_FORMAT, // returns the current data format
  412. SRB_BEGIN_FLUSH, // beginning flush state
  413. SRB_END_FLUSH, // ending flush state
  414. //
  415. // device/instance specific codes follow
  416. //
  417. SRB_GET_STREAM_INFO = 0x100,// get the stream information structure
  418. SRB_OPEN_STREAM, // open the specified stream
  419. SRB_CLOSE_STREAM, // close the specified stream
  420. SRB_OPEN_DEVICE_INSTANCE, // open an instance of the device
  421. SRB_CLOSE_DEVICE_INSTANCE, // close an instance of the device
  422. SRB_GET_DEVICE_PROPERTY, // get a property of the device
  423. SRB_SET_DEVICE_PROPERTY, // set a property for the device
  424. SRB_INITIALIZE_DEVICE, // initialize the device
  425. SRB_CHANGE_POWER_STATE, // change power state
  426. SRB_UNINITIALIZE_DEVICE, // uninitialize the device
  427. SRB_UNKNOWN_DEVICE_COMMAND, // IRP function is unknown to class driver
  428. SRB_PAGING_OUT_DRIVER, // indicates that the driver is to be paged out
  429. // only sent if enabled in registry. board ints
  430. // should be disabled & STATUS_SUCCESS returned.
  431. SRB_GET_DATA_INTERSECTION, // returns stream data intersection
  432. SRB_INITIALIZATION_COMPLETE,// indicates init sequence has completed
  433. SRB_SURPRISE_REMOVAL, // indicates surprise removal of HW has occurred
  434. SRB_DEVICE_METHOD,
  435. SRB_STREAM_METHOD,
  436. } SRB_COMMAND;
  437. //
  438. // definition for scatter/gather
  439. //
  440. typedef struct {
  441. PHYSICAL_ADDRESS PhysicalAddress;
  442. ULONG Length;
  443. } KSSCATTER_GATHER, *PKSSCATTER_GATHER;
  444. typedef struct _HW_STREAM_REQUEST_BLOCK {
  445. ULONG SizeOfThisPacket; // sizeof STREAM_REQUEST_BLOCK
  446. // (version check)
  447. SRB_COMMAND Command; // SRB command, see SRB_COMMAND enumeration
  448. NTSTATUS Status; // SRB completion status
  449. PHW_STREAM_OBJECT StreamObject;
  450. // minidriver's stream object for this request
  451. PVOID HwDeviceExtension; // minidriver's device ext.
  452. PVOID SRBExtension; // per-request workspace for the
  453. // minidriver
  454. //
  455. // the following union passes in the information needed for the various
  456. // SRB
  457. // functions.
  458. //
  459. union _CommandData {
  460. //
  461. // pointer to the data descriptor for SRB_READ or SRB_WRITE_DATA
  462. //
  463. PKSSTREAM_HEADER DataBufferArray;
  464. //
  465. // pointer to the stream descriptor for SRB_GET_STREAM_INFO
  466. //
  467. PHW_STREAM_DESCRIPTOR StreamBuffer;
  468. //
  469. // pointer to the state for SRB_GET or SRB_SET_DEVICE_STATE
  470. //
  471. KSSTATE StreamState;
  472. //
  473. // pointer to the time structure for SRB_GET and
  474. // SRB_SET_ONBOARD_CLOCK
  475. //
  476. PSTREAM_TIME_REFERENCE TimeReference;
  477. //
  478. // pointer to the property descriptor for SRB_GET and
  479. // SRB_SET_PROPERTY
  480. //
  481. PSTREAM_PROPERTY_DESCRIPTOR PropertyInfo;
  482. //
  483. // pointer to the requested format for SRB_OPEN_STREAM and
  484. // SRB_PROPOSE_DATA_FORMAT
  485. //
  486. PKSDATAFORMAT OpenFormat;
  487. //
  488. // pointer to the PORT_CONFIGURATION_INFORMATION struct for
  489. // SRB_INITIALIZE_DEVICE
  490. //
  491. struct _PORT_CONFIGURATION_INFORMATION *ConfigInfo;
  492. //
  493. // handle to the master clock.
  494. //
  495. HANDLE MasterClockHandle;
  496. //
  497. // power state
  498. //
  499. DEVICE_POWER_STATE DeviceState;
  500. //
  501. // data intersection info
  502. //
  503. PSTREAM_DATA_INTERSECT_INFO IntersectInfo;
  504. PVOID MethodInfo;
  505. //
  506. // Filter type index for OPEN_DEVICE_INSTANCE
  507. //
  508. LONG FilterTypeIndex;
  509. } CommandData;// union for command data
  510. //
  511. // field for indicating the number of KSSTREM_HEADER elements pointed to
  512. // by the DataBufferArray field above.
  513. //
  514. ULONG NumberOfBuffers;
  515. //
  516. // the following fields are used to time the request. The class driver
  517. // will set both of these fields to a nonzero value when the request
  518. // is received by the minidriver, and then begin counting down the
  519. // TimeoutCounter field until it reaches zero. When it reaches zero,
  520. // the minidriver's timeout handler will be called. If the minidriver
  521. // queues a request for a long time, it should set the TimeoutCounter to
  522. // zero to turn off the timer, and once the request is dequeued should
  523. // set the TimeoutCounter field to the value in TimeoutOriginal.
  524. //
  525. ULONG TimeoutCounter; // timer countdown value in seconds
  526. ULONG TimeoutOriginal; // original timeout value in seconds
  527. struct _HW_STREAM_REQUEST_BLOCK *NextSRB;
  528. // link field available to minidriver for queuing
  529. PIRP Irp; // pointer to original IRP, usually not
  530. // needed.
  531. ULONG Flags; // flags defined below.
  532. //
  533. // To indicate the filter instance extension
  534. //
  535. PVOID HwInstanceExtension;
  536. // pointer to the instance extension
  537. //
  538. // the following union is used to indicate to the minidriver the amount
  539. // of data to transfer, and used by the minidriver to report the amount
  540. // of data it was actually able to transfer.
  541. //
  542. union {
  543. ULONG NumberOfBytesToTransfer;
  544. ULONG ActualBytesTransferred;
  545. };
  546. PKSSCATTER_GATHER ScatterGatherBuffer; // buffer pointing to array
  547. // of s/g elements
  548. ULONG NumberOfPhysicalPages; // # of physical pages in request
  549. ULONG NumberOfScatterGatherElements;
  550. // # of physical elements pointed
  551. // to by ScatterGatherBuffer
  552. ULONG Reserved[1]; // Reserved for future use
  553. } HW_STREAM_REQUEST_BLOCK, *PHW_STREAM_REQUEST_BLOCK;
  554. //
  555. // flags definitions for CRB
  556. //
  557. //
  558. // this flag indicates that the request is either an SRB_READ_DATA or
  559. // SRB_WRITE_DATA request, as opposed to a non-data request.
  560. //
  561. #define SRB_HW_FLAGS_DATA_TRANSFER 0x00000001
  562. //
  563. // this flag indicates that the request is for a stream, as opposed to being
  564. // for the device.
  565. //
  566. #define SRB_HW_FLAGS_STREAM_REQUEST 0x00000002
  567. //
  568. // Structure defining the buffer types for StreamClassGetPhysicalAddress.
  569. //
  570. typedef enum {
  571. PerRequestExtension, // indicates the phys address of the SRB
  572. // extension
  573. DmaBuffer, // indicates the phys address of the DMA
  574. // buffer
  575. SRBDataBuffer // indicates the phys address of a data
  576. // buffer
  577. } STREAM_BUFFER_TYPE;
  578. //
  579. // Structure for I/O and Memory address ranges
  580. //
  581. typedef struct _ACCESS_RANGE {
  582. STREAM_PHYSICAL_ADDRESS RangeStart; // start of the range
  583. ULONG RangeLength;// length of the range
  584. BOOLEAN RangeInMemory; // FALSE if a port address
  585. ULONG Reserved; //
  586. } ACCESS_RANGE, *PACCESS_RANGE;
  587. //
  588. // Configuration information structure. Contains the information necessary
  589. // to initialize the adapter.
  590. //
  591. typedef struct _PORT_CONFIGURATION_INFORMATION {
  592. ULONG SizeOfThisPacket; // Size of this structure, used as
  593. // version check
  594. PVOID HwDeviceExtension; // minidriver's device extension
  595. //
  596. // the below field supplies a pointer to the device's functional
  597. // device object, which is created by stream class.
  598. // Most minidrivers will not need to use this.
  599. //
  600. PDEVICE_OBJECT ClassDeviceObject; // class driver's FDO
  601. //
  602. // the below field supplies a pointer to the device's "attached" physical
  603. // device object, which is returned from IoAttachDeviceToDeviceStack.
  604. // Most minidrivers will not need to use this.
  605. // This PDO must be used for calls to IoCallDriver. See the note below
  606. // for the RealPhysicalDeviceObject, and also see WDM documentation.
  607. //
  608. PDEVICE_OBJECT PhysicalDeviceObject; // attached physical device object
  609. ULONG SystemIoBusNumber; // IO bus number (0 for machines that
  610. // have
  611. // only 1 IO bus)
  612. INTERFACE_TYPE AdapterInterfaceType; // Adapter interface type
  613. // supported by HBA:
  614. // Internal
  615. // Isa
  616. // Eisa
  617. // MicroChannel
  618. // TurboChannel
  619. // PCIBus
  620. // VMEBus
  621. // NuBus
  622. // PCMCIABus
  623. // CBus
  624. // MPIBus
  625. // MPSABus
  626. ULONG BusInterruptLevel; // interrupt level
  627. ULONG BusInterruptVector; // interrupt vector
  628. KINTERRUPT_MODE InterruptMode; // interrupt mode (latched, level)
  629. ULONG DmaChannel; // DMA channel
  630. //
  631. // Specifies the number of AccessRanges elements in the array,
  632. // described next. The OS-specific class driver always sets this
  633. // member to the value passed in the HW_INITIALIZATION_DATA
  634. // structure when the minidriver driver called CodecXXXInitialize.
  635. //
  636. ULONG NumberOfAccessRanges; // Number of access ranges
  637. // allocated
  638. //
  639. // Points to the first element of an array of ACCESS_RANGE-type elements.
  640. // The given NumberOfAccessRanges determines how many elements must be
  641. // configured with bus-relative range values. The AccessRanges
  642. // pointer must be NULL if NumberOfAccessRanges is zero.
  643. //
  644. PACCESS_RANGE AccessRanges; // Pointer to array of access range
  645. // elements
  646. //
  647. // the following field is filled in by the minidriver to indicate the
  648. // size of the buffer needed to build the HW_STREAM_DESCRIPTOR structure
  649. // and all of its substructures.
  650. //
  651. ULONG StreamDescriptorSize; // size of the stream descriptor
  652. PIRP Irp; // IRP for PNP start function, normally
  653. // not used by the minidriver.
  654. //
  655. // the following field indicates the interrupt object for the adapter
  656. // if nonzero. This field is normally not used by the minidriver.
  657. //
  658. PKINTERRUPT InterruptObject;
  659. //
  660. // the following field indicates the DMA adapter object for the adapter
  661. // if nonzero. This field is normally not used by the minidriver.
  662. //
  663. PADAPTER_OBJECT DmaAdapterObject;
  664. //
  665. // the below field supplies a pointer to the device's "real" physical
  666. // device object, which is supplied on the AddDevice call. Most
  667. // minidrivers will not need to use this.
  668. // This PDO must be used for registry access, etc. See the note above
  669. // for the PhysicalDeviceObject, and also see WDM documentation.
  670. //
  671. PDEVICE_OBJECT RealPhysicalDeviceObject; // real physical device object
  672. ULONG Reserved[1]; // Reserved for future use
  673. } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
  674. //
  675. // Function prototypes for minidriver routines called by the class driver
  676. //
  677. typedef VOID
  678. (STREAMAPI * PHW_RECEIVE_DEVICE_SRB) ( // HwReceivePacket
  679. // routine
  680. IN PHW_STREAM_REQUEST_BLOCK SRB
  681. );
  682. typedef VOID
  683. (STREAMAPI * PHW_CANCEL_SRB) ( // HwCancelPacket routine
  684. IN PHW_STREAM_REQUEST_BLOCK SRB
  685. );
  686. typedef VOID
  687. (STREAMAPI * PHW_REQUEST_TIMEOUT_HANDLER) ( // HwRequestTimeoutHandle
  688. //
  689. // r routine
  690. IN PHW_STREAM_REQUEST_BLOCK SRB
  691. );
  692. typedef BOOLEAN
  693. (STREAMAPI * PHW_INTERRUPT) ( // HwInterrupt routine
  694. IN PVOID DeviceExtension
  695. );
  696. typedef VOID
  697. (STREAMAPI * PHW_TIMER_ROUTINE) ( // timer callback routine
  698. IN PVOID Context
  699. );
  700. typedef VOID
  701. (STREAMAPI * PHW_PRIORITY_ROUTINE) ( // change priority
  702. // callback routine
  703. IN PVOID Context
  704. );
  705. typedef VOID
  706. (STREAMAPI * PHW_QUERY_CLOCK_ROUTINE) ( // query clock
  707. // callback routine
  708. IN PHW_TIME_CONTEXT TimeContext
  709. );
  710. typedef BOOLEAN
  711. (STREAMAPI * PHW_RESET_ADAPTER) ( // HwResetAdapter routine
  712. IN PVOID DeviceExtension
  713. );
  714. //
  715. // Minidriver stream notification types passed in to StreamClassStreamNotification
  716. // follow.
  717. //
  718. typedef enum _STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE {
  719. //
  720. // indicates that the minidriver is ready for the next stream data
  721. // request
  722. //
  723. ReadyForNextStreamDataRequest,
  724. //
  725. // indicates that the minidriver is ready for the next stream control
  726. // request
  727. //
  728. ReadyForNextStreamControlRequest,
  729. //
  730. // indicates that the hardware is starved for data
  731. //
  732. HardwareStarved,
  733. //
  734. // indicates that the specified STREAM SRB has completed
  735. //
  736. StreamRequestComplete,
  737. SignalMultipleStreamEvents,
  738. SignalStreamEvent,
  739. DeleteStreamEvent,
  740. StreamNotificationMaximum
  741. } STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE, *PSTREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE;
  742. //
  743. // Minidriver device notification types passed in to StreamClassDeviceNotification
  744. // follow.
  745. //
  746. // notes for SignalMultipleDeviceEvents and SignalMultipleDeviceInstanceEvents:
  747. //
  748. // SignalMultipleDeviceEvents: should only be used by single instance legacy drivers
  749. // SignalMultipleDeviceInstanceEvents: this should be used by multiple instance drivers
  750. // These types are used by StreamClassDeviceNotification().
  751. //
  752. // When SignalMultipleDeviceEvents is used the function should be called
  753. // as StreamClassDeviceNotification( SignalMultipleDeviceEvents,
  754. // pHwDeviceExtension,
  755. // pEventGUID,
  756. // EventItem);
  757. //
  758. // When SignalMultipleDeviceInstanceEvents is used the function should be passed in
  759. // as StreamClassDeviceNotification( SignalMultipleDeviceInstanceEvents,
  760. // pHwDeviceExtension,
  761. // pHwInstanceExtesnion,
  762. // pEventGUID,
  763. // EventItem);
  764. //
  765. typedef enum _STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE {
  766. //
  767. // indicates that the minidriver is ready for the next device request
  768. //
  769. ReadyForNextDeviceRequest,
  770. //
  771. // indicates that the specified DEVICE SRB has completed
  772. //
  773. DeviceRequestComplete,
  774. SignalMultipleDeviceEvents,
  775. SignalDeviceEvent,
  776. DeleteDeviceEvent,
  777. SignalMultipleDeviceInstanceEvents,
  778. DeviceNotificationMaximum
  779. } STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE, *PSTREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE;
  780. //
  781. // Structure passed between minidriver initialization
  782. // and STREAM class initialization
  783. //
  784. typedef struct _HW_INITIALIZATION_DATA {
  785. union {
  786. //
  787. // This first 4 bytes was used as a field for the size of this structure.
  788. // We split this field into 2 ushorts to contain the size of this packet
  789. // and a version number which stream class driver uses to recognize that
  790. // the last two fields, NumNameExtensions and NameExtensionArray are valid
  791. // information instead of uninitialized ramdom values. We hereby designate
  792. // the StreamClassVersion to be 0x0200.
  793. //
  794. #define STREAM_CLASS_VERSION_20 0x0200
  795. ULONG HwInitializationDataSize; // Size of this structure,
  796. struct {
  797. USHORT SizeOfThisPacket; // Size of this packet.
  798. USHORT StreamClassVersion; // Must be 0x0200
  799. };
  800. };
  801. //
  802. // minidriver routines follow
  803. //
  804. PHW_INTERRUPT HwInterrupt;// minidriver's interrupt routine
  805. PHW_RECEIVE_DEVICE_SRB HwReceivePacket;
  806. // minidriver's request routine
  807. PHW_CANCEL_SRB HwCancelPacket;
  808. // minidriver's cancel routine
  809. PHW_REQUEST_TIMEOUT_HANDLER HwRequestTimeoutHandler;
  810. // minidriver's timeout handler routine
  811. //
  812. // minidriver resources follow
  813. //
  814. ULONG DeviceExtensionSize; // size in bytes of the
  815. // minidrivers
  816. // per-adapter device extension data
  817. ULONG PerRequestExtensionSize; // size of per-request
  818. // workspace
  819. ULONG PerStreamExtensionSize; // size of per-stream workspace
  820. ULONG FilterInstanceExtensionSize; // size of the filter
  821. // instance extension
  822. BOOLEAN BusMasterDMA; // Adapter uses bus master DMA for
  823. // one or more streams
  824. BOOLEAN Dma24BitAddresses; // TRUE indicates 24 bit DMA only
  825. // (ISA)
  826. ULONG BufferAlignment; // buffer alignment mask
  827. //
  828. // the following BOOLEAN should be set to FALSE unless the minidriver
  829. // can deal with multiprocessor reentrancy issues!
  830. //
  831. BOOLEAN TurnOffSynchronization;
  832. //
  833. // size of DMA buffer needed by minidriver. The minidriver may obtain
  834. // its DMA buffer by calling StreamClassGetDmaBuffer while or after
  835. // SRB_INITIALIZE_DEVICE is received.
  836. //
  837. ULONG DmaBufferSize;
  838. //
  839. // A version 20 mini driver must specify the following two fields.
  840. // It specifies a name for each type. The names will be used to create
  841. // symbolic links for clients to open them.
  842. // The names can be any wide char strings that the driver chooses. At
  843. // OPEN_DEVICE_INSTANCE, a filter type index and the filter instance extension
  844. // are specified. Consequent Srbs will contain the filter extension for the
  845. // target filter instance. NameExtensionArray is a pointer to a constant array
  846. // of pointers which point to constant wide char strings.
  847. //
  848. ULONG NumNameExtensions;
  849. PWCHAR *NameExtensionArray;
  850. } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
  851. //
  852. // Execution Priorities passed in to the StreamClassChangePriority function
  853. //
  854. typedef enum _STREAM_PRIORITY {
  855. High, // highest priority, IRQL equal to the
  856. // adapter's ISR
  857. Dispatch, // medium priority, IRQL equal to DISPATCH
  858. // level
  859. Low, // lowest priority, IRQL equal to PASSIVE or
  860. // APC level
  861. LowToHigh // go from low priority to high priority
  862. } STREAM_PRIORITY, *PSTREAM_PRIORITY;
  863. //
  864. // the following are prototypes for services provided by the class driver
  865. //
  866. VOID STREAMAPI
  867. StreamClassScheduleTimer(
  868. IN OPTIONAL PHW_STREAM_OBJECT StreamObject,
  869. IN PVOID HwDeviceExtension,
  870. IN ULONG NumberOfMicroseconds,
  871. IN PHW_TIMER_ROUTINE TimerRoutine,
  872. IN PVOID Context
  873. );
  874. VOID STREAMAPI
  875. StreamClassCallAtNewPriority(
  876. IN OPTIONAL PHW_STREAM_OBJECT StreamObject,
  877. IN PVOID HwDeviceExtension,
  878. IN STREAM_PRIORITY Priority,
  879. IN PHW_PRIORITY_ROUTINE PriorityRoutine,
  880. IN PVOID Context
  881. );
  882. VOID STREAMAPI
  883. StreamClassStreamNotification(
  884. IN STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType,
  885. IN PHW_STREAM_OBJECT StreamObject,
  886. ...
  887. );
  888. VOID STREAMAPI
  889. StreamClassDeviceNotification(
  890. IN STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE NotificationType,
  891. IN PVOID HwDeviceExtension,
  892. ...
  893. );
  894. STREAM_PHYSICAL_ADDRESS STREAMAPI
  895. StreamClassGetPhysicalAddress(
  896. IN PVOID HwDeviceExtension,
  897. IN PHW_STREAM_REQUEST_BLOCK HwSRB OPTIONAL,
  898. IN PVOID VirtualAddress,
  899. IN STREAM_BUFFER_TYPE Type,
  900. OUT ULONG * Length
  901. );
  902. PVOID STREAMAPI
  903. StreamClassGetDmaBuffer(
  904. IN PVOID HwDeviceExtension
  905. );
  906. VOID STREAMAPI
  907. StreamClassDebugPrint(
  908. STREAM_DEBUG_LEVEL DebugPrintLevel,
  909. PCCHAR DebugMessage,
  910. ...
  911. );
  912. VOID STREAMAPI
  913. StreamClassDebugBreakPoint(
  914. VOID
  915. );
  916. VOID STREAMAPI
  917. StreamClassDebugAssert(
  918. IN PCHAR File,
  919. IN ULONG Line,
  920. IN PCHAR AssertText,
  921. IN ULONG AssertValue
  922. );
  923. NTSTATUS STREAMAPI
  924. StreamClassRegisterAdapter(
  925. IN PVOID Argument1,
  926. IN PVOID Argument2,
  927. IN PHW_INITIALIZATION_DATA HwInitializationData
  928. );
  929. #define StreamClassRegisterMinidriver StreamClassRegisterAdapter
  930. VOID
  931. StreamClassAbortOutstandingRequests(
  932. IN PVOID HwDeviceExtension,
  933. IN PHW_STREAM_OBJECT HwStreamObject,
  934. IN NTSTATUS Status
  935. );
  936. VOID
  937. StreamClassQueryMasterClock(
  938. IN PHW_STREAM_OBJECT HwStreamObject,
  939. IN HANDLE MasterClockHandle,
  940. IN TIME_FUNCTION TimeFunction,
  941. IN PHW_QUERY_CLOCK_ROUTINE ClockCallbackRoutine
  942. );
  943. //
  944. // The 1st parameter was PVOID HwDeviceExtension. It MUST be HwInstanceExtension
  945. // for multi-instance and multi-filter types ( version 20 ) drivers. Legacy
  946. // single instance drivers can continue to specify HwDeviceExtensionin as the
  947. // 1st parameter. It can also specify HwInstanceExtension.
  948. //
  949. PKSEVENT_ENTRY
  950. StreamClassGetNextEvent(
  951. IN PVOID HwInstanceExtension_OR_HwDeviceExtension,
  952. IN OPTIONAL PHW_STREAM_OBJECT HwStreamObject,
  953. IN OPTIONAL GUID * EventGuid,
  954. IN OPTIONAL ULONG EventItem,
  955. IN OPTIONAL PKSEVENT_ENTRY CurrentEvent
  956. );
  957. NTSTATUS
  958. StreamClassRegisterFilterWithNoKSPins(
  959. IN PDEVICE_OBJECT DeviceObject,
  960. IN const GUID * InterfaceClassGUID,
  961. IN ULONG PinCount,
  962. IN BOOL * PinDirection,
  963. IN KSPIN_MEDIUM * MediumList,
  964. IN OPTIONAL GUID * CategoryList
  965. );
  966. BOOLEAN STREAMAPI
  967. StreamClassReadWriteConfig(
  968. IN PVOID HwDeviceExtension,
  969. IN BOOLEAN Read,
  970. IN PVOID Buffer,
  971. IN ULONG Offset,
  972. IN ULONG Length
  973. );
  974. VOID STREAMAPI
  975. StreamClassQueryMasterClockSync(
  976. IN HANDLE MasterClockHandle,
  977. IN OUT PHW_TIME_CONTEXT TimeContext
  978. );
  979. VOID STREAMAPI
  980. StreamClassCompleteRequestAndMarkQueueReady(
  981. IN PHW_STREAM_REQUEST_BLOCK Srb
  982. );
  983. VOID STREAMAPI
  984. StreamClassReenumerateStreams(
  985. IN PVOID HwDeviceExtension,
  986. IN ULONG StreamDescriptorSize
  987. );
  988. //
  989. // A version 2.0 stream class mini driver must use this function
  990. // in stead of StreamClassReenumerateStreams()
  991. //
  992. VOID STREAMAPI
  993. StreamClassFilterReenumerateStreams(
  994. IN PVOID HwInstanceExtension,
  995. IN ULONG StreamDescriptorSize
  996. );
  997. #endif //_STREAM_H