home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rmfiles.zip / mitsrc.zip / CDASIC.C next >
Text File  |  1994-07-13  |  5KB  |  161 lines

  1.  #define INCL_DOSINFOSEG
  2.  #define INCL_NO_SCB
  3.  #define INCL_INITRP_ONLY
  4.  #include "os2.h"                  // \DRV6\H
  5.  #include "cmd.h"
  6.  #include <conio.h>
  7.  
  8.  #define Orchid_IRQ3          0x0008
  9.  #define BinIrq3               3
  10.  #define Orchid_IRQ5          0x0010
  11.  #define BinIrq5               5
  12.  #define Orchid_IRQ7          0x0018
  13.  #define BinIrq7               7
  14.  #define Orchid_IRQ9          0x0020
  15.  #define BinIrq9               9
  16.  #define Orchid_IRQ10         0x0028
  17.  #define BinIrq10              10
  18.  #define Orchid_IRQ11         0x0030
  19.  #define BinIrq11              11
  20.  #define Orchid_IRQ12         0x0038
  21.  #define BinIrq12              12
  22.  #define JazzPort300          0x00
  23.  #define JazzPort320          0x10
  24.  #define JazzPort340          0x20
  25.  #define JazzPort360          0x30
  26.  #define JazzIrqNone          0x00
  27.  #define JazzIrq10            0x04
  28.  #define JazzIrq11            0x08
  29.  #define JazzIrq12            0x0C
  30.  #define JazzCDPort           0x600
  31.  #define JazzResetPort        0x6
  32.  #define JazzDataPort         0xA
  33.  #define JazzPresent          0xAA
  34.  #define JazzResetCmd1        0xd0
  35.  #define JazzResetCmd2        0x0
  36.  #define ImportantBit         1
  37.  
  38. #define PortBase 0x220
  39. #define PortBase_Adjust 0x20
  40.  
  41. #define Orchid_PSS_ID_VERS   4
  42. #define Orchid_CD_ConfigPort 0x16
  43. #define Orchid_DSP_Signature 0x4500
  44. #define HighByteMask 0xff00
  45.  
  46. BOOL EnableOrchidASIC(USHORT Port, USHORT IRQ)
  47. {
  48. USHORT Addr,value,IrqMask=0;
  49. BOOL rc=FALSE;
  50.  
  51.         for(Addr=PortBase; Addr<=PortBase+PortBase_Adjust;Addr+=PortBase_Adjust )
  52.           {
  53.           value=(inpw(Addr+Orchid_PSS_ID_VERS) & HighByteMask);
  54.           if(value == Orchid_DSP_Signature)
  55.             {
  56.             switch(IRQ)
  57.               {
  58.               case BinIrq3:
  59.                 IrqMask=Orchid_IRQ3;
  60.                 break;
  61.               case BinIrq5:
  62.                 IrqMask=Orchid_IRQ5;
  63.                 break;
  64.               case BinIrq9:
  65.                 IrqMask=Orchid_IRQ9;
  66.                 break;
  67.               case BinIrq10:
  68.                 IrqMask=Orchid_IRQ10;
  69.                 break;
  70.               case BinIrq11:
  71.                 IrqMask=Orchid_IRQ11;
  72.                 break;
  73.               case BinIrq12:
  74.                 IrqMask=Orchid_IRQ12;
  75.                 break;
  76.               default:
  77.                 break;
  78.               } /* end switch */
  79.             outpw(Addr+Orchid_CD_ConfigPort,((Port<<4) & HighByteMask) | IrqMask);
  80.             rc=TRUE;
  81.             break;
  82.             } /* end if */
  83.           } /* end for */
  84.      return rc;
  85. }
  86.  
  87. BOOL EnableJazzASIC(USHORT Port, USHORT IRQ,USHORT Adapter)
  88. {
  89. UCHAR BitMask,i;
  90. USHORT port,l,count;
  91. BOOL Found=FALSE;
  92.                 outp(Adapter+JazzResetPort,JazzResetCmd1);
  93.                 for(l=0; l<255; l++) // delay just a little bit
  94.                   {
  95.                   i=inp(Adapter+JazzResetPort);
  96.                   if( (i & 1) ==0)
  97.                     {
  98.                     i=inp(Adapter+JazzDataPort);
  99.                     break;
  100.                     } /* end if */
  101.                   } /* end for */
  102.                 if(i==JazzPresent)
  103.                   {
  104.                   Found=TRUE;
  105.                   switch(Port)
  106.                     {
  107.                     case 0x300:
  108.                       BitMask=JazzPort300;
  109.                       break;
  110.                     case 0x320:
  111.                       BitMask=JazzPort320;
  112.                       break;
  113.                     case 0x340:
  114.                       BitMask=JazzPort340;
  115.                       break;
  116.                     case 0x360:
  117.                       BitMask=JazzPort360;
  118.                       break;
  119.                     default:
  120.                       BitMask=JazzPort300;
  121.                       break;
  122.                     } /* end switch */
  123.                   switch(IRQ)
  124.                     {
  125.                     case BinIrq10:
  126.                       BitMask|=JazzIrq10;
  127.                       break;
  128.                     case BinIrq11:
  129.                       BitMask|=JazzIrq11;
  130.                       break;
  131.                     case BinIrq12:
  132.                       BitMask|=JazzIrq12;
  133.                       break;
  134.                     default:
  135.                       BitMask|=JazzIrqNone;
  136.                       break;
  137.                     } /* end switch */
  138.                   for(i=0; i<6; i++)
  139.                     {
  140.                     outp(JazzCDPort,BitMask & ImportantBit);
  141.                     BitMask>>=ImportantBit;
  142.                     } /* end for */
  143.                   } /* end if */
  144. return FALSE;
  145. }
  146.  
  147. VOID EnableASIC(USHORT Port, USHORT IRQ,USHORT type,USHORT Adapter)
  148. {
  149.      switch(type)
  150.        {
  151.        case 5:
  152.          EnableOrchidASIC(Port,IRQ);          // enable orchid asic
  153.          break;
  154.        case 6:
  155.          EnableJazzASIC(Port,IRQ,Adapter);            // if that failed, try jazz
  156.          break;
  157.        default:
  158.          break;
  159.        }
  160. }
  161.