summaryrefslogtreecommitdiffstats
path: root/private/mvdm/vdd/samples/hpscan/hpscan16.asm
blob: 5e121e9694e5e94ca5d44ec03dfa3efd33550101 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.MODEL small
;*************************************************
; Filename:	hpscan16.asm
; Purpose:  Stub DOS Device Driver. Pass device 
;   "HPSCAN" requests to the VDD, hpscan32.dll.
; Environment: MSDOS, Windows NT.
; (C) Hewlett-Packard Company 1993.
;*************************************************
INCLUDE hpscan16.inc     ;private
INCLUDE isvbop.inc       ;NT DDK

SUBTTL Segment and data definitions
      ASSUME   CS:CSEG,DS:NOTHING,ES:NOTHING
CSEG  SEGMENT

;-------------------------------------------------
; Resident data area - variables needed after init
;-------------------------------------------------

;**--- Device Header, must be at offset zero ---**
SCAN_HEADER:
        dd -1         ;becomes ptr to next req hdr
        dw 0C000H     ;character, supports IOCTL
        dw offset STRAT     ;Strategy routine
        dw offset IDVR      ;Interrupt routine
DH_NAME db 'HPSCAN  '       ;char device name

;**---- Request Header addr, saved by STRAT ----**
RH_PTRA LABEL  DWORD
RH_PTRO        dw  ?   ;offset
RH_PTRS        dw  ?   ;segment

;**------------- Define Stack Space ------------**
STK_SEG  dw  ?        ;Save original stack segment
STK_PTR  dw  ?        ;Save original stack pointer
STACK    dw  200 DUP (0)     ;Local stack
TOP_STK  dw  ?        ;Top of local stack

;**--------------- VDD information -------------**
VDD_DllName      db  "HPSCAN32.DLL", 0
VDD_InitFunc     db  "VDDInit", 0
VDD_DispFunc     db  "VDDDispatch", 0
VDD_hVDD         dw  ?

;**-------------- Copyright Info ---------------**
  db '(C) Copyright Hewlett-Packard Company 1993.'
  db 'All rights reserved.'

SUBTTL Device Strategy & Interrupt entry points

;**--------------- STRAT routine ---------------**
STRAT  proc  far           ;Strategy routine
    mov  cs:RH_PTRO,bx     ;save offset address
    mov  cs:RH_PTRS,es     ;save segment address
    ret                    ;end Strategy routine
STRAT  endp

;**--------------- IDVR routine ---------------**
IDVR  proc  far     ;Interrupt routine
    push  ds        ;save all modified registers
    push  es        ;DOS has stack for 20 pushes
    push  ax
    push  bx
    push  cx
    push  dx
    push  di
    push  si
    push  bp

    mov  cs:STK_PTR,sp   ;save original stack ptr
    mov  cs:STK_SEG,ss   ;save original stack seg
    cli                  ;disable for stack ops
    mov  ax,cs           ;setup new stack ptr
    mov  ss,ax           ;setup new stack seg
    mov  sp,offset TOP_STK
    sti                  ;restore flags back
    cld                  ;all moves are forward

    les  bx,cs:RH_PTRA  ;load req hdr adr in es:bx
    mov  al,RH.RHC_CMD
    cmp  al,0           ;check for init command
    je   BOOTUP         ;command 0 = init

    xor  dx,dx          ;some other command
    mov  dl,RH.RHC_CMD  ;dx = command code
    mov  cx,RH.RHC_CNT  ;cx = count
    mov  ax,RH.RHC_SEG  ;es:bx = addr of data
    mov  bx,RH.RHC_OFF
    mov  es,ax          ;finally, load VDD handle
    mov  ax,word ptr cs:[VDD_hVDD]
    DispatchCall        ;call Dispatch in VDD
                        ;returns with status in di
EXIT:
    les  bx,cs:RH_PTRA  ;restore ES:BX
    or   di,STAT_DONE   ;add "DONE" bit to status
    mov  RH.RHC_STA,di  ;save status in requ hdr
    cli                 ;disable ints for stack op
    mov  ss,cs:STK_SEG  ;restore stack seg
    mov  sp,cs:STK_PTR  ;restore stack ptr  
    sti                 ;re-enable interrupts

    pop  bp             ;restore registers
    pop  si
    pop  di
    pop  dx
    pop  cx
    pop  bx
    pop  ax
    pop  es
    pop  ds
    ret                 ;far return
IDVR endp

;**--------- jump here for Init Command --------**
BOOTUP:
    mov  ax,offset EndDriver
    mov  RH.RHC_OFF,ax  ;address of end of driver
    mov  RH.RHC_SEG,CS  ;reference from code seg

    mov  si,offset VDD_DllName  ;load regs for VDD
    mov  di,offset VDD_InitFunc
    mov  bx,offset VDD_DispFunc
    mov  ax,ds
    mov  es,ax
    RegisterModule      ;calls the VDD
    jnc  save_hVDD      ;if NC then success
    mov  di,STAT_GF     ;set failure status
    jmp  EXIT           ;return via common exit

save_hVDD:
    mov  [VDD_hVDD],ax  ;save handle in ax
    mov  di,STAT_OK     ;load OK status
    jmp  EXIT           ;return via common exit

EndDriver db ?
CSEG    ENDS
        END  SCAN_HEADER ;REQUIRED BY EXE2BIN