]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DEV/DRIVER/DRIVER.ASM
2 ; SCCSID = @(#)driver.asm 4.13 85/10/15
3 ; SCCSID = @(#)driver.asm 4.13 85/10/15
5 ; External block device driver
6 ; Hooks into existing routines in IBMBIO block driver via Int 2F mpx # 8.
7 ; This technique minimizes the size of the driver.
10 ; Revised Try_h: to test for flagheads as msg was being displayed on FormFactor
11 ; this caused the FormFactor to be set in the Head
12 ; Revised the # of sectors/cluster for F0h to 1
13 ;==============================================================================
15 ;AN000 - New for DOS Version 4.00 - J.K.
16 ;AC000 - Changed for DOS Version 4.00 - J.K.
17 ;AN00x - PTM number for DOS Version 4.00 - J.K.
18 ;==============================================================================
19 ;AN001 - d55 Unable the fixed disk accessibility of DRIVER.SYS. 7/7/87 J.K.
20 ;AN002 - p196 Driver.sys does not signal init. failure 8/17/87 J.K.
21 ;AN003 - p267 "No driver letter..." message 8/19/87 J.K.
22 ;AN004 - p268 "Too many parameter..." message 8/20/87 J.K.
23 ;AN005 - p300 "Bad 1.44MB BPB information..." 8/20/87 J.K.
24 ;AN006 - p490 Driver should reject identical parms 8/28/87 J.K.
25 ;AN007 - p921 Parser.ASM problem 9/18/87 J.K.
26 ;AN008 - d493 New init request structure 2/25/88 J.K.
27 ;==============================================================================
29 code segment byte public
30 assume
cs:code,ds:code,es:code
34 include SYSMSG
.INC ;equates and macros
39 ;---------------------------------------------------
44 DW -1,-1 ; link to next device
45 DW 0000100001000000B ; bit 6 indicates DOS 3.20 driver
53 CMDLEN equ
0 ;LENGTH OF THIS COMMAND
54 UNIT equ
1 ;SUB UNIT SPECIFIER
55 CMD equ
2 ;COMMAND CODE
57 MEDIA equ
13 ;MEDIA DESCRIPTOR
58 TRANS equ
14 ;TRANSFER ADDRESS
59 COUNT equ
18 ;COUNT OF BLOCKS OR CHARACTERS
60 START equ
20 ;FIRST BLOCK TO TRANSFER
61 EXTRA equ
22 ;Usually a pointer to Vol Id for error 15
62 CONFIG_ERRMSG equ
23 ;AN009; To set this field to Non-zero
63 ; to display "Error in CONFIG.SYS..."
71 MOV WORD PTR CS:[PTRSAV
],BX
72 MOV WORD PTR CS:[PTRSAV
+2],ES
82 cmp byte ptr es:[bx].cmd
,0
87 ; Because we are passing the call onto the block driver in IBMBIO, we need to
88 ; ensure that the unit number corresponds to the logical (DOS) unit number, as
89 ; opposed to the one that is relevant to this device driver.
90 mov al,byte ptr cs:[DOS_Drive_Letter
]
91 mov byte ptr es:[bx].UNIT
,al
95 ; We need to preserve the flags that are returned by IBMBIO. YUK!!!!!
108 RET ;RESTORE REGS AND RETURN
111 include msbds
.inc ; include BDS structures
112 ;include versiona.inc
114 BDS
DW -1 ;Link to next structure
116 DB 1 ;Int 13 Drive Number
117 DB 3 ;Logical Drive Letter
119 DW 512 ;Physical sector size in bytes
120 DB -1 ;Sectors/allocation unit
121 DW 1 ;Reserved sectors for DOS
122 DB 2 ;No. allocation tables
123 DW 64 ;Number directory entries
124 DW 9*40 ;Number sectors (at 512 bytes ea.)
125 DB 00000000B ;Media descriptor, initially 00H.
126 DW 2 ;Number of FAT sectors
129 DW 0 ;Hidden sector count
130 dw 0 ;AN000; Hidden sector count (High)
131 dw 0 ;AN000; Number sectors (low)
132 dw 0 ;AN000; Number sectors (high)
133 DB 0 ; TRUE => Large fats
134 OPCNT1
DW 0 ;Open Ref. Count
136 FLAGS1
DW 0020H ;Various flags
137 DW 80 ;Number of cylinders in device
138 RecBPB1
DW 512 ; default is that of 3.5" disk
153 TRACK1
DB -1 ;Last track accessed on this drive
154 TIM_LO1
DW -1 ;Keep these two contiguous (?)
156 VOLID1
DB "NO NAME ",0 ;Volume ID for this disk
158 FILE_ID db "FAT12 ",0 ;AN000;
160 DOS_Drive_Letter db ?
; Logical drive associated with this unit
162 ENDCODE
LABEL WORD ; Everything below this is thrown away
163 ; after initialisation.
165 DskDrv dw offset FDRIVE
; "array" of BPBs
167 ;AN000; For system parser;
169 FarSW equ
0 ; Near call expected
171 DateSW equ
0 ; Check date format
173 TimeSW equ
0 ; Check time format
175 FileSW equ
0 ; Check file specification
177 CAPSW equ
0 ; Perform CAPS if specified
179 CmpxSW equ
0 ; Check complex list
181 NumSW equ
1 ; Check numeric value
183 KeySW equ
0 ; Support keywords
185 SwSW equ
1 ; Support switches
187 Val1SW equ
1 ; Support value definition 1
189 Val2SW equ
1 ; Support value definition 2
191 Val3SW equ
0 ; Support value definition 3
193 DrvSW equ
0 ; Support drive only format
195 QusSW equ
0 ; Support quoted string format
196 ;---------------------------------------------------
198 assume
ds:nothing
;AN007;!!!Parse.ASM sometimes assumes DS
199 ; to access its own variable!!!
200 include PARSE
.ASM
;together with PSDATA.INC
201 assume
ds:code ;AN007;
203 ;Control block definitions for PARSER.
204 ;---------------------------------------------------
207 db 0 ;AN000;No extras
209 Parmsx
label byte ;AN000;
210 db 0,0 ;AN000;No positionals
211 db 5 ;AN000;5 switch control definitions
212 dw D_Control
;AN000;/D
213 dw T_Control
;AN000;/T
214 dw HS_Control
;AN000;/H, /S
215 dw CN_Control
;AN000;/C, /N
216 dw F_Control
;AN000;/F
217 db 0 ;AN000;no keywords
219 D_Control
label word ;AN000;
220 dw 8000h
;AN000;numeric value
221 dw 0 ;AN000;no functions
222 dw Result_Val
;AN000;result buffer
223 dw D_Val
;AN000;value defintions
224 db 1 ;AN000;# of switch in the following list
225 Switch_D
label byte ;AN000;
228 D_Val
label byte ;AN000;
229 db 1 ;AN000;# of value defintions
230 db 1 ;AN000;# of ranges
231 db 1 ;AN000;Tag value when match
233 dd 0,127 ;AN001;Do not allow a Fixed disk.
235 Result_Val
label byte ;AN000;
237 Item_Tag
label byte ;AN000;
239 Synonym_ptr
label word ;AN000;
240 dw ?
;AN000;es:offset -> found Synonym
241 RV_Byte
label byte ;AN000;
242 RV_Word
label word ;AN000;
243 RV_Dword
label dword ;AN000;
244 dd ?
;AN000;value if number, or seg:off to string
246 T_Control
label word ;AN000;
247 dw 8000h
;AN000;numeric value
248 dw 0 ;AN000;no functions
249 dw Result_Val
;AN000;result buffer
250 dw T_Val
;AN000;value defintions
251 db 1 ;AN000;# of switch in the following list
252 Switch_T
label byte ;AN000;
255 T_Val
label byte ;AN000;
256 db 1 ;AN000;# of value defintions
257 db 1 ;AN000;# of ranges
258 db 1 ;AN000;Tag value when match
261 HS_Control
label word ;AN000;
262 dw 8000h
;AN000;numeric value
263 dw 0 ;AN000;no function flag
264 dw Result_Val
;AN000;Result_buffer
265 dw HS_VAL
;AN000;value definition
266 db 2 ;AN000;# of switch in following list
267 Switch_H
label byte ;AN000;
269 Switch_S
label byte ;AN000;
272 HS_Val
label byte ;AN000;
273 db 1 ;AN000;# of value defintions
274 db 1 ;AN000;# of ranges
275 db 1 ;AN000;Tag value when match
278 CN_Control
label word ;AN000;
279 dw 0 ;AN000;no match flags
280 dw 0 ;AN000;no function flag
281 dw Result_Val
;AN000;no values returned
282 dw NoVal
;AN000;no value definition
283 ; db 2 ;AN000;# of switch in following list
285 Switch_C
label byte ;AN000;
287 ;Switch_N label byte ;AN000;
292 F_Control
label word ;AN000;
293 dw 8000h
;AN000;numeric value
294 dw 0 ;AN000;no function flag
295 dw Result_Val
;AN000;Result_buffer
296 dw F_VAL
;AN000;value definition
297 db 1 ;AN000;# of switch in following list
298 Switch_F
label byte ;AN000;
301 F_Val
label byte ;AN000;
302 db 2 ;AN000;# of value definitions (Order dependent)
303 db 0 ;AN000;no ranges
304 db 4 ;AN000;# of numeric choices
305 F_Choices
label byte ;AN000;
306 db 1 ;AN000;1st choice (item tag)
308 db 2 ;AN000;2nd choice
310 db 3 ;AN000;3rd choice
312 db 4 ;AN000;4th choice
316 ;AN000;System messages handler data
317 ;AN000;Put the data here
319 MSG_SERVICES
<MSGDATA
>
321 ;AN000;Place the messages here
322 MSG_SERVICES
<DRIVER
.CL1
, DRIVER
.CL2
, DRIVER
.CLA
>
324 ;AN000;Put messages handler code here.
325 MSG_SERVICES
<LOADmsg
,DISPLAYmsg
,CHARmsg
>
329 ; Sets ds:di -> BDS for this drive
338 ; Place for DSK$INIT to exit
341 MOV AH,10000001B ;MARK ERROR RETURN
343 mov byte ptr ds:[bx.MEDIA
], 0 ;AN002; # of units
344 mov word ptr ds:[bx.CONFIG_ERRMSG
], -1 ;AN009;Show IBMBIO error message too.
348 EXIT: MOV AH,00000001B
349 ERR1: LDS BX,CS:[PTRSAV
]
350 MOV WORD PTR [BX].STATUS
,AX ;MARK OPERATION COMPLETE
352 RestoreRegsAndReturn:
371 Drive_Let_Sublist
label dword
372 db 11 ;AN000;length of this table
375 D_Seg dw ?
;AN000;Segment value. Should be CS
376 db 1 ;AN000;DRIVER.SYS has only %1
377 db 00000000b ;AN000;left align(in fact, Don't care), a character.
378 db 1 ;AN000;max field width 1
379 db 1 ;AN000;min field width 1
380 db ' ' ;AN000;character for pad field (Don't care).
395 extrn nodrive
:byte,loadokmsg
:byte,letter
:byte, badvermsg
:byte
401 initmsg db "Initializing device driver",13,10,"$"
402 stratmsg db "In strategy of driver",10,13,"$"
403 dskinmsg db "In DSKIN part of driver",10,13,"$"
404 outinitmsg db "Out of init code ",10,13,"$"
405 exitmsg db "Exiting from driver",10,13,"$"
406 parsemsg db "Parsing switches",10,13,"$"
407 errmsg db "Error occurred",10,13,"$"
408 linemsg db "Parsed line",10,13,"$"
409 int2fokmsg db "****************Int2f loaded**************",10,13,"$"
410 mediamsg db "Media check ok",10,13,"$"
411 getbpbmsg db "getbpb ok",10,13,"$"
412 iookmsg db "Successful I/O",10,13,"$"
413 parseokmsg db "Parsing done fine",10,13,"$"
414 nummsg db "Number read is "
415 number db "00 ",10,13,"$"
416 drvmsg db "Process drive "
417 driven db "0",10,13,"$"
418 cylnmsg db "Process cylinder ",10,13,"$"
419 slimmsg db "Process sec/trk ",10,13,"$"
420 hdmsg db "Process head "
421 hdnum db "0",10,13,"$"
422 ffmsg db "Process form factor "
423 ffnum db "0",10,13,"$"
424 nxtmsg db "Next switch ",10,13,"$"
425 msg48tpi db "Got a 48 tpi drive",10,13,"$"
438 LDS BX,CS:[PTRSAV
] ;GET POINTER TO I/O PACKET
440 MOV AL,BYTE PTR DS:[BX].UNIT
;AL = UNIT CODE
441 MOV AH,BYTE PTR DS:[BX].MEDIA
;AH = MEDIA DESCRIP
442 MOV CX,WORD PTR DS:[BX].COUNT
;CX = COUNT
443 MOV DX,WORD PTR DS:[BX].START
;DX = START SECTOR
445 LES DI,DWORD PTR DS:[BX].TRANS
453 push cs ;AN000; Initialize Segment of Sub list.
455 call SYSLOADMSG
;AN000; linitialize message handler
456 jnc GoodVer
;AN000; Error. Do not install driver.
457 mov cx, 0 ;AN000; No substitution
458 mov dh, -1 ;AN000; Utility message
459 call Show_Message
;AN000; Show message
460 jmp err$exitj2
;AN000; and exit
462 ;; check for correct DOS version
466 ; cmp ax,expected_version
475 ; Mov dx,offset BadVerMsg
477 ; jmp err$exitj2 ; do not install driver
481 int 2fH
; see if installed
483 jnz err$exitj2
; do not install driver if not present
485 mov si,word ptr [bx].count
; get pointer to line to be parsed
486 mov ax,word ptr [bx].count
+2
488 call Skip_Over_Name
; skip over file name of driver
489 mov di,offset BDS
; point to BDS for drive
491 pop es ; es:di -> BDS
495 mov al,byte ptr [bx].extra
; get DOS drive letter
496 mov byte ptr es:[di].DriveLet
,al
497 mov cs:[DOS_Drive_Letter
],al
499 ; mov cs:[letter],al ; set up for printing final message
500 mov cs:[D_Letter
], al ;AN000;
501 call SetDrvParms
; Set up BDS according to switches
503 mov ah,8 ; Int 2f multiplex number
504 mov al,1 ; install the BDS into the list
506 pop ds ; ds:di -> BDS for drive
509 lds bx,dword ptr cs:[ptrsav
]
512 mov byte ptr [bx].media
,ah
513 mov ax,offset ENDCODE
514 mov word ptr [bx].TRANS
,AX ; set address of end of code
515 mov word ptr [bx].TRANS
+2,CS
516 mov word ptr [bx].count
,offset DskDrv
517 mov word ptr [bx].count
+2,cs
522 mov si, offset Drive_Let_SubList
;AC000;
523 mov ax, LOADOK_MSG_NUM
;load ok message
524 mov cx, 1 ;AN000; 1 substitution
525 mov dh, -1 ;AN000; utility message
527 ; mov dx,offset loadokmsg
537 ; Skips over characters at ds:si until it hits a `/` which indicates a switch
538 ; J.K. If it hits 0Ah or 0Dh, then will return with SI points to that character.
544 je End_SkipName
;AN003;
546 je End_SkipName
;AN003;
549 End_SkipName: ;AN003;
550 dec si ; go back one character
560 ; mov dx,offset nxtmsg
567 ; cmp al,13 ; carriage return
569 ; CMP AL,10 ; line feed
571 ; cmp al,0 ; null string
573 ; mov ax,-2 ; mark error invalid-character-in-input
575 ; jmp short exitparse
579 ; mov cs:Switches,BX ; save switches read so far
581 ; cmp ax,-1 ; mark error number-too-large
584 ; mov ax,-2 ; mark invalid parameter
586 ; jmp short exitparse
589 ; test cs:Switches,flagdrive ; see if drive specified
594 ; mov dx,offset nodrive
597 ; mov ax,-3 ; mark error no-drive-specified
599 ; jmp short exitparse
602 ; call SetDrive ; ds:di points to BDS now.
604 ; and ax,fChangeline+fNon_Removable ; get switches for Non_Removable and Changeline
605 ; or ds:[di].flags,ax
606 ; xor ax,ax ; everything is fine
609 ;; Can detect status of parsing by examining value in AX.
611 ;; -1 ==> Number too large
612 ;; -2 ==> Invalid character in input
613 ;; -3 ==> No drive specified
626 ;In) DS:SI -> Input string
628 ; ES:DI -> BDS table inside this program
631 ; if successfule, then { AX will be set according to the switch
632 ; flag value. BDS.Flag, Drivenumb, cylin,
633 ; slim, heads ffactor are set }
636 ; If (no drive specified) then { display messages };
640 ;Subroutine to be called:
641 ; SYSPARSE:NEAR, SHOW_MESSAGE:NEAR, GET_RESULT:NEAR
644 ;{ While (Not end_of_Line)
653 ; if (carry set) then Exit; /* Initialization failed */
654 ; if (No drive number entered) /* Drive number is a requirement */
655 ; then { Show_Message ();
659 assume
ds:nothing
;AN000;make sure
660 push di ;AN000;save BDS pointer
661 mov di, offset PARMS
;AN000;now, es:di -> parse control definition
663 xor cx, cx ;AN004; I don't have positionals.
665 call SYSPARSE
;AN000;
666 cmp ax, $P_RC_EOL
;AN000;end of line?
668 cmp ax, $P_NO_ERROR
;AN000;no error?
669 jne SysP_Fail
;AN000;
670 call Get_Result
;AN000;
671 jmp SysP_While
;AN000;
673 test Switches
, FLAGDRIVE
;AN000;drive number specified?
674 jnz SysP_Ok
;AN000;Drive number is a requirement
676 mov ax, NODRIVE_MSG_NUM
;AN000;no drive specification
677 mov cx, 0 ;AN000;no substitutions
678 mov dh, -1 ;AN000;utility message
679 call Show_Message
;AN000;
681 jmp short SysP_Err
;AN003;
683 mov dh, 2 ;AN000; parse error
685 call Show_Message
;AN000; Show parse error
688 jmp short PL_Ret
;AN000;
692 pop di ;AN000;restore BDS pointer
698 ;In) A successful result of SYSPARSE in Result_Val
699 ; es = cs, ds = command line segment
701 ; Switches set according to the user option.
702 ; Drivenumb, Cyln, Heads, Slim, ffactor set if specified.
704 ; Switch (Synonym_Ptr)
705 ; { case Switch_D: Switches = Switches | FLAGDRIVE; /* Set switches */
706 ; Drivenumb = Reg_DX.Value_L;
709 ; case Switch_T: Switches = Switches | Flagcyln;
710 ; Cyln = Reg_DX.Value_L;
713 ; case Switch_H: Switches = Switches | Flagheads;
714 ; Heads = Reg_DX.Value_L;
717 ; case Switch_S: Switches = Switches | FlagSecLim;
718 ; Slim = Reg_DX.Value_L;
721 ; case Switch_C: Switches = Switches | fChangeline;
724 ;; case Switch_N: Switches = Switches | fNon_Removable;
727 ; case Switch_F: Switches = Switches | Flagff;
728 ; Reg_DX = (Reg_DX.ITEM_Tag - 1)*5;/*Get the offset of
730 ; ffactor = byte ptr (F_Choices + DX + 1);
731 ; /*Get the value of it */
738 mov ax, Synonym_Ptr
;AN000;
739 push ax ;AN006; save Synonym_ptr
740 cmp ax, offset Switch_D
;AN000;
742 or Switches
, FLAGDRIVE
;AN000;
743 mov al, RV_Byte
;AN000;
744 mov Drivenumb
, al ;AN000;
747 cmp ax, offset Switch_T
;AN000;
749 or Switches
, FLAGCYLN
;AN000;
750 mov ax, RV_Word
;AN000;
754 cmp ax, offset Switch_H
;AN000;
756 or Switches
, FLAGHEADS
;AN000;
757 mov ax, RV_Word
;AN000;
758 mov Heads
, ax ;AN000;
761 cmp ax, offset Switch_S
;AN000;
763 or Switches
, FLAGSECLIM
;AN000;
764 mov ax, RV_Word
;AN000;
768 cmp ax, offset Switch_C
;AN000;
771 or Switches
, fCHANGELINE
;AN000;
774 ; cmp ax, offset Switch_N ;AN000;
776 ; or Switches, fNON_REMOVABLE ;AN000;
779 cmp ax, offset Switch_F
;AN000;
780 jne GR_Not_Found_Ret
;AN000;error in SYSPARSE
781 or Switches
, FLAGFF
;AN000;
783 mov si, offset F_Choices
;AN000;
785 mov al, Item_Tag
;AN000;
790 mov al, byte ptr es:[si+1] ;AN000;get the result of choices
791 mov ffactor
, al ;AN000;set form factor
794 pop ax ;AN006; Restore Synonym ptr
795 push di ;AN006; Save di
798 mov byte ptr es:[di], ' ' ;AN006;We don't have this switch any more.
800 jmp short Gr_Done_Ret
;AN006;
802 pop ax ;AN006;adjust stack
809 ; Scans an input line for blank or tab characters. On return, the line pointer
810 ; will be pointing to the next non-blank character.
816 cmp al,9 ; Tab character
822 ; Gets a number from the input stream, reading it as a string of characters.
823 ; It returns the number in AX. It assumes the end of the number in the input
824 ; stream when the first non-numeric character is read. It is considered an error
825 ; if the number is too large to be held in a 16 bit register. In this case, AX
826 ; contains -1 on return.
837 ; cmp al,'0' ; check for valid numeric input
842 ; xchg ax,bx ; save intermediate value
849 ; xchg ax,bx ; stash total
859 ; dec si ; put last character back into buffer
868 ; Processes a switch in the input. It ensures that the switch is valid, and
869 ; gets the number, if any required, following the switch. The switch and the
870 ; number *must* be separated by a colon. Carry is set if there is any kind of
875 ; and al,0DFH ; convert it to upper case
880 ; mov cl,cs:switchlist ; get number of valid switches
884 ; pop es ; set es:di -> switches
886 ; mov di,1+offset switchlist ; point to string of valid switches
892 ; shl ax,cl ; set bit to indicate switch
894 ; or bx,ax ; save this with other switches
896 ; test ax,7cH ; test against switches that require number to follow
903 ; cmp ax,-1 ; was number too large?
911 ; mov dx,offset nummsg
921 ; xor bx,cx ; remove this switch from the records
924 ; jmp short done_swtch
927 ; This routine takes the switch just input, and the number following (if any),
928 ; and sets the value in the appropriate variable. If the number input is zero
929 ; then it does nothing - it assumes the default value that is present in the
930 ; variable at the beginning.
936 ; test Switches,cx ; if this switch has been done before,
937 ; jnz done_ret ; ignore this one.
944 ; mov dx,offset drvmsg
956 ; mov dx,offset ffmsg
962 ; jz done_ret ; if number entered was 0, assume default value
967 ; mov dx,offset cylnmsg
977 ; mov dx,offset slimmsg
982 ;; Switch must be one for number of Heads.
990 ; mov dx,offset hdmsg
999 ; SetDrvParms sets up the recommended BPB in each BDS in the system based on
1000 ; the form factor. It is assumed that the BPBs for the various form factors
1001 ; are present in the BPBTable. For hard files, the Recommended BPB is the same
1002 ; as the BPB on the drive.
1003 ; No attempt is made to preserve registers since we are going to jump to
1004 ; SYSINIT straight after this routine.
1010 call SetDrive
; ds:di -> BDS
1011 ;test cs:switches,flagff ; has formfactor been specified?
1014 mov byte ptr [di].formfactor
,bl ; replace with new value
1016 mov bl,[di].FormFactor
1017 ;AC000; The followings are redundanat since there is no input specified for Hard file.
1020 ; mov ax,[di].DrvLim
1021 ; cmp ax, 0 ;AN000;32 bit sector number?
1023 ; mov ax,word ptr [di].hdlim
1024 ; mul word ptr [di].seclim
1025 ; mov cx,ax ; cx has # sectors per cylinder
1027 ; xor dx,dx ; set up for div
1028 ; div cx ; div #sec by sec/cyl to get # cyl
1030 ; jz No_Cyl_Rnd ; came out even
1035 ; add si,BytePerSec ; ds:si -> BPB for hard file
1036 ; jmp short Set_RecBPB
1038 ;AC000; End of deletion.
1042 mov dx,offset msg48tpi
1048 shl bx,1 ; bx is word index into table of BPBs
1049 mov si,offset BPBTable
1050 mov si,word ptr [si+bx] ; get address of BPB
1052 add di,RBytePerSec
; es:di -> Recommended BPB
1055 repe movsb ; move BPBSIZ bytes
1057 call Handle_Switches
; replace with 'new' values as
1058 ; specified in switches.
1060 ; We need to set the media byte and the total number of sectors to reflect the
1061 ; number of heads. We do this by multiplying the number of heads by the number
1062 ; of 'sectors per head'. This is not a fool-proof scheme!!
1064 mov ax,[di].Rdrvlim
; this is OK for two heads
1065 sar ax,1 ; ax contains # of sectors/head
1067 dec cl ; get it 0-based
1069 jc Set_All_Done_BRG
; We have too many sectors - overflow!!
1072 ; We use media descriptor byte F0H for any type of medium that is not currently
1073 ; defined i.e. one that does not fall into the categories defined by media
1074 ; bytes F8H, F9H, FCH-FFH.
1077 MOV AL, 1 ;1 sector/cluster
1078 MOV BL, BYTE PTR [DI].Rmediad
1079 CMP BYTE PTR [DI].FormFactor
, ffOther
1080 JE GOT_CORRECT_MEDIAD
1081 MOV CH, BYTE PTR [DI].FormFactor
1085 JMP GOT_CORRECT_MEDIAD
1086 Set_All_Done_BRG:jmp Set_All_Done
1088 CMP WORD PTR [DI].RSecLim
, 8 ;8 SEC/TRACK?
1091 JMP GOT_CORRECT_MEDIAD
1094 JMP GOT_CORRECT_MEDIAD
1096 MOV BL, 0F0h ;default 0F0h
1097 MOV AL, 1 ;1 sec/cluster
1098 CMP BYTE PTR [DI].FormFactor
, ffOther
1099 JE GOT_CORRECT_MEDIAD
1100 CMP BYTE PTR [DI].FormFactor
, ff48tpi
1103 CMP WORD PTR [DI].RSecLim
, 8 ;8 SEC/TRACK?
1106 JMP GOT_CORRECT_MEDIAD
1109 JMP GOT_CORRECT_MEDIAD
1111 CMP BYTE PTR [DI].FormFactor
, ff96tpi
1113 MOV AL, 1 ;1 sec/cluster
1115 JMP GOT_CORRECT_MEDIAD
1117 CMP BYTE PTR [DI].FormFactor
, ffSmall
;3-1/2, 720kb
1118 JNE GOT_CORRECT_MEDIAD
;Not ffSmall. Strange Media device.
1119 MOV AL, 2 ;2 sec/cluster
1122 ;J.K. 12/9/86 THE ABOVE IS A QUICK FIX FOR 3.3 DRIVER.SYS PROB. OLD LOGIC IS COMMENTED OUT.
1123 ; mov bl,0F0H ; assume strange media
1124 ; mov al,1 ; AL is sectors/cluster - match 3.3 bio dcl. 6/27/86
1125 ; ja Got_Correct_Mediad
1126 ;; We check to see if the form factor specified was "other"
1127 ; cmp byte ptr [di].FormFactor,ffOther
1128 ; jz Got_Correct_Mediad
1129 ;; We must have 1 or 2 heads (0 is ignored)
1130 ; mov bl,byte ptr [di].Rmediad
1132 ; jz Got_Correct_Mediad
1133 ;; We must have one head - OK for 48tpi media
1134 ; mov al,1 ; AL is sectors/cluster
1135 ; mov ch,byte ptr [di].FormFactor
1139 ; jmp short Got_Correct_Mediad
1141 ; dec bl ; adjust for one head
1142 ;J.K. END OF OLD LOGIC
1145 mov byte ptr [di].RSecPerClus
,al
1146 mov byte ptr [di].Rmediad
,bl
1147 ; Calculate the correct number of Total Sectors on medium
1148 mov ax,word ptr [di].Ccyln
1149 mov bx,word ptr [di].RHdLim
1151 mov bx,word ptr [di].RSecLim
1153 ; AX contains the total number of sectors on the disk
1154 mov word ptr [di].RDrvLim
,ax
1155 ;J.K. For ffOther type of media, we should set Sec/FAT, and # of Root directory
1157 cmp byte ptr [di].FormFactor
, ffOther
;AN005;
1158 jne Set_All_Ok
;AN005;
1160 dec ax ;AN005; DrvLim - 1.
1161 mov bx, 3 ;AN005; Assume 12 bit fat.
1162 mul bx ;AN005; = 1.5 byte
1169 mov [di].RCSecFat
, ax ;AN005;
1170 mov [di].RCDir
, 0E0h ;AN005; directory entry # = 224
1177 ; Handle_Switches replaces the values that were entered on the command line in
1178 ; config.sys into the recommended BPB area in the BDS.
1180 ; No checking is done for a valid BPB here.
1183 call setdrive
; ds:di -> BDS
1184 test cs:switches
,flagdrive
1185 jz done_handle
; if drive not specified, exit
1186 mov al,cs:[drivenumb
]
1187 mov byte ptr [di].DriveNum
,al
1188 ; test cs:switches,flagcyln
1191 mov word ptr [di].cCyln
,ax
1193 test cs:switches
,flagseclim
1196 mov word ptr [di].RSeclim
,ax
1198 test cs:switches
,flagheads
1201 mov word ptr [di].RHdlim
,ax
1206 Show_Message proc
near
1207 ;In) AX = message number
1208 ; DS:SI -> Substitution list if necessary.
1209 ; CX = 0 or n depending on the substitution number
1210 ; DH = -1 FOR UTILITY MSG CLASS, 2 FOR PARSE ERROR
1211 ;Out) Message displayed using DOS function 9 with no keyboard input.
1215 mov dl, 0 ;AN000;no input
1216 call SYSDISPMSG
;AN000;
1221 ; The following are the recommended BPBs for the media that we know of so
1254 ; 3 1/2 inch diskette BPB
1258 DW 1 ; Double sided with 9 sec/trk
1269 BPBTable dw BPB48T
; 48tpi drives
1270 dw BPB96T
; 96tpi drives
1271 dw BPB35
; 3.5" drives
1272 ; The following are not supported, so we default to 3.5" layout
1273 dw BPB35
; Not used - 8" drives
1274 dw BPB35
; Not Used - 8" drives
1275 dw BPB35
; Not Used - hard files
1276 dw BPB35
; Not Used - tape drives
1277 dw BPB35
; Not Used - Other
1279 switchlist db 7,"FHSTDCN" ; Preserve the positions of N and C.
1281 ; The following depend on the positions of the various letters in SwitchList
1285 flagseclim equ
0010H
1290 ;Equates for message number
1291 NODRIVE_MSG_NUM equ
2
1292 LOADOK_MSG_NUM equ
3