|
;; $Id: ui.inc,v 1.1 2007-09-01 22:44:05 niro Exp $ |
|
1 |
;; ----------------------------------------------------------------------- |
;; ----------------------------------------------------------------------- |
2 |
;; |
;; |
3 |
;; Copyright 1994-2005 H. Peter Anvin - All Rights Reserved |
;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 |
|
;; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin |
5 |
;; |
;; |
6 |
;; This program is free software; you can redistribute it and/or modify |
;; This program is free software; you can redistribute it and/or modify |
7 |
;; it under the terms of the GNU General Public License as published by |
;; it under the terms of the GNU General Public License as published by |
14 |
; |
; |
15 |
; This file should be entered with the config file open (for getc) |
; This file should be entered with the config file open (for getc) |
16 |
; |
; |
17 |
|
load_config_file: |
18 |
call parse_config ; Parse configuration file |
call parse_config ; Parse configuration file |
19 |
no_config_file: |
no_config_file: |
20 |
|
|
21 |
|
call adv_init |
22 |
|
; |
23 |
|
; Check for an ADV boot-once entry |
24 |
|
; |
25 |
|
mov dl,ADV_BOOTONCE |
26 |
|
call adv_get |
27 |
|
jcxz .no_bootonce |
28 |
|
|
29 |
|
.have_bootone: |
30 |
|
; We apparently have a boot-once set; clear it and |
31 |
|
; then execute the boot-once... |
32 |
|
|
33 |
|
; Save the boot-once data; SI = data, CX = length |
34 |
|
mov di,command_line |
35 |
|
rep movsb |
36 |
|
xor ax,ax |
37 |
|
stosb |
38 |
|
|
39 |
|
; Clear the boot-once data from the ADV |
40 |
|
xor cx,cx ; Set to zero = delete |
41 |
|
call adv_set |
42 |
|
jc .err |
43 |
|
call adv_write |
44 |
|
.err: jmp load_kernel |
45 |
|
|
46 |
|
.no_bootonce: |
47 |
|
|
48 |
; |
; |
49 |
; Check whether or not we are supposed to display the boot prompt. |
; Check whether or not we are supposed to display the boot prompt. |
50 |
; |
; |
51 |
check_for_key: |
check_for_key: |
|
cmp word [ForcePrompt],0 ; Force prompt? |
|
|
jnz enter_command |
|
52 |
test byte [KbdFlags],5Bh ; Shift Alt Caps Scroll |
test byte [KbdFlags],5Bh ; Shift Alt Caps Scroll |
53 |
jz auto_boot ; If neither, default boot |
jnz enter_command |
54 |
|
cmp word [ForcePrompt],0 ; Force prompt? |
55 |
|
jz auto_boot |
56 |
|
cmp word [DefaultLevel],1 ; Active UI statement? |
57 |
|
ja auto_boot |
58 |
|
|
59 |
enter_command: |
enter_command: |
60 |
cmp word [NoEscape],0 ; If NOESCAPE, no prompt, |
cmp word [NoEscape],0 ; If NOESCAPE, no prompt, |
61 |
jne auto_boot ; always run default cmd |
jne auto_boot ; always run default cmd |
62 |
|
|
63 |
mov si,boot_prompt |
mov si,boot_prompt |
64 |
call cwritestr |
call writestr |
65 |
|
|
66 |
mov byte [FuncFlag],0 ; <Ctrl-F> not pressed |
mov byte [FuncFlag],0 ; <Ctrl-F> not pressed |
67 |
mov di,command_line |
mov di,command_line |
102 |
cmp di,command_line ; Space must not be first |
cmp di,command_line ; Space must not be first |
103 |
je short get_char |
je short get_char |
104 |
enter_char: test byte [FuncFlag],1 |
enter_char: test byte [FuncFlag],1 |
105 |
jz .not_ctrl_f |
jnz ctrl_f ; Keystroke after <Ctrl-F> |
106 |
mov byte [FuncFlag],0 |
cmp di,max_cmd_len+command_line ; Check there's space |
|
cmp al,'0' |
|
|
jb .not_ctrl_f |
|
|
je ctrl_f_0 |
|
|
cmp al,'9' |
|
|
jbe ctrl_f |
|
|
.not_ctrl_f: cmp di,max_cmd_len+command_line ; Check there's space |
|
107 |
jnb short get_char |
jnb short get_char |
108 |
stosb ; Save it |
stosb ; Save it |
109 |
call writechr ; Echo to screen |
call writechr ; Echo to screen |
110 |
jmp short get_char |
jmp short get_char |
111 |
not_ascii: mov byte [FuncFlag],0 |
not_ascii: |
112 |
cmp al,0Dh ; Enter |
cmp al,0Dh ; Enter |
113 |
je command_done |
je command_done |
114 |
|
cmp al,09h ; Tab |
115 |
|
je display_labels |
116 |
cmp al,'F' & 1Fh ; <Ctrl-F> |
cmp al,'F' & 1Fh ; <Ctrl-F> |
117 |
je set_func_flag |
je set_func_flag |
118 |
|
%if IS_PXELINUX |
119 |
|
cmp al,'N' & 1Fh ; <Ctrl-N> |
120 |
|
je show_network_info |
121 |
|
%endif |
122 |
cmp al,'U' & 1Fh ; <Ctrl-U> |
cmp al,'U' & 1Fh ; <Ctrl-U> |
123 |
je kill_command ; Kill input line |
je kill_command ; Kill input line |
124 |
cmp al,'V' & 1Fh ; <Ctrl-V> |
cmp al,'V' & 1Fh ; <Ctrl-V> |
131 |
je get_char ; to erase |
je get_char ; to erase |
132 |
dec di ; Unstore one character |
dec di ; Unstore one character |
133 |
mov si,wipe_char ; and erase it from the screen |
mov si,wipe_char ; and erase it from the screen |
134 |
call cwritestr |
call writestr |
135 |
jmp short get_char_2 |
get_char_2: |
136 |
|
jmp short get_char |
137 |
|
|
138 |
kill_command: |
kill_command: |
139 |
call crlf |
call crlf |
145 |
|
|
146 |
set_func_flag: |
set_func_flag: |
147 |
mov byte [FuncFlag],1 |
mov byte [FuncFlag],1 |
148 |
get_char_2: |
jmp short get_char_2 |
149 |
jmp short get_char |
|
150 |
|
display_labels: |
151 |
|
cmp word [NoComplete],0 ; Label completion enabled? |
152 |
|
jne get_char_2 |
153 |
|
push di ; Save pointer |
154 |
|
mov cx,di |
155 |
|
sub cx,command_line |
156 |
|
call crlf |
157 |
|
mov esi,[HighMemSize] ; Start from top of memory |
158 |
|
.scan: |
159 |
|
cmp esi,[VKernelEnd] |
160 |
|
jbe .not_vk |
161 |
|
|
162 |
ctrl_f_0: add al,10 ; <Ctrl-F>0 == F10 |
push cx ; save command line size |
163 |
ctrl_f: sub al,'1' |
|
164 |
|
mov edi,VKernelBuf |
165 |
|
call rllunpack |
166 |
|
; ESI updated on return |
167 |
|
|
168 |
|
sub di,cx ; Return to beginning of buf |
169 |
|
pop cx ; restore command line size |
170 |
|
push si ; save SI |
171 |
|
cmp cx,0 |
172 |
|
jz .print |
173 |
|
push di |
174 |
|
push cx |
175 |
|
mov si,command_line |
176 |
|
es repe cmpsb |
177 |
|
pop cx |
178 |
|
pop di |
179 |
|
jne .next |
180 |
|
.print: |
181 |
|
mov al,' ' |
182 |
|
call writechr |
183 |
|
|
184 |
|
mov si,di |
185 |
|
call writestr |
186 |
|
.next: |
187 |
|
pop si ; restore SI |
188 |
|
jmp .scan |
189 |
|
.not_vk: |
190 |
|
call crlf |
191 |
|
jmp fk_wrcmd |
192 |
|
|
193 |
|
ctrl_f: |
194 |
xor ah,ah |
xor ah,ah |
195 |
jmp short show_help |
mov [FuncFlag],ah |
196 |
|
cmp al,'0' |
197 |
|
jb get_char_2 |
198 |
|
je .zero ; <Ctrl-F>0 = F10 |
199 |
|
or al,20h ; Lower case |
200 |
|
cmp al,'9' |
201 |
|
jna .digit |
202 |
|
cmp al,'a' ; F10-F12 = <Ctrl-F>A, B, C |
203 |
|
jb get_char_2 |
204 |
|
cmp al,'c' |
205 |
|
ja get_char_2 |
206 |
|
sub al,'a'-10 |
207 |
|
jmp show_help |
208 |
|
.zero: |
209 |
|
mov al,10 |
210 |
|
jmp show_help |
211 |
|
.digit: |
212 |
|
sub al,'1' |
213 |
|
jmp show_help |
214 |
|
|
215 |
func_key: |
func_key: |
216 |
; AL = 0 if we get here |
; AL = 0 if we get here |
217 |
xchg al,ah |
xchg al,ah |
218 |
cmp al,68 ; F10 |
cmp al,44h ; F10 |
219 |
ja short get_char_2 |
ja .f11_f12 |
220 |
sub al,59 ; F1 |
sub al,3Bh ; F1 |
221 |
jb short get_char_2 |
jb get_char_2 |
222 |
show_help: ; AX = func key # (0 = F1, 9 = F10) |
jmp show_help |
223 |
|
.f11_f12: |
224 |
|
cmp al,85h ; F11 |
225 |
|
jb get_char_2 |
226 |
|
cmp al,86h ; F12 |
227 |
|
ja get_char_2 |
228 |
|
sub al,85h-10 |
229 |
|
|
230 |
|
show_help: ; AX = func key # (0 = F1, 9 = F10, 11 = F12) |
231 |
push di ; Save end-of-cmdline pointer |
push di ; Save end-of-cmdline pointer |
232 |
shl ax,FILENAME_MAX_LG2 ; Convert to pointer |
shl ax,FILENAME_MAX_LG2 ; Convert to pointer |
233 |
add ax,FKeyName |
add ax,FKeyName |
234 |
xchg di,ax |
xchg di,ax |
235 |
cmp byte [di+NULLOFFSET],NULLFILE |
cmp byte [di+NULLOFFSET],NULLFILE |
236 |
je short fk_nofile ; Undefined F-key |
je short fk_nofile ; Undefined F-key |
237 |
call searchdir |
call open |
238 |
jz short fk_nofile ; File not found |
jz short fk_nofile ; File not found |
|
push si |
|
239 |
call crlf |
call crlf |
|
pop si |
|
240 |
call get_msg_file |
call get_msg_file |
241 |
jmp short fk_wrcmd |
jmp short fk_wrcmd |
242 |
|
|
243 |
print_version: |
print_version: |
244 |
push di ; Command line write pointer |
push di ; Command line write pointer |
245 |
mov si,syslinux_banner |
mov si,syslinux_banner |
246 |
call cwritestr |
call writestr |
247 |
%ifdef HAVE_BIOSNAME |
%ifdef HAVE_BIOSNAME |
248 |
mov si,[BIOSName] |
mov si,[BIOSName] |
249 |
call cwritestr |
call writestr |
250 |
%endif |
%endif |
251 |
mov si,copyright_str |
mov si,copyright_str |
252 |
call cwritestr |
call writestr |
253 |
|
|
254 |
; ... fall through ... |
; ... fall through ... |
255 |
|
|
259 |
; of DI (the command line write pointer) is on the stack. |
; of DI (the command line write pointer) is on the stack. |
260 |
fk_wrcmd: |
fk_wrcmd: |
261 |
mov si,boot_prompt |
mov si,boot_prompt |
262 |
call cwritestr |
call writestr |
263 |
pop di ; Command line write pointer |
pop di ; Command line write pointer |
264 |
push di |
push di |
265 |
mov byte [di],0 ; Null-terminate command line |
mov byte [di],0 ; Null-terminate command line |
266 |
mov si,command_line |
mov si,command_line |
267 |
call cwritestr ; Write command line so far |
call writestr ; Write command line so far |
268 |
fk_nofile: pop di |
fk_nofile: pop di |
269 |
jmp short get_char_2 |
jmp get_char |
270 |
|
|
271 |
|
; |
272 |
|
; Show network info (in the form of the ipappend strings) |
273 |
|
; |
274 |
|
%if IS_PXELINUX |
275 |
|
show_network_info: |
276 |
|
push di ; Command line write pointer |
277 |
|
call crlf |
278 |
|
mov si,IPAppends ; See comboot.doc |
279 |
|
mov cx,numIPAppends |
280 |
|
.loop: |
281 |
|
lodsw |
282 |
|
push si |
283 |
|
mov si,ax |
284 |
|
call writestr |
285 |
|
call crlf |
286 |
|
pop si |
287 |
|
loop .loop |
288 |
|
jmp fk_wrcmd |
289 |
|
%endif |
290 |
|
|
291 |
; |
; |
292 |
; Jump here to run the default command line |
; Jump here to run the default command line |
293 |
; |
; |
294 |
auto_boot: |
auto_boot: |
295 |
|
cmp word [DefaultLevel],0 ; No UI or DEFAULT? |
296 |
|
jne .have_default |
297 |
|
mov si,no_default_msg |
298 |
|
call writestr |
299 |
|
cmp word [NoEscape],0 ; NOESCAPE but no DEFAULT? |
300 |
|
jne kaboom ; If so, we're stuck! |
301 |
|
jmp enter_command |
302 |
|
|
303 |
|
.have_default: |
304 |
mov si,default_cmd |
mov si,default_cmd |
305 |
mov di,command_line |
mov di,command_line |
306 |
mov cx,(max_cmd_len+4) >> 2 |
mov cx,(max_cmd_len+4) >> 2 |
307 |
rep movsd |
rep movsd |
308 |
jmp short load_kernel |
jmp short load_kernel |
309 |
|
|
310 |
|
section .data |
311 |
|
no_default_msg db 'No DEFAULT or UI configuration directive found!' |
312 |
|
db CR, LF, 0 |
313 |
|
|
314 |
|
section .text |
315 |
|
|
316 |
; |
; |
317 |
; Jump here when the command line is completed |
; Jump here when the command line is completed |
318 |
; |
; |
330 |
mov si,command_line |
mov si,command_line |
331 |
mov di,KernelName |
mov di,KernelName |
332 |
push si |
push si |
|
push di |
|
333 |
call mangle_name |
call mangle_name |
|
pop di |
|
334 |
pop si |
pop si |
335 |
; |
; |
336 |
; Fast-forward to first option (we start over from the beginning, since |
; Fast-forward to first option (we start over from the beginning, since |
360 |
; Now check if it is a "virtual kernel" |
; Now check if it is a "virtual kernel" |
361 |
; |
; |
362 |
vk_check: |
vk_check: |
363 |
xor si,si ; Beginning of vk_seg |
mov esi,[HighMemSize] ; Start from top of memory |
364 |
.scan: |
.scan: |
365 |
cmp si,[VKernelBytes] |
cmp esi,[VKernelEnd] |
366 |
jae .not_vk |
jbe .not_vk |
367 |
|
|
368 |
push ds |
mov edi,VKernelBuf |
|
push word vk_seg |
|
|
pop ds |
|
|
|
|
|
mov di,VKernelBuf |
|
369 |
call rllunpack |
call rllunpack |
370 |
pop ds |
; ESI updated on return |
|
; SI updated on return |
|
371 |
|
|
372 |
sub di,cx ; Return to beginning of buf |
sub di,cx ; Return to beginning of buf |
373 |
push si |
push si |
374 |
mov si,KernelName |
mov si,command_line |
375 |
mov cx,FILENAME_MAX |
.loop: |
376 |
es repe cmpsb |
lodsb |
377 |
|
cmp al,' ' |
378 |
|
jbe .done |
379 |
|
scasb |
380 |
|
je .loop |
381 |
|
.nomatch: |
382 |
pop si |
pop si |
|
je .found |
|
383 |
jmp .scan |
jmp .scan |
384 |
|
.done: |
385 |
|
cmp byte [di],0 ; Must match end of string |
386 |
|
jne .nomatch |
387 |
|
pop si |
388 |
|
|
389 |
; |
; |
390 |
; We *are* using a "virtual kernel" |
; We *are* using a "virtual kernel" |
400 |
mov [CmdLinePtr],di ; Where to add rest of cmd |
mov [CmdLinePtr],di ; Where to add rest of cmd |
401 |
pop es |
pop es |
402 |
mov di,KernelName |
mov di,KernelName |
403 |
push di |
push di |
404 |
mov si,VKernelBuf+vk_rname |
mov si,VKernelBuf+vk_rname |
405 |
mov cx,FILENAME_MAX ; We need ECX == CX later |
mov cx,FILENAME_MAX ; We need ECX == CX later |
406 |
rep movsb |
rep movsb |
411 |
%endif |
%endif |
412 |
xor bx,bx ; Try only one version |
xor bx,bx ; Try only one version |
413 |
|
|
414 |
%if IS_PXELINUX || IS_ISOLINUX |
mov al,[VKernelBuf+vk_type] |
415 |
|
mov [KernelType],al |
416 |
|
|
417 |
|
%if HAS_LOCALBOOT |
418 |
; Is this a "localboot" pseudo-kernel? |
; Is this a "localboot" pseudo-kernel? |
419 |
%if IS_PXELINUX |
cmp al,VK_LOCALBOOT ; al == KernelType |
420 |
cmp byte [VKernelBuf+vk_rname+4], 0 |
mov ax,[VKernelBuf+vk_rname] ; Possible localboot type |
421 |
%else |
je local_boot |
|
cmp byte [VKernelBuf+vk_rname], 0 |
|
422 |
%endif |
%endif |
|
jne get_kernel ; No, it's real, go get it |
|
|
|
|
|
mov ax, [VKernelBuf+vk_rname+1] |
|
|
jmp local_boot |
|
|
%else |
|
423 |
jmp get_kernel |
jmp get_kernel |
|
%endif |
|
424 |
|
|
425 |
.not_vk: |
.not_vk: |
|
|
|
426 |
; |
; |
427 |
; Not a "virtual kernel" - check that's OK and construct the command line |
; Not a "virtual kernel" - check that's OK and construct the command line |
428 |
; |
; |
441 |
pop di |
pop di |
442 |
pop si |
pop si |
443 |
pop es |
pop es |
444 |
|
|
445 |
|
mov [KernelType], cl ; CL == 0 here |
446 |
|
|
447 |
; |
; |
448 |
; Find the kernel on disk |
; Find the kernel on disk |
449 |
; |
; |
450 |
get_kernel: mov byte [KernelName+FILENAME_MAX],0 ; Zero-terminate filename/extension |
get_kernel: mov byte [KernelName+FILENAME_MAX],0 ; Zero-terminate filename/extension |
|
%if IS_SYSLINUX || IS_MDSLINUX ; SYSLINUX has to deal with DOS mangled names... |
|
|
mov eax,[KernelName+8] ; Save initial extension |
|
|
mov [exten_table_end],eax ; Last case == initial ext. |
|
|
%else |
|
451 |
mov di,KernelName+4*IS_PXELINUX |
mov di,KernelName+4*IS_PXELINUX |
452 |
|
cmp byte [di],' ' |
453 |
|
jbe bad_kernel ; Missing kernel name |
454 |
xor al,al |
xor al,al |
455 |
mov cx,FILENAME_MAX-5 ; Need 4 chars + null |
mov cx,FILENAME_MAX-5 ; Need 4 chars + null |
456 |
repne scasb ; Scan for final null |
repne scasb ; Scan for final null |
457 |
jne .no_skip |
jne .no_skip |
458 |
dec di ; Point to final null |
dec di ; Point to final null |
459 |
.no_skip: mov [KernelExtPtr],di |
.no_skip: mov [KernelExtPtr],di |
|
%endif |
|
460 |
mov bx,exten_table |
mov bx,exten_table |
461 |
.search_loop: push bx |
.search_loop: push bx |
462 |
mov di,KernelName ; Search on disk |
mov di,KernelName ; Search on disk |
463 |
call searchdir |
call searchdir |
464 |
pop bx |
pop bx |
465 |
jnz kernel_good |
jnz kernel_good |
466 |
mov eax,[bx] ; Try a different extension |
mov eax,[bx] ; Try a different extension |
|
%if IS_SYSLINUX || IS_MDSLINUX |
|
|
mov [KernelName+8],eax |
|
|
%else |
|
467 |
mov si,[KernelExtPtr] |
mov si,[KernelExtPtr] |
468 |
mov [si],eax |
mov [si],eax |
469 |
mov byte [si+4],0 |
mov byte [si+4],0 |
|
%endif |
|
470 |
add bx,byte 4 |
add bx,byte 4 |
471 |
cmp bx,exten_table_end |
cmp bx,exten_table_end |
472 |
jna .search_loop ; allow == case (final case) |
jna .search_loop ; allow == case (final case) |
486 |
push di |
push di |
487 |
call unmangle_name ; Get human form |
call unmangle_name ; Get human form |
488 |
mov si,err_notfound ; Complain about missing kernel |
mov si,err_notfound ; Complain about missing kernel |
489 |
call cwritestr |
call writestr |
490 |
pop si ; KernelCName |
pop si ; KernelCName |
491 |
call cwritestr |
call writestr |
492 |
mov si,crlf_msg |
mov si,crlf_msg |
493 |
jmp abort_load ; Ask user for clue |
jmp abort_load ; Ask user for clue |
494 |
|
|
495 |
; |
; |
496 |
; on_error: bad kernel, but we have onerror set |
; on_error: bad kernel, but we have onerror set; CX = OnerrorLen |
497 |
; |
; |
498 |
on_error: |
on_error: |
499 |
mov si,Onerror |
mov si,Onerror |
538 |
; |
; |
539 |
getchar_timeout: |
getchar_timeout: |
540 |
call vgashowcursor |
call vgashowcursor |
541 |
RESET_IDLE |
call reset_idle |
542 |
|
|
543 |
.loop: |
.loop: |
544 |
push word [BIOS_timer] |
push word [BIOS_timer] |
545 |
call pollchar |
call pollchar |
546 |
jnz .got_char |
jnz .got_char |
547 |
|
call do_idle |
548 |
pop ax |
pop ax |
549 |
cmp ax,[BIOS_timer] ; Has the timer advanced? |
cmp ax,[BIOS_timer] ; Has the timer advanced? |
550 |
je .loop |
je .loop |
551 |
DO_IDLE |
|
|
|
|
552 |
dec dword [ThisKbdTo] |
dec dword [ThisKbdTo] |
553 |
jz .timeout |
jz .timeout |
554 |
dec dword [ThisTotalTo] |
dec dword [ThisTotalTo] |
576 |
; that decision on the file extension. The following extensions are |
; that decision on the file extension. The following extensions are |
577 |
; recognized; case insensitive: |
; recognized; case insensitive: |
578 |
; |
; |
579 |
; .com - COMBOOT image |
; .com - COMBOOT image |
580 |
; .cbt - COMBOOT image |
; .cbt - COMBOOT image |
581 |
; .c32 - COM32 image |
; .c32 - COM32 image |
582 |
; .bs - Boot sector |
; .bs - Boot sector |
599 |
; COMBOOT function INT 22h, AX=0016h. |
; COMBOOT function INT 22h, AX=0016h. |
600 |
mov si,[Kernel_SI] |
mov si,[Kernel_SI] |
601 |
mov eax,[Kernel_EAX] |
mov eax,[Kernel_EAX] |
|
mov dx,[Kernel_EAX+2] |
|
602 |
|
|
603 |
kernel_good: |
kernel_good: |
604 |
pusha |
pushad |
605 |
|
; |
606 |
|
; Common initialization for all kernel types |
607 |
|
; |
608 |
|
xor ax,ax |
609 |
|
mov [InitRDPtr],ax |
610 |
|
mov [QuietBoot],al |
611 |
|
%if IS_PXELINUX |
612 |
|
mov [KeepPXE],al |
613 |
|
%endif |
614 |
|
|
615 |
mov si,KernelName |
mov si,KernelName |
616 |
mov di,KernelCName |
mov di,KernelCName |
617 |
call unmangle_name |
call unmangle_name |
618 |
sub di,KernelCName |
sub di,KernelCName |
619 |
mov [KernelCNameLen],di |
mov [KernelCNameLen],di |
620 |
popa |
|
621 |
|
; Default memory limit, can be overridden by image loaders |
622 |
%if IS_SYSLINUX || IS_MDSLINUX |
mov eax,[HighMemRsvd] |
623 |
mov ecx,[KernelName+7] |
mov [MyHighMemSize],eax |
624 |
mov cl,'.' |
|
625 |
%else |
popad |
626 |
|
|
627 |
push di |
push di |
628 |
push ax |
push ax |
629 |
mov di,KernelName+4*IS_PXELINUX |
mov di,KernelName+4*IS_PXELINUX |
635 |
.one_step: mov ecx,[di-4] ; 4 bytes before end |
.one_step: mov ecx,[di-4] ; 4 bytes before end |
636 |
pop ax |
pop ax |
637 |
pop di |
pop di |
|
%endif |
|
638 |
|
|
639 |
; |
; |
640 |
; At this point, DX:AX contains the size of the kernel, and SI contains |
; At this point, EAX contains the size of the kernel, SI contains |
641 |
; the file handle/cluster pointer. |
; the file handle/cluster pointer, and ECX contains the extension (if any.) |
642 |
; |
; |
643 |
or ecx,20202000h ; Force lower case |
movzx di,byte [KernelType] |
644 |
|
add di,di |
645 |
|
jmp [kerneltype_table+di] |
646 |
|
|
647 |
|
is_unknown_filetype: |
648 |
|
or ecx,20202000h ; Force lower case (except dot) |
649 |
|
|
650 |
cmp ecx,'.com' |
cmp ecx,'.com' |
651 |
je is_comboot_image |
je is_comboot_image |
661 |
je is_bss_sector |
je is_bss_sector |
662 |
cmp ecx,'.bin' |
cmp ecx,'.bin' |
663 |
je is_bootsector |
je is_bootsector |
|
%if IS_SYSLINUX || IS_MDSLINUX |
|
|
cmp ecx,'.bs ' |
|
|
je is_bootsector |
|
|
cmp ecx,'.0 ' |
|
|
je is_bootsector |
|
|
%else |
|
664 |
shr ecx,8 |
shr ecx,8 |
665 |
cmp ecx,'.bs' |
cmp ecx,'.bs' |
666 |
je is_bootsector |
je is_bootsector |
667 |
shr ecx,8 |
shr ecx,8 |
668 |
cmp cx,'.0' |
cmp cx,'.0' |
669 |
je is_bootsector |
je is_bootsector |
670 |
%endif |
|
671 |
; Otherwise Linux kernel |
; Otherwise Linux kernel |
672 |
|
jmp is_linux_kernel |
673 |
|
|
674 |
|
is_config_file: |
675 |
|
pusha |
676 |
|
mov si,KernelCName ; Save the config file name, for posterity |
677 |
|
mov di,ConfigName |
678 |
|
call strcpy |
679 |
|
popa |
680 |
|
call openfd |
681 |
|
call reset_config |
682 |
|
jmp load_config_file |
683 |
|
|
684 |
|
; This is an image type we can't deal with |
685 |
|
is_bad_image: |
686 |
|
mov si,err_badimage |
687 |
|
call writestr |
688 |
|
jmp enter_command |
689 |
|
|
690 |
|
%if IS_SYSLINUX |
691 |
|
; ok |
692 |
|
%else |
693 |
|
is_bss_sector equ is_bad_image |
694 |
|
%endif |
695 |
|
%if IS_ISOLINUX |
696 |
|
; ok |
697 |
|
%else |
698 |
|
is_disk_image equ is_bad_image |
699 |
|
%endif |
700 |
|
|
701 |
|
section .data |
702 |
|
boot_prompt db 'boot: ', 0 |
703 |
|
wipe_char db BS, ' ', BS, 0 |
704 |
|
err_badimage db 'Invalid image type for this media type!', CR, LF, 0 |
705 |
|
err_notfound db 'Could not find kernel image: ',0 |
706 |
|
err_notkernel db CR, LF, 'Invalid or corrupt kernel image.', CR, LF, 0 |
707 |
|
|
708 |
|
|
709 |
|
alignz 2 |
710 |
|
kerneltype_table: |
711 |
|
dw is_unknown_filetype ; VK_KERNEL |
712 |
|
dw is_linux_kernel ; VK_LINUX |
713 |
|
dw is_bootsector ; VK_BOOT |
714 |
|
dw is_bss_sector ; VK_BSS |
715 |
|
dw is_bootsector ; VK_PXE |
716 |
|
dw is_disk_image ; VK_FDIMAGE |
717 |
|
dw is_comboot_image ; VK_COMBOOT |
718 |
|
dw is_com32_image ; VK_COM32 |
719 |
|
dw is_config_file ; VK_CONFIG |
720 |
|
|
721 |
section .bss |
section .bss |
722 |
alignb 4 |
alignb 4 |
726 |
CmdOptPtr resw 1 ; Pointer to first option on cmd line |
CmdOptPtr resw 1 ; Pointer to first option on cmd line |
727 |
KbdFlags resb 1 ; Check for keyboard escapes |
KbdFlags resb 1 ; Check for keyboard escapes |
728 |
FuncFlag resb 1 ; Escape sequences received from keyboard |
FuncFlag resb 1 ; Escape sequences received from keyboard |
729 |
|
KernelType resb 1 ; Kernel type, from vkernel, if known |
730 |
|
|
731 |
section .text |
section .text |
732 |
|
; |
733 |
|
; Linux kernel loading code is common. |
734 |
|
; |
735 |
|
%include "runkernel.inc" |
736 |
|
|
737 |
|
; |
738 |
|
; COMBOOT-loading code |
739 |
|
; |
740 |
|
%include "comboot.inc" |
741 |
|
%include "com32.inc" |
742 |
|
%include "cmdline.inc" |
743 |
|
|
744 |
|
; |
745 |
|
; Boot sector loading code |
746 |
|
; |
747 |
|
%include "bootsect.inc" |
748 |
|
|
749 |
|
; |
750 |
|
; Abort loading code |
751 |
|
; |
752 |
|
%include "abort.inc" |
753 |
|
|
754 |
|
; |
755 |
|
; Hardware cleanup common code |
756 |
|
; |
757 |
|
%include "cleanup.inc" |