; Prepare for shutting down
;
call vgaclearmode
+ call cleanup_hardware
;
; Set up initial stack frame (not used by PXE if keeppxe is
--- /dev/null
+;; -----------------------------------------------------------------------
+;;
+;; 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
%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
ret
;
-; Abort loading code
-;
-%include "abort.inc"
-
-;
; allocate_file: Allocate a file structure
;
; If successful:
%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.
;
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.
%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:
.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...
;
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.
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.
;
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
;
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"