-
Notifications
You must be signed in to change notification settings - Fork 7
/
chkinit.asm
executable file
·1548 lines (1526 loc) · 64.8 KB
/
chkinit.asm
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
page ,132 ;
;*****************************************************************************
;*****************************************************************************
;UTILITY NAME: CHKOVER.COM
;
;MODULE NAME: CHKINIT.SAL
;
;ÚÄÄÄÄÄÄÄÄÄÄ#
;³ Main_Init ³
;ÀÄÂÄÄÄÄÄÄÄÄÄÙ
; ³
; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ# ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ôInit_Input_OutputÃÄÄÄÄ´Preload_Messages³
; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ³ ôParse_Drive_Letter ³
; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ³ ôParse_Command_Line ³
;; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ³ À´Interpret_Parse³
; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ# ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ôValidate_Target_DriveôCheck_Target_Drive³
; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ³ ôCheck_For_Network³
; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ³ À´Check_Translate_Drive³
; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ôHook_Interrupts³
; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ôClear_Append_X³
; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ÚÄÄÄÄÄÄÄÄÄ# ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; ôCHKDSK_IFSôEXEC_FS_CHKDSK³
; ³ÀÄÄÄÄÄÄÄÄÄÄÙ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄ#
; ³ À´Main_Routine³
; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ#
; À´Reset_Append_X³
; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
;*****************************************************************************
;;an099;dcl for p3202
;*****************************************************************************
;
;*****************************************************************************
; Include files
;*****************************************************************************
.xlist ;an000;bgb
include chkseg.inc ;an005;bgb ;an000;bgb
include pathmac.inc ;an000;bgb
INCLUDE CHKEQU.INC ; ;an000;bgb;AN000;
INCLUDE CHKCHNG.INC ;List of changes ;an000;bgb
include dossym.inc ;an000;bgb
INCLUDE SYSCALL.INC ; ;an000;bgb;AN000;
INCLUDE CHKMACRO.INC ; ;an000;bgb;AN000;
INCLUDE CHKPARSE.INC ; ;an000;bgb;AN000;
INCLUDE IOCTL.INC ;an000;bgb
.list ;an000;bgb
;an000;bgb
;an000;bgb
;an000;bgb
psp segment public para 'DUMMY' ;an000;bgb
org 05Ch ;an000;bgb
FCB1 label byte ;an000;bgb
org 06Ch ;an000;bgb
FCB2 label byte ;an000;bgb
psp ends ;an000;bgb
;an000;bgb
; ;an000;bgb
DATA segment public para 'DATA' ;an000;bgb
;***************************************************************************** ;an000;bgb
; Data Area ;an000;bgb
;***************************************************************************** ;an000;bgb
old_drive db 0 ;an000;bgb
include version.inc
IF IBMCOPYRIGHT
ELSE
myramdisk db 'RDV 1.20'
ENDIF
myvdisk db 'VDISK' ;an000;bgb
bytes_per_sector dw 0 ;an005;bgb ;an000;bgb
BPB_Buffer A_DeviceParameters <> ; ;an000;bgb;AN000;
;an000;bgb
Data_Start_Low dw ? ; ;an000;bgb;AN000;
Data_Start_High dw ? ; ;an000;bgb
;an000;bgb
public command_line_buffer ;an046;bgb
Command_Line_Buffer db 128 dup(0) ; ;an000;bgb;AN000;
Command_Line_Length equ $ - Command_Line_Buffer ; ;an000;bgb;AN000;
;an046;bgb
Fatal_Error db 0 ; ;an000;bgb;AN000;
;an000;bgb
Command_Line db NO ; ;an000;bgb
Append db 0 ; ;an000;bgb
;an000;bgb
ifdef fsexec ;an038;bgb
;These should stay together ; ;an038;bgb
; --------------------------------------- ; ; ;an038;bgb
FS_String_Buffer db 13 dup(" ") ; ;an038;bgb
FS_String_End db "CHK.EXE",0 ; ;an038;bgb
Len_FS_String_End equ $ - FS_String_End ; ;an038;bgb
;---------------------------------------- ; ;an038;bgb
FS_Not_Fat db 0 ; ;an038;bgb
FAT12_String db "FAT12 " ; ;an038;bgb
FAT16_String db "FAT16 " ; ;an038;bgb
Len_FS_ID_String equ $ - FAT16_String ; ;an038;bgb
Media_ID_Buffer Media_ID <> ; ;an038;bgb
endif ;an038;bgb
ExitStatus db 0 ; ;an000;bgb;AN000;
;an000;bgb
PSP_Segment dw 0 ; ;an000;bgb;AN000;
tot_bytes_lo dw 0 ; low word of number of sectors in disk ;an000;bgb;an006;bgb
tot_bytes_hi dw 0 ;high word of number of sectors in disk ;an000;bgb;an006;bgb
fat_dir_secs dw 0 ;sectors in fat, directory and resvd ;an000;bgb;an006;bgb
;an000;bgb
;***************************************************************************** ;an000;bgb
; Public Data Declarations ;an000;bgb
;***************************************************************************** ;an000;bgb
public bpb_buffer ;an000;bgb;an006;bgb
public tot_bytes_lo ;an000;bgb;an006;bgb
public tot_bytes_hi ;an000;bgb;an006;bgb
public fat_dir_secs ;an000;bgb;an006;bgb
public bytes_per_sector ;an000;bgb;an005;bgb
Public Data_Start_Low ;an000;bgb
Public Data_Start_High ;an000;bgb
Public Fatal_Error ;an000;bgb
Public ExitStatus ;an000;bgb
Public PSP_Segment ;an000;bgb
ifdef fsexec ;an038;bgb
Public FS_String_Buffer ;an038;bgb
endif ;an038;bgb
; ;an000;bgb
;***************************************************************************** ;an000;bgb
; External Data Declarations ;an000;bgb
;***************************************************************************** ;an000;bgb
EXTRN movsi:word ;move si pointer here for display of invalid parm ;an046;bgb;an000;bgb;an005;bgb
EXTRN fatcnt:Byte ;an000;bgb;an005;bgb
EXTRN AllDrv:Byte ;an000;bgb
EXTRN VolNam:Byte ;an000;bgb
EXTRN BadDrvM:Byte ;an000;bgb
EXTRN OrphFCB:Byte ;an000;bgb
EXTRN Arg_Buf:Byte ;an000;bgb
EXTRN Noisy:Byte ;an000;bgb
EXTRN DoFix:Byte ;an000;bgb
EXTRN SubstErr:Byte ;an000;bgb
EXTRN No_Net_Arg:Byte ;an000;bgb
EXTRN UserDev:Byte ;an000;bgb
EXTRN BadDrv_Arg:Byte ;an000;bgb
EXTRN TranSrc:Byte ;an000;bgb
EXTRN ContCh:Word ;an000;bgb
EXTRN HardCh:Word ;an000;bgb
EXTRN Fragment:Byte ;an000;bgb
EXTRN Parse_Error_Msg:Byte ;an000;bgb
EXTRN Chkprmt_End:Byte ;an000;bgb
extrn save_drive:byte ;an000;bgb
EXTRN Read_Write_Relative:Byte ;an000;bgb
EXTRN inval_media:byte ;an000;bgb;an033;bgb
data ends ;an000;bgb
;an000;bgb
;an000;bgb
code segment public para 'CODE' ;an000;bgb
;***************************************************************************** ;an000;bgb
; External Routine Declarations ;an000;bgb
;***************************************************************************** ;an000;bgb
ifdef fsexec ;an038;bgb
EXTRN Exec_FS_CHKDSK:Near ;an000;bgb
endif
EXTRN SysLoadMsg:Near ;an000;bgb
EXTRN SysDispMsg:Near ;an000;bgb
EXTRN Done:Near ;an000;bgb
EXTRN Main_Routine:Near ;an000;bgb
EXTRN INT_23:Near ;an000;bgb
EXTRN INT_24:Near ;an000;bgb
EXTRN Path_Name:Near ;an000;bgb
extrn read_once:near ;an000;bgb
public p97, multiply_32_bits ;an000;bgb
public func60 ;an000;bgb
public hook_interrupts ;an000;bgb
public get_bpb ;an000;bgb
pathlabl chkinit ;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Main_Init ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Main control routine for init section ;an000;bgb
; ;an000;bgb
;Called Procedures: Check_DOS_Version ;an000;bgb
; Init_Input_Output ;an000;bgb
; Validate_Target_Drive ;an000;bgb
; Hook_Interrupts ;an000;bgb
; Clear_Append_X ;an000;bgb
; CHKDSK_IFS ;an000;bgb
; Reset_Append_X ;an000;bgb
; ;an000;bgb
;Input: None ;an000;bgb
; ;an000;bgb
;Output: None ;an000;bgb
; ;an000;bgb
;Change History: Created 5/8/87 MT ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; Set segregs to DATA ;an000;bgb
; Get segment of PSP ;an000;bgb
; Fatal_Error = NO ;an000;bgb
; Flush all buffers (INT 21h AH=0Dh) ;an000;bgb
; Parse input and load messages (CALL Init_Input_Output) ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; Check target drive letter (CALL Validate_Target_Drive) ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; Set up Control Break (CALL Hook_Interrupts) ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; CALL Clear_Append_X ;an000;bgb
; CALL CHKDSK_IFS ;an000;bgb
; CALL Reset_Append_X ;an000;bgb
; ENDIF ;an000;bgb
; ENDIF ;an000;bgb
; ENDIF ;an000;bgb
; Exit program ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Main_Init ; ;an000;bgb;AN000;
Set_Data_Segment ;Setup addressibility ;an000;bgb;AN000;
call get_psp ;an000;bgb
;;;;;;;;DOS_Call GetCurrentPSP ;Get PSP segment address ;an000;bgb;ac034;bgb
;;;;;;;;mov PSP_Segment,bx ;Save it for later ;an000;bgb;ac034;bgb
mov Fatal_Error,No ;Init the error flag ;an000;bgb;AN000;
Dos_Call Disk_Reset ;Flush all buffers ;an000;bgb
call Init_IO ;Setup messages and parse ;an000;bgb;AN000;
cmp Fatal_Error,Yes ;Error occur? ;an000;bgb;AN000;
; $IF NE ;Nope, keep going ;an000;bgb;AN000;
JE $$IF1
call Validate_Target_Drive ;Check drive letter ;an000;bgb;AN000;
cmp Fatal_Error,Yes ;Error occur? ;an000;bgb;AN000;
; $IF NE ;Nope, keep going ;an000;bgb;AN000;
JE $$IF2
;;;;;;;;;;;;;;call Hook_Interrupts ;Set CNTRL -Break hook ;an000;bgb;AN000;
call Clear_Append_X ; ;an000;bgb;AN000;
call CHKDSK_IFS ;Chkdsk correct file system ;an000;bgb;AN000;
call Reset_Append_X ; ;an000;bgb;AN000;
; $ENDIF ; ;an000;bgb;AN000;
$$IF2:
; $ENDIF ; ;an000;bgb;AN000;
$$IF1:
mov al,ExitStatus ;Get Errorlevel ;an000;bgb;AN000;
DOS_Call Exit ;Exit program ;an000;bgb;AN000;
int 20h ;If other exit fails ;an000;bgb;AN000;
Main_Init endp ; ;an000;bgb;AN000;
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: get_psp ;an000;bgb
;***************************************************************************** ;an000;bgb
;Description: get info from the psp area ;an000;bgb
; ;an000;bgb
;Called Procedures: get_drive ;an000;bgb
; ;an000;bgb
;Change History: Created 8/7/87 bgb ;an000;bgb
; ;an000;bgb
;Input: none ;an000;bgb
; ;an000;bgb
;Output: psp_segment ;an000;bgb
; command_line_buffer ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; get addr of psp ;an000;bgb
; move command line into data seg ;an000;bgb
; get drive number of target ;an000;bgb
; get addr of data seg ;an000;bgb
; call get_drive ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
Procedure get_psp ;;AN000; ;an000;bgb
;;;;;;;;DOS_Call GetCurrentPSP ;Get PSP segment address :AN035;b;an000;bgbgb
;;;;;;;;mov PSP_Segment,bx ;Save it for later ;AN035;b;an000;bgbgb
; get command line from psp ;an000;bgb;AN000;bgb
mov cx,PSP_Segment ;point ds to data seg ;an000;bgb;AN000;bgb
mov ds,cx ; " " " " " ;an000;bgb;AN000;bgb
assume ds:NOTHING,es:dg ; " " " " " ;an000;bgb;AN000;bgb
; get the drive number of the target from the psp (0=default, a=1, b=2, c=3) ;AN;an000;bgb000;bgb
mov bl,ds:[FCB1] ;Get target drive from FCB -74 ;AN0;an000;bgb00;
Set_Data_Segment ;Set DS,ES to Data segment ;AN0;an000;bgb00;bgb
call get_drive ;an000;bgb
ret ;an000;bgb
get_psp endp ; ;AN000; ;an000;bgb
;an000;bgb
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: get_drive ;an000;bgb
;***************************************************************************** ;an000;bgb
;Description: get drive letter from reg bl ;an000;bgb
; ;an000;bgb
;Change History: Created 8/7/87 bgb ;an000;bgb
; ;an000;bgb
;Input: bl = drive num (default=0) ;an000;bgb
; ;an000;bgb
;Output: driveletter ;an000;bgb
; user_drive ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; IF drive-num = default ;an000;bgb
; get default drive number (a=1) ;an000;bgb
; convert to letter ;an000;bgb
; ELSE ;an000;bgb
; convert to letter ;an000;bgb
; ENDIF ;an000;bgb
; move letter into data areas ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
Procedure get_drive ;;AN000; ;an000;bgb
; convert drive number to drive letter ;an000;bgb
cmp bl,0 ;a=1 b=2 c=3 ;Is it default drive? 0=default ;AN000; ;an000;bgb
; $IF E ;Yes, turn it into drive letter ;AN000; ;an000;bgb
JNE $$IF5
; get default drive number ;an000;bgb
DOS_Call Get_Default_Drive ;Get default drive num in al ;AN00;an000;bgb0;
;a=0, b=1, c=2 ;an000;bgb
; $ELSE ;Not default, A=1 ;AN000; ;an000;bgb
JMP SHORT $$EN5
$$IF5:
; bl already contains the correct drive number - save it ;an000;bgb
dec bl ;make it zero based ;an000;bgb
mov al,bl ;an000;bgb
; $ENDIF ; 74+40=b4 ;an000;bgb
$$EN5:
mov BadDrvm+1,al ; " " " " ;an000;bgb ;AN000;
inc al ;an000;bgb
mov byte ptr Buffer.drnum_stroff,al ; ;an000;bgb ;
mov AllDrv,al ; ;an000;bgb ;AC000;
mov VolNam,al ; ;an000;bgb ;AC000;
mov OrphFCB,al ; ;an000;bgb ;AC000;
dec al ;an000;bgb
add al,"A" ;convert it to letter ;AN000; ;an000;bgb
mov arg_buf,al ;set up prompt msg ;AN0;an000;bgb00;bgb
ret ;an000;bgb
get_drive endp ; ;AN000; ;an000;bgb
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Init_Input_Output ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;description: Initialize messages, Parse command line if FAT file system ;an000;bgb
; ;an000;bgb
;Called Procedures: Preload_Messages ;an000;bgb
; Parse_Command_Line ;an000;bgb
; ;an000;bgb
;Change History: Created 5/10/87 MT ;an000;bgb
; ;an000;bgb
;Input: PSP command line at 81h and length at 80h ;an000;bgb
; ;an000;bgb
;Output: FS_Not_FAT = YES/NO ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; FS_Not_FAT = NO ;an000;bgb
; Load messages (CALL Preload_Messages) ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; Get file system type (INT 21h AX=440Dh, CX=084Eh GET MEDIA_ID) ;an000;bgb
; IF CY (Old type diskette),OR ;an000;bgb
; IF "FAT_12 ",OR ;an000;bgb
; IF "FAT_16 " ;an000;bgb
; CALL Parse_Command_Line ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; Interpret_Parse ;an000;bgb
; ENDIF ;an000;bgb
; ELSE ;an000;bgb
; Get drive letter only (CALL Parse_Drive_Letter) ;an000;bgb
; FS_Not_FAT = YES ;an000;bgb
; ENDIF ;an000;bgb
; ENDIF ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Init_IO ; ;AN000; ;an000;bgb
;an000;bgb
call Preload_Messages ;Load up message retriever ;an000;bgb;AN000;
ifdef fsexec ;an038;bgb
mov FS_Not_FAT,No ;an038;bgb
cmp Fatal_Error,YES ;Quit? ;an038;bgb;AN000;
; $IF NE ;Nope, keep going ;an038;bgb;AN000;
JE $$IF8
mov al,GENERIC_IOCTL ;Generic IOCtl call ;an038;bgb;AN000;
push ds ; ;an038;bgb;AN000;
mov bx,PSP_Segment ; ;an038;bgb;AN000;
mov ds,bx ; ;an038;bgb;AN000;
assume ds:nothing ; ;an038;bgb;AN000;
;an038;bgb
mov bl,ds:FCB1 ;Get drive (A=1) ;an038;bgb;AN000;
;an038;bgb
pop ds ; ;an038;bgb;AN000;
assume ds:dg ; ;an038;bgb;AN000;
xor bh,bh ;Set bh=0 ;an038;bgb;AN000;
mov ch,RawIO ;Get Media ID call ;an038;bgb;AN000;
mov cl,GET_MEDIA_ID ; ;an038;bgb;AN000;
lea dx,Media_ID_Buffer ;Point at buffer ;an038;bgb;AN000;
DOS_Call IOCtl ;Do function call ;an038;bgb;AN000;
; $IF C,OR ;Old style diskette, OR ;an038;bgb;AN000;
JC $$LL9
lea si,FAT12_String ;Check for FAT_12 string ;an038;bgb;AN000;
lea di,Media_ID_Buffer.Media_ID_File_System ; ;AN000;;an038;bgb
mov cx,Len_FS_ID_String ;Length of compare ;an038;bgb;AN000;
repe cmpsb ;Find it? ;an038;bgb;AN000;
; $IF E,OR ;Nope, keep going ;an038;bgb;AN000;
JE $$LL9
lea si,FAT16_String ;Check for FAT_16 string ;an038;bgb;AN000;
lea di,Media_ID_Buffer.Media_ID_File_System ; ;AN000;;an038;bgb
mov cx,Len_FS_ID_String ;Length of compare ;an038;bgb;AN000;
repe cmpsb ;Do compare ;an038;bgb;AN000;
; $IF E ;Find it? ;an038;bgb;AN000;
JNE $$IF9
$$LL9:
endif ;an038;bgb
call Parse_Command_Line ;Parse in command line input ;an038;bgb;AN000;
ifdef fsexec ;an038;bgb
; $ELSE ;We got FS other than FAT ;an038;bgb;AN000;
JMP SHORT $$EN9
$$IF9:
;;;;;;;;;;;;;;call Parse_Drive_Letter ;Only look for drive letter ;an038;bgb;AN000;
mov FS_Not_FAT,Yes ;Indicate exec file system ;an038;bgb;AN000;
mov cx,8 ;an038;bgb;an027;bgb
lea si,Media_ID_Buffer.Media_ID_File_System ;get file system;an038;bgb ;an027;bgb
lea di,fs_string_buffer ;put it here ;an038;bgb;an027;bgb
rep movsb ;an038;bgb;an027;bgb
lea di,fs_string_buffer ;point to beginning again ;an038;bgb;an027;bgb
; $DO COMPLEX ;search th string until eol found ;an038;bgb;an027;bgb
JMP SHORT $$SD11
$$DO11:
inc di ;next char ;an038;bgb;an027;bgb
; $STRTDO ;start loop here ;an038;bgb;an027;bgb
$$SD11:
cmp byte ptr [di],' ' ;end of string ? ;an038;bgb;an027;bgb
; $ENDDO E ;end loop when eol found ;an038;bgb;an027;bgb
JNE $$DO11
lea si,fs_string_end ;get end of string - rec.exe ;an038;bgb;an027;bgb
mov cx,8 ; 8 more chars ;an038;bgb;an027;bgb
rep movsb ;move it in ;an038;bgb;an027;bgb
; $ENDIF ; ;an038;bgb;AN000;
$$EN9:
; $ENDIF ; ;an038;bgb;AN000;
$$IF8:
endif ;an038;bgb
ret ; ;an000;bgb;AN000;
;an000;bgb
Init_IO endp ; ;AN000; ;an000;bgb
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Preload_Messages ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Preload messages using common message retriever routines. ;an000;bgb
; ;an000;bgb
;Called Procedures: SysLoadMsg ;an000;bgb
; ;an000;bgb
; ;an000;bgb
;Change History: Created 5/1/87 MT ;an000;bgb
; ;an000;bgb
;Input: Fatal_Error = NO ;an000;bgb
; ;an000;bgb
;Output: Fatal_Error = YES/NO ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; Preload All messages (Call SysLoadMsg) ;an000;bgb
; IF error ;an000;bgb
; Display SysLoadMsg error message ;an000;bgb
; Fatal_Error = YES ;an000;bgb
; ENDIF ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Preload_Messages ; ;an000;bgb;AN000;
; ;an000;bgb
call SysLoadMsg ;Preload the messages ;an000;bgb;AN000;
; $IF C ;Error? ;an000;bgb;AN000;
JNC $$IF16
call SysDispMsg ;Display preload msg ;an000;bgb;AN000;
mov Fatal_Error, YES ;Indicate error exit ;an000;bgb;AN000;
; $ENDIF ; ;an000;bgb;AN000;
$$IF16:
ret ; ;an000;bgb;AN000;
;an000;bgb
Preload_Messages endp ; ;an000;bgb;AN000;
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Parse_Drive_Letter ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Copy the command line - then parse looking only for drive ;an000;bgb
; letter. Ignore errors, because this is only called to get ;an000;bgb
; the drive letter for non-FAT chkdsk ;an000;bgb
; ;an000;bgb
;Called Procedures: SysParse ;an000;bgb
; ;an000;bgb
;Change History: Created 5/12/87 MT ;an000;bgb
; ;an000;bgb
;Input: Command line input at 81h ;an000;bgb
; ;an000;bgb
;Output: None ;an000;bgb
; ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; Copy command line to buffer ;an000;bgb
; DO ;an000;bgb
; Parse buffer line (CALL SysParse) using drive letter only tables ;an000;bgb
; LEAVE end of parse ;an000;bgb
; ENDDO missing operand ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
;Procedure Parse_Drive_Letter ; ;an000;bgb;AN000;
; Set_Data_Segment ;Set DS,ES to Data segment ;an000;bgb;AN000;
; mov cx,PSP_Segment ;Get segment of PSP ;an000;bgb;AN000;
; mov ds,cx ; " " " " ;an000;bgb;AN000;
; assume ds:nothing ; ;an000;bgb;AN000;
; mov si,Command_Line_Parms ;Point to command line ;an000;bgb;AN000;
; lea di,Command_Line_Buffer ;Point to buffer to save to ;an000;bgb;AN000;
; mov cx,Command_Line_Length ;Number of bytes to move ;an000;bgb;AN000;
; rep movsb ;Copy the entire buffer ;an000;bgb;AN000;
; Set_Data_Segment ; ;an000;bgb;AN000;
; lea si,Command_Line_Buffer ;Pointer to parse line ;an000;bgb;AN000;
; lea di,input_table ;Pointer to control table ;an000;bgb;AN000;
; $DO ;Parse for drive letter ;an000;bgb;AN000;
; xor dx,dx ;Parse line @SI ;an000;bgb;AN000;
; xor cx,cx ;Parse table @DI ;an000;bgb;AN000;
; call SysParse ;Go parse ;an000;bgb;AN000;
; cmp ax,End_Of_Parse ;Check for end of parse ;an000;bgb;AN000;
; $LEAVE E ;In other words, no drive letter;an000;bgb;AN000;
; cmp ax,Operand_Missing ; exit if positional missing ;an000;bgb;AN000;
; $ENDDO E ;Ignore errors!!! ;an000;bgb;AN000;
; Set_Data_Segment ; ;an000;bgb;AN000;
; ret ; ;an000;bgb;AN000;
; ;an000;bgb
;Parse_Drive_Letter endp ; ;an000;bgb;AN000;
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Parse_Command_Line ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Parse the command line. Check for errors, and display error and ;an000;bgb
; exit program if found. Use parse error messages except in case ;an000;bgb
; of no parameters, which has its own message ;an000;bgb
; ;an000;bgb
;Called Procedures: Message (macro) ;an000;bgb
; SysParse ;an000;bgb
; Interpret_Parse ;an000;bgb
; ;an000;bgb
;Change History: Created 5/1/87 MT ;an000;bgb
; ;an000;bgb
;Input: Fatal_Error = NO ;an000;bgb
; PSP_Segment ;an000;bgb
; ;an000;bgb
;Output: Fatal_Error = YES/NO ;an000;bgb
; Parse output buffers set up ;an000;bgb
; ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; SEARCH ;an000;bgb
; Parse command line (CALL SysParse) ;an000;bgb
; EXITIF end of parsing command line ;an000;bgb
; Figure out last thing parsed (Call Interpret_Parse) ;an000;bgb
; ORELSE ;an000;bgb
; See if parse error ;an000;bgb
; ENDLOOP parse error ;an000;bgb
; See what was parsed (Call Interpret_Parse) ;an000;bgb
; Fatal_Error = YES ;an000;bgb
; ENDSRCH ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Parse_Command_Line ; ;an000;bgb;AN000;
;an000;bgb
push ds ;Save data segment ;an000;bgb;AN000;
Set_Data_Segment ; ;an000;bgb;AN000;
mov cx,PSP_Segment ;Get segment of PSP ;an000;bgb;AN000;
mov ds,cx ; " " " " ;an000;bgb;AN000;
;an000;bgb
assume ds:nothing,es:dg ; ;an000;bgb;AN000;
;an000;bgb
mov si,Command_Line_Parms ;Point at command line ;an000;bgb;AN000;
lea di,Command_Line_Buffer ;Where to put a copy of it ;an000;bgb;AN000;
mov cx,Command_Line_Length ;How long was input? ;an000;bgb;AN000;
repnz movsb ;Copy it ;an000;bgb;AN000;
lea Di,Command_Line_Buffer ; ;an046;bgb
public nextdi ;an046;bgb
nextdi: ;an046;bgb
mov al,0dh ;search for end of line ;an046;bgb
cmp al,ES:[Di] ;zero terminate string ;an046;bgb
; $IF NZ ;an046;bgb
JZ $$IF18
inc di ;an046;bgb
jmp nextdi ;an046;bgb
; $ELSE ;an046;bgb
JMP SHORT $$EN18
$$IF18:
mov byte ptr ES:[di+1],00 ;an046;bgb
; $ENDIF ;an046;bgb
$$EN18:
;an046;bgb
Set_Data_Segment ;Set DS,ES to Data segment ;an000;bgb;AN000;
xor cx,cx ; ;an000;bgb;AN000;
xor dx,dx ;Required for SysParse call ;;an000;bgbAN000;
lea si,Command_Line_Buffer ;Pointer to parse line ;an000;bgb ;AN000;
lea di,input_table ;Pointer to control table ;an000;bgb ;AN000;
; $SEARCH ;Loop until all parsed ;an000;bgb;AN000;
$$DO21:
cmp Fatal_Error,Yes ;Interpret something bad? ;an000;bgb;AN000;
; $EXITIF E,OR ;If so, don't parse any more ;an000;bgb;AN000;
JE $$LL22
call SysParse ;Go parse ;an000;bgb;AN000;
cmp ax,End_Of_Parse ;Check for end of parse ;an000;bgb;AN000;
; $EXITIF E ;Is it? ;an000;bgb;AN000;
JNE $$IF21
$$LL22:
;All done ;an000;bgb;AN000;
; $ORELSE ;Not end ;an000;bgb;AN000;
JMP SHORT $$SR21
$$IF21:
cmp ax,0 ;Check for parse error ;an000;bgb;AN000;
; $LEAVE NE ;Stop if there was one ;an000;bgb;AN000;
JNE $$EN21
call Interpret_Parse ;Go find what we parsed ;an000;bgb;AN000;
; $ENDLOOP ;Parse error, see what it was ;an000;bgb;AN000;
JMP SHORT $$DO21
$$EN21:
dec si ;point to last byte of invalid parm
public decsi
decsi: cmp byte ptr [si],' ' ;are we pointing to a space? ;an046;bgb
; $IF E,OR ;if so, we dont want to do that
JE $$LL26
cmp byte ptr [si],0dh ;are we pointing to CR? ;an046;bgb
; $IF E ;if so, we dont want to do that
JNE $$IF26
$$LL26:
dec si ;find the last byte of parm
jmp decsi
; $ENDIF
$$IF26:
mov byte ptr [si+1],00 ;zero terminate display string ;an046;bgb
nextsi:
public nextsi
dec si ;look at previous char ;an046;bgb
cmp byte ptr [si],' ' ;find parm separator ;an046;bgb
jnz nextsi ;loop until begin of parm found
mov movsi,si ;mov si into display parms ;an046;bgb
PARSE_MESSAGE ;Display parse error ;an000;bgb;AN000;
mov Fatal_Error,YES ;Indicate death! ;an000;bgb;AN000;
; $ENDSRCH ; ;an000;bgb;AN000;
$$SR21:
pop ds ; ;an000;bgb;AN000;
ret ; ;an000;bgb;AN000;
;an000;bgb
Parse_Command_Line endp ; ;an000;bgb;AN000;
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Interpret_Parse ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;description: Get any switches entered, and dr ;an000;bgb
; ;an000;bgb
; ;an000;bgb
;Called Procedures: Message (macro) ;an000;bgb
; ;an000;bgb
;Change History: Created 5/1/87 MT ;an000;bgb
; ;an000;bgb
;Input: DS:DrNum (FCB at 5Ch) ;an000;bgb
; ;an000;bgb
;Output: Noisy = ON/OFF ;an000;bgb
; DoFix = ON/OFF ;an000;bgb
; ALLDRV = Target drive, A=1 ;an000;bgb
; VOLNAM = Target drive, A=1 ;an000;bgb
; ORPHFCB = Target drive, A=1 ;an000;bgb
; BADDRVm+1 = Target drive, A=0 ;an000;bgb
; Arg_Buf = Target drive letter ;an000;bgb
; Fragment > 1 if filespec entered ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; Noisy = OFF ;an000;bgb
; DoFix = OFF ;an000;bgb
; IF /V ;an000;bgb
; Noisy = ON ;an000;bgb
; ENDIF ;an000;bgb
; IF /F ;an000;bgb
; DoFix = ON ;an000;bgb
; ENDIF ;an000;bgb
; IF file spec entered ;an000;bgb
; Build filename ;an000;bgb
; Fragment = 1 ;an000;bgb
; ENDIF ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Interpret_Parse ; ;an000;bgb;AN000;
;an000;bgb
push ds ;Save segment ;an000;bgb;AN000;
push si ;Restore SI for parser ;an000;bgb;AN000;
push cx ; ;an000;bgb;AN000;
push di ; ;an000;bgb
Set_Data_Segment ; ;an000;bgb
cmp byte ptr Buffer.dfType,Type_Drive ;Have drive letter? ;AN000; ;an000;bgb
; $IF E ;Yes, save info ;an000;bgb;AN000;
JNE $$IF29
and word ptr dfcontrol,filespec ;dont let another drive letter ;an000;bgb
mov al,byte ptr Buffer.Drnum_stroff ;Get drive entered ;;an000;bgbAN000;
mov AllDrv,al ; ;an000;bgb;AC000;
mov VolNam,al ; ;an000;bgb;AC000;
mov OrphFCB,al ; ;an000;bgb;AC000;
dec al ;Make it 0 based ;an000;bgb;AN000;
mov BadDrvm+1,al ; " " " " ;an000;bgb;AN000;
add al,'A' ;Make it a drive letter ;an000;bgb;AN000;
mov Arg_Buf,al ;Save it ;an000;bgb;AN000;
; $ENDIF ; ;an000;bgb;AN000;
$$IF29:
cmp SwBuffer.Switch_Pointer,offset Sw_v ;AN020;;an000;bgbbgb
; $IF E ; ;an000;bgb;AN000;
JNE $$IF31
mov Noisy,ON ;Set flag ;an000;bgb;AC000;
mov byte ptr sw_v,blank ;an000;bgb;an020;bgb
; $ENDIF ; ;an000;bgb;AN000;
$$IF31:
cmp SwBuffer.Switch_Pointer,offset sw_f ;AN020;;an000;bgbbgb
; $IF E ; ;an000;bgb;AN000;
JNE $$IF33
mov DoFix,ON ;Set flag ;an000;bgb;AC000;
mov byte ptr sw_f,blank ;;an000;bgban020;bgb
; $ENDIF ; ;an000;bgb;AN000;
$$IF33:
;;;;;;; cmp FileSpec_Buffer.FileSpec_Pointer,offset FileSpec_Control.Keyword;an000;bgb ;AN000;
cmp buffer.dftype, type_filespec ;an000;bgb
; $IF E ; ;an000;bgb;AN000;
JNE $$IF35
mov word ptr dfcontrol,0 ;dont let another drive letter or filesp;an000;bgbec
mov si,Buffer.drnum_StrOff ; ;AN000; ;an000;bgb
lea di,Path_Name ;Point to where to build path ;an000;bgb;AN000;
cld ;SI-DI dir is up ;an000;bgb;AN000;
; $DO ;Move string one char at a time ;an000;bgb;AN000;
$$DO36:
cmp byte ptr [si],Asciiz_End ;Is it the end? ;an000;bgb;AN000;
; $LEAVE E ;You got it ;an000;bgb;AN000;
JE $$EN36
movsb ;Nope, move the character ;an000;bgb;AN000;
; $ENDDO ;And keep crusin ;an000;bgb;AN000;
JMP SHORT $$DO36
$$EN36:
inc fragment ;To be compat with old code ;an000;bgb;AN000;
; $ENDIF ; ;an000;bgb;AN000;
$$IF35:
pop di ;Restore parse regs ;an000;bgb;AN000;
pop cx ; ;an000;bgb;AN000;
pop si ; ;an000;bgb;AN000;
pop ds ; ;an000;bgb;AN000;
ret ; ;an000;bgb;AN000;
;an000;bgb
;an000;bgb
Interpret_Parse endp ; ;an000;bgb;AN000;
;an000;bgb
;an000;bgb
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Validate_Target_Drive ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Control routine for validating the specified format target drive. ;an000;bgb
; If any of the called routines find an error, they will print ;an000;bgb
; message and terminate program, without returning to this routine ;an000;bgb
; ;an000;bgb
;Called Procedures: Check_Target_Drive ;an000;bgb
; Check_For_Network ;an000;bgb
; Check_Translate_Drive ;an000;bgb
; ;an000;bgb
;Change History: Created 5/1/87 MT ;an000;bgb
; ;an000;bgb
;Input: Fatal_Error = NO ;an000;bgb
; ;an000;bgb
;Output: Fatal_Error = YES/NO ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; CALL Check_Target_Drive ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; CALL Check_For_Network ;an000;bgb
; IF !Fatal_Error ;an000;bgb
; CALL Check_Translate_Drive ;an000;bgb
; ENDIF ;an000;bgb
; ENDIF ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
;an000;bgb
Procedure Validate_Target_Drive ; ;an000;bgb;AN000;
call Check_For_Network ;See if Network drive letter ;an000;;an043;bgbbgb;AN000;
cmp Fatal_Error,YES ;Can we continue? ;an0;an043;bgb00;bgb;AN000;
; $IF NE ;Yep ;an0;an043;bgb00;bgb;AN000;
JE $$IF40
call Check_Target_Drive ;See if valid drive letter ;an000;bgb;AN000;
cmp Fatal_Error,YES ;Can we continue? ;an000;bgb;AN000;
; $IF NE ;Yep ;an000;bgb;AN000;
JE $$IF41
call Check_For_Network ;See if Network drive letter ;an000;bgb;AN000;
cmp Fatal_Error,YES ;Can we continue? ;an000;bgb;AN000;
; $IF NE ;Yep ;an000;bgb;AN000;
JE $$IF42
call Check_Translate_Drive ;See if Subst, Assigned ;an000;bgb;AN000;
; $ENDIF ;- Fatal_Error passed back ;an000;bgb;AN000;
$$IF42:
; $ENDIF ; ;an000;bgb;AN000;
$$IF41:
; $ENDIF ;an000;bgb
$$IF40:
ret ; ;an000;bgb;AN000;
;an000;bgb
Validate_Target_Drive endp ; ;an000;bgb;AN000;
;an000;bgb
;***************************************************************************** ;an000;bgb
;Routine name: Check_Target_Drive ;an000;bgb
;***************************************************************************** ;an000;bgb
; ;an000;bgb
;Description: Check to see if valid DOS drive by checking if drive is ;an000;bgb
; removable. If error, the drive is invalid. Save default ;an000;bgb
; drive info. Also get target drive BPB information, and compute ;an000;bgb
; the start of the data area ;an000;bgb
; ;an000;bgb
;Called Procedures: Message (macro) ;an000;bgb
; ;an000;bgb
;Change History: Created 5/1/87 MT ;an000;bgb
; ;an000;bgb
;Input: Fatal_Error = NO ;an000;bgb
; ;an000;bgb
;Output: BIOSFile = default drive letter ;an000;bgb
; DOSFile = default drive letter ;an000;bgb
; CommandFile = default drive letter ;an000;bgb
; Fatal_Error = YES/NO ;an000;bgb
; ;an000;bgb
;Psuedocode ;an000;bgb
;---------- ;an000;bgb
; ;an000;bgb
; Get default drive (INT 21h, AH = 19h) ;an000;bgb
; Convert it to drive letter ;an000;bgb
; Save into BIOSFile,DOSFile,CommandFile ;an000;bgb
; See if drive removable (INT 21h, AX=4409h IOCtl) ;an000;bgb
; IF error - drive invalid ;an000;bgb
; Display Invalid drive message ;an000;bgb
; Fatal_Error= YES ;an000;bgb
; ENDIF ;an000;bgb
; Get BPB of target drive (Generic IOCtl Get Device parameters) ;an000;bgb
; Compute start of data area ;an000;bgb
; ret ;an000;bgb
;***************************************************************************** ;an000;bgb
Procedure Check_Target_Drive ; ;an000;bgb;AN000;
call func60 ; ;an000;bgb
mov al,save_drive ;an000;bgb
cmp al,0ffh ;save drive spec ;an000;bgb
; $IF E ;an000;bgb
JNE $$IF46
Message BadDrv_Arg ;Print message ;an000;bgb;AC000;
mov Fatal_Error,Yes ;Indicate error ;an000;bgb;AN000;
jmp Exit_Baddrv ;dont do rest of proc ;an000;bgb;an021;bgb;an099;
; $ENDIF ;an000;bgb
$$IF46:
DOS_Call Get_Default_Drive ;Find the current drive 19 ;an000;bgb;AC000;
mov UserDev,al ;Save it ;an000;bgb; ;
cmp AllDrv,0 ;Was drive entered? ;an000;bgb;AN002;
; $IF E ;No ;an000;bgb;AN002;
JNE $$IF48
mov BadDrvm+1,al ;Save 0 based number ;an000;bgb;AN002;
inc al ;Make 1 based ;an000;bgb;AN002;
mov byte ptr Buffer.Drnum_stroff,al ; ;an000;bgb ;
mov AllDrv,al ;Use default drive for ;an000;bgb;AN002;
mov VolNam,al ;entries for drive fields ;an000;bgb;AN002;
mov OrphFCB,al ; ;an000;bgb;AN002;
add al,'A'-1 ;Make it a drive letter ;an000;bgb;AN002;
mov Arg_Buf,al ;Save it ;an000;bgb;AN002;
; $ENDIF ; ;an000;bgb;AN002;
$$IF48:
mov bl,alldrv ;Get drive number (A=1) ;AN00;an044;bgb;an000;bgb0;
mov al,09h ;See if drive is local ;an000;bgb;AC000;
DOS_Call IOCtl ;-this will fail if bad drive ;an000;bgb;AC000;
; $IF C ;CY means invalid drive ;an000;bgb;AC000;
JNC $$IF50
Message BadDrv_Arg ;Print message ;an000;bgb;AC015;bgb
mov Fatal_Error,Yes ;Indicate error ;an000;bgb;AN015;bgb
; $ENDIF ; ;an000;bgb;AN000;
$$IF50:
cmp fatal_error,no ;an000;bgb
; $IF E ;an000;bgb
JNE $$IF52
get_bpb: mov al,GENERIC_IOCTL ;Get BPB information ;an000;bgb ;AN000;
mov ch,RawIO ; " " " " ;an000;bgb ;AN000;
mov cl,GET_DEVICE_PARAMETERS ; ;an000;bgb ;AN000;
mov bl,AllDrv ; " " " " ;an000;bgb ;AN000;
lea dx,BPB_Buffer ; dx points to bpb area ;an000;bgb ;AN000;
mov byte ptr bpb_buffer, 0ffh ;turn bit 0 on to get bpb inf;an000;bgbo of disk ;an008;bgb
DOS_Call IOCtl ; " " " " ;an000;bgb ;AN000;
mov bx,dx ;use bx as the pointer to bpb;an000;bgb ;an015;bgb
; $IF C ;is ioct not supported or bad? ;an000;bgb ;an015;bgb
JNC $$IF53
mov al,BadDrvm+1 ; drive number a=0 ;an000;bgb ;AN015;bgb
lea bx,chkprmt_end ; transfer address es:bx ;an000;bgb ;an015;bgb
;warning! this label must be the last in the code segment ;an000;bgb
mov cx,1 ; 1 sector - boot record ;an000;bgb ;an015;bgb
mov dx,0 ; logical sector 0 ;an000;bgb ;an015;bgb
mov Read_Write_Relative.Start_Sector_High,0 ; ;an000;bgb ;an015;bgb
call read_once ;an000;bgb ;an015;bgb
; $IF C ;couldnt read the boot? ;an000;bgb ;an015;bgb
JNC $$IF54
Message BadDrv_Arg ;Print message ;an000;bgb ;AC015;bgb
mov Fatal_Error,Yes ;Indicate error ;an000;bgb ;AN015;bgb
; $ELSE ;ioct not supported - is it vdisk ;an000;bgb ;an015;bgb
JMP SHORT $$EN54
$$IF54:
; mov di,bx ;an000;bgb;an022;bgb
; add di,3 ;es:di --> to vdisk area in boot rcd ;an000;bgb;an022;bgb
; lea si,myvdisk ;ds:si --> proper vdisk string ;an000;bgb;an022;bgb
; mov cx,5 ; compare 5 bytes ;an000;bgb;an022;bgb
; repe cmpsb ;compare both strings ;an000;bgb;an022;bgb
IF IBMCOPYRIGHT
; $IF NE ;an000;bgb;an022;bgb
; jmp baddrv ;an000;bgb
; $ENDIF ;an000;bgb;an022;bgb
ELSE
; $IF NE
mov di,bx
add di,3
lea si,myramdisk
mov cx,8
repe cmpsb
; $IF NE
JE $$IF56
jmp baddrv
; $ENDIF
$$IF56:
; $ENDIF
ENDIF
; $ENDIF ;an000;bgb;an022;bgb
$$EN54:
add bx,4 ;boot-record-offset - device-paramete;an000;bgbr offset ;an015;bgb
; $ENDIF ;an000;bgb ;an015;bgb
$$IF53:
; $ENDIF ;an000;bgb
$$IF52:
cmp fatal_error,no ;an000;bgb
; $IF E ;an000;bgb
JNE $$IF61
call get_boot_info ;an053;bgb
call calc_space ;an000;bgb
; $ENDIF ;an000;bgb
$$IF61:
cmp bytes_per_sector,0 ;an000;bgb;an033;bgb
; $IF E ;an000;bgb;an033;bgb
JNE $$IF63
baddrv: mov fatal_error,yes ;an000;bgb;an033;bgb
mov dx,offset dg:inval_media ;an000;bgb;an033;bgb
invoke printf_crlf ;an000;bgb;an033;bgb
; $ENDIF ;an000;bgb;an033;bgb
$$IF63:
Exit_Baddrv: ;AN099;
ret ;And we're outa here ;an000;bgb;AN000;
Check_Target_Drive endp ; ;an000;bgb;AN000;
;an000;bgb
;an000;bgb
;****************************************************************************** ;an053;bgb;an000;bgb
; get_boot_info ;an053;bgb
; ;an053;bgb
; ;an053;bgb;an000;bgb
; Inputs : none ;an053;bgb;an000;bgb
; ;an053;bgb;an000;bgb
; Outputs : ;an053;bgb
;****************************************************************************** ;an053;bgb;an000;bgb
Procedure get_boot_info ; ;an053;bgb;an000;bgb
mov cx,[bx].BytePerSector ; usually 512 ;an053;bgb;an000;bgb ;an015;bgb
cmp cx,512 ;vdisk sizes ;an053;bgb
; $IF NE,AND ;vdisk sizes ;an053;bgb
JE $$IF65