LDLINUX: Fix "kaboom" bug when booting off hard disk
authorhpa <hpa>
Fri, 25 Oct 2002 06:47:20 +0000 (06:47 +0000)
committerhpa <hpa>
Fri, 25 Oct 2002 06:47:20 +0000 (06:47 +0000)
Provide an API call for "perform final cleanup"

comboot.doc
comboot.inc
ldlinux.asm

index 2f5f247..f427246 100644 (file)
@@ -292,6 +292,10 @@ AX=0007h   Read file
        aligned.  SYSLINUX guarantees at least this alignment for the
        COMBOOT load segment or the COM32 bounce buffer.
 
+       Keep in mind that a "file" may be a TFTP connection, and that
+       leaving a file open for an extended period of time may result
+       in a timeout.
+
        WARNING: Calling this function with an invalid file handle
        will probably crash the system.
 
@@ -377,3 +381,34 @@ AX=000Bh   Get Serial Console Configuration
 
        If no serial port is configured, DX will be set to 0 and the
        other registers are undefined.
+
+
+AX=000Ch       Perform final cleanup
+       Input:  AX      000Ch
+               DX      derivative-specific flags (0000h = clean up all)
+       Output: None
+
+       This routine performs any "final cleanup" the boot loader
+       would normally perform before loading a kernel, such as
+       unloading the PXE stack in the case of PXELINUX.  AFTER
+       INVOKING THIS CALL, NO OTHER API CALLS MAY BE INVOKED, NOR MAY
+       THE PROGRAM TERMINATE AND RETURN TO THE BOOT LOADER.  This
+       call basically tells the boot loader "get out of the way, I'll
+       handle it from here."  The boot loader will continue to
+       provide interrupt and BIOS call thunking services as long its
+       memory areas (0x1000-0xffff, 0x100000-0x100fff) are not
+       overwritten.  MAKE SURE TO DISABLE INTERRUPTS BEFORE
+       OVERWRITING THESE MEMORY AREAS.
+
+       The permissible values for DX are as follows:
+
+       SYSLINUX:       0000h   Normal cleanup
+
+       PXELINUX:       0000h   Normal cleanup
+                       0003h   Keep UNDI and PXE stacks loaded
+
+       ISOLINUX:       0000h   Normal cleanup
+
+       All other values are undefined, and may have different
+       meanings in future versions of SYSLINUX.
+
index d7b03a7..15b25fc 100644 (file)
@@ -479,6 +479,27 @@ comapi_serialcfg:
                ret
 
 ;
+; INT 22h AX=000Ch     Perform final cleanup
+;
+comapi_cleanup:
+%if IS_PXELINUX
+               ; Unload PXE if requested
+               test dl,3
+               setnz [KeepPXE]
+               call unload_pxe
+%elif IS_SYSLINUX
+               ; Restore original FDC table
+               mov eax,[OrigFDCTabPtr]
+               mov [fdctab],eax
+%endif
+               ; Reset the floppy disk subsystem
+               xor ax,ax
+               xor dx,dx
+               int 13h
+               clc
+               ret
+
+;
 ; This stuff should really be in the data section...
 ;
 %macro                 int21 2
@@ -513,6 +534,7 @@ int22_table:
                dw comapi_pxecall               ; 0009 call PXE stack
                dw comapi_derinfo               ; 000A derivative-specific info
                dw comapi_serialcfg             ; 000B get serial port config
+               dw comapi_cleanup               ; 000C perform final cleanup
 int22_count    equ ($-int22_table)/2
 
 APIKeyWait     db 0
index 7380330..6de92f1 100644 (file)
@@ -294,8 +294,6 @@ start:
                mov ds,ax               ; Now we can initialize DS...
 
                mov [di+bsDriveNumber-FloppyTable],dl
-               and dl,dl               ; If floppy disk (00-7F), assume no
-               js harddisk             ; partition table
 ;
 ; 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
@@ -308,6 +306,14 @@ start:
                lfs si,[bx]             ; FS:SI -> original fdctab
                push fs                 ; Save on stack in case we need to bail
                push si
+
+               ; Save the old fdctab even if hard disk so the stack layout
+               ; is the same.  The instructions above do not change the flags
+               and dl,dl               ; If floppy disk (00-7F), assume no
+                                       ; partition table
+               js harddisk
+
+floppy:
                mov cl,6                ; 12 bytes (CX == 0)
                ; es:di -> FloppyTable already
                ; This should be safe to do now, interrupts are off...