home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdrom.zip / DDK / BASE / SRC / DEV / DASD / CDROM / MITSUMI / devhelp.asm < prev    next >
Assembly Source File  |  1996-06-18  |  11KB  |  449 lines

  1. .386p
  2.  
  3. include devhelp.inc
  4. include devhdr.inc
  5.  
  6.  
  7. ;   EXTRN  _DevHlp : DWORD
  8.    EXTRN  _Device_Help : DWORD
  9.  
  10.  
  11. ;NULL            SEGMENT WORD PUBLIC 'BEGDATA' USE16
  12. ;NULL            ENDS
  13.  
  14. _DATA           SEGMENT WORD PUBLIC 'DATA' USE16
  15. _DATA           ENDS
  16.  
  17. _BSS            SEGMENT WORD PUBLIC 'BSS' USE16
  18. _BSS            ENDS
  19.  
  20. FAR_BSS         SEGMENT WORD PUBLIC 'FAR_BSS' USE16
  21. FAR_BSS         ENDS
  22.  
  23. CONST           SEGMENT WORD PUBLIC 'CONST' USE16
  24. CONST           ENDS
  25.  
  26. LAST_DATA       SEGMENT WORD PUBLIC 'LAST_DATA' USE16
  27.                 public _last_data_byte, _traceflag
  28. _traceflag      db 0
  29. _last_data_byte db 0
  30. LAST_DATA       ENDS
  31.  
  32. _TEXT           SEGMENT WORD PUBLIC 'CODE' USE16
  33.    EXTRN  _CDStrat1:near
  34. _TEXT           ENDS
  35.  
  36. RMCode          SEGMENT WORD PUBLIC 'CODE' USE16
  37. RMCode          ENDS
  38. code            SEGMENT WORD PUBLIC 'CODE' USE16
  39. code            ENDS
  40.  
  41. END_TEXT        SEGMENT WORD PUBLIC 'CODE' USE16
  42.                 public _last_code_byte
  43. _last_code_byte db 0
  44. END_TEXT        ENDS
  45.  
  46. ;DGROUP  GROUP NULL, CONST, _BSS, FAR_BSS, _DATA, LAST_DATA
  47. DGROUP  GROUP CONST, _BSS, _DATA, FAR_BSS, LAST_DATA
  48. CGROUP  GROUP _TEXT,RMCode, code,END_TEXT
  49.  
  50. LAST_DATA       SEGMENT WORD PUBLIC 'LAST_DATA' USE16
  51. LAST_DATA       ENDS
  52.  
  53.  
  54. _DATA           SEGMENT WORD PUBLIC 'DATA' USE16
  55.    ASSUME CS:CGROUP, DS:DGROUP, ES:NOTHING, SS:NOTHING
  56.  
  57.                 public DiskDDHeader
  58.  
  59. DiskDDHeader   dd      -1
  60.                dw      DEVLEV_3 + DEV_CHAR_DEV
  61.                dw      _CDStrat1
  62.                dw      0
  63.                db      "MITSUMI$"
  64.                dw      0
  65.                dw      0
  66.                dw      0
  67.                dw      0
  68.                dd      DEV_ADAPTER_DD
  69.                dw      0
  70.  
  71.    _lsw_phys_add     DW 0
  72.    _msw_phys_add     DW 0
  73.  
  74. _DATA           ENDS
  75.  
  76. _TEXT           SEGMENT WORD PUBLIC 'CODE' USE16
  77.    ASSUME CS:CGROUP, DS:DGROUP, ES:NOTHING, SS:NOTHING
  78.  
  79. ; ================================================================== ;
  80. ;                                                                    ;
  81. ; /* Function : 15 Hex */                                            ;
  82. ;                                                                    ;
  83. ;  FARPOINTER DevHelp_PhysToVirt( FARPOINTER physAdr, USHORT len )   ;
  84. ;                                                                    ;
  85. ; ------------------------------------------------------------------ ;
  86. ;                                                                    ;
  87.  
  88. Phys2Virt_PhysAdrLo     EQU   [BP+4]
  89. Phys2Virt_PhysAdrHi     EQU   [BP+6]
  90. Phys2Virt_Len           EQU   [BP+8]
  91.  
  92. _DevHelp_PhysToVirt PROC NEAR
  93.    PUBLIC _DevHelp_PhysToVirt
  94.  
  95.       PUSH     BP
  96.       MOV      BP,SP
  97.  
  98.       PUSH     DI
  99.       PUSH     ES
  100.  
  101.       MOV      AX,WORD PTR Phys2Virt_PhysAdrHi
  102.       MOV      BX,WORD PTR Phys2Virt_PhysAdrLo
  103.       MOV      CX,WORD PTR Phys2Virt_Len
  104.       MOV      DH,1
  105.       MOV      DL,DH_PhysToVirt
  106.  
  107.       CALL     [_Device_Help]
  108.  
  109.       JC       ptverr
  110.  
  111.       MOV      DX,ES
  112.       MOV      AX,DI
  113.       JMP      SHORT ptv90
  114.  
  115. ptverr:
  116.       SUB      DX,DX
  117.       SUB      AX,AX
  118.  
  119. ptv90:
  120.       POP      ES
  121.       POP      DI
  122.       POP      BP
  123.  
  124.       RET
  125.  
  126. _DevHelp_PhysToVirt ENDP
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. ; ==================================================================== ;
  134. ;                                                                      ;
  135. ;  DevHelp_Block( ULONG BlockID, ULONG TimeLimit, UCHAR IntFlag )      ;
  136. ;                                                                      ;
  137. ;     This routine block the current event                             ;
  138. ;                                                                      ;
  139. ;  input :                                                             ;
  140. ;     BlockID :                                                        ;
  141. ;     TimeLimit :                                                      ;
  142. ;     IntFlag :                                                        ;
  143. ;                                                                      ;
  144. ;  output :                                                            ;
  145. ;                                                                      ;
  146. ; -------------------------------------------------------------------- ;
  147. ;                                                                      ;
  148.  
  149. BlockIDLo         EQU   +4[BP]
  150. BlockIDHi         EQU   +6[BP]
  151. BlockTimeLimitLo  EQU   +8[BP]
  152. BlockTimeLimitHi  EQU   +10[BP]
  153. BlockIntFlag      EQU   +12[BP]
  154.  
  155. _DevHelp_Block          PROC
  156.    PUBLIC _DevHelp_Block
  157.  
  158.       PUSH  BP
  159.       MOV   BP,SP
  160.  
  161.       PUSH  DI
  162.  
  163.       MOV   BX,BlockIDLo
  164.       MOV   AX,BlockIDHi
  165.       MOV   CX,BlockTimeLimitLo
  166.       MOV   DI,BlockTimeLimitHi
  167.       MOV   DH,BlockIntFlag
  168.       MOV   DL,DH_Block
  169.  
  170.       CALL  [_Device_Help]
  171. ;;      cmp   al,0
  172.       jnc   blockrun
  173.       jz    blocktimeout
  174.       jnz   blockinterrupt
  175.       mov   ax,3                        ; should NEVER get this
  176.       jmp   blockdone
  177. blocktimeout:
  178.       mov   ax,1                        ; well, we timed out...
  179.       jmp   blockdone
  180. blockrun:                               ; all ok, run was done
  181.       mov   ax,0
  182.       jmp   blockdone
  183. blockinterrupt:                         ; oops, interrupted
  184.       mov   ax,2
  185. blockdone:
  186.       POP   DI
  187.       POP   BP
  188.  
  189.       RET
  190.  
  191. _DevHelp_Block          ENDP
  192.  
  193. RunIDLo        EQU +4[BP]
  194. RunIDHi        EQU +6[BP]
  195.  
  196. _DevHelp_Run            PROC
  197.    PUBLIC _DevHelp_Run
  198.  
  199.       PUSH  BP
  200.       MOV   BP,SP
  201.  
  202.       MOV   BX,RunIDLo
  203.       MOV   AX,RunIDHi
  204.       MOV   DL,DH_Run
  205.  
  206.       CALL  [_Device_Help]
  207.  
  208.       JC    run90
  209.       SUB   AX,AX
  210.  
  211. run90:
  212.       POP   BP
  213.  
  214.       RET
  215.  
  216. _DevHelp_Run            ENDP
  217.  
  218.  
  219. _DevHelp_GetDosVar PROC
  220.         PUBLIC _DevHelp_GetDosVar
  221.         push bp
  222.         mov  bp,sp
  223.         mov AX,[bp+4]
  224.         mov cx,1                        ; disk device types
  225.         mov DL,DH_GetDOSVar
  226.         CALL [_Device_Help]
  227.         cmp word ptr [bp+4],1
  228.         jne done
  229.         mov es,ax
  230.         mov ax,es:[bx]
  231.         mov bx,0
  232. done:
  233.         mov DX,AX
  234.         mov AX,BX
  235.         pop  bp
  236.         ret
  237. _DevHelp_GetDosVar endp
  238.  
  239. _DevHelp_Yield PROC
  240.         PUBLIC _DevHelp_Yield
  241.         pushF
  242.         mov dl,DH_Yeild
  243.         CALL [_Device_Help]
  244.         popF
  245.         ret
  246.  
  247. _DevHelp_Yield endp
  248.  
  249. _DevHelp_RAS PROC
  250.         PUBLIC _DevHelp_RAS
  251.         push    bp
  252.         mov     bp,sp
  253.         push    si
  254.         cmp     _Traceflag,1
  255.         jne     notrace
  256.         mov dl,DH_RAS
  257.         push ds
  258.         pop  es
  259.         mov     ax, [bp+4]
  260.         mov     cx, [bp+6]
  261.         mov     bx, [bp+8]
  262.         lds     si, [bp+10]
  263.  
  264.         CALL es:[_Device_Help]
  265.         push    es
  266.         pop     ds
  267. notrace:
  268.         pop     si
  269.         pop     bp
  270.         ret
  271.  
  272. _DevHelp_RAS   endp
  273.  
  274. _DevHelp_DisplayMsg proc
  275.         public _DevHelp_DisplayMsg
  276.         push    bp
  277.         mov     bp,sp
  278.         lds     si,[bp+4];
  279.         mov     bx,0
  280.         mov     dl,DH_SAVE_MESSAGE
  281.         CALL    [_Device_Help]
  282.         pop     bp
  283.         ret
  284. _DevHelp_DisplayMsg endp
  285.  
  286. _DevHelp_RegisterDeviceClass PROC
  287.         PUBLIC _DevHelp_RegisterDeviceClass
  288.         push    bp
  289.         mov     bp,sp
  290.         push    es                      ; save ES
  291.         push    ds                      ; save DS
  292.         push    ds                      ; get DS
  293.         pop     es                      ; into ES
  294.         LDS     SI,[bp+4]               ; DS:SI = Ptr ADD to ASCIIZ name        [4][6]
  295.                                         ;         maximum of 16 chars
  296.         MOV     AX,[bp+10]              ; AX:BX = Ptr to ADD's Direct Call      [8]
  297.         mov     BX,[bp+8]               ;         Command Handler               [10]
  298.         MOV     DI,[bp+12]              ; Must be 0 for ADDs                    [12]
  299.         MOV     CX,[bp+14]              ; Must be 1 for ADDs                    [14]
  300.         MOV     DL,DH_RegisterDeviceClass
  301.         CALL    es:[_Device_Help]
  302.         jnc     handleok                ; if no error done
  303.         mov     ax,0                    ; set error
  304. handleok:
  305.         pop     ds                      ; restore DS
  306.         pop     es                      ; restore ES
  307.         pop     bp                      ; restore BP
  308.         ret                             ; return
  309. _DevHelp_RegisterDeviceClass endp
  310.  
  311. _DevHelp_AllocGdtSel proc
  312.         public  _DevHelp_AllocGdtSel
  313.         push    bp
  314.         mov     bp,sp
  315.         les     di,[bp+4]
  316.         mov     cx,word ptr [bp+8]
  317.         mov     dl,DH_AllocGDTSelector
  318.         CALL    [_Device_Help]
  319.         jc      selerror
  320.         mov     ax,0
  321. selerror:
  322.         pop     bp
  323.         ret
  324. _DevHelp_AllocGdtSel endp
  325.  
  326. _DevHelp_AllocPhys proc
  327.         public  _DevHelp_AllocPhys
  328.         push    bp
  329.         mov     bp,sp
  330.         mov     ax,[bp+6]
  331.         mov     bx,[bp+4]
  332.         mov     dh,byte ptr [bp+8]
  333.         mov     dl,DH_AllocPhys
  334.         CALL    [_Device_Help]
  335.         les     di,[bp+10]
  336.         jc      allocphyserr
  337.         mov     word ptr es:[di],bx
  338.         mov     word ptr es:[di+2],ax
  339.         mov     ax,0
  340.         jmp     allocphysdone
  341. allocphyserr:
  342.         mov     word ptr es:[di],0
  343.         mov     word ptr es:[di+2],0
  344. allocphysdone:
  345.         pop     bp
  346.         ret
  347. _DevHelp_AllocPhys endp
  348.  
  349. _DevHelp_PhysToGDT proc
  350. ;
  351. ;       [bp+4] = physical (32 bits)
  352. ;       [bp+8] = size     (16 bits)
  353. ;       [bp+10] = selector (16 bits)
  354. ;
  355.         public  _DevHelp_PhysToGDT
  356.         push    bp
  357.         mov     bp,sp
  358.         mov     ax,[bp+6]
  359.         mov     bx,[bp+4]
  360.         mov     cx,[bp+8]
  361.         mov     si,[bp+10]
  362.         mov     dl,DH_PhysToGDTSelector
  363.         CALL    [_Device_Help]
  364.         jc      physgdterr
  365.         mov     ax,0
  366. physgdterr:
  367.         pop     bp
  368.         ret
  369. _DevHelp_PhysToGDT endp
  370.  
  371. _DevHelp_Settimer proc
  372.         public  _DevHelp_Settimer
  373.         push    bp
  374.         mov     bp,sp
  375.         mov     ax,[bp+4]
  376.         mov     dl,DH_SetTimer
  377.         CALL    [_Device_Help]
  378.         mov     ax,0
  379.         jnc     stimernoerr
  380.         mov     ax,1
  381. stimernoerr:
  382.         pop     bp
  383.         ret
  384. _DevHelp_Settimer endp
  385.  
  386.  
  387. _DevHelp_SetIRQ proc
  388. ;
  389. ;       [bp+4] = offset of handler
  390. ;       [bp+6] = irq number (binary)
  391. ;       [bp+8] = shared/non shared flag 1 = shared, 0 = not shared
  392. ;
  393.         public  _DevHelp_SetIRQ
  394.         push    bp
  395.         mov     bp,sp
  396.         mov     ax,[bp+4]
  397.         mov     bx,[bp+6]
  398.         mov     dh, byte ptr [bp+8]
  399.         mov     dl,DH_SetIRQ
  400.         CALL    [_Device_Help]
  401.         mov     ax,0
  402.         jnc     noseterr
  403.         mov     ax,1
  404. noseterr:
  405.         pop     bp
  406.         ret
  407. _DevHelp_SetIRQ endp
  408.  
  409. _DevHelp_UnsetIRQ proc
  410. ;
  411. ;       [bp+4] = offset of handler
  412. ;
  413.         public  _DevHelp_UnsetIRQ
  414.         push    bp
  415.         mov     bp,sp
  416.         mov     bx,[bp+4]
  417.         mov     dl,DH_UnsetIRQ
  418.         CALL    [_Device_Help]
  419.         mov     ax,0
  420.         jnc     noreseterr
  421.         mov     ax,1
  422. noreseterr:
  423.         pop     bp
  424.         ret
  425. _DevHelp_UnsetIRQ endp
  426.  
  427. _DevHelp_EOI proc
  428. ;
  429. ;       [bp+4] = offset of handler
  430. ;
  431.         public  _DevHelp_EOI
  432.         push    bp
  433.         mov     bp,sp
  434.         mov     bx,[bp+4]
  435.         mov     dl,DH_EOI
  436.         CALL    [_Device_Help]
  437.         mov     ax,0
  438.         pop     bp
  439.         ret
  440. _DevHelp_EOI endp
  441.  
  442.  
  443.  
  444.  
  445. _TEXT           ENDS
  446.                 END
  447.  
  448.  
  449.