1 TITLE MTCON
- Console device driver for MT
-MSDOS
7 ;; interruptible waits and unwinding
8 ;; per screen keyboard buffers
10 ;------------------------------------------------------------------------
13 ; V1.00 04/10/84 M.A.Ulloa
14 ; First Implementation: Only one segment used and only
15 ; one screen in the color card (alpha mode).
17 ; V1.01 04/15/84 M.A.Ulloa
18 ; Re-enabled the blocking of writing from processes not
19 ; with the current screen.
21 ; V1.02 04/16/84 M.A.Ulloa
22 ; Increased to 8 the num of screens. Added the screen
23 ; blanking when reading and writing the screen data
24 ; (see BLANK switch). Added screen # for writes.
26 ; V1.03 04/17/84 M.A.Ulloa
27 ; Corrected problem with flush.
29 ; V1.05 04/30/84 A.R.Whitney
30 ; Added conditional compilation to allow linking with
33 ; V1.06 05/08/84 A.R.Whitney
34 ; Added ANSI escape sequences. Conditional on ANSI.
36 ; V1.07 05/15/84 A.R.Whitney
37 ; Fixed compatibility problems with Eagle PC Turbo.
38 ; Fixed BLANK conditional code to allow saving graphics
40 ; Added enable/disable 25th line to Ansi.
42 ; V1.08 05/22/84 A.R.Whitney
43 ; Fixed problem with scrolling in screen modes other
44 ; than 80x25. Bug due to 25th line stuff.
46 ;------------------------------------------------------------------------
57 CVERS equ
01 ; update version number!!
60 BLANK equ TRUE
; blank screen during data r/w
61 INBIOS equ TRUE
; link with BIOS
62 ANSI equ TRUE
; include ANSI escape sequences
63 LINE25 equ TRUE
; special 25th line like VT52
64 EAGLE equ TRUE
; Eagle PC ROM botches CRT_LEN
67 subttl Screen Information Block Definition
70 ;------------------------------------------------------------------------
71 ; Screen Information Block (SIB) Definition
73 ; This structure contains all information necessary to
74 ; describe the state of the screen, plus pointers to buffers
75 ; which contain the actual screen content.
78 ;------------------------------------------------------------------------
79 MaxSEG equ
2 ; NOTE: assumption is made in the
80 ; code that all SIB's have same
83 SizeNeeded dw 0 ; needed size for seg, (0 = unused)
84 MemFlag dw ?
; maintened by system (0 = in mem)
85 MPointer dd ?
; vaild iff MemFlag == 0
88 ;------------------------------------------------------------------------
89 MaxSIB equ
8 ; maximum number of Screens
93 TermSize EQU
20 ; max. size of terminal emulation state
97 ctlS db 0 ; if the screen is NOT frozen = 0
98 ; NOTE: this field should be the
99 ; FIRST of each SIB !! (see ConWrit)
100 OffsetVal dw 7 ; start of Seg Descriptors
101 SegCnt dw MaxSeg
; max number of Segments
102 SIBlen dw (SIZE SIBst
) ; length of the SIB
104 db ((SIZE SEGst
) * MaxSeg
) dup (?
)
105 ;--- PC video state info
110 xCURSOR_POSN
DW 8 DUP(?
)
116 xTERM_STATE
DB TermSize
DUP(?
)
120 subttl Request packet definitions
123 ;------------------------------------------------------------------------
124 ; Request packet offset definitions
127 CMDLEN
= 0 ;LENGTH OF THIS COMMAND
128 UNIT
= 1 ;SUB UNIT SPECIFIER
129 CMD
= 2 ;COMMAND CODE
131 MEDIA
= 13 ;MEDIA DESCRIPTOR
132 TRANS
= 14 ;TRANSFER ADDRESS
133 COUNT
= 18 ;COUNT OF BLOCKS OR CHARACTERS
134 START
= 20 ;FIRST BLOCK TO TRANSFER
137 subttl IBM
-PC ROM
Data area Locations
140 ;------------------------------------------------------------------------
141 ; IBM-PC ROM Data area Locations
144 RomData
SEGMENT AT 40H
148 KeyBuffer
DW 16 DUP (?
)
149 KeyBufLen equ
($-KeyBuffer
) ; length of KeyBuffer
156 CURSOR_POSN
DW 8 DUP(?
)
163 CrtLen EQU
($-CRT_MODE
) ; length of screen state area
166 MonoSc
SEGMENT AT 0B000H
167 ;--- 4k of screen memory
170 ColorSc
SEGMENT AT 0B800H
171 ;--- 16k of screen memory
174 BRKADR equ
006CH ; Break vector address
181 BiosSeg group
Code,BiosInit
182 Code Segment byte public 'CODE'
184 ;------------------------------------------------------------------------
188 assume
cs:Code,ds:NOTHING
,es:NOTHING
,ss:NOTHING
195 CONDEV dw 0FFFFh,0FFFFh
197 ;*** should ioctl bit be set for gen ioctl too?
198 dw 1100000000010011b ; console in and out
204 ;------------------------------------------------------------------------
205 ; Command dispatch table
210 dw OFFSET BiosSeg
:$ConInit
; Initialization function
211 dw StatusComplete
; Media Check
212 dw StatusComplete
; Build BPB
213 dw CmdErr
; IOCTL Input
214 dw $ConRead
; Input (Read)
215 dw $ConRdnd
; Non-Destructive read, no wait
216 dw StatusComplete
; Input Status
217 dw $ConFlsh
; Input Flush
218 dw $ConWrit
; Output (Write)
219 dw $ConWrit
; Output with verify
220 dw StatusComplete
; Output Status
221 dw StatusComplete
; Output Flush
222 dw StatusComplete
; IOCTL Output
224 dw StatusComplete
; Device Open
225 dw StatusComplete
; Device Close
226 dw StatusComplete
; Removable Media
228 dw $GenIOCTL
; Generic IOCTL
229 dw $ConStop
; Pause Device
230 dw $ConStart
; Continue Device
234 CTSIZE equ
(ComTblEnd
- ComTbl
)/2 ; number of table entries
237 subttl Device
Data Area
240 ;------------------------------------------------------------------------
244 SaveFlg db 0 ; Screen being saved flag, (true = 1)
246 EXTRN DosFunction
:DWORD
248 DosFunction dd ?
; pointer to dos "helper" functions
250 AltAH db 0 ; Side buffer for input
251 CurrSc dw 0 ; Current screen number
252 CurrSIB dw SIB
; offset to the current SIB
253 SIB SIBst MaxSIB
dup (<>) ; allocate room for SIB's
256 ScreenLen db 08h ; table of (high byte of) regen. buffer
257 db 08h ; len. Indexed by screen mode.
258 db 10h
; 80x25 text modes
260 db 40h
; graphics modes
269 EXTRN BUGBITS
:BYTE,DPRINTF
:NEAR
275 subttl Device
Entry Points
278 ;------------------------------------------------------------------------
279 ; 2.0 Interrupt Routine (Not Used)
287 ;------------------------------------------------------------------------
288 ; 2.0 Strategy Routine, main entry point
291 ; ES:BX points to Request packet
301 mov si,OFFSET
CS:ComTbl
317 mov al, byte ptr ds:[bx].CMD
318 cmp al,CTSIZE
; Command within range?
319 jae CmdErr
; no must be an error
320 mov cx, word ptr ds:[bx].COUNT
321 les di, dword ptr ds:[bx].TRANS
323 mov si, offset ComTbl
327 jmp word ptr cs:[si] ; dispatch
336 ;------------------------------------------------------------------------
337 ; Exit Routines, Common to all device functions
341 extrn StatusComplete
:NEAR,StatusError
:NEAR,StatusDevReady
:NEAR
345 assume
ds:NOTHING
,es:NOTHING
348 mov ah,00000011b ; device busy
352 mov al,3 ; Unknown command Error
358 StatusComplete: mov ah,00000001b
362 mov word ptr es:[bx].STATUS
,ax ; put status out
377 subttl
Break - Break interrupt routine
380 ;------------------------------------------------------------------------
381 ; Break interrupt routine
384 assume
ds:NOTHING
,es:NOTHING
387 int 32H
; save registers
388 cli ; ints should be off, make sure!
392 mov ax,offset RomData
:KeyBuffer
396 mov ax,3 ; send char to system
397 mov dx,5 ; ConsInputFilter subfunction
399 jz brk1
; key was eaten by system
400 mov [AltAH
],al ; force a ^C
405 SUBTTL Keyboard interrupt routine
407 ; Replacement for ROM keyboard interrupt, tacks on the front.
408 ; OldKeyInterrupt is set to original contents of INT 09H.
409 ; The input character is passed to the O.S. console input filter
410 ; to determine if any special action should be taken. The filter
411 ; return value indicates if the character should be saved in the
412 ; type ahead buffer or if it should be discarded. A keyboard
413 ; semaphore exists to indicate if a process is waiting for input.
414 ; If the keboard semaphore is set all of the processes sleeping on
418 KeySem db 0 ; non-zero if someone waiting on input
420 KeyboardInterrupt PROC
FAR
426 PUSHF ; Save flags to simulate INT
427 CALL CS:OldKeyInterrupt
; Now do ROM code
428 ; Now tell DOS keyboard had char
429 cli ; interrupts off!
430 mov bx,BufferTail
; Get tail of queue
431 cmp bx,BufferHead
; Anything in keyboard queue?
432 JE NoKey
; No, don't requeue then
435 cmp bx,offset RomData
:KeyBuffer
436 jae kbi1
; no wrap around in buffer
437 mov bx,offset RomData
:KeyBuffer
+(KeyBufLen
-2)
439 mov ax,[bx] ; get last queued char.
440 mov dx,5 ; ConsInputFilter subfunction
442 jnz kbi2
; key should remain in buffer
443 mov BufferTail
,bx ; discard key from buffer
447 CMP KeySem
,0 ; Outstanding request?
448 JE NoKey
; No, may not be inited either
455 mov cs:byte ptr [bx],0 ; reset keyboard semaphore
457 call [DosFunction
] ; awaken anyone waiting on input
464 KeyBoardInterrupt ENDP
466 ;-------------------------------------------------------------
467 ; Keyboard INT 16 intercept routine to allow console input to sleep.
468 ; Only console input function 1 is intercepted, all other functions
469 ; are allowed to go directly to the ROM BIOS. For the function 1
470 ; the input status is checked, if a character is ready the function
471 ; is allowed to go to the ROM BIOS. Otherwise the keyboard semaphore
472 ; is set and the process is put to sleep on the address of the
473 ; semaphore. When a key is typed the keyboard interrupt routine
474 ; will wakeup any processes sleeping on this semaphore.
476 ; WARNING: The following routines can be entered recursively
477 ; due to the fact that the ROM BIOS routines called
478 ; reenable interrupts. It's not usually a problem
479 ; since interrupts will generally be processed faster
480 ; than anyone can type.
485 ;-------------------------------------------------------------
487 KeyBoardHandler proc
far
499 test byte ptr [bx],0FFh
505 DoInt16
LABEL FAR ; entry for ChrIn
515 test byte ptr [bx],0FFh
519 mov dx,9 ;; ProcBlock
520 call [DosFunction
] ; sleep until a screen switch
524 mov ah,1 ; get console status
525 pushf ; simulate INT to old handler
528 cli ; subfunction 1 unconditionally sets IF
529 jnz LocalRead
; go read character
532 mov cs:byte ptr [bx],0FFh ; set keyboard semaphore
534 mov dx,9 ;; ProcBlock
535 call [DosFunction
] ; sleep until a char is typed
543 jmp [OldKbdHandler
] ; read the character and return
548 subttl $ConRead
- Console Input
(Read
)
551 ;------------------------------------------------------------------------
552 ; Console Input (Read)
555 ; DS:BX = pointer to Request packet
556 ; ES:DI = Transfer address
560 assume
ds:NOTHING
,es:NOTHING
566 ; jcxz CRExit ; no chars to read BUGBUG restore
567 jgl2: cld ; make sure!
568 mov dx,word ptr ds:[bx].START
; get screen number
569 cmp dx,(MaxSIB
-1) ; valid number?
570 jbe ConRLoop
; yes, do input
571 mov al,0BH ; no, READ FAULT ERROR
574 DEBUG 10h
,1,<CONR
:$x
=$x?
>,<dx,CurrSc
>
577 call GetSIBAdr
; get pointer to the SIB
578 DEBUG 10h
,1,<Block read wrong screen
>,<>
579 call DoPBlock
; block the process
580 jmp short ConRLoop
; test flag again
586 CRExit: jmp StatusComplete
590 subttl ChrIn
- Read a single character
In
593 ;------------------------------------------------------------------------
594 ; Read a single character In
602 assume
ds:NOTHING
,es:NOTHING
605 DEBUG 10h
,1,<in.ChrIn
>,<>
607 xchg al,[AltAH
] ; Get Character & zero AltAH
608 or al,al ; A char available?
611 ;--- NOTE: The blocking on read is done at int 16h level
612 ; in IBMBIO. No need to block here.
614 DEBUG 10h
,1,< con
.do
.16 >,<>
615 mov ah,0 ; no, do a read call
619 DEBUG 10h
,1,< con
.got
.$x
>,<ax>
620 or ax,ax ; check for non-key after BREAK
624 jgl1: cmp ax,7200h
; CTRL-PRTSC ?
626 mov al,10h
; yes, make it a ctrl-P
627 sja0: or al,al ; special case?
634 subttl $ConRdnd
- Console non
-destructive Input
, no
wait
637 ;------------------------------------------------------------------------
638 ; Console non-destructive Input, no wait
641 ; DS:BX = pointer to Request packet
644 assume
ds:NOTHING
,es:NOTHING
647 mov dx,word ptr ds:[bx].START
; get screen number
648 cmp dx,(MaxSIB
-1) ; valid number?
649 jbe sjq0
; yes, do input
650 mov al,0BH ; no, READ FAULT ERROR
653 DEBUG 10h
,1,<CNDR
:$x
=$x?
>,<dx,CurrSc
>
659 jne ConBus
; not current screen, no char avail
661 ; call GetSIBAdr ; get pointer to the SIB
662 ; call DoPBlock ; block the process
663 ; jmp short sjq0 ; test flag again
665 mov al,[AltAH
] ; char avail already?
668 DEBUG 10h
,1,< NRD
:do
.16 >,<>
669 mov ah,1 ; no, get status
672 DEBUG 10h
,1,< NRD
:nonbus $x
>,<ax>
674 jnz NotBk
; Check for null after break
675 mov ah,0 ; flush the null
677 jmp $ConRdnd
; try again
678 ; jmp short $ConRdnd ; try again BUGBUG
680 cmp ax,7200h
; CTRL-PRTSC ?
682 mov al,10h
; yes, make it a ctrl-P
684 mov byte ptr ds:[bx].MEDIA
,al ; save character
685 DoExit: jmp StatusComplete
687 ConBus: DEBUG 10h
,1,< ConBus
- >,<>
691 subttl $ConFlsh
- Console Flush Input
694 ;------------------------------------------------------------------------
695 ; Console Flush Input
698 ; DS:BX = pointer to Request packet
701 assume
ds:NOTHING
,es:NOTHING
704 mov dx,word ptr ds:[bx].START
; get screen number
705 cmp dx,(MaxSIB
-1) ; valid number?
706 jbe sjr0
; yes, do flush
707 mov al,0BH ; no, READ FAULT ERROR
712 call GetSIBAdr
; get pointer to the SIB
713 call DoPBlock
; block the process
714 jmp short sjr0
; test flag again
716 mov [AltAH
],0 ; clear side bufer
721 cli ; Disable interrupts
722 mov ax,offset RomData
:KeyBuffer
; Start of Rom buffer
724 mov [BufferTail
],ax ; Empty the queue
731 subttl $ConWrit
- Console Output
(Write
)
734 ;------------------------------------------------------------------------
735 ; Console Output (Write)
738 ; DS:BX = pointer to Request packet
739 ; ES:DI = Transfer address
743 assume
ds:NOTHING
,es:NOTHING
747 mov dx, word ptr ds:[bx].START
; get screen number
748 cmp dx,(MaxSIB
-1) ; valid screen number?
750 mov al,0AH ; no, write fault error
758 cmp dx,[CurrSc
] ; Is it to the current screen?
759 je sjb2
; yes, do not block
760 call GetSIBAdr
; get pointer to the SIB
761 sjb1: call DoPBlock
; block the process
762 jmp short ConWLoop
; test ALL flags again
764 cmp [bx].ctlS
,0 ; is the screen frozen?
766 mov ax,bx ; AX = [CurrSIB] = [CurrSIB].ctlS !!!!
767 jmp short sjb1
; yes, block the process
769 cmp [SaveFlg
],0 ; are we in the middle of a save?
770 je sjb4
; no, do write
771 mov ax,offset SaveFlg
772 jmp short sjb1
; yes, block...
774 mov al,es:[di] ; get a character
778 CWExit: jmp StatusComplete
781 subttl CharOut
- Output a character to the screen
784 ;------------------------------------------------------------------------
785 ; Output a character to the screen
788 ; AL = Character to write
791 ; BX, CX, DX, DI, DS & ES
794 assume
ds:NOTHING
,es:NOTHING
804 int 10h
; Write Character
811 subttl $GenIOCTL
- Generic IOCTL
814 ;------------------------------------------------------------------------
818 ; DS:BX = pointer to Request packet
821 ;--- Offsets into the request packet
822 ;*** Check offset are correct
823 FunCode
= 14 ; Function Code
824 FunCat
= 13 ; Function Category
826 RegSI
= 15 ; Contents of SI
827 RegDI
= 17 ; Contents of DI
828 DatBuf
= 19 ; Pointer to data buffer
830 ;--- Code & Category definitions
831 IOC_SC
= 03h ;--- Screen Control
832 IOSC_LS
= 41h
; Locate SIB
833 IOSC_SS
= 42h
; save segment
834 IOSC_RS
= 43h
; restore segment
835 IOSC_EI
= 44h
; re-enable i/o
836 IOSC_IS
= 45h
; initialize screen
838 assume
ds:NOTHING
,es:NOTHING
841 cmp byte ptr ds:[bx].FunCode
,IOC_SC
842 jne GI_BadCode
; function not suported
843 mov si,word ptr ds:[bx].RegSI
844 mov al,byte ptr ds:[bx].FunCat
862 jmp CmdErr
; error exit: Command error
865 subttl do_IOSC_LS
- Locate SIB
868 ;------------------------------------------------------------------------
873 ; DS:BX = pointer to Request packet
876 assume
ds:NOTHING
,es:NOTHING
879 cmp si,(MaxSIB
-1) ; index within range?
886 cmp si,[CurrSc
] ; is it the current screen?
888 mov [CurrSc
],si ; no, just switch curr screens
890 call GetSIBAdr
; get pointer to SIB
891 mov [CurrSIB
],ax ; save pointer to curr SIB
895 mov [SaveFlg
],1 ; Signal we are Saving the screen
897 ;*** Only one segment for now
900 call GetSegAdr
; on return BX points to segment
912 assume
es:NOTHING
; not true, but just to be safe
914 mov [bx].SizeNeeded
,ax ; save size of segment
915 mov ax,dx ; pointer to current SIB
920 mov word ptr ds:[bx].DatBuf
,ax ; offset
921 mov word ptr ds:[bx].DatBuf
+2,cs ; segment
922 mov word ptr ds:[bx].RegSI
,0 ; operation ok
926 mov word ptr ds:[bx].RegSI
,1 ; bad SIB number error
930 subttl do_IOSC_SS
- Save
Segment
933 ;------------------------------------------------------------------------
937 ; SI = Segment Index (into the Current SIB)
938 ; DS:BX = pointer to Request packet
941 assume
ds:NOTHING
,es:NOTHING
944 cmp si,(MaxSeg
-1) ; within range?
946 ja BadNum
; no, somebody screwed up...
949 cmp si,0 ; first segment save?
950 jne nfSS
; no, just save screen data
951 ;--- save screen state data
954 mov ds,ax ; DS = ROM data area
956 mov si,offset RomData
:CRT_MODE
957 mov cx,CrtLen
; length of screen state data
962 lea di,[di].xCRT_MODE
964 rep movsb ; copy ROM info to SIB area
969 mov si,offset AnsiState
; point to ANSI state info
971 rep movsb ; save ANSI state info in SIB
973 pop si ; restore segment index
974 ;--- save a segment of screen data
980 call GetSegAdr
; get adress of segment and curr SIB ptr
981 mov cx,[bx].SizeNeeded
; CX = Ammount to transfer
983 les di,[bx].MPointer
; ES:DI = Screen save area
986 ;*** For now we are using only one segment
988 mov si,dx ; SI points to the current SIB
989 mov bx,ColorSc
; assume color card
990 cmp [si].xCRT_MODE
,7 ; is this a BW monitor?
995 mov dx,[si].xADDR_6845
; point to mode register
997 mov al,[si].xCRT_MODE_SET
; and get value
999 out dx,al ; turn off video
1001 mov ds,bx ; DS points to apropiate screen area
1005 rep movsw ; copy the screen
1008 out dx,al ; turn on video
1012 mov word ptr ds:[bx].RegSI
,0 ; operation ok
1016 subttl do_IOSC_RS
- Restore Segment
1019 ;------------------------------------------------------------------------
1023 ; SI = Segment Index (into the Current SIB)
1024 ; DS:BX = pointer to Request packet
1027 assume
ds:NOTHING
,es:NOTHING
1030 cmp si,(MaxSeg
-1) ; within range?
1031 ja BadNumJ1
; no, somebody screwed up...
1037 cmp si,0 ; first segment save?
1038 jne nfRS
; no, just restore screen data
1039 ;--- restore screen state data
1040 push si ; save index
1043 lea si,[si].xCRT_MODE
1045 mov es,ax ; ES = ROM data area
1047 mov cx,CrtLen
; length of screen state data
1048 mov di,offset RomData
:CRT_MODE
1050 rep movsb ; copy ROM info from SIB area
1056 mov di,offset AnsiState
; point to ANSI state info
1058 rep movsb ; restore ANSI state info from SIB
1063 ;--- Setup new screen state
1065 mov al,[si].xCRT_MODE
1066 cmp al,7 ; is this the BW monitor?
1068 mov al,2 ; this is the "real" mode
1071 int 10h
; set new mode
1072 mov cx,[si].xCURSOR_MODE
1074 int 10h
; set cursor type
1075 mov dx,[si].xCURSOR_POSN
1076 mov bh,[si].xACTIVE_PAGE
1078 int 10h
; set cursor position
1079 mov al,[si].xACTIVE_PAGE
1081 int 10h
; set page #
1082 mov dx,[si].xADDR_6845
1084 mov al,[si].xCRT_PALETTE
1085 out dx,al ; set color port
1086 mov es:CRT_PALETTE
,al
1087 pop si ; restore segment index
1088 ;--- restore a segment of screen data
1091 call GetSegAdr
; get adress of segment
1092 mov cx,[bx].SizeNeeded
; CX = Ammount to transfer
1094 lds si,[bx].MPointer
; DS:SI = Screen save area
1097 ;*** For now we are using only one segment
1099 mov di,dx ; DI points to the current SIB
1100 mov bx,ColorSc
; assume color card
1101 cmp cs:[di].xCRT_MODE
,7 ; is this a BW monitor?
1106 mov dx,cs:[di].xADDR_6845
; point to mode register
1108 mov al,cs:[di].xCRT_MODE_SET
; and get value
1110 out dx,al ; turn off video
1112 mov es,bx ; ES points to apropiate screen area
1116 rep movsw ; copy the screen
1119 out dx,al ; turn on video
1125 mov word ptr ds:[bx].RegSI
,0 ; operation ok
1132 subttl do_IOSC_EI
- Re
-enable i
/o
1135 ;------------------------------------------------------------------------
1139 ; DS:BX = pointer to Request packet
1142 assume
ds:NOTHING
,es:NOTHING
1145 mov [SaveFlg
],0 ; Signal we are done Saving the screen
1146 mov ax,offset
Code:SaveFlg
1147 call DoPRun
; ProcRun
1148 mov ax,[CurrSIB
] ; pointer to current SIB
1149 call DoPRun
; ProcRun any output blocked because
1150 ; screen was not current
1154 subttl do_IOSC_IS
- Initialize Screen
1157 ;------------------------------------------------------------------------
1162 ; DS:BX = pointer to Request packet
1165 assume
ds:NOTHING
,es:NOTHING
1168 cmp si,(MaxSIB
-1) ; index within range?
1174 mov [CurrSc
],si ; switch curr screens
1176 call GetSIBAdr
; get pointer to SIB
1177 mov [CurrSIB
],ax ; save pointer to curr SIB
1179 mov [si].ctlS
,0 ; screen not frozen
1180 ;--- set screen mode to pc mode 3 (80x25 BW)
1181 mov ax,0003 ; Set mode 3
1185 mov word ptr ds:[bx].RegSI
,0 ; operation ok
1189 subttl $ConStop
- Stop
(freeze
) console output
1192 ;------------------------------------------------------------------------
1193 ; Stop (freeze) console output
1196 assume
ds:NOTHING
,es:NOTHING
1199 mov bx,[CurrSIB
] ; pointer to current SIB
1200 mov cs:[bx].ctlS
,01 ; set the freeze flag
1204 subttl $ConStart
- Start
(continue
) console output
1207 ;------------------------------------------------------------------------
1208 ; Start (continue) console output
1211 assume
ds:NOTHING
,es:NOTHING
1214 mov bx,[CurrSIB
] ; pointer to current SIB
1215 cmp cs:[bx].ctlS
,0 ; is it already going?
1216 je csRet
; yes, no need to re-enable
1217 mov cs:[bx].ctlS
,0 ; reset the freeze flag
1218 lea ax,[bx].ctlS
; get address of current ctlS
1219 call DoPRun
; do ProcRun
1220 csRet: jmp StatusComplete
1223 subttl DoPBlock
- Block the current process
1226 ;------------------------------------------------------------------------
1227 ; Block the current process
1230 ; CS:AX = address to block on
1232 ; modifies: AX, FLAGS
1235 assume
ds:NOTHING
,es:NOTHING
1242 mov ax,cs ; AX:BX = event identifier
1243 xor cx,cx ; No timeout
1244 ;; mov dx,0109h ;;BUGBUG - should be interruptible wait; will
1245 ;; give InternalError (SchedFind - not on Q)
1246 mov dx,0009h ; PROCBLOC function
1249 pop dx ; on return ints are back on
1255 subttl DoPRun
- Restart a process
1258 ;------------------------------------------------------------------------
1262 ; CS:AX = address to signal on (same as blocked on)
1264 ; modifies: AX, FLAGS
1267 assume
ds:NOTHING
,es:NOTHING
1275 mov dx,10 ; PROCRUN function
1283 subttl GetSIBAdr
- Return SIB address
1286 ;------------------------------------------------------------------------
1287 ; Returns the adress of the specified SIB
1290 ; DX = index to the SIB
1293 ; AX = pointer to the SIB
1298 assume
ds:Code,es:NOTHING
1301 push dx ; save screen #
1304 mul dx ; multiply by size of SIB entry
1305 pop dx ; restore screen #
1306 add ax,offset SIB
; AX = pointer to SIB for the write
1310 subttl GetSegAdr
- Return
segment address
1313 ;------------------------------------------------------------------------
1314 ; Returns the adress of a segment in the current SIB
1317 ; AX = index to the segment
1320 ; BX = pointer to the segment
1321 ; DX = pointer to the Current SIB
1324 assume
ds:Code,es:NOTHING
1328 mul dx ; multiply by size of SEG entry
1329 mov bx,[CurrSIB
] ; pointer to SIB
1330 mov dx,bx ; save for exit
1331 mov bx,[bx].OffsetVal
; pointer to start of SEGs in SIB
1332 add bx,ax ; BX = pointer to SEG from start of SIB
1333 add bx,dx ; BX = absolute pointer to SEG to use
1343 subttl $ConInit
- Initialization Routine
1346 ;------------------------------------------------------------------------
1347 ; Initialization Routine
1350 ; DS:BX = pointer to Request packet
1351 ; ES:DI = Dos Functions entry point address
1354 assume
ds:NOTHING
,es:NOTHING
1358 push ds ; print greeting
1365 mov word ptr ds:[bx].TRANS
, offset $ConInit
1366 mov word ptr ds:[bx].TRANS
+2,cs
1368 mov cs:Word Ptr DosFunction
,di ; Save pointer to service routines
1369 mov cs:Word Ptr DosFunction
+2,es
1374 call [DosFunction
] ; get DOS variable ScrnIoOk
1375 mov word ptr ScrnIoOk
,ax
1376 mov word ptr ScrnIoOk
+2,dx
1378 ;* Initialize interrupt vectors.
1379 ;;BUGBUG - we should be using Get/Set_Interrupt_Vector calls
1381 xor ax,ax ; initialize break interrupt handler
1382 mov es,ax ; points to page 0
1384 mov word ptr es:BRKADR
,offset
Break
1385 mov word ptr es:BRKADR
+2,ax ; Vector for Break
1387 MOV DI,9*4 ; INT 9 - Keyboard interrupt vector
1388 MOV CX,es:[DI] ; Save old addr to hook to
1389 MOV WORD PTR OldKeyInterrupt
,CX
1391 MOV WORD PTR (OldKeyInterrupt
+2),CX
1392 MOV CX,OFFSET KeyboardInterrupt
1396 STOSW ; Set new keyboard interrupt
1398 mov di,16h
*4 ; INT 16 - keyboard input
1399 MOV CX,es:[DI] ; Save INT 16 addr to hook to
1400 MOV WORD PTR OldKbdHandler
,CX
1402 MOV WORD PTR (OldKbdHandler
+2),CX
1403 MOV CX,OFFSET KeyboardHandler
1406 XCHG AX,CX ; Set new keyboard Handler
1414 BiosInit
segment para
public 'CODE'
1417 Intro db "--- Installing MTCON Device Driver V"
1418 db CVERS
+"0",".",CREV
/10+"0"
1419 db (CREV
-CREV
/10*10)+"0"," ---"