VESA library: add support for reading lss16 images
[profile/ivi/syslinux.git] / ui.inc
diff --git a/ui.inc b/ui.inc
index bb34084..0677733 100644 (file)
--- a/ui.inc
+++ b/ui.inc
@@ -1,6 +1,6 @@
 ;; -----------------------------------------------------------------------
 ;;
-;;   Copyright 1994-2007 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
@@ -17,6 +17,33 @@ load_config_file:
                call parse_config               ; Parse configuration file
 no_config_file:
 
+               call adv_init
+;
+; Check for an ADV boot-once entry
+;
+               mov dl,ADV_BOOTONCE
+               call adv_get
+               jcxz .no_bootonce
+
+.have_bootone:
+               ; We apparently have a boot-once set; clear it and
+               ; then execute the boot-once...
+
+               ; Save the boot-once data; SI = data, CX = length
+               mov di,command_line
+               rep movsb
+               xor ax,ax
+               stosb
+
+               ; Clear the boot-once data from the ADV
+               xor cx,cx                       ; Set to zero = delete
+               call adv_set
+               jc .err
+               call adv_write
+.err:          jmp load_kernel
+
+.no_bootonce:
+
 ;
 ; Check whether or not we are supposed to display the boot prompt.
 ;
@@ -72,13 +99,13 @@ got_ascii:  cmp al,7Fh                      ; <DEL> == <BS>
                cmp di,command_line             ; Space must not be first
                je short get_char
 enter_char:    test byte [FuncFlag],1
-               je ctrl_f                       ; Keystroke after <Ctrl-F>
+               jnz ctrl_f                      ; Keystroke after <Ctrl-F>
                cmp di,max_cmd_len+command_line ; Check there's space
                jnb short get_char
                stosb                           ; Save it
                call writechr                   ; Echo to screen
                jmp short get_char
-not_ascii:     mov byte [FuncFlag],0
+not_ascii:
                cmp al,0Dh                      ; Enter
                je command_done
                cmp al,'F' & 1Fh                ; <Ctrl-F>
@@ -140,17 +167,17 @@ ctrl_f:
 func_key:
                ; AL = 0 if we get here
                xchg al,ah
-               cmp al,68                       ; F10
+               cmp al,44h                      ; F10
                ja .f11_f12
-               sub al,59                       ; F1
+               sub al,3Bh                      ; F1
                jb get_char_2
                jmp show_help
 .f11_f12:
-               cmp al,8                      ; F11
+               cmp al,85h                      ; F11
                jb get_char_2
-               cmp al,8                      ; F12
+               cmp al,86h                      ; F12
                ja get_char_2
-               sub al,87-10
+               sub al,85h-10
 
 show_help:     ; AX = func key # (0 = F1, 9 = F10, 11 = F12)
                push di                         ; Save end-of-cmdline pointer
@@ -159,11 +186,9 @@ show_help: ; AX = func key # (0 = F1, 9 = F10, 11 = F12)
                xchg di,ax
                cmp byte [di+NULLOFFSET],NULLFILE
                je short fk_nofile              ; Undefined F-key
-               call searchdir
+               call open
                jz short fk_nofile              ; File not found
-               push si
                call crlf
-               pop si
                call get_msg_file
                jmp short fk_wrcmd
 
@@ -272,19 +297,14 @@ clin_opt_ok:
 ; Now check if it is a "virtual kernel"
 ;
 vk_check:
-               xor si,si                       ; Beginning of vk_seg
+               mov esi,[HighMemSize]           ; Start from top of memory
 .scan:
-               cmp si,[VKernelBytes]
-               jae .not_vk
-
-               push ds
-               push word vk_seg
-               pop ds
+               cmp esi,[VKernelEnd]
+               jbe .not_vk
 
                mov di,VKernelBuf
                call rllunpack
-               pop ds
-               ; SI updated on return
+               ; ESI updated on return
 
                sub di,cx                       ; Return to beginning of buf
                push si
@@ -514,16 +534,21 @@ kernel_good_saved:
                ; COMBOOT function INT 22h, AX=0016h.
                mov si,[Kernel_SI]
                mov eax,[Kernel_EAX]
-               mov dx,[Kernel_EAX+2]
 
 kernel_good:
-               pusha
+               pushad
+
                mov si,KernelName
                mov di,KernelCName
                call unmangle_name
                sub di,KernelCName
                mov [KernelCNameLen],di
-               popa
+
+               ; Default memory limit, can be overridden by image loaders
+               mov eax,[HighMemRsvd]
+               mov [MyHighMemSize],eax
+
+               popad
 
                push di
                push ax
@@ -538,7 +563,7 @@ kernel_good:
                pop di
 
 ;
-; At this point, DX:AX contains the size of the kernel, SI contains
+; At this point, EAX contains the size of the kernel, SI contains
 ; the file handle/cluster pointer, and ECX contains the extension (if any.)
 ;
                movzx di,byte [KernelType]
@@ -600,7 +625,12 @@ is_disk_image      equ is_bad_image
 %endif
 
                section .data
+boot_prompt    db 'boot: ', 0
+wipe_char      db BS, ' ', BS, 0
 err_badimage   db 'Invalid image type for this media type!', CR, LF, 0
+err_notfound   db 'Could not find kernel image: ',0
+err_notkernel  db CR, LF, 'Invalid or corrupt kernel image.', CR, LF, 0
+
 
                align 2, db 0
 kerneltype_table:
@@ -625,3 +655,29 @@ FuncFlag   resb 1                  ; Escape sequences received from keyboard
 KernelType     resb 1                  ; Kernel type, from vkernel, if known
 
                section .text
+;
+; Linux kernel loading code is common.
+;
+%include "runkernel.inc"
+
+;
+; COMBOOT-loading code
+;
+%include "comboot.inc"
+%include "com32.inc"
+%include "cmdline.inc"
+
+;
+; Boot sector loading code
+;
+%include "bootsect.inc"
+
+;
+; Abort loading code
+;
+%include "abort.inc"
+
+;
+; Hardware cleanup common code
+;
+%include "cleanup.inc"