home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / idd.arc / mono.arc / mhdr.asm < prev    next >
Assembly Source File  |  1989-02-13  |  5KB  |  221 lines

  1.     PAGE    60, 132
  2. TITLE    HDR    22-Sep-88    Device Driver Header            |
  3. SUBTTL    Copyright (c) 1988  Frank E. Whaley                |
  4.  
  5. ;-----------------------------------------------------------------------|
  6. ;                                    |
  7. ;    Device Driver Library                        |
  8. ;        Device Driver Header                    |
  9. ;                                    |
  10. ;-----------------------------------------------------------------------|
  11.  
  12. ;-----------------------------------------------------------------------|
  13. ;    Equates                                |
  14. ;-----------------------------------------------------------------------|
  15.  
  16.     INCLUDE    DRIVER.EQU
  17.  
  18. StkSiz    EQU    2048            ; local stack size
  19.  
  20.     PAGE
  21. ;-----------------------------------------------------------------------|
  22. ;    Program Segment                            |
  23. ;-----------------------------------------------------------------------|
  24.  
  25.     Cseg
  26.  
  27.     Extrn    _Init:Near,        _MediaCheck:Near,    _BuildBPB:Near
  28.     Extrn    _IoCtlIn:Near,        _Input:Near,        _ndInput:Near
  29.     Extrn    _InputStatus:Near,    _InputFlush:Near,    _Output:Near
  30.     Extrn    _OutVerify:Near,    _OutStatus:Near,    _OutFlush:Near
  31.     Extrn    _IoCtlOut:Near,        _DevOpen:Near,        _DevClose:Near
  32.     Extrn    _RemMedia:Near
  33.  
  34.     ORG    0
  35.  
  36. HDR    Proc    Far
  37.  
  38. ;-----------------------------------------------------------------------|
  39. ;    Device Header                            |
  40. ;-----------------------------------------------------------------------|
  41.  
  42.     DD    -1            ; -> next device
  43.     DW    CharacterDevice
  44.     DW    Strategy        ; -> device strategy
  45.     DW    Interrupt        ; -> device interrupt
  46.     DB    "MON     "
  47.  
  48. ;-----------------------------------------------------------------------|
  49. ;    Code Segment Variables                        |
  50. ;-----------------------------------------------------------------------|
  51.  
  52. RHptr    DD    (?)            ; -> Request Header
  53. ssEntry    DW    (?)            ; entry SS
  54. spEntry    DW    (?)            ; entry SP
  55.  
  56.     PAGE
  57. ;-----------------------------------------------------------------------|
  58. ;    Device Strategy                            |
  59. ;                                    |
  60. ;    ENTRY :    ES:BX -> Request Header                    |
  61. ;                                    |
  62. ;    EXIT :    Request Header copied to ReqHdr                |
  63. ;        all registers preserved                    |
  64. ;                                    |
  65. ;-----------------------------------------------------------------------|
  66.  
  67. Strategy:
  68.  
  69.     MOV    Word Ptr CS:RHptr,BX    ; save request header ptr
  70.     MOV    Word Ptr CS:RHptr + 2,ES
  71.  
  72.     PUSHF                ; (+1) save the world
  73.     PUSH    ES            ; (+2)
  74.     PUSH    DS            ; (+3)
  75.     PUSH    SI            ; (+4)
  76.     PUSH    DI            ; (+5)
  77.     PUSH    CX            ; (+6)
  78.     PUSH    BX            ; (+7)
  79.  
  80.     MOV    SI,BX
  81.     MOV    BX,ES
  82.     MOV    DS,BX            ; DS:SI -> Request Header
  83.  
  84.     MOV    BX,Offset PGroup:PTail
  85.     MOV    CL,4
  86.     SHR    BX,CL
  87.     MOV    CX,CS
  88.     ADD    BX,CX
  89.     MOV    ES,BX
  90.  
  91.     MOV    DI,Offset DGroup:_ReqHdr; ES:DI -> ReqHdr
  92.     CLD
  93.     XOR    CH,CH
  94.     MOV    CL,[SI]
  95.     REP    MOVSB            ; copy Request Header
  96.     
  97.     POP    BX            ; (+6) restore
  98.     POP    CX            ; (+5)
  99.     POP    DI            ; (+4)
  100.     POP    SI            ; (+3)
  101.     POP    DS            ; (+2)
  102.     POP    ES            ; (+1)
  103.     POPF                ; (+0)
  104.     RET
  105.  
  106.     PAGE
  107. ;-----------------------------------------------------------------------|
  108. ;    Device Interrupt                        |
  109. ;                                    |
  110. ;    ENTRY :    anything                        |
  111. ;                                    |
  112. ;    EXIT :    all registers preserved                    |
  113. ;                                    |
  114. ;-----------------------------------------------------------------------|
  115.  
  116. Interrupt:
  117.  
  118.     PUSH    DS            ; (+1) save the world
  119.     PUSH    ES            ; (+2)
  120.     PUSH    AX            ; (+3)
  121.     PUSH    BX            ; (+4)
  122.     PUSH    CX            ; (+5)
  123.     PUSH    DX            ; (+6)
  124.     PUSH    SI            ; (+7)
  125.     PUSH    DI            ; (+8)
  126.     PUSH    BP            ; (+9)
  127.  
  128.     MOV    CS:ssEntry,SS        ; save entry SS
  129.     MOV    CS:spEntry,SP        ; and SP
  130.  
  131.     MOV    AX,Offset PGroup:PTail    ; set our DS, SS, BP, and SP
  132.     MOV    CL,4
  133.     SHR    AX,CL
  134.     MOV    CX,CS
  135.     ADD    AX,CX
  136.     MOV    BX,Offset DGroup:MyStack
  137.     MOV    DS,AX
  138.     MOV    ES,AX
  139.     MOV    SS,AX
  140.     MOV    SP,BX
  141.     MOV    BP,BX
  142.  
  143.     ;
  144.     ; call our function
  145.     ;
  146.     MOV    AL,_ReqHdr + 2        ; AL = Command Code
  147.     SHL    AL,1
  148.     CBW
  149.     MOV    SI,Offset DGroup:FuncTab
  150.     ADD    SI,AX
  151.     CALL    Word Ptr [SI]
  152.  
  153.     ;
  154.     ; copy back Request Header
  155.     ;
  156.     LES    DI,RHptr        ; ES:DI -> original space
  157.  
  158.     MOV    SI,Offset DGroup:_ReqHdr; DS:SI -> our (updated) copy
  159.     CLD
  160.     XOR    CH,CH
  161.     MOV    CL,[SI]
  162.     REP    MOVSB            ; copy Request Header
  163.  
  164.     MOV    SS,CS:ssEntry        ; restore original stuff
  165.     MOV    SP,CS:spEntry
  166.  
  167.     POP    BP            ; (+8) restore
  168.     POP    DI            ; (+7)
  169.     POP    SI            ; (+6)
  170.     POP    DX            ; (+5)
  171.     POP    CX            ; (+4)
  172.     POP    BX            ; (+3)
  173.     POP    AX            ; (+2)
  174.     POP    ES            ; (+1)
  175.     POP    DS            ; (+0)
  176.     RET
  177.  
  178. HDR    EndP
  179.  
  180.     EndCS
  181.  
  182.     PAGE
  183. ;-----------------------------------------------------------------------|
  184. ;    Data Segment                            |
  185. ;-----------------------------------------------------------------------|
  186.  
  187.     Dseg
  188.  
  189.     Public    _ReqHdr
  190.  
  191. FuncTab    Label Word
  192.     DW    Offset PGroup:_Init
  193.     DW    Offset PGroup:_MediaCheck
  194.     DW    Offset PGroup:_BuildBPB
  195.     DW    Offset PGroup:_IoCtlIn
  196.     DW    Offset PGroup:_Input
  197.     DW    Offset PGroup:_ndInput
  198.     DW    Offset PGroup:_InputStatus
  199.     DW    Offset PGroup:_InputFlush
  200.     DW    Offset PGroup:_Output
  201.     DW    Offset PGroup:_OutVerify
  202.     DW    Offset PGroup:_OutStatus
  203.     DW    Offset PGroup:_OutFlush
  204.     DW    Offset PGroup:_IoCtlOut
  205.     DW    Offset PGroup:_DevOpen
  206.     DW    Offset PGroup:_DevClose
  207.     DW    Offset PGroup:_RemMedia
  208.  
  209.     EndDS
  210.  
  211.     Useg
  212.  
  213. _ReqHdr    DB    256 Dup (?)        ; copy of Request Header
  214.  
  215.     DB    StkSiz Dup (?)        ; our stack, overflows into ReqHdr
  216. MyStack    Label    Word
  217.  
  218.     EndUS
  219.  
  220.     END    HDR            ; of HDR.ASM
  221.