Copy the partition info for the benefit of foreign boot sectors. Document
authorhpa <hpa>
Thu, 7 May 1998 01:33:33 +0000 (01:33 +0000)
committerhpa <hpa>
Thu, 7 May 1998 01:33:33 +0000 (01:33 +0000)
1024 cyl and 65536 track limit.  The latter should be fixed, sometime.

ldlinux.asm
syslinux.doc

index 47d1666..ae81010 100644 (file)
@@ -301,6 +301,7 @@ FKeyName    resb 10*16              ; File names for F-key help
 NumBuf         resb 16                 ; Buffer to load number
 NumBufEnd      equ NumBuf+15           ; Pointer to last byte in NumBuf
                alignb 4
+PartInfo       resb 16                 ; Partition table entry
 InitRDat       resd 1                  ; Load address (linear) for initrd
 HiLoadAddr      resd 1                 ; Address pointer for high load loop
 KernelName      resb 12                        ; Mangled name for kernel
@@ -400,19 +401,24 @@ superblock_len    equ $-superblock
 
 start:
                cli                     ; No interrupts yet, please
+               cld                     ; Copy upwards
 ;
 ; Set up the stack
 ;
-               xor ax,ax
-               mov ss,ax
+               xor cx,cx
+               mov ss,cx
                mov sp,StackBuf         ; Just below BSS
+               mov es,cx
 ;
 ; DS:SI may contain a partition table entry.  Preserve it for us.
 ;
-               mov dh,[si]             ; "Active flag" (sanity check)
-               mov bp,[si+8]           ; LSW of linear offset
-               mov bx,[si+10]          ; MSW of linear offset
-
+;              mov dh,[si]             ; "Active flag" (sanity check)
+;              mov bp,[si+8]           ; LSW of linear offset
+;              mov bx,[si+10]          ; MSW of linear offset
+               mov cl,8                ; Save partition info (CH == 0)
+               mov di,PartInfo
+               rep movsw
+;
 ; Now sautee the BIOS floppy info block to that it will support decent-
 ; size transfers; the floppy block is 11 bytes and is stored in the
 ; INT 1Eh vector (brilliant waste of resources, eh?)
@@ -421,8 +427,9 @@ start:
 ; had to waste precious boot sector space with this code.
 ;
 ; This code no longer fits.  Hope that noone really needs it anymore.
-; In fact, some indications is that this code does more harm than good
-; with all the new kinds of drives and media.
+; (If so, it needs serious updating.)  In fact, some indications is that
+; this code does more harm than good with all the new kinds of drives and
+; media.
 ;
 %ifdef SUPPORT_REALLY_BROKEN_BIOSES
                lds si,[ss:fdctab]      ; DS:SI -> original
@@ -441,7 +448,7 @@ start:
                mov [fdctab+2],ax       ; Segment 0
                mov [fdctab],di         ; offset floppy_block
 %else
-               mov ds,ax
+               mov ds,cx               ; CX == 0
 %endif
 ;
 ; Ready to enable interrupts, captain
@@ -454,21 +461,27 @@ start:
 ;
 ; Would it be better to zero out bsHidden if we don't have a partition table?
 ;
-               push dx
+; Note: di points to beyond the end of PartInfo
+;
                mov [bsDriveNumber],dl
                test dl,80h             ; If floppy disk (00-7F), assume no
                jz not_harddisk         ; partition table
-               test dh,7Fh             ; Sanity check: "active flag" should
+               test byte [di-16],7Fh   ; Sanity check: "active flag" should
                jnz no_partition        ; be 00 or 80
