2 TITLE DOS
- CONSOLE Code Page Switching Device Driver
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 ; FILENAME: DISPLAY.ASM
6 ; PROGRAM: DISPLAY.SYS (Main module)
7 ; LINK PROCEDURE: Linkk
10 ; This routine is structured as a DOS Device Driver.
11 ; IE it is installed via the CONFIG.SYS command:
14 ; The following device commands are supported:
18 ; Install the CON device driver. This is used for downloading of
19 ; the character sets (various Code Pages) according to the respective
20 ; display adapter. The interface provided by the video BIOS is used
21 ; to download a block of 256 characters (in various resolutions - ie.
22 ; 8x8, 8x14, and 8x16). Also, the interrupt 2F hex is chained for
23 ; communication between the CON device driver and the keyboard routine.
25 ; Refer to INIT.ASM for code
27 ; 13 hex - GENERIC IOCTL
28 ; ----------------------
31 ; Invoke is use to activate the appropriate CP font. The mechanism
32 ; is based soley on the code page value passed from the MODE & CHCP
33 ; commands. Once a CP ahs benn INVOKED, it is loaded for ALL display
34 ; modes on the respective display adapter - ONLY IF the proper font
35 ; resolution can be accessed.
37 ; Refer to CPS-FUNC.INC for code
41 ; Designate start passes the list of designated code pages to load.
42 ; It is sent just prior to the IOCTL WRITE calls containing the 'CPI'
43 ; files. The list of designated code pages is check for duplicates
44 ; and for invalids (-1).
46 ; Refer to CPS-FUNC.INC for code
50 ; Once the data (for a DESIGNATION) has been routed to the CPS driver,
51 ; it is followed by a DESIGNATE STOP command. This confirms the completion
52 ; of the DESIGNATE procedure. If there was an error detected during the
53 ; DESIGNATE procedure, it must be followed by a DESIGNATE STOP.
55 ; Refer to CPS-FUNC.INC for code
58 ; 0C hex - IOCTL OUTPUT
59 ; ---------------------
60 ; Following a DESIGNATE START, the contents of the specified data file
61 ; (expected .CPI format) is copied by DOS to the CPS driver. This is
62 ; via the GENERIC IOCTL WRITE calls. During these calls, the data is
63 ; parsed by the FONT-PARSER (F-PARSER.SRC) to select the CP and fonts
66 ; Refer to CPS-FUNC.INC for code
69 ; (C)Copyright 1988 Microsoft
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75 ; Request Header (Common portion)
77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
79 %
OUT .Compiling
: DISPLAY.ASM
80 %
OUT . ô CPS
-CON driver
82 %
OUT .Include Files
:\a
90 PUBLIC CPD_HDWR_N_MAX
;
91 PUBLIC CPD_DESG_N_MAX
;
95 PUBLIC CPD_FONT_PNTER
;
97 PUBLIC IRPT_CMD_EXIT
;
101 CODE SEGMENT BYTE PUBLIC 'CODE' ;
102 ASSUME
CS:CODE,DS:CODE ;
103 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
104 ;****************************************
106 ;****************************************
107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 START EQU
$ ; begin resident data & code
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
111 ; DEVICE HEADER - must be at offset zero within device driver
112 ; (DHS is defined according to this structure)
114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117 DEV_HDR:DD -1 ; Pointer to next device header
118 DW 0C053H ; Attribute (Char device)
119 DW OFFSET STRATEGY
; Pnter to device "strategy"
120 DW OFFSET INTERRUPT
; Pnter to device "interrupt"
121 DB 'CON ' ; Device name
122 ; and of course a descriptive name
123 ; which can be viewed by a TYPE!
124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126 ; Console Description Table
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
130 STACK_END
DW 1FFH
+60H
DUP(0) ; 200H + 'my' needs (re/ DOS 3.30 ref)
136 BUF1: BUF_DATA
<> ; exclude PAR_EXTRACTO
138 CP_PNTER_TABLE
DW OFFSET CPD_HDWR_N
; TABLE OF POINTERS TO CP INFO
139 DW OFFSET CPD_DESG_N
;
140 DW OFFSET CPD_FONT_PNTER
;
141 DW OFFSET CPD_FONT_WRITE
;
142 DW OFFSET CPD_FONT_DATA
;
144 CPD_TABLE
LABEL WORD ; TABLE DATA INFO FOR CP's
145 CPD_ACTIVE
DW -1 ; TEMPORARY
146 CPD_CLASS
DB '........' ; THIS IS SET TO (EGA, LCD)
149 DW 12 DUP(-1) ; (HDWR_CP's) (MAX=12)
150 CPD_HDWR_N_MAX EQU
($-CPD_HDWR_N
)/2-1 ;
151 CPD_DESG_N
DW -1 ; # OF DESIG CP's
152 DW 12 DUP(-1) ; (DESG CP's) (MAX=12)
153 CPD_DESG_N_MAX EQU
($-CPD_DESG_N
)/2-1 ;
154 CPD_FONT_PNTER
DW 12 DUP(0,0) ; SEG_OFFSET POINTER TO DATA BUFFERS
155 CPD_FONT_WRITE
DW 12 DUP(0,0) ; SEG_OFFSET OF FONTS BEING WRITTEN
156 CPD_FONT_DATA
DW 12 DUP(0) ; COUNT OF FONT DATA TO SKIP/COPY!
157 FONT_PRIORITY
DB 8 DUP(-1) ; USED TO CLASSIFY FONT PRIORITY
158 NUM_FONT_PRIORITY EQU
($-FONT_PRIORITY
) ; DURING A DESIGNATION
159 CPD_TEMP_DESG
DW 0 ; # OF DESIG CP's TEMP BUFFER
160 DW 12 DUP(-1) ; (DESG CP's) (MAX=12)
161 CPD_REQ_DESG
DW 0 ; # OF DESIG CP's REQUESTED
162 DW 12 DUP(-1) ; (DESG CP's) (MAX=12)
165 ANSI_DA_INFO DA_INFO_PACKET
<> ;J.K. Information packet to ANSI used for MODE SET INT10 call.
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
169 ; CON Device "strategy" entry point
170 ; Retain the Request Header address for use by Interrupt routine
172 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 LEA BX, BUF1
; BUF = BUF1 CS:[BX]
178 POP BUF
.RH_PTRO
; OFFSET OF REQUEST HEADER
179 MOV BUF
.RH_PTRS
,ES ; SEGMENT
183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
185 ; Table of command processing routine entry points
187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
188 CMD_TABLE
LABEL WORD ;
189 DW OFFSET INIT
; 0 - Initialization
190 DW OFFSET NO_OPERATION
; 1 - Media check
191 DW OFFSET NO_OPERATION
; 2 - Build BPB
192 DW OFFSET NO_OPERATION
; 3 - IOCTL input
193 DW OFFSET NO_OPERATION
; 4 - Input
194 DW OFFSET NO_OPERATION
; 5 - Non destructive input no wait
195 DW OFFSET NO_OPERATION
; 6 - Input status
196 DW OFFSET NO_OPERATION
; 7 - Input flush
197 DW OFFSET NO_OPERATION
; 8 - Write
198 DW OFFSET NO_OPERATION
; 9 - Output with verify
199 DW OFFSET NO_OPERATION
; A - Output status
200 DW OFFSET NO_OPERATION
; B - Output flush
201 DW OFFSET DESG_WRITE
; C - IOCTL output
202 DW OFFSET NO_OPERATION
; D - Device OPEN
203 DW OFFSET NO_OPERATION
; E - Device CLOSE
204 DW OFFSET NO_OPERATION
; F - Removable media
205 DW OFFSET NO_OPERATION
; 10 - Removable media
206 DW OFFSET NO_OPERATION
; 11 - Removable media
207 DW OFFSET NO_OPERATION
; 12 - Removable media
208 DW OFFSET GENERIC_IOCTL
; 13 - Removable media
209 MAX_CMD EQU
($-CMD_TABLE
)/2 ; highest valid command follows
210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
212 ; CON Device "interrupt" entry point
214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
215 INTERRUPT PROC
FAR ; device interrupt entry point
221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
223 ; Common interrupt entry :
224 ; at entry, BUFn (CS:BX) of CON is defined
226 ; Check if header link has to be set
228 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
230 MOV DI,OFFSET DEV_HDR
; CON Device header
232 MOV BUF
.DEV_HDRO
,DI ;
233 MOV BUF
.DEV_HDRS
,CS ;
234 CLD ; all moves forward
236 CMP BUF
.CON_STRAO
, -1 ;
237 JNE L4
; has been linked to DOS CON
238 CMP BUF
.CON_STRAS
, -1 ;
239 JNE L4
; has been linked to DOS CON
240 ; next device header : ES:[DI]
241 LDS SI,DWORD PTR BUF
.DEV_HDRO
;
242 LES DI,DWORD PTR HP
.DH_NEXTO
;
244 ;$SEARCH WHILE ; pointer to next device header is NOT
249 ;$LEAVE E, AND ; leave if both offset and segment are
265 ;$EXITIF Z ; Exit if name is found in linked hd.
266 JNZ L3
; Name is not found
267 ; Name is found in the linked header
268 MOV AX,NHD
.DH_STRAO
; Get the STRATEGY address
269 MOV BUF
.CON_STRAO
,AX ;
271 X1: MOV BUF
.CON_STRAS
,AX ;
273 MOV AX,NHD
.DH_INTRO
; Get the INTERRUPT address
274 MOV BUF
.CON_INTRO
,AX ;
276 X2: MOV BUF
.CON_INTRS
,AX ;
278 ;$ORELSE ; FInd next header to have the same
281 LES DI,DWORD PTR NHD
.DH_NEXTO
;
285 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
288 ; ES:DI REQUEST HEADER
290 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
291 LES DI,DWORD PTR BUF
.RH_PTRO
; GET RH ADDRESS PASSED TO
292 ; "STRATEGY" INTO ES:DI
293 MOV AL,RH
.RHC_CMD
; COMMAND CODE FROM REQUEST HEADER
294 CBW ; ZERO AH (IF AL > 7FH, NEXT COMPARE
295 ; WILL CATCH THAT ERROR)
296 CMP AL,MAX_CMD
; IF COMMAND CODE IS TOO HIGH
297 JAE L6
; JUMP TO ERROR ROUTINE
299 ADD AX,AX ; DOUBLE COMMAND CODE FOR TABLE OFFSET
300 MOV SI,AX ; PUT INTO INDEX REGISTER FOR JMP
302 CALL CS:CMD_TABLE
[SI] ; CALL ROUTINE TO HANDLE THE COMMAND
303 JC IRPT_CMD_EXIT
; CY=1 IF NO PASS_CONTROL REQ'D
307 L6: CALL PASS_CONTROL
; CALL ROUTINE TO HANDLE THE COMMAND
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
309 ; At entry to command processing routine
311 ; ES:DI = Request Header address
312 ; CS:BX = Buffer for CON
313 ; CS = code segment address
316 ; top of stack is return address, IRPT_CMD_EXIT
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
318 IRPT_CMD_EXIT: ; RETURN FROM COMMAND ROUTINE
319 LES DI,DWORD PTR BUF
.RH_PTRO
; RESTORE ES:DI AS REQUEST HEADER PTR
323 XOR BUF
.STATUS
,AX ; SET STATUS BACK TO OK!
326 IRPT_0: OR AH,STAT_DONE
; ADD "DONE" BIT TO STATUS WORD
327 IRPT_1: MOV RH
.RHC_STA
,AX ; STORE STATUS INTO REQUEST HEADER
328 IRPT_2: POP SI ; RESTORE REGISTERS
335 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
339 ; This calls the attached device to perform any further
340 ; action on the call!
342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347 LES BX,DWORD PTR BUF
.RH_PTRO
; pass the request header to the
348 CALL DWORD PTR CS:[SI].CON_STRAO
; CON strategy routine.
350 CALL DWORD PTR BUF
.CON_INTRO
; interrupt the CON
353 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
356 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
361 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
363 ; PULL IN THE CODE PAGE FUNCTION CODE
365 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
366 INCLUDE INT2FCOM
.INC ;
367 INCLUDE INT10COM
.INC ;
368 INCLUDE CPS
-FUNC
.INC ;
369 INCLUDE WRITE
.INC ; SPECIAL MARKER IN WRITE.INC
370 INCLUDE F
-PARSER
.INC ;
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
373 ; Adjust the assembly-time instruction counter to a paragraph
376 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
377 IF ($-START
) MOD 16 ;
378 ORG ($-START
)+16-(($-START
) MOD 16);
380 EOF_MARKER EQU
$ ; end of resident code
381 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;