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 |
|
---|
19 | ;JUMPS
|
---|
20 |
|
---|
21 | ;
|
---|
22 | ; THIS SOURCE IS OBSOLETE AND IS REPLACED BY THE C-EQUIVALENT.
|
---|
23 | ;
|
---|
24 |
|
---|
25 | Include ../../INCLUDE/ASM.INC
|
---|
26 |
|
---|
27 | .386p
|
---|
28 | .model small, basic
|
---|
29 |
|
---|
30 | airboot group code_seg,bss_data
|
---|
31 |
|
---|
32 | code_seg segment public use16
|
---|
33 | ;assume cs:code_seg, ds:code_seg, es:nothing, ss:nothing
|
---|
34 | assume cs:airboot, ds:airboot, es:nothing, ss:nothing
|
---|
35 |
|
---|
36 | org 100h
|
---|
37 | COM_StartUp: jmp COM_Init
|
---|
38 |
|
---|
39 | COM_Copyright db 'AiR-BOOT Installer for DOS v1.0.8', 13, 10
|
---|
40 | db ' - (c) Copyright 2008-2012 by M. Kiewitz.', 13, 10
|
---|
41 | db 13, 10
|
---|
42 | db '-> ...Please wait... <-', 13, 10, 0
|
---|
43 |
|
---|
44 | COM_LoadFile db ' - Loading bootcode from file...', 0
|
---|
45 |
|
---|
46 | COM_ImageName db 'airboot.bin', 0
|
---|
47 |
|
---|
48 | COM_FailedOpen db 'airboot.bin not found', 13, 10, 0
|
---|
49 | COM_FailedRead db 'Read airboot.bin failed', 13, 10, 0
|
---|
50 | COM_FailedRead2 db 'Invalid airboot.bin', 13, 10, 0
|
---|
51 | COM_FailedAlloc db 'Not enough memory!', 13, 10, 0
|
---|
52 |
|
---|
53 | COM_LockFailed db 'Unable to lock harddrive', 13, 10, 0
|
---|
54 |
|
---|
55 | COM_CmdForceCode db 'forcecode'
|
---|
56 | COM_CmdForceCodeLen equ 9
|
---|
57 | COM_CmdForceConfig db 'forceconfig'
|
---|
58 | COM_CmdForceConfigLen equ 11
|
---|
59 | COM_CmdSilent db 'silent'
|
---|
60 | COM_CmdSilentLen equ 6
|
---|
61 |
|
---|
62 | TXT_AfterAdd db 13, 10, 'Please hit ENTER to reboot your system...', 0
|
---|
63 | TXT_AfterDelete:
|
---|
64 | TXT_AfterQuit db 13, 10, 'Please hit ENTER to quit AiR-BOOT Installer for DOS', 0
|
---|
65 |
|
---|
66 | COM_Init: mov ax, cs
|
---|
67 | mov ds, ax
|
---|
68 | mov es, ax ; CS==DS==ES
|
---|
69 | mov si, offset COM_Copyright
|
---|
70 | call APIShowMessage
|
---|
71 |
|
---|
72 | ; Resize our own memory block
|
---|
73 | mov bx, 1000h
|
---|
74 | mov ah, 4Ah
|
---|
75 | int 21h ; DOS: RESIZE MEMORY BLOCK
|
---|
76 |
|
---|
77 | ; We now analyse the commandline...
|
---|
78 | mov ah, 62h
|
---|
79 | int 21h ; GET CURRENT PSP (into BX)
|
---|
80 | push es
|
---|
81 | mov es, bx ; ES points now to PSP-Segment
|
---|
82 | xor dh,dh
|
---|
83 | mov byte ptr dl, es:[80h] ; CX - Length of Command-Line
|
---|
84 | or dx, dx
|
---|
85 | jz COM_CmdLineDone
|
---|
86 | mov cx, dx
|
---|
87 | mov si, 81h
|
---|
88 | COM_CmdLineLowcaseLoop:
|
---|
89 | or bptr [si], 20h
|
---|
90 | inc si
|
---|
91 | dec cx
|
---|
92 | jnz COM_CmdLineLowcaseLoop
|
---|
93 | mov di, 81h ; Start at that position
|
---|
94 | COM_CmdLineLoop:
|
---|
95 | cmp bptr es:[di], '/'
|
---|
96 | jne COM_CmdLineNextChar
|
---|
97 | ; Found a delimiter
|
---|
98 | inc di
|
---|
99 | dec dx
|
---|
100 | jz COM_CmdLineDone
|
---|
101 | mov cx, COM_CmdSilentLen
|
---|
102 | mov si, offset COM_CmdSilent
|
---|
103 | call COM_CheckCmdParm
|
---|
104 | jne COM_CmdLineNextParm
|
---|
105 | mov Option_Silent, 1
|
---|
106 | COM_CmdLineNextParm:
|
---|
107 | mov cx, COM_CmdForceCodeLen
|
---|
108 | mov si, offset COM_CmdForceCode
|
---|
109 | call COM_CheckCmdParm
|
---|
110 | jne COM_CmdLineNextParm2
|
---|
111 | mov Option_ForceCode, 1
|
---|
112 | COM_CmdLineNextParm2:
|
---|
113 | mov cx, COM_CmdForceConfigLen
|
---|
114 | mov si, offset COM_CmdForceConfig
|
---|
115 | call COM_CheckCmdParm
|
---|
116 | jne COM_CmdLineLoop
|
---|
117 | mov Option_ForceConfig, 1
|
---|
118 | jmp COM_CmdLineLoop
|
---|
119 | COM_CmdLineNextChar:
|
---|
120 | inc di
|
---|
121 | dec dx
|
---|
122 | jnz COM_CmdLineLoop
|
---|
123 | jmp COM_CmdLineDone
|
---|
124 |
|
---|
125 | COM_CheckCmdParm:
|
---|
126 | push cx
|
---|
127 | push si
|
---|
128 | push di
|
---|
129 | repe cmpsb
|
---|
130 | pop di
|
---|
131 | pop si
|
---|
132 | pop cx
|
---|
133 | retn
|
---|
134 |
|
---|
135 | COM_CmdLineDone:; Now read airboot.bin into memory at DS:
|
---|
136 | mov si, offset COM_LoadFile
|
---|
137 | call APIShowMessage
|
---|
138 | mov ax, 3D00h
|
---|
139 | mov dx, offset COM_ImageName
|
---|
140 | xor cl, cl
|
---|
141 | int 21h ; DOS: OPEN EXISTING FILE
|
---|
142 | jnc COM_DoneOpen
|
---|
143 | mov si, offset COM_FailedOpen
|
---|
144 | call APIShowError
|
---|
145 |
|
---|
146 | COM_DoneOpen: mov bx, ax ; BX = Filehandle
|
---|
147 |
|
---|
148 | mov ah, 3Fh
|
---|
149 | mov cx, image_size ; Image size
|
---|
150 | mov dx, offset BootImage
|
---|
151 | int 21h ; DOS: READ FILE
|
---|
152 | jnc COM_DoneRead
|
---|
153 | mov si, offset COM_FailedRead
|
---|
154 | call APIShowError
|
---|
155 |
|
---|
156 | COM_DoneRead: cmp ax, image_size
|
---|
157 | je COM_DoneRead2
|
---|
158 | COM_InvalidFile:mov si, offset COM_FailedRead2
|
---|
159 | call APIShowError
|
---|
160 |
|
---|
161 | COM_DoneRead2: mov ah, 3Fh
|
---|
162 | mov cx, 1
|
---|
163 | mov dx, offset BootImage
|
---|
164 | int 21h ; DOS: READ FILE
|
---|
165 | jc COM_DoneRead3
|
---|
166 | or ax, ax
|
---|
167 | jz COM_DoneRead3 ; EOF -> is now expected
|
---|
168 | jmp COM_InvalidFile
|
---|
169 |
|
---|
170 | COM_DoneRead3: mov ah, 3Eh
|
---|
171 | int 21h ; DOS: CLOSE FILE
|
---|
172 |
|
---|
173 | mov si, offset TXT_Okay
|
---|
174 | call APIShowMessage
|
---|
175 |
|
---|
176 | ; And allocate space for reading in track 0 (generic code)
|
---|
177 | mov ah, 48h
|
---|
178 | mov bx, 800h ; 32768 Bytes
|
---|
179 | int 21h ; DOS: ALLOCATE MEMORY
|
---|
180 | jnc COM_DoneAlloc
|
---|
181 | mov si, offset COM_FailedAlloc
|
---|
182 | call APIShowError
|
---|
183 |
|
---|
184 | COM_DoneAlloc: mov es, ax ; ES = memory space for track 0
|
---|
185 | jmp RunInstaller
|
---|
186 |
|
---|
187 | ; =============================================================================
|
---|
188 | APIExitProgram: mov ax, ds
|
---|
189 | mov bx, es
|
---|
190 | cmp ax, bx
|
---|
191 | je AEP_SkipFree
|
---|
192 | mov ah, 49h
|
---|
193 | int 21h ; DOS: FREE MEMORY
|
---|
194 | AEP_SkipFree: mov ax, 4C00h
|
---|
195 | int 21h ; DOS: TERMINATE PROGRAM
|
---|
196 |
|
---|
197 | ; =============================================================================
|
---|
198 | APIAfterAdd: ; Reboot system
|
---|
199 | mov ax, 8600h
|
---|
200 | mov cx, 65
|
---|
201 | xor dx, dx
|
---|
202 | int 15h ; Wait a little bit...
|
---|
203 | db 0EAh ; Jump to eternity
|
---|
204 | dw 0FFF0h
|
---|
205 | dw 0F000h
|
---|
206 |
|
---|
207 | APIAfterDelete:
|
---|
208 | APIAfterQuit: jmp APIExitProgram
|
---|
209 |
|
---|
210 | ; =============================================================================
|
---|
211 | ; DS:SI - NUL-terminated message to display to console
|
---|
212 | APIShowMessage: push ax
|
---|
213 | push dx
|
---|
214 | push si
|
---|
215 | mov ah, 02h
|
---|
216 | ASM_Loop: lodsb
|
---|
217 | or al, al
|
---|
218 | jz ASM_Done
|
---|
219 | mov dl, al
|
---|
220 | int 21h ; DOS: WRITE CHARACTER TO CONSOLE
|
---|
221 | jmp ASM_Loop
|
---|
222 | ASM_Done: pop si
|
---|
223 | pop dx
|
---|
224 | pop ax
|
---|
225 | retn
|
---|
226 |
|
---|
227 | ; =============================================================================
|
---|
228 | APIShowChar: push ax
|
---|
229 | push dx
|
---|
230 | mov ah, 02h
|
---|
231 | mov dl, al
|
---|
232 | int 21h ; DOS: WRITE CHARACTER TO CONSOLE
|
---|
233 | pop dx
|
---|
234 | pop ax
|
---|
235 | retn
|
---|
236 |
|
---|
237 | ; =============================================================================
|
---|
238 | APIShowError: call APIShowMessage
|
---|
239 | call APIExitProgram
|
---|
240 |
|
---|
241 | ; =============================================================================
|
---|
242 | ; Returns AL - Keyboard character that was pressed
|
---|
243 | APIReadKeyboard:mov ah, 07h
|
---|
244 | int 21h ; DOS: DIRECT CONSOLE INPUT
|
---|
245 | ; Result in AL
|
---|
246 | retn
|
---|
247 |
|
---|
248 | APILockVolume: push ax
|
---|
249 | push bx
|
---|
250 | push cx
|
---|
251 | push dx
|
---|
252 | mov ax, 3000h
|
---|
253 | int 21h ; DOS: GET DOS VERSION
|
---|
254 | cmp ax, 0700h
|
---|
255 | jne ALV_SkipLock
|
---|
256 | mov ax, 440Bh
|
---|
257 | mov cx, 084Bh
|
---|
258 | mov bx, 0303h
|
---|
259 | xor dx, dx
|
---|
260 | int 21h ; DOS 7.0: LOCK PHYSICAL DRIVE
|
---|
261 | ALV_SkipLock:
|
---|
262 | pop dx
|
---|
263 | pop cx
|
---|
264 | pop bx
|
---|
265 | pop ax
|
---|
266 | jc ALV_Error
|
---|
267 | retn
|
---|
268 | ALV_Error: mov si, offset COM_LockFailed
|
---|
269 | call APIShowError
|
---|
270 |
|
---|
271 | Include ../INST_X86/INSTALL.INC ; Execute generic code
|
---|
272 | COM_EndOfSegment:
|
---|
273 |
|
---|
274 | code_seg ends
|
---|
275 |
|
---|
276 | bss_data segment public use16 'BSS'
|
---|
277 | ; Space for bootcode-image
|
---|
278 | BootImage db 31744 dup (?)
|
---|
279 | bss_data ends
|
---|
280 |
|
---|
281 | end COM_StartUp
|
---|