home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / pas_sdk1 / pas / subs / misc / gethw.asm < prev    next >
Encoding:
Assembly Source File  |  1992-09-15  |  16.0 KB  |  548 lines

  1. ;$Author:   BCRANE  $
  2. ;$Date:   15 Sep 1992 13:30:32  $
  3. ;$Header:   X:/sccs/misc/gethw.asv   1.7   15 Sep 1992 13:30:32   BCRANE  $
  4. ;$Log:   X:/sccs/misc/gethw.asv  $
  5. ;  
  6. ;     Rev 1.7   15 Sep 1992 13:30:32   BCRANE
  7. ;  added NOINT2F ifdef for use in standalone environment
  8. ;  
  9. ;     Rev 1.6   14 Sep 1992 10:38:04   DCODY
  10. ;  changed docare mask bits to check a more general set of hardware
  11. ;  
  12. ;     Rev 1.5   31 Aug 1992 12:21:02   DCODY
  13. ;  the fourth board address was the third board! changed...
  14. ;  
  15. ;     Rev 1.4   24 Jul 1992 15:41:14   DCODY
  16. ;  The function now will search for the board in 4 locations if the
  17. ;  user passes in a 0 as the base address.
  18. ;  
  19. ;     Rev 1.3   20 Jul 1992 11:46:18   DCODY
  20. ;  Makes up to 4 passes to find the hardware at up to 4 I/O addresses.
  21. ;  
  22. ;     Rev 1.2   17 Jul 1992 14:02:32   DCODY
  23. ;  moved TheDMAChannel and TheIRQChannel into gethw. Also declared a copy
  24. ;  of mvtranslatecode in the code segment.
  25. ;  
  26. ;     Rev 1.1   23 Jun 1992 16:32:50   DCODY
  27. ;  PAS2 update
  28. ;  
  29. ;     Rev 1.0   15 Jun 1992 09:39:50   BCRANE
  30. ;  Initial revision.
  31. ;$Logfile:   X:/sccs/misc/gethw.asv  $
  32. ;$Modtimes$
  33. ;$Revision:   1.7  $
  34.  
  35.     Title    GetHW  --  Determine the Pro Audio Spectrum Version
  36.     Subttl    Copyright (c) 1991,1992. Media Vision, Inc. All Rights Reserved
  37.     page    64,131
  38.  
  39. ;   /*\
  40. ;---|*|----====< GetHW >====----
  41. ;---|*|
  42. ;---|*| Get the Pro Audio hardware device configuration, etc.
  43. ;---|*|
  44. ;   \*/
  45.  
  46.         .xlist
  47.     include model.inc
  48.         include common.inc
  49.     include masm.inc
  50.     include target.inc
  51.     .list
  52.  
  53. ;
  54. ;   /*\
  55. ;---|*|--------------------------==================--------------------------
  56. ;---|*|
  57. ;---|*|    The Pro AudioSpectrum Plus, Pro AudioSpectrum 16 and CDPC
  58. ;---|*|    all support relocatable I/O.  PAS hardware must occupy four
  59. ;---|*|    contiguous I/O locations.  All I/O accesses use those four addresses
  60. ;---|*|    and their 'harmonic' addresses.  Harmonic addresses are those
  61. ;---|*|    addresses that under normal circumstance would decode to the same
  62. ;---|*|    contiguous four I/O locations.  For example, harmonic addresses of
  63. ;---|*|    port 388h would include 788h, 1388h, 1788h, 1f88h, etc.
  64. ;---|*|
  65. ;---|*|    Most hardware will not conflict with the default address range of
  66. ;---|*|    388h-38Bh.  This address range is based on the I/O locations
  67. ;---|*|    chosen by Adlib and this range is supposed to be reserved for
  68. ;---|*|    SDLC or 2nd Bisynchronous communications hardware.  It has been
  69. ;---|*|    reported that an ISDN card decodes to this range also.  More
  70. ;---|*|    importantly, if a customer wants to have multiple sound cards
  71. ;---|*|    co-resident in his system, we must provide a means of relocating
  72. ;---|*|    the I/O range.
  73. ;---|*|
  74. ;---|*|    Media Vision's I/O relocation capability is software selectable to
  75. ;---|*|    any ONE of 64 4-address locations.  The possible locations are
  76. ;---|*|    depicted below:
  77. ;---|*|
  78. ;---|*|     0     2     4      6    8     A     C      E
  79. ;---|*|
  80. ;---|*|   200h    |<------------- game control------------------->|
  81. ;---|*|
  82. ;---|*|   210h    |<-- expansion unit -->|        |        |
  83. ;---|*|
  84. ;---|*|   220h    |<---- Sound Blaster decode #1 ---------------->|
  85. ;---|*|
  86. ;---|*|   230h    |<---- Sound Blaster decode #2 ---------------->|
  87. ;---|*|
  88. ;---|*|   240h    |<---- Sound Blaster decode #3 ---------------->|
  89. ;---|*|
  90. ;---|*|   250h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  91. ;---|*|
  92. ;---|*|   260h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  93. ;---|*|
  94. ;---|*|   270h    |<---PAS--->|          |<--3rd Parallel Printer->|
  95. ;---|*|
  96. ;---|*|   280h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  97. ;---|*|
  98. ;---|*|   290h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  99. ;---|*|
  100. ;---|*|   2A0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  101. ;---|*|
  102. ;---|*|   2B0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  103. ;---|*|
  104. ;---|*|   2C0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  105. ;---|*|
  106. ;---|*|   2D0h    |<-----------     3270     PC    --------------->|
  107. ;---|*|
  108. ;---|*|   2E0h    |<---PAS--->|<---PAS--->|<---PAS--->|<---PAS--->|
  109. ;---|*|
  110. ;---|*|   2F0h    |<----- reserved ------>|<-Async comm. 2 ------.|
  111. ;---|*|
  112. ;---|*|     0     2     4      6    8     A     C      E
  113. ;---|*|
  114. ;---|*|   300h    |<401---------- Prototype card ---------------->|
  115. ;---|*|
  116. ;---|*|   310h    |<401---------- Prototype card ---------------->|
  117. ;---|*|
  118. ;---|*|   320h    |<401----------    hard disk   ---------------->|
  119. ;---|*|
  120. ;---|*|   330h    |<401---XT/3270-------->|<---PAS--->|<---PAS--->|
  121. ;---|*|
  122. ;---|*|   340h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  123. ;---|*|
  124. ;---|*|   350h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  125. ;---|*|
  126. ;---|*|   360h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  127. ;---|*|
  128. ;---|*|   370h    |<401, PAS->|          |<--2nd Parallel Printer->|
  129. ;---|*|
  130. ;---|*|   380h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  131. ;---|*|
  132. ;---|*|   390h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  133. ;---|*|
  134. ;---|*|   3A0h    |<401, PAS->|<---PAS--->|<---PAS--->|<---PAS--->|
  135. ;---|*|
  136. ;---|*|   3B0h    |<401, Monochrome Display and Parallel 1  ----->|
  137. ;---|*|
  138. ;---|*|   3C0h    |<401, ------------ VGA   --------------------->|
  139. ;---|*|
  140. ;---|*|   3D0h    |<401,-------     3270     PC    --------------->|
  141. ;---|*|
  142. ;---|*|   3E0h    |<401,    reserved ------>|<---- COM 3 serial---->|
  143. ;---|*|
  144. ;---|*|   3F0h    |<401,     Disk     ------>|<-- Asych comm. 1 ---->|
  145. ;---|*|
  146. ;---|*|
  147. ;---|*|
  148. ;---|*|   Note: 401 indicates one of the possible locations of the
  149. ;---|*|     MPU-401 MIDI interface.  It decodes at 3x0 - 3x1 where
  150. ;---|*|     x is an element of {0,1,2,3,4,5,6,7,8,9,a,b,c d,e,f}
  151. ;---|*|
  152. ;---|*|     SoundBlaster decode range is 2x0 thru 2xf where x is
  153. ;---|*|     an element of {2,3,4}
  154. ;---|*|
  155. ;---|*|
  156. ;---|*|   It requires very little effort to support the relocation of
  157. ;---|*|   the hardware if the routines provided here are used.    Once
  158. ;---|*|   the Pro AudioSpectrum chip has been located, any I/O address
  159. ;---|*|   can be relocated by XOR-ing the address (usually contained in)
  160. ;---|*|   the DX register) with a 16-bit variable.
  161. ;---|*|
  162. ;   \*/
  163. ;
  164.  
  165. ;
  166. ;---------------------------========================---------------------------
  167. ;---------------------------====< DATA SECTION >====---------------------------
  168. ;---------------------------========================---------------------------
  169. ;
  170.     .data
  171. ;
  172. ; The board base address for the original PAS card was based at 388. This will
  173. ; be XORed to the new address to derive a translation code. This code can be
  174. ; XORed back into any original PAS address resulting in the true card address.
  175. ;
  176.  
  177.     public    _MVTranslateCode
  178. _MVTranslateCode    dw    0    ; I/O base xor default_base
  179.  
  180.     public    _MVHWVersionBits
  181. _MVHWVersionBits    dw    -1    ; holds the product feature bits
  182.  
  183. VERSION_PAS             equ     0       ; Pro Audio Spectrum
  184. VERSION_PASPLUS     equ    1    ; Pro Audio Plus card
  185. VERSION_PAS16        equ    2    ; Pro Audio 16 card
  186. VERSION_CDPC        equ    3    ; CDPC card & unit
  187.  
  188. ;
  189. ; The following equates build up a mask of bits that we do wish to keep
  190. ; when comparing feature bits. The zero bits can be ignored, whereas, the
  191. ; the 1 bits must match.
  192. ;
  193.  
  194. PASdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  195. PASPLUSdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  196. PAS16docare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  197. CDPCdocare    equ    <(bMVA508 OR bMVDAC16 OR bMVOPL3 OR bMV101 )>
  198.  
  199. ;
  200. ProductIDTable    label    word
  201.     dw    PRODUCT_PROAUDIO and PASdocare
  202.     dw    PRODUCT_PROPLUS  and PASPLUSdocare
  203.     dw    PRODUCT_PRO16     and PAS16docare
  204.     dw    PRODUCT_CDPC     and CDPCdocare
  205.     dw    -1
  206. ;
  207. DoCareBits    label    word
  208.     dw    PASdocare
  209.     dw    PASPLUSdocare
  210.     dw    PAS16docare
  211.     dw    CDPCdocare
  212.     dw    -1                ; table terminator
  213.  
  214.     public    TheDMAChannel        ; defaults to channel 1
  215. TheDMAChannel   db      DEFAULTDMA      ; defaults to channel 1
  216.     public    TheIRQChannel        ; defaults to IRQ 7
  217. TheIRQChannel    db    DEFAULTIRQ    ; defaults to IRQ 7
  218.  
  219. ;
  220. ;---------------------------========================---------------------------
  221. ;---------------------------====< CODE SECTION >====---------------------------
  222. ;---------------------------========================---------------------------
  223. ;
  224.     .code
  225.  
  226.     public    _csMVTranslateCode
  227. _csMVTranslateCode    dw    0    ; I/O base xor default_base
  228.  
  229. ;
  230. ;   /*\
  231. ;---|*|----====< long mvGetHWVersion() >====----
  232. ;---|*|
  233. ;---|*| Detects and identifies the installed Pro AudioSpectrum.
  234. ;---|*|
  235. ;---|*| Entry Conditions:
  236. ;---|*|     word address containing the base address.
  237. ;---|*|
  238. ;---|*| Exit Conditions:
  239. ;---|*|     DX:AX = -1, the hardware is not installed.
  240. ;---|*|     DX:AX = -2, some type of hardware is installed - can't ID it.
  241. ;---|*|     DX      = Product ID
  242. ;---|*|     AH      = PAS hardware version
  243. ;---|*|     AL      = SCSI, or MITSUMI CD-ROM interface installed.
  244. ;---|*|     BX:CX = the bit fields that identify the board
  245. ;---|*|     Carry is set on error
  246. ;---|*|
  247. ;   \*/
  248.  
  249.     public    mvGetHWVersion
  250. mvGetHWVersion    proc
  251.     push    bp            ; frame the stack
  252.     mov    bp,sp
  253.  
  254.     push    si            ; save the C criticals
  255.     push    di
  256. ;
  257. ; calculate the translation code
  258. ;
  259.     mov    di,wParm1        ; get the base I/O address
  260.  
  261.     .errnz    USE_ACTIVE_ADDR
  262.     or    di,di            ; do we search just one?
  263.     jnz    mvgehw_05        ; yes, pass it on...
  264.  
  265.     ; search the default address
  266.  
  267.         mov     di,DEFAULT_BASE         ; try the first address
  268.     call    SearchHWVersion
  269.     cmp    dx,-1            ; found?
  270.     jnz    mvgehw_exit        ; yes, exit now...
  271.  
  272.     ; search the first alternate address
  273.  
  274.     mov    di,ALT_BASE_1        ; try the first alternate
  275.     call    SearchHWVersion
  276.     cmp    dx,-1            ; found?
  277.     jnz    mvgehw_exit        ; yes, exit now...
  278.  
  279.     ; search the second alternate address
  280.  
  281.     mov    di,ALT_BASE_2        ; try the second alternate
  282.     call    SearchHWVersion
  283.     cmp    dx,-1            ; found?
  284.     jnz    mvgehw_exit        ; yes, exit now...
  285.  
  286.     ; search the third, or user requested alternate address
  287.  
  288.     mov    di,ALT_BASE_3        ; try the third alternate
  289. ;
  290. mvgehw_05:
  291.     call    SearchHWVersion     ; pass the third A, or user I/O
  292. ;
  293. mvgehw_exit:
  294.     pop    di
  295.     pop    si
  296.     pop    bp
  297.     ret
  298.  
  299. mvGetHWVersion    endp
  300.  
  301. ;
  302. ;   /*\
  303. ;---|*|----====< SearchHWVersion >====----
  304. ;---|*|
  305. ;---|*| Given a specific I/O address, this routine will see if the
  306. ;---|*| hardware exists at this address.
  307. ;---|*|
  308. ;---|*| Entry Conditions:
  309. ;---|*|     DI holds the I/O address to test
  310. ;---|*|     BX:CX = bMVSCSI
  311. ;---|*|
  312. ;---|*| Exit Conditions:
  313. ;---|*|     BX:CX = the bit fields that identify the board
  314. ;---|*|
  315. ;   \*/
  316. ;
  317. SearchHWVersion proc near
  318.     push    si            ; save the C criticals
  319.     push    di
  320. ;
  321. ; calculate the translation code
  322. ;
  323.     xor    di,DEFAULT_BASE     ; di holds the translation code
  324.  
  325. ifndef NOINT2F
  326.     mov    ax,0BC00H        ; make sure MVSOUND.SYS is loaded
  327.     mov    bx,'??'                 ; this is our way of knowing if the
  328.     xor    cx,cx            ; hardware is actually present.
  329.     xor    dx,dx
  330.     int    2fh            ; get the ID pattern
  331.     xor    bx,cx            ; build the result
  332.     xor    bx,dx
  333.     cmp    bx,'MV'                 ; if not here, exit...
  334.     jjnz    sehw_bad
  335. ;
  336. ; get the MVSOUND.SYS specified DMA and IRQ channel
  337. ;
  338.         mov     ax,0bc04h               ; get the DMA and IRQ numbers
  339.     int    2fh
  340.     mov    TheDMAChannel,bl    ; save the correct DMA & IRQ
  341.     mov    TheIRQChannel,cl
  342. endif
  343.  
  344. ;
  345. ; grab the version # in the interrupt mask. The top few bits hold the version #
  346. ;
  347.         mov     dx,INTRCTLR             ; board ID is in MSB 3 bits
  348.     xor    dx,di            ; adjust to other address
  349.     in    al,dx
  350.     cmp    al,-1            ; bus float meaning not present?
  351.     je    sehw_bad        ; yes, there is no card here
  352.  
  353.     mov    ah,al            ; save an original copy
  354.     xor    al,fICrevbits        ; the top bits wont change
  355.  
  356.     out    dx,al            ; send out the inverted bits
  357.     pause
  358.         pause
  359.     in    al,dx            ; get it back...
  360.  
  361.     cmp    al,ah            ; both should match now...
  362.     xchg    al,ah            ; (restore without touching the flags)
  363.     out    dx,al
  364.  
  365.     jnz    sehw_bad        ; we have a bad board
  366.  
  367.         and     ax,fICrevbits           ; isolate the ID bits & clear AH
  368.     mov    cl,fICrevshr        ; shift the bits into a meaningful
  369.     shr    al,cl            ; position (least signficant bits)
  370.     mov    si,ax            ; save the version #
  371. ;
  372. ; We do have hardware! Load the product bit definitions
  373. ;
  374.     sub    bx,bx
  375.     mov    cx,bMVSCSI        ; setup bx:cx for the original PAS
  376.  
  377.         or      al,al                   ; is this the first version of h/w?
  378.     jz    sehw_done        ; yes, simple exit will do.
  379.  
  380.     call    FindBits        ; load all the rest of the h/w bits
  381. ;
  382. sehw_done:
  383. ;
  384. ; loop on a table search to find identify the board
  385. ;
  386.     push    bx            ; save this high bits
  387.     mov    bx,-2
  388.     ;
  389.     sehw_05:
  390.     add    bx,2
  391.     cmp    ProductIDTable[bx],-1    ; at the end of the table?
  392.     jz    sehw_bad_hw        ; yes, we can't identify this board
  393.     mov    dx,cx            ; dx holds the product bits
  394.     and    dx,DoCareBits[bx]    ; keep the bits we care about
  395.     cmp    dx,ProductIDTable[bx]    ; do these bits match a product?
  396.     jnz    sehw_05         ; no, keep looking
  397.  
  398.     mov    dx,bx
  399.     shr    dx,1            ; make word index a byte index
  400.     pop    bx
  401.  
  402.     mov    [_MVTranslateCode],di       ; save the translation code
  403.     mov    cs:[_csMVTranslateCode],di ; save the translation code
  404.  
  405.     mov    ax,si            ; load the h/w version #
  406.     sub    ah,ah            ; for our purposes, we will return SCSI
  407.     xchg    ah,al            ; into ah
  408.         clc                             ; The board was identified !
  409.  
  410.     mov    [_mvHWVersionBits],cx    ; save the good bits
  411.  
  412.     jmp    short sehw_exit
  413. ;
  414. sehw_bad_hw:
  415.     pop    bx            ; flush the stack
  416.     mov    ax,-2
  417.     cwd
  418.     stc
  419.     jmp    short sehw_exit
  420. ;
  421. sehw_bad:
  422.     mov    ax,-1            ; we got here due to a bad board
  423.     cwd
  424.         stc
  425. ;
  426. sehw_exit:
  427.     pop    di
  428.     pop    si
  429.     ret
  430.  
  431. SearchHWVersion endp
  432.  
  433. ;
  434. ;   /*\
  435. ;---|*|----====< FindBit >====----
  436. ;---|*|
  437. ;---|*| Checks the installed hardware for all the feature bits.
  438. ;---|*|
  439. ;---|*| Entry Conditions:
  440. ;---|*|     DI holds the I/O address translation code
  441. ;---|*|     BX:CX = bMVSCSI
  442. ;---|*|
  443. ;---|*| Exit Conditions:
  444. ;---|*|     BX:CX = the bit fields that identify the board
  445. ;---|*|
  446. ;   \*/
  447. ;
  448.  
  449. FindBits        proc    near
  450. ;
  451. ; All second generation Pro Audio cards use the MV101 and have SB emulation.
  452. ;
  453.     or    cx,bMVSBEMUL+bMV101    ; force SB emulation
  454. ;
  455. ; determine if the enhanced SCSI interface is present
  456. ;
  457.         mov     dx,ENHANCEDSCSI         ; test for SCSI mod (U48)
  458.     xor    dx,di            ; modify via the translate code
  459.  
  460.     out    dx,al            ; strobe
  461.     pause                ; I/O bus delay
  462.     in    al,dx            ; get the bit
  463.  
  464.     and    al,1            ; bit0==1 means old SCSI PAL
  465.     cmp    al,1            ; reverse sense
  466.     sbb    ax,ax            ; ax = ffff if enhanced SCSI
  467.     and    ax,bMVENHSCSI        ; save the bit
  468.     or    cx,ax            ; merge it in
  469. ;
  470. ; determine AT/PS2, CDPC slave mode
  471. ;
  472.     mov    dx,MASTERMODRD        ; check for the CDPC
  473.         xor     dx,di                   ; modify via the translate code
  474.  
  475.         in      al,dx
  476.     test    al,bMMRDatps2        ; AT(1) or PS2(0)
  477.     jnz    @F
  478.     or    cx,bMVPS2
  479.     ;
  480.     @@:
  481.     test    al,bMMRDmsmd        ; Master(0) or Slave(1)
  482.     jz    @F
  483.     or    cx,bMVSLAVE
  484.     ;
  485.     @@:
  486.     push    cx            ; move the revision bits
  487.  
  488.     mov    dx,MASTERCHIPR
  489.     xor    dx,di
  490.  
  491.     .errnz    bMV101_REV-(000Fh SHL 11)
  492.  
  493.     in    al,dx            ; get the low 4 bits of the chip rev
  494.     and    ax,000Fh        ; into ah
  495.     mov    cl,11            ; FROM 0000 0000 0000 1111b
  496.     shl    ax,cl            ; TO   0111 1000 0000 0000b
  497.  
  498.         pop     cx
  499.         or      cx,ax                   ; merge in the bits
  500. ;
  501. ; determine the CDROM drive type, FM chip, 8/16 bit DAC, and mixer
  502. ;
  503.     mov    dx,SLAVEMODRD        ; check for the CDPC
  504.         xor     dx,di                   ; modify via the translate code
  505.     in    al,dx
  506.  
  507.         test    al,bSMRDdactyp          ; 16 bit DAC?
  508.     jz    @F            ; no, its an 8 bit DAC
  509.     or    cx,bMVDAC16        ; its a 16 bit DAC
  510.     ;
  511.     @@:
  512.     test    al,bSMRDfmtyp        ; OPL3 chip?
  513.     jz    @F            ; no, so it's the PAS16 card
  514.     or    cx,bMVOPL3        ; is an OPL3
  515.     ;
  516.     @@:
  517.     mov    dx,cx            ; inference check for new mixer
  518.     and    dx,bMVSLAVE+bMVDAC16    ; Slave & 16 bit dac is the CDPC
  519.     cmp    dx,bMVDAC16        ; 16 bit DAC on master?
  520.     jnz    @F            ; no, it's the CDPC with Nation mixer
  521.     or    cx,bMVA508
  522.     ;
  523.     @@:
  524.     and    al,bSMRDdrvtyp        ; isolate the CDROM drive type
  525.     cmp    al,2            ; Sony 535 interface?
  526.     jnz    @F            ; no, continue on...
  527.     and    cx,NOT (bMVSCSI+bMVENHSCSI) ; yes, flush the SCSI bits
  528.     or    cx,bMVSONY            ; set the 535 bit
  529.     ;
  530.     @@:
  531. ;
  532. ; determine if MPU-401 emulation is active
  533. ;
  534.         mov     dx,COMPATREGE           ; compatibility register
  535.     xor    dx,di            ; modify via translate code
  536.     in    al,dx
  537.     test    al,cpMPUEmulation
  538.     jz    @F
  539.     or    cx,bMVMPUEMUL
  540.     ;
  541.     @@:
  542.     ret
  543.  
  544. FindBits    endp
  545.  
  546.     end
  547.  
  548.