cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;; @file
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Bootsector for grub chainloading that shutdowns the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Copyright (C) 2007-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; available from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; you can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; General Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; The contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; of the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; VirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; CDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; You may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; terms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncBITS 16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncstart:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Start with a jump just to follow the convention.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp short the_code
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync nop
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctimes 3ah db 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncthe_code:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cli
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Boch shutdown request - write "Shutdown" byte by byte to port 08900h.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov cx, 64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dx, 08900h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncretry:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'S'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'h'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'u'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 't'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'd'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'o'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'w'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, 'n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync out dx, al
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync loop retry
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Shutdown failed!
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;; @todo print some message before halting.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hlt
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Padd the remainder of the sector with zeros and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; end it with the dos signature.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncpadding:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctimes 510 - (padding - start) db 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 055h, 0aah
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync