Workaround for VMware console bug; make more common code common
authorH. Peter Anvin <hpa@zytor.com>
Thu, 21 Jun 2007 00:08:23 +0000 (17:08 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 21 Jun 2007 00:08:23 +0000 (17:08 -0700)
bootsect.inc
cleanup.inc [new file with mode: 0644]
extlinux.asm
isolinux.asm
ldlinux.asm
pxelinux.asm
runkernel.inc
ui.inc

index 3a5fd1b..6989956 100644 (file)
@@ -108,6 +108,7 @@ replace_bootstrap:
                ; Prepare for shutting down
                ;
                call vgaclearmode
+               call cleanup_hardware
 
                ;
                ; Set up initial stack frame (not used by PXE if keeppxe is
diff --git a/cleanup.inc b/cleanup.inc
new file mode 100644 (file)
index 0000000..3685a01
--- /dev/null
@@ -0,0 +1,49 @@
+;; -----------------------------------------------------------------------
+;;   
+;;   Copyright 2007 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
+;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+;;   Boston MA 02111-1307, USA; either version 2 of the License, or
+;;   (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; cleanup.inc
+;;
+;; Some final tidying before jumping to a kernel or bootsector
+;;
+
+;
+; cleanup_hardware:
+;
+;      Shut down anything transient.  *No segment assumptions*.
+;      Can trash any registers.
+;
+cleanup_hardware:
+
+;
+; Linux wants the floppy motor shut off before starting the kernel,
+; at least bootsect.S seems to imply so.  If we don't load the floppy
+; driver, this is *definitely* so!
+;
+               xor ax,ax
+               xor dx,dx
+               int 13h
+
+; Vmware crashes if we scroll in the decompressor!  Try to detect vmware
+; and if it is Vmware, clear the screen...
+               mov eax,'VMXh'
+               xor ebx, ebx
+               mov ecx, 10             ; Get version
+               mov dx, 'VX'
+               in eax, dx
+               cmp ebx, 'VMXh'
+               jne .no_vmware
+
+               mov ax,0x0003           ; Set mode (clear screen/home cursor)
+               int 10h
+.no_vmware:
+               ret
index e5c89ba..c43a051 100644 (file)
@@ -862,24 +862,6 @@ load_config:
 %include "ui.inc"
 
 ;
-; 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"
-
-
-;
 ; getlinsec_ext: same as getlinsec, except load any sector from the zero
 ;               block as all zeros; use to load any data derived
 ;               from an ext2 block pointer, i.e. anything *except the
@@ -909,11 +891,6 @@ getlinsec_ext:
                ret
 
 ;
-; Abort loading code
-;
-%include "abort.inc"
-
-;
 ; allocate_file: Allocate a file structure
 ;
 ;              If successful:
index f9e8741..68aea24 100644 (file)
@@ -945,23 +945,6 @@ load_config:
 %include "ui.inc"
 
 ;
-; 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"
-
-;
 ; Enable disk emulation.  The kind of disk we emulate is dependent on the size of
 ; the file: 1200K, 1440K or 2880K floppy, otherwise harddisk.
 ;
@@ -1133,11 +1116,6 @@ local_boot:
                jmp kaboom                      ; If we returned, oh boy...
 
 ;
-; Abort loading code
-;
-%include "abort.inc"
-
-;
 ; close_file:
 ;           Deallocates a file structure (pointer in SI)
 ;           Assumes CS == DS.
index 5a5216f..8fbf0a3 100644 (file)
@@ -926,28 +926,6 @@ getfattype:
 %include "ui.inc"
 
 ;
-; 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"
-
-;
 ; allocate_file: Allocate a file structure
 ;
 ;              If successful:
index 003d910..3bcb372 100644 (file)
@@ -823,12 +823,6 @@ config_scan:
 .success:
 
 ;
-; Now we have the config file open.  Parse the config file and
-; run the user interface.
-;
-%include "ui.inc"
-
-;
 ; Linux kernel loading code is common.  However, we need to define
 ; a couple of helper macros...
 ;
@@ -858,19 +852,11 @@ config_scan:
                call unload_pxe
 %endmacro
 
-%include "runkernel.inc"
-
-;
-; COMBOOT-loading code
-;
-%include "comboot.inc"
-%include "com32.inc"
-%include "cmdline.inc"
-
 ;
-; Boot sector loading code
+; Now we have the config file open.  Parse the config file and
+; run the user interface.
 ;
-%include "bootsect.inc"
+%include "ui.inc"
 
 ;
 ; Boot to the local disk by returning the appropriate PXE magic.
@@ -895,11 +881,6 @@ local_boot:
                retf                            ; Return to PXE
 
 ;
-; Abort loading code
-;
-%include "abort.inc"
-
-;
 ; kaboom: write a message and bail out.  Wait for quite a while,
 ;        or a user keypress, then do a hard reboot.
 ;
index 1ba620e..66304af 100644 (file)
@@ -454,16 +454,8 @@ root_not_floppy:
                mov [cs:fdctab],word linux_fdctab ; Save new floppy tab pos
                mov [cs:fdctab+2],es
 %endif
-;
-; Linux wants the floppy motor shut off before starting the kernel,
-; at least bootsect.S seems to imply so.  If we don't load the floppy
-; driver, this is *definitely* so!
-;
-kill_motor:
-               xor ax,ax
-               xor dx,dx
-               int 13h
 
+               call cleanup_hardware
 ;
 ; If we're debugging, wait for a keypress so we can read any debug messages
 ;
diff --git a/ui.inc b/ui.inc
index 189b599..25822ad 100644 (file)
--- a/ui.inc
+++ b/ui.inc
@@ -625,3 +625,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"