;*DDK*************************************************************************/
;
; COPYRIGHT    Copyright (C) 1995 IBM Corporation
;
;    The following IBM OS/2 WARP source code is provided to you solely for
;    the purpose of assisting you in your development of OS/2 WARP device
;    drivers. You may use this code in accordance with the IBM License
;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
;    Copyright statement may not be removed.;
;*****************************************************************************/
;*****************************************************************************/
;
;
;    The following IBM OS/2 2.1 source code is provided to you solely for
;    the purpose of assisting you in your development of OS/2 2.x device
;    drivers. You may use this code in accordance with the IBM License
;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
;    Copyright statement may not be removed.;
;*****************************************************************************/
;/*****************************************************************************
;*
;* SOURCE FILE NAME = CS_IDC.ASM
;*
;* DESCRIPTIVE NAME =
;*
;*
;* VERSION
;*
;* DATE
;*
;* DESCRIPTION
;*
;* FUNCTIONS
;*
;*
;* NOTES        NONE
;*
;* STRUCTURES   NONE
;*
;* EXTERNAL REFERENCES
;*
;*              NONE
;*
;* EXTERNAL FUNCTIONS
;*
;*              NONE
;*
;* CHANGE ACTIVITY =
;*   DATE      FLAG        APAR   CHANGE DESCRIPTION
;*   --------  ----------  -----  --------------------------------------
;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx
;*   03/13/95              113752 Set up DS before calling IDC Entry Point in PCMCIA
;*****************************************************************************/

.286
.287

;*
;* constant definitions
;*
ATTACHDD equ 42


_DATA   SEGMENT WORD PUBLIC 'DATA'
_DATA   ENDS

_BSS    SEGMENT WORD PUBLIC 'BSS'
_BSS    ENDS

CONST   SEGMENT WORD PUBLIC 'CONST'
CONST   ENDS

_TEXT   SEGMENT WORD PUBLIC 'CODE'
_TEXT   ENDS

DGROUP  GROUP   _DATA, CONST, _BSS
CGRP    GROUP   _TEXT


_DATA   SEGMENT
Driver_name       DB 'PCMCIA$ ',  00H
Driver_handle     DW 6 DUP (0)
Driver_entry_func DW 2 DUP (0)
Driver_DS         DW        0     ; @113752

EXTRN Device_help:NEAR
_DATA   ENDS


_TEXT   SEGMENT WORD PUBLIC 'CODE'
        ASSUME cs:CGRP, ds:DGROUP, es:NOTHING, ss:NOTHING


;/***************************************************************************
;*
;* FUNCTION NAME = _cs_idc_init
;*
;* DESCRIPTION   = short cs_idc_init(void)
;*
;* INPUT         =
;*
;* OUTPUT        =
;*
;* RETURN-NORMAL =
;*
;* RETURN-ERROR  =
;*
;**************************************************************************/

PUBLIC _cs_idc_init
_cs_idc_init PROC NEAR

            push bx                    ; attach to card services driver
            push di
            push dx

            mov  bx,OFFSET DGROUP:Driver_name
            mov  di,OFFSET DGROUP:Driver_handle
            mov  dl,ATTACHDD
            call DWORD PTR Device_help
            jc   error1

                                       ; if successful get entry point
                                       ;                to cs driver
next:       mov  ax,WORD PTR Driver_handle + 6    ;offset
            mov  dx,WORD PTR Driver_handle + 8    ;segment
            mov  bx,WORD PTR Driver_handle + 0ah  ; @113752 - DS of IDC DD
            mov  WORD PTR Driver_entry_func,ax
            mov  WORD PTR Driver_entry_func+2,dx
            mov  WORD PTR Driver_DS,bx               ; @113752
            mov  ax,0
            jmp  done1

error1:     mov  ax,-1

done1:      pop  dx
            pop  di
            pop  bx
            ret

_cs_idc_init endp


;/***************************************************************************
;*
;* FUNCTION NAME = _do_card_services
;*
;* DESCRIPTION   = void do_card_services(IDC_PACKET *idc_packP)
;*
;* INPUT         =
;*
;* OUTPUT        =
;*
;* RETURN-NORMAL =
;*
;* RETURN-ERROR  =
;*
;**************************************************************************/

public _do_card_services
_do_card_services proc near

            push bp                    ; save registers
            mov bp,sp
            push si
            push di
            push cx
            push es
            push bx
            push ds                    ; @113752

            mov  bx,WORD PTR [bp+4]    ; set up function argument
            mov  al,BYTE PTR [bx]

            mov  ah,0afh               ; set up static value

            mov  dx,WORD PTR [bx+1]    ; set up handle

            mov  di,WORD PTR [bx+5]    ; set up pointer
            mov  si,WORD PTR [bx+3]

            mov  cx,WORD PTR [bx+7]    ; set up arglength

            mov  es,WORD PTR [bx+11]   ; set up argpointer
            mov  bx,WORD PTR [bx+9]

            mov  ds,Driver_DS          ; @113752

            call DWORD PTR Driver_entry_func ; make the idc request to card services

                                       ; error if carry flag set
            jc   done3                 ;   - return code in ax

            mov  bx,WORD PTR [bp+4]    ; set up handle
            mov  WORD PTR [bx+1],dx

            mov  ax,0                  ; call successful

done3:      pop  ds                    ; @113752
            pop  bx
            pop  es                    ; restore registers - return
            pop  cx
            pop  di
            pop  si
            mov  sp,bp
            pop  bp
            ret

_do_card_services endp

_TEXT ENDS

        END
