Further rationalize command-line parsing by allowing functions to
authorhpa <hpa>
Tue, 30 Apr 2002 03:33:27 +0000 (03:33 +0000)
committerhpa <hpa>
Tue, 30 Apr 2002 03:33:27 +0000 (03:33 +0000)
take an argument.

isolinux.asm
keywords.inc
ldlinux.asm
parsecmd.inc
parseconfig.inc
pxelinux.asm

index 1be8b20..807f707 100644 (file)
@@ -689,6 +689,12 @@ all_read:
                ; Now set up screen parameters
                call adjust_screen
 
+               ; Wipe the F-key area
+               mov al,NULLFILE
+               mov di,FKeyName
+               mov cx,10*(1 << FILENAME_MAX_LG2)
+               rep stosb
+
                ; Patch the writechr routine to point to the full code
                mov word [writechr+1], writechr_full-(writechr+3)
 
@@ -914,21 +920,19 @@ ctrl_f:           push di
                jmp short show_help
 
 func_key:
+               ; AL = 0 if we get here
                push di
                cmp ah,68                       ; F10
                ja get_char_2
                sub ah,59                       ; F1
                jb get_char_2
-               shr ax,8
+               xchg al,ah
 show_help:     ; AX = func key # (0 = F1, 9 = F10)
-               mov cl,al
-               shl ax,FILENAME_MAX_LG2         ; Convert to offset
-               mov bx,1
-               shl bx,cl
-               and bx,[FKeyMap]
-               jz get_char_2                   ; Undefined F-key
-               mov di,ax
+               shl ax,FILENAME_MAX_LG2         ; Convert to pointer
+               xchg di,ax
                add di,FKeyName
+               cmp byte [di],NULLFILE
+               je get_char_2                   ; Undefined F-key
                call searchdir
                jz fk_nofile
                push si
@@ -1865,35 +1869,6 @@ initrd_cmd_len   equ 7
 ; Config file keyword table
 ;
 %include "keywords.inc"
-               align 2, db 0
-
-keywd_table:
-               keyword append, pc_append
-               keyword default, pc_default
-               keyword timeout, pc_timeout
-               keyword font, pc_font
-               keyword kbdmap, pc_kbd
-               keyword display, pc_display
-               keyword prompt, pc_prompt
-               keyword label, pc_label
-               keyword implicit, pc_implicit
-               keyword kernel, pc_kernel
-               keyword serial, pc_serial
-               keyword say, pc_say
-               keyword f1, pc_f1
-               keyword f2, pc_f2
-               keyword f3, pc_f3
-               keyword f4, pc_f4
-               keyword f5, pc_f5
-               keyword f6, pc_f6
-               keyword f7, pc_f7
-               keyword f8, pc_f8
-               keyword f9, pc_f9
-               keyword f10, pc_f10
-               keyword f0, pc_f10
-               keyword localboot, pc_localboot
-
-keywd_count    equ ($-keywd_table)/keywd_size
 
 ;
 ; Extensions to search for (in *forward* order).
@@ -1935,7 +1910,6 @@ img_table:
 ;
 AppendLen       dw 0                    ; Bytes in append= command
 KbdTimeOut      dw 0                    ; Keyboard timeout (if any)
-FKeyMap                dw 0                    ; Bitmap for F-keys loaded
 CmdLinePtr     dw cmd_line_here        ; Command line advancing pointer
 initrd_flag    equ $
 initrd_ptr     dw 0                    ; Initial ramdisk pointer/flag
index 51551ef..1025543 100644 (file)
 
 %macro keyword 2
        dd hash_%1      ; Hash value
+       dw 0            ; No argument
        dw %2           ; Entrypoint
 %endmacro
 
