Add support for forcing the filetype, and loading a secondary config file.
authorH. Peter Anvin <hpa@zytor.com>
Sat, 23 Sep 2006 06:24:45 +0000 (23:24 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 23 Sep 2006 06:24:45 +0000 (23:24 -0700)
Add support for forcing the filetype, and loading a secondary config file.
Also bump the version number to version 3.40.

19 files changed:
NEWS
bootsect.inc
comboot.doc
conio.inc
extlinux.asm
font.inc
graphics.inc
init.inc
isolinux.asm
kernel.inc
keywords
keywords.inc
layout.inc
ldlinux.asm
parseconfig.inc
pxelinux.asm
syslinux.doc
ui.inc
version

diff --git a/NEWS b/NEWS
index d8a8a64..c208c9c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ Starting with 1.47, changes marked with SYSLINUX/PXELINUX/ISOLINUX
 apply to that specific program only; other changes apply to all of
 them.
 
+Changes in 3.40:
+       * New keywords allow the type of file to be specified in the
+         configuration file.
+       * It is now supported to load a different configuration file
+         with the CONFIG keyword.
+
 Changes in 3.31:
        * The simple menu system (menu.c32 and vesamenu.c32) now
          support loading more than one configuration file at a time,
index b1360a5..b0077b2 100644 (file)
@@ -145,12 +145,3 @@ replace_bootstrap:
                movzx esp,di
 
                jmp shuffle_and_boot
-
-%if IS_SYSLINUX || IS_MDSLINUX
-               ; Nothing
-%else
-is_bss_sector:
-               mov si,err_bssimage
-               call cwritestr
-               jmp enter_command
-%endif
index 58549e6..23ab384 100644 (file)
@@ -639,7 +639,7 @@ AX=0016h [3.10] Run kernel image
                DS:SI   Filename of kernel image (zero-terminated string)
                ES:BX   Command line (zero-terminated string)
                ECX     IPAPPEND flags [PXELINUX]
-               EDX     Reserved - MUST BE ZERO
+               EDX     Type of file (since 3.40)
        Output: Does not return if successful; returns with CF=1 if
                the kernel image is not found.
 
@@ -659,6 +659,19 @@ AX=0016h [3.10] Run kernel image
        may still return to the command line if the image is somehow
        corrupt, however.)
 
+       The file types are defined as follows:
+
+                   Equivalent
+       EDX     Config  Extensions      Type of file    
+       0       KERNEL                  Determined by filename extension
+       1       LINUX   none            Linux kernel image
+       2       BOOT    .0 .bs .bin     Bootstrap program
+       3       BSS     .bss            Boot sector with patch [SYSLINUX]
+       4       FDIMAGE .img            Floppy disk image [ISOLINUX]
+       5       COMBOOT .com .cbt       16-bit COMBOOT program
+       6       COM32   .c32            COM32 program
+       7       CONFIG                  Configuration file
+
 
 AX=0017h [3.30] Report video mode change
        Input:  AX      0017h
index 8fd9d9d..f8b8073 100644 (file)
--- a/conio.inc
+++ b/conio.inc
@@ -386,7 +386,7 @@ debug_tracer:       pushad
                ret
 %endif ; DEBUG_TRACERS
 
-               section .data
+               section .config
                ; This is a word to pc_setint16 can set it
 DisplayCon     dw 01h                  ; Console display enabled
 
index 7ddc278..ddc0cc6 100644 (file)
@@ -62,6 +62,7 @@ SYMLINK_SECTORS       equ 2                   ; Max number of sectors in a symlink
 vk_vname:      resb FILENAME_MAX       ; Virtual name **MUST BE FIRST!**
 vk_rname:      resb FILENAME_MAX       ; Real name
 vk_appendlen:  resw 1
+vk_type:       resb 1                  ; Type of file
                alignb 4
 vk_append:     resb max_cmd_len+1      ; Command line
                alignb 4
@@ -1516,6 +1517,7 @@ getfssec:
 %include "conio.inc"           ; Console I/O
 %include "plaincon.inc"                ; writechr
 %include "writestr.inc"                ; String output
+%include "configinit.inc"      ; Initialize configuration
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
 %include "bcopy32.inc"         ; 32-bit bcopy
