summaryrefslogtreecommitdiff
path: root/v4.0/src/BOOT
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/BOOT')
-rw-r--r--v4.0/src/BOOT/BOOT.SKL8
-rw-r--r--v4.0/src/BOOT/MAKEFILE25
-rw-r--r--v4.0/src/BOOT/MSBOOT.ASM530
3 files changed, 563 insertions, 0 deletions
diff --git a/v4.0/src/BOOT/BOOT.SKL b/v4.0/src/BOOT/BOOT.SKL
new file mode 100644
index 0000000..764febd
--- /dev/null
+++ b/v4.0/src/BOOT/BOOT.SKL
@@ -0,0 +1,8 @@
1:class 1
2; MESSAGES FOR THE IBM BOOT SECTOR. NUL Terminated.
3; At this time, for DOS 4.00, we only have maximum 11 bytes left
4; for translation.!!!!!!!!!!!!!!!!!!!!!
5
6:use 001 BOOT SYSMSG
7
8:end
diff --git a/v4.0/src/BOOT/MAKEFILE b/v4.0/src/BOOT/MAKEFILE
new file mode 100644
index 0000000..12ac4d8
--- /dev/null
+++ b/v4.0/src/BOOT/MAKEFILE
@@ -0,0 +1,25 @@
1#******************** makefile for boot *****************************
2
3msg =..\messages
4dos =..\dos
5inc =..\inc
6hinc =..\h
7
8#
9#################### dependencies begin here ############################
10#
11
12all: msboot.bin
13
14boot.cl1: boot.skl \
15 $(msg)\$(COUNTRY).MSG \
16 makefile
17
18msboot.obj: msboot.asm boot.cl1
19
20msboot.bin: msboot.obj
21 link msboot;
22 exe2bin msboot.exe msboot.bin
23 dbof msboot.bin boot.inc 7c00 200
24 copy boot.inc $(inc)
25 del boot.inc
diff --git a/v4.0/src/BOOT/MSBOOT.ASM b/v4.0/src/BOOT/MSBOOT.ASM
new file mode 100644
index 0000000..b2a4103
--- /dev/null
+++ b/v4.0/src/BOOT/MSBOOT.ASM
@@ -0,0 +1,530 @@
1 Page 60,132 ; SCCSID = @(#)msboot.asm 1.1 85/05/13
2TITLE BOOT SECTOR 1 OF TRACK 0 - BOOT LOADER
3
4; Rev 1.0 ChrisP, AaronR and others. 2.0 format boot
5;
6; Rev 3.0 MarkZ PC/AT enhancements
7; 2.50 in label
8; Rev 3.1 MarkZ 3.1 in label due to vagaries of SYSing to IBM drive D's
9; This resulted in the BPB being off by 1. So we now trust
10; 2.0 and 3.1 boot sectors and disbelieve 3.0.
11;
12; Rev 3.2 LeeAc Modify layout of extended BPB for >32M support
13; Move PHYDRV to 3rd byte from end of sector
14; so that it won't have to be moved again
15; FORMAT and SYS count on PHYDRV being in a known location
16;
17; Rev. 3.3 D.C. L. Changed Sec 9 EOT field from 15 to 18. May 29, 1986.
18;
19; Rev 3.31 MarkT The COUNT value has a bogus check (JBE????) to determine
20; if we've loaded in all the sectors of IBMBIO. This will
21; cause too big of a load if the sectors per track is high
22; enough, causing either a stack overflow or the boot code
23; to be overwritten.
24;
25; Rev 4.00 J. K. For DOS 4.00 Modified to handle the extended BPB, and
26; 32 bit sector number calculation to enable the primary
27; partition be started beyond 32 MB boundary.
28;
29;
30; The ROM in the IBM PC starts the boot process by performing a hardware
31; initialization and a verification of all external devices. If all goes
32; well, it will then load from the boot drive the sector from track 0, head 0,
33; sector 1. This sector is placed at physical address 07C00h. The initial
34; registers are set up as follows: CS=DS=ES=SS=0. IP=7C00h, SP=0400H.
35;
36; The code in this sector is responsible for locating the MSDOS device drivers
37; (IBMBIO) and for placing the directory sector with this information at
38; physical address 00500h. After loading in this sector, it reads in the
39; entirety of the BIOS at BIOSEG:0 and does a long jump to that point.
40;
41; If no BIOS/DOS pair is found an error message is displayed and the user is
42; prompted to reinsert another disk. If there is a disk error during the
43; process, a message is displayed and things are halted.
44;
45; At the beginning of the boot sector, there is a table which describes the
46; MSDOS structure of the media. This is equivalent to the BPB with some
47; additional information describing the physical layout of the driver (heads,
48; tracks, sectors)
49;
50;==============================================================================
51;REVISION HISTORY:
52;AN000 - New for DOS Version 4.00 - J.K.
53;AC000 - Changed for DOS Version 4.00 - J.K.
54;AN00x - PTM number for DOS Version 4.00 - J.K.
55;==============================================================================
56;AN001; d52 Make the fixed positioned variable "CURHD" to be local. 7/6/87 J.K.
57;AN002; d48 Change head settle at boot time. 7/7/87 J.K.
58;AN003; P1820 New message SKL file 10/20/87 J.K.
59;AN004; D304 New structrue of Boot record for OS2. 11/09/87 J.K.
60;==============================================================================
61
62ORIGIN EQU 7C00H ; Origin of bootstrap LOADER
63BIOSEG EQU 70H ; destingation segment of BIOS
64BioOff EQU 700H ; offset of bios
65cbSec EQU 512
66cbDirEnt EQU 32
67DirOff EQU 500h
68IBMLOADSIZE equ 3 ;J.K. Size of IBMLOAD module in sectors
69ROM_DISKRD equ 2
70include version.inc
71
72;
73; Define the destination segment of the BIOS, including the initialization
74; label
75;
76SEGBIOS SEGMENT AT BIOSEG
77BIOS LABEL BYTE
78SEGBIOS ENDS
79
80CODE SEGMENT
81 ASSUME CS:CODE,DS:NOTHING,ES:NOTHING,SS:NOTHING
82
83; ORG DirOff + 1Ch
84;BiosFS LABEL WORD
85
86 ORG ORIGIN
87
88DSKADR = 1EH*4 ;POINTER TO DRIVE PARAMETERS
89
90Public $START
91$START:
92 JMP START
93;----------------------------------------------------------
94;
95; THE FOLLOWING DATA CONFIGURES THE BOOT PROGRAM
96; FOR ANY TYPE OF DRIVE OR HARDFILE
97;
98;J.K. Extened_BPB
99
100if ibmcopyright
101 DB "IBM "
102else
103 DB "MSDOS"
104endif
105 DB "4.0" ;AN005;
106ByteSec DW cbSec ; SIZE OF A PHYSICAL SECTOR
107 DB 8 ; SECTORS PER ALLOCATION UNIT
108cSecRes DW 1 ; NUMBER OF RESERVED SECTORS
109cFat DB 2 ; NUMBER OF FATS
110DirNum DW 512 ; NUMBER OF DIREC ENTRIES
111cTotSec DW 4*17*305-1 ; NUMBER OF SECTORS - NUMBER OF HIDDEN SECTORS
112 ; (0 when 32 bit sector number)
113MEDIA DB 0F8H ; MEDIA BYTE
114cSecFat DW 8 ; NUMBER OF FAT SECTORS
115SECLIM DW 17 ; SECTORS PER TRACK
116HDLIM DW 4 ; NUMBER OF SURFACES
117Ext_cSecHid label dword
118cSecHid_L DW 1 ;AN000; NUMBER OF HIDDEN SECTORS
119cSecHid_H dw 0 ;AN000; high order word of Hiden Sectors
120Ext_cTotSec label dword
121ctotsec_L dw 0 ;AN000; 32 bit version of NUMBER OF SECTORS
122ctotsec_H dw 0 ;AN000; (when 16 bit version is zero)
123;
124Phydrv db 80h ;AN004;
125Curhd db 0h ;AN004; Current Head
126Ext_Boot_Sig db 41 ;AN000;
127Boot_Serial dd 0 ;AN000;
128Boot_Vol_Label db 'NO NAME ' ;AN000;
129Boot_System_id db 'FAT12 ' ;AN000;
130
131;J.K. Danger!!! If not 32 bit sector number calculation, FORMAT should
132;set the value of cSecHid_h and Ext_cTotSec to 0 !!!
133;
134
135;
136Public UDATA
137UDATA LABEL byte
138Sec9 equ byte ptr UDATA+0 ;11 byte diskette parm. table
139BIOS$_L EQU WORD PTR UDATA+11
140BIOS$_H equ word ptr UDATA+13 ;AN000;
141CURTRK EQU WORD PTR UDATA+15
142CURSEC EQU BYTE PTR UDATA+17
143DIR$_L EQU WORD PTR UDATA+18
144Dir$_H equ word ptr UDATA+20 ;AN000;
145START:
146
147;
148; First thing is to reset the stack to a better and more known place. The ROM
149; may change, but we'd like to get the stack in the correct place.
150;
151 CLI ;Stop interrupts till stack ok
152 XOR AX,AX
153 MOV SS,AX ;Work in stack just below this routine
154 ASSUME SS:CODE
155 MOV SP,ORIGIN
156 PUSH SS
157 POP ES
158 ASSUME ES:CODE
159;
160; We copy the disk parameter table into a local area. We scan the table above
161; for non-zero parameters. Any we see get changed to their non-zero values.
162;
163;J.K. We copy the disk parameter table into a local area (overlayed into the
164;code), and set the head settle time to 1, and End of Track to SECLIM given
165;by FORMAT.
166
167 MOV BX,DSKADR
168 LDS SI,DWORD PTR SS:[BX] ; get address of disk table
169 PUSH DS ; save original vector for possible
170 PUSH SI ; restore
171 PUSH SS
172 PUSH BX
173 MOV DI,offset Sec9
174 MOV CX,11
175 CLD
176if $ le BIOS$_L
177 %OUT Don't destroy unexcuted code yet!!!
178endif
179 repz movsb ;AN000;
180 push es ;AN000;
181 pop ds ;AN000; DS = ES = code = 0.
182 assume ds:code ;AN000;
183; mov byte ptr [di-2], 1 ;AN000; Head settle time
184;J.K. Change the head settle to 15 ms will slow the boot time quite a bit!!!
185 mov byte ptr [di-2], 0fh ;AN002; Head settle time
186 mov cx, SECLIM ;AN004;
187 mov byte ptr [di-7], cl ;AN000; End of Track
188;
189; Place in new disk parameter table vector.
190;
191 MOV [BX+2],AX
192 MOV [BX],offset SEC9
193;
194; We may now turn interrupts back on. Before this, there is a small window
195; when a reboot command may come in when the disk parameter table is garbage
196;
197 STI ;Interrupts OK now
198;
199; Reset the disk system just in case any thing funny has happened.
200;
201 INT 13H ;Reset the system
202; JC RERROR
203 jc CKErr ;AN000;
204;
205; The system is now prepared for us to begin reading. First, determine
206; logical sector numbers of the start of the directory and the start of the
207; data area.
208
209 xor ax,ax ;AN000;
210 cmp cTotSec,ax ;AN000; 32 bit calculation?
211 je Dir_Cont ;AN000;
212 mov cx,cTotSec ;AN000;
213 mov cTotSec_L,cx ;AN000; cTotSec_L,cTotSec_H will be used for calculation
214Dir_Cont: ;AN000;
215 MOV AL,cFat ;Determine sector dir starts on
216 MUL cSecFat ;DX;AX
217 ADD AX,cSecHid_L
218 adc DX,cSecHid_H ;AN000;
219 ADD AX,cSecRes
220 ADC DX,0
221 MOV [DIR$_L],AX ; DX;AX = cFat*cSecFat + cSecRes + cSecHid
222 mov [DIR$_H],DX ;AN000;
223 MOV [BIOS$_L],AX
224 mov [BIOS$_H],DX ;AN000;
225;
226; Take into account size of directory (only know number of directory entries)
227;
228 MOV AX,cbDirEnt ; bytes per directory entry
229 MUL DirNum ; convert to bytes in directory
230 MOV BX,ByteSec ; add in sector size
231 ADD AX,BX
232 DEC AX ; decrement so that we round up
233 DIV BX ; convert to sector number
234 ADD [BIOS$_L],AX ; Start sector # of Data area
235 adc [BIOS$_H],0 ;AN000;
236
237;
238; We load in the first directory sector and examine it to make sure the the
239; BIOS and DOS are the first two directory entries. If they are not found,
240; the user is prompted to insert a new disk. The directory sector is loaded
241; into 00500h
242;
243 MOV BX,DirOff ; sector to go in at 00500h
244 mov dx,[DIR$_H] ;AN000;
245 MOV AX,[DIR$_L] ; logical sector of directory
246 CALL DODIV ; convert to sector, track, head
247 jc CKErr ;AN000; Overflow? BPB must be wrong!!
248; MOV AX,0201H ; disk read 1 sector
249 mov al, 1 ;AN000; disk read 1 sector
250 CALL DOCALL ; do the disk read
251 JB CKERR ; if errors try to recover
252;
253; Now we scan for the presence of IBMBIO COM and IBMDOS COM. Check the
254; first directory entry.
255;
256 MOV DI,BX
257 MOV CX,11
258 MOV SI,OFFSET BIO ; point to "ibmbio com"
259 REPZ CMPSB ; see if the same
260 JNZ CKERR ; if not there advise the user
261;
262; Found the BIOS. Check the second directory entry.
263;
264 LEA DI,[BX+20h]
265 MOV SI,OFFSET DOS ; point to "ibmdos com"
266 MOV CX,11
267 REPZ CMPSB
268 JZ DoLoad
269
270;
271; There has been some recoverable error. Display a message and wait for a
272; keystroke.
273;
274CKERR: MOV SI,OFFSET SYSMSG ; point to no system message
275ErrOut: CALL WRITE ; and write on the screen
276 XOR AH,AH ; wait for response
277 INT 16H ; get character from keyboard
278 POP SI ; reset disk parameter table back to
279 POP DS ; rom
280 POP [SI]
281 POP [SI+2]
282 INT 19h ; Continue in loop till good disk
283
284Load_Failure:
285 pop ax ;adjust the stack
286 pop ax
287 pop ax
288 jmp short Ckerr ;display message and reboot.
289
290;J.K. We don't have the following error message any more!!!
291;J.K. Sysmsg is fine. This will save space by eliminating DMSSG message.
292;RERROR: MOV SI,OFFSET DMSSG ; DISK ERROR MESSAGE
293; JMP ErrOut
294
295;
296; We now begin to load the BIOS in. Compute the number of sectors needed.
297; J.K. All we have to do is just read in sectors contiguously IBMLOADSIZE
298; J.K. times. We here assume that IBMLOAD module is contiguous. Currently
299; J.K. we estimate that IBMLOAD module will not be more than 3 sectors.
300
301DoLoad:
302 mov BX,BioOff ;offset of ibmbio(IBMLOAD) to be loaded.
303 mov CX,IBMLOADSIZE ;# of sectors to read.
304 mov AX, [BIOS$_L] ;Sector number to read.
305 mov DX, [BIOS$_H] ;AN000;
306Do_While: ;AN000;
307 push AX ;AN000;
308 push DX ;AN000;
309 push CX ;AN000;
310 call DODIV ;AN000; DX;AX = sector number.
311 jc Load_Failure ;AN000; Adjust stack. Show error message
312 mov al, 1 ;AN000; Read 1 sector at a time.
313 ;This is to handle a case of media
314 ;when the first sector of IBMLOAD is the
315 ;the last sector in a track.
316 call DOCALL ;AN000; Read the sector.
317 pop CX ;AN000;
318 pop DX ;AN000;
319 pop AX ;AN000;
320 jc CkErr ;AN000; Read error?
321 add AX,1 ;AN000; Next sector number.
322 adc DX,0 ;AN000;
323 add BX,ByteSec ;AN000; adjust buffer address.
324 loop Do_While ;AN000;
325
326
327; MOV AX,BiosFS ; get file size
328; XOR DX,DX ; presume < 64K
329; DIV ByteSec ; convert to sectors
330; INC AL ; reading in one more can't hurt
331; MOV COUNT,AL ; Store running count
332; MOV AX,BIOS$ ; get logical sector of beginning of BIOS
333; MOV BIOSAV,AX ; store away for real bios later
334; MOV BX,BioOff ; Load address from BIOSSEG
335;
336; Main read-in loop.
337; ES:BX points to area to read.
338; Count is the number of sectors remaining.
339; BIOS$ is the next logical sector number to read
340;
341;LOOPRD:
342; MOV AX,BIOS$ ; Starting sector
343; CALL DODIV
344;
345; CurHD is the head for this next disk request
346; CurTrk is the track for this next request
347; CurSec is the beginning sector number for this request
348;
349; Compute the number of sectors that we may be able to read in a single ROM
350; request.
351;
352; MOV AX,SECLIM
353; SUB AL,CURSEC
354; INC AX
355;
356; AX is the number of sectors that we may read.
357;
358
359;
360;New code for Rev 3.31
361;*****************************************************************************
362
363; CMP COUNT,AL ;Is sectors we can read more than we need?
364; JAE GOT_SECTORS ;No, it is okay
365; MOV AL,COUNT ;Yes, only read in what is left
366
367;GOT_SECTORS:
368
369;*****************************************************************************
370;End of change
371;
372
373
374; PUSH AX
375; CALL DOCALL
376; POP AX
377; JB RERROR ; If errors report and go to ROM BASIC
378; SUB COUNT,AL ; Are we finished?
379;
380;Old code replaced by Rev 3.3
381;********************************************************************
382; JBE DISKOK ; Yes -- transfer control to the DOS
383;********************************************************************
384;New code for Rev 3.3
385;
386
387; JZ DISKOK ; Yes -- transfer control to the DOS
388
389;********************************************************************
390;End of change
391;
392; ADD BIOS$,AX ; increment logical sector position
393; MUL ByteSec ; determine next offset for read
394; ADD BX,AX ; (BX)=(BX)+(SI)*(Bytes per sector)
395; JMP LOOPRD ; Get next track
396;
397; IBMINIT requires the following input conditions:
398;
399; DL = INT 13 drive number we booted from
400; CH = media byte
401;J.K.I1. BX was the First data sector on disk (0-based)
402;J.K.I1. IBMBIO init routine should check if the boot record is the
403;J.K.I1. extended one by looking at the extended_boot_signature.
404;J.K.I1. If it is, then should us AX;BX for the starting data sector number.
405
406DISKOK:
407 MOV CH,Media
408 MOV DL,PhyDrv
409 MOV bx,[BIOS$_L] ;AN000; J.K.I1.Get bios sector in bx
410 mov ax,[BIOS$_H] ;AN000; J.K.I1.
411 JMP FAR PTR BIOS ;CRANK UP THE DOS
412
413WRITE: LODSB ;GET NEXT CHARACTER
414 OR AL,AL ;clear the high bit
415 JZ ENDWR ;ERROR MESSAGE UP, JUMP TO BASIC
416 MOV AH,14 ;WILL WRITE CHARACTER & ATTRIBUTE
417 MOV BX,7 ;ATTRIBUTE
418 INT 10H ;PRINT THE CHARACTER
419 JMP WRITE
420
421; convert a logical sector into Track/sector/head. AX has the logical
422; sector number
423; J.K. DX;AX has the sector number. Because of not enough space, we are
424; going to use Simple 32 bit division here.
425; Carry set if DX;AX is too big to handle.
426;
427
428DODIV:
429 cmp dx,Seclim ;AN000; To prevent overflow!!!
430 jae DivOverFlow ;AN000; Compare high word with the divisor.
431 DIV SECLIM ;AX = Total tracks, DX = sector number
432 INC DL ;Since we assume SecLim < 255 (a byte), DH =0.
433 ;Cursec is 1-based.
434 MOV CURSEC, DL ;save it
435 XOR DX,DX
436 DIV HDLIM
437 MOV CURHD,DL ;Also, Hdlim < 255.
438 MOV CURTRK,AX
439 clc ;AN000;
440 ret ;AN000;
441DivOverFlow: ;AN000;
442 stc ;AN000;
443EndWR:
444 ret
445
446;
447;J.K.We don't have space for the following full 32 bit division.
448; convert a logical sector into Track/sector/head. AX has the logical
449; sector number
450; J.K. DX;AX has the sector number.
451;DODIV:
452; push ax
453; mov ax,dx
454; xor dx,dx
455; div SecLim
456; mov Temp_H,ax
457; pop ax
458; div SecLim ;J.K.Temp_H;AX = total tracks, DX=sector
459; INC DL ;Since we assume SecLim < 255 (a byte), DH =0.
460; ;Cursec is 1-based.
461; MOV CURSEC, DL ;save it
462; push ax
463; mov ax,Temp_H
464; XOR DX,DX
465; DIV HDLIM
466; mov Temp_H,ax
467; pop ax
468; div HdLim ;J.K.Temp_H;AX=total cyliners,DX=head
469; MOV CURHD,DL ;Also, Hdlim < 255.
470; cmp Temp_H,0
471; ja TooBigToHandle
472; cmp ax, 1024
473; ja TooBigToHandle
474; MOV CURTRK,AX
475;ENDWR: RET
476;TooBigToHandle:
477; stc
478; ret
479
480;
481; Issue one read request. ES:BX have the transfer address, AL is the number
482; of sectors.
483;
484DOCALL: MOV AH,ROM_DISKRD ;AC000;=2
485 MOV DX,CURTRK
486 MOV CL,6
487 SHL DH,CL
488 OR DH,CURSEC
489 MOV CX,DX
490 XCHG CH,CL
491 MOV DL, PHYDRV
492 mov dh, curhd
493 INT 13H
494 RET
495
496; include ibmbtmes.inc
497 include boot.cl1 ;AN003;
498
499
500 IF IBMCOPYRIGHT
501BIO DB "IBMBIO COM"
502DOS DB "IBMDOS COM"
503 ELSE
504BIO DB "IO SYS"
505DOS DB "MSDOS SYS"
506 ENDIF
507
508Free EQU (cbSec - 4) - ($-$start) ;AC000;
509;Free EQU (cbSec - 5) - ($-$start)
510if Free LT 0
511 %out FATAL PROBLEM:boot sector is too large
512endif
513
514 org origin + (cbSec - 2) ;AN004;
515; org origin + (cbSec - 5)
516
517;Warning!! Do not change the position of following unless
518;Warning!! you change BOOTFORM.INC (in COMMON subdirectory) file.
519;Format should set this EOT value for IBMBOOT.
520;FEOT db 12h ;AN000; set by FORMAT. AN004;Use SecLim in BPB instead.
521; FORMAT and SYS count on CURHD,PHYDRV being right here
522;J.K. CURHD has been deleted since it is not being used by anybody.
523;CURHD DB ? ;AN001;Unitialized (J.K. Maybe don't need this).
524;PHYDRV db 0 ;AN000;moved into the header part.
525; Boot sector signature
526 db 55h,0aah
527
528CODE ENDS
529 END
530 \ No newline at end of file