home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / DASD / CDROM / ATAPI / ATAPIPS2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  4.8 KB  |  176 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /*static char *SCCSID = "src/dev/dasd/ibm/ibm1s506/s506ps2.c, idsk, r207, 8.005p 93/03/18";*/
  13. /**************************************************************************
  14.  *
  15.  * SOURCE FILE NAME =  S506PS2.C
  16.  *
  17.  * DESCRIPTIVE NAME = IBM1S506.ADD - Adapter Driver for ST506/IDE DASD
  18.  *
  19.  *
  20.  *
  21.  * VERSION = V2.0
  22.  *
  23.  * DATE
  24.  *
  25.  * DESCRIPTION : Adapter Driver PS/2 IDE Port routines.
  26.  *
  27.  * Purpose:
  28.  *
  29.  *
  30.  *
  31.  *
  32.  *
  33. */
  34.  #define INCL_NOBASEAPI
  35.  #define INCL_NOPMAPI
  36.  #define INCL_NO_SCB
  37.  #define INCL_INITRP_ONLY
  38.  #define INCL_DOSERRORS
  39.  #include "os2.h"
  40.  #include "dos.h"
  41.  #include "bseerr.h"
  42.  #include "dskinit.h"
  43.  #include <scb.h>
  44.  #include <abios.h>
  45.  
  46.  #include "iorb.h"
  47.  #include "reqpkt.h"
  48.  #include "dhcalls.h"
  49.  #include "addcalls.h"
  50.  
  51.  #include "atapips2.h"
  52.  #include "atapicon.h"
  53.  #include "atapityp.h"
  54.  #include "atapiext.h"
  55.  #include "atapipro.h"
  56.  
  57. ///*------------------------------------*/
  58. ///*                                    */
  59. ///* SetPS2DiskLight                    */
  60. ///* ---------------                    */
  61. ///*                                    */
  62. ///*                                    */
  63. ///*------------------------------------*/
  64. //VOID NEAR SetPS2DiskLight( USHORT On )
  65. //{
  66. //  USHORT        Data;
  67. //
  68. //  LightCount += (( On ) ? 1 : -1 );
  69. //
  70. //  if ( (LightState == 0) != (LightCount == 0) )
  71. //  {
  72. //    DISABLE
  73. //
  74. //    LightState = (LightCount != 0);
  75. //
  76. //    inp( PS2_CTRL_PORT_A, Data )
  77. //    IODelay();
  78. //
  79. //    if ( LightState )
  80. //    {
  81. //      Data |= PS2_FIXED_DISK_LIGHT;
  82. //    }
  83. //    else
  84. //    {
  85. //      Data &= ~PS2_FIXED_DISK_LIGHT;
  86. //    }
  87. //    outp( PS2_CTRL_PORT_A, Data );
  88. //    IODelay();
  89. //
  90. //
  91. //    ENABLE
  92. //  }
  93. //}
  94.  
  95. /*------------------------------------*/
  96. /*                                    */
  97. /* SetupPS2IDEPort                    */
  98. /* ---------------                    */
  99. /*                                    */
  100. /*                                    */
  101. /*------------------------------------*/
  102.  
  103. VOID NEAR SetupPS2IDEPort( USHORT Enable )
  104. {
  105.   USHORT        Data;
  106.   USHORT        PS2_Setup_Reg;
  107.   USHORT        PS2_Planar_Pos;
  108.  
  109.   DISABLE
  110.  
  111.   /*--------------------------*/
  112.   /* Enable Planar Setup Mode */
  113.   /*--------------------------*/
  114.   inp( PS2_SETUP_REG, PS2_Setup_Reg );
  115.   IODelay();
  116.  
  117.   Data = ~PS2_DISABLE_PLANAR_SETUP;
  118.  
  119.   outp( PS2_SETUP_REG, Data );
  120.   IODelay();
  121.  
  122.   /*---------------------------------*/
  123.   /* Enable Fixed Disk POS Reg (103) */
  124.   /*---------------------------------*/
  125.   inp( PS2_PLANAR_POS_REG, PS2_Planar_Pos );
  126.   IODelay();
  127.  
  128.   PS2_Planar_Pos |= ENABLE_FIXED_POS;
  129.  
  130.   outp( PS2_PLANAR_POS_REG, PS2_Planar_Pos );
  131.   IODelay();
  132.  
  133.   /*-------------------------------------------------*/
  134.   /* Enable/Disable Integrated Fixed Disk Controller */
  135.   /*-------------------------------------------------*/
  136.   inp( PS2_FIXED_POS_REG, Data );
  137.   IODelay();
  138.  
  139.   /*-----------------------------------------------*/
  140.   /* Our engineers cant seem to figure out how     */
  141.   /* to share bits in 3F6/3F7 between the diskette */
  142.   /* and IDE controllers!                          */
  143.   /*-----------------------------------------------*/
  144.  
  145.   if ( Enable )
  146.   {
  147.     Data |= (ENABLE_FIXED_DRIVE | REG_3F7_TO_DSKT);
  148.     Data &= ~REG_3F6_TO_DSKT;
  149.   }
  150.   else
  151.   {
  152.     Data &= ~ENABLE_FIXED_DRIVE;
  153.  
  154.     /*--------------------------------------------------*/
  155.     /* Setting the 3F6/3F7 control bits on a Mod 30-286 */
  156.     /* causes the machine to reboot!                    */
  157.     /*--------------------------------------------------*/
  158.     if ( MachineID != MCHID_30286 )
  159.     {
  160.       Data |= (REG_3F6_TO_DSKT | REG_3F7_TO_DSKT);
  161.     }
  162.   }
  163.  
  164.   outp( PS2_FIXED_POS_REG, Data );
  165.   IODelay();
  166.  
  167.   /*---------------------------------------*/
  168.   /* Restore original Planar setup reg (94)*/
  169.   /*---------------------------------------*/
  170.   outp( PS2_SETUP_REG, PS2_Setup_Reg )
  171.   IODelay();
  172.  
  173.   ENABLE
  174. }
  175.  
  176.