home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v5.zip / TOOLKT21 / ASM / SAMPLES / PDD / PDDINIT.ASM < prev   
Assembly Source File  |  1993-03-12  |  5KB  |  178 lines

  1. ;**************************************************************************
  2. ;                   IBM Sample Physical Device Driver
  3. ;
  4. ;                   Copyright  IBM Corp 1992.
  5. ;***************************************************************************
  6. ;Initial Release -David Kenner.
  7.  
  8. TITLE   PDD_INIT
  9. NAME    PDD_INIT
  10. PAGE    60,132
  11.  
  12.       .MODEL  large,os_os2
  13. .286P
  14. ;***************************************************************************
  15. ;CODING CONVENTIONS
  16. ; all psuedo-ops, equates, documentation, publics, and externs are in uppercase.
  17. ; all cseg and data names are in lowercase.
  18. ;
  19. ;  ROUTINES IN THIS MODULE:
  20. ;             tcacmd_entry               router routine for vtca calls
  21. ;             tcaRegister                registers PDD with VDMM
  22. ;
  23. ;****************************************************************************
  24. INCL_ERRORS     equ 1;
  25.         .XCREF
  26.         .XLIST
  27.         INCLUDE  pdd.inc                ; TCA MACROS AND DEFINITIONS
  28.         INCLUDE  bseerr.inc             ; ERROR csegS FOR DEVICES
  29.         INCLUDE  basemaca.inc           ; VARIOUS MACRO'S
  30.         INCLUDE  devsym.inc
  31.         INCLUDE  devhlp.inc             ; DEFINITION OF DEVICE HELP CALLS
  32. ;       INCLUDE  struc.inc              ; STRUCTURED MACRO SUPPORT
  33.         INCLUDE  infoseg.inc            ; STRUCTURES DEFINING THE INFOSEG
  34.         INCLUDE  gas.inc                ; GENERAL ALERT EQUATES
  35.         .LIST
  36.         .CREF
  37.  
  38.         EXTRN    devhlp_ptr:NEAR        ; POINTER TO DEV HELP ROUTINES
  39.         EXTRN    tcaRegister:FAR        ; PDD REGISTER ROUTINE
  40.         EXTRN    DosWrite:FAR
  41.  
  42.         page
  43.  
  44.          stdin   equ  0
  45.          stdout  equ  1
  46.          stderr  equ  2
  47.  
  48.          cr      equ  0dh
  49.          lf      equ  0ah
  50.  
  51. dseg    SEGMENT  PUBLIC 'DATA'
  52. dsegend         label      byte
  53.      IdIn      db   cr,lf
  54.                db   "Toolkit Sample Physical Device Driver"
  55.                db   cr,lf
  56.                db   "Copyright IBM Corp. 1991"
  57.                db   cr,lf
  58.      IdIn_len  equ  $-IdIn
  59.  
  60.      wlen      dw   ?
  61. dseg    ends
  62.  
  63.  
  64. ;       Request Header
  65.  
  66. rh          segment at 0
  67. rh_len      db  ?               ; length of request header
  68. rh_unit     db  ?               ; unit cseg (not used)
  69. rh_command  db  ?               ; command cseg
  70. rh_status   dw  ?               ; status
  71. rh_rsvd     dw  2 dup(?)        ; reserved for DOS
  72. rh_q_link   dw  2 dup(?)        ; request queue linkage
  73. rh_dseg     equ $               ; dseg appropriate to the operation
  74.  
  75. ;       Request Header dseg for INIT command
  76.             org rh_dseg-rh
  77. rh_no_units db  ?               ; number of units (not used)
  78. rh_end_addr dd  ?               ; ending address of device driver
  79. rh_bpb      dd  ?               ; address of BPB array (not used)
  80. rh_drive    db  ?
  81.  
  82. ;       Request Header dseg for IOCTL command
  83.             org rh_dseg-rh
  84. rh_ioctl_categ db  ?            ; category cseg
  85. rh_ioctl_funct db  ?            ; function cseg
  86. rh_ioctl_parm  dd  ?            ; addr of parms (offset and selector)
  87. rh_ioctl_buff  dd  ?            ; addr of buffer (offset and selector)
  88.  
  89. rh          ends
  90.  
  91. cseg    SEGMENT  PUBLIC 'CODE'
  92.         ASSUME  CS:cseg,DS:dseg,ES:RH
  93.  
  94. end_of_driver label byte                 ; last byte of device driver    @VDD
  95. ;******************* START OF SPECIFICATIONS ************************
  96. ;
  97. ; SUBROUTINE NAME:  initialize
  98. ;
  99. ; DESCRIPTIVE NAME: PDD initialize routine
  100. ;
  101. ; FUNCTION: This entry point is the TCA PDD's initialization routine.
  102. ;           This routine will do the device driver  initialization,
  103. ;           (save devhlp address and set up overlay point), as well
  104. ;           as register the PDD entry point with the VDD.
  105. ;
  106. ; ENTRY POINT: initialize
  107. ;       LINKAGE: CALL NEAR
  108. ;
  109. ; INPUT: NONE
  110. ;
  111. ; EXIT-NORMAL: EAX = NONE
  112. ;
  113. ; EXIT-ERROR:  EAX = NONE
  114. ;
  115. ; INTERNAL REFERENCES:  NONE
  116. ;
  117. ; EXTERNAL REFERENCES:  NONE
  118. ;
  119. ;********************************************************************
  120.  
  121. Procedure initialize,FAR
  122.  
  123. ;       Initialize device driver - pass back end of driver address
  124.  
  125. ;initialize:
  126.  
  127.         ASSUME  CS:cseg,DS:dseg,ES:RH
  128. ;       int     3
  129.         mov     ax, word ptr rh_end_addr[bx] ; Get address for devhlp routines
  130.         mov     word ptr devhlp_ptr,ax       ;   and store in devhlp_ptr
  131.         mov     ax, word ptr rh_end_addr+2[bx]
  132.         mov     word ptr devhlp_ptr+2,ax
  133.  
  134.         push    es
  135.         push    bx
  136.  
  137.  
  138.  
  139.  
  140. ;
  141. ;       Register the TCADD's VDD services entry point with VTCA.
  142. ;       This entry point is the router for all the IDC communications.
  143. ;
  144.         call    tcaRegister                  ; register PDD entry point  ;
  145.  
  146.  
  147.         ;
  148.         ;Do initial sign-on message
  149.         ;Init is done at ring three,some of the API's can be safely
  150.         ;called from here
  151.         ;
  152.         .386P
  153.          push stdout
  154.          push ds
  155.          push offset ds:Idin
  156.          push IdIn_len
  157.          push ds
  158.          push offset ds:wlen
  159.          call DosWrite
  160.          mov word ptr es: [bx + 3 ],0100h
  161.  
  162.         .286P
  163.         pop     bx
  164.         pop     es
  165.  
  166.   ; the next 2 lines set up the address of the end of the real
  167.   ; device driver. the init cseg will be deleted by dos
  168.  
  169.         mov     word ptr rh_end_addr[bx],offset end_of_driver
  170.         mov     word ptr rh_end_addr+2[bx],offset dsegend
  171.  
  172.         ret
  173.  
  174.  
  175. EndProc initialize
  176. cseg    ends
  177. end     initialize
  178.