home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / PCMCIA / CLDFM / COM_IDC.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-04-14  |  5.6 KB  |  192 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. ;    The following IBM OS/2 2.1 source code is provided to you solely for
  15. ;    the purpose of assisting you in your development of OS/2 2.x device
  16. ;    drivers. You may use this code in accordance with the IBM License
  17. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  18. ;    Copyright statement may not be removed.;
  19. ;*****************************************************************************/
  20. ;/*****************************************************************************
  21. ;*
  22. ;* SOURCE FILE NAME = COM_IDC.ASM
  23. ;*
  24. ;* DESCRIPTIVE NAME =
  25. ;*
  26. ;*
  27. ;* VERSION
  28. ;*
  29. ;* DATE
  30. ;*
  31. ;* DESCRIPTION
  32. ;*
  33. ;* FUNCTIONS
  34. ;*
  35. ;*
  36. ;* NOTES        NONE
  37. ;*
  38. ;* STRUCTURES   NONE
  39. ;*
  40. ;* EXTERNAL REFERENCES
  41. ;*
  42. ;*              NONE
  43. ;*
  44. ;* EXTERNAL FUNCTIONS
  45. ;*
  46. ;*              NONE
  47. ;*
  48. ;* CHANGE ACTIVITY =
  49. ;*   DATE      FLAG        APAR   CHANGE DESCRIPTION
  50. ;*   --------  ----------  -----  --------------------------------------
  51. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx
  52. ;*   03/13/95              113751 DS Set before calling IDC Entry Point in COM
  53. ;*****************************************************************************/
  54.  
  55. .286
  56. .287
  57.  
  58. ;*
  59. ;* constant definitions
  60. ;*
  61. ATTACHDD equ 42
  62.  
  63.  
  64. _DATA   SEGMENT WORD PUBLIC 'DATA'
  65. _DATA   ENDS
  66.  
  67. _BSS    SEGMENT WORD PUBLIC 'BSS'
  68. _BSS    ENDS
  69.  
  70. CONST   SEGMENT WORD PUBLIC 'CONST'
  71. CONST   ENDS
  72.  
  73. _TEXT   SEGMENT WORD PUBLIC 'CODE'
  74. _TEXT   ENDS
  75.  
  76. DGROUP  GROUP   _DATA, CONST, _BSS
  77. CGRP    GROUP   _TEXT
  78.  
  79.  
  80. _DATA   SEGMENT
  81. Driver_name       DB 'COM1    ',  00H
  82. Driver_handle     DW 6 DUP (0)
  83. Driver_entry_func DW 2 DUP (0)
  84. Driver_DS         DW        0     ; @113751
  85. Idc_pack          DW 5 DUP (0)
  86.  
  87. EXTRN Device_help:NEAR
  88. _DATA   ENDS
  89.  
  90.  
  91. _TEXT   SEGMENT WORD PUBLIC 'CODE'
  92.         ASSUME cs:CGRP, ds:DGROUP, es:NOTHING, ss:NOTHING
  93.  
  94. PUBLIC _com_idc_init
  95. _com_idc_init PROC NEAR
  96.  
  97.             push bx                    ; attach to com driver
  98.             push di
  99.             push dx
  100.  
  101.             mov  bx,OFFSET DGROUP:Driver_name
  102.             mov  di,OFFSET DGROUP:Driver_handle
  103.             mov  dl,ATTACHDD
  104.             call DWORD PTR Device_help
  105.             jc   error1
  106.  
  107.                                        ; if successful store entry point
  108.                                        ;               com driver
  109. next:       mov  ax,WORD PTR Driver_handle + 6       ; offset
  110.             mov  dx,WORD PTR Driver_handle + 8       ; segment
  111.             mov  bx,WORD PTR Driver_handle + 0ah     ; @113751 - DS of IDC DD
  112.             mov  WORD PTR Driver_entry_func,ax
  113.             mov  WORD PTR Driver_entry_func+2,dx
  114.             mov  WORD PTR Driver_DS,bx               ; @113751
  115.             mov  ax,0
  116.             jmp  done1
  117.  
  118. error1:     mov  ax,-1
  119.  
  120. done1:      pop  dx
  121.             pop  di
  122.             pop  bx
  123.             ret
  124.  
  125. _com_idc_init ENDP
  126.  
  127.  
  128. ;/***************************************************************************
  129. ;*
  130. ;* FUNCTION NAME = _set_com_port
  131. ;*
  132. ;* DESCRIPTION   = USHORT set_com_port(USHORT command, USHORT com_port
  133. ;*                                     USHORT io_address, USHORT irq_num)
  134. ;*
  135. ;* INPUT         =
  136. ;*
  137. ;* OUTPUT        =
  138. ;*
  139. ;* RETURN-NORMAL =
  140. ;*
  141. ;* RETURN-ERROR  =
  142. ;*
  143. ;**************************************************************************/
  144.  
  145. PUBLIC _set_com_port
  146. _set_com_port PROC NEAR
  147.  
  148.         push bp                        ; save registers
  149.         mov  bp,sp                     ;    - set up parameter pointer
  150.         push bx
  151.         push es
  152.         push ds                        ;@113751
  153.                                        ; packP = -2
  154.                                        ; irq_num = 10
  155.                                        ; io_address = 8
  156.                                        ; com_port = 6
  157.                                        ; command = 4
  158.  
  159.                                        ; idc_pack.command = command
  160.         mov  ax,WORD PTR [bp+4]                      ;command
  161.         mov  WORD PTR Idc_pack,ax
  162.                                        ; idc_pack.com_port = com_port
  163.         mov  ax,WORD PTR [bp+6]                      ;com_port
  164.         mov  WORD PTR Idc_pack+2,ax
  165.                                        ; idc_pack.io_address = io_address
  166.         mov  ax,WORD PTR [bp+8]                      ;io_address
  167.         mov  WORD PTR Idc_pack+4,ax
  168.                                        ; idc_pack.irq_num = irq_num
  169.         mov  ax,WORD PTR [bp+10]                     ;irq_num
  170.         mov  WORD PTR Idc_pack+6,ax
  171.                                        ; set up idc packet
  172.         mov  ax,DGROUP
  173.         mov  es,ax
  174.         mov  bx,OFFSET DGROUP:Idc_pack
  175.         mov  ds,Driver_DS              ; @113751
  176.  
  177.         call DWORD PTR Driver_entry_func ; make idc call
  178.                                        ; set up return code
  179.         mov  ax,WORD PTR Idc_pack+8
  180.                                        ; restore registers and return
  181.         pop  ds                        ; @113751
  182.         pop  es
  183.         pop  bx
  184.         pop  bp
  185.         ret
  186.  
  187. _set_com_port ENDP
  188.  
  189. _TEXT ENDS
  190.  
  191. END
  192.