-keywd_size     equ 6   ; Bytes per keyword
+%macro keyword 3
+       dd hash_%1      ; Hash value
+       dw %3           ; 16-bit argument
+       dw %2           ; Entrypoint
+%endmacro
+
+%macro keyword 4
+       dd hash_%1      ; Hash value
+       db %3, %4       ; 2 8-bit arguments
+       dw %2           ; Entrypoint
+%endmacro
+
+keywd_size     equ 8   ; Bytes per keyword
+
+               align 4, db 0
+
+keywd_table:
+               keyword append,    pc_append
+               keyword default,   pc_default
+               keyword display,   pc_filecmd,  get_msg_file
+               keyword font,      pc_filecmd,  loadfont
+               keyword implicit,  pc_setint16, AllowImplicit
+               keyword kbdmap,    pc_filecmd,  loadkeys
+               keyword kernel,    pc_kernel
+               keyword label,     pc_label
+               keyword prompt,    pc_setint16, ForcePrompt
+               keyword say,       pc_say
+               keyword serial,    pc_serial
+               keyword timeout,   pc_timeout
+               keyword f1,        pc_fkey,     FKeyName+(0<<FILENAME_MAX_LG2)
+               keyword f2,        pc_fkey,     FKeyName+(1<<FILENAME_MAX_LG2)
+               keyword f3,        pc_fkey,     FKeyName+(2<<FILENAME_MAX_LG2)
+               keyword f4,        pc_fkey,     FKeyName+(3<<FILENAME_MAX_LG2)
+               keyword f5,        pc_fkey,     FKeyName+(4<<FILENAME_MAX_LG2)
+               keyword f6,        pc_fkey,     FKeyName+(5<<FILENAME_MAX_LG2)
+               keyword f7,        pc_fkey,     FKeyName+(6<<FILENAME_MAX_LG2)
+               keyword f8,        pc_fkey,     FKeyName+(7<<FILENAME_MAX_LG2)
+               keyword f9,        pc_fkey,     FKeyName+(8<<FILENAME_MAX_LG2)
+               keyword f10,       pc_fkey,     FKeyName+(9<<FILENAME_MAX_LG2)
+               keyword f0,        pc_fkey,     FKeyName+(9<<FILENAME_MAX_LG2)
+%if IS_PXELINUX
+               keyword ipappend,  pc_ipappend
+%endif
+%if IS_PXELINUX || IS_ISOLINUX
+               keyword localboot, pc_localboot
+%endif
+
+keywd_count    equ ($-keywd_table)/keywd_size
+
index e46643a..2a93985 100644 (file)
@@ -940,6 +940,13 @@ all_read:
 ;
                ; Now set up screen parameters
                call adjust_screen
+
+               ; Wipe the F-key area
+               mov al,NULLFILE
+               mov di,FKeyName
+               mov cx,10*(1 << FILENAME_MAX_LG2)
+               rep stosb
+
 ;
 ; Now, everything is "up and running"... patch kaboom for more
 ; verbosity and using the full screen system
@@ -1092,21 +1099,19 @@ ctrl_f:         push di
                jmp short show_help
 
 func_key:
+               ; AL = 0 if we get here
                push di
                cmp ah,68                       ; F10
                ja get_char_2
                sub ah,59                       ; F1
                jb get_char_2
-               shr ax,8
+               xchg al,ah
 show_help:     ; AX = func key # (0 = F1, 9 = F10)
-               mov cl,al
-               shl ax,4                        ; Convert to x16
-               mov bx,1
-               shl bx,cl
-               and bx,[FKeyMap]
-               jz get_char_2                   ; Undefined F-key
-               mov di,ax
+               shl ax,FILENAME_MAX_LG2         ; Convert to pointer
+               xchg di,ax
                add di,FKeyName
+               cmp byte [di],NULLFILE
+               je get_char_2                   ; Undefined F-key
                call searchdir
                jz fk_nofile
                push si
@@ -1673,35 +1678,6 @@ initrd_cmd_len   equ 7
 ; Config file keyword table
 ;
 %include "keywords.inc"
