1 ; ***********************************************************
  2 ; *                                                         *
  3 ; * Copyright, (C) Honeywell Bull Inc., 1987                *
  4 ; *                                                         *
  5 ; * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6 ; *                                                         *
  7 ; ***********************************************************
  8 
  9 page 55,132
 10 
 11 ; HISTORY COMMENTS:
 12 ;  1) change(86-02-16,Westcott), approve(87-07-13,MCR7580),
 13 ;     audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 14 ;     Created.
 15 ;  2) change(86-09-04,Flegel), approve(87-07-13,MCR7580),
 16 ;     audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 17 ;     Installed mowse_timer to count seconds
 18 ;     rather than use timer_count to count ticks.
 19 ;                                                      END HISTORY COMMENTS
 20 
 21 ;/* : PROCEDURE FUNCTION (int1cep):
 22 ;
 23 ;This is the NARC interrupt handler.  It is designed to receive control when
 24 ;ever any of the three interrupts defined below occurs. If the interrupts are
 25 ;not nested, and if the interrupt did not occur in DOS, then NARC is invoked
 26 ;by a call to rcvdatas.
 27 ;
 28 ; Entries: int 1Ch  (from timer)
 29 ;          int 28h  (from console I/O wait routine)
 30 ;          int 13h  (from diskette services)
 31 ;*/
 32 
 33 ;/* : NOTES:
 34 ;
 35 ;The implementation is a duplicate of the one used by the Print spooler in
 36 ;Dos 2.0.
 37 ;*/
 38 
 39 include dos.mac
 40 include asmdefs.mac
 41 
 42 NON_EOI    = 20h
 43 EOI_PORT   = 20h
 44 
 45 page
 46 ;**************************************************************
 47 ;                                       MAIN
 48 ;**************************************************************
 49 pseg
 50 
 51 ;--------- Public Declarations
 52 
 53 public int13ep
 54 public int1cep
 55 public int28ep
 56 public wstime
 57 
 58 ;--------- External Declarations
 59 
 60 extrn   mowse_time:word                ; Current time in MOWSE
 61 extrn   ticpersec:word                 ; Clock tics per second
 62 extrn   calladvtmr:word                ; Time to call advtmr routine
 63 extrn   advance_count:word             ; Time to advance count
 64 extrn   time_count:dword               ; Number of tics since
 65 extrn   INT13:word                     ; Interrupt vector
 66 extrn   INT1C:word                     ; ...
 67 extrn   INT28:word                     ; ...
 68 extrn   IN_DOS:word                    ; Are we in DOS flag
 69 extrn   IN_INT28:word                  ; Are we in INT28 flag
 70 extrn   IN_NARC:word                   ; are we in MOWSE flag
 71 extrn   IN_SOFT:word                   ; are we in soft interrupt flag
 72 
 73 ;--------- External Procedures
 74 
 75 extrn   rcvdata:near
 76 extrn   receive_byte:near
 77 extrn   setup_stack:near
 78 extrn   reset_stack:near
 79 extrn   advtmr:near
 80 
 81 int1cep proc near
 82 
 83 ; /* : increment advance_count, increment time_count */
 84 
 85         inc     CS:advance_count
 86         inc     word ptr CS:time_count+2
 87         jnz     shortt
 88         inc     word ptr CS:time_count
 89 
 90 shortt:
 91         inc     CS:calladvtmr          ; Increment the protocol timer
 92         push    cx
 93         push    ax
 94         xor     cx,cx
 95         call    setup_stack
 96         push    bp
 97 
 98 ; /* : issue non-specific EOI to allow interrupts */
 99 