-               mov [bsHidden1],bp
-               mov [bsHidden2],bx
+               lea si,[di-8]
+               mov di,bsHidden1
+               mov cl,2                ; CH == 0
+               rep movsw
+;              mov [bsHidden1],bp
+;              mov [bsHidden2],bx
 no_partition:
 ;
 ; Get disk drive parameters (don't trust the superblock.)  Don't do this for
-; floppy drives -- INT 13:08 on floppy drives will return info about what the
-; *drive* supports, not about the *media*...
+; floppy drives -- INT 13:08 on floppy drives will (may?) return info about
+; what the *drive* supports, not about the *media*.  Fortunately floppy disks
+; tend to have a fixed, well-defined geometry which is stored in the superblock.
 ;
-               pop dx                  ; Restore DL = drive #
+               ; DL == drive # still
                mov ah,08h
                int 13h
                jc no_driveparm
@@ -487,8 +500,8 @@ not_harddisk:
 ; wasting precious boot sector space again...
 ;
 debugentrypt:
-               xor ax,ax               ; INT 13:08 destroys ES
-               mov es,ax               ; so we clear it this late
+               push ss
+               pop es
                mov al,[bsFATs]         ; Number of FATs (AH == 0)
                jc kaboom               ; If the floppy init failed
                mul word [bsFATsecs]    ; Get the size of the FAT area
@@ -641,6 +654,9 @@ getonesec:
 ;           mov bp,1 ; nop ... (BD 01 00 90 90...) when installing with
 ;           the -s option.
 ;
+; BUG ALERT: We can have up to 2^18 tracks (1024 cylinders*256 heads), but the
+; first divide only allows for 2^16-1.
+;
 getlinsec:
                mov si,[bsSecPerTrack]
                div si                  ; Convert linear to sector/track
@@ -1494,14 +1510,10 @@ not_vk:         pop ds
 ;
 ; Find the kernel on disk
 ;
-get_kernel:     mov eax,[KernelName+8]         ; Save initial extension
+get_kernel:     mov byte [KernelName+11],0     ; Zero-terminate filename/extension
+               mov eax,[KernelName+8]          ; Save initial extension
                mov [OrigKernelExt],eax
 .search_loop:  push bx
-               mov si,KernelName
-                mov di,KernelCName
-                call unmangle_name              ; Get human form
-                sub di,KernelCName
-                mov [KernelCNameLen],di
                 mov di,KernelName              ; Search on disk
                 call searchdir
                pop bx
@@ -1510,9 +1522,14 @@ get_kernel:     mov eax,[KernelName+8]           ; Save initial extension
                mov [KernelName+8],eax
                sub bx,byte 4
                jnb .search_loop
-bad_kernel:     mov si,err_notfound            ; Complain about missing kernel
+bad_kernel:     
+               mov si,KernelName
+                mov di,KernelCName
+               push di
+                call unmangle_name              ; Get human form
+               mov si,err_notfound             ; Complain about missing kernel
                call writestr
-                mov si,KernelCName
+               pop si                          ; KernelCName
                 call writestr
                 mov si,crlf
                 jmp abort_load                  ; Ask user for clue
@@ -1569,8 +1586,15 @@ kernel_corrupt: mov si,err_notkernel
 ; Anything else is assumed to be a Linux kernel.
 ;
 kernel_good:
+               pusha
+               mov si,KernelName
+                mov di,KernelCName
+                call unmangle_name              ; Get human form
+                sub di,KernelCName
+                mov [KernelCNameLen],di
+               popa
+
                mov ecx,[KernelName+8]          ; Get (mangled) extension
-               and ecx,00ffffffh               ; 3 bytes
                cmp ecx,'COM'
                je near is_comboot_image
                cmp ecx,'CBT'
@@ -2043,6 +2067,8 @@ is_comboot_image:
                rep stosd
 
                mov word [es:0], 020CDh ; INT 20h instruction
+               ; First non-free paragraph
+               mov word [es:02h], comboot_seg+1000h
 
                ; Copy the command line from high memory
                mov cx,125              ; Max cmdline len (minus space and CR)
@@ -2113,9 +2139,13 @@ is_bss_sector:
 load_bootsec:
                and dx,dx
                jnz bad_bootsec
-               cmp ax,[bsBytesPerSec]
+               mov bx,[bsBytesPerSec]
+               cmp ax,bx
                jne bad_bootsec
 
+               ; Make sure we don't test this uninitialized
+               mov [bx+trackbuf-2],dx  ; Note DX == 0
+
                mov bx,trackbuf
                mov cx,1                ; 1 cluster >= 1 sector
                call getfssec
@@ -2139,9 +2169,14 @@ load_bootsec:
                mov si,trackbuf
                mov di,bootsec
                mov cx,[bsBytesPerSec]
-               rep movsb
+               rep movsb               ; Copy the boot sector!
                
-               xor si,si               ; BUG: should point to partition info
+               mov si,PartInfo
+               mov di,800h-18          ; Put partition info here
+               push di
+               mov cx,8                ; 16 bytes
+               rep movsw
+               pop si                  ; DS:SI points to partition info
 
                jmp bootsec
 
@@ -2393,6 +2428,12 @@ ac_ret:         popa
 ;           larger chunks than a sector at a time (which is probably
 ;           a waste of coding effort, but I like to do things right).
 ;
+;           FIXME: usually we can load the entire root dir in memory,
+;           and files are usually at the beginning anyway.  It probably
+;           would be worthwhile to remember if we have the first chunk
+;           in memory and skip the load if that (it would speed up online
+;           help, mainly.)
+;
 ;           NOTE: This file considers finding a zero-length file an
 ;           error.  This is so we don't have to deal with that special
 ;           case elsewhere in the program (most loops have the test
index 20af2ed..7faeb62 100644 (file)
@@ -1,6 +1,6 @@
                               SYSLINUX
-                            Version 1.37
-                           April 20, 1998
+                            Version 1.40
+                             May 6, 1998
 
               A bootloader for Linux using MS-DOS floppies
 
@@ -97,13 +97,13 @@ APPEND options...
         them.  This is the equivalent of the LILO "append" option.
 
 LABEL label
-  KERNEL kernel
+  KERNEL image
   APPEND options...
         Indicates that if "label" is entered as the kernel to boot,
-        SYSLINUX should instead boot "kernel", and the specified APPEND
+        SYSLINUX should instead boot "image", and the specified APPEND
         options should be used instead of the ones specified in the
         global section of the file (before the first LABEL command.)
-        The default for "kernel" is the same as "label", and if no
+        The default for "image" is the same as "label", and if no
         APPEND is given the default is to use the global entry (if any).
         Up to 128 LABEL entries are permitted.
 
@@ -117,10 +117,13 @@ LABEL label
           kernel mykernel
           append myoptions
 
-       Note  Labels are mangled as if they were DOS filenames, and must be
+       Notes:  Labels are mangled as if they were DOS filenames, and must be
                unique after mangling.  For example, two labels
                "v2.1.30" and "v2.1.31" will not be distinguishable.
 
+               The "image" doesn't have to be a Linux kernel; it can
+               be a boot sector or a COMBOOT file (see below.)
+
   APPEND -
         Append nothing.  APPEND with a single hyphen as argument in a
         LABEL section can be used to override a global APPEND.
@@ -195,16 +198,6 @@ Note that the configuration file is not completely decoded.  Syntax
 different from the one described above may still work correctly in this
 version of SYSLINUX, but may break in a future one.
 
-The following combinations of options can be used to mimic the behaviour
-of SYSLINUX 1.0 with LINUXMSG.TXT or BOOTMSG.TXT present, respectively:
-
-# Mimic SYSLINUX 1.0 with LINUXMSG.TXT file present:
-display linuxmsg.txt
-prompt 1
-
-# Mimic SYSLINUX 1.0 with BOOTMSG.TXT file present:
-display bootmsg.txt
-
    ++++ LARGE KERNELS AND INITIAL RAMDISK SUPPORT ++++
 
 This version of SYSLINUX supports large kernels (bzImage format),
@@ -266,6 +259,102 @@ are interpreted:
 <SUB>                                   <SUB> = <Ctrl-Z> = ASCII 26
         End of file (DOS convention).
 
+   ++++ COMBOOT IMAGES AND OTHER OPERATING SYSTEMS ++++
+
+This version of SYSLINUX supports chain loading of other operating
+systems (such as MS-DOS and its derivatives, including Windows 95/98),
+as well as COMBOOT-style standalone executables (a subset of DOS .COM
+files; see separate section below.)
+
+Chain loading requires the boot sector of the foreign operating system
+to be stored in a file in the root directory of the filesystem.
+Because neither Linux kernels, boot sector images, nor COMBOOT files
+have reliable magic numbers, SYSLINUX will look at the file
+extension.  The following extensions are recognized:
+
+       none or other   Linux kernel image
+       .CBT            COMBOOT image (not runnable from DOS)
+       .BSS            Boot sector (DOS superblock will be patched in)
+       .BS             Boot sector
+       .COM            COMBOOT image (runnable from DOS)
+
+For filenames given on the command line, SYSLINUX will search for the
+file by adding extensions in the order listed above if the plain
+filename is not found.  Filenames in KERNEL statements must be fully
+qualified.
+
+   ++++ BOOTING DOS ++++
+
+This is the recommended procedure for creating a SYSLINUX disk that
+can boot either DOS or Linux.  This example assumes the drive is A: in
+DOS and /dev/fd0 in Linux; for other drives, substitute the
+appropriate drive designator.
+
+1. Make a DOS bootable disk.  This can be done either by specifying
+   the /s option when formatting the disk in DOS, or by running the
+   DOS command SYS:
+
+       format a: /s
+   or
+       sys a:
+
+2. Boot Linux.  Copy the DOS boot sector from the disk into a file:
+
+       dd if=/dev/fd0 of=dos.bss bs=512 count=1
+
+3. Run SYSLINUX on the disk:
+
+       syslinux /dev/fd0
+
+4. Mount the disk and copy the DOS boot sector file to it.  The file
+   *must* have extension .bss:
+
+       mount -t msdos /dev/fd0 /mnt
+       cp dos.bss /mnt
+
+5. Copy the Linux kernel image(s), initrd(s), etc to the disk, and
+   create/edit syslinux.cfg and help files if desired:
+
+       cp vmlinux /mnt
+       cp initrd.gz /mnt
+
+6. Unmount the disk.
+
+       umount /mnt
+
+   ++++ COMBOOT EXECUTABLES ++++
+
+A COMBOOT file is a standalone executable in DOS .COM format.  They
+can, among other things, be produced by the Etherboot package by
+Markus Gutschke and Ken Yap.  The following requirements apply for
+these files to be sufficiently "standalone" for SYSLINUX to be able to
+load and run them:
+
+  * The program must not execute any DOS calls (since there is no
+    DOS), although it may call the BIOS.  The only exception is that
+    the program may execute INT 20h (Terminate Program) to return to
+    the SYSLINUX prompt.  Note especially that INT 21h AH=4Ch, INT 21h
+    AH=31h or INT 27h are *not* supported.
+  * Only the following fields in the PSP are supported:
+    - pspInt20 at offset 00h;
+    - pspNextParagraph at offset 02h;
+    - pspCommandTail at offset 80h (contains the arguments from the
+      SYSLINUX command line).
+
+    All other fields will contain zero.
+  * The program must not modify any main memory outside its 64K
+    segment if it returns to SYSLINUX via INT 20h.
+
+SYSLINUX requires that COMBOOT files end in ".COM" or ".CBT".  Files
+ending in .COM can be run from the DOS command line, files ending in
+.CBT cannot, otherwise there is no difference.  SYSLINUX will prefer a
+.CBT file over a similarly named .COM.
+
+SYSLINUX currently doesn't provide any form of API for the use of
+COMBOOT files.  If there is need, a future version may contain an INT
+interface to some SYSLINUX functions; please contact me if you have a
+need or ideas for such an API.
+
    ++++ NOVICE PROTECTION ++++
 
 SYSLINUX will attempt to detect if the user is trying to boot on a 286
@@ -290,7 +379,7 @@ BIOSes are very buggy when it comes to booting CD-ROMs.  Some users
 have reported that the following steps are helpful in making a CD-ROM
 that is bootable on the largest possible number of machines:
 
-       a) Use the -s (slow and stupid) option to SYSLINUX;
+       a) Use the -s (safe, slow and stupid) option to SYSLINUX;
        b) Put the boot image as close to the beginning of the
           ISO 9660 filesystem as possible.
 
@@ -316,6 +405,24 @@ Then use the FDISK command to mark the appropriate partition active.
 SYSLINUX, like DOS, requires that the partition which contains it
 lives entirely below cylinder 1024 for proper operation.
 
+   ++++ COMPATIBILITY WITH SYSLINUX 1.0 ++++
+
+The following combinations of options can be used to mimic the behaviour
+of SYSLINUX 1.0 with LINUXMSG.TXT or BOOTMSG.TXT present, respectively:
+
+# Mimic SYSLINUX 1.0 with LINUXMSG.TXT file present:
+display linuxmsg.txt
+prompt 1
+
+# Mimic SYSLINUX 1.0 with BOOTMSG.TXT file present:
+display bootmsg.txt
+
+   ++++ KNOWN BUGS ++++
+
+SYSLINUX will have problems with disks with more than 65536 tracks
+(cylinders * heads) or 1024 cylinders if the filesystem on which
+SYSLINUX is installed extends beyond either of these two maxima.
+
    ++++ BUG REPORTS ++++
 
 I would appreciate hearing of any problems you have with SYSLINUX.  I