source: trunk/install/floppy/makedisk.asm@ 63

Last change on this file since 63 was 57, checked in by Ben Rietbroek, 10 years ago

All source-files lowercased [v1.1.1-testing]

Some standard files like 'COPYING', 'LICENSE', etc. have not been
converted to lower case because they are usually distributed uppercased.

File size: 10.9 KB
Line 
1; AiR-BOOT (c) Copyright 1998-2009 M. Kiewitz
2;
3; This file is part of AiR-BOOT
4;
5; AiR-BOOT is free software: you can redistribute it and/or modify it under
6; the terms of the GNU General Public License as published by the Free
7; Software Foundation, either version 3 of the License, or (at your option)
8; any later version.
9;
10; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
11; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
12; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13; details.
14;
15; You should have received a copy of the GNU General Public License along with
16; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
17;
18
19JUMPS
20
21include ..\..\include\asm.inc
22
23 .386p
24 model large, basic
25
26code_seg segment public use16
27 assume cs:code_seg, ds:nothing, es:nothing, ss:nothing
28 org 100h
29AiRBOOTMakeDisk:jmp MakeDisk_Start
30
31TXT_Intro: db 'AiR-BOOT DOS Install-Disc Maker - (c) 2002-2009 by M. Kiewitz', 13, 10
32 db ' uses FreeDOS bootrecord (c) 1997 by Svante Frey', 13, 10
33 db 13, 10
34 db 'This program will generate an install-bootdisc, so AiR-BOOT can be installed',13,10
35 db 'for any OS, like many of them do not allow direct harddisc access.',13,10
36 db 13,10
37 db 'Please note: The floppy needs to be already formated using FAT.', 13, 10
38 db ' The file kernel.sys will get created.',13,10
39 db 13,10
40 db 'Please insert a floppy-disc into drive A: and hit ENTER...',13,10
41 db ' ...any other key will abort this program... $'
42
43TXT_Abort: db 'Program aborted!', 13, 10, '$'
44
45TXT_ReadingFloppy:
46 db ' þ Reading floppy bootrecord...', '$'
47TXT_FloppyNoFAT:db ' This floppy is not formated using FAT filesystem.', 13, 10, '$'
48TXT_WritingFloppy:
49 db ' þ Writing floppy bootrecord...', '$'
50
51TXT_ReadingBootcode:
52 db ' þ Reading bootcode...', '$'
53TXT_FailedOpenBootCode:
54 db 'airboot.bin not found!', 13, 10, '$'
55TXT_FailedReadBootCode:
56 db 'could not read airboot.bin', 13, 10, '$'
57TXT_InvalidBootCode:
58 db 'invalid airboot.bin', 13, 10, '$'
59
60TXT_WritingData:db ' þ Writing data to floppy...', '$'
61
62TXT_FailedOpenKernelSys:
63 db 'could not create a:\kernel.sys', 13, 10, '$'
64TXT_FailedWriteKernelSys:
65 db 'could not write a:\kernel.sys', 13, 10, '$'
66
67TXT_Okay: db 'ok', 13, 10, '$'
68
69TXT_ReadError: db 'LOAD ERROR!', 13, 10
70 db ' Try a different floppy or No floppy in drive', 13, 10, '$'
71TXT_WriteError: db 'WRITE ERROR!', 13, 10
72 db ' Try a different floppy', 13, 10, '$'
73TXT_Done: db 'Please activate write-protection on this disc!',13,10,'$'
74
75AiRBOOTVolume db 'AiRBOOT '
76
77BootCodeFile db 'airboot.bin', 0
78
79KernelSysFile db 'a:\kernel.sys', 0
80
81RetryCount db 0
82
83APIShowMessage: mov ah, 09
84 int 21h ; DIRECT CONSOLE STRING OUTPUT
85 retn
86APIShowError: mov ah, 09
87 int 21h ; DIRECT CONSOLE STRING OUTPUT
88 jmp GoByeBye
89
90MakeDisk_Start: mov ax, cs
91 mov ds, ax
92 mov es, ax ; DS==ES==CS
93 mov dx, offset TXT_Intro
94 call APIShowMessage
95
96 mov ah, 07h
97 int 21h ; DIRECT CONSOLE INPUT
98 cmp al, 13
99 je GoGoCreate
100 mov dx, offset TXT_Abort
101 call APIShowError
102
103 ; Now at first load first sector of floppy into memory...
104GoGoCreate: mov ah, 06h
105 mov dl, 13
106 int 21h ; DIRECT CONSOLE OUTPUT
107 mov dl, 10
108 int 21h ; DIRECT CONSOLE OUTPUT
109
110 mov dx, offset TXT_ReadingFloppy
111 call APIShowMessage
112
113 ; First we read the 1st sector of the floppy...
114 mov RetryCount, 3
115 mov bx, offset FloppyBootRecord
116ReadFloppy: mov cx, 0001h ; Cylinder 0, Sector 1
117 xor dx, dx ; Disc 0 (floppy), Head 0
118 mov ax, 0201h
119 int 13h ; BIOS - LOAD ONE SECTOR
120 jnc ReadFloppyDone
121 cmp ah, 9 ; DMA Boundary problem?
122 jne NoDMAboundary
123 mov bx, offset FloppyBootRecord2
124NoDMAboundary: xor ah, ah
125 int 13h ; BIOS - RESET DISC
126 dec RetryCount
127 jnz ReadFloppy
128 mov dx, offset TXT_ReadError
129 call APIShowError
130
131ReadFloppyDone: push bx
132 push dx
133 mov dx, offset TXT_Okay
134 call APIShowMessage
135 pop dx
136 pop bx
137 ; Check, if floppy is formated using FAT
138 mov si, bx
139 add si, 54
140 cmp wptr [si], 'AF'
141 jne FloppyNoFAT
142 cmp bptr [si+2], 'T'
143 je FloppyIsFAT ; Some have 'FAT' some have 'FAT12'
144FloppyNoFAT: mov dx, offset TXT_FloppyNoFAT
145 call APIShowError
146
147FloppyIsFAT: push bx
148 push cx
149 push dx
150 mov dx, offset TXT_WritingFloppy
151 call APIShowMessage
152 mov di, bx
153 mov si, offset FreeDOSBootRecord
154 mov cx, 3
155 rep movsb ; Copy first 3 bytes of FreeDOS BR
156 add si, 40
157 add di, 40
158 mov cx, 11
159 rep movsb ; Copy over volume label ('AiRBOOT')
160 add si, 8
161 add di, 8
162 mov cx, 450/2 ; Copy rest of FreeDOS BR
163 rep movsw
164 pop dx
165 pop cx
166 pop bx
167 ; Now we write it back...
168 mov ax, 0301h
169 int 13h ; BIOS - WRITE ONE SECTOR
170 jnc WriteFloppyDone
171 mov dx, offset TXT_WriteError
172 call APIShowError
173
174WriteFloppyDone:mov dx, offset TXT_Okay
175 call APIShowMessage
176
177 ; Now we create kernel.sys on the floppy and that's it
178 ; kernel.sys is actually kernel.com (KernelSys label) and
179 ; airboot.bin appended afterwards
180
181 mov dx, offset TXT_ReadingBootcode
182 call APIShowMessage
183
184 mov ax, 3D00h
185 mov dx, offset BootCodeFile
186 xor cl, cl
187 int 21h ; DOS: OPEN EXISTING FILE
188 jnc DoneOpenBootCode
189 mov dx, offset TXT_FailedOpenBootCode
190 call APIShowError
191
192DoneOpenBootCode:
193 mov bx, ax ; BX = Filehandle
194 mov ah, 3Fh
195 mov cx, 30720 ; Image size
196 mov dx, offset BootCodeImage
197 int 21h ; DOS: READ FILE
198 jnc DoneReadBootCode
199 mov dx, offset TXT_FailedReadBootCode
200 call APIShowError
201
202DoneReadBootCode:
203 cmp ax, 30720
204 je DoneReadBootCode2
205InvalidBootCode:mov dx, offset TXT_InvalidBootCode
206 call APIShowError
207
208DoneReadBootCode2:
209 mov ah, 3Fh
210 mov cx, 1
211 mov dx, offset BootCodeImage
212 int 21h ; DOS: READ FILE
213 jc DoneReadBootCode3
214 or ax, ax
215 jz DoneReadBootCode3 ; EOF -> is now expected
216 jmp InvalidBootCode
217
218DoneReadBootCode3:
219 mov ah, 3Eh
220 int 21h ; DOS: CLOSE FILE
221 mov dx, offset TXT_Okay
222 call APIShowMessage
223
224 ; Now create a:\kernel.sys
225 mov dx, offset TXT_WritingData
226 call APIShowMessage
227
228 mov ax, 3C02h
229 mov dx, offset KernelSysFile
230 xor cl, cl
231 int 21h ; DOS: CREATE/TRUNCATE FILE
232 jnc DoneOpenKernelSys
233 mov dx, offset TXT_FailedOpenKernelSys
234 call APIShowMessage
235
236DoneOpenKernelSys:
237 mov bx, ax ; BX = Filehandle
238
239 mov ah, 40h
240 mov cx, 4280 ; kernel.com size
241 mov dx, offset KernelSys
242 int 21h ; DOS: WRITE FILE
243 jnc DoneWriteKernelSys1
244FailedWriteKernelSys:
245 mov dx, offset TXT_FailedWriteKernelSys
246 call APIShowError
247DoneWriteKernelSys1:
248 cmp ax, 4280
249 jne FailedWriteKernelSys
250
251 mov ah, 40h
252 mov cx, 30720 ; Bootcode image size
253 mov dx, offset BootCodeImage
254 int 21h ; DOS: WRITE FILE
255 jc FailedWriteKernelSys
256 cmp ax, 30720
257 jne FailedWriteKernelSys
258
259 mov ah, 3Eh
260 int 21h ; DOS: CLOSE FILE
261
262 mov dx, offset TXT_Okay
263 call APIShowMessage
264 mov dx, offset TXT_Done
265 call APIShowMessage
266
267 ; Terminate ourselves...
268GoByeBye: mov ax, 4C00h
269 int 21h ; Terminate us...
270
271; Uninitialized variables come here...
272; Attention: FreeDOS and kernel-code need to come here first because we will
273; append them to makedisk.com. Also if you change kernel-code,
274; you will need to adjust length accordingly
275FreeDOSBootRecord:
276 db 512 dup(?)
277KernelSys: db 4280 dup(?)
278
279FloppyBootRecord: db 512 dup (?)
280FloppyBootRecord2: db 512 dup (?)
281
282BootCodeImage: db 30720 dup (?)
283
284
285code_seg ends
286 end AiRBOOTMakeDisk
Note: See TracBrowser for help on using the repository browser.