-
Notifications
You must be signed in to change notification settings - Fork 3
/
AG.DOC
7051 lines (4991 loc) · 242 KB
/
AG.DOC
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
MICROSOFT(R)
MS(tm)-DOS
Adaptation Guide
Last Updated on JULY 24, 1987
in conjunction with the MS-DOS 3.30 FINAL RELEASE
Microsoft Corporation
Information in this document is subject to change without
notice and does not represent a commitment on the part of
Microsoft Corporation. The software described in this
document is furnished under a license agreement or
non-disclosure agreement. The software may be used or
copied only in accordance with the terms of that agreement.
It is against the law to copy the MS-DOS Disk Operating
System on magnetic tape, disk, or any other medium for any
purpose other than the purchaser's personal use.
Copyright (C) Microsoft Corporation, 1982, 1983, 1984, 1985, 1986
INTEL is a registered trademark of Intel Corporation.
IBM is a registered trademark of International Business
Machines Corporation.
Microsoft, the Microsoft logo, and MS-DOS are registered
trademarks of Microsoft Corporation.
XENIX is a trademark of Microsoft Corporation.
TABLE OF CONTENTS
CHAPTER 1 MS-DOS INSTALLATION KIT
1.1 README.DOC File 1-1
CHAPTER 2 MS-DOS DEVELOPMENT TOOLS
CHAPTER 3 INSTALLING MS-DOS
CHAPTER 4 DISK STRUCTURE AND BOOTSTRAP LOADING
CHAPTER 5 RESIDENT DEVICE DRIVERS
CHAPTER 6 SYSINIT AND MS-DOS INITIALIZATION
CHAPTER 7 WRITING THE FORMAT MODULE
CHAPTER 8 TROUBLE SHOOTING
APPENDIX A CUSTOMIZATION OF MS-DOS AND
INTERNATIONALIZATION
A.1 Customizing MS-DOS A-1
A.2 ECS Considerations -- MS-DOS 2.25 A-2
A.3 Input A-3
A.4 Output A-3
APPENDIX B HOW TO UPGRADE A 2.X BIOS TO 3.X
APPENDIX C HOW TO UPGRADE A 3.1 BIOS TO 3.2
APPENDIX D DEVICE DRIVERS - CHAPTER 2 MS-DOS 3.20 PROGRAMMER'S REFERENCE
APPENDIX E MS-DOS 2.25 DEVICE DRIVER EXTENSIONS
APPENDIX F MS-DOS 2.25 APPLICATION LEVEL INTERFACE EXTENSION
APPENDIX G SPECIAL DOC
APPENDIX H PROGRAMMING RECOMMENDATIONS - CHAPTER 7 MS-DOS 3.20
PROGRAMMER'S REFERENCE
GLOSSARY OF MS-DOS TERMS
CONTENTS
CHAPTER 1 MS-DOS INSTALLATION KIT
1.1 README.DOC File 1-1
1.2 Contents 1-1
1.3 Common Questions and Answers 1-2
1.4 MS-DOS Hardware Requirements 1-3
1.5 MS-DOS Overview 1-5
CHAPTER 1
MS-DOS INSTALLATION KIT
1.1 README.DOC FILE
Check the README.DOC file on DISTRIBUTION DISKETTES for
version specific information and any addenda to this document.
1.2 CONTENTS
The MS-DOS 3.21 Installation Kit is provided on 5-1/4" high capacity
1.2 Megabyte disks. It consists of the MS-DOS DISTRIBUTION
DISKETTES that include files formerly found
version.
Included with the kit is a Sample MS-DOS 2.XX/3.XX Implementation.
The sample implementation runs on all members of the IBM PC family and
is intended to be functionally equivalent to the IBM implementation.
The purpose of this sample is to assist Microsoft OEMs with their
MS-DOS installations, but can also be used directly as part of the OEMs
product. IO.SYS, the BIOS, has been intended to be self documenting and
Microsoft will support services for it as it run on IBM PCs.
Included in the kit is a copy of the current Microsoft(R) Macro Assembler
featuring SYMDEB, the symbolic debugger. The full MASM retail package is
no longer provided.
The installation kit also includes four manuals:
MS-DOS User's Guide. This is an introduction to ______ ______ _____
MS-DOS, including how to start the system and use
applications.
MS-DOS User's Reference Manual. This manual ______ ______ _________ ______
explains hierarchical directories, the MS-DOS file
structure, and MS-DOS commands and utilities. This
manual is new in 3.XX.
MS-DOS Programmer's Reference Manual. This manual ______ ____________ _________ ______
includes a summary of all published system calls
and MS-DOS structures.
MS-DOS Adaptation Guide. This manual describes how ______ __________ _____
to implement MS-DOS on OEM machines. This guide is
available on diskette only and is the text you are
now reading.
MS-DOS INSTALLATION KIT Page 1-2
1.3 COMMON QUESTIONS AND ANSWERS
Q. What kind of development machine do you recommend?
A. Microsoft recommends that an MS-DOS machine be used as a
development tool in preparing software for your target
machine. Using an MS-DOS machine avoids problems with
incompatible assemblers and object module formats. You
may want to read standard MS-DOS disk formats. Using
the development machine to build a system disk for the
target machine simplifies the implementation process.
Q. Are sources available?
A. Sources for MS-DOS are not available (except for the sample
BIOS implementation).
Q. What language is MS-DOS written in?
A. The source code for MS-DOS and most utilities is written
in 8086 assembler code. It is compatible with the macro
facility found in Microsoft Macro Assembler for the
MS-DOS operating system. The format of the object
modules provided is a subset of the INTEL(R) format, and
may not be compatible with non-Microsoft linkers.
Q. What does an MS-DOS implementor need to know?
A. To install MS-DOS, you will need to be familiar with
systems programming in 8086 assembler language. This
means you should have experience in writing device
drivers for disk drives, keyboards, printers, and other
peripherals.
Q. How long does it take to install MS-DOS?
A. This depends on whether the low-level I/O routines are
already written. The record time for getting MS-DOS up
and running on a new machine is one weekend. In this
case, all of the low-level routines were in ROM.
Typically, a complete customer-ready MS-DOS
implementation takes two or more months.
MS-DOS INSTALLATION KIT Page 1-3
Q. Are there any consultants who do MS-DOS implementations?
A. Microsoft can supply a list of consultants who have done
MS-DOS implementations. Microsoft cannot make any
recommendations regarding the competence of these
consultants.
Q. Do you recommend that we have an In Circuit Emulator
(ICE) for our machine?
A. Yes. Since there are no MS-DOS debugging tools that can
be used to debug the boot sequence, an ICE is very
helpful.
1.4 MS-DOS HARDWARE REQUIREMENTS
To be compatible with the MS-DOS operating system, a machine
must conform to certain hardware characteristics. These
characteristics are as follows:
o The processor must be INTEL 8086 compatible.
o The Interrupt vector locations 20H through 3FH must
be reserved for MS-DOS.
o Four character device drivers and one block device
driver are required. They must recognize the
MS-DOS device driver call format.
o An ANSI terminal driver must be implemented.
(MS-DOS sends an ANSI escape sequence to clear the
console.)
o A logical disk, as described in this document, must
be available to MS-DOS. A disk format table, as
described in this document, should be present in
the first logical sector of each disk. Logical
sectors must be a multiple of 64 bytes in size.
o Random Access Memory (RAM) should be contiguous
from the point where MS-DOS is located through top
of memory.
o MS-DOS requires a minimum of 128K of RAM (depending
on IO.SYS size). Microsoft recommends a minimum
configuration of 128K non-video RAM and 192K for
future products.
The sample BIOS that is provided has been designed to only run on
a machine with the exact architecture of IBM PC family.
If MS-DOS can run on the OEMs hardware using the sample BIOS, then
the hardware is compatible with the IBM PC family architecture.
MS-DOS INSTALLATION KIT Page 1-4
In addition to these minimum requirements, the following
hardware features are recommended for optimum performance as
well as compatibility with new Microsoft products. Features
recommended for performance on 2.0 and higher systems are
starred.
o *An interrupt-driven keyboard with a type-ahead
buffer (Interrupt-driven I/O for all devices).
o *Direct memory access.
o *Non-interlaced disks.
o *Disk door locks or a detection mechanism to check
if disks have been changed.
o Support of standard MS-DOS disk formats.
o User-addressable bit-mapped video display with
minimum resolution of 640 by 200 pixels.
o Programmable interval timer.
o Mouse support.
o RS-232 and printer interfaces.
o Minimum 192K RAM memory.
o A Scroll Lock/Break key that puts a Control-S and
Control-C at the beginning of the keyboard
type-ahead buffer when pressed.
MS-DOS INSTALLATION KIT Page 1-5
1.5 MS-DOS OVERVIEW
An MS-DOS implementation requires seven components:
1. The resident device drivers (the IO.SYS file), a
collection of hardware-specific device drivers that
must be written by the OEM. The resident device
drivers are called by MS-DOS to handle I/O
requests. These device drivers may be partly ROM
resident or may be completely RAM resident.
2. The SYSINIT Module(s), (SYSINIT1.OBJ and SYSINIT2.OBJ
in 3.xx and only SYSINIT.OBJ in 2.xx) and SYSIMES.OBJ,
Microsoft-supplied modules which are linked to the
resident device drivers and initialize the system.
The file that contains these device drivers is
named IO.SYS (on the IBM(R) PC, this file is named
IBMBIO.COM).
3. MSDOS.SYS, the hardware-independent disk operating
system supplied by Microsoft. (On the IBM PC, this
file is named IBMDOS.COM.)
4. COMMAND.COM, the command interpreter program that
reads and interprets keyboard input, executes
"built-in" commands like DIR, and initiates
external programs.
5. Bootstrap loader, the OEM-supplied module that
loads the IO.SYS and MSDOS.SYS files into memory.
MSDOS.SYS may optionally be loaded by IO.SYS.
A sample bootstrap loader has been provided with
the OEM kit. This sample bootstrap loader is
compatible with the IBM PC family.
6. A system ROM which may optionally perform
diagnostics on power-up or reset. The system ROM
loads the boot sector into RAM and transfers
control to it.
7. MS-DOS utilities, including FORMAT, for which
Microsoft modules are provided and a
hardware-specific section must be written by the
OEM. NOTE: Refer to the MS-DOS 3.3 specific portions
for use of the hardware independent FORMAT utility.
MS-DOS INSTALLATION KIT
CONTENTS
CHAPTER 2 MS-DOS DEVELOPMENT TOOLS
EDLIN Text Editor 2-1
Microsoft Macro Assembler 2-1
Microsoft Linker (MS-LINK) 2-2
MS-DEBUG 2-2
EXE2BIN 2-2
FORMAT 2-2
CHAPTER 2
MS-DOS DEVELOPMENT TOOLS
An assembler, text editor, linker, and other utilities are
required for completing an MS-DOS implementation. We assume
that your development machine has the following standard
utilities:
EDLIN Text Editor
The EDLIN text editor provided with MS-DOS for your
development machine may be used to prepare assembler
source files. The version of EDLIN on MS-DOS 2.x and
3.x release disks is for versions 2.x and 3.x only, and
will not run under MS-DOS 1.x. A third party full screen
text editor (not a word processor) may be more efficient
for manipulating source files.
Microsoft Macro Assembler
A complimentary copy of the current Microsoft Macro Assembler
is provided with the MS-DOS installation kit.
The assembler is not actually a part of MS-DOS; it must be
licensed separately if you wish to ship it to your
customers. The Cross-Reference Utility (MS-CREF),
included with Microsoft Macro Assembler, can be used to
make cross-reference listings of assembler programs.
The Microsoft Macro Assembler package will only run
under MS-DOS 2.XX and later operating systems. The
output of the assembler is a relocatable object module
(.OBJ file type) which conforms to a subset of the
INTEL MCS 86 object module format description. Refer
to the MS-DOS Programmer's Reference Manual for ______ ____________ _________ ______
information on the INTEL MCS 86 object module format
description.
MS-DOS DEVELOPMENT TOOLS Page 2-2
Microsoft Linker (MS-LINK)
Your MS-DOS development machine should include a linker
named LINK.EXE. Use LINK.EXE for linking object
modules (.OBJ files) produced by the Microsoft Macro
Assembler. The output of the Linker is a file with an
.EXE format. This is an executable program requiring a
special loader that is part of MS-DOS. Refer to the
MS-DOS Programmer's Reference Manual for details on ______ ____________ _________ ______
.EXE formats.
SYMDEB
SYMDEB.EXE is the MS-DOS symbolic debugger. The debugger
can do absolute disk reads and writes. You may use this
facility to write your bootstrap loader program into
the boot sector. Note that since MS-DOS is not
reentrant, this debugger may not be used to set break
points within the DOS or device drivers.
EXE2BIN
The EXE2BIN.EXE utility supplied with your MS-DOS
development machine must be used for converting output
from the Linker (.EXE files) to a pure binary (core
image) format not requiring a special loader. Note
that only .COM files may execute out of ROM.
FORMAT
The FORMAT program (FORMAT.EXE) supplied with your
MS-DOS development machine may be used to format a boot
disk for the target machine, assuming both machines
have compatible media.
EXEFIX
EXEFIX is a special purpose utility used for building
SORT. It sets the maximum memory allocation.
MS-DOS DEVELOPMENT TOOLS
CONTENTS
CHAPTER 3 INSTALLING MS-DOS
CHAPTER 3
INSTALLING MS-DOS
If you are using an MS-DOS machine for development and your
target machine will read MS-DOS standard disk formats,
follow these steps to implement MS-DOS.
NOTE: The steps involved in developing IO.SYS are not necessary
if the sample BIOS provided with the OEM kit is used.
This sample can also be used for technical reference.
1. Using a text editor on your development machine,
write the 8086 assembler source code for the
resident device drivers. The resident device
drivers are the hardware-specific routines that
will be accessed by MS-DOS to perform I/O. There
must be a minimum of five device drivers: four ____
character drivers and one block device driver (the
disk drive on most systems). In addition to the
device drivers, you may want to include some code
for hardware initialization. The source file
should be named IO.ASM and must not contain a STACK
segment.
For more information, see:
MS-DOS Programmer's Reference Manual ______ ____________ _________ ______
IO.ASM on the distribution disk
The resident device driver section of this manual
2. Use MASM.EXE, the macro assembler provided with
your MS-DOS installation kit to assemble your
device driver code. MASM will create a file called
IO.OBJ, which is in a special object module format
(a subset of INTEL's object module format).
For more information, see:
Microsoft Macro Assembler Manual (Macro Assembler _________ _____ _________ ______
section)
3. Use LINK.EXE, the Microsoft Linker, to link your
IO.OBJ module to appropriate SYSINIT.OBJ module(s)and the
appropriate SYSIMES.OBJ module. The
modules must be linked in this order:
2.xx IO.OBJ+SYSINIT.OBJ+SYSIMES.OBJ
3.XX IO.OBJ+SYSINIT1.OBJ+SYSINIT2.OBJ+SYSIMES.OBJ
The output file should be named IO.EXE. You
INSTALLING MS-DOS Page 3-2
may get the message "Warning, no STACK segment" while
linking the module. This is a warning message and
is normal with some versions of the linker.
For more information, see:
Microsoft Macro Assembler Manual (Chapter 3 LINK: _________ _____ _________ ______
A Linker)
4. The file created in step 3 is an .EXE file which is
in a special format recognized by the .EXE loader.
Since the .EXE loader is not available at boot
time, the IO.EXE file must be converted to a pure
binary core image file. This is done with the
EXE2BIN utility provided with the MS-DOS release on
your development machine. The EXE2BIN utility must
know exactly where the code will reside in memory
to resolve any FAR references. You will be
prompted for the base address, the absolute segment
address where the code will begin. The resultant
file must be named IO.SYS. EXE2BIN will change the
name when you type the following command line:
EXE2BIN IO.EXE IO.SYS
------------------------------------------------------------
| |
| Note |
| |
| It is the responsibility of the bootstrap loader to |
| locate IO.SYS at the location you specified as the base |
| address. The location itself is arbitrary, since one |
| of the parameters that the resident device driver code |
| passes to SYSINIT is the location of the first device |
| driver. |
| |
|__________________________________________________________|
For more information, see:
MS-DOS User's Reference Manual (Chapter 3) ______ ______ _________ ______
5. Customize the function key table in DOSMES.ASM.
6. Use MSDOSBLD.BAT on the distribution disk to assemble
appropriate object modules and link them with those
already provided to form MSDOS.SYS.
7. Write a bootstrap loader program using the text
editor. This step is not necessary if the sample
bootstrap loader included in the OEM kit is used.
The sample bootstrap loader can also be used for
technical reference.
Name this file BOOT.ASM. We assume that you have
a system ROM which will load the first sector of
the system disk into memory when you turn
on or reset the compter. Ideally, the bootstrap
loader fits into the first sector of the boot disk.
In addition to the loader, information relating to
the BIOS Parameter Block (BPB) should be kept in the
boot sector of the disk. The format of the boot
INSTALLING MS-DOS Page 3-3
sector is described in Chapter 4.
The bootstrap loader loads IO.SYS and MSDOS.SYS into
memory. MS-DOS can be located any place in memory
above IO.SYS. (IO.SYS can alternately be used to
load MSDOS.SYS.) Loading IO.SYS and MSDOS.SYS is
simple because these two files must always be the
first files on the disk. This means that a
bootstrap loader could simply load a series of
consecutive sectors into memory. Your bootstrap
loader may also read in the first sector of the
directory before it loads IO.SYS to verify that
these files are the first files on the disk.
For more information, see:
MS-DOS Programmer's Reference Manual ______ ____________ _________ ______
(Chapter 2)
MS-DOS Adaptation Guide (Chapter 4) ______ __________ _____
8. Assemble, link, and convert to binary (using
EXE2BIN) the BOOT.ASM file to produce BOOT.BIN.
9. Format a non-system disk using your MS-DOS
development machine.
10. Using the MS-DOS Copy command, copy IO.SYS,
MSDOS.SYS, and appropriate version of
COMMAND.COM to the formatted disk.
11. Using DEBUG.COM on the development machine, load
BOOT.BIN and write it to the first sector of the
formatted disk. This can be done as follows:
DEBUG
-N BOOT.BIN
-L (loads BOOT.BIN)
-W 100 0 0 1 (writes BOOT.BIN to drive 0
sector 0)
-Q
Note: More operations may be required depending on
how your boot program is organized.
For more information, see:
Microsoft Macro Assembler Manual (Chapter 4 SYMDEB: _________ _____ _________ ______
A Symbolic Debug Utility
The formatted disk should now be bootable by your
system.
INSTALLING MS-DOS Page 3-4
12. Write the source code for the hardware-specific part
of the FORMAT program. The MS-DOS 3.3 version of the
FORMAT utility has been structured so that the hardware
specific portions have been placed solely in IO.SYS.
Minimal work should be required for the OEM use of the
MS-DOS 3.2 FORMAT utility.
Assemble and link this to the FORMAT.OBJ and FORMES.OBJ
files supplied by Microsoft. The modules must be linked
in the following order:
2.XX: FORMAT.OBJ+FORMES.OBJ+OEMFOR.OBJ
where OEMFOR.OBJ is your hardware-specific module.
Use EXE2BIN to convert the OEMFOR.EXE file produced
to FORMAT.COM.
3.XX: FORMAT.OBJ+FORPROC.OBJ+FORMES.OBJ+OEMFOR.OBJ+PRINTF.OBJ
where OEMFOR is your hardware-specific module.
Although the PRINTF.OBJ module is the last module
specified, it does not follow the OEM module in the
memory image.
For more information, see:
MS-DOS Adaptation Guide (Chapter 7) ______ __________ _____
OEMFOR.ASM Disk file of sample OEM FORMAT module
MS-DOS User's Reference Manual (Format Command, ______ ______ _________ ______
Chapter 3)
MS-DOS Programmer's Reference Manual (Chapter 3) ______ ____________ _________ ______
13. Install the MS-DOS OEM serial number.
For information on how this is done, refer to the README.DOC
on the distribution diskette.
14. Modify SORTMES.ASM as appropriate.
15. Build SORT executable with SORTBLD.BAT.
16. Modify PRINT source modules as appropriate
17. Build PRINT executable with PRINTBLD.BAT
INSTALLING MS-DOS
CONTENTS
CHAPTER 4 DISK STRUCTURE AND BOOTSTRAP LOADING
4.1 Reserved Area 4-1
4.2 File Allocation Table 4-2
4.3 MS-DOS File System Limits 4-4
4.3.1 Disk Format Identification 4-6
4.4 The role of the Boot Sector 4-7
CHAPTER 4
DISK STRUCTURE AND BOOTSTRAP LOADING
MS-DOS disks are divided into four logical data areas.
1. Reserved sectors (boot sector)
2. File Allocation Tables
3. Root directory
4. Data area which may include subdirectories
as well as program and data files
When creating non-standard disks or non-removable media
(such as hard disks), the logical disk which your device _______
driver presents to MS-DOS must conform to the above
standard. The physical layout may be completely different. ________
For example, you may want to implement a partitioning scheme
on the hard disk so that it can be shared by multiple
operating systems. In this case, either the device driver
or firmware maps the physical structure into an MS-DOS
logical layout. The MS-DOS file system can even be
logically implemented within another operating system's file
structure.
4.1 RESERVED AREA
The reserved area is the first part of the disk and is
typically used for boot purposes. Some machines not
specifically designed for MS-DOS may use track 0 for special
purposes (it may even have a different sector size than the
rest of the disk). In this case, the entire track should be
marked as reserved so that the device driver will map
MS-DOS's logical sector 0 to the beginning of track 1
instead of track 0.
It may be difficult to fit the required boot information
into a single sector. Note that disk formats using 128- or
256-byte sectors and without any firmware support may
DISK STRUCTURE AND BOOTSTRAP LOADING Page 4-2
require several sectors.
4.2 FILE ALLOCATION TABLE
The File Allocation Table (FAT) is the most important data
structure on the disk. Two copies are usually kept at the
OEM's option. (Two copies need not be kept for a virtual
RAM disk because, in this case, the media cannot be damaged.)
MS-DOS files are allocated in "allocation units" or "clusters".
Each cluster is some number of sectors. The number of sectors
per allocation unit must be a power of 2 which fits in a byte.
Thus, the complete list of possible values is:
1, 2, 4, 8, 16, 32, 64, 128.
The FAT is a physical map of the allocation units in the
data area of the disk. There is one FAT entry for each
allocation unit on the disk plus two reserved entries at the
beginning of the FAT. The entries serve as a linked list of
pointers. For a complete discussion of FAT structure, refer
to Chapter 3 of the MS-DOS Programmer's Reference Manual. ______ ____________ _________ ______
FAT size can be determined by the following formula:
FAT = Q * ( T - R - D + 2)
--------------------
Q * N + ( A * S )
FAT is the number of sectors needed for one FAT and will
usually not be an integer. It must be rounded up to
the next integer value.
Q is the number 1.5 for 12-bit FAT entries and 2.0
for 16-bit FAT entries.
T is the total number of sectors on the disk.
R is the number of reserved sectors.
D is the number of root directory sectors (there must
be 32 bytes for each directory entry).
A is the number of sectors per cluster or allocation
unit.
N is the number of file allocation tables on the disk.
S is the number of bytes per sector.
MS-DOS 3.x can use 16-bit FAT pointers whenever the total
DISK STRUCTURE AND BOOTSTRAP LOADING Page 4-3
number of clusters on the disk exceeds 4085 (=4096-10; two
are reserved at the beginning, and eight are reserved at the
end). Although the FAT entries are 16 bits, the present
software only works with 15 bits (up to 32766 clusters).
____________________________________________________________
| |
| Important |
| |
| Be careful when reducing cluster size as it can cause |
| significant performance degradation. Reducing cluster |
| size results in increased fragmentation, a larger FAT |
| to buffer (increasing the number of disk accesses); and |
| increasing the FAT entries from 12 to 16-bit expands |
| the FAT size by 33%. |
| |
|__________________________________________________________|
The FORMAT program will create a proper FAT. The FAT has an
entry for each allocation unit in the data area of the disk.
It also contains two extra entries at the beginning. These
represent reserved clusters. The first cluster of the data
region of the disk is cluster 2.
The first (0th cluster) of these two reserved entries can be
used to indicate the format of the disk. Only the low 8
bits are used, and this byte is often referred to as the
FATID byte. The high 4 bits (high byte if a 16-bit FAT) of
this first cluster are all set (=1).
The FATID byte is restricted to be in the range 0F8H to
0FFH, inclusive (8 possible values). The FATID byte is also
an end-of-file (EOF) mark. If a FAT chain contains a zero
entry (which should never happen), it will point to this EOF
marker. The second (1st cluster) of these two reserved
entries is always 0FFFH (0FFFFH for a 16-bit FAT), which is
an end-of-file mark.
DISK STRUCTURE AND BOOTSTRAP LOADING Page 4-4
Figure 4.1 illustrates the first two clusters of a 12-bit
File Allocation Table.
FAT BYTE 00 01 02 03
XXH XXH XXH XXH----->Byte 3
|| || ||
Middle 4 bits | || High and middle 4 bits of
of cluster 0 | || cluster 1 (always F)
| | High 4 bits of
Low 4 bits of | cluster 0 (always F)
cluster 0 |
| | Low 4 bits of cluster
|------------------| 1 (always F)
|
FATID BYTE
Figure 4.1. First Two Entries of the FAT (12-bit)
4.3 MS-DOS FILE SYSTEM LIMITS
The following figure shows the file storage limitations
within MS-DOS.
| MS-DOS 2.x | Both | MS-DOS 3.x
_______________|______________|_____________|_______________
|FAT entry size |12 bits | |12 or 16 bits |
|Sector size | |64b-32Kb | |
|No. of Sectors | |Max of 64K | |
|Cluster size | |1-128 sectors| |
|Max. disk size |4085 clusters |64K sectors |32766 clusters|
|Max. file size | |Disk size | |
________________|______________|_____________|______________|
All ranges in the table are inclusive. As well as the above
limitations, there are also various limits as noted below:
1. FAT entry size.
This is the only file storage limit difference
between MS-DOS 2.XX and 3.XX; it significantly
increases the maximum number of clusters and hence
the maximum disk size allowed. MS-DOS 3.x
determines whether a 12- or 16-bit FAT is in use by
calculating the number of disk clusters from the
BPB. If the number of clusters is less than or
equal to 4085, a 12-bit FAT is in use; otherwise,
a 16-bit FAT is assumed. A 16-bit FAT cannot be
used if the total number of clusters is less than
DISK STRUCTURE AND BOOTSTRAP LOADING Page 4-5
or equal to 4085.
Some existing MS-DOS applications (such as copy
protection schemes and disk maintenance utilities)
bypass MS-DOS and manipulate the FAT directly.
These existing applications will cause problems
with 16-bit FATs until the applications are updated
to recognize the 16-bit FATs.
2. Sector Size.
Must be a multiple of 64 bytes.
3. No. of Sectors.
The number of sectors is limited to 64K because
16-bit sector numbers are passed to the device
drivers.
4. Cluster Size.
The cluster size (bytes/cluster = sectors/cluster *
bytes/sector) must be less than 64K because MS-DOS
uses 16-bit arithmetic.
Sectors/Cluster must be a power of 2 in the range
1-128.
Excessively small cluster sizes can seriously
degrade performance. Refer to the MS-DOS ______
Programmer's Reference Manual for sample disk ____________ _________ ______
formats.
5. Max. Disk Size.
MS-DOS 2.XX: Lesser of 4085 clusters or 64K sectors
(For example, 64K*512 byte sectors = 32Mb disk).
MS-DOS 3.XX: Lesser of 32766 clusters or 64K
sectors.
The total number of sectors is limited to 64K due