home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / PCMCIA / SOCKET / SSPCICVA.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  10KB  |  247 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Award Software International Inc., 1994
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.                 name    SSPCICVA
  13.                 page    60, 132
  14.                 title   'SSPCICVA'
  15. ;******************************************************************************
  16. ;*
  17. ;*                            File SSPCICVA.ASM
  18. ;*
  19. ;*                        Socket Services PCIC File
  20. ;*
  21. ;*                           Validation routines
  22. ;*
  23. ;*
  24. ;*
  25. ;******************************************************************************
  26.  
  27.                 include ssmac.inc           ; Macros
  28.                 include ssdefs.inc          ; Sockets Services definitions
  29.                 include ss_segm.inc         ; Segment definitions
  30.                 include ssPCIC.inc          ; PCIC module defs
  31.  
  32.  
  33. ;*****************************************************************************
  34. ;*                         --- Segment ResCode ---
  35. ;*****************************************************************************
  36. sBegin          ResCode
  37.  
  38.  
  39. COMMENT ~*********************************************************************
  40.         Procedure:      covValidateIRQ
  41.         Revision:       2
  42.         Date:           05/25/1993
  43.         Purpose:        Validate request IRQ level and active state valid
  44.         Entry:          [AL] = IRQ request level
  45.                         [SI] = Ptr to Info Table with valid IRQ levels
  46.         Exit:           [CF] = status
  47.                         If IRQ invalid, then CY and AH = BAD_IRQ
  48.                         Else NC
  49. *****************************************************************************~
  50. covValidateIRQ  PROC    NEAR
  51.                 assume  ds:@data, es:Nothing
  52.  
  53.                 pushx   <cx, dx>
  54.                 push    ax
  55.  
  56.                 mov     dx, word ptr ((CHARTBL PTR [SI]).ActiveLo)
  57.                 test    al, IRQ_HIGH            ; Active low request ?
  58.                 jz      @f                      ; Yes, continue
  59.                                                 ; No, get valid high IRQ levels
  60.                 mov     dx, word ptr ((CHARTBL PTR [SI]).ActiveHi)
  61.  
  62. @@:             mov     cl, al                  ; Setup shift count
  63.                 and     cl, IRQ_LEVEL_MSK       ; Mask for IRQ Level
  64.                 test    cl, NOT P_IRQ15         ; IRQ above 15 ?
  65.                 jnz     BadIRQ                  ; Yes, error out
  66.  
  67.                 mov     ax, 1                   ; Create bit mask for request IRQ level
  68.                 and     cx, P_IRQ15             ; Mask-in IRQ 0 thru 15
  69.                 jcxz    @f                      ; If zero, we're done
  70.  
  71.                 shl     ax, cl                  ; Otherwise shift into appropriate bit
  72.  
  73. @@:             test    ax, dx                  ; Valid IRQ level ?
  74.                 jz      BadIRQ
  75.  
  76.                 pop     ax                      ; Restore ooriginal AX
  77.                 clc                             ; Indicate success
  78.                 jmp     short @f
  79.  
  80. BadIRQ:         mov     ah, BAD_IRQ             ; Indicate     IRQ
  81.                 add     sp, 2                   ; Discard ax in the stack
  82.                 stc
  83.  
  84. @@:             popx    <dx, cx>
  85.                 ret
  86.  
  87. covValidateIRQ  ENDP
  88.  
  89. ;*****************************************************************************
  90. ;*                         --- CheckPowerLevel ---
  91. ;*
  92. ;*     Purpose: Check, if power level is valid
  93. ;*       Input: AL - Power table entry
  94. ;*              AH - VCC or VPP1 or VPP2
  95. ;*              SI - Pointer to the first entry to the power table
  96. ;*              CX - Number of entries into power table
  97. ;*      Output: CY - if level is invalid
  98. ;* Scratch reg: none
  99. ;*     Written: by Alexis A.Piatetsky 10.06.94
  100. ;*****************************************************************************
  101. CheckPowerLevel PROC    NEAR
  102.                 assume  ds:@data, es:Nothing
  103.  
  104.                 pushx   <ax, cx, si>
  105.  
  106.                 mov     si, offset PowerTable
  107.                 mov     cx, [si]            ; Number of table entries
  108.                 add     si, 2               ; Point to the 1st entry
  109.  
  110. ;----------------------- Check, if entry is in the table ----------------------
  111.  
  112.                 cmp     al, cl              ; Entry in range?
  113.                 jae     cpl_fail            ; No, report error
  114.  
  115. ;----------------- Check, if entry is valid for selected power ----------------
  116.  
  117.                 mov     ch, ah              ; Save attribute
  118.                 xor     ah, ah              ; Use word
  119.                 push    cx
  120.                 mov     cx, SIZEOF PWRENTRY
  121.                 mul     cl                  ; Calculate table offset
  122.                 pop     cx
  123.                 add     si, ax              ; Point to selected entry
  124.  
  125.                 test    (PWRENTRY PTR [SI]).ValidSignals, ch
  126.                 jz      cpl_fail
  127.  
  128.                 clc                         ; Report valid entry
  129.                 jmp     short @f            ; Terminate
  130.  
  131. cpl_fail:       stc                         ; Report checking fail
  132. @@:             popx    <si, cx, ax>
  133.                 ret
  134. CheckPowerLevel ENDP
  135.  
  136.  
  137. ;*****************************************************************************
  138. ;*                          --- covValidatePw ---
  139. ;*
  140. ;*     Purpose: Validate Power levels
  141. ;*       Input: [BX] - Pointer to the adapter structure
  142. ;*              [BP] - Pointer to the user args
  143. ;*              SI   - Socket number
  144. ;*              AH   - Lower nibble - Vcc Level
  145. ;*              AL   - Upper nibble - Vpp1 Level, Lower nibble - Vpp2 Level
  146. ;*      Output: If SUCCESS, then NC.
  147. ;*              If error - CY and AH - Error code
  148. ;* Scratch reg: AX, if check fail
  149. ;*     Written: by Alexis A.Piatetsky 09.06.94
  150. ;*****************************************************************************
  151. covValidatePw   PROC    NEAR
  152.                 assume  ds:@data, es:Nothing
  153.  
  154.                 pushx   <cx, dx, ax>
  155.  
  156.                 mov     dl, al              ; Separate Vpp1 and Vpp2
  157.                 mov     dh, al
  158.  
  159.                 and     dl, 0Fh             ; dl = Vpp2
  160.                 mov     cl, 4
  161.                 shr     dh, cl              ; dh = Vpp1
  162.  
  163.                 mov     cl, ah              ; cl = Vcc
  164.  
  165.                 mov     ch, 0               ; ch - Index of 0.0V
  166.  
  167. ;---------------------------- Validate Power levels ---------------------------
  168.  
  169.                 mov     al, ah              ; Check Vcc
  170.                 mov     ah, VCC
  171.                 call    CheckPowerLevel
  172.                 jc      vp_bad_vcc
  173.  
  174.                 mov     al, dh              ; Check Vpp1
  175.                 mov     ah, VPP1
  176.                 call    CheckPowerLevel
  177.                 jc      vp_bad_vpp
  178.  
  179.                 mov     al, dl              ; Check Vpp2
  180.                 mov     ah, VPP2
  181.                 call    CheckPowerLevel
  182.                 jc      vp_bad_vpp
  183.  
  184.                 cmp     cl, ch              ; Switch Vcc off?
  185.                 jne     @f
  186.  
  187.                 cmp     dl, ch              ; Vcc == 0, Vpp must be 0
  188.                 jne     vp_bad_vpp
  189.                 cmp     dh, dl
  190.                 jne     vp_bad_vpp
  191.  
  192. @@:
  193.                 clc                         ; Report success
  194.                 pop     ax
  195.                 jmp     short vp_exit
  196.  
  197. vp_bad_vcc:     mov     ah, BAD_VCC         ; Report     Vcc value
  198.                 jmp     short @f
  199.  
  200. vp_bad_vpp:     mov     ah, BAD_VPP         ; Report     Vpp value
  201. @@:             add     sp, 2               ; Discard AX in the stack
  202.                 stc
  203.  
  204. vp_exit:        popx    <dx, cx>
  205.                 ret
  206. covValidatePw   ENDP
  207.  
  208. ;*****************************************************************************
  209. ;*                          --- covValidateIFt ---
  210. ;*
  211. ;*     Purpose: Validate interface Type
  212. ;*       Input: Reagister AH = IFType
  213. ;*                  Bit 0    = Memory-only interface
  214. ;*                  Bit 1    = I/O and memory interface
  215. ;*                  All other bits reserved and are reset to zero (0)
  216. ;*                  [SI]     = Pointer to the Socket Info structure
  217. ;*      Output: If successful, NC
  218. ;*              else CY and AH = BAD_TYPE
  219. ;* Scratch reg: none
  220. ;*     Written: by Alexis A.Piatetsky 10.06.94
  221. ;*****************************************************************************
  222. covValidateIFt  PROC    NEAR
  223.                 assume  ds:@data, es:Nothing
  224.  
  225.                 test    ah, NOT (IF_MEMORY OR IF_IO)
  226.                 jnz     vit_err                 ; Any reserved bit set
  227.  
  228.                 and     ah, IF_MEMORY OR IF_IO  ; Mask in interface type bits
  229.                 jz      vit_err                 ; If neither set, error out
  230.  
  231.                 cmp     ah, IF_MEMORY OR IF_IO  ; Are both set ?
  232.                 je      vit_err
  233.  
  234.                 test    byte ptr (CHARTBL PTR [si]).SktCaps, ah
  235.                 jz      vit_err                 ; Can socket do this?
  236.  
  237.                 clc
  238.                 jmp     short @f
  239.  
  240. vit_err:        mov     ah, BAD_TYPE
  241.                 stc
  242.  
  243. @@:             ret
  244. covValidateIFt  ENDP
  245. sEnd            ResCode
  246.                 end
  247.