home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / PCMCIA / CLDFM / CS_UTIL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  27.6 KB  |  949 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. /**************************************************************************
  13.  *
  14.  * SOURCE FILE NAME = UTIL.C
  15.  *
  16.  * DESCRIPTIVE NAME =
  17.  *
  18.  *
  19.  * VERSION =
  20.  *
  21.  * DATE
  22.  *
  23.  * DESCRIPTION
  24.  *
  25.  *
  26.  * FUNCTIONS
  27.  *
  28.  * ENTRY POINTS:
  29.  *
  30.  * DEPENDENCIES:
  31.  *
  32.  * NOTES
  33.  *
  34.  *
  35.  * STRUCTURES
  36.  *
  37.  * EXTERNAL REFERENCES
  38.  *
  39.  * EXTERNAL FUNCTIONS
  40.  *
  41. */
  42.  
  43. #include "types.h"
  44. #include "cs.h"
  45. #include "cs_util.h"
  46. #include "cs_idc.h"
  47. #include "card_id.h"
  48.  
  49.    /*
  50.    ** type definitions
  51.    */
  52. #if defined (CS_2_0)
  53. typedef struct {
  54.     USHORT socket;                     /* logical socket                 */
  55.     USHORT base_ports1;                /* base port address for range    */
  56.     UCHAR num_ports1;                  /* number of contiguous ports     */
  57.     UCHAR attributes1;                 /* bit-mapped attributes          */
  58.     USHORT base_ports2;                /* base port address for range    */
  59.     UCHAR num_ports2;                  /* number of contiguous ports     */
  60.     UCHAR attributes2;                 /* bit-mapped attributes          */
  61.     UCHAR address_lines;               /* num of address lines decoded   */
  62. } REQUEST_IO;
  63. #endif
  64.  
  65. #if defined (CS_1_7)
  66. typedef struct {
  67.     USHORT socket;                     /* logical socket                 */
  68.     USHORT base_ports1;                /* base port address for range    */
  69.     UCHAR num_ports1;                  /* number of contiguous ports     */
  70.     UCHAR attributes1;                 /* bit-mapped attributes          */
  71.     USHORT base_ports2;                /* base port address for range    */
  72.     UCHAR num_ports2;                  /* number of contiguous ports     */
  73.     UCHAR attributes2;                 /* bit-mapped attributes          */
  74.     UCHAR address_lines;               /* num of address lines decoded   */
  75.     UCHAR access_speed;                /* access speed for io ranges     */
  76. } REQUEST_IO;
  77. #endif
  78.  
  79. typedef struct {
  80.     USHORT socket;                     /* logical socket;                */
  81.     USHORT attributes;                 /* bit mapped attributes          */
  82.     UCHAR assigned_irq;                /* irq number assigned by cs      */
  83.     UCHAR irq_info1;                   /* first PCMCIA irq byte          */
  84.     USHORT irq_info2;                  /* optional PCMCIA irq bytes      */
  85. } REQUEST_IRQ;
  86.  
  87. #if defined (CS_2_0)
  88. typedef struct {
  89.     USHORT socket;                     /* logical socket                 */
  90.     USHORT attributes;                 /* bit mask for attributes        */
  91.     UCHAR vcc;                         /* vcc setting                    */
  92.     UCHAR vpp1;                        /* vpp1 setting                   */
  93.     UCHAR vpp2;                        /* vpp2 setting                   */
  94.     UCHAR int_type;                    /* interface type                 */
  95.     ULONG config_base;                 /* base address of registers      */
  96.     UCHAR status;                      /* status register setting        */
  97.     UCHAR pin;                         /* card pin register setting      */
  98.     UCHAR copy;                        /* copy register setting          */
  99.     UCHAR option;                      /* option register setting        */
  100.     UCHAR present;                     /* config registers present       */
  101. } REQUEST_CONFIGURATION;
  102. #endif
  103.  
  104. #if defined (CS_1_7)
  105. typedef struct {
  106.     USHORT socket;                     /* logical socket                 */
  107.     USHORT attributes;                 /* bit mask for attributes        */
  108.     UCHAR vcc;                         /* vcc setting                    */
  109.     UCHAR vpp1;                        /* vpp1 setting                   */
  110.     UCHAR vpp2;                        /* vpp2 setting                   */
  111.     UCHAR status;                      /* status register setting        */
  112.     UCHAR pin;                         /* card pin register setting      */
  113.     UCHAR copy;                        /* copy register setting          */
  114.     UCHAR option;                      /* option register setting        */
  115.     UCHAR present;                     /* config registers present       */
  116.     ULONG config_base;                 /* base address of registers      */
  117.     UCHAR int_type;                    /* interface type                 */
  118. } REQUEST_CONFIGURATION;
  119. #endif
  120.  
  121. #if defined (CS_2_0)
  122. typedef struct {
  123.     USHORT socket;                     /* logical socket;                */
  124.     USHORT attributes;                 /* bit mapped attributes          */
  125.     UCHAR assigned_irq;                /* irq number assigned            */
  126. } RELEASE_IRQ;
  127. #endif
  128.  
  129. #if defined (CS_1_7)
  130. typedef struct {
  131.     USHORT socket;                     /* logical socket;                */
  132.     USHORT attributes;                 /* bit mapped attributes          */
  133.     UCHAR assigned_irq;                /* irq number assigned            */
  134.     UCHAR irq_info1;                   /* first PCMCIA irq byte          */
  135.     USHORT irq_info2;                  /* optional PCMCIA irq bytes      */
  136. } RELEASE_IRQ;
  137. #endif
  138.  
  139. #if defined (CS_2_0)
  140. typedef struct {
  141.     USHORT socket;                     /* logical socket                 */
  142.     USHORT base_ports1;                /* base port address for range    */
  143.     UCHAR num_ports1;                  /* number of contiguous ports     */
  144.     UCHAR attributes1;                 /* bit-mapped attributes          */
  145.     USHORT base_ports2;                /* base port address for range    */
  146.     UCHAR num_ports2;                  /* number of contiguous ports     */
  147.     UCHAR attributes2;                 /* bit-mapped attributes          */
  148.     UCHAR address_lines;               /* num of address lines decoded   */
  149. } RELEASE_IO;
  150. #endif
  151.  
  152. #if defined (CS_1_7)
  153. typedef struct {
  154.     USHORT socket;                     /* logical socket                 */
  155.     USHORT base_ports1;                /* base port address for range    */
  156.     UCHAR num_ports1;                  /* number of contiguous ports     */
  157.     UCHAR attributes1;                 /* bit-mapped attributes          */
  158.     USHORT base_ports2;                /* base port address for range    */
  159.     UCHAR num_ports2;                  /* number of contiguous ports     */
  160.     UCHAR attributes2;                 /* bit-mapped attributes          */
  161.     UCHAR address_lines;               /* num of address lines decoded   */
  162.     UCHAR access_speed;                /* access speed for io ports      */
  163. } RELEASE_IO;
  164. #endif
  165.  
  166. typedef struct {
  167.     USHORT socket;                     /* logical socket                 */
  168. } RELEASE_CONFIGURATION;
  169.  
  170. typedef struct {
  171.     USHORT socket;                     /* logical socket                 */
  172.     USHORT attributes;                 /* bit-mapped attributes          */
  173.     UCHAR desired_tuple;               /* desired tuple code value       */
  174.     UCHAR reserved;                    /* reserved                       */
  175.     USHORT flags;                      /* cs tuple flags data            */
  176.     ULONG link_offset;                 /* cs link state information      */
  177.     ULONG cis_offset;                  /* cs cis state information       */
  178.     UCHAR tuple_code;                  /* tuple found                    */
  179.     UCHAR tuple_link;                  /* link value for tuple           */
  180. } GET_FIRST_TUPLE;
  181.  
  182. typedef struct {
  183.     USHORT socket;                     /* logical socket                 */
  184.     USHORT attributes;                 /* bit-mapped attributes          */
  185.     UCHAR desired_tuple;               /* desired tuple code value       */
  186.     UCHAR tuple_offset;                /* offset into tuple              */
  187.     USHORT flags;                      /* cs tuple flags data            */
  188.     ULONG link_offset;                 /* cs link state info             */
  189.     ULONG cis_offset;                  /* cs cis state information       */
  190.     USHORT tuple_data_max;             /* max size of tuple data area    */
  191.     USHORT tuple_data_len;             /* num of bytes in tuple body     */
  192.     UCHAR  tuple_data[CARD_ID_LEN];    /* tuple data                     */
  193. } GET_TUPLE_DATA;
  194.  
  195.  
  196.    /*
  197.    ** private global variables
  198.    */
  199. extern USHORT  Client_handle;
  200.  
  201.    /*
  202.    ** private  function prototypes
  203.    */
  204. USHORT cs_request_io(USHORT, USHORT);
  205. USHORT cs_request_irq(USHORT, USHORT);
  206. USHORT cs_request_configuration(USHORT, USHORT);
  207. USHORT cs_release_irq(USHORT, USHORT);
  208. USHORT cs_release_io(USHORT, USHORT);
  209. USHORT cs_release_configuration(USHORT);
  210.  
  211. /****************************************************************************
  212.  *
  213.  * FUNCTION NAME = cs_acquire_resource
  214.  *
  215.  * DESCRIPTION   = This function acquires resources and performs initialization
  216.  *                 activities on both pcic and pcmcia card.
  217.  *                 The parameter 'socket_num' contains the socket to initalize.
  218.  *                 The parameters 'io_address' and 'irq_num' contain the io
  219.  *                 address and the interrupt request number to assign to the
  220.  *                 socket.
  221.  *
  222.  * INPUT         =
  223.  *
  224.  * OUTPUT        =
  225.  *
  226.  * RETURN-NORMAL = 0
  227.  *
  228.  * RETURN-ERROR  = -1
  229.  *
  230.  ****************************************************************************/
  231.  
  232. USHORT  cs_acquire_resource(USHORT socket_num, USHORT io_address,
  233.                                                         USHORT irq_num)
  234. {
  235.     USHORT ret_code;
  236.  
  237.         /* request the interrupt request number - return if error
  238.         */
  239.     if ((ret_code = cs_request_irq(socket_num, irq_num)) != SUCCESS)
  240.         return(ret_code);
  241.  
  242.         /* request io address - return if error
  243.         */
  244.     if ((ret_code = cs_request_io(socket_num, io_address )) != SUCCESS)
  245.     {
  246.         cs_release_irq(socket_num, irq_num);
  247.         return(ret_code);
  248.     }
  249.  
  250.         /* request configuration - return if error
  251.         */
  252.     if ((ret_code = cs_request_configuration(socket_num, io_address))
  253.                                                              != SUCCESS)
  254.     {
  255.         cs_release_irq(socket_num, irq_num);
  256.         cs_release_io(socket_num, io_address);
  257.         return(ret_code);
  258.     }
  259.  
  260.         /* return successful
  261.         */
  262.     return(SUCCESS);
  263. }
  264.  
  265. /****************************************************************************
  266.  *
  267.  * FUNCTION NAME = cs_requiest_irq
  268.  *
  269.  * DESCRIPTION   = This function requests from card services that a
  270.  *                 particular interrupt be assigned to a socket.
  271.  *                 The parameters 'socket_num' and 'irq_num' are the
  272.  *                 socket number and interrupt number
  273.  *
  274.  * INPUT         =
  275.  *
  276.  * OUTPUT        =
  277.  *
  278.  * RETURN-NORMAL = 0
  279.  *
  280.  * RETURN-ERROR  = -1
  281.  *
  282.  ****************************************************************************/
  283.  
  284.      REQUEST_IRQ data4;
  285.     IDC_PACKET   idc_pack4;
  286.  
  287. static USHORT cs_request_irq(USHORT socket_num, USHORT irq_num)
  288.  
  289.  {
  290.     USHORT ret_code;
  291.  
  292.          /* set up logical socket number
  293.          */
  294.      data4.socket = socket_num;
  295.  
  296.          /* set up attributes - time multiplexed sharing
  297.          */
  298. #if defined (CS_2_0)
  299.      data4.attributes = 0x0002;
  300. #endif
  301.  
  302. #if defined (CS_1_7)
  303.      data4.attributes = 0x0001;
  304. #endif
  305.          /* set up for level interrupt and make second info field valid
  306.          */
  307.      data4.irq_info1 = 0x30;
  308.      data4.irq_info1 |= irq_num;
  309.  
  310.          /* designate desired irq number
  311.          */
  312.      data4.irq_info2 = 0x0001;
  313.      data4.irq_info2 <<= irq_num;
  314.  
  315.          /* set codes for request irq
  316.          */
  317.      idc_pack4.function = 0x20;
  318.  
  319.          /* set client handle
  320.          */
  321.      idc_pack4.handle = Client_handle;
  322.  
  323.      idc_pack4.pointer = (ULONG) 0;
  324.  
  325.          /* set size of packet
  326.          */
  327.      idc_pack4.arglength = sizeof(REQUEST_IRQ);
  328.  
  329.          /* set segment and offset for packet
  330.          */
  331.      idc_pack4.argpointer = (ULONG) (REQUEST_IRQ far *) &data4;
  332.  
  333.      if ((ret_code = do_card_services(&idc_pack4)) != SUCCESS)
  334.           return(ret_code);
  335.  
  336.          /* return success
  337.          */
  338.      return(SUCCESS);
  339. }
  340.  
  341. /****************************************************************************
  342.  *
  343.  * FUNCTION NAME = cs_request_io
  344.  *
  345.  * DESCRIPTION   = This function requests from card services that a particular
  346.  *                 io address be assigned to a socket.
  347.  *                 The parameters 'socket_num' and 'io_address' contain the
  348.  *                 socket number and io address.
  349.  *
  350.  * INPUT         =
  351.  *
  352.  * OUTPUT        =
  353.  *
  354.  * RETURN-NORMAL = 0
  355.  *
  356.  * RETURN-ERROR  = -1
  357.  *
  358.  ****************************************************************************/
  359.  
  360.     REQUEST_IO data5;
  361.     IDC_PACKET idc_pack5;
  362.  
  363. static USHORT cs_request_io(USHORT socket_num, USHORT io_address)
  364.  
  365. {
  366.     USHORT ret_code;
  367.  
  368.         /* set up logical socket
  369.         */
  370.     data5.socket = socket_num;
  371.  
  372.         /* set up base address for ports
  373.         */
  374.     data5.base_ports1 = io_address;
  375.  
  376.         /* set up range for ports
  377.         */
  378.     data5.num_ports1 = 0x08;
  379.  
  380.         /* set up attributes - specify that the addresses are not shared with
  381.         ** another client
  382.         */
  383.     data5.attributes1 = 0x00;
  384.  
  385.         /* set up additonal port info - no additional ports specified
  386.         */
  387.     data5.base_ports2 = 0x0000;
  388.     data5.num_ports2= 0x00;
  389.     data5.attributes2 = 0x00;
  390.  
  391.         /* set up address line info - specify no additional addresses need
  392.         ** to marked as in use
  393.         */
  394. #if defined (CS_2_0)
  395.     data5.address_lines = 16;
  396. #endif
  397.  
  398. #if defined (CS_1_7)
  399.  
  400.         /* set up address line info - specify no additional addresses need
  401.         ** to marked as in use
  402.         */
  403.     data5.address_lines = 0;
  404.  
  405.         /* set up access speed - specify that access speed for ports is
  406.         ** 100 nsec
  407.         */
  408.     data5.access_speed = 0x04;
  409. #endif
  410.         /* set up codes for request io
  411.         */
  412.     idc_pack5.function = 0x1f;
  413.  
  414.         /* set up client handle
  415.         */
  416.     idc_pack5.handle = Client_handle;
  417.  
  418.     idc_pack5.pointer = (ULONG) 0;
  419.  
  420.         /* set up size of packet
  421.         */
  422.     idc_pack5.arglength = sizeof(REQUEST_IO);
  423.  
  424.         /* set up segment and offset for packet
  425.         */
  426.     idc_pack5.argpointer = (ULONG) (REQUEST_IO far *) &data5;
  427.  
  428.     if ((ret_code = do_card_services(&idc_pack5)) != SUCCESS)
  429.          return(ret_code);
  430.  
  431.         /* return successful
  432.         */
  433.     return(SUCCESS);
  434. }
  435.  
  436. /****************************************************************************
  437.  *
  438.  * FUNCTION NAME = cs_request_configuration
  439.  *
  440.  * DESCRIPTION   = This function requests from card services that a
  441.  *                 particular i/o address be assigned to a socket.
  442.  *                 The parameters 'socket_num' and 'io_address' are
  443.  *                 the socket number and io address.
  444.  *
  445.  * INPUT         =
  446.  *
  447.  * OUTPUT        =
  448.  *
  449.  * RETURN-NORMAL = 0
  450.  *
  451.  * RETURN-ERROR  = -1
  452.  *
  453.  ****************************************************************************/
  454.  
  455.     REQUEST_CONFIGURATION data6;
  456.     IDC_PACKET idc_pack6;
  457.  
  458. static USHORT cs_request_configuration(USHORT socket_num, USHORT io_address)
  459.  
  460. {
  461.     UCHAR option_reg_value;
  462.     USHORT ret_code;
  463.  
  464.         /* set up socket number
  465.         */
  466.     data6.socket = socket_num;
  467.  
  468. #if defined (CS_2_0)
  469.  
  470.         /* set up exclusive use and enable irq
  471.         */
  472.     data6.attributes = 0x0002;
  473. #endif
  474.  
  475. #if defined (CS_1_7)
  476.  
  477.         /* set up exclusive use and enable irq
  478.         */
  479.     data6.attributes = 0x0003;
  480. #endif
  481.         /* set up for 5.0 volts (50 x 0.1)
  482.         */
  483.     data6.vcc = 50;
  484.  
  485.         /* set vpp - no requirements
  486.         */
  487.     data6.vpp1 = 0;
  488.     data6.vpp2 = 0;
  489.  
  490.         /* set up option configuration register for normal operation, card
  491.         ** enable, and designated com port
  492.         */
  493.     switch (io_address)
  494.     {
  495.         case 0x3f8:
  496.             option_reg_value = 0x20;
  497.             break;
  498.         case 0x2f8:
  499.             option_reg_value = 0x21;
  500.             break;
  501.         case 0x3e8:
  502.             option_reg_value = 0x22;
  503.             break;
  504.         case 0x2e8:
  505.             option_reg_value = 0x23;
  506.             break;
  507.     };
  508.         /* set up interface type - memory and i/o
  509.         */
  510.     data6.int_type = 0x02;
  511.  
  512.         /* set up base address of config registers in attribute memory
  513.         */
  514.     data6.config_base = (ULONG) 0x100;
  515.  
  516.         /* set option register value
  517.         */
  518.     data6.option = option_reg_value;
  519.  
  520.         /* set pin register value
  521.         */
  522.     data6.pin = 0x00;
  523.  
  524.         /* set copy register value
  525.         */
  526.     data6.copy = 0x00;
  527.  
  528.         /* set status register value - enable audio and ring indicate
  529.         */
  530.     data6.status = 0x18;
  531.  
  532.         /* set which registers are present - option and status registers
  533.         ** are present
  534.         */
  535.     data6.present = 0x03;
  536.  
  537.         /* set code for request configuration
  538.         */
  539.     idc_pack6.function = 0x30;
  540.  
  541.         /* set client handle
  542.         */
  543.     idc_pack6.handle = Client_handle;
  544.  
  545.     idc_pack6.pointer = (ULONG) 0;
  546.  
  547.         /* set size of packet
  548.         */
  549.     idc_pack6.arglength = sizeof(REQUEST_CONFIGURATION);
  550.  
  551.         /* set segment and offset for request configuration
  552.         */
  553.     idc_pack6.argpointer = (ULONG) (REQUEST_CONFIGURATION far *) &data6;
  554.  
  555. /* #define DEBUG
  556. ** _asm push ax
  557. ** _asm int 3
  558. ** _asm mov ax,7
  559. ** _asm pop ax
  560. ** #endif
  561. */
  562.     if ((ret_code = do_card_services(&idc_pack6)) != SUCCESS)
  563.         return(ret_code);
  564.  
  565.         /* return successful
  566.         */
  567.     return(SUCCESS);
  568. }
  569.  
  570. /****************************************************************************
  571.  *
  572.  * FUNCTION NAME = cs_is_modem_card
  573.  *
  574.  * DESCRIPTION   = This function determines if a modem card is present in
  575.  *                 a particular socket.
  576.  *                 The parameter 'socket_num' contains the number of the
  577.  *                 socket to check.
  578.  *                 The function returns the value TRUE if a modem card is
  579.  *                 present.  Otherwise, the value FALSE is returned if a
  580.  *                 modem card is not present or if an error occurred.
  581.  *
  582.  * INPUT         =
  583.  *
  584.  * OUTPUT        =
  585.  *
  586.  * RETURN-NORMAL =
  587.  * RETURN-ERROR  = FALSE
  588.  *
  589.  ****************************************************************************/
  590.  
  591.     GET_FIRST_TUPLE data7;
  592.     GET_TUPLE_DATA  data8;
  593.     IDC_PACKET      idc_pack7;
  594.  
  595. BOOL cs_is_modem_card(USHORT socket_num)
  596.  
  597. {
  598.  
  599.         /* set up socket number
  600.         */
  601.     data7.socket = socket_num;
  602.  
  603.         /* set up attributes
  604.         */
  605.     data7.attributes = 0x0000;
  606.  
  607.         /* set up to look for  first tuple
  608.         */
  609.     data7.desired_tuple = 0x15;
  610.  
  611.         /* set up codes for get first tuple
  612.         */
  613.     idc_pack7.function = 0x07;
  614.  
  615.         /* set up client handle
  616.         */
  617.     idc_pack7.handle = Client_handle;
  618.  
  619.     idc_pack7.pointer = (ULONG) 0;
  620.  
  621.         /* set up size of packet
  622.         */
  623.     idc_pack7.arglength = sizeof(GET_FIRST_TUPLE);
  624.  
  625.         /* set up segment and offset of packet
  626.         */
  627.     idc_pack7.argpointer = (ULONG) (GET_FIRST_TUPLE far *) &data7;
  628.  
  629.  
  630.     if (do_card_services(&idc_pack7) != SUCCESS)
  631.        return(FALSE);
  632.  
  633.         /* set up socket number
  634.         */
  635.     data8.socket = socket_num;
  636.  
  637.         /* set up attributes
  638.         */
  639.     data8.attributes = data7.attributes;
  640.  
  641.         /* set up desired tuple code value
  642.         */
  643.     data8.desired_tuple = data7.desired_tuple;
  644.  
  645.         /* set up data flags
  646.         */
  647.     data8.flags = data7.flags;
  648.  
  649.         /* set up link state information
  650.         */
  651.     data8.link_offset = data7.link_offset;
  652.  
  653.         /* set up cis state information
  654.         */
  655.     data8.cis_offset = data7.cis_offset;
  656.  
  657.         /* set up offset into tuple from link byte
  658.         */
  659.     data8.tuple_offset = 0x04;
  660.  
  661.         /* set up maximum size of tuple data area
  662.         */
  663.     data8.tuple_data_max =  CARD_ID_LEN;
  664.  
  665.         /* set up codes for get tuple data
  666.         */
  667.     idc_pack7.function = 0x0d;
  668.  
  669.         /* set up client handle
  670.         */
  671.     idc_pack7.handle = Client_handle;
  672.  
  673.     idc_pack7.pointer = (ULONG) 0;
  674.  
  675.         /* set up size of packet
  676.         */
  677.     idc_pack7.arglength = sizeof(GET_TUPLE_DATA);
  678.  
  679.         /* set up segment and offset of packet
  680.         */
  681.     idc_pack7.argpointer = (ULONG) (GET_TUPLE_DATA far *) &data8;
  682.  
  683.  
  684.     if (do_card_services(&idc_pack7) != SUCCESS)
  685.         return(FALSE);
  686.  
  687.         /* return true if expected tuple contents
  688.         */
  689.     if (correct_card_id((UCHAR far *) data8.tuple_data))
  690.         return(TRUE);
  691.  
  692.     return(FALSE);
  693. }
  694.  
  695. /****************************************************************************
  696.  *
  697.  * FUNCTION NAME = cs_release_resource
  698.  *
  699.  * DESCRIPTION   = This function requests from card services that resources
  700.  *                 be released for a particular socket.
  701.  *                 The parameter 'socket_num' is the socket number for
  702.  *                 which to release resources. The parameters 'io_address'
  703.  *                 and 'irq_num' are the io address and interrupt number
  704.  *                 to release.
  705.  *
  706.  * INPUT         =
  707.  *
  708.  * OUTPUT        =
  709.  *
  710.  * RETURN-NORMAL = 0
  711.  *
  712.  * RETURN-ERROR  = -1
  713.  *
  714.  ****************************************************************************/
  715.  
  716. USHORT cs_release_resource(USHORT socket_num, USHORT io_address,
  717.                                                                                                                   USHORT irq_num)
  718. {
  719.     USHORT ret_code;
  720.  
  721.         /* release configuration - return if error
  722.         */
  723.     if ((ret_code = cs_release_configuration(socket_num)) != SUCCESS)
  724.         return(ret_code);
  725.  
  726.         /* release interrupt - return if error
  727.         */
  728.     if ((ret_code = cs_release_irq(socket_num, irq_num)) != SUCCESS)
  729.         return(ret_code);
  730.  
  731.         /* release io address - return if error
  732.         */
  733.     if ((ret_code = cs_release_io(socket_num, io_address)) != SUCCESS)
  734.         return(ret_code);
  735.  
  736.         /* return success
  737.         */
  738.     return(SUCCESS);
  739. }
  740.  
  741. /****************************************************************************
  742.  *
  743.  * FUNCTION NAME =
  744.  *
  745.  * DESCRIPTION   = This function requests from card services that a
  746.  *                 configuration be released for a socket.
  747.  *                 The parameter 'socket_num' is the socket number.
  748.  *
  749.  * INPUT         =
  750.  *
  751.  * OUTPUT        =
  752.  *
  753.  * RETURN-NORMAL = -1
  754.  *
  755.  * RETURN-ERROR  = 0
  756.  *
  757.  ****************************************************************************/
  758.  
  759.     RELEASE_CONFIGURATION data11;
  760.     IDC_PACKET            idc_pack10;
  761.  
  762. static USHORT cs_release_configuration(USHORT socket_num)
  763.  
  764. {
  765.     USHORT ret_code;
  766.  
  767.         /* set up logical socket
  768.         */
  769.     data11.socket = socket_num;
  770.  
  771.         /* set codes for release configuration
  772.         */
  773.     idc_pack10.function = 0x1e;
  774.  
  775.         /* set client handle
  776.         */
  777.     idc_pack10.handle = Client_handle;
  778.  
  779.     idc_pack10.pointer = (ULONG) 0;
  780.  
  781.         /* set size of packet
  782.         */
  783.     idc_pack10.arglength = sizeof(RELEASE_CONFIGURATION);
  784.  
  785.         /* set segment and offset for packet
  786.         */
  787.     idc_pack10.argpointer = (ULONG) (RELEASE_CONFIGURATION far *) &data11;
  788.  
  789.     if ((ret_code = do_card_services(&idc_pack10)) != SUCCESS)
  790.         return(ret_code);
  791.  
  792.         /* return success
  793.         */
  794.     return(SUCCESS);
  795. }
  796.  
  797. /****************************************************************************
  798.  *
  799.  * FUNCTION NAME = cs_release_irq
  800.  *
  801.  * DESCRIPTION   = This function requests from card services that an
  802.  *                 interrupt number be released for a socket.
  803.  *                 The parameters 'socket_num' and 'irq_num' are the
  804.  *                 socket number and interrupt number.
  805.  *
  806.  * INPUT         =
  807.  *
  808.  * OUTPUT        =
  809.  *
  810.  * RETURN-NORMAL = 0
  811.  *
  812.  * RETURN-ERROR  = -1
  813.  *
  814.  ****************************************************************************/
  815.  
  816.     RELEASE_IRQ data9;
  817.     IDC_PACKET  idc_pack8;
  818.  
  819. static USHORT cs_release_irq(USHORT socket_num, USHORT irq_num)
  820.  
  821. {
  822.     USHORT ret_code;
  823.  
  824.         /* set up logical socket number
  825.         */
  826.     data9.socket = socket_num;
  827.  
  828.         /* set attributes - prefer exclusive irq
  829.         */
  830. #if defined (CS_1_7)
  831.     data9.attributes = 0x0001;
  832. #endif
  833.  
  834. #if defined (CS_2_0)
  835.     data9.attributes = 0x0002;
  836. #endif
  837.  
  838.         /* set up irq number - designate previously established irq
  839.         */
  840.     data9.assigned_irq = irq_num;
  841.  
  842.         /* set code for release irq
  843.         */
  844.     idc_pack8.function = 0x1c;
  845.  
  846.         /* set client handle
  847.         */
  848.     idc_pack8.handle = Client_handle;
  849.  
  850.     idc_pack8.pointer = (ULONG) 0;
  851.  
  852.         /* set size of packet
  853.         */
  854.     idc_pack8.arglength = sizeof(RELEASE_IRQ);
  855.  
  856.         /* set segment and offset for packet
  857.         */
  858.     idc_pack8.argpointer = (ULONG) (RELEASE_IRQ far *) &data9;
  859.  
  860.  
  861.     if ((ret_code = do_card_services(&idc_pack8)) != SUCCESS)
  862.         return(ret_code);
  863.  
  864.         /* return success
  865.         */
  866.     return(SUCCESS);
  867. }
  868.  
  869. /****************************************************************************
  870.  *
  871.  * FUNCTION NAME = cs_release_io
  872.  *
  873.  * DESCRIPTION   = This function requests from card services that an
  874.  *                 io address be released for a socket.
  875.  *                 The parameters 'socket_num' and 'io_address' are
  876.  *                 the socket number and io address.
  877.  *
  878.  * INPUT         =
  879.  *
  880.  * OUTPUT        =
  881.  *
  882.  * RETURN-NORMAL = 0
  883.  *
  884.  * RETURN-ERROR  = -1
  885.  *
  886.  ****************************************************************************/
  887.  
  888.     RELEASE_IO data10;
  889.     IDC_PACKET idc_pack9;
  890.  
  891. static USHORT cs_release_io(USHORT socket_num, USHORT io_address)
  892.  
  893. {
  894.     USHORT ret_code;
  895.  
  896.         /* set up logical socket
  897.         */
  898.     data10.socket = socket_num;
  899.  
  900.         /* set up base address for ports
  901.         */
  902.     data10.base_ports1 = io_address;
  903.  
  904.         /* set up range for ports
  905.         */
  906.     data10.num_ports1 = 0x08;
  907.  
  908.         /* set attributes - specify that the addresses are not shared with
  909.         ** another client
  910.         */
  911.     data10.attributes1 = 0x00;
  912.  
  913.         /* set additional port info - no additional ports specified
  914.         */
  915.     data10.base_ports2 = 0x0000;
  916.     data10.num_ports2= 0x00;
  917.     data10.attributes2 = 0x00;
  918.  
  919.         /* set address line info
  920.         */
  921.     data10.address_lines = 16;
  922.  
  923.         /* set codes for release io
  924.         */
  925.     idc_pack9.function = 0x1b;
  926.  
  927.         /* set client handle
  928.         */
  929.     idc_pack9.handle = Client_handle;
  930.  
  931.     idc_pack9.pointer = (ULONG) 0;
  932.  
  933.         /* set size of packet
  934.         */
  935.     idc_pack9.arglength = sizeof(RELEASE_IO);
  936.  
  937.         /* set segment and offset for packet
  938.         */
  939.     idc_pack9.argpointer = (ULONG) (RELEASE_IO far *) &data10;
  940.  
  941.  
  942.     if ((ret_code = do_card_services(&idc_pack9)) != SUCCESS)
  943.         return(ret_code);
  944.  
  945.         /* return success
  946.         */
  947.     return(SUCCESS);
  948. }
  949.