2 ;******************* START OF SPECIFICATIONS ***********************************
4 ; MODULE NAME: SYS1.SAL + SYS2.SAL + SYSSR.SAL
6 ; DESCRIPTIVE NAME: SYS
8 ; FUNCTION: Copies system programs IBMBIO.COM and
9 ; IBMDOS.COM onto a specified media.
19 ; INTERNAL REFERENCES:
25 ; EXTERNAL REFERENCES:
31 ; NOTES: Version 4.0 is a MAJOR diversion from all previous versions of DOS.
33 ; In all older versions of SYS the target diskette, HAD to meet the
34 ; following criteria in order to be SYSed:
35 ; - there must be enough physical room for IBMBIO and
37 ; - the first data cluster (#2) had to be either not
38 ; used - or owned by IBMBIO allready on the disk
39 ; - The first 2 root DIR entries had to be unused, deleted
40 ; or owned by IBMBIO and IBMDOS.
42 ; 4.0 SYS is far less restrictive.
43 ; - there must still be enough physical room for IBMBIO
45 ; - SYS will free up all required data clusters required
47 ; - The 2 root DIR entries for IBMDOS and IBMBIO may
48 ; be anywhere in the root. SYS will move entrys
49 ; in order for IBMBIO and IBMDOS to be in their proper
51 ; *** NOTE **** - Sys will operate on DOS 3.2, 3.3 and 4.0.
52 ; This has reqired a HARD CODED lower bound - DOS_low
53 ; that is set in this file to 3.20
55 ; REVISION HISTORY: Ax000 Version 4.0 05/01/87 - first release FG
56 ; Ax001 4.0 PTR P324 D Love
57 ; Ax002 4.0 PTR P583 FG
58 ; Ax003 4.0 DCR D4 - sys anything,anywhere FG
59 ; Ax004 4.0 DCR D201 - extended arbib change FG
60 ; Ax005 4.0 PTR P1334 - 1.2 MB + system hang FG
61 ; Ax006 4.0 PTR P1403 - BIO & DOS wrong spots FG
62 ; Ax007 4.0 PTR P1404,5 - DIR search error FG
63 ; Ax008 4.0 PTR P1406 - IOCTL to INT 21-69 FG
64 ; Ax009 4.0 PTR P1637 - full 720KB error FG
65 ; Ax010 4.0 PTR P1764 - single file error FG
66 ; Ax011 4.0 PTR P1772 - IBMBIO cluster chain FG
67 ; Ax012 4.0 PTR P1710 - ASSIGN or SUBST invalid FG
68 ; Ax013 4.0 PTR P1872 - ROOT restoration problem FG
69 ; Ax014 4.0 PTR P1884 - more ROOT problems FG
70 ; Ax015 4.0 PTR P2165 - ROOT DIR above #100h sec.FG
71 ; Ax016 4.0 DCR D304 - change in BOOT.INC FG
72 ; Ax017 4.0 PTR P2356 - HILDA error message FG
73 ; Ax018 4.0 PTR P2769 - no system on default drv FG
74 ; Ax019 4.0 DCR D380 - run on current VER -1 FG
75 ; Ax020 4.0 PTR P3028 - run using PATHGEN FG
76 ; Ax021 4.0 DCR D494 - add "source" & DOS 3.2 FG
77 ; Ax022 4.0 PTR P3728 - wrong network message FG
78 ; Ax023 4.0 DCR D503 - Version is now 4.0 FG
79 ; Ax024 4.0 PTM P3905 - fix parse error format FG
80 ; Ax025 4.0 PTM P4118 - fix message error FG
82 ; PRE-VERSION 4.0 HISTORY:
84 ; 1.6 05/21/82 Added rev number message
85 ; 1.61 06/04/82 Allow SYS to blank disk TimP at SCP
86 ; 1.70 06/30/82 NON contiguous DOS allowed on 2.00 IBM. Allows SYS to
88 ; 1.71 07/02/82 Put in CHDIRs to make sure everything done in root dir.
89 ; 1.80 04/26/83 MZ make sys work in small machines; use full 2.0
91 ; 1.81 07/22/83 ARR Added check in IBM version for valid FAT ID on
92 ; destination because of IBM problem with SYSing to
93 ; unformatted disks which are really formatted. Prints
94 ; NoDest message for ridic IBM reasons, should have a
96 ; 1.82 08/12/83 ARR ZIBOed again. Mark fails to check for errors on
97 ; his file I/O. Results in SYS saying system
98 ; transferred when it hasn't been.
99 ; 1.83 09/08/83 EKE Added code to quit if sys called on a drive across
101 ; 1.84 09/09/83 CHRISP grabbed against his will to make this stupid
102 ; program write out a boot sector
103 ; 1.85 10/18/83 NP Printf to print messages and it's now an .EXE file
104 ; 1.86 11/8/83 MZ fix hard file output of boot sector
105 ; 1.87 5/1/84 MZ make sys prompt for system disk in default drive.
106 ; 3.20 11/9/84 RS make sys write out a correct boot sector for the
107 ; version of DOS. It grabs the boot sector off the system
108 ; disk and inserts the correct BPB.
109 ; Uses IOCTL Get Device Parms to get BPB for a Hard drive.
110 ; 3.20 08/5/85 RS Allow FAT ID byte of 0F0H for 'strange' media
111 ; layouts. These come about because of /T /N switches in
113 ; 3.20 09/16/85 Incorporate tables of filenames to allow system files
114 ; used by other OEMs to be SYSed onto disks formatted on
115 ; other MSDOS systems. Allows the flexibility to replace
116 ; system files for one OEM by system files for another.
119 ; 3.30 06/04/86 MT removes initial check for IBMBIO and DOS - not needed
120 ; because of later search of dirs
121 ; 3.30 06/16/86 MT only force part of IBMBIO contig - do this by assuming
122 ; contig part smaller than 1.10 BIOS
123 ; 3.30 06/16/86 MT Check diks space for enough room to install BIO and DOS
125 ; Label: "The DOS SHARE Utility"
126 ; "Version 4.00 (C) Copyright 1988 Microsoft
127 ; "Licenced Material - Program Property of Microsoft"
129 ;******************* END OF SPECIFICATIONS *************************************
130 BREAK <SYS1 - Program Organization>
131 ;******************+ START OF PSEUDOCODE +**************************************
133 ;ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
134 ;³ Main ÃÄÄ´Init_Input_OutputÃÄÄÄÄ´SysLoadMsg³ (DOS version check)
135 ;ÀÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÙ
136 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
137 ; ³ À´Parse_Command_Line³
138 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
139 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
140 ; ôValidate_Target_DriveôCheck_Default_Drive³
141 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
142 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
143 ; ³ ôCheck_Target_Drive³
144 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
145 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
146 ; ³ À´Check_For_Network³
147 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
148 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
149 ; ôGet_System_FilesÃÄÄÄÄÄ´Prompt_For_Media³
150 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
151 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
152 ; ³ ôCheck_Removable³
153 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
160 ; ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
161 ; ôCheck_SYS_ConditionsÃÄ´Verify_File_System³
162 ; ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
163 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄ Ä Ä Ä Ä Ä Ä Ä ¿
164 ; ³ ôRead_DirectoryÃÄÄÄÄÄÄÄÄÄ´Prompt_For_Media³
165 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄ Ä Ä Ä Ä Ä Ä Ä Ù
166 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
167 ; ³ ôVerify_File_Location³
168 ; ³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
169 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄ¿
170 ; ³ À´Determine_Free_SpaceÃÄÄÄ´Get_Cluster³
171 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÙ
172 ; ³ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄ¿
173 ; ôDo_SYSÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´Create_SystemÃÄÄÄÄÄÄÄÄÄÄ´Create_File³
174 ; ³ÀÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÙ
181 ; ³ÚÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄ¿
182 ; ôDo_EndÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´Close_Files³
183 ; ³ÀÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÙ
184 ; ³ ³ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
185 ; ³ À´Write_Boot_RecordÃÄÄÄÄÄ´Create_Serial_ID³
186 ; ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
190 ; ³ÚÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
191 ; À´Message ÃÄÄÄÄÄÄÄÄÄÄÄÄ´Get_DOS_Error³
192 ; ÀÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
194 ;******************- END OF PSEUDOCODE -**************************************
195 BREAK <SYS - Segment Definition>
196 ;---------------------------------------
197 ; NOTE: Structures used by SYS include:
199 ; find_buf - DTA mapper
201 ; dir_entry - Directory struc
202 ; A_DeviceParameters - IOCtl struc
203 ; BootForm - Boot Rec struc
204 ;---------------------------------------
207 ; INCLUDE DOSSYM.INC ;also defines version of dos
215 ; INCLUDE IOCTL.INC ; Get / Set Device Parameters IOCTL
223 ; INCLUDE BOOTFORM.INC ; Boot Record Structure
230 ; INCLUDE PATHMAC.INC ; PATH macro for PATHGEN
237 IBMJAPVER EQU FALSE ; this and the following are mutually
238 IBMVER EQU TRUE ; exclusive
240 CODE SEGMENT PARA PUBLIC
243 DATA SEGMENT PARA PUBLIC
246 ; $SALUT (4,25,30,41)
247 ;--------------------------------------
249 ;--------------------------------------
251 DOS_low equ 0300h + 20 ; 3 in high reg, 20 in low reg. ;AN023;
252 not_used equ 0 ; filler for INT 21's
253 num_2_letter equ 040h ; turn dirve number to letter
254 dev_local equ 9 ; IOCtl - get device parameters
255 removable equ 01h ; for testing removeability
256 net_drive equ 01000h ; for testing net drive
257 DOS_system_atrib equ 7 ; DOS system file atributes
258 DOS_volume_atrib equ 8 ; DOS volume label atribute
259 error_RC equ 1 ; error return code
260 any_error equ 255 ; mask for detecting errors
261 success equ 0 ; successful completion of SYS
262 LSeek_EOF equ 2 ; seek relative to eof
263 LSeek_Start equ 0 ; seek relative to beginning
264 old_type_media equ 26 ; DOS extended error - old type media
265 file_not_found equ 2 ; DOS extended error - file not found
266 file_spec_length equ 11 ; length of file name
267 empty equ 0 ; empty directory entry
268 deleted equ 0E5h ; entry is deleted
269 SetAtrib equ 01h ; set file attributes
270 set equ 1 ; set file date and time
271 BIG_FAT_THRESHOLD equ 4086 ; size break for FAT12 - FAT16
272 PRELOAD equ 1 ; normal preload
273 return_error equ 1 ; SYS return error code
274 FQ_DOS_DIR_CON_INP equ 07h ; Flush Queue / Direct CON in no echo
275 hard_drive equ 0F8H ; Media Descriptor for Hard drive
276 first_drive equ 80H ; first physical hard drive number
277 noerror equ 0 ; no errors
278 FAT_sect_size equ 12 ; FAT sector count
279 dot equ 02Eh ; Sub DIR DOT
280 bad_sector equ 0F7h ; FAT bad sector mark
281 end_cluster equ 0FFh ; FAT last cluster mark
282 not_found equ 0FFh ; current cluster not yet found
283 cluster_ent_per_sect equ 512/2 ; (bytes/sector) / (bytes/cluster entry)
284 ; = cluster entries / sector
285 clusters_loaded equ cluster_ent_per_sect * FAT_sect_size ; = # of cluster
286 ; entries loaded in 12 sectors.
288 FAT_BUF equ 512 * 13 ; This space is used to do a number
289 ; of tasks. It existes at the START
290 ; of BUF. It is used as a 1 sector
291 ; buffer for processing DIR sector
292 ; manipulation. It is also used to
293 ; process the FAT. NOTE: a 12 bit fat
294 ; has a max. of FFFh (4K) entries - or
295 ; 6K of space - or 12 sectors (512 bytes)
296 ; an extra 512 bytes is added for safety
298 ;----------------------------------------
299 ; definition of the MODE bits
300 ; for an extended open
301 ;----------------------------------------
303 ; BITS DEFINED FOR THE MODE WORD
304 ; FORMAT = 0WF0000CISSS0AAA
305 ; Write ÄÄÄÄÄÄÄÄÄÄÄÙ³ ³³³ ÀÄÄÄ Access code
306 ; 0 = no commit ³ ³³³ 0 = read
307 ; 1 = auto commit ³ ³³³ 1 = write
308 ; ³ ³³³ 2 = read/write
309 ; Fail action ÄÄÄÄÄÄÄÄÄÄÄÄÙ ³³³ 3 = execute
310 ; 0 = INT 24h ³³³ 4 = FCB
311 ; 1 = return error ³³³
312 ; ³³ÀÄÄÄ Sharing mode
313 ; Code Page support ÄÄÄÄÄÄÄÄÙ³ 0 = compatability
314 ; 0 = validate code page ³ 1 = deny read/write
315 ; 1 = no code page check ³ 2 = deny write
319 ; 0 = pass handle to child
322 MODE_COM equ 0100000000000000b ; Auto Commit
323 MODE_NO24 equ 0010000000000000b ; No 24 - return error
324 MODE_NOCP equ 0000000100000000b ; No 24 - return error
325 MODE_NOINH equ 0000000010000000b ; No child procees access
327 ;MODE_SH_COMP equ 0000000000000000b 0 = compatability
328 MODE_SH_D_RW equ 0000000000010000b ; 1 = deny read/write
329 MODE_SH_D_W equ 0000000000100000b ; 2 = deny write
330 MODE_SH_D_R equ 0000000000110000b ; 3 = deny read
331 MODE_SH_D_NONE equ 0000000001000000b ; 4 = deny none
333 ;MODE_AC_R equ 0000000000000000b 0 = read
334 MODE_AC_W equ 0000000000000001b ; 1 = write
335 MODE_AC_RW equ 0000000000000010b ; 2 = read/write
336 MODE_AC_EXE equ 0000000000000011b ; 3 = execute
337 MODE_AC_FCB equ 0000000000000100b ; 4 = FCB
339 open_mode equ MODE_NO24+MODE_NOCP+MODE_NOINH+MODE_SH_D_RW+ MODE_AC_RW
341 ;-------------------------------------------------
342 ; Message Skeleton File
343 ;-------------------------------------------------
349 ;use EXTEND15 ; INVALID DRIVE
353 ;use PARSE1 ;1 - Too many operands
354 ;use PARSE2 ;2 - Required operand missing
355 ;3 - Not in switch list provided
356 ;4 - Not in keyword list provided
357 ;6 - Out of range specified
358 ;7 - Not in value list provided
359 ;8 - Not in string list provided
360 ;use PARSE9 ;9 - Invalid Parameter
368 ;def 7 "No room for system on destination disk",CR,LF ; Old
369 ;def 8 "Ivalid path or System files not found",CR,LF ; New
370 ;use 9 COMMON30 ; System transferred - Old
371 ;def 10 "No system on default drive",CR,LF ; Old
372 ;def 11 "Can not specify default drive",CR,LF ; New
373 ;def 12 "Write failure, diskette unusable",CR,LF ; New
374 ;use 19 COMMON25 ; Invalid path ; New
378 ;use 13 COMMON12 ; Cannot %1 to a Network drive - Old
379 ;def 14 "Insert system disk in drive %1",CR,LF ; Old
380 ;use 15 COMMON19 ; Insert destination disk in drive %1 - Old
381 ;def 16 "Not able to SYS to %1 file system",CR,LF ; New
382 ;use 18 COMMON14 ; Cannot %1 a SUBSTed or ASSIGNed drive - NEW
386 ;use 17 COMMON28 ; Press any key to continue. . . - Old
390 ;----------------------------------------
391 ; Message Number Equates
392 ;----------------------------------------
394 util equ 0ffh ; all Utility messages
395 DOS_error equ 1 ; DOS error CLASS
396 PARSE_error equ 2 ; PARSE error CLASS
397 util_B equ 0bh ; Utility CLASS B messages
399 util_C equ 0ch ; Utility CLASS C messages
401 util_D equ 0dh ; Utility CLASS D messages
403 extended_15 equ 15 ; DOS extended error 15
404 reqd_missing equ 2 ; PARSE error 2
408 no_room equ 7 ; No room for system on destination disk Old
409 system_not_found equ 8 ; Invalid path or System files not found Old
410 done equ 9 ; System transferred Old
411 no_sys_on_def equ 10 ; No system on default drive Old
412 not_on_default equ 11 ; Can not specify default drive New
413 write_fail equ 12 ; Write failure, diskette unusable New
414 bad_path equ 19 ; Invalid path
417 cant_network equ 13 ; Cannot %1 to a Network drive Old
418 sys_disk equ 14 ; Insert system disk in drive %1 Old
419 dest_disk equ 15 ; Insert destination disk in drive %1 Old
420 cant_sys equ 16 ; Not able to SYS to %1 file system New
421 cant_assign equ 18 ; Cannot %1 a SUBSTed or ASSIGNed drive Old
425 press_key equ 17 ; Press any key to continue. . . Change