Windows NT 4.0 source code leak
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.

266 lines
7.1 KiB

4 years ago
  1. //-------------------------------------------------------------------------
  2. //
  3. // CARDTMV1.C
  4. //
  5. // TMV1 Adapter Specific File
  6. //
  7. // See also cardtxxx.h, cardtxxx.h may redefine some functions with #defines.
  8. //
  9. // Revisions:
  10. // 09-01-92 KJB First.
  11. // 03-26-93 JAP Fixed up typedef and prototype inconsistencies
  12. // 04-05-93 KJB Fixed definition problem for WINNT.
  13. // Involving CardAddressRange...
  14. // 04-22-93 JAP Added AdapterInterrupts[] and CardGetIRQ().
  15. // 05-05-93 KJB Fixed CardSetInterruptLevel so that it calls
  16. // MV101SetInterruptLevel like it should.
  17. // 05-12-93 JAP Altered CardGetShortName() to return only
  18. // the type of card.
  19. // 05-13-93 KJB Added CardParseCommandString for card specific
  20. // standard string parsing across platforms.
  21. // Changed CardCheckAdapter to accept an
  22. // Initialization info from command line, ie
  23. // force bi-directional ports, etc.
  24. // All functions that used to take an PBASE_REGISTER
  25. // parameter now take PWORKSPACE. CardCheckAdapter
  26. // takes the both the PBASE_REGISTER and the
  27. // PWORKSPACE parameters. Auto Request Sense is
  28. // now supported.
  29. // 05-13-93 KJB Merged Microsoft Bug fixes to card detection.
  30. // 05-14-93 KJB Removed P3CDoIo, it did not work for scatter gather.
  31. // 05-17-93 KJB CardAddressRangeLength now return 0xffff.
  32. // Fixed compiler warnings.
  33. //
  34. //-------------------------------------------------------------------------
  35. #include CARDTXXX_H
  36. #ifdef WINNT
  37. //------------------------------------------------------------------------
  38. // The address ranges the card will use. These are accessed by trantor.c
  39. // to inform NTOS of the resources we are using.
  40. //------------------------------------------------------------------------
  41. CONST CardAddressRange cardAddressRange[] =
  42. {
  43. {0x1c00,0x04,FALSE}, // 0x1f88
  44. {0x3c00,0x04,FALSE}, // 0x3f88
  45. {0x4000,0x02,FALSE}, // 0x4388
  46. {0x5c00,0x04,FALSE}, // 0x5f88
  47. {0x8003,0x01,FALSE}, // 0x838b
  48. {0xbc00,0x01,FALSE} // 0xbf88
  49. };
  50. #endif
  51. //------------------------------------------------------------------------
  52. // The following table specifies the possible interrupts that
  53. // can be used by the adapter. A zero entry terminates the search.
  54. //------------------------------------------------------------------------
  55. CONST USHORT AdapterInterrupts [] =
  56. {2, 3, 4, 5, 6, 7, 10, 11, 12, 14, 15, 0};
  57. //------------------------------------------------------------------------
  58. // The following table specifies the ports to be checked when searching for
  59. // an adapter. A zero entry terminates the search.
  60. //------------------------------------------------------------------------
  61. CONST ULONG AdapterAddresses[] =
  62. {0x388, 0x384, 0x38C, 0x288, 0x280, 0x284, 0x28C, 0x0};
  63. //-----------------------------------------------------------------------
  64. //
  65. // The following routines are stub routines to provide an entry
  66. // point for the library. They reference the correct routines for
  67. // the appropriate card. Only these routines may be called from outside
  68. // the library. See the rouines they reference for a description of
  69. // the rouines, if the meaning is unclear.
  70. //
  71. //-----------------------------------------------------------------------
  72. //------------------------------------------------------------------------
  73. // the maximum transfer size
  74. // by decreasinge this we can get better system performace since
  75. // the data transfer occurs with interrupts disabled, this might be
  76. // decreased for our smaller cards
  77. // Used only by WINNT
  78. //------------------------------------------------------------------------
  79. ULONG CardMaxTransferSize (VOID)
  80. {
  81. return 16*1024L;
  82. }
  83. // we use interrupts
  84. BOOLEAN CardSupportsInterrupts (VOID)
  85. {
  86. return TRUE;
  87. }
  88. // default interrupt number is 10
  89. UCHAR CardDefaultInterruptLevel (VOID)
  90. {
  91. return 15;
  92. }
  93. // the following info is for initialization only
  94. // this card is memory mapped
  95. BOOLEAN CardAddressRangeInIoSpace (VOID)
  96. {
  97. return TRUE;
  98. }
  99. // we use 0x10000 bytes in memory space
  100. USHORT CardAddressRangeLength (VOID)
  101. {
  102. // return 0x10000;
  103. return 0xffff;
  104. }
  105. // The following is used along with the constant structure in card.c
  106. // to define the precise i/o addresses a card will use
  107. USHORT CardNumberOfAddressRanges (VOID)
  108. {
  109. return 0;
  110. }
  111. USHORT CardStartCommandInterrupt (PTSRB t)
  112. {
  113. return (ScsiStartCommandInterrupt (t));
  114. }
  115. USHORT CardFinishCommandInterrupt (PTSRB t)
  116. {
  117. return (ScsiFinishCommandInterrupt (t));
  118. }
  119. USHORT CardDoCommand (PTSRB t)
  120. {
  121. return (ScsiDoCommand (t));
  122. }
  123. //
  124. // BOOLEAN CardCheckAdapter
  125. //
  126. // Initializes a workspace for the adapter at this address.
  127. // Returns TRUE if adapter found.
  128. //
  129. BOOLEAN CardCheckAdapter (PWORKSPACE w, PINIT init)
  130. {
  131. PADAPTER_INFO g = (PADAPTER_INFO) w;
  132. BOOLEAN rval;
  133. //
  134. // Initialize workspace and takes card specific parameter information
  135. // to set how the card will be used. For example, command line info
  136. // to force the parallel port to bi-directional or uni-directional modes.
  137. //
  138. g->BaseIoAddress = init->BaseIoAddress;
  139. // if no init structure, use all defaults
  140. if (init) {
  141. g->InterruptLevel = init->InterruptLevel;
  142. } else {
  143. g->InterruptLevel = CardDefaultInterruptLevel();
  144. }
  145. rval = MV101CheckAdapter (g);
  146. // if card found, set interrupt level
  147. if (rval) {
  148. MV101SetInterruptLevel (g, g->InterruptLevel);
  149. }
  150. return rval;
  151. }
  152. //
  153. // CardParseCommandString(PINIT p, PCHAR str)
  154. //
  155. // Parses the command string to get all card specific parameters.
  156. // Will fill in defaults where no parameters are supplied, or
  157. // if the str pointer is NULL.
  158. //
  159. // Returns false if it could not parse the string given.
  160. //
  161. // Can be used to parse the string piece by piece, by sending
  162. // the same INIT structure each time. Send NULL as the string
  163. // first time to initialize the PINIT structure to the standard defaults.
  164. //
  165. // BaseIoAddress will be set to NULL by default, and the program can
  166. // detect that it has changed during parsing and just search for the
  167. // card as specified by the command line argument if it has changed. If
  168. // it does not change, the program should cycle through all valid addresses.
  169. //
  170. BOOLEAN CardParseCommandString(PINIT init, PCHAR str)
  171. {
  172. // for now, just fill in some defaults
  173. init->InterruptLevel = CardDefaultInterruptLevel();
  174. init->BaseIoAddress = NULL;
  175. return TRUE;
  176. }
  177. VOID CardEnableInterrupt (PADAPTER_INFO g)
  178. {
  179. MV101EnableInterrupt (g);
  180. }
  181. VOID CardDisableInterrupt (PADAPTER_INFO g)
  182. {
  183. MV101DisableInterrupt (g);
  184. }
  185. BOOLEAN CardInterrupt (PADAPTER_INFO g)
  186. {
  187. return (N5380Interrupt (g));
  188. }
  189. VOID CardResetBus (PADAPTER_INFO g)
  190. {
  191. N5380ResetBus (g);
  192. }
  193. PUCHAR CardGetName (VOID)
  194. {
  195. return "Media Vision Pro Audio Spectrum";
  196. }
  197. PUCHAR CardGetShortName (VOID)
  198. {
  199. return "Pro Audio";
  200. }
  201. UCHAR CardGetType (VOID)
  202. {
  203. return CARDTYPE_TMV1;
  204. }