-               align 2, db 0
-
-keywd_table:
-               keyword append, pc_append
-               keyword default, pc_default
-               keyword timeout, pc_timeout
-               keyword font, pc_font
-               keyword kbdmap, pc_kbd
-               keyword display, pc_display
-               keyword prompt, pc_prompt
-               keyword label, pc_label
-               keyword implicit, pc_implicit
-               keyword kernel, pc_kernel
-               keyword serial, pc_serial
-               keyword say, pc_say
-               keyword f1, pc_f1
-               keyword f2, pc_f2
-               keyword f3, pc_f3
-               keyword f4, pc_f4
-               keyword f5, pc_f5
-               keyword f6, pc_f6
-               keyword f7, pc_f7
-               keyword f8, pc_f8
-               keyword f9, pc_f9
-               keyword f10, pc_f10
-               keyword f0, pc_f10
-
-keywd_count    equ ($-keywd_table)/keywd_size
-
 ;
 ; Extensions to search for (in *reverse* order).  Note that the last
 ; (lexically first) entry in the table is a placeholder for the original
@@ -1724,7 +1700,6 @@ debug_magic       dw 0D00Dh               ; Debug code sentinel
 %endif
 AppendLen       dw 0                    ; Bytes in append= command
 KbdTimeOut      dw 0                    ; Keyboard timeout (if any)
-FKeyMap                dw 0                    ; Bitmap for F-keys loaded
 CmdLinePtr     dw cmd_line_here        ; Command line advancing pointer
 initrd_flag    equ $
 initrd_ptr     dw 0                    ; Initial ramdisk pointer/flag
index f10e4f5..5639db9 100644 (file)
@@ -57,7 +57,7 @@ getcommand:
                lodsd
                cmp ebx,eax
                je .found_keywd
-               lodsw                   ; Skip entrypoint
+               lodsd                   ; Skip entrypoint/argument
                loop .table_search
 
                ; Otherwise unrecognized keyword
@@ -71,7 +71,8 @@ getcommand:
                call cwritestr
                jmp short .find
 
-.found_keywd:  call near [si]
+.found_keywd:  lodsw                   ; Load argument into ax
+               call near [si]
                clc
                ret
 
index a46694a..cee88df 100644 (file)
@@ -99,28 +99,34 @@ pc_timeout: call getint
 .err:          ret
 
 ;
-; "display" command
+; Generic integer variable setting commands:
+; "prompt", "implicit"
 ;
-pc_display:    call pc_getfile
-               jz .err                         ; File not found?
-               call get_msg_file               ; Load and display file
-.err:          ret
-
-;
-; "prompt" command
-;
-pc_prompt:     call getint
+pc_setint16:
+               push ax
+               call getint
+               pop si
                jc .err
-               mov [ForcePrompt],bx
+               mov [si],bx
 .err:          ret
 
 ;
-; "implicit" command
+; Generic file-processing commands:
+; "display", "font", "kbdmap"
 ;
-pc_implicit:    call getint
-                jc .err
-                mov [AllowImplicit],bx
-.err:          ret
+pc_filecmd:    push ax                         ; Function to tailcall
+               mov di,trackbuf
+               push di
+               call getline
+               pop si
+               mov di,MNameBuf
+               push di
+               call mangle_name
+               pop di
+               call searchdir                  ; tailcall
+               jnz .ok
+               pop ax                          ; Drop the successor function
+.ok:           ret                             ; Tailcall if OK, error return
 
 ;
 ; "serial" command
@@ -209,31 +215,12 @@ pc_serial:        call getint
 ;
 ; "F"-key command
 ;
-; This relies on the fact that [si] points to the address of the entrypoint
-;
-pc_f1:         nop
-pc_f2:         nop
-pc_f3:         nop
-pc_f4:         nop
-pc_f5:         nop
-pc_f6:         nop
-pc_f7:         nop
-pc_f8:         nop
-pc_f9:         nop
-pc_f10:
-               mov cx,[si]
-               sub cx,pc_f1
-               push cx
-               mov ax,1
-               shl ax,cl
-               or [FKeyMap], ax                ; Mark that we have this loaded
+pc_fkey:       push ax
                mov di,trackbuf
                push di
                call getline                    ; Get filename to display
                pop si
                pop di
-               shl di,FILENAME_MAX_LG2         ; Convert to offset
-               add di,FKeyName
                call mangle_name                ; Mangle file name
                ret
 
@@ -264,22 +251,6 @@ pc_label:  call commit_vk                  ; Commit any current vkernel
                ret
 
 ;