@@ -1556,7 +1558,6 @@ err_oldkernel   db 'Cannot load a ramdisk with an old kernel image.'
                 db CR, LF, 0
 err_notdos     db ': attempted DOS system call', CR, LF, 0
 err_comlarge   db 'COMBOOT image too large.', CR, LF, 0
-err_bssimage   db 'BSS images not supported.', CR, LF, 0
 err_a20                db CR, LF, 'A20 gate not responding!', CR, LF, 0
 err_bootfailed db CR, LF, 'Boot failed: please change disks and press '
                db 'a key to continue.', CR, LF, 0
index 04080ba..c2d1350 100644 (file)
--- a/font.inc
+++ b/font.inc
@@ -102,8 +102,6 @@ use_font:
                mov ax,1103h                    ; Select page 0
                int 10h
 
-               ; Fall through to adjust_screen
-
 lf_ret         equ use_font.lf_ret
 
 ;
index cfdcf6e..e80e04c 100644 (file)
@@ -307,8 +307,8 @@ vgaclearmode:
 ;              int 10h
                mov [UsingVGA], byte 0
 
-               call use_font           ; Restore text font/data
                mov byte [ScrollAttribute], 07h
+               call use_font           ; Restore text font/data
 .done:
                popad
                pop es
index a01c6e9..2f31b0e 100644 (file)
--- a/init.inc
+++ b/init.inc
@@ -22,23 +22,10 @@ common_init:
                ; 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
-
-               mov si,linuxauto_cmd            ; Default command: "linux auto"
-               mov di,default_cmd
-                mov cx,linuxauto_len
-               rep movsb
-
-               mov di,KbdMap                   ; Default keymap 1:1
-               xor al,al
-               inc ch                          ; CX <- 256
-mkkeymap:      stosb
-               inc al
-               loop mkkeymap
+;
+; Initialize configuration information
+;
+               call reset_config
 
 ;
 ; Clear Files structures
@@ -57,9 +44,4 @@ mkkeymap:     stosb
                add ax,PKTBUF_SIZE
                loop .setbufptr
 %endif
-
-               section .data
-linuxauto_cmd  db 'linux auto',0
-linuxauto_len   equ $-linuxauto_cmd
-
                section .text                   ; This is an inline file...
index fd7cb75..9174626 100644 (file)
@@ -56,6 +56,7 @@ SECTOR_SIZE   equ (1 << SECTOR_SHIFT)
 vk_vname:      resb FILENAME_MAX       ; Virtual name **MUST BE FIRST!**
 vk_rname:      resb FILENAME_MAX       ; Real name
 vk_appendlen:  resw 1
+vk_type:       resb 1                  ; Type of file
                alignb 4
 vk_append:     resb max_cmd_len+1      ; Command line
                alignb 4
@@ -825,17 +826,16 @@ rl_checkpt_off    equ ($-$$)
 ; ----------------------------------------------------------------------------
 
 all_read:
+
+; Test tracers
+               TRACER 'T'
+               TRACER '>'
+
 ;
