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

  1. ;       SCCSID = @(#)pddddm.asm    6.2 92/03/24
  2. ;**************************************************************************
  3. ;                   IBM Sample Physical Device Driver
  4. ;
  5. ;                   Copyright  IBM Corp 1992.
  6. ;***************************************************************************
  7. .286P
  8.  
  9.         page    60,132
  10.         title   _DD   Kriter Tca Device Driver
  11.  
  12.       .MODEL  large,os_os2
  13.         INCLUDE  devhlp.inc             ; DEFINITION OF DEVICE HELP CALLS
  14.  
  15.         EXTRN   initialize:NEAR                                         ;@VDD
  16.         EXTRN   VTCAAddress:FAR                                         ;@VDD
  17.         PUBLIC  devhlp_ptr                                              ;@VDD
  18.         page
  19.  
  20.  
  21. ;       Request Header
  22.  
  23. rh          segment at 0
  24. rh_len      db  ?               ; length of request header
  25. rh_unit     db  ?               ; unit CSEG (not used)
  26. rh_command  db  ?               ; command CSEG
  27. rh_status   dw  ?               ; status
  28. rh_rsvd     dw  2 dup(?)        ; reserved for DOS
  29. rh_q_link   dw  2 dup(?)        ; request queue linkage
  30. rh_DSEG     equ $               ; DSEG appropriate to the operation
  31.  
  32. ;       Request Header DSEG for INIT command
  33.             org rh_DSEG-rh
  34. rh_no_units db  ?               ; number of units (not used)
  35. rh_end_addr dd  ?               ; ending address of device driver
  36. rh_bpb      dd  ?               ; address of BPB array (not used)
  37. rh_drive    db  ?
  38.  
  39. ;       Request Header DSEG for IOCTL command
  40.             org rh_DSEG-rh
  41. rh_ioctl_categ db  ?            ; category CSEG
  42. rh_ioctl_funct db  ?            ; function CSEG
  43. rh_ioctl_parm  dd  ?            ; addr of parms (offset and selector)
  44. rh_ioctl_buff  dd  ?            ; addr of buffer (offset and selector)
  45.  
  46. rh          ends
  47.  
  48. ;
  49. ;*******************************************************************************
  50. ; DSEG segment
  51. ;*******************************************************************************
  52.  
  53. DSEG    SEGMENT   PUBLIC  'DATA'                                          ;@VDD
  54.  
  55. ;       Device Header
  56.  
  57.  
  58.         dd     -1               ; address of next device header
  59.         dw     8880h            ; device attribute
  60.         dw     dev_strategy     ; address of device strategy entry point
  61.         dw     ?                ; reserved
  62.         db     'TCA_DDM '       ; name
  63.         dw     4 dup(?)         ; reserved
  64.  
  65.  
  66.  
  67.  
  68. ; TCA Device Driver Work Area
  69.  
  70. devhlp_ptr      dd         ?    ; device help interface pointer
  71.  
  72. public IRQ_level
  73. IRQ_level       dw         9    ; hardware IRQ level currently in use    @A0A
  74.  
  75. DSEG            ends
  76.  
  77. ;*******************************************************************************
  78. ; CSEG segment
  79. ;*******************************************************************************
  80.  
  81. CSEG    SEGMENT  PUBLIC 'CODE'                                           ;@VDD
  82.  
  83. StatusReg       equ   02d0h     ; Tca card status reg io port (adapter 0)
  84. ControlReg      equ   02d4h     ; Tca card control reg io port (adapter 0)
  85.  
  86. ControlDisable  equ   080h      ; Output to ControlReg to disable adapter
  87.  
  88.         page
  89.         assume  cs:CSEG,ds:DSEG,es:rh
  90.  
  91. ;Device Strategy Entry Point
  92.  
  93. dev_strategy proc far
  94.  
  95.         ; INT     3
  96.  
  97.         mov     rh_status[bx],0100h      ; store successful return CSEG and
  98.                                          ;    request complete status in
  99.                                          ;    request header status word
  100.         mov     al,rh_command[bx]        ; route control based on
  101.         cmp     al,10h                   ;      command CSEG
  102.         ja      invalid_command          ; invalid if above generic ioctl
  103.         sal     al,1                     ; set up to
  104.         cbw                              ;   take the
  105.         mov     si,ax                    ;      correct jump into the table
  106.         jmp     short route
  107.  
  108.         page
  109.  
  110. function_table label word
  111.         dw      initialize               ; init
  112.         dw      media_check
  113.         dw      build_bpb
  114.         dw      reserved_3
  115.         dw      read
  116.         dw      non_destruc_read
  117.         dw      input_status
  118.         dw      input_flush
  119.         dw      write
  120.         dw      write_verify
  121.         dw      output_status
  122.         dw      output_flush
  123.         dw      reserved_c
  124.         dw      dev_open                 ; open
  125.         dw      dev_close                ; close
  126.         dw      remov_media
  127.         dw      ioctl                    ; generic ioctl
  128. route:
  129.         jmp     function_table[si]
  130.  
  131.  
  132. ;       Unsupported command CSEGs
  133.  
  134. invalid_command:
  135. media_check:
  136. build_bpb:
  137. reserved_3:
  138. read:
  139. non_destruc_read:
  140. input_status:
  141. input_flush:
  142. write:
  143. write_verify:
  144. output_status:
  145. output_flush:
  146. reserved_c:
  147. remov_media:
  148. dev_open:
  149. dev_close:
  150. ioctl:
  151.  
  152.         mov     rh_status[bx],8103h      ; store unknown command error and
  153.                                          ;    request complete status in
  154.                                          ;    request header status word
  155.  
  156.         ret
  157.  
  158. dev_strategy endp
  159.  
  160. ;Device Interrupt Entry Point
  161.  
  162.  public dev_interrupt
  163.  dev_interrupt proc far
  164.         assume   ds:DSEG
  165.  
  166.  
  167.          cli                              ; ensure interrupts are inhibited
  168.  
  169.  ;
  170.  ;       remove IRQ entry point (disables IRQ)
  171.  ;
  172.  
  173.          mov     bx,9                     ; get the IRQ number              @A0C
  174.          mov     dl,DevHlp_UnSetIRQ       ; UnSetIRQ command code in dl     @A1A
  175.          call    dword ptr [devhlp_ptr]   ; Call to Device Help Services
  176.  
  177.          jnc     int198
  178.          ; int 3
  179.  
  180.  int198:
  181.  ;                                                                         @VDD
  182.  ;    Let VTCA know the interrupt occurred                                 @VDD
  183.  ;                                                                         @VDD
  184.  
  185.  .386P
  186.          mov    eax,0                                                     ;@VDD
  187.  
  188.          push   eax                       ;Function                        @VDD
  189.          push   eax                                                       ;@VDD
  190.          push   eax                                                       ;@VDD
  191.  
  192.          call    FWORD PTR [VTCAAddress]                                  ;@VDD
  193.  .286P
  194.  
  195.          mov     ax,IRQ_level             ; hardware EOI level in use      @A2C
  196.          mov     dl,31h
  197.          call    [devhlp_ptr]    ; issue EOI for level 9 interrupt
  198.  
  199.          sti                                                              ;@VDD
  200.  
  201.          clc
  202.                                                                           ;@VDD
  203.          ret                              ; return                         @VDD
  204.  
  205.  dev_interrupt endp
  206.  
  207. CSEG    ends
  208.         end
  209.