-; "font" command
-;
-pc_font:       call pc_getfile                 ; "font" command
-               jz .err                         ; File not found?
-               call loadfont                   ; Load and install font
-.err:          ret
-
-;
-; "kbd" command
-;
-pc_kbd:                call pc_getfile                 ; "kbd" command
-               jz .err
-               call loadkeys
-.err:          ret
-
-;
 ; "say" command
 ;
 pc_say:                mov di,trackbuf                 ; "say" command
@@ -292,20 +263,6 @@ pc_say:            mov di,trackbuf                 ; "say" command
                jmp crlf                        ; tailcall
 
 ;
-; pc_getfile:  For command line options that take file argument, this
-;              routine decodes the file argument and runs it through searchdir
-;
-pc_getfile:    mov di,trackbuf
-               push di
-               call getline
-               pop si
-               mov di,MNameBuf
-               push di
-               call mangle_name
-               pop di
-               jmp searchdir                   ; tailcall
-
-;
 ; Main loop for configuration file parsing
 ;
 parse_config:
index 1986bc2..2c87925 100644 (file)
@@ -289,6 +289,13 @@ _start1:
 ;
                ; Now set up screen parameters
                call adjust_screen
+
+               ; Wipe the F-key area
+               mov al,NULLFILE
+               mov di,FKeyName
+               mov cx,10*(1 << FILENAME_MAX_LG2)
+               rep stosb
+
 ;
 ; Tell the user we got this far
 ;
@@ -835,21 +842,19 @@ ctrl_f:           push di
                jmp short show_help
 
 func_key:
+               ; AL = 0 if we get here
                push di
                cmp ah,68                       ; F10
                ja get_char_2
                sub ah,59                       ; F1
                jb get_char_2
-               shr ax,8
+               xchg al,ah
 show_help:     ; AX = func key # (0 = F1, 9 = F10)
-               mov cl,al
-               shl ax,FILENAME_MAX_LG2         ; Convert to offset
-               mov bx,1
-               shl bx,cl
-               and bx,[FKeyMap]
-               jz get_char_2                   ; Undefined F-key
-               mov di,ax
+               shl ax,FILENAME_MAX_LG2         ; Convert to pointer
+               xchg di,ax
                add di,FKeyName
+               cmp byte [di],NULLFILE
+               je get_char_2                   ; Undefined F-key
                call searchdir
                jz fk_nofile
                push si
@@ -2306,36 +2311,6 @@ initrd_cmd_len   equ 7
 ; Config file keyword table
 ;
 %include "keywords.inc"
-               align 2, db 0
-
-keywd_table:
-               keyword append, pc_append
-               keyword default, pc_default
-               keyword timeout, pc_timeout
-               keyword font, pc_font
-               keyword kbdmap, pc_kbd
-               keyword display, pc_display
-               keyword prompt, pc_prompt
-               keyword label, pc_label
-               keyword implicit, pc_implicit
-               keyword kernel, pc_kernel
-               keyword serial, pc_serial
-               keyword say, pc_say
-               keyword f1, pc_f1
-               keyword f2, pc_f2
-               keyword f3, pc_f3
-               keyword f4, pc_f4
-               keyword f5, pc_f5
-               keyword f6, pc_f6
-               keyword f7, pc_f7
-               keyword f8, pc_f8
-               keyword f9, pc_f9
-               keyword f10, pc_f10
-               keyword f0, pc_f10
-               keyword ipappend, pc_ipappend
-               keyword localboot, pc_localboot
-
-keywd_count    equ ($-keywd_table)/keywd_size
 
 ;
 ; Extensions to search for (in *forward* order).
@@ -2415,7 +2390,6 @@ pxe_undi_shutdown_pkt:
 ;
 AppendLen       dw 0                    ; Bytes in append= command
 KbdTimeOut      dw 0                    ; Keyboard timeout (if any)
-FKeyMap                dw 0                    ; Bitmap for F-keys loaded
 CmdLinePtr     dw cmd_line_here        ; Command line advancing pointer
 initrd_flag    equ $
 initrd_ptr     dw 0                    ; Initial ramdisk pointer/flag