-; Initialize screen (if we're using one)
+; Common initialization code
 ;
-               ; 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
+%include "init.inc"
+%include "cpuinit.inc"
 
                ; Patch the writechr routine to point to the full code
                mov word [writechr+1], writechr_full-(writechr+3)
@@ -846,16 +846,6 @@ all_read:
                call writestr
 %endif
 
-; Test tracers
-               TRACER 'T'
-               TRACER '>'
-
-;
-; Common initialization code
-;
-%include "init.inc"
-%include "cpuinit.inc"
-
 ;
 ; Now we're all set to start with our *real* business. First load the
 ; configuration file (if any) and parse it.
@@ -1476,6 +1466,7 @@ getfssec:
 
 %include "getc.inc"            ; getc et al
 %include "conio.inc"           ; Console I/O
+%include "configinit.inc"      ; Initialize configuration
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
 %include "bcopy32.inc"         ; 32-bit bcopy
@@ -1514,7 +1505,6 @@ err_oldkernel   db 'Cannot load a ramdisk with an old kernel image.'
                 db CR, LF, 0
 err_notdos     db ': attempted DOS system call', CR, LF, 0
 err_comlarge   db 'COMBOOT image too large.', CR, LF, 0
-err_bssimage   db 'BSS images not supported.', CR, LF, 0
 err_a20                db CR, LF, 'A20 gate not responding!', CR, LF, 0
 notfound_msg   db 'not found', CR, LF, 0
 localboot_msg  db 'Booting from local disk...', CR, LF, 0
index 48a704b..2a99da5 100644 (file)
@@ -87,4 +87,17 @@ pxelinux_id  equ 032h                ; 3 = SYSLINUX family; 2 = PXELINUX
 isolinux_id    equ 033h                ; 3 = SYSLINUX family; 3 = ISOLINUX
 extlinux_id    equ 034h                ; 3 = SYSLINUX family; 4 = EXTLINUX
 
+;
+; Types of vkernels
+;
+VK_KERNEL      equ 0                   ; Choose by filename
+VK_LINUX       equ 1                   ; Linux kernel image
+VK_BOOT                equ 2                   ; Boot sector
+VK_BSS         equ 3                   ; BSS boot sector
+VK_FDIMAGE     equ 4                   ; Floppy disk image
+VK_COMBOOT     equ 5                   ; COMBOOT image
+VK_COM32       equ 6                   ; COM32 image
+VK_CONFIG      equ 7                   ; Configuration file
+VK_TYPES       equ 8                   ; Number of VK types
+
 %endif ; _KERNEL_INC
index bfcbc2a..31a6085 100644 (file)
--- a/keywords
+++ b/keywords
@@ -1,5 +1,6 @@
 menu
 append
+config
 default
 display
 font
@@ -7,6 +8,12 @@ implicit
 ipappend
 kbdmap
 kernel
+linux
+boot
+bss
+fdimage
+comboot
+com32
 label
 localboot
 prompt
index cffe6a7..e15ea99 100644 (file)
@@ -50,7 +50,14 @@ keywd_table:
                keyword font,      pc_filecmd,  loadfont
                keyword implicit,  pc_setint16, AllowImplicit
                keyword kbdmap,    pc_filecmd,  loadkeys
-               keyword kernel,    pc_kernel
+               keyword kernel,    pc_kernel,   VK_KERNEL
+               keyword linux,     pc_kernel,   VK_LINUX
+               keyword boot,      pc_kernel,   VK_BOOT
+               keyword bss,       pc_kernel,   VK_BSS
+               keyword fdimage,   pc_kernel,   VK_FDIMAGE
+               keyword comboot,   pc_kernel,   VK_COMBOOT
+               keyword com32,     pc_kernel,   VK_COM32
+               keyword config,    pc_kernel,   VK_CONFIG
                keyword label,     pc_label
                keyword prompt,    pc_setint16, ForcePrompt
                keyword say,       pc_say
index d688a6e..d3b9f05 100644 (file)
@@ -47,8 +47,11 @@ STACK_START  equ TEXT_START-STACK_SIZE
 
                section .earlybss nobits start=BSS_START
                section .bcopy32  align=4 valign=16 follows=.data vfollows=.earlybss
+               section .config   align=4 valign=16 follows=.bcopy32 vfollows=.bcopy32
+               section .config.end nobits align=4 follows=.config
+
                ; NASM BUG: follows= here should be vfollows=
-               section .bss      nobits align=256 follows=.bcopy32
+               section .bss      nobits align=256 follows=.config.end
 
                section .text     start=TEXT_START
                ; NASM BUG: follows=.text not accepted here
index b5a9ebf..a3b24a8 100644 (file)
@@ -64,6 +64,7 @@ SECTOR_SIZE   equ (1 << SECTOR_SHIFT)
 vk_vname:      resb FILENAME_MAX       ; Virtual name **MUST BE FIRST!**
 vk_rname:      resb FILENAME_MAX       ; Real name
 vk_appendlen:  resw 1
+vk_type:       resb 1                  ; Type of file
                alignb 4
 vk_append:     resb max_cmd_len+1      ; Command line
                alignb 4
@@ -1408,6 +1409,7 @@ getfatsector:
 %include "conio.inc"           ; Console I/O
 %include "plaincon.inc"                ; writechr
 %include "writestr.inc"                ; String output
+%include "configinit.inc"      ; Initialize configuration
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
 %include "bcopy32.inc"         ; 32-bit bcopy
index aef3161..c96895d 100644 (file)
@@ -1,6 +1,6 @@
 ;; -----------------------------------------------------------------------
 ;;
-;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2006 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
@@ -100,9 +100,11 @@ pc_localboot:      call getint
 %endif
 
 ;
-; "kernel" command
+; "kernel", "config", ... command
+;
 pc_kernel:     cmp byte [VKernel],0
                je .err                         ; ("label" section only)
+               mov [VKernelBuf+vk_type],al
                call pc_getline
                mov di,VKernelBuf+vk_rname
                call mangle_name
@@ -252,10 +254,15 @@ pc_serial:        call getint
                call slow_out
 
                ; Show some life
+               cmp byte [SerialNotice],0
+               je .notfirst
+               mov byte [SerialNotice],0
+
                mov si,syslinux_banner
                call write_serial_str
                mov si,copyright_str
                call write_serial_str
+.notfirst:
                ret
 
 .serial_port_bad:
@@ -374,7 +381,9 @@ commit_vk:
 
                section .data
 vk_overflow_msg        db 'Out of memory parsing config file', CR, LF, 0
+SerialNotice   db 1                    ; Only print this once
 
+               section .config
                align 4, db 0
 KbdTimeout      dd 0                    ; Keyboard timeout (if any)
 TotalTimeout   dd 0                    ; Total timeout (if any)
@@ -390,6 +399,10 @@ SerialPort dw 0                    ; Serial port base (or 0 for no serial port)
 VKernelBytes   dw 0                    ; Number of bytes used by vkernels
 VKernel                db 0                    ; Have we seen any "label" statements?
 
+%if IS_PXELINUX
+IPAppend       db 0                    ; Default IPAPPEND option
+%endif
+
                section .latebss
                 alignb 4               ; For the good of REP MOVSD
 command_line   resb max_cmd_len+2      ; Command line buffer
index ac986d3..6f99b32 100644 (file)
@@ -96,7 +96,7 @@ TFTP_EOPTNEG  equ htons(8)            ; Option negotiation failure
 vk_vname:      resb FILENAME_MAX       ; Virtual name **MUST BE FIRST!**
 vk_rname:      resb FILENAME_MAX       ; Real name
 vk_ipappend:   resb 1                  ; "IPAPPEND" flag
-               resb 1                  ; Pad
+vk_type:       resb 1                  ; Type of file
 vk_appendlen:  resw 1
                alignb 4
 vk_append:     resb max_cmd_len+1      ; Command line
@@ -2305,6 +2305,7 @@ check_for_arp:
 %include "writestr.inc"                ; String output
 writestr       equ cwritestr
 %include "writehex.inc"                ; Hexadecimal output
+%include "configinit.inc"      ; Initialize configuration
 %include "parseconfig.inc"     ; High-level config file handling
 %include "parsecmd.inc"                ; Low-level config file handling
 %include "bcopy32.inc"         ; 32-bit bcopy
@@ -2347,7 +2348,6 @@ err_oldkernel   db 'Cannot load a ramdisk with an old kernel image.'
                 db CR, LF, 0
 err_notdos     db ': attempted DOS system call', CR, LF, 0
 err_comlarge   db 'COMBOOT image too large.', CR, LF, 0
-err_bssimage   db 'BSS images not supported.', CR, LF, 0
 err_a20                db CR, LF, 'A20 gate not responding!', CR, LF, 0
 err_bootfailed db CR, LF, 'Boot failed: press a key to retry, or wait for reset...', CR, LF, 0
 bailmsg                equ err_bootfailed
@@ -2546,5 +2546,4 @@ EndOfGetCBuf      dw getcbuf+trackbufsize ; = getcbuf+BufSafeBytes
 %error trackbufsize must be a multiple of TFTP_BLOCKSIZE
 %endif
 %endif
-IPAppend       db 0                    ; Default IPAPPEND option
 DHCPMagic      db 0                    ; DHCP site-specific option info
index 356c289..75968f6 100644 (file)
@@ -183,6 +183,19 @@ LABEL label
                The "kernel" doesn't have to be a Linux kernel; it can
                be a boot sector or a COMBOOT file (see below.)
 
+  LINUX image                  - Linux kernel image (default)
+  BOOT image                   - Bootstrap program (.bs, .0, .bin)
+  BSS image                    - BSS image (.bss)
+  FDIMAGE image                        - Floppy disk image (.img)
+  COMBOOT image                        - COMBOOT program (.com, .cbt)
+  COM32 image                  - COM32 program (.c32)
+  CONFIG image                 - New configuration file
+       Using one of these keywords instead of KERNEL forces the
+       filetype, regardless of the filename.
+
+       CONFIG means restart the boot loader using a different
+       configuration file.
+
   APPEND -
         Append nothing.  APPEND with a single hyphen as argument in a
         LABEL section can be used to override a global APPEND.
@@ -501,6 +514,10 @@ file by adding extensions in the order listed above if the plain
 filename is not found.  Filenames in KERNEL statements must be fully
 qualified.
 
+If this is specified with one of the keywords LINUX, BOOT, BSS,
+FDIMAGE, COMBOOT, COM32, or CONFIG instead of KERNEL, the filetype is
+considered to be the one specified regardless of the filename.
+
 
       ++++ BOOTING DOS (OR OTHER SIMILAR OPERATING SYSTEMS) ++++
 
diff --git a/ui.inc b/ui.inc
index 6ea3a4a..ab39567 100644 (file)
--- a/ui.inc
+++ b/ui.inc
 ;
 ; This file should be entered with the config file open (for getc)
 ;
+load_config_file:
                call parse_config               ; Parse configuration file
 no_config_file:
+
 ;
 ; Check whether or not we are supposed to display the boot prompt.
 ;
@@ -277,6 +279,9 @@ vk_check:
 %endif
                xor bx,bx                       ; Try only one version
 
+               mov al, [VKernelBuf+vk_type]
+               mov [KernelType], al
+
 %if IS_PXELINUX || IS_ISOLINUX
                ; Is this a "localboot" pseudo-kernel?
 %if IS_PXELINUX
@@ -312,6 +317,9 @@ vk_check:
                 pop di
                 pop si
                 pop es
+
+               mov [KernelType], cl            ; CL == 0 here
+
 ;
 ; Find the kernel on disk
 ;
@@ -503,9 +511,14 @@ kernel_good:
 %endif
 
 ;
-; At this point, DX:AX contains the size of the kernel, and SI contains
-; the file handle/cluster pointer.
+; At this point, DX:AX contains the size of the kernel, SI contains
+; the file handle/cluster pointer, and ECX contains the extension (if any.)
 ;
+               mov di,[KernelType]
+               add di,di
+               jmp [kerneltype_table+di]
+
+is_unknown_filetype:
                or ecx,20202000h                ; Force lower case (except dot)
 
                cmp ecx,'.com'
@@ -536,6 +549,43 @@ kernel_good:
                je is_bootsector
 %endif
                ; Otherwise Linux kernel
+               jmp is_linux_kernel
+
+is_config_file:
+               call openfd
+               call reset_config
+               jmp load_config_file
+
+; This is an image type we can't deal with
+is_bad_image:
+               mov si,err_badimage
+               call cwritestr
+               jmp enter_command
+
+%if IS_SYSLINUX || IS_MDSLINUX
+               ; ok
+%else
+is_bss_sector  equ is_bad_image
+%endif
+%if IS_ISOLINUX
+               ; ok
+%else
+is_disk_image  equ is_bad_image
+%endif
+
+               section .data
+err_badimage   db 'Invalid image type for this media type!', CR, LF, 0
+
+               align 2, db 0
+kerneltype_table:
+               dw is_unknown_filetype  ; VK_KERNEL
+               dw is_linux_kernel      ; VK_LINUX
+               dw is_bootsector        ; VK_BOOT
+               dw is_bss_sector        ; VK_BSS
+               dw is_disk_image        ; VK_FDIMAGE
+               dw is_comboot_image     ; VK_COMBOOT
+               dw is_com32_image       ; VK_COM32
+               dw is_config_file       ; VK_CONFIG
 
                section .bss
                alignb 4
@@ -545,5 +595,6 @@ KernelExtPtr        resw 1                  ; During search, final null pointer
 CmdOptPtr       resw 1                 ; Pointer to first option on cmd line
 KbdFlags       resb 1                  ; Check for keyboard escapes
 FuncFlag       resb 1                  ; Escape sequences received from keyboard
+KernelType     resb 1                  ; Kernel type, from vkernel, if known
 
                section .text
diff --git a/version b/version
index f606beb..a2b1f51 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-3.31
+3.40