100         mov     al,NON_EOI
101         out     EOI_PORT,al
102 
103 ; /* : If 1 second has elapsed
104 ;      - reset counter
105 ;      - increment mowsetime
106 ;      - set flag to call advtmr */
107 
108         push    ax
109         mov     ax,CS:advance_count
110         cmp     ax,CS:ticpersec
111         pop     ax
112         jb      check_dos
113         inc     CS:mowse_time
114         mov     CS:advance_count,0
115 
116 ; /* : if in DOS, return */
117 
118 check_dos:
119         push    ds
120         push    si
121         lds     si,dword ptr cs:[IN_DOS]
122         cmp     byte ptr [si],0
123         pop     si
124         pop     ds
125         jne     ret1c
126 
127 ; /* : If calladvtmr flag set then reset flag and call advtmr */
128 
129         push    ax
130         mov     ax,CS:calladvtmr
131         shl     ax,1                   ; Multiply the current timer by two
132         cmp     ax,ticpersec           ; same as comparing time to 1/2 second
133         pop     ax
134         jl      dont_advance           ; if equal to 1 second, increment
135 
136         mov     CS:calladvtmr,0
137         push    ax
138         mov     bp,sp
139         call    advtmr                 ; advance protocol timeout timer
140         mov     sp,bp
141         pop     ax
142 
143 dont_advance:
144 
145 ; /* : Call rcvbyte to empty rs232 buffer */
146 
147         mov     bp,sp
148         call    receive_byte
149         mov     sp,bp
150 
151 ; /* : if in narc already, return */
152 
153         cmp     CS:IN_NARC,0
154         jne     ret1c
155 
156 ; /* : if in software interrupt, return */
157 
158         cmp     CS:IN_SOFT,0
159         jne     ret1c
160 
161 ; /* : Call rcvdata */
162 
163         inc     cs:IN_NARC             ; Notify that we are in MOWSE
164         push    ax
165         mov     bp, sp
166         xor     ax,ax
167         push    ax
168         call    rcvdata                ; call narc routine
169         mov     sp, bp
170         pop     ax
171         mov     CS:IN_NARC,0
172 
173 ret1c:
174         pop     bp
175         call    reset_stack
176         pop     ax
177         pop     cx
178 
179 ; /* : return from interrupt */
180 
181         jmp     dword ptr cs:[INT1C]
182 
183 ; /* : int28ep - interrupt 28 handler (console i/o)
184 ;      if in narc already, return */
185 
186 int28ep:
187         cmp     CS:IN_NARC,0
188         jne     ret28
189 
190 ; /* : if in software interrupt, return */
191 
192         cmp     CS:IN_SOFT,0
193         jne     ret28
194 
195 ; /* : if in software interrupt, return */
196 
197         cmp     CS:IN_INT28,0
198         jne     ret28
199 
200 ; /* : set in_narc and in_int28 flags */
201 
202         inc     CS:IN_NARC
203         inc     CS:IN_INT28
204         sti
205 
206 ; /* : call rcvdata */
207 
208         push    cx
209         push    ax
210         xor     cx,cx
211         call    setup_stack            ; Swap in MOWSE stack
212         push    bp
213         mov     bp, sp
214         mov     ax,1                   ; set dosflag to indicate that we are in DOS
215         push    ax
216         call    rcvdata                ; Handle messages
217         mov     sp, bp
218         pop     bp
219         cli
220         call    reset_stack            ; Swap out MOWSE stack
221         pop     ax
222         pop     cx
223         sti
224 
225 ; /* : return from int28 */
226 
227         mov     CS:IN_NARC,0
228         mov     CS:IN_INT28,0
229 
230 ret28:
231         jmp     dword ptr cs:[INT28]
232 
233 int1cep endp
234 
235 ; /* : int13ep - interrupt 13 handler (diskette services) */
236 
237 int13ep proc far
238         pushf
239 
240 ; /* : set in_narc flag */
241 
242         inc     cs:IN_NARC
243         push    cs
244         push    word ptr cs:INT13RET   ; push return address
245 
246 ; /* : simulate interrupt */
247 
248         push    word ptr cs:INT13+2    ; push real interrupt segment address
249         push    word ptr cs:INT13      ; push real interrupt offset address
250         ret                            ; simulate interrupt
251 
252 ; /* : decrement in_narc flag */
253 
254 ret13:  pushf
255         dec     cs:IN_NARC
256         popf
257         ret     2                      ; We'll let you guess what the 2 means
258 
259 INT13RET dw     offset ret13           ; return address from interrupt
260 
261 int13ep endp
262 
263 ;/* PROCEDURE FUNCTION (wstime):
264 ;
265 ;returns current value of mowse_time to caller.
266 ;*/
267 
268 wstime proc near
269      mov   ax,word ptr CS:mowse_time
270      ret
271 wstime endp
272 endps
273         end
274